API Reference
Complete API reference for @gentleduck/calendar hooks, core functions, and types.
Full prop tables, return types, and type definitions for every export in @gentleduck/calendar.
Hooks
| Export | Description |
|---|---|
| useCalendar | Main calendar hook - state, actions, and prop getters |
| useTimePicker | Time picker hook - spinbutton fields and keyboard input |
| useDateTime | Combined date + time hook |
useAnnouncer | Screen reader announcement hook |
useKeyboard | Keyboard navigation hook |
Core functions
| Export | Description |
|---|---|
| Grid | Grid builder functions - buildCalendarMonth, buildMultiMonth, etc. |
| Selection | Selection logic - selectDay, applySelection |
| Navigation | Navigation functions - navigate, canNavigate |
isDateDisabled | Check if a date is disabled by the current constraints |
isInRange | Check if a date falls within a range |
clampTime | Clamp a time value to min/max bounds |
formatTimeField | Format a single time field for display |
getAmPm | Get the AM/PM value from a time |
incrementField | Increment or decrement a time field by step |
isValidTime | Validate a time value against constraints |
parseTimeInput | Parse raw keyboard input into a time field value |
to12Hour | Convert a 24-hour value to 12-hour format |
to24Hour | Convert a 12-hour value to 24-hour format |
Types
These types are exported from @gentleduck/calendar and used across the API:
| Type | Description |
|---|---|
Adapter.IDateAdapter<TDate> | Interface for pluggable date backends |
Calendar.ICalendarConfig<TDate, M> | Full calendar configuration |
Calendar.ICalendarLocaleConfig | Locale settings (locale tag, week start day, direction, numbering system, calendar) |
Selection.CalendarValue<TDate, M> | Conditional type resolving per selection mode |
Grid.ICalendarDay<TDate> | Day cell with selection/state flags |
Grid.ICalendarWeek<TDate> | Week with weekNumber + 7 days |
Grid.ICalendarMonth<TDate> | Month grid with weeks |
Selection.SelectionMode | 'single' | 'range' | 'multi' |
Selection.ISelectionConstraints<TDate> | Disabled dates and date bounds |
Selection.DateRange<TDate> | { from: TDate, to: TDate | null } |
Navigation.Direction | 'prev' | 'next' |
Navigation.Unit | 'month' | 'year' | 'decade' |
DayProps | Props returned by getDayProps |
GridProps | Props returned by getGridProps |
NavProps | Props returned by getNavProps |
HeaderProps | Props returned by getHeaderProps |
AnnouncerReturn | Return type of useAnnouncer |
KeyboardConfig | Configuration for the keyboard navigation hook |
KeyboardReturn | Return type of useKeyboard |
TimeFieldProps | Props returned by getFieldProps |
Time.ITimeValue | { hour, minute, second? } |
Time.ITimeField | 'hour' | 'minute' | 'second' | 'ampm' |
Time.IHourCycle | '12' | '24' |
Time.ITimePickerConfig | Configuration for the time picker |
UseCalendarConfig | Configuration accepted by useCalendar |
UseCalendarReturn | Return type of useCalendar |
UseTimePickerConfig | Configuration accepted by useTimePicker |
UseTimePickerReturn | Return type of useTimePicker |
UseDateTimeConfig | Configuration accepted by useDateTime |
UseDateTimeReturn | Return type of useDateTime |
Calendar.ViewMode | 'days' | 'months' | 'years' |
Adapter.WeekStartDay | Numeric day used as the first day of the week |
Grid.IDecadeEntry | Entry in the decade view grid |
Grid.IYearEntry | Entry in the year view grid |