@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,59 @@
|
|
|
1
|
+
import { toPlainDateTime, plainDate, plainTime, } from "../../foundation/index.js";
|
|
2
|
+
import { parseDate } from "../../date/index.js";
|
|
3
|
+
import { dayPeriodOf, parseTime } from "../../time/index.js";
|
|
4
|
+
const fail = (error) => ({
|
|
5
|
+
error: error === "invalid" || error === "invalid-date" ? "invalid" : "unparseable",
|
|
6
|
+
});
|
|
7
|
+
const ISO = /^(\d{4}-\d{2}-\d{2})[T ](\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?)(Z|[+-]\d{2}:?\d{2})?$/;
|
|
8
|
+
const TIME_TAIL = /(\d{1,2}:\d{2}(?::\d{2})?)(?:\s*([^\d\s:]+\.?))?\s*$/u;
|
|
9
|
+
const HOUR_TAIL = /(\d{1,2})\s*([^\d\s:]+\.?)\s*$/u;
|
|
10
|
+
/**
|
|
11
|
+
* Split pasted text into a date and a time and parse each with the Date and Time
|
|
12
|
+
* parsers: ISO with `T`, `17/11/2026 9:30`, `Nov 17, 2026 9:30 PM`, a bare date or a
|
|
13
|
+
* bare time. Built on `date/` and `time/` only.
|
|
14
|
+
*/
|
|
15
|
+
export function parseDateTime(text, context = {}) {
|
|
16
|
+
const trimmed = text.trim();
|
|
17
|
+
if (trimmed === "")
|
|
18
|
+
return { error: "empty" };
|
|
19
|
+
const iso = ISO.exec(trimmed);
|
|
20
|
+
if (iso) {
|
|
21
|
+
try {
|
|
22
|
+
const wall = toPlainDateTime(iso[3] ? `${iso[1]}T${iso[2]}${iso[3]}` : `${iso[1]}T${iso[2]}`, context.timeZone ?? "UTC");
|
|
23
|
+
return {
|
|
24
|
+
date: plainDate(wall.year, wall.month, wall.day),
|
|
25
|
+
time: plainTime(wall.hour, wall.minute, wall.second),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return { error: "invalid" };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
let datePart = trimmed;
|
|
33
|
+
let timePart = "";
|
|
34
|
+
const withColon = TIME_TAIL.exec(trimmed);
|
|
35
|
+
const hourOnly = HOUR_TAIL.exec(trimmed);
|
|
36
|
+
if (withColon &&
|
|
37
|
+
(!withColon[2] || dayPeriodOf(withColon[2], context.locale))) {
|
|
38
|
+
timePart = withColon[0];
|
|
39
|
+
datePart = trimmed.slice(0, withColon.index);
|
|
40
|
+
}
|
|
41
|
+
else if (hourOnly && dayPeriodOf(hourOnly[2], context.locale)) {
|
|
42
|
+
timePart = hourOnly[0];
|
|
43
|
+
datePart = trimmed.slice(0, hourOnly.index);
|
|
44
|
+
}
|
|
45
|
+
datePart = datePart.replace(/[\s,]+(at)?[\s,]*$/i, "").trim();
|
|
46
|
+
if (timePart === "") {
|
|
47
|
+
const date = parseDate(datePart, context);
|
|
48
|
+
return "date" in date ? { date: date.date, time: null } : fail(date.error);
|
|
49
|
+
}
|
|
50
|
+
const time = parseTime(timePart, { locale: context.locale });
|
|
51
|
+
if (!("time" in time))
|
|
52
|
+
return fail(time.error);
|
|
53
|
+
if (datePart === "")
|
|
54
|
+
return { date: null, time: time.time };
|
|
55
|
+
const date = parseDate(datePart, context);
|
|
56
|
+
return "date" in date
|
|
57
|
+
? { date: date.date, time: time.time }
|
|
58
|
+
: fail(date.error);
|
|
59
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Attributes, type Availability, type AvailabilitySpec, type DateTimeInput, type Messages, type PlainDate, type PlainTime } from "../../foundation/index.js";
|
|
2
|
+
import { type PanelController, type DatePanelOptions, type PanelState } from "../../date/index.js";
|
|
3
|
+
import { type TimePanelController, type TimePanelOptions, type TimePanelState } from "../../time/index.js";
|
|
4
|
+
import { type Draft, type Zone } from "../compose.js";
|
|
5
|
+
import type { DateTimeValue } from "../types.js";
|
|
6
|
+
type Inner<T> = Omit<T, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "min" | "max">;
|
|
7
|
+
export type DateTimePanelOptions = {
|
|
8
|
+
id?: string;
|
|
9
|
+
value?: DateTimeValue;
|
|
10
|
+
defaultValue?: DateTimeValue;
|
|
11
|
+
onValueChange?: (value: DateTimeValue, info: {
|
|
12
|
+
adjusted: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
/** Fires when the time part commits while a date is chosen and the value is valid (X8). */
|
|
15
|
+
onValueCommit?: (value: NonNullable<DateTimeValue>) => void;
|
|
16
|
+
/** The zone the user sees and edits. Without it values are plain wall times. */
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
/** The zone of the emitted value (the same instant). */
|
|
19
|
+
valueTimeZone?: string;
|
|
20
|
+
disambiguation?: Zone["disambiguation"];
|
|
21
|
+
/** Fills the time when a date is picked first. */
|
|
22
|
+
defaultTime?: DateTimeInput | string;
|
|
23
|
+
min?: DateTimeInput;
|
|
24
|
+
max?: DateTimeInput;
|
|
25
|
+
disablePast?: boolean;
|
|
26
|
+
isDateDisabled?: (date: PlainDate) => boolean;
|
|
27
|
+
isDateUnavailable?: (date: PlainDate) => boolean;
|
|
28
|
+
isTimeDisabled?: (time: PlainTime, date: PlainDate) => boolean;
|
|
29
|
+
isTimeUnavailable?: (time: PlainTime, date: PlainDate) => boolean;
|
|
30
|
+
/** Availability model (plan 11 V7–V8): dates and times of the selected day. */
|
|
31
|
+
availability?: AvailabilitySpec | Availability;
|
|
32
|
+
date?: Inner<DatePanelOptions>;
|
|
33
|
+
time?: Inner<TimePanelOptions>;
|
|
34
|
+
locale?: string;
|
|
35
|
+
now?: number;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
autoFocus?: boolean;
|
|
39
|
+
messages?: Partial<Messages>;
|
|
40
|
+
};
|
|
41
|
+
export type DateTimePanelState = {
|
|
42
|
+
id: string;
|
|
43
|
+
value: DateTimeValue;
|
|
44
|
+
draft: Draft;
|
|
45
|
+
adjusted: boolean;
|
|
46
|
+
nonexistent: boolean;
|
|
47
|
+
date: PanelState;
|
|
48
|
+
time: TimePanelState;
|
|
49
|
+
messages: Messages;
|
|
50
|
+
};
|
|
51
|
+
export type DateTimePanelController = {
|
|
52
|
+
getState(): DateTimePanelState;
|
|
53
|
+
subscribe(listener: (state: DateTimePanelState) => void): () => void;
|
|
54
|
+
setOptions(options: Partial<DateTimePanelOptions>): void;
|
|
55
|
+
getDate(): PanelController<unknown, DatePanelOptions>;
|
|
56
|
+
getTime(): TimePanelController<unknown, TimePanelOptions>;
|
|
57
|
+
clear(): void;
|
|
58
|
+
commit(): void;
|
|
59
|
+
getRootAttributes(): Attributes;
|
|
60
|
+
destroy(): void;
|
|
61
|
+
};
|
|
62
|
+
/** Date and time panels composed by one controller (plan 08 X6–X8). */
|
|
63
|
+
export declare function createDateTimePanelController(initial?: DateTimePanelOptions): DateTimePanelController;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { compare, compileAvailability, createControllable, createId, defaultMessages, mergeMessages, toPlainTime, } from "../../foundation/index.js";
|
|
2
|
+
import { createDatePanelController, } from "../../date/index.js";
|
|
3
|
+
import { createTimePanelController, } from "../../time/index.js";
|
|
4
|
+
import { compose, decompose, sameDateTime, } from "../compose.js";
|
|
5
|
+
import { getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
|
|
6
|
+
/** Date and time panels composed by one controller (plan 08 X6–X8). */
|
|
7
|
+
export function createDateTimePanelController(initial = {}) {
|
|
8
|
+
let options = initial;
|
|
9
|
+
const id = options.id ?? createId("chrono-datetime-panel");
|
|
10
|
+
const zone = () => ({
|
|
11
|
+
timeZone: options.timeZone,
|
|
12
|
+
valueTimeZone: options.valueTimeZone,
|
|
13
|
+
disambiguation: options.disambiguation,
|
|
14
|
+
});
|
|
15
|
+
const bounds = () => getBounds({
|
|
16
|
+
min: options.min,
|
|
17
|
+
max: options.max,
|
|
18
|
+
disablePast: options.disablePast,
|
|
19
|
+
timeZone: options.timeZone,
|
|
20
|
+
now: options.now,
|
|
21
|
+
});
|
|
22
|
+
const control = createControllable({
|
|
23
|
+
value: options.value,
|
|
24
|
+
defaultValue: options.defaultValue ?? null,
|
|
25
|
+
onChange: (value) => options.onValueChange?.(value, { adjusted: lastAdjusted }),
|
|
26
|
+
equals: sameDateTime,
|
|
27
|
+
});
|
|
28
|
+
let lastAdjusted = false;
|
|
29
|
+
let draft = decompose(control.get(), zone());
|
|
30
|
+
let composed = compose(draft, zone());
|
|
31
|
+
/** A time is allowed on a date when the bounds and the app's rule accept it. */
|
|
32
|
+
const timeAllowed = (date, time) => {
|
|
33
|
+
const limit = timeBoundsFor(date, bounds());
|
|
34
|
+
if (limit.min && compare(time, limit.min) < 0)
|
|
35
|
+
return false;
|
|
36
|
+
if (limit.max && compare(time, limit.max) > 0)
|
|
37
|
+
return false;
|
|
38
|
+
return !options.isTimeDisabled?.(time, date);
|
|
39
|
+
};
|
|
40
|
+
const defaultTime = () => options.defaultTime === undefined
|
|
41
|
+
? null
|
|
42
|
+
: toPlainTime(options.defaultTime);
|
|
43
|
+
const availabilityOf = () => options.availability === undefined
|
|
44
|
+
? undefined
|
|
45
|
+
: compileAvailability(options.availability, {
|
|
46
|
+
timeZone: options.timeZone,
|
|
47
|
+
now: options.now,
|
|
48
|
+
});
|
|
49
|
+
const dateOptions = () => {
|
|
50
|
+
const b = bounds();
|
|
51
|
+
return {
|
|
52
|
+
...options.date,
|
|
53
|
+
id: `${id}-date`,
|
|
54
|
+
locale: options.locale,
|
|
55
|
+
timeZone: options.timeZone ?? options.date?.timeZone,
|
|
56
|
+
now: options.now,
|
|
57
|
+
min: b.min,
|
|
58
|
+
max: b.max,
|
|
59
|
+
isDateDisabled: (date) => isDayDisabled(date, b) || (options.isDateDisabled?.(date) ?? false),
|
|
60
|
+
isDateUnavailable: options.isDateUnavailable,
|
|
61
|
+
availability: options.availability,
|
|
62
|
+
value: draft.date,
|
|
63
|
+
onValueChange: (date) => setDate(date),
|
|
64
|
+
readOnly: options.readOnly,
|
|
65
|
+
disabled: options.disabled,
|
|
66
|
+
autoFocus: options.autoFocus,
|
|
67
|
+
messages: options.messages,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
const timeOptions = () => {
|
|
71
|
+
const limit = draft.date ? timeBoundsFor(draft.date, bounds()) : {};
|
|
72
|
+
const date = draft.date;
|
|
73
|
+
return {
|
|
74
|
+
...options.time,
|
|
75
|
+
id: `${id}-time`,
|
|
76
|
+
locale: options.locale,
|
|
77
|
+
timeZone: options.timeZone ?? options.time?.timeZone,
|
|
78
|
+
now: options.now,
|
|
79
|
+
min: limit.min,
|
|
80
|
+
max: limit.max,
|
|
81
|
+
isTimeDisabled: date
|
|
82
|
+
? (time) => options.isTimeDisabled?.(time, date) ?? false
|
|
83
|
+
: undefined,
|
|
84
|
+
isTimeUnavailable: date
|
|
85
|
+
? (time) => {
|
|
86
|
+
const availability = availabilityOf();
|
|
87
|
+
return ((options.isTimeUnavailable?.(time, date) ?? false) ||
|
|
88
|
+
(availability ? !availability.isTimeAvailable(date, time) : false));
|
|
89
|
+
}
|
|
90
|
+
: undefined,
|
|
91
|
+
value: draft.time,
|
|
92
|
+
onValueChange: (time) => setTime(time),
|
|
93
|
+
onValueCommit: () => commitNow(),
|
|
94
|
+
readOnly: options.readOnly,
|
|
95
|
+
disabled: options.disabled,
|
|
96
|
+
messages: options.messages,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const dateCtl = createDatePanelController(dateOptions());
|
|
100
|
+
const timeCtl = createTimePanelController(timeOptions());
|
|
101
|
+
let state;
|
|
102
|
+
const listeners = new Set();
|
|
103
|
+
const compute = () => ({
|
|
104
|
+
id,
|
|
105
|
+
value: control.get(),
|
|
106
|
+
draft,
|
|
107
|
+
adjusted: composed.adjusted,
|
|
108
|
+
nonexistent: composed.nonexistent,
|
|
109
|
+
date: dateCtl.getState(),
|
|
110
|
+
time: timeCtl.getState(),
|
|
111
|
+
messages: mergeMessages(defaultMessages, options.messages),
|
|
112
|
+
});
|
|
113
|
+
const emit = () => {
|
|
114
|
+
const next = compute();
|
|
115
|
+
if (state && JSON.stringify(state) === JSON.stringify(next))
|
|
116
|
+
return;
|
|
117
|
+
state = next;
|
|
118
|
+
for (const listener of [...listeners])
|
|
119
|
+
listener(state);
|
|
120
|
+
};
|
|
121
|
+
/** Push the draft into the composed controllers and the value. */
|
|
122
|
+
const update = () => {
|
|
123
|
+
dateCtl.setOptions(dateOptions());
|
|
124
|
+
timeCtl.setOptions(timeOptions());
|
|
125
|
+
composed = compose(draft, zone());
|
|
126
|
+
const allowed = draft.date && draft.time ? timeAllowed(draft.date, draft.time) : false;
|
|
127
|
+
const value = allowed ? composed.value : null;
|
|
128
|
+
if (!sameDateTime(control.get(), value)) {
|
|
129
|
+
lastAdjusted = composed.adjusted;
|
|
130
|
+
control.set(value);
|
|
131
|
+
}
|
|
132
|
+
emit();
|
|
133
|
+
};
|
|
134
|
+
function setDate(date) {
|
|
135
|
+
draft = { date, time: draft.time };
|
|
136
|
+
if (date && !draft.time) {
|
|
137
|
+
const fill = defaultTime();
|
|
138
|
+
if (fill)
|
|
139
|
+
draft = { date, time: fill };
|
|
140
|
+
}
|
|
141
|
+
update();
|
|
142
|
+
}
|
|
143
|
+
function setTime(time) {
|
|
144
|
+
draft = { date: draft.date, time };
|
|
145
|
+
update();
|
|
146
|
+
}
|
|
147
|
+
function commitNow() {
|
|
148
|
+
const value = control.get();
|
|
149
|
+
if (value && draft.date)
|
|
150
|
+
options.onValueCommit?.(value);
|
|
151
|
+
}
|
|
152
|
+
state = compute();
|
|
153
|
+
dateCtl.subscribe(emit);
|
|
154
|
+
timeCtl.subscribe(emit);
|
|
155
|
+
return {
|
|
156
|
+
getState: () => state,
|
|
157
|
+
subscribe(listener) {
|
|
158
|
+
listeners.add(listener);
|
|
159
|
+
return () => {
|
|
160
|
+
listeners.delete(listener);
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
setOptions(next) {
|
|
164
|
+
options = { ...options, ...next };
|
|
165
|
+
control.sync({ value: options.value });
|
|
166
|
+
const current = control.get();
|
|
167
|
+
if (!sameDateTime(composed.value, current)) {
|
|
168
|
+
draft = current
|
|
169
|
+
? decompose(current, zone())
|
|
170
|
+
: { date: null, time: null };
|
|
171
|
+
}
|
|
172
|
+
update();
|
|
173
|
+
},
|
|
174
|
+
getDate: () => dateCtl,
|
|
175
|
+
getTime: () => timeCtl,
|
|
176
|
+
clear() {
|
|
177
|
+
if (options.disabled || options.readOnly)
|
|
178
|
+
return;
|
|
179
|
+
draft = { date: null, time: null };
|
|
180
|
+
timeCtl.clear();
|
|
181
|
+
update();
|
|
182
|
+
},
|
|
183
|
+
commit: commitNow,
|
|
184
|
+
getRootAttributes: () => ({
|
|
185
|
+
role: "group",
|
|
186
|
+
"data-chrono-datetime-panel": true,
|
|
187
|
+
"data-adjusted": state.adjusted,
|
|
188
|
+
"data-disabled": options.disabled ?? false,
|
|
189
|
+
"data-readonly": options.readOnly ?? false,
|
|
190
|
+
}),
|
|
191
|
+
destroy() {
|
|
192
|
+
listeners.clear();
|
|
193
|
+
dateCtl.destroy();
|
|
194
|
+
timeCtl.destroy();
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type Attributes, type DateTimeInput, type Messages, type PlainDate, type PlainDateTime, type PlainTime, type ZonedDateTime } from "../../foundation/index.js";
|
|
2
|
+
import { type DateRangePanelOptions, type DateRangeValue, type PanelController, type PanelState } from "../../date/index.js";
|
|
3
|
+
import { type TimePanelController, type TimePanelOptions, type TimePanelState } from "../../time/index.js";
|
|
4
|
+
import { type Zone } from "../compose.js";
|
|
5
|
+
import { type DateTimeRangeReason } from "../constraints.js";
|
|
6
|
+
import type { DateTimeRangeValue } from "../types.js";
|
|
7
|
+
type Inner<T> = Omit<T, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "min" | "max">;
|
|
8
|
+
type Value = PlainDateTime | ZonedDateTime;
|
|
9
|
+
export type DateTimeRangePanelOptions = {
|
|
10
|
+
id?: string;
|
|
11
|
+
value?: DateTimeRangeValue;
|
|
12
|
+
defaultValue?: DateTimeRangeValue;
|
|
13
|
+
onValueChange?: (value: DateTimeRangeValue) => void;
|
|
14
|
+
/** Fires when the end time commits and the range is valid (X9). */
|
|
15
|
+
onValueCommit?: (value: {
|
|
16
|
+
start: Value;
|
|
17
|
+
end: Value;
|
|
18
|
+
}) => void;
|
|
19
|
+
timeZone?: string;
|
|
20
|
+
valueTimeZone?: string;
|
|
21
|
+
disambiguation?: Zone["disambiguation"];
|
|
22
|
+
/** Minutes. */
|
|
23
|
+
minDuration?: number;
|
|
24
|
+
maxDuration?: number;
|
|
25
|
+
min?: DateTimeInput;
|
|
26
|
+
max?: DateTimeInput;
|
|
27
|
+
disablePast?: boolean;
|
|
28
|
+
isDateDisabled?: (date: PlainDate) => boolean;
|
|
29
|
+
isDateUnavailable?: (date: PlainDate) => boolean;
|
|
30
|
+
isTimeDisabled?: (time: PlainTime, date: PlainDate) => boolean;
|
|
31
|
+
date?: Inner<DateRangePanelOptions>;
|
|
32
|
+
startTime?: Inner<TimePanelOptions>;
|
|
33
|
+
endTime?: Inner<TimePanelOptions>;
|
|
34
|
+
onInvalidRange?: (reason: DateTimeRangeReason) => void;
|
|
35
|
+
locale?: string;
|
|
36
|
+
now?: number;
|
|
37
|
+
readOnly?: boolean;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
autoFocus?: boolean;
|
|
40
|
+
messages?: Partial<Messages>;
|
|
41
|
+
};
|
|
42
|
+
export type DateTimeRangePanelState = {
|
|
43
|
+
id: string;
|
|
44
|
+
value: DateTimeRangeValue;
|
|
45
|
+
draft: {
|
|
46
|
+
range: DateRangeValue;
|
|
47
|
+
startTime: PlainTime | null;
|
|
48
|
+
endTime: PlainTime | null;
|
|
49
|
+
};
|
|
50
|
+
validity: "empty" | "incomplete" | "valid" | DateTimeRangeReason;
|
|
51
|
+
duration: number | null;
|
|
52
|
+
date: PanelState;
|
|
53
|
+
startTime: TimePanelState;
|
|
54
|
+
endTime: TimePanelState;
|
|
55
|
+
messages: Messages;
|
|
56
|
+
};
|
|
57
|
+
export type DateTimeRangePanelController = {
|
|
58
|
+
getState(): DateTimeRangePanelState;
|
|
59
|
+
subscribe(listener: (state: DateTimeRangePanelState) => void): () => void;
|
|
60
|
+
setOptions(options: Partial<DateTimeRangePanelOptions>): void;
|
|
61
|
+
getDate(): PanelController<unknown, DateRangePanelOptions>;
|
|
62
|
+
getStartTime(): TimePanelController<unknown, TimePanelOptions>;
|
|
63
|
+
getEndTime(): TimePanelController<unknown, TimePanelOptions>;
|
|
64
|
+
clear(): void;
|
|
65
|
+
commit(): void;
|
|
66
|
+
getRootAttributes(): Attributes;
|
|
67
|
+
destroy(): void;
|
|
68
|
+
};
|
|
69
|
+
/** A date range panel and two time panels composed by one controller (plan 08 X9). */
|
|
70
|
+
export declare function createDateTimeRangePanelController(initial?: DateTimeRangePanelOptions): DateTimeRangePanelController;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { createControllable, createId, defaultMessages, mergeMessages, } from "../../foundation/index.js";
|
|
2
|
+
import { createDateRangePanelController, } from "../../date/index.js";
|
|
3
|
+
import { createTimePanelController, } from "../../time/index.js";
|
|
4
|
+
import { compose, decompose, sameDateTime } from "../compose.js";
|
|
5
|
+
import { checkDateTimeRange, getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
|
|
6
|
+
const sameRange = (a, b) => a === b ||
|
|
7
|
+
(a !== null &&
|
|
8
|
+
b !== null &&
|
|
9
|
+
sameDateTime(a.start, b.start) &&
|
|
10
|
+
sameDateTime(a.end, b.end));
|
|
11
|
+
/** A date range panel and two time panels composed by one controller (plan 08 X9). */
|
|
12
|
+
export function createDateTimeRangePanelController(initial = {}) {
|
|
13
|
+
let options = initial;
|
|
14
|
+
const id = options.id ?? createId("chrono-datetime-range-panel");
|
|
15
|
+
const zone = () => ({
|
|
16
|
+
timeZone: options.timeZone,
|
|
17
|
+
valueTimeZone: options.valueTimeZone,
|
|
18
|
+
disambiguation: options.disambiguation,
|
|
19
|
+
});
|
|
20
|
+
const bounds = () => getBounds({
|
|
21
|
+
min: options.min,
|
|
22
|
+
max: options.max,
|
|
23
|
+
disablePast: options.disablePast,
|
|
24
|
+
timeZone: options.timeZone,
|
|
25
|
+
now: options.now,
|
|
26
|
+
});
|
|
27
|
+
const control = createControllable({
|
|
28
|
+
value: options.value,
|
|
29
|
+
defaultValue: options.defaultValue ?? null,
|
|
30
|
+
onChange: (value) => options.onValueChange?.(value),
|
|
31
|
+
equals: sameRange,
|
|
32
|
+
});
|
|
33
|
+
const initialDraft = (value) => {
|
|
34
|
+
const start = decompose(value?.start ?? null, zone());
|
|
35
|
+
const end = decompose(value?.end ?? null, zone());
|
|
36
|
+
return {
|
|
37
|
+
range: value ? { start: start.date, end: end.date } : null,
|
|
38
|
+
startTime: start.time,
|
|
39
|
+
endTime: end.time,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
let draft = initialDraft(control.get());
|
|
43
|
+
const composeBoth = () => {
|
|
44
|
+
const start = compose({ date: draft.range?.start ?? null, time: draft.startTime }, zone()).value;
|
|
45
|
+
const end = compose({ date: draft.range?.end ?? null, time: draft.endTime }, zone()).value;
|
|
46
|
+
return { start, end };
|
|
47
|
+
};
|
|
48
|
+
const checkNow = (start, end) => checkDateTimeRange(start, end, {
|
|
49
|
+
minDuration: options.minDuration,
|
|
50
|
+
maxDuration: options.maxDuration,
|
|
51
|
+
bounds: bounds(),
|
|
52
|
+
});
|
|
53
|
+
/** The end time options that would break the range are disabled (X9). */
|
|
54
|
+
const endBreaks = (time) => {
|
|
55
|
+
const date = draft.range?.end;
|
|
56
|
+
const { start } = composeBoth();
|
|
57
|
+
if (!date || !start)
|
|
58
|
+
return false;
|
|
59
|
+
const end = compose({ date, time }, zone()).value;
|
|
60
|
+
return end ? !checkNow(start, end).valid : false;
|
|
61
|
+
};
|
|
62
|
+
const timeOpts = (kind, date, time, user) => {
|
|
63
|
+
const limit = date ? timeBoundsFor(date, bounds()) : {};
|
|
64
|
+
return {
|
|
65
|
+
...user,
|
|
66
|
+
id: `${id}-${kind}-time`,
|
|
67
|
+
locale: options.locale,
|
|
68
|
+
timeZone: options.timeZone,
|
|
69
|
+
now: options.now,
|
|
70
|
+
min: limit.min,
|
|
71
|
+
max: limit.max,
|
|
72
|
+
isTimeDisabled: (t) => (date ? options.isTimeDisabled?.(t, date) : false) ||
|
|
73
|
+
(kind === "end" && endBreaks(t)),
|
|
74
|
+
value: time,
|
|
75
|
+
onValueChange: (next) => {
|
|
76
|
+
draft =
|
|
77
|
+
kind === "start"
|
|
78
|
+
? { ...draft, startTime: next }
|
|
79
|
+
: { ...draft, endTime: next };
|
|
80
|
+
update();
|
|
81
|
+
},
|
|
82
|
+
onValueCommit: kind === "end" ? () => commitNow() : undefined,
|
|
83
|
+
readOnly: options.readOnly,
|
|
84
|
+
disabled: options.disabled,
|
|
85
|
+
messages: options.messages,
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const dateOpts = () => {
|
|
89
|
+
const b = bounds();
|
|
90
|
+
return {
|
|
91
|
+
...options.date,
|
|
92
|
+
id: `${id}-date`,
|
|
93
|
+
locale: options.locale,
|
|
94
|
+
timeZone: options.timeZone,
|
|
95
|
+
now: options.now,
|
|
96
|
+
min: b.min,
|
|
97
|
+
max: b.max,
|
|
98
|
+
isDateDisabled: (d) => isDayDisabled(d, b) || (options.isDateDisabled?.(d) ?? false),
|
|
99
|
+
isDateUnavailable: options.isDateUnavailable,
|
|
100
|
+
value: draft.range,
|
|
101
|
+
onValueChange: (range) => {
|
|
102
|
+
draft = { ...draft, range };
|
|
103
|
+
update();
|
|
104
|
+
},
|
|
105
|
+
readOnly: options.readOnly,
|
|
106
|
+
disabled: options.disabled,
|
|
107
|
+
autoFocus: options.autoFocus,
|
|
108
|
+
messages: options.messages,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const dateCtl = createDateRangePanelController(dateOpts());
|
|
112
|
+
const startCtl = createTimePanelController(timeOpts("start", draft.range?.start, draft.startTime, options.startTime));
|
|
113
|
+
const endCtl = createTimePanelController(timeOpts("end", draft.range?.end, draft.endTime, options.endTime));
|
|
114
|
+
let state;
|
|
115
|
+
const listeners = new Set();
|
|
116
|
+
const evaluate = () => {
|
|
117
|
+
const { start, end } = composeBoth();
|
|
118
|
+
const filled = [
|
|
119
|
+
draft.range?.start,
|
|
120
|
+
draft.range?.end,
|
|
121
|
+
draft.startTime,
|
|
122
|
+
draft.endTime,
|
|
123
|
+
].filter(Boolean).length;
|
|
124
|
+
if (filled === 0)
|
|
125
|
+
return { value: null, validity: "empty", duration: null };
|
|
126
|
+
if (!start || !end)
|
|
127
|
+
return { value: null, validity: "incomplete", duration: null };
|
|
128
|
+
const check = checkNow(start, end);
|
|
129
|
+
return check.valid
|
|
130
|
+
? { value: { start, end }, validity: "valid", duration: check.duration }
|
|
131
|
+
: { value: null, validity: check.reason, duration: null };
|
|
132
|
+
};
|
|
133
|
+
let current = evaluate();
|
|
134
|
+
const compute = () => ({
|
|
135
|
+
id,
|
|
136
|
+
value: control.get(),
|
|
137
|
+
draft,
|
|
138
|
+
validity: current.validity,
|
|
139
|
+
duration: current.duration,
|
|
140
|
+
date: dateCtl.getState(),
|
|
141
|
+
startTime: startCtl.getState(),
|
|
142
|
+
endTime: endCtl.getState(),
|
|
143
|
+
messages: mergeMessages(defaultMessages, options.messages),
|
|
144
|
+
});
|
|
145
|
+
const emit = () => {
|
|
146
|
+
const next = compute();
|
|
147
|
+
if (state && JSON.stringify(state) === JSON.stringify(next))
|
|
148
|
+
return;
|
|
149
|
+
state = next;
|
|
150
|
+
for (const listener of [...listeners])
|
|
151
|
+
listener(state);
|
|
152
|
+
};
|
|
153
|
+
function update() {
|
|
154
|
+
dateCtl.setOptions(dateOpts());
|
|
155
|
+
startCtl.setOptions(timeOpts("start", draft.range?.start, draft.startTime, options.startTime));
|
|
156
|
+
endCtl.setOptions(timeOpts("end", draft.range?.end, draft.endTime, options.endTime));
|
|
157
|
+
current = evaluate();
|
|
158
|
+
if (!sameRange(control.get(), current.value))
|
|
159
|
+
control.set(current.value);
|
|
160
|
+
emit();
|
|
161
|
+
}
|
|
162
|
+
function commitNow() {
|
|
163
|
+
const value = control.get();
|
|
164
|
+
if (value?.start && value.end) {
|
|
165
|
+
options.onValueCommit?.({ start: value.start, end: value.end });
|
|
166
|
+
}
|
|
167
|
+
else if (current.validity !== "empty" &&
|
|
168
|
+
current.validity !== "incomplete" &&
|
|
169
|
+
current.validity !== "valid") {
|
|
170
|
+
options.onInvalidRange?.(current.validity);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
state = compute();
|
|
174
|
+
dateCtl.subscribe(emit);
|
|
175
|
+
startCtl.subscribe(emit);
|
|
176
|
+
endCtl.subscribe(emit);
|
|
177
|
+
return {
|
|
178
|
+
getState: () => state,
|
|
179
|
+
subscribe(listener) {
|
|
180
|
+
listeners.add(listener);
|
|
181
|
+
return () => {
|
|
182
|
+
listeners.delete(listener);
|
|
183
|
+
};
|
|
184
|
+
},
|
|
185
|
+
setOptions(next) {
|
|
186
|
+
options = { ...options, ...next };
|
|
187
|
+
control.sync({ value: options.value });
|
|
188
|
+
if (!sameRange(current.value, control.get()))
|
|
189
|
+
draft = initialDraft(control.get());
|
|
190
|
+
update();
|
|
191
|
+
},
|
|
192
|
+
getDate: () => dateCtl,
|
|
193
|
+
getStartTime: () => startCtl,
|
|
194
|
+
getEndTime: () => endCtl,
|
|
195
|
+
clear() {
|
|
196
|
+
if (options.disabled || options.readOnly)
|
|
197
|
+
return;
|
|
198
|
+
draft = { range: null, startTime: null, endTime: null };
|
|
199
|
+
startCtl.clear();
|
|
200
|
+
endCtl.clear();
|
|
201
|
+
update();
|
|
202
|
+
},
|
|
203
|
+
commit: commitNow,
|
|
204
|
+
getRootAttributes: () => ({
|
|
205
|
+
role: "group",
|
|
206
|
+
"data-chrono-datetime-panel": "range",
|
|
207
|
+
"data-disabled": options.disabled ?? false,
|
|
208
|
+
"data-readonly": options.readOnly ?? false,
|
|
209
|
+
}),
|
|
210
|
+
destroy() {
|
|
211
|
+
listeners.clear();
|
|
212
|
+
dateCtl.destroy();
|
|
213
|
+
startCtl.destroy();
|
|
214
|
+
endCtl.destroy();
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PlainDateTime, ZonedDateTime } from "../foundation/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* `PlainDateTime` when no `timeZone` is set, `ZonedDateTime` when one is (plan 08 X1).
|
|
4
|
+
* Never a string or a `Date`.
|
|
5
|
+
*/
|
|
6
|
+
export type DateTimeValueOf<Z> = Z extends string ? ZonedDateTime : PlainDateTime;
|
|
7
|
+
export type DateTimeValue = PlainDateTime | ZonedDateTime | null;
|
|
8
|
+
/** Half-open `[start, end)`. */
|
|
9
|
+
export type DateTimeRangeValue = {
|
|
10
|
+
start: PlainDateTime | ZonedDateTime | null;
|
|
11
|
+
end: PlainDateTime | ZonedDateTime | null;
|
|
12
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type PlainDate, type PlainTime } from "../../foundation/index.js";
|
|
2
|
+
export type DayInstant = {
|
|
3
|
+
/** `HH:mm`, or `HH:mm#2` for the second occurrence of a repeated time. */
|
|
4
|
+
key: string;
|
|
5
|
+
time: PlainTime;
|
|
6
|
+
/** Minutes east of UTC. */
|
|
7
|
+
offset: number;
|
|
8
|
+
/** Epoch milliseconds: the identity of the entry. */
|
|
9
|
+
instant: number;
|
|
10
|
+
/** 1, or 2 for the repeated hour. */
|
|
11
|
+
ordinal: 1 | 2;
|
|
12
|
+
};
|
|
13
|
+
/** `+07:00` for an offset in minutes. */
|
|
14
|
+
export declare function formatOffset(minutes: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Wall-aligned entries of one day (plan 08 X4): times in a gap are left out, times in
|
|
17
|
+
* the repeated hour appear twice (earlier first), each with its offset.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDayInstants(date: PlainDate, timeZone: string, stepMinutes: number): DayInstant[];
|