@zealakit/chrono-react 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +625 -2
- package/dist/calendar/components.d.ts +346 -0
- package/dist/calendar/components.js +243 -0
- package/dist/calendar/context.d.ts +636 -0
- package/dist/calendar/context.js +21 -0
- package/dist/calendar/index.d.ts +6 -0
- package/dist/calendar/index.js +6 -0
- package/dist/calendar/mini-calendar.d.ts +60 -0
- package/dist/calendar/mini-calendar.js +51 -0
- package/dist/calendar/options.d.ts +4 -0
- package/dist/calendar/options.js +98 -0
- package/dist/calendar/use-calendar.d.ts +340 -0
- package/dist/calendar/use-calendar.js +154 -0
- package/dist/calendar/use-mini-calendar.d.ts +302 -0
- package/dist/calendar/use-mini-calendar.js +56 -0
- package/dist/calendar/utilities.d.ts +9 -0
- package/dist/calendar/utilities.js +8 -0
- package/dist/date/bind-panel.d.ts +30 -0
- package/dist/date/bind-panel.js +125 -0
- package/dist/date/components.d.ts +197 -0
- package/dist/date/components.js +193 -0
- package/dist/date/context.d.ts +34 -0
- package/dist/date/context.js +19 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.js +4 -0
- package/dist/date/options.d.ts +7 -0
- package/dist/date/options.js +91 -0
- package/dist/date/use-date-input.d.ts +43 -0
- package/dist/date/use-date-input.js +138 -0
- package/dist/date/use-date-panel.d.ts +81 -0
- package/dist/date/use-date-panel.js +21 -0
- package/dist/date/utilities.d.ts +4 -0
- package/dist/date/utilities.js +4 -0
- package/dist/datetime/components.d.ts +121 -0
- package/dist/datetime/components.js +164 -0
- package/dist/datetime/context.d.ts +8 -0
- package/dist/datetime/context.js +18 -0
- package/dist/datetime/index.d.ts +4 -0
- package/dist/datetime/index.js +4 -0
- package/dist/datetime/options.d.ts +5 -0
- package/dist/datetime/options.js +99 -0
- package/dist/datetime/use-datetime-input.d.ts +44 -0
- package/dist/datetime/use-datetime-input.js +145 -0
- package/dist/datetime/use-datetime-panel.d.ts +128 -0
- package/dist/datetime/use-datetime-panel.js +60 -0
- package/dist/datetime/utilities.d.ts +4 -0
- package/dist/datetime/utilities.js +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/shared/defined-options.d.ts +18 -0
- package/dist/shared/defined-options.js +9 -0
- package/dist/shared/merge-props.d.ts +9 -0
- package/dist/shared/merge-props.js +31 -0
- package/dist/shared/modifiers.d.ts +7 -0
- package/dist/shared/modifiers.js +6 -0
- package/dist/shared/part.d.ts +10 -0
- package/dist/shared/part.js +9 -0
- package/dist/shared/slot.d.ts +12 -0
- package/dist/shared/slot.js +57 -0
- package/dist/shared/style-properties.d.ts +8 -0
- package/dist/shared/style-properties.js +13 -0
- package/dist/shared/to-react-props.d.ts +11 -0
- package/dist/shared/to-react-props.js +27 -0
- package/dist/time/bind-panel.d.ts +19 -0
- package/dist/time/bind-panel.js +97 -0
- package/dist/time/components.d.ts +183 -0
- package/dist/time/components.js +169 -0
- package/dist/time/context.d.ts +24 -0
- package/dist/time/context.js +19 -0
- package/dist/time/index.d.ts +4 -0
- package/dist/time/index.js +4 -0
- package/dist/time/options.d.ts +5 -0
- package/dist/time/options.js +85 -0
- package/dist/time/use-time-input.d.ts +43 -0
- package/dist/time/use-time-input.js +138 -0
- package/dist/time/use-time-panel.d.ts +37 -0
- package/dist/time/use-time-panel.js +18 -0
- package/dist/time/utilities.d.ts +4 -0
- package/dist/time/utilities.js +4 -0
- package/dist/vendor/core/calendar/availability.d.ts +39 -0
- package/dist/vendor/core/calendar/availability.js +73 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +1396 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.js +363 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +171 -0
- package/dist/vendor/core/calendar/controllers/shared.d.ts +33 -0
- package/dist/vendor/core/calendar/controllers/shared.js +82 -0
- package/dist/vendor/core/calendar/events/agenda-layout.d.ts +21 -0
- package/dist/vendor/core/calendar/events/agenda-layout.js +72 -0
- package/dist/vendor/core/calendar/events/all-day-row.d.ts +22 -0
- package/dist/vendor/core/calendar/events/all-day-row.js +93 -0
- package/dist/vendor/core/calendar/events/background-layout.d.ts +66 -0
- package/dist/vendor/core/calendar/events/background-layout.js +106 -0
- package/dist/vendor/core/calendar/events/index.d.ts +17 -0
- package/dist/vendor/core/calendar/events/index.js +8 -0
- package/dist/vendor/core/calendar/events/month-layout.d.ts +13 -0
- package/dist/vendor/core/calendar/events/month-layout.js +157 -0
- package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
- package/dist/vendor/core/calendar/events/normalize.js +156 -0
- package/dist/vendor/core/calendar/events/now-indicator.d.ts +18 -0
- package/dist/vendor/core/calendar/events/now-indicator.js +19 -0
- package/dist/vendor/core/calendar/events/overflow.d.ts +36 -0
- package/dist/vendor/core/calendar/events/overflow.js +112 -0
- package/dist/vendor/core/calendar/events/sort.d.ts +21 -0
- package/dist/vendor/core/calendar/events/sort.js +35 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +22 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.js +177 -0
- package/dist/vendor/core/calendar/events/types.d.ts +141 -0
- package/dist/vendor/core/calendar/events/types.js +1 -0
- package/dist/vendor/core/calendar/index.d.ts +70 -0
- package/dist/vendor/core/calendar/index.js +37 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +11 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +37 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +122 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +53 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +24 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +43 -0
- package/dist/vendor/core/calendar/interaction/event-focus.d.ts +28 -0
- package/dist/vendor/core/calendar/interaction/event-focus.js +44 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
- package/dist/vendor/core/calendar/interaction/hit-test.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/hit-test.js +26 -0
- package/dist/vendor/core/calendar/interaction/pending.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/pending.js +17 -0
- package/dist/vendor/core/calendar/interaction/pointer.d.ts +21 -0
- package/dist/vendor/core/calendar/interaction/pointer.js +169 -0
- package/dist/vendor/core/calendar/interaction/selection.d.ts +29 -0
- package/dist/vendor/core/calendar/interaction/selection.js +47 -0
- package/dist/vendor/core/calendar/internal/equal.d.ts +3 -0
- package/dist/vendor/core/calendar/internal/equal.js +43 -0
- package/dist/vendor/core/calendar/navigation/navigate.d.ts +33 -0
- package/dist/vendor/core/calendar/navigation/navigate.js +81 -0
- package/dist/vendor/core/calendar/navigation/range.d.ts +15 -0
- package/dist/vendor/core/calendar/navigation/range.js +52 -0
- package/dist/vendor/core/calendar/navigation/title.d.ts +12 -0
- package/dist/vendor/core/calendar/navigation/title.js +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.d.ts +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.js +62 -0
- package/dist/vendor/core/calendar/navigation/zoom.d.ts +5 -0
- package/dist/vendor/core/calendar/navigation/zoom.js +11 -0
- package/dist/vendor/core/calendar/recurrence/apply.d.ts +50 -0
- package/dist/vendor/core/calendar/recurrence/apply.js +206 -0
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
- package/dist/vendor/core/calendar/recurrence/expand.js +298 -0
- package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
- package/dist/vendor/core/calendar/recurrence/pack.js +248 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.js +8 -0
- package/dist/vendor/core/calendar/recurrence/rrule.d.ts +12 -0
- package/dist/vendor/core/calendar/recurrence/rrule.js +278 -0
- package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
- package/dist/vendor/core/calendar/recurrence/series.js +163 -0
- package/dist/vendor/core/calendar/recurrence/types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/types.js +1 -0
- package/dist/vendor/core/calendar/resources/keys.d.ts +2 -0
- package/dist/vendor/core/calendar/resources/keys.js +2 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.js +129 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.js +98 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.js +109 -0
- package/dist/vendor/core/calendar/resources/tree.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/tree.js +86 -0
- package/dist/vendor/core/calendar/resources/types.d.ts +177 -0
- package/dist/vendor/core/calendar/resources/types.js +1 -0
- package/dist/vendor/core/calendar/resources/views.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/views.js +45 -0
- package/dist/vendor/core/calendar/resources/windowing.d.ts +11 -0
- package/dist/vendor/core/calendar/resources/windowing.js +17 -0
- package/dist/vendor/core/calendar/views/day.d.ts +37 -0
- package/dist/vendor/core/calendar/views/day.js +36 -0
- package/dist/vendor/core/calendar/views/list-layout.d.ts +8 -0
- package/dist/vendor/core/calendar/views/list-layout.js +5 -0
- package/dist/vendor/core/calendar/views/mini-calendar.d.ts +23 -0
- package/dist/vendor/core/calendar/views/mini-calendar.js +31 -0
- package/dist/vendor/core/calendar/views/month-layout.d.ts +30 -0
- package/dist/vendor/core/calendar/views/month-layout.js +63 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.d.ts +26 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.js +27 -0
- package/dist/vendor/core/date/index.d.ts +9 -0
- package/dist/vendor/core/date/index.js +9 -0
- package/dist/vendor/core/date/input/date-input-controller.d.ts +97 -0
- package/dist/vendor/core/date/input/date-input-controller.js +466 -0
- package/dist/vendor/core/date/input/date-range-input-controller.d.ts +43 -0
- package/dist/vendor/core/date/input/date-range-input-controller.js +186 -0
- package/dist/vendor/core/date/input/parse.d.ts +22 -0
- package/dist/vendor/core/date/input/parse.js +78 -0
- package/dist/vendor/core/date/input/validity.d.ts +6 -0
- package/dist/vendor/core/date/input/validity.js +13 -0
- package/dist/vendor/core/date/panel/panel-controller.d.ts +176 -0
- package/dist/vendor/core/date/panel/panel-controller.js +704 -0
- package/dist/vendor/core/date/presets.d.ts +22 -0
- package/dist/vendor/core/date/presets.js +103 -0
- package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
- package/dist/vendor/core/date/selection/multiple.js +29 -0
- package/dist/vendor/core/date/selection/range.d.ts +29 -0
- package/dist/vendor/core/date/selection/range.js +35 -0
- package/dist/vendor/core/date/types.d.ts +12 -0
- package/dist/vendor/core/date/types.js +1 -0
- package/dist/vendor/core/datetime/compose.d.ts +24 -0
- package/dist/vendor/core/datetime/compose.js +49 -0
- package/dist/vendor/core/datetime/constraints.d.ts +42 -0
- package/dist/vendor/core/datetime/constraints.js +56 -0
- package/dist/vendor/core/datetime/index.d.ts +9 -0
- package/dist/vendor/core/datetime/index.js +9 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +96 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.js +380 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.d.ts +46 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +171 -0
- package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
- package/dist/vendor/core/datetime/input/parse.js +56 -0
- package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
- package/dist/vendor/core/datetime/panel/controller.js +191 -0
- package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
- package/dist/vendor/core/datetime/panel/range-controller.js +205 -0
- package/dist/vendor/core/datetime/types.d.ts +12 -0
- package/dist/vendor/core/datetime/types.js +1 -0
- package/dist/vendor/core/datetime/zone/day-instants.d.ts +19 -0
- package/dist/vendor/core/datetime/zone/day-instants.js +52 -0
- package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
- package/dist/vendor/core/datetime/zone/resolve.js +24 -0
- package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
- package/dist/vendor/core/dom/auto-scroll.js +57 -0
- package/dist/vendor/core/dom/drag-session.d.ts +25 -0
- package/dist/vendor/core/dom/drag-session.js +257 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +12 -0
- package/dist/vendor/core/foundation/a11y/announcer.js +24 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +76 -0
- package/dist/vendor/core/foundation/a11y/index.d.ts +8 -0
- package/dist/vendor/core/foundation/a11y/index.js +5 -0
- package/dist/vendor/core/foundation/a11y/labels.d.ts +21 -0
- package/dist/vendor/core/foundation/a11y/labels.js +43 -0
- package/dist/vendor/core/foundation/a11y/messages.d.ts +80 -0
- package/dist/vendor/core/foundation/a11y/messages.js +74 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.d.ts +18 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.js +73 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.js +64 -0
- package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
- package/dist/vendor/core/foundation/constraints/availability.js +480 -0
- package/dist/vendor/core/foundation/constraints/date.d.ts +21 -0
- package/dist/vendor/core/foundation/constraints/date.js +41 -0
- package/dist/vendor/core/foundation/constraints/index.d.ts +9 -0
- package/dist/vendor/core/foundation/constraints/index.js +4 -0
- package/dist/vendor/core/foundation/constraints/range.d.ts +44 -0
- package/dist/vendor/core/foundation/constraints/range.js +70 -0
- package/dist/vendor/core/foundation/constraints/time.d.ts +30 -0
- package/dist/vendor/core/foundation/constraints/time.js +56 -0
- package/dist/vendor/core/foundation/grid/index.d.ts +8 -0
- package/dist/vendor/core/foundation/grid/index.js +4 -0
- package/dist/vendor/core/foundation/grid/month-grid.d.ts +33 -0
- package/dist/vendor/core/foundation/grid/month-grid.js +52 -0
- package/dist/vendor/core/foundation/grid/time-axis.d.ts +25 -0
- package/dist/vendor/core/foundation/grid/time-axis.js +32 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.d.ts +17 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.js +26 -0
- package/dist/vendor/core/foundation/grid/year-grid.d.ts +29 -0
- package/dist/vendor/core/foundation/grid/year-grid.js +40 -0
- package/dist/vendor/core/foundation/index.d.ts +8 -0
- package/dist/vendor/core/foundation/index.js +8 -0
- package/dist/vendor/core/foundation/input/form.d.ts +7 -0
- package/dist/vendor/core/foundation/input/form.js +10 -0
- package/dist/vendor/core/foundation/input/index.d.ts +6 -0
- package/dist/vendor/core/foundation/input/index.js +3 -0
- package/dist/vendor/core/foundation/input/segment-engine.d.ts +33 -0
- package/dist/vendor/core/foundation/input/segment-engine.js +45 -0
- package/dist/vendor/core/foundation/input/tokenize.d.ts +19 -0
- package/dist/vendor/core/foundation/input/tokenize.js +24 -0
- package/dist/vendor/core/foundation/locale/digits.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/digits.js +35 -0
- package/dist/vendor/core/foundation/locale/direction.d.ts +1 -0
- package/dist/vendor/core/foundation/locale/direction.js +25 -0
- package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
- package/dist/vendor/core/foundation/locale/format.js +77 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.js +41 -0
- package/dist/vendor/core/foundation/locale/index.d.ts +10 -0
- package/dist/vendor/core/foundation/locale/index.js +8 -0
- package/dist/vendor/core/foundation/locale/names.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/names.js +30 -0
- package/dist/vendor/core/foundation/locale/resolve.d.ts +7 -0
- package/dist/vendor/core/foundation/locale/resolve.js +39 -0
- package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
- package/dist/vendor/core/foundation/locale/week-info.js +60 -0
- package/dist/vendor/core/foundation/locale/zone-label.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/zone-label.js +24 -0
- package/dist/vendor/core/foundation/ranges/date-range.d.ts +18 -0
- package/dist/vendor/core/foundation/ranges/date-range.js +40 -0
- package/dist/vendor/core/foundation/ranges/index.d.ts +4 -0
- package/dist/vendor/core/foundation/ranges/index.js +2 -0
- package/dist/vendor/core/foundation/ranges/interval.d.ts +24 -0
- package/dist/vendor/core/foundation/ranges/interval.js +54 -0
- package/dist/vendor/core/foundation/store/attributes.d.ts +19 -0
- package/dist/vendor/core/foundation/store/attributes.js +43 -0
- package/dist/vendor/core/foundation/store/controllable.d.ts +19 -0
- package/dist/vendor/core/foundation/store/controllable.js +50 -0
- package/dist/vendor/core/foundation/store/env.d.ts +1 -0
- package/dist/vendor/core/foundation/store/env.js +3 -0
- package/dist/vendor/core/foundation/store/ids.d.ts +9 -0
- package/dist/vendor/core/foundation/store/ids.js +12 -0
- package/dist/vendor/core/foundation/store/index.d.ts +11 -0
- package/dist/vendor/core/foundation/store/index.js +7 -0
- package/dist/vendor/core/foundation/store/store.d.ts +7 -0
- package/dist/vendor/core/foundation/store/store.js +25 -0
- package/dist/vendor/core/foundation/store/ticker.d.ts +11 -0
- package/dist/vendor/core/foundation/store/ticker.js +27 -0
- package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
- package/dist/vendor/core/foundation/store/with-optional.js +3 -0
- package/dist/vendor/core/foundation/values/clock.d.ts +4 -0
- package/dist/vendor/core/foundation/values/clock.js +21 -0
- package/dist/vendor/core/foundation/values/compare.d.ts +16 -0
- package/dist/vendor/core/foundation/values/compare.js +70 -0
- package/dist/vendor/core/foundation/values/convert.d.ts +31 -0
- package/dist/vendor/core/foundation/values/convert.js +108 -0
- package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
- package/dist/vendor/core/foundation/values/epoch-day.js +43 -0
- package/dist/vendor/core/foundation/values/index.d.ts +14 -0
- package/dist/vendor/core/foundation/values/index.js +10 -0
- package/dist/vendor/core/foundation/values/iso.d.ts +24 -0
- package/dist/vendor/core/foundation/values/iso.js +111 -0
- package/dist/vendor/core/foundation/values/plain-date-time.d.ts +8 -0
- package/dist/vendor/core/foundation/values/plain-date-time.js +25 -0
- package/dist/vendor/core/foundation/values/plain-date.d.ts +33 -0
- package/dist/vendor/core/foundation/values/plain-date.js +105 -0
- package/dist/vendor/core/foundation/values/plain-time.d.ts +15 -0
- package/dist/vendor/core/foundation/values/plain-time.js +43 -0
- package/dist/vendor/core/foundation/values/types.d.ts +37 -0
- package/dist/vendor/core/foundation/values/types.js +1 -0
- package/dist/vendor/core/foundation/values/week.d.ts +9 -0
- package/dist/vendor/core/foundation/values/week.js +31 -0
- package/dist/vendor/core/foundation/values/year-month.d.ts +10 -0
- package/dist/vendor/core/foundation/values/year-month.js +19 -0
- package/dist/vendor/core/foundation/values/zoned.d.ts +16 -0
- package/dist/vendor/core/foundation/values/zoned.js +152 -0
- package/dist/vendor/core/index.d.ts +5 -0
- package/dist/vendor/core/index.js +5 -0
- package/dist/vendor/core/time/index.d.ts +8 -0
- package/dist/vendor/core/time/index.js +8 -0
- package/dist/vendor/core/time/input/parse.d.ts +19 -0
- package/dist/vendor/core/time/input/parse.js +82 -0
- package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
- package/dist/vendor/core/time/input/time-input-controller.js +547 -0
- package/dist/vendor/core/time/input/time-range-input-controller.d.ts +49 -0
- package/dist/vendor/core/time/input/time-range-input-controller.js +178 -0
- package/dist/vendor/core/time/input/validity.d.ts +7 -0
- package/dist/vendor/core/time/input/validity.js +16 -0
- package/dist/vendor/core/time/panel/time-panel-controller.d.ts +163 -0
- package/dist/vendor/core/time/panel/time-panel-controller.js +809 -0
- package/dist/vendor/core/time/selection/range.d.ts +25 -0
- package/dist/vendor/core/time/selection/range.js +35 -0
- package/dist/vendor/core/time/selection/slots.d.ts +46 -0
- package/dist/vendor/core/time/selection/slots.js +76 -0
- package/dist/vendor/core/time/types.d.ts +11 -0
- package/dist/vendor/core/time/types.js +1 -0
- package/package.json +83 -4
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { mergeProps } from "../shared/merge-props.js";
|
|
5
|
+
import { Part } from "../shared/part.js";
|
|
6
|
+
import { composeRefs } from "../shared/slot.js";
|
|
7
|
+
import { TimeFieldContext, TimePanelContext, useTimeFieldContext, useTimePanelContext, } from "./context.js";
|
|
8
|
+
import { splitTimeInputProps, splitTimePanelProps, splitTimeRangeInputProps, splitTimeRangePanelProps, } from "./options.js";
|
|
9
|
+
import { useTimeInput, useTimeRangeInput } from "./use-time-input.js";
|
|
10
|
+
import { useTimePanel, useTimeRangePanel } from "./use-time-panel.js";
|
|
11
|
+
const withChrono = (consumer, chrono) => mergeProps(consumer, chrono);
|
|
12
|
+
/** Hidden form inputs (plan 06 A15). Rendered on the server too, so forms post without JS. */
|
|
13
|
+
function HiddenInputs({ inputs }) {
|
|
14
|
+
return (_jsx(_Fragment, { children: inputs.map((input) => (_jsx("input", { type: "hidden", name: input.name, value: input.value }, `${input.name}:${input.value}`))) }));
|
|
15
|
+
}
|
|
16
|
+
/** One editable part (day, month or year). */
|
|
17
|
+
export const TimeInputSegment = forwardRef(function TimeInputSegment({ segment, children, asChild, ...rest }, ref) {
|
|
18
|
+
const field = useTimeFieldContext("TimeInputSegment");
|
|
19
|
+
return (_jsx(Part, { as: "span", asChild: asChild, ref: ref, ...withChrono(rest, field.getSegmentProps(segment)), children: children ?? segment.text }));
|
|
20
|
+
});
|
|
21
|
+
/** A separator between parts. Hidden from assistive technology. */
|
|
22
|
+
export const TimeInputLiteral = forwardRef(function TimeInputLiteral({ segment, children, asChild, ...rest }, ref) {
|
|
23
|
+
const field = useTimeFieldContext("TimeInputLiteral");
|
|
24
|
+
return (_jsx(Part, { as: "span", asChild: asChild, ref: ref, ...withChrono(rest, field.getSegmentProps(segment)), children: children ?? segment.text }));
|
|
25
|
+
});
|
|
26
|
+
/** The native text field of `mode="text"`. */
|
|
27
|
+
export const TimeInputTextField = forwardRef(function TimeInputTextField({ asChild, ...rest }, ref) {
|
|
28
|
+
const field = useTimeFieldContext("TimeInputTextField");
|
|
29
|
+
return (_jsx(Part, { as: "input", asChild: asChild, ref: ref, ...withChrono(rest, field.getTextFieldProps()) }));
|
|
30
|
+
});
|
|
31
|
+
export const TimeInputClearButton = forwardRef(function TimeInputClearButton({ children, asChild, ...rest }, ref) {
|
|
32
|
+
const field = useTimeFieldContext("TimeInputClearButton");
|
|
33
|
+
const props = field.getClearButtonProps();
|
|
34
|
+
return (_jsx(Part, { as: "button", asChild: asChild, ref: ref, ...withChrono(rest, props), children: children ?? props["aria-label"] }));
|
|
35
|
+
});
|
|
36
|
+
/** The default content of a field: segments, or the text field. */
|
|
37
|
+
function FieldContent() {
|
|
38
|
+
const { state } = useTimeFieldContext("TimeInput");
|
|
39
|
+
if (state.mode === "text")
|
|
40
|
+
return _jsx(TimeInputTextField, {});
|
|
41
|
+
return (_jsx(_Fragment, { children: state.segments.map((segment, index) => segment.type === "literal" ? (_jsx(TimeInputLiteral, { segment: segment }, index)) : (_jsx(TimeInputSegment, { segment: segment }, segment.type))) }));
|
|
42
|
+
}
|
|
43
|
+
/** A time field: segmented (default) or text. Use `TimeInputSegment` parts for custom layouts. */
|
|
44
|
+
export const TimeInput = forwardRef(function TimeInput({ children, asChild, ...props }, ref) {
|
|
45
|
+
const [options, rest] = splitTimeInputProps(props);
|
|
46
|
+
const input = useTimeInput(definedOptions({
|
|
47
|
+
...options,
|
|
48
|
+
id: props.id,
|
|
49
|
+
}));
|
|
50
|
+
const { ref: rootRef, ...rootProps } = input.getRootProps();
|
|
51
|
+
const { id: _id, ...elementProps } = rest;
|
|
52
|
+
return (_jsx(TimeFieldContext.Provider, { value: input, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [typeof children === "function" ? children(input.state) : (children ?? _jsx(FieldContent, {})), _jsx(HiddenInputs, { inputs: input.state.hidden })] }) }));
|
|
53
|
+
});
|
|
54
|
+
function RangeField({ side, children, asChild, forwardedRef, ...rest }) {
|
|
55
|
+
const range = useRangeContext(side === "start" ? "TimeRangeInputStart" : "TimeRangeInputEnd");
|
|
56
|
+
const field = range[side];
|
|
57
|
+
const { ref: rootRef, ...rootProps } = field.getRootProps();
|
|
58
|
+
return (_jsx(TimeFieldContext.Provider, { value: field, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(forwardedRef, rootRef), ...withChrono(rest, {
|
|
59
|
+
...rootProps,
|
|
60
|
+
role: "group",
|
|
61
|
+
"aria-label": field.state.messages[side === "start" ? "startTime" : "endTime"],
|
|
62
|
+
}), children: typeof children === "function" ? children(field.state) : (children ?? _jsx(FieldContent, {})) }) }));
|
|
63
|
+
}
|
|
64
|
+
import { createContext, useContext } from "react";
|
|
65
|
+
import { definedOptions } from "./../shared/defined-options.js";
|
|
66
|
+
const RangeContext = createContext(null);
|
|
67
|
+
function useRangeContext(part) {
|
|
68
|
+
const value = useContext(RangeContext);
|
|
69
|
+
if (!value) {
|
|
70
|
+
throw new Error(`[chrono-react] <${part}> must be used inside <TimeRangeInput>.`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
export const TimeRangeInputStart = forwardRef(function TimeRangeInputStart(props, ref) {
|
|
75
|
+
return _jsx(RangeField, { side: "start", forwardedRef: ref, ...props });
|
|
76
|
+
});
|
|
77
|
+
export const TimeRangeInputEnd = forwardRef(function TimeRangeInputEnd(props, ref) {
|
|
78
|
+
return _jsx(RangeField, { side: "end", forwardedRef: ref, ...props });
|
|
79
|
+
});
|
|
80
|
+
/** Two time fields (start and end) in one group, in both modes. */
|
|
81
|
+
export const TimeRangeInput = forwardRef(function TimeRangeInput({ children, asChild, ...props }, ref) {
|
|
82
|
+
const [options, rest] = splitTimeRangeInputProps(props);
|
|
83
|
+
const range = useTimeRangeInput(definedOptions({
|
|
84
|
+
...options,
|
|
85
|
+
id: props.id,
|
|
86
|
+
}));
|
|
87
|
+
const { ref: rootRef, ...rootProps } = range.getRootProps();
|
|
88
|
+
const { id: _id, ...elementProps } = rest;
|
|
89
|
+
return (_jsx(RangeContext.Provider, { value: range, children: _jsxs(Part, { as: "div", asChild: asChild, ref: composeRefs(ref, rootRef), ...withChrono(elementProps, rootProps), children: [children ?? (_jsxs(_Fragment, { children: [_jsx(TimeRangeInputStart, {}), _jsx("span", { "aria-hidden": "true", children: "\u2013" }), _jsx(TimeRangeInputEnd, {})] })), _jsx(HiddenInputs, { inputs: range.state.hidden })] }) }));
|
|
90
|
+
});
|
|
91
|
+
/** One time (or slot). Custom content can read `slot.data`. */
|
|
92
|
+
export const TimePanelOption = forwardRef(function TimePanelOption({ option, children, asChild, ...rest }, ref) {
|
|
93
|
+
const panel = useTimePanelContext("TimePanelOption");
|
|
94
|
+
const slot = panel.controller.getSlot(option.key);
|
|
95
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, panel.getOptionProps(option)), children: typeof children === "function" ? children(option, slot) : (children ?? option.text) }));
|
|
96
|
+
});
|
|
97
|
+
/** One column of the columns layout (hour, minute, second, day period). */
|
|
98
|
+
export const TimePanelColumn = forwardRef(function TimePanelColumn({ column, children, asChild, ...rest }, ref) {
|
|
99
|
+
const panel = useTimePanelContext("TimePanelColumn");
|
|
100
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, panel.getColumnProps(column)), children: typeof children === "function"
|
|
101
|
+
? children(column)
|
|
102
|
+
: (children ??
|
|
103
|
+
column.options.map((option) => _jsx(TimePanelOption, { option: option }, option.key))) }));
|
|
104
|
+
});
|
|
105
|
+
export const TimePanelGroup = forwardRef(function TimePanelGroup({ group, children, asChild, ...rest }, ref) {
|
|
106
|
+
const panel = useTimePanelContext("TimePanelGroup");
|
|
107
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, panel.getGroupProps(group)), children: children ??
|
|
108
|
+
group.options.map((option) => _jsx(TimePanelOption, { option: option }, option.key)) }));
|
|
109
|
+
});
|
|
110
|
+
/** The visible label of a group (hidden from the group's own `aria-label`). */
|
|
111
|
+
export const TimePanelGroupLabel = forwardRef(function TimePanelGroupLabel({ children, asChild, ...rest }, ref) {
|
|
112
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...rest, children: children }));
|
|
113
|
+
});
|
|
114
|
+
/** The listbox of the list layout. */
|
|
115
|
+
export const TimePanelList = forwardRef(function TimePanelList({ children, asChild, ...rest }, ref) {
|
|
116
|
+
const panel = useTimePanelContext("TimePanelList");
|
|
117
|
+
const { groups } = panel.state;
|
|
118
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: ref, ...withChrono(rest, panel.getListProps()), children: typeof children === "function"
|
|
119
|
+
? children(groups)
|
|
120
|
+
: (children ??
|
|
121
|
+
groups.map((group) => (_jsxs(TimePanelGroup, { group: group, children: [group.label ? _jsx(TimePanelGroupLabel, { children: group.label }) : null, group.options.map((option) => (_jsx(TimePanelOption, { option: option }, option.key)))] }, group.key)))) }));
|
|
122
|
+
});
|
|
123
|
+
function SetContent({ set }) {
|
|
124
|
+
return (_jsx(_Fragment, { children: set.columns.map((column) => (_jsx(TimePanelColumn, { column: column }, column.key))) }));
|
|
125
|
+
}
|
|
126
|
+
function RangeSet({ side, children, asChild, forwardedRef, ...rest }) {
|
|
127
|
+
const panel = useTimePanelContext(side === "start" ? "TimeRangePanelStart" : "TimeRangePanelEnd");
|
|
128
|
+
const set = panel.state.sets.find((item) => item.key === side);
|
|
129
|
+
if (!set)
|
|
130
|
+
return null;
|
|
131
|
+
return (_jsx(Part, { as: "div", asChild: asChild, ref: forwardedRef, ...withChrono(rest, panel.getSetProps(set)), children: children ?? _jsx(SetContent, { set: set }) }));
|
|
132
|
+
}
|
|
133
|
+
/** The start column set of a range panel in the columns layout. */
|
|
134
|
+
export const TimeRangePanelStart = forwardRef(function TimeRangePanelStart(props, ref) {
|
|
135
|
+
return _jsx(RangeSet, { side: "start", forwardedRef: ref, ...props });
|
|
136
|
+
});
|
|
137
|
+
export const TimeRangePanelEnd = forwardRef(function TimeRangePanelEnd(props, ref) {
|
|
138
|
+
return _jsx(RangeSet, { side: "end", forwardedRef: ref, ...props });
|
|
139
|
+
});
|
|
140
|
+
function PanelContent() {
|
|
141
|
+
const panel = useTimePanelContext("TimePanel");
|
|
142
|
+
const { state } = panel;
|
|
143
|
+
if (state.layout === "list")
|
|
144
|
+
return _jsx(TimePanelList, {});
|
|
145
|
+
return (_jsx(_Fragment, { children: state.sets.map((set) => state.kind === "range" ? (set.key === "start" ? (_jsx(TimeRangePanelStart, {}, set.key)) : (_jsx(TimeRangePanelEnd, {}, set.key))) : (_jsx(SetContent, { set: set }, set.key))) }));
|
|
146
|
+
}
|
|
147
|
+
function PanelRoot({ panel, forwardedRef, asChild, children, rest, }) {
|
|
148
|
+
const { ref: rootRef, ...rootProps } = panel.getRootProps();
|
|
149
|
+
const { id: _id, ...elementProps } = rest;
|
|
150
|
+
return (_jsx(TimePanelContext.Provider, { value: panel, children: _jsx(Part, { as: "div", asChild: asChild, ref: composeRefs(forwardedRef, rootRef), ...withChrono(elementProps, rootProps), children: children ?? _jsx(PanelContent, {}) }) }));
|
|
151
|
+
}
|
|
152
|
+
/** A single-time panel: columns (default) or a list of times or slots. */
|
|
153
|
+
export const TimePanel = forwardRef(function TimePanel({ children, asChild, ...props }, ref) {
|
|
154
|
+
const [options, rest] = splitTimePanelProps(props);
|
|
155
|
+
const panel = useTimePanel(definedOptions({
|
|
156
|
+
...options,
|
|
157
|
+
id: props.id,
|
|
158
|
+
}));
|
|
159
|
+
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, children: children }));
|
|
160
|
+
});
|
|
161
|
+
/** A range panel (two picks): a list (default) or two column sets. */
|
|
162
|
+
export const TimeRangePanel = forwardRef(function TimeRangePanel({ children, asChild, ...props }, ref) {
|
|
163
|
+
const [options, rest] = splitTimeRangePanelProps(props);
|
|
164
|
+
const panel = useTimeRangePanel(definedOptions({
|
|
165
|
+
...options,
|
|
166
|
+
id: props.id,
|
|
167
|
+
}));
|
|
168
|
+
return (_jsx(PanelRoot, { panel: panel, forwardedRef: ref, asChild: asChild, rest: rest, children: children }));
|
|
169
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TimeInputPropGetters } from "./use-time-input.js";
|
|
2
|
+
import type { TimePanelPropGetters } from "./use-time-panel.js";
|
|
3
|
+
export type TimePanelContextValue = TimePanelPropGetters;
|
|
4
|
+
export type TimeFieldContextValue = Pick<TimeInputPropGetters, "state" | "controller" | "getSegmentProps" | "getTextFieldProps" | "getClearButtonProps">;
|
|
5
|
+
export declare const TimePanelContext: import("react").Context<{
|
|
6
|
+
state: import("./use-time-panel.js").TimePanelState;
|
|
7
|
+
controller: import("../vendor/core/time/index.js").TimePanelController<any, any>;
|
|
8
|
+
actions: {
|
|
9
|
+
clear: () => void;
|
|
10
|
+
commit: () => void;
|
|
11
|
+
};
|
|
12
|
+
getRootProps: () => import("../shared/to-react-props.js").ChronoProps & {
|
|
13
|
+
ref: import("react").RefObject<HTMLElement>;
|
|
14
|
+
};
|
|
15
|
+
getSetProps: (set: import("../vendor/core/time/index.js").TimePanelSetState) => import("../shared/to-react-props.js").ChronoProps;
|
|
16
|
+
getColumnProps: (column: import("../vendor/core/time/index.js").TimePanelColumnState) => import("../shared/to-react-props.js").ChronoProps;
|
|
17
|
+
getGroupProps: (group: import("../vendor/core/time/index.js").TimePanelGroupState) => import("../shared/to-react-props.js").ChronoProps;
|
|
18
|
+
getListProps: () => import("../shared/to-react-props.js").ChronoProps;
|
|
19
|
+
getOptionProps: (option: import("../vendor/core/time/index.js").TimePanelOptionState) => import("../shared/to-react-props.js").ChronoProps;
|
|
20
|
+
} | null>;
|
|
21
|
+
export declare const TimeFieldContext: import("react").Context<TimeFieldContextValue | null>;
|
|
22
|
+
/** Internal: parts read their panel from the nearest panel root (no global Provider). */
|
|
23
|
+
export declare function useTimePanelContext(part: string): TimePanelContextValue;
|
|
24
|
+
export declare function useTimeFieldContext(part: string): TimeFieldContextValue;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export const TimePanelContext = createContext(null);
|
|
4
|
+
export const TimeFieldContext = createContext(null);
|
|
5
|
+
/** Internal: parts read their panel from the nearest panel root (no global Provider). */
|
|
6
|
+
export function useTimePanelContext(part) {
|
|
7
|
+
const value = useContext(TimePanelContext);
|
|
8
|
+
if (!value) {
|
|
9
|
+
throw new Error(`[chrono-react] <${part}> must be used inside <TimePanel> or <TimeRangePanel>.`);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function useTimeFieldContext(part) {
|
|
14
|
+
const value = useContext(TimeFieldContext);
|
|
15
|
+
if (!value) {
|
|
16
|
+
throw new Error(`[chrono-react] <${part}> must be used inside <TimeInput> or a <TimeRangeInput> field.`);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TimeInputOptions, TimePanelOptions, TimeRangeInputOptions, TimeRangePanelOptions } from "../vendor/core/time/index.js";
|
|
2
|
+
export declare const splitTimePanelProps: (props: object) => [TimePanelOptions, Record<string, unknown>];
|
|
3
|
+
export declare const splitTimeRangePanelProps: (props: object) => [TimeRangePanelOptions, Record<string, unknown>];
|
|
4
|
+
export declare const splitTimeInputProps: (props: object) => [TimeInputOptions, Record<string, unknown>];
|
|
5
|
+
export declare const splitTimeRangeInputProps: (props: object) => [TimeRangeInputOptions, Record<string, unknown>];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const BASE_PANEL_KEYS = [
|
|
2
|
+
"layout",
|
|
3
|
+
"granularity",
|
|
4
|
+
"hourCycle",
|
|
5
|
+
"step",
|
|
6
|
+
"start",
|
|
7
|
+
"end",
|
|
8
|
+
"slotDuration",
|
|
9
|
+
"slots",
|
|
10
|
+
"groupBy",
|
|
11
|
+
"min",
|
|
12
|
+
"max",
|
|
13
|
+
"disabledRanges",
|
|
14
|
+
"isTimeDisabled",
|
|
15
|
+
"isTimeUnavailable",
|
|
16
|
+
"scrollToSelected",
|
|
17
|
+
"autoFocus",
|
|
18
|
+
"readOnly",
|
|
19
|
+
"disabled",
|
|
20
|
+
"locale",
|
|
21
|
+
"timeZone",
|
|
22
|
+
"now",
|
|
23
|
+
"messages",
|
|
24
|
+
"timer",
|
|
25
|
+
"value",
|
|
26
|
+
"defaultValue",
|
|
27
|
+
"onValueChange",
|
|
28
|
+
"onValueCommit",
|
|
29
|
+
];
|
|
30
|
+
const PANEL_KEYS = BASE_PANEL_KEYS;
|
|
31
|
+
const RANGE_PANEL_KEYS = [
|
|
32
|
+
...BASE_PANEL_KEYS,
|
|
33
|
+
"onRangePreviewChange",
|
|
34
|
+
"onInvalidRange",
|
|
35
|
+
"allowOvernight",
|
|
36
|
+
"minDuration",
|
|
37
|
+
"maxDuration",
|
|
38
|
+
];
|
|
39
|
+
const INPUT_KEYS = [
|
|
40
|
+
"value",
|
|
41
|
+
"defaultValue",
|
|
42
|
+
"onValueChange",
|
|
43
|
+
"onValueCommit",
|
|
44
|
+
"mode",
|
|
45
|
+
"granularity",
|
|
46
|
+
"hourCycle",
|
|
47
|
+
"step",
|
|
48
|
+
"placeholderValue",
|
|
49
|
+
"parse",
|
|
50
|
+
"format",
|
|
51
|
+
"onInvalidInput",
|
|
52
|
+
"name",
|
|
53
|
+
"required",
|
|
54
|
+
"readOnly",
|
|
55
|
+
"disabled",
|
|
56
|
+
"min",
|
|
57
|
+
"max",
|
|
58
|
+
"disabledRanges",
|
|
59
|
+
"isTimeDisabled",
|
|
60
|
+
"isTimeUnavailable",
|
|
61
|
+
"locale",
|
|
62
|
+
"timeZone",
|
|
63
|
+
"now",
|
|
64
|
+
"messages",
|
|
65
|
+
];
|
|
66
|
+
const RANGE_INPUT_KEYS = [
|
|
67
|
+
...INPUT_KEYS,
|
|
68
|
+
"startName",
|
|
69
|
+
"endName",
|
|
70
|
+
"allowOvernight",
|
|
71
|
+
"minDuration",
|
|
72
|
+
"maxDuration",
|
|
73
|
+
];
|
|
74
|
+
function split(props, keys) {
|
|
75
|
+
const options = {};
|
|
76
|
+
const rest = {};
|
|
77
|
+
for (const [key, value] of Object.entries(props)) {
|
|
78
|
+
(keys.includes(key) ? options : rest)[key] = value;
|
|
79
|
+
}
|
|
80
|
+
return [options, rest];
|
|
81
|
+
}
|
|
82
|
+
export const splitTimePanelProps = (props) => split(props, PANEL_KEYS);
|
|
83
|
+
export const splitTimeRangePanelProps = (props) => split(props, RANGE_PANEL_KEYS);
|
|
84
|
+
export const splitTimeInputProps = (props) => split(props, INPUT_KEYS);
|
|
85
|
+
export const splitTimeRangeInputProps = (props) => split(props, RANGE_INPUT_KEYS);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type TimeInputController, type TimeInputOptions, type TimeInputState, type TimeRangeInputOptions, type TimeSegmentView } from "../vendor/core/time/index.js";
|
|
2
|
+
import { type RefObject } from "react";
|
|
3
|
+
import { type ChronoProps } from "../shared/to-react-props.js";
|
|
4
|
+
export type TimeInputPropGetters = ReturnType<typeof useTimeInput>;
|
|
5
|
+
/** Headless date input (segmented or text) for React. */
|
|
6
|
+
export declare function useTimeInput(options?: TimeInputOptions): {
|
|
7
|
+
state: TimeInputState;
|
|
8
|
+
controller: TimeInputController;
|
|
9
|
+
getRootProps: () => ChronoProps & {
|
|
10
|
+
ref: RefObject<HTMLElement>;
|
|
11
|
+
};
|
|
12
|
+
getSegmentProps: (segment: TimeSegmentView) => ChronoProps;
|
|
13
|
+
getTextFieldProps: () => Record<string, unknown>;
|
|
14
|
+
getClearButtonProps: () => ChronoProps;
|
|
15
|
+
};
|
|
16
|
+
/** Headless date range input: two fields in one group. */
|
|
17
|
+
export declare function useTimeRangeInput(options?: TimeRangeInputOptions): {
|
|
18
|
+
state: import("../vendor/core/time/index.js").TimeRangeInputState;
|
|
19
|
+
controller: import("../vendor/core/time/index.js").TimeRangeInputController;
|
|
20
|
+
start: {
|
|
21
|
+
state: TimeInputState;
|
|
22
|
+
controller: TimeInputController;
|
|
23
|
+
getRootProps: () => ChronoProps & {
|
|
24
|
+
ref: RefObject<HTMLElement>;
|
|
25
|
+
};
|
|
26
|
+
getSegmentProps: (segment: TimeSegmentView) => ChronoProps;
|
|
27
|
+
getTextFieldProps: () => Record<string, unknown>;
|
|
28
|
+
getClearButtonProps: () => ChronoProps;
|
|
29
|
+
};
|
|
30
|
+
end: {
|
|
31
|
+
state: TimeInputState;
|
|
32
|
+
controller: TimeInputController;
|
|
33
|
+
getRootProps: () => ChronoProps & {
|
|
34
|
+
ref: RefObject<HTMLElement>;
|
|
35
|
+
};
|
|
36
|
+
getSegmentProps: (segment: TimeSegmentView) => ChronoProps;
|
|
37
|
+
getTextFieldProps: () => Record<string, unknown>;
|
|
38
|
+
getClearButtonProps: () => ChronoProps;
|
|
39
|
+
};
|
|
40
|
+
getRootProps: () => ChronoProps & {
|
|
41
|
+
ref: RefObject<HTMLElement>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createTimeInputController, createTimeRangeInputController, } from "../vendor/core/time/index.js";
|
|
3
|
+
import { focusPart } from "../vendor/core/foundation/index.js";
|
|
4
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
|
|
5
|
+
import { modifiersOf } from "../shared/modifiers.js";
|
|
6
|
+
import { toReactProps } from "../shared/to-react-props.js";
|
|
7
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
8
|
+
/** Prop getters for one date field (a single input, or one end of a range). */
|
|
9
|
+
function useField(controller, state, onReset, onBlurOutside) {
|
|
10
|
+
const rootRef = useRef(null);
|
|
11
|
+
const move = useRef(false);
|
|
12
|
+
useIsomorphicLayoutEffect(() => {
|
|
13
|
+
if (!move.current || !rootRef.current)
|
|
14
|
+
return;
|
|
15
|
+
focusPart(rootRef.current, state.focusedPart);
|
|
16
|
+
move.current = false;
|
|
17
|
+
}, [state]);
|
|
18
|
+
const reset = useRef(onReset);
|
|
19
|
+
reset.current = onReset;
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const form = rootRef.current?.closest("form");
|
|
22
|
+
if (!form)
|
|
23
|
+
return;
|
|
24
|
+
const handler = () => reset.current();
|
|
25
|
+
form.addEventListener("reset", handler);
|
|
26
|
+
return () => form.removeEventListener("reset", handler);
|
|
27
|
+
}, []);
|
|
28
|
+
return useMemo(() => ({
|
|
29
|
+
state,
|
|
30
|
+
controller,
|
|
31
|
+
getRootProps: () => ({
|
|
32
|
+
...toReactProps(controller.getRootAttributes()),
|
|
33
|
+
ref: rootRef,
|
|
34
|
+
onKeyUp: () => {
|
|
35
|
+
move.current = false;
|
|
36
|
+
},
|
|
37
|
+
onBlur: (event) => {
|
|
38
|
+
const next = event.relatedTarget;
|
|
39
|
+
if (!next || !event.currentTarget.contains(next))
|
|
40
|
+
onBlurOutside();
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
getSegmentProps: (segment) => {
|
|
44
|
+
const attributes = toReactProps(controller.getSegmentAttributes(segment));
|
|
45
|
+
if (segment.type === "literal")
|
|
46
|
+
return attributes;
|
|
47
|
+
const part = segment.type;
|
|
48
|
+
return {
|
|
49
|
+
...attributes,
|
|
50
|
+
onFocus: () => controller.focusPart(part),
|
|
51
|
+
onBlur: () => controller.settle(),
|
|
52
|
+
onKeyDown: (event) => {
|
|
53
|
+
if (controller.handleKeyDown(part, event.key, modifiersOf(event))) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
move.current = true;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onPaste: (event) => {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
controller.paste(event.clipboardData.getData("text"));
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
getTextFieldProps: () => {
|
|
65
|
+
const { disabled: _d, readonly: _r, ...attributes } = toReactProps(controller.getTextFieldAttributes());
|
|
66
|
+
return {
|
|
67
|
+
...attributes,
|
|
68
|
+
value: state.text,
|
|
69
|
+
disabled: state.disabled,
|
|
70
|
+
readOnly: state.readOnly,
|
|
71
|
+
onChange: (event) => controller.setText(event.target.value),
|
|
72
|
+
onBlur: () => {
|
|
73
|
+
controller.commitText();
|
|
74
|
+
onBlurOutside();
|
|
75
|
+
},
|
|
76
|
+
onKeyDown: (event) => {
|
|
77
|
+
if (controller.handleTextKeyDown(event.key)) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
onPaste: (event) => {
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
controller.setText(event.clipboardData.getData("text"));
|
|
85
|
+
controller.commitText();
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
getClearButtonProps: () => ({
|
|
90
|
+
...toReactProps(controller.getClearButtonAttributes()),
|
|
91
|
+
onClick: () => {
|
|
92
|
+
controller.clear();
|
|
93
|
+
move.current = true;
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
}), [controller, state, onBlurOutside]);
|
|
97
|
+
}
|
|
98
|
+
/** Headless date input (segmented or text) for React. */
|
|
99
|
+
export function useTimeInput(options = {}) {
|
|
100
|
+
const generatedId = useId();
|
|
101
|
+
const [controller] = useState(() => createTimeInputController({ ...options, id: options.id ?? generatedId }));
|
|
102
|
+
useIsomorphicLayoutEffect(() => {
|
|
103
|
+
const { id: _id, ...next } = options;
|
|
104
|
+
controller.setOptions(next);
|
|
105
|
+
});
|
|
106
|
+
const state = useSyncExternalStore(controller.subscribe, controller.getState, controller.getState);
|
|
107
|
+
const commit = useMemo(() => () => controller.commit(), [controller]);
|
|
108
|
+
const reset = useMemo(() => () => controller.reset(), [controller]);
|
|
109
|
+
return useField(controller, state, reset, commit);
|
|
110
|
+
}
|
|
111
|
+
/** Headless date range input: two fields in one group. */
|
|
112
|
+
export function useTimeRangeInput(options = {}) {
|
|
113
|
+
const generatedId = useId();
|
|
114
|
+
const [controller] = useState(() => createTimeRangeInputController({
|
|
115
|
+
...options,
|
|
116
|
+
id: options.id ?? generatedId,
|
|
117
|
+
}));
|
|
118
|
+
useIsomorphicLayoutEffect(() => {
|
|
119
|
+
const { id: _id, ...next } = options;
|
|
120
|
+
controller.setOptions(next);
|
|
121
|
+
});
|
|
122
|
+
const state = useSyncExternalStore(controller.subscribe, controller.getState, controller.getState);
|
|
123
|
+
const commit = useMemo(() => () => controller.commit(), [controller]);
|
|
124
|
+
const reset = useMemo(() => () => controller.reset(), [controller]);
|
|
125
|
+
const start = useField(controller.getStart(), state.start, reset, commit);
|
|
126
|
+
const end = useField(controller.getEnd(), state.end, reset, commit);
|
|
127
|
+
const rootRef = useRef(null);
|
|
128
|
+
return useMemo(() => ({
|
|
129
|
+
state,
|
|
130
|
+
controller,
|
|
131
|
+
start,
|
|
132
|
+
end,
|
|
133
|
+
getRootProps: () => ({
|
|
134
|
+
...toReactProps(controller.getRootAttributes()),
|
|
135
|
+
ref: rootRef,
|
|
136
|
+
}),
|
|
137
|
+
}), [controller, state, start, end]);
|
|
138
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type TimePanelOptions, type TimePanelState, type TimeRangePanelOptions } from "../vendor/core/time/index.js";
|
|
2
|
+
import { useBoundPanel } from "./bind-panel.js";
|
|
3
|
+
export type TimePanelPropGetters = ReturnType<typeof useBoundPanel>;
|
|
4
|
+
/** Headless single-time panel for React. No Provider is needed. */
|
|
5
|
+
export declare function useTimePanel(options?: TimePanelOptions): {
|
|
6
|
+
state: TimePanelState;
|
|
7
|
+
controller: import("../vendor/core/time/index.js").TimePanelController<any, any>;
|
|
8
|
+
actions: {
|
|
9
|
+
clear: () => void;
|
|
10
|
+
commit: () => void;
|
|
11
|
+
};
|
|
12
|
+
getRootProps: () => import("../shared/to-react-props.js").ChronoProps & {
|
|
13
|
+
ref: import("react").RefObject<HTMLElement>;
|
|
14
|
+
};
|
|
15
|
+
getSetProps: (set: import("../vendor/core/time/index.js").TimePanelSetState) => import("../shared/to-react-props.js").ChronoProps;
|
|
16
|
+
getColumnProps: (column: import("../vendor/core/time/index.js").TimePanelColumnState) => import("../shared/to-react-props.js").ChronoProps;
|
|
17
|
+
getGroupProps: (group: import("../vendor/core/time/index.js").TimePanelGroupState) => import("../shared/to-react-props.js").ChronoProps;
|
|
18
|
+
getListProps: () => import("../shared/to-react-props.js").ChronoProps;
|
|
19
|
+
getOptionProps: (option: import("../vendor/core/time/index.js").TimePanelOptionState) => import("../shared/to-react-props.js").ChronoProps;
|
|
20
|
+
};
|
|
21
|
+
export declare function useTimeRangePanel(options?: TimeRangePanelOptions): {
|
|
22
|
+
state: TimePanelState;
|
|
23
|
+
controller: import("../vendor/core/time/index.js").TimePanelController<any, any>;
|
|
24
|
+
actions: {
|
|
25
|
+
clear: () => void;
|
|
26
|
+
commit: () => void;
|
|
27
|
+
};
|
|
28
|
+
getRootProps: () => import("../shared/to-react-props.js").ChronoProps & {
|
|
29
|
+
ref: import("react").RefObject<HTMLElement>;
|
|
30
|
+
};
|
|
31
|
+
getSetProps: (set: import("../vendor/core/time/index.js").TimePanelSetState) => import("../shared/to-react-props.js").ChronoProps;
|
|
32
|
+
getColumnProps: (column: import("../vendor/core/time/index.js").TimePanelColumnState) => import("../shared/to-react-props.js").ChronoProps;
|
|
33
|
+
getGroupProps: (group: import("../vendor/core/time/index.js").TimePanelGroupState) => import("../shared/to-react-props.js").ChronoProps;
|
|
34
|
+
getListProps: () => import("../shared/to-react-props.js").ChronoProps;
|
|
35
|
+
getOptionProps: (option: import("../vendor/core/time/index.js").TimePanelOptionState) => import("../shared/to-react-props.js").ChronoProps;
|
|
36
|
+
};
|
|
37
|
+
export type { TimePanelState };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createTimePanelController, createTimeRangePanelController, } from "../vendor/core/time/index.js";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
|
+
import { useBoundPanel } from "./bind-panel.js";
|
|
5
|
+
/** Headless single-time panel for React. No Provider is needed. */
|
|
6
|
+
export function useTimePanel(options = {}) {
|
|
7
|
+
const generatedId = useId();
|
|
8
|
+
const [controller] = useState(() => createTimePanelController({ ...options, id: options.id ?? generatedId }));
|
|
9
|
+
return useBoundPanel(controller, options);
|
|
10
|
+
}
|
|
11
|
+
export function useTimeRangePanel(options = {}) {
|
|
12
|
+
const generatedId = useId();
|
|
13
|
+
const [controller] = useState(() => createTimeRangePanelController({
|
|
14
|
+
...options,
|
|
15
|
+
id: options.id ?? generatedId,
|
|
16
|
+
}));
|
|
17
|
+
return useBoundPanel(controller, options);
|
|
18
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { checkTimeRangeValue, getBookingSlots, parseTime } from "../vendor/core/time/index.js";
|
|
2
|
+
export { getHourCycle, getTimeStatus, isSameTime, snapTime, toPlainTime, } from "../vendor/core/foundation/index.js";
|
|
3
|
+
export type { BookingSlot, BookingSlotInput, HourCycle, TimeGranularity, TimeInputOptions, TimeInputState, TimePanelColumnState, TimePanelGroupState, TimePanelOptionState, TimePanelOptions, TimePanelSetState, TimePanelState, TimeParseResult, TimeRangeInputOptions, TimeRangeInputState, TimeRangePanelOptions, TimeRangeValue, TimeSegmentView, TimeValidity, TimeValue, } from "../vendor/core/time/index.js";
|
|
4
|
+
export type { TimeInput as TimeInputValue } from "../vendor/core/foundation/index.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Pure utilities and value helpers re-exported from core. No "use client":
|
|
2
|
+
// they stay ordinary functions in Server Components and server actions.
|
|
3
|
+
export { checkTimeRangeValue, getBookingSlots, parseTime } from "../vendor/core/time/index.js";
|
|
4
|
+
export { getHourCycle, getTimeStatus, isSameTime, snapTime, toPlainTime, } from "../vendor/core/foundation/index.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Availability, type AvailabilitySpec, type DateTimeInput, type DateInput } from "../foundation/index.js";
|
|
2
|
+
import type { CalendarEventInput } from "./events/types.js";
|
|
3
|
+
import type { EventId } from "./events/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to the Calendar `availability` function option (plan 11 R6).
|
|
6
|
+
* `excludeEventId` is set while a drag/resize previews, so an event never
|
|
7
|
+
* blocks its own new position.
|
|
8
|
+
*/
|
|
9
|
+
export type AvailabilityContext = {
|
|
10
|
+
excludeEventId?: EventId | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** What the Calendar `availability` option accepts (plan 11 V4, R6, R7). */
|
|
13
|
+
export type CalendarAvailabilityInput = AvailabilitySpec | Availability | ((context: AvailabilityContext) => AvailabilitySpec | Availability);
|
|
14
|
+
export type AvailabilityFromEventsOptions = {
|
|
15
|
+
/** Only events shown in this resource block time. */
|
|
16
|
+
resourceId?: string | number;
|
|
17
|
+
/** Leave this event out (the one being moved). */
|
|
18
|
+
excludeId?: EventId;
|
|
19
|
+
/**
|
|
20
|
+
* The zone event strings and `Date`s are read in. Needed when events carry an
|
|
21
|
+
* offset or `Z`; the returned spec's `timeZone` is set to it, so the rules are
|
|
22
|
+
* the wall times the calendar shows. Without it, the written wall time is used.
|
|
23
|
+
*/
|
|
24
|
+
timeZone?: string;
|
|
25
|
+
/** Customise the rule reason shown by `getAvailabilityLabel`. */
|
|
26
|
+
reason?: (event: CalendarEventInput) => string | undefined;
|
|
27
|
+
};
|
|
28
|
+
/** The wall-clock ISO form of a date or date-time value, without a zone suffix. */
|
|
29
|
+
export declare function wallIso(value: DateTimeInput | DateInput, timeZone?: string, allDay?: boolean): string;
|
|
30
|
+
/**
|
|
31
|
+
* Turn bookings into `blocked` rules (plan 11 V11). All-day events run
|
|
32
|
+
* `[start, end)` on dates; timed events on wall times. Pass `excludeId` while
|
|
33
|
+
* dragging so the moved event does not block itself (R6).
|
|
34
|
+
*/
|
|
35
|
+
export declare function availabilityFromEvents(events: readonly CalendarEventInput[], options?: AvailabilityFromEventsOptions): AvailabilitySpec;
|
|
36
|
+
export declare function resolveCalendarAvailability(input: CalendarAvailabilityInput | undefined, context: AvailabilityContext, options?: {
|
|
37
|
+
timeZone?: string;
|
|
38
|
+
now?: number | undefined;
|
|
39
|
+
}): Availability | undefined;
|