Rich scheduling/rules editor powered by @karmaniverous/rrstack
. Use it to define activation windows (spans) and recurring schedules with fine-grained constraints.
Value type: RRStackOptions
(timezone, timeUnit, rules).
Peer dependency: @karmaniverous/rrstack
(install in your app when using this component).
import { useForm } from 'react-hook-form';
import { Form } from 'semantic-ui-react';
import { HookFormRRStack } from '@karmaniverous/hook-form-semantic';
type FormData = {
schedule: {
timezone: string;
timeUnit?: 'ms' | 's';
rules: unknown[];
};
};
export function ScheduleEditor() {
const { control, handleSubmit } = useForm<FormData>({
defaultValues: {
schedule: {
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
timeUnit: 'ms',
rules: [],
},
},
});
return (
<Form onSubmit={handleSubmit(console.log)}>
<HookFormRRStack<FormData>
hookControl={control}
hookName="schedule"
label="Availability"
/>
<Form.Button primary style={{ marginTop: 12 }}>
Save
</Form.Button>
</Form>
);
}
Notes
@karmaniverous/rrstack
as a peer dependency.