UNPKG

react-availability-grid

Version:

React component for selecting time availability across multiple days. Perfect for meeting schedulers and booking systems.

30 lines (27 loc) 1.12 kB
import { Dayjs } from 'dayjs'; export { Dayjs } from 'dayjs'; interface TimeGridProps { selection: Dayjs[]; setSelection: (selection: Dayjs[] | ((prevSelection: Dayjs[]) => Dayjs[])) => void; startDate: Dayjs; endDate: Dayjs; intervalSize?: number; earliestStart: Dayjs; latestEnd: Dayjs; /** * Optional array of allowed time slots. If provided, only these times will be selectable. * If omitted or empty, all future times are allowed. * * IMPORTANT: This prop should be memoized (useMemo) or be a stable reference to avoid * unnecessary re-renders of all cells. * * @example * const allowedTimes = useMemo(() => doctorAvailableSlots, [doctorAvailableSlots]); */ allowedTimes?: Dayjs[]; onSelectionChange?: (selection: Dayjs[]) => void; className?: string; style?: React.CSSProperties; } declare function TimeGrid({ selection, setSelection, startDate, endDate, intervalSize, earliestStart, latestEnd, allowedTimes, onSelectionChange, className, style, }: TimeGridProps): JSX.Element; export { TimeGrid, type TimeGridProps };