@zealakit/chrono-react 0.0.0-stage → 1.0.0-beta.1
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 +624 -2
- package/dist/calendar/components.d.ts +346 -0
- package/dist/calendar/components.js +245 -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 +50 -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 +156 -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 +202 -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 +169 -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/merge-props.d.ts +9 -0
- package/dist/shared/merge-props.js +33 -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 +60 -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 +174 -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 +74 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +1448 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.js +382 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +170 -0
- package/dist/vendor/core/calendar/controllers/shared.d.ts +29 -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 +71 -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 +107 -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 +156 -0
- package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
- package/dist/vendor/core/calendar/events/normalize.js +159 -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 +184 -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 +19 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +64 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +125 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +56 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +23 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +203 -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/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 +119 -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 +83 -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 +61 -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 +207 -0
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
- package/dist/vendor/core/calendar/recurrence/expand.js +302 -0
- package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
- package/dist/vendor/core/calendar/recurrence/pack.js +251 -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 +288 -0
- package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
- package/dist/vendor/core/calendar/recurrence/series.js +165 -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 +130 -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 +111 -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 +39 -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 +30 -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 +478 -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 +189 -0
- package/dist/vendor/core/date/input/parse.d.ts +22 -0
- package/dist/vendor/core/date/input/parse.js +84 -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 +726 -0
- package/dist/vendor/core/date/presets.d.ts +22 -0
- package/dist/vendor/core/date/presets.js +104 -0
- package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
- package/dist/vendor/core/date/selection/multiple.js +32 -0
- package/dist/vendor/core/date/selection/range.d.ts +29 -0
- package/dist/vendor/core/date/selection/range.js +39 -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 +395 -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 +182 -0
- package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
- package/dist/vendor/core/datetime/input/parse.js +59 -0
- package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
- package/dist/vendor/core/datetime/panel/controller.js +197 -0
- package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
- package/dist/vendor/core/datetime/panel/range-controller.js +217 -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 +54 -0
- package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
- package/dist/vendor/core/datetime/zone/resolve.js +26 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +7 -0
- package/dist/vendor/core/foundation/a11y/announcer.js +36 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +86 -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 +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.js +66 -0
- package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
- package/dist/vendor/core/foundation/constraints/availability.js +490 -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 +49 -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 +37 -0
- package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
- package/dist/vendor/core/foundation/locale/format.js +79 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.js +45 -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 +29 -0
- package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
- package/dist/vendor/core/foundation/locale/week-info.js +61 -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 +56 -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/global-state.d.ts +1 -0
- package/dist/vendor/core/foundation/store/global-state.js +21 -0
- package/dist/vendor/core/foundation/store/ids.d.ts +2 -0
- package/dist/vendor/core/foundation/store/ids.js +7 -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/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 +112 -0
- package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
- package/dist/vendor/core/foundation/values/epoch-day.js +47 -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 +113 -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 +45 -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 +155 -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 +84 -0
- package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
- package/dist/vendor/core/time/input/time-input-controller.js +562 -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 +185 -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 +839 -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 +78 -0
- package/dist/vendor/core/time/types.d.ts +11 -0
- package/dist/vendor/core/time/types.js +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { compare, compileAvailability, createControllable, createId, defaultMessages, getHiddenInputs, getTimeZoneLabel, mergeMessages, nowZoned, toInstant, } from "../../foundation/index.js";
|
|
2
|
+
import { createDateInputController, } from "../../date/index.js";
|
|
3
|
+
import { createTimeInputController, } from "../../time/index.js";
|
|
4
|
+
import { compose, decompose, sameDateTime, } from "../compose.js";
|
|
5
|
+
import { getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
|
|
6
|
+
import { formatOffset } from "../zone/day-instants.js";
|
|
7
|
+
import { parseDateTime } from "./parse.js";
|
|
8
|
+
const DATE_PARTS = new Set(["day", "month", "year"]);
|
|
9
|
+
const isDatePart = (part) => DATE_PARTS.has(part);
|
|
10
|
+
/** The text between the date and the time of a locale ("," + space, or a space). */
|
|
11
|
+
function separatorOf(locale) {
|
|
12
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
13
|
+
year: "numeric",
|
|
14
|
+
month: "numeric",
|
|
15
|
+
day: "numeric",
|
|
16
|
+
hour: "numeric",
|
|
17
|
+
minute: "numeric",
|
|
18
|
+
timeZone: "UTC",
|
|
19
|
+
}).formatToParts(Date.UTC(2020, 0, 1, 15, 4));
|
|
20
|
+
let sawDate = false;
|
|
21
|
+
let text = "";
|
|
22
|
+
for (const part of parts) {
|
|
23
|
+
if (part.type === "day" || part.type === "month" || part.type === "year") {
|
|
24
|
+
sawDate = true;
|
|
25
|
+
text = "";
|
|
26
|
+
}
|
|
27
|
+
else if (sawDate && part.type === "literal") {
|
|
28
|
+
text += part.value;
|
|
29
|
+
}
|
|
30
|
+
else if (part.type === "hour")
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return text || " ";
|
|
34
|
+
}
|
|
35
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
36
|
+
/** A date and a time input composed by one controller (plan 08 X10). */
|
|
37
|
+
export function createDateTimeInputController(initial = {}) {
|
|
38
|
+
let options = initial;
|
|
39
|
+
const id = options.id ?? createId("chrono-datetime-input");
|
|
40
|
+
const zone = () => ({
|
|
41
|
+
timeZone: options.timeZone,
|
|
42
|
+
valueTimeZone: options.valueTimeZone,
|
|
43
|
+
disambiguation: options.disambiguation,
|
|
44
|
+
});
|
|
45
|
+
const bounds = () => getBounds({
|
|
46
|
+
min: options.min,
|
|
47
|
+
max: options.max,
|
|
48
|
+
disablePast: options.disablePast,
|
|
49
|
+
timeZone: options.timeZone,
|
|
50
|
+
now: options.now,
|
|
51
|
+
});
|
|
52
|
+
const control = createControllable({
|
|
53
|
+
value: options.value,
|
|
54
|
+
defaultValue: options.defaultValue ?? null,
|
|
55
|
+
onChange: (value) => options.onValueChange?.(value, { adjusted: lastAdjusted }),
|
|
56
|
+
equals: sameDateTime,
|
|
57
|
+
});
|
|
58
|
+
let lastAdjusted = false;
|
|
59
|
+
let draft = decompose(control.get(), zone());
|
|
60
|
+
let focusedGroup = "date";
|
|
61
|
+
let lastCommitted = control.get();
|
|
62
|
+
const availabilityOf = () => options.availability === undefined
|
|
63
|
+
? undefined
|
|
64
|
+
: compileAvailability(options.availability, {
|
|
65
|
+
timeZone: options.timeZone,
|
|
66
|
+
now: options.now,
|
|
67
|
+
});
|
|
68
|
+
const dateOptions = () => {
|
|
69
|
+
const b = bounds();
|
|
70
|
+
return {
|
|
71
|
+
id: `${id}-date`,
|
|
72
|
+
mode: options.mode,
|
|
73
|
+
value: draft.date,
|
|
74
|
+
onValueChange: (date) => setDraft({ date, time: draft.time }),
|
|
75
|
+
locale: options.locale,
|
|
76
|
+
timeZone: options.timeZone,
|
|
77
|
+
now: options.now,
|
|
78
|
+
min: b.min,
|
|
79
|
+
max: b.max,
|
|
80
|
+
isDateDisabled: (d) => isDayDisabled(d, b) || (options.isDateDisabled?.(d) ?? false),
|
|
81
|
+
isDateUnavailable: options.isDateUnavailable,
|
|
82
|
+
availability: options.availability,
|
|
83
|
+
onInvalidInput: options.onInvalidInput,
|
|
84
|
+
required: options.required,
|
|
85
|
+
readOnly: options.readOnly,
|
|
86
|
+
disabled: options.disabled,
|
|
87
|
+
messages: options.messages,
|
|
88
|
+
onFocusEdge: (direction) => edge("date", direction),
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const timeOptions = () => {
|
|
92
|
+
const date = draft.date;
|
|
93
|
+
const limit = date ? timeBoundsFor(date, bounds()) : {};
|
|
94
|
+
return {
|
|
95
|
+
id: `${id}-time`,
|
|
96
|
+
mode: options.mode,
|
|
97
|
+
value: draft.time,
|
|
98
|
+
onValueChange: (time) => setDraft({ date: draft.date, time }),
|
|
99
|
+
locale: options.locale,
|
|
100
|
+
timeZone: options.timeZone,
|
|
101
|
+
now: options.now,
|
|
102
|
+
granularity: options.granularity,
|
|
103
|
+
hourCycle: options.hourCycle,
|
|
104
|
+
step: options.step,
|
|
105
|
+
min: limit.min,
|
|
106
|
+
max: limit.max,
|
|
107
|
+
isTimeDisabled: date
|
|
108
|
+
? (t) => options.isTimeDisabled?.(t, date) ?? false
|
|
109
|
+
: undefined,
|
|
110
|
+
isTimeUnavailable: date
|
|
111
|
+
? (t) => {
|
|
112
|
+
const availability = availabilityOf();
|
|
113
|
+
return availability
|
|
114
|
+
? !availability.isTimeAvailable(date, t)
|
|
115
|
+
: false;
|
|
116
|
+
}
|
|
117
|
+
: undefined,
|
|
118
|
+
onInvalidInput: options.onInvalidInput,
|
|
119
|
+
required: options.required,
|
|
120
|
+
readOnly: options.readOnly,
|
|
121
|
+
disabled: options.disabled,
|
|
122
|
+
messages: options.messages,
|
|
123
|
+
onFocusEdge: (direction) => edge("time", direction),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
const dateCtl = createDateInputController(dateOptions());
|
|
127
|
+
const timeCtl = createTimeInputController(timeOptions());
|
|
128
|
+
const firstLast = (group, which) => {
|
|
129
|
+
const parts = (group === "date"
|
|
130
|
+
? dateCtl.getState().segments
|
|
131
|
+
: timeCtl.getState().segments)
|
|
132
|
+
.filter((segment) => segment.type !== "literal")
|
|
133
|
+
.map((segment) => segment.type);
|
|
134
|
+
return (which === "first" ? parts[0] : parts[parts.length - 1]);
|
|
135
|
+
};
|
|
136
|
+
function edge(group, direction) {
|
|
137
|
+
if (group === "date" && direction === 1) {
|
|
138
|
+
focusedGroup = "time";
|
|
139
|
+
timeCtl.focusPart(firstLast("time", "first"));
|
|
140
|
+
}
|
|
141
|
+
else if (group === "time" && direction === -1) {
|
|
142
|
+
focusedGroup = "date";
|
|
143
|
+
dateCtl.focusPart(firstLast("date", "last"));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
options.onFocusEdge?.(direction);
|
|
147
|
+
}
|
|
148
|
+
emit();
|
|
149
|
+
}
|
|
150
|
+
let state;
|
|
151
|
+
const listeners = new Set();
|
|
152
|
+
const evaluate = () => {
|
|
153
|
+
const composed = compose(draft, zone());
|
|
154
|
+
const b = bounds();
|
|
155
|
+
let value = composed.value;
|
|
156
|
+
if (value && draft.date && draft.time) {
|
|
157
|
+
const wall = draft.date;
|
|
158
|
+
const t = draft.time;
|
|
159
|
+
void wall;
|
|
160
|
+
const limit = timeBoundsFor(draft.date, b);
|
|
161
|
+
if (limit.min && compare(t, limit.min) < 0)
|
|
162
|
+
value = null;
|
|
163
|
+
if (limit.max && compare(t, limit.max) > 0)
|
|
164
|
+
value = null;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
value,
|
|
168
|
+
adjusted: composed.adjusted,
|
|
169
|
+
nonexistent: composed.nonexistent,
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
let current = evaluate();
|
|
173
|
+
const validity = () => {
|
|
174
|
+
const d = dateCtl.getState().validity;
|
|
175
|
+
const t = timeCtl.getState().validity;
|
|
176
|
+
if (d === "empty" && t === "empty")
|
|
177
|
+
return "empty";
|
|
178
|
+
for (const v of [d, t]) {
|
|
179
|
+
if (v !== "valid" && v !== "empty" && v !== "incomplete")
|
|
180
|
+
return v;
|
|
181
|
+
}
|
|
182
|
+
if (d !== "valid" || t !== "valid")
|
|
183
|
+
return "incomplete";
|
|
184
|
+
if (current.nonexistent)
|
|
185
|
+
return "nonexistent-time";
|
|
186
|
+
if (!current.value) {
|
|
187
|
+
const wall = draft.time && draft.date ? timeBoundsFor(draft.date, bounds()) : {};
|
|
188
|
+
return wall.min && draft.time && compare(draft.time, wall.min) < 0
|
|
189
|
+
? "before-min"
|
|
190
|
+
: "after-max";
|
|
191
|
+
}
|
|
192
|
+
return "valid";
|
|
193
|
+
};
|
|
194
|
+
const formString = (value) => {
|
|
195
|
+
if (options.formValue)
|
|
196
|
+
return options.formValue(value);
|
|
197
|
+
const seconds = options.granularity === "second";
|
|
198
|
+
const base = `${value.year}-${pad(value.month)}-${pad(value.day)}T${pad(value.hour)}:${pad(value.minute)}${seconds ? `:${pad(value.second)}` : ""}`;
|
|
199
|
+
return "timeZone" in value ? `${base}${formatOffset(value.offset)}` : base;
|
|
200
|
+
};
|
|
201
|
+
const compute = () => {
|
|
202
|
+
const dateState = dateCtl.getState();
|
|
203
|
+
const timeState = timeCtl.getState();
|
|
204
|
+
const messages = mergeMessages(defaultMessages, options.messages);
|
|
205
|
+
const mode = options.mode ?? "segmented";
|
|
206
|
+
const literal = {
|
|
207
|
+
type: "literal",
|
|
208
|
+
text: separatorOf(options.locale ?? undefined),
|
|
209
|
+
value: null,
|
|
210
|
+
placeholder: "",
|
|
211
|
+
min: 0,
|
|
212
|
+
max: 0,
|
|
213
|
+
valueText: "",
|
|
214
|
+
editable: false,
|
|
215
|
+
};
|
|
216
|
+
const value = control.get();
|
|
217
|
+
const at = options.now ?? (value && "timeZone" in value ? toInstant(value) : 0);
|
|
218
|
+
return {
|
|
219
|
+
id,
|
|
220
|
+
mode,
|
|
221
|
+
segments: [...dateState.segments, literal, ...timeState.segments],
|
|
222
|
+
dateField: dateState,
|
|
223
|
+
timeField: timeState,
|
|
224
|
+
value,
|
|
225
|
+
validity: validity(),
|
|
226
|
+
adjusted: current.adjusted,
|
|
227
|
+
focusedPart: focusedGroup === "date" ? dateState.focusedPart : timeState.focusedPart,
|
|
228
|
+
zoneLabel: options.timeZone
|
|
229
|
+
? getTimeZoneLabel(options.timeZone, options.locale, at)
|
|
230
|
+
: null,
|
|
231
|
+
required: options.required ?? false,
|
|
232
|
+
readOnly: options.readOnly ?? false,
|
|
233
|
+
disabled: options.disabled ?? false,
|
|
234
|
+
direction: dateState.direction,
|
|
235
|
+
locale: dateState.locale,
|
|
236
|
+
messages,
|
|
237
|
+
hidden: getHiddenInputs([
|
|
238
|
+
[options.name, value ? formString(value) : null],
|
|
239
|
+
]),
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
const emit = () => {
|
|
243
|
+
const next = compute();
|
|
244
|
+
if (state && JSON.stringify(state) === JSON.stringify(next))
|
|
245
|
+
return;
|
|
246
|
+
state = next;
|
|
247
|
+
for (const listener of [...listeners])
|
|
248
|
+
listener(state);
|
|
249
|
+
};
|
|
250
|
+
function setDraft(next) {
|
|
251
|
+
draft = next;
|
|
252
|
+
current = evaluate();
|
|
253
|
+
dateCtl.setOptions(dateOptions());
|
|
254
|
+
timeCtl.setOptions(timeOptions());
|
|
255
|
+
if (!sameDateTime(control.get(), current.value)) {
|
|
256
|
+
lastAdjusted = current.adjusted;
|
|
257
|
+
control.set(current.value);
|
|
258
|
+
}
|
|
259
|
+
emit();
|
|
260
|
+
}
|
|
261
|
+
state = compute();
|
|
262
|
+
dateCtl.subscribe(emit);
|
|
263
|
+
timeCtl.subscribe(emit);
|
|
264
|
+
void nowZoned;
|
|
265
|
+
const groupOf = (part) => (isDatePart(part) ? dateCtl : timeCtl);
|
|
266
|
+
const controller = {
|
|
267
|
+
getState: () => state,
|
|
268
|
+
subscribe(listener) {
|
|
269
|
+
listeners.add(listener);
|
|
270
|
+
return () => {
|
|
271
|
+
listeners.delete(listener);
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
setOptions(next) {
|
|
275
|
+
options = { ...options, ...next };
|
|
276
|
+
control.sync({ value: options.value });
|
|
277
|
+
if (!sameDateTime(current.value, control.get())) {
|
|
278
|
+
draft = decompose(control.get(), zone());
|
|
279
|
+
}
|
|
280
|
+
current = evaluate();
|
|
281
|
+
dateCtl.setOptions(dateOptions());
|
|
282
|
+
timeCtl.setOptions(timeOptions());
|
|
283
|
+
emit();
|
|
284
|
+
},
|
|
285
|
+
getDate: () => dateCtl,
|
|
286
|
+
getTime: () => timeCtl,
|
|
287
|
+
handleKeyDown(part, key, modifiers) {
|
|
288
|
+
focusedGroup = isDatePart(part) ? "date" : "time";
|
|
289
|
+
const group = groupOf(part);
|
|
290
|
+
return group.handleKeyDown(part, key, modifiers);
|
|
291
|
+
},
|
|
292
|
+
focusPart(part) {
|
|
293
|
+
focusedGroup = isDatePart(part) ? "date" : "time";
|
|
294
|
+
groupOf(part).focusPart(part);
|
|
295
|
+
emit();
|
|
296
|
+
},
|
|
297
|
+
settle() {
|
|
298
|
+
dateCtl.settle();
|
|
299
|
+
timeCtl.settle();
|
|
300
|
+
},
|
|
301
|
+
paste(text) {
|
|
302
|
+
if (options.disabled || options.readOnly)
|
|
303
|
+
return false;
|
|
304
|
+
const result = parseDateTime(text, {
|
|
305
|
+
locale: options.locale,
|
|
306
|
+
timeZone: options.timeZone,
|
|
307
|
+
});
|
|
308
|
+
if ("error" in result) {
|
|
309
|
+
options.onInvalidInput?.(text);
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
setDraft({
|
|
313
|
+
date: result.date ?? draft.date,
|
|
314
|
+
time: result.time ?? draft.time,
|
|
315
|
+
});
|
|
316
|
+
return true;
|
|
317
|
+
},
|
|
318
|
+
commit() {
|
|
319
|
+
dateCtl.commit();
|
|
320
|
+
timeCtl.commit();
|
|
321
|
+
const value = control.get();
|
|
322
|
+
if (value &&
|
|
323
|
+
state.validity === "valid" &&
|
|
324
|
+
!sameDateTime(value, lastCommitted)) {
|
|
325
|
+
lastCommitted = value;
|
|
326
|
+
options.onValueCommit?.(value);
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
clear() {
|
|
330
|
+
if (options.disabled || options.readOnly)
|
|
331
|
+
return;
|
|
332
|
+
dateCtl.clear();
|
|
333
|
+
timeCtl.clear();
|
|
334
|
+
focusedGroup = "date";
|
|
335
|
+
draft = { date: null, time: null };
|
|
336
|
+
lastCommitted = null;
|
|
337
|
+
setDraft(draft);
|
|
338
|
+
},
|
|
339
|
+
reset() {
|
|
340
|
+
const value = options.defaultValue ?? null;
|
|
341
|
+
draft = decompose(value, zone());
|
|
342
|
+
lastCommitted = value;
|
|
343
|
+
dateCtl.reset();
|
|
344
|
+
timeCtl.reset();
|
|
345
|
+
control.set(value);
|
|
346
|
+
setDraft(draft);
|
|
347
|
+
},
|
|
348
|
+
getRootAttributes: () => ({
|
|
349
|
+
role: "group",
|
|
350
|
+
"data-chrono-datetime-input": true,
|
|
351
|
+
"data-mode": state.mode,
|
|
352
|
+
"data-disabled": state.disabled,
|
|
353
|
+
"data-readonly": state.readOnly,
|
|
354
|
+
"data-invalid": state.validity !== "valid" && state.validity !== "empty",
|
|
355
|
+
"data-adjusted": state.adjusted,
|
|
356
|
+
"aria-disabled": state.disabled ? "true" : undefined,
|
|
357
|
+
dir: state.direction,
|
|
358
|
+
}),
|
|
359
|
+
getSegmentAttributes(segment) {
|
|
360
|
+
if (segment.type === "literal")
|
|
361
|
+
return dateCtl.getSegmentAttributes(segment);
|
|
362
|
+
const base = groupOf(segment.type) === dateCtl
|
|
363
|
+
? dateCtl.getSegmentAttributes(segment)
|
|
364
|
+
: timeCtl.getSegmentAttributes(segment);
|
|
365
|
+
return {
|
|
366
|
+
...base,
|
|
367
|
+
// One tab stop for the whole group, not one per sub-controller.
|
|
368
|
+
tabindex: state.disabled
|
|
369
|
+
? undefined
|
|
370
|
+
: segment.type === state.focusedPart
|
|
371
|
+
? 0
|
|
372
|
+
: -1,
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
getDateFieldAttributes: () => ({
|
|
376
|
+
...dateCtl.getTextFieldAttributes(),
|
|
377
|
+
"aria-label": state.messages.date,
|
|
378
|
+
}),
|
|
379
|
+
getTimeFieldAttributes: () => ({
|
|
380
|
+
...timeCtl.getTextFieldAttributes(),
|
|
381
|
+
"aria-label": state.messages.time,
|
|
382
|
+
}),
|
|
383
|
+
getClearButtonAttributes: () => ({
|
|
384
|
+
type: "button",
|
|
385
|
+
"aria-label": state.messages.clear,
|
|
386
|
+
"data-disabled": state.disabled || state.validity === "empty",
|
|
387
|
+
}),
|
|
388
|
+
destroy() {
|
|
389
|
+
listeners.clear();
|
|
390
|
+
dateCtl.destroy();
|
|
391
|
+
timeCtl.destroy();
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
return controller;
|
|
395
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Attributes, type HiddenInput } from "../../foundation/index.js";
|
|
2
|
+
import { type DateTimeRangeReason } from "../constraints.js";
|
|
3
|
+
import type { DateTimeRangeValue, DateTimeValue } from "../types.js";
|
|
4
|
+
import { type DateTimeInputController, type DateTimeInputOptions, type DateTimeInputState, type DateTimeValidity } from "./datetime-input-controller.js";
|
|
5
|
+
export type DateTimeRangeInputOptions = Omit<DateTimeInputOptions, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "name" | "onFocusEdge"> & {
|
|
6
|
+
value?: DateTimeRangeValue;
|
|
7
|
+
defaultValue?: DateTimeRangeValue;
|
|
8
|
+
onValueChange?: (value: DateTimeRangeValue) => void;
|
|
9
|
+
onValueCommit?: (value: {
|
|
10
|
+
start: NonNullable<DateTimeValue>;
|
|
11
|
+
end: NonNullable<DateTimeValue>;
|
|
12
|
+
}) => void;
|
|
13
|
+
name?: string;
|
|
14
|
+
startName?: string;
|
|
15
|
+
endName?: string;
|
|
16
|
+
/** Minutes. */
|
|
17
|
+
minDuration?: number;
|
|
18
|
+
maxDuration?: number;
|
|
19
|
+
};
|
|
20
|
+
export type DateTimeRangeValidity = DateTimeValidity | DateTimeRangeReason;
|
|
21
|
+
export type DateTimeRangeInputState = {
|
|
22
|
+
id: string;
|
|
23
|
+
value: DateTimeRangeValue;
|
|
24
|
+
validity: DateTimeRangeValidity;
|
|
25
|
+
start: DateTimeInputState;
|
|
26
|
+
end: DateTimeInputState;
|
|
27
|
+
duration: number | null;
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
readOnly: boolean;
|
|
30
|
+
hidden: HiddenInput[];
|
|
31
|
+
messages: DateTimeInputState["messages"];
|
|
32
|
+
};
|
|
33
|
+
export type DateTimeRangeInputController = {
|
|
34
|
+
getState(): DateTimeRangeInputState;
|
|
35
|
+
subscribe(listener: (state: DateTimeRangeInputState) => void): () => void;
|
|
36
|
+
setOptions(options: Partial<DateTimeRangeInputOptions>): void;
|
|
37
|
+
getStart(): DateTimeInputController;
|
|
38
|
+
getEnd(): DateTimeInputController;
|
|
39
|
+
commit(): void;
|
|
40
|
+
clear(): void;
|
|
41
|
+
reset(): void;
|
|
42
|
+
getRootAttributes(): Attributes;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
};
|
|
45
|
+
/** Two date-time inputs in one group (plan 08 X10). */
|
|
46
|
+
export declare function createDateTimeRangeInputController(initial?: DateTimeRangeInputOptions): DateTimeRangeInputController;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { createControllable, createId, getHiddenInputs, } from "../../foundation/index.js";
|
|
2
|
+
import { sameDateTime } from "../compose.js";
|
|
3
|
+
import { checkDateTimeRange, getBounds, } from "../constraints.js";
|
|
4
|
+
import { createDateTimeInputController, } from "./datetime-input-controller.js";
|
|
5
|
+
const sameRange = (a, b) => a === b ||
|
|
6
|
+
(a !== null &&
|
|
7
|
+
b !== null &&
|
|
8
|
+
sameDateTime(a.start, b.start) &&
|
|
9
|
+
sameDateTime(a.end, b.end));
|
|
10
|
+
/** Two date-time inputs in one group (plan 08 X10). */
|
|
11
|
+
export function createDateTimeRangeInputController(initial = {}) {
|
|
12
|
+
let options = initial;
|
|
13
|
+
const id = options.id ?? createId("chrono-datetime-range-input");
|
|
14
|
+
const control = createControllable({
|
|
15
|
+
value: options.value,
|
|
16
|
+
defaultValue: options.defaultValue ?? null,
|
|
17
|
+
onChange: (value) => options.onValueChange?.(value),
|
|
18
|
+
equals: sameRange,
|
|
19
|
+
});
|
|
20
|
+
let lastCommitted = control.get();
|
|
21
|
+
const childOptions = () => {
|
|
22
|
+
const { value: _v, defaultValue: _d, onValueChange: _c, onValueCommit: _m, name: _n, startName: _s, endName: _e, minDuration: _a, maxDuration: _b, ...shared } = options;
|
|
23
|
+
// The fields only format the hidden value; this range names the inputs.
|
|
24
|
+
return {
|
|
25
|
+
...shared,
|
|
26
|
+
name: options.name || options.startName || options.endName
|
|
27
|
+
? "value"
|
|
28
|
+
: undefined,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const combine = (start, end) => start === null && end === null ? null : { start, end };
|
|
32
|
+
const setSide = (side, value) => {
|
|
33
|
+
const now = control.get();
|
|
34
|
+
control.set(combine(side === "start" ? value : (now?.start ?? null), side === "end" ? value : (now?.end ?? null)));
|
|
35
|
+
propagate();
|
|
36
|
+
refresh();
|
|
37
|
+
};
|
|
38
|
+
const startCtl = createDateTimeInputController({
|
|
39
|
+
...childOptions(),
|
|
40
|
+
id: `${id}-start`,
|
|
41
|
+
value: control.get()?.start ?? null,
|
|
42
|
+
defaultValue: undefined,
|
|
43
|
+
onValueChange: (value) => setSide("start", value),
|
|
44
|
+
});
|
|
45
|
+
const endCtl = createDateTimeInputController({
|
|
46
|
+
...childOptions(),
|
|
47
|
+
id: `${id}-end`,
|
|
48
|
+
value: control.get()?.end ?? null,
|
|
49
|
+
defaultValue: undefined,
|
|
50
|
+
onValueChange: (value) => setSide("end", value),
|
|
51
|
+
});
|
|
52
|
+
function propagate() {
|
|
53
|
+
const value = control.get();
|
|
54
|
+
startCtl.setOptions({ value: value?.start ?? null });
|
|
55
|
+
endCtl.setOptions({ value: value?.end ?? null });
|
|
56
|
+
}
|
|
57
|
+
let state;
|
|
58
|
+
const listeners = new Set();
|
|
59
|
+
const compute = () => {
|
|
60
|
+
const start = startCtl.getState();
|
|
61
|
+
const end = endCtl.getState();
|
|
62
|
+
let validity;
|
|
63
|
+
let duration = null;
|
|
64
|
+
if (start.validity === "empty" && end.validity === "empty")
|
|
65
|
+
validity = "empty";
|
|
66
|
+
else if (start.validity !== "valid" && start.validity !== "empty")
|
|
67
|
+
validity = start.validity;
|
|
68
|
+
else if (end.validity !== "valid" && end.validity !== "empty")
|
|
69
|
+
validity = end.validity;
|
|
70
|
+
else if (!start.value || !end.value)
|
|
71
|
+
validity = "incomplete";
|
|
72
|
+
else {
|
|
73
|
+
const check = checkDateTimeRange(start.value, end.value, {
|
|
74
|
+
minDuration: options.minDuration,
|
|
75
|
+
maxDuration: options.maxDuration,
|
|
76
|
+
bounds: getBounds({
|
|
77
|
+
min: options.min,
|
|
78
|
+
max: options.max,
|
|
79
|
+
disablePast: options.disablePast,
|
|
80
|
+
timeZone: options.timeZone,
|
|
81
|
+
now: options.now,
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
validity = check.valid ? "valid" : check.reason;
|
|
85
|
+
if (check.valid)
|
|
86
|
+
duration = check.duration;
|
|
87
|
+
}
|
|
88
|
+
const value = control.get();
|
|
89
|
+
const name = options.name;
|
|
90
|
+
return {
|
|
91
|
+
id,
|
|
92
|
+
value,
|
|
93
|
+
validity,
|
|
94
|
+
start,
|
|
95
|
+
end,
|
|
96
|
+
duration,
|
|
97
|
+
disabled: start.disabled,
|
|
98
|
+
readOnly: start.readOnly,
|
|
99
|
+
hidden: getHiddenInputs([
|
|
100
|
+
[
|
|
101
|
+
options.startName ?? (name ? `${name}-start` : undefined),
|
|
102
|
+
start.hidden[0]?.value ?? null,
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
options.endName ?? (name ? `${name}-end` : undefined),
|
|
106
|
+
end.hidden[0]?.value ?? null,
|
|
107
|
+
],
|
|
108
|
+
]),
|
|
109
|
+
messages: start.messages,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
const refresh = () => {
|
|
113
|
+
const next = compute();
|
|
114
|
+
if (state && JSON.stringify(state) === JSON.stringify(next))
|
|
115
|
+
return;
|
|
116
|
+
state = next;
|
|
117
|
+
for (const listener of [...listeners])
|
|
118
|
+
listener(state);
|
|
119
|
+
};
|
|
120
|
+
state = compute();
|
|
121
|
+
startCtl.subscribe(refresh);
|
|
122
|
+
endCtl.subscribe(refresh);
|
|
123
|
+
return {
|
|
124
|
+
getState: () => state,
|
|
125
|
+
subscribe(listener) {
|
|
126
|
+
listeners.add(listener);
|
|
127
|
+
return () => {
|
|
128
|
+
listeners.delete(listener);
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
setOptions(next) {
|
|
132
|
+
options = { ...options, ...next };
|
|
133
|
+
control.sync({ value: options.value });
|
|
134
|
+
const shared = childOptions();
|
|
135
|
+
// The hidden values belong to this range; the two fields carry no `name`.
|
|
136
|
+
startCtl.setOptions({ ...shared, value: control.get()?.start ?? null });
|
|
137
|
+
endCtl.setOptions({ ...shared, value: control.get()?.end ?? null });
|
|
138
|
+
refresh();
|
|
139
|
+
},
|
|
140
|
+
getStart: () => startCtl,
|
|
141
|
+
getEnd: () => endCtl,
|
|
142
|
+
commit() {
|
|
143
|
+
const value = control.get();
|
|
144
|
+
if (state.validity === "valid" &&
|
|
145
|
+
value?.start &&
|
|
146
|
+
value.end &&
|
|
147
|
+
!sameRange(value, lastCommitted)) {
|
|
148
|
+
lastCommitted = value;
|
|
149
|
+
options.onValueCommit?.({ start: value.start, end: value.end });
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
clear() {
|
|
153
|
+
startCtl.clear();
|
|
154
|
+
endCtl.clear();
|
|
155
|
+
lastCommitted = null;
|
|
156
|
+
},
|
|
157
|
+
reset() {
|
|
158
|
+
const value = options.defaultValue ?? null;
|
|
159
|
+
control.set(value);
|
|
160
|
+
propagate();
|
|
161
|
+
startCtl.reset();
|
|
162
|
+
endCtl.reset();
|
|
163
|
+
lastCommitted = value;
|
|
164
|
+
refresh();
|
|
165
|
+
},
|
|
166
|
+
getRootAttributes: () => ({
|
|
167
|
+
role: "group",
|
|
168
|
+
"data-chrono-datetime-range-input": true,
|
|
169
|
+
"data-mode": state.start.mode,
|
|
170
|
+
"data-disabled": state.disabled,
|
|
171
|
+
"data-readonly": state.readOnly,
|
|
172
|
+
"data-invalid": state.validity !== "valid" && state.validity !== "empty",
|
|
173
|
+
"aria-disabled": state.disabled ? "true" : undefined,
|
|
174
|
+
dir: state.start.direction,
|
|
175
|
+
}),
|
|
176
|
+
destroy() {
|
|
177
|
+
listeners.clear();
|
|
178
|
+
startCtl.destroy();
|
|
179
|
+
endCtl.destroy();
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type PlainDate, type PlainTime } from "../../foundation/index.js";
|
|
2
|
+
export type DateTimeParseContext = {
|
|
3
|
+
locale?: string;
|
|
4
|
+
/** The display zone; an ISO string with an offset or `Z` is converted into it. */
|
|
5
|
+
timeZone?: string;
|
|
6
|
+
today?: PlainDate;
|
|
7
|
+
};
|
|
8
|
+
/** `date` and `time` are `null` when the text holds only the other one (plan 08 §13.2). */
|
|
9
|
+
export type DateTimeParseResult = {
|
|
10
|
+
date: PlainDate | null;
|
|
11
|
+
time: PlainTime | null;
|
|
12
|
+
} | {
|
|
13
|
+
error: "empty" | "unparseable" | "invalid";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Split pasted text into a date and a time and parse each with the Date and Time
|
|
17
|
+
* parsers: ISO with `T`, `17/11/2026 9:30`, `Nov 17, 2026 9:30 PM`, a bare date or a
|
|
18
|
+
* bare time. Built on `date/` and `time/` only.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseDateTime(text: string, context?: DateTimeParseContext): DateTimeParseResult;
|