@zealakit/chrono-react 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +625 -2
- package/dist/calendar/components.d.ts +346 -0
- package/dist/calendar/components.js +243 -0
- package/dist/calendar/context.d.ts +636 -0
- package/dist/calendar/context.js +21 -0
- package/dist/calendar/index.d.ts +6 -0
- package/dist/calendar/index.js +6 -0
- package/dist/calendar/mini-calendar.d.ts +60 -0
- package/dist/calendar/mini-calendar.js +51 -0
- package/dist/calendar/options.d.ts +4 -0
- package/dist/calendar/options.js +98 -0
- package/dist/calendar/use-calendar.d.ts +340 -0
- package/dist/calendar/use-calendar.js +154 -0
- package/dist/calendar/use-mini-calendar.d.ts +302 -0
- package/dist/calendar/use-mini-calendar.js +56 -0
- package/dist/calendar/utilities.d.ts +9 -0
- package/dist/calendar/utilities.js +8 -0
- package/dist/date/bind-panel.d.ts +30 -0
- package/dist/date/bind-panel.js +125 -0
- package/dist/date/components.d.ts +197 -0
- package/dist/date/components.js +193 -0
- package/dist/date/context.d.ts +34 -0
- package/dist/date/context.js +19 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.js +4 -0
- package/dist/date/options.d.ts +7 -0
- package/dist/date/options.js +91 -0
- package/dist/date/use-date-input.d.ts +43 -0
- package/dist/date/use-date-input.js +138 -0
- package/dist/date/use-date-panel.d.ts +81 -0
- package/dist/date/use-date-panel.js +21 -0
- package/dist/date/utilities.d.ts +4 -0
- package/dist/date/utilities.js +4 -0
- package/dist/datetime/components.d.ts +121 -0
- package/dist/datetime/components.js +164 -0
- package/dist/datetime/context.d.ts +8 -0
- package/dist/datetime/context.js +18 -0
- package/dist/datetime/index.d.ts +4 -0
- package/dist/datetime/index.js +4 -0
- package/dist/datetime/options.d.ts +5 -0
- package/dist/datetime/options.js +99 -0
- package/dist/datetime/use-datetime-input.d.ts +44 -0
- package/dist/datetime/use-datetime-input.js +145 -0
- package/dist/datetime/use-datetime-panel.d.ts +128 -0
- package/dist/datetime/use-datetime-panel.js +60 -0
- package/dist/datetime/utilities.d.ts +4 -0
- package/dist/datetime/utilities.js +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/shared/defined-options.d.ts +18 -0
- package/dist/shared/defined-options.js +9 -0
- package/dist/shared/merge-props.d.ts +9 -0
- package/dist/shared/merge-props.js +31 -0
- package/dist/shared/modifiers.d.ts +7 -0
- package/dist/shared/modifiers.js +6 -0
- package/dist/shared/part.d.ts +10 -0
- package/dist/shared/part.js +9 -0
- package/dist/shared/slot.d.ts +12 -0
- package/dist/shared/slot.js +57 -0
- package/dist/shared/style-properties.d.ts +8 -0
- package/dist/shared/style-properties.js +13 -0
- package/dist/shared/to-react-props.d.ts +11 -0
- package/dist/shared/to-react-props.js +27 -0
- package/dist/time/bind-panel.d.ts +19 -0
- package/dist/time/bind-panel.js +97 -0
- package/dist/time/components.d.ts +183 -0
- package/dist/time/components.js +169 -0
- package/dist/time/context.d.ts +24 -0
- package/dist/time/context.js +19 -0
- package/dist/time/index.d.ts +4 -0
- package/dist/time/index.js +4 -0
- package/dist/time/options.d.ts +5 -0
- package/dist/time/options.js +85 -0
- package/dist/time/use-time-input.d.ts +43 -0
- package/dist/time/use-time-input.js +138 -0
- package/dist/time/use-time-panel.d.ts +37 -0
- package/dist/time/use-time-panel.js +18 -0
- package/dist/time/utilities.d.ts +4 -0
- package/dist/time/utilities.js +4 -0
- package/dist/vendor/core/calendar/availability.d.ts +39 -0
- package/dist/vendor/core/calendar/availability.js +73 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +1396 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.js +363 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +171 -0
- package/dist/vendor/core/calendar/controllers/shared.d.ts +33 -0
- package/dist/vendor/core/calendar/controllers/shared.js +82 -0
- package/dist/vendor/core/calendar/events/agenda-layout.d.ts +21 -0
- package/dist/vendor/core/calendar/events/agenda-layout.js +72 -0
- package/dist/vendor/core/calendar/events/all-day-row.d.ts +22 -0
- package/dist/vendor/core/calendar/events/all-day-row.js +93 -0
- package/dist/vendor/core/calendar/events/background-layout.d.ts +66 -0
- package/dist/vendor/core/calendar/events/background-layout.js +106 -0
- package/dist/vendor/core/calendar/events/index.d.ts +17 -0
- package/dist/vendor/core/calendar/events/index.js +8 -0
- package/dist/vendor/core/calendar/events/month-layout.d.ts +13 -0
- package/dist/vendor/core/calendar/events/month-layout.js +157 -0
- package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
- package/dist/vendor/core/calendar/events/normalize.js +156 -0
- package/dist/vendor/core/calendar/events/now-indicator.d.ts +18 -0
- package/dist/vendor/core/calendar/events/now-indicator.js +19 -0
- package/dist/vendor/core/calendar/events/overflow.d.ts +36 -0
- package/dist/vendor/core/calendar/events/overflow.js +112 -0
- package/dist/vendor/core/calendar/events/sort.d.ts +21 -0
- package/dist/vendor/core/calendar/events/sort.js +35 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +22 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.js +177 -0
- package/dist/vendor/core/calendar/events/types.d.ts +141 -0
- package/dist/vendor/core/calendar/events/types.js +1 -0
- package/dist/vendor/core/calendar/index.d.ts +70 -0
- package/dist/vendor/core/calendar/index.js +37 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +11 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +37 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +122 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +53 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +24 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +43 -0
- package/dist/vendor/core/calendar/interaction/event-focus.d.ts +28 -0
- package/dist/vendor/core/calendar/interaction/event-focus.js +44 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
- package/dist/vendor/core/calendar/interaction/hit-test.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/hit-test.js +26 -0
- package/dist/vendor/core/calendar/interaction/pending.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/pending.js +17 -0
- package/dist/vendor/core/calendar/interaction/pointer.d.ts +21 -0
- package/dist/vendor/core/calendar/interaction/pointer.js +169 -0
- package/dist/vendor/core/calendar/interaction/selection.d.ts +29 -0
- package/dist/vendor/core/calendar/interaction/selection.js +47 -0
- package/dist/vendor/core/calendar/internal/equal.d.ts +3 -0
- package/dist/vendor/core/calendar/internal/equal.js +43 -0
- package/dist/vendor/core/calendar/navigation/navigate.d.ts +33 -0
- package/dist/vendor/core/calendar/navigation/navigate.js +81 -0
- package/dist/vendor/core/calendar/navigation/range.d.ts +15 -0
- package/dist/vendor/core/calendar/navigation/range.js +52 -0
- package/dist/vendor/core/calendar/navigation/title.d.ts +12 -0
- package/dist/vendor/core/calendar/navigation/title.js +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.d.ts +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.js +62 -0
- package/dist/vendor/core/calendar/navigation/zoom.d.ts +5 -0
- package/dist/vendor/core/calendar/navigation/zoom.js +11 -0
- package/dist/vendor/core/calendar/recurrence/apply.d.ts +50 -0
- package/dist/vendor/core/calendar/recurrence/apply.js +206 -0
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
- package/dist/vendor/core/calendar/recurrence/expand.js +298 -0
- package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
- package/dist/vendor/core/calendar/recurrence/pack.js +248 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.js +8 -0
- package/dist/vendor/core/calendar/recurrence/rrule.d.ts +12 -0
- package/dist/vendor/core/calendar/recurrence/rrule.js +278 -0
- package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
- package/dist/vendor/core/calendar/recurrence/series.js +163 -0
- package/dist/vendor/core/calendar/recurrence/types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/types.js +1 -0
- package/dist/vendor/core/calendar/resources/keys.d.ts +2 -0
- package/dist/vendor/core/calendar/resources/keys.js +2 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.js +129 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.js +98 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.js +109 -0
- package/dist/vendor/core/calendar/resources/tree.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/tree.js +86 -0
- package/dist/vendor/core/calendar/resources/types.d.ts +177 -0
- package/dist/vendor/core/calendar/resources/types.js +1 -0
- package/dist/vendor/core/calendar/resources/views.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/views.js +45 -0
- package/dist/vendor/core/calendar/resources/windowing.d.ts +11 -0
- package/dist/vendor/core/calendar/resources/windowing.js +17 -0
- package/dist/vendor/core/calendar/views/day.d.ts +37 -0
- package/dist/vendor/core/calendar/views/day.js +36 -0
- package/dist/vendor/core/calendar/views/list-layout.d.ts +8 -0
- package/dist/vendor/core/calendar/views/list-layout.js +5 -0
- package/dist/vendor/core/calendar/views/mini-calendar.d.ts +23 -0
- package/dist/vendor/core/calendar/views/mini-calendar.js +31 -0
- package/dist/vendor/core/calendar/views/month-layout.d.ts +30 -0
- package/dist/vendor/core/calendar/views/month-layout.js +63 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.d.ts +26 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.js +27 -0
- package/dist/vendor/core/date/index.d.ts +9 -0
- package/dist/vendor/core/date/index.js +9 -0
- package/dist/vendor/core/date/input/date-input-controller.d.ts +97 -0
- package/dist/vendor/core/date/input/date-input-controller.js +466 -0
- package/dist/vendor/core/date/input/date-range-input-controller.d.ts +43 -0
- package/dist/vendor/core/date/input/date-range-input-controller.js +186 -0
- package/dist/vendor/core/date/input/parse.d.ts +22 -0
- package/dist/vendor/core/date/input/parse.js +78 -0
- package/dist/vendor/core/date/input/validity.d.ts +6 -0
- package/dist/vendor/core/date/input/validity.js +13 -0
- package/dist/vendor/core/date/panel/panel-controller.d.ts +176 -0
- package/dist/vendor/core/date/panel/panel-controller.js +704 -0
- package/dist/vendor/core/date/presets.d.ts +22 -0
- package/dist/vendor/core/date/presets.js +103 -0
- package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
- package/dist/vendor/core/date/selection/multiple.js +29 -0
- package/dist/vendor/core/date/selection/range.d.ts +29 -0
- package/dist/vendor/core/date/selection/range.js +35 -0
- package/dist/vendor/core/date/types.d.ts +12 -0
- package/dist/vendor/core/date/types.js +1 -0
- package/dist/vendor/core/datetime/compose.d.ts +24 -0
- package/dist/vendor/core/datetime/compose.js +49 -0
- package/dist/vendor/core/datetime/constraints.d.ts +42 -0
- package/dist/vendor/core/datetime/constraints.js +56 -0
- package/dist/vendor/core/datetime/index.d.ts +9 -0
- package/dist/vendor/core/datetime/index.js +9 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +96 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.js +380 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.d.ts +46 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +171 -0
- package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
- package/dist/vendor/core/datetime/input/parse.js +56 -0
- package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
- package/dist/vendor/core/datetime/panel/controller.js +191 -0
- package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
- package/dist/vendor/core/datetime/panel/range-controller.js +205 -0
- package/dist/vendor/core/datetime/types.d.ts +12 -0
- package/dist/vendor/core/datetime/types.js +1 -0
- package/dist/vendor/core/datetime/zone/day-instants.d.ts +19 -0
- package/dist/vendor/core/datetime/zone/day-instants.js +52 -0
- package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
- package/dist/vendor/core/datetime/zone/resolve.js +24 -0
- package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
- package/dist/vendor/core/dom/auto-scroll.js +57 -0
- package/dist/vendor/core/dom/drag-session.d.ts +25 -0
- package/dist/vendor/core/dom/drag-session.js +257 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +12 -0
- package/dist/vendor/core/foundation/a11y/announcer.js +24 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +76 -0
- package/dist/vendor/core/foundation/a11y/index.d.ts +8 -0
- package/dist/vendor/core/foundation/a11y/index.js +5 -0
- package/dist/vendor/core/foundation/a11y/labels.d.ts +21 -0
- package/dist/vendor/core/foundation/a11y/labels.js +43 -0
- package/dist/vendor/core/foundation/a11y/messages.d.ts +80 -0
- package/dist/vendor/core/foundation/a11y/messages.js +74 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.d.ts +18 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.js +73 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.js +64 -0
- package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
- package/dist/vendor/core/foundation/constraints/availability.js +480 -0
- package/dist/vendor/core/foundation/constraints/date.d.ts +21 -0
- package/dist/vendor/core/foundation/constraints/date.js +41 -0
- package/dist/vendor/core/foundation/constraints/index.d.ts +9 -0
- package/dist/vendor/core/foundation/constraints/index.js +4 -0
- package/dist/vendor/core/foundation/constraints/range.d.ts +44 -0
- package/dist/vendor/core/foundation/constraints/range.js +70 -0
- package/dist/vendor/core/foundation/constraints/time.d.ts +30 -0
- package/dist/vendor/core/foundation/constraints/time.js +56 -0
- package/dist/vendor/core/foundation/grid/index.d.ts +8 -0
- package/dist/vendor/core/foundation/grid/index.js +4 -0
- package/dist/vendor/core/foundation/grid/month-grid.d.ts +33 -0
- package/dist/vendor/core/foundation/grid/month-grid.js +52 -0
- package/dist/vendor/core/foundation/grid/time-axis.d.ts +25 -0
- package/dist/vendor/core/foundation/grid/time-axis.js +32 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.d.ts +17 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.js +26 -0
- package/dist/vendor/core/foundation/grid/year-grid.d.ts +29 -0
- package/dist/vendor/core/foundation/grid/year-grid.js +40 -0
- package/dist/vendor/core/foundation/index.d.ts +8 -0
- package/dist/vendor/core/foundation/index.js +8 -0
- package/dist/vendor/core/foundation/input/form.d.ts +7 -0
- package/dist/vendor/core/foundation/input/form.js +10 -0
- package/dist/vendor/core/foundation/input/index.d.ts +6 -0
- package/dist/vendor/core/foundation/input/index.js +3 -0
- package/dist/vendor/core/foundation/input/segment-engine.d.ts +33 -0
- package/dist/vendor/core/foundation/input/segment-engine.js +45 -0
- package/dist/vendor/core/foundation/input/tokenize.d.ts +19 -0
- package/dist/vendor/core/foundation/input/tokenize.js +24 -0
- package/dist/vendor/core/foundation/locale/digits.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/digits.js +35 -0
- package/dist/vendor/core/foundation/locale/direction.d.ts +1 -0
- package/dist/vendor/core/foundation/locale/direction.js +25 -0
- package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
- package/dist/vendor/core/foundation/locale/format.js +77 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.js +41 -0
- package/dist/vendor/core/foundation/locale/index.d.ts +10 -0
- package/dist/vendor/core/foundation/locale/index.js +8 -0
- package/dist/vendor/core/foundation/locale/names.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/names.js +30 -0
- package/dist/vendor/core/foundation/locale/resolve.d.ts +7 -0
- package/dist/vendor/core/foundation/locale/resolve.js +39 -0
- package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
- package/dist/vendor/core/foundation/locale/week-info.js +60 -0
- package/dist/vendor/core/foundation/locale/zone-label.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/zone-label.js +24 -0
- package/dist/vendor/core/foundation/ranges/date-range.d.ts +18 -0
- package/dist/vendor/core/foundation/ranges/date-range.js +40 -0
- package/dist/vendor/core/foundation/ranges/index.d.ts +4 -0
- package/dist/vendor/core/foundation/ranges/index.js +2 -0
- package/dist/vendor/core/foundation/ranges/interval.d.ts +24 -0
- package/dist/vendor/core/foundation/ranges/interval.js +54 -0
- package/dist/vendor/core/foundation/store/attributes.d.ts +19 -0
- package/dist/vendor/core/foundation/store/attributes.js +43 -0
- package/dist/vendor/core/foundation/store/controllable.d.ts +19 -0
- package/dist/vendor/core/foundation/store/controllable.js +50 -0
- package/dist/vendor/core/foundation/store/env.d.ts +1 -0
- package/dist/vendor/core/foundation/store/env.js +3 -0
- package/dist/vendor/core/foundation/store/ids.d.ts +9 -0
- package/dist/vendor/core/foundation/store/ids.js +12 -0
- package/dist/vendor/core/foundation/store/index.d.ts +11 -0
- package/dist/vendor/core/foundation/store/index.js +7 -0
- package/dist/vendor/core/foundation/store/store.d.ts +7 -0
- package/dist/vendor/core/foundation/store/store.js +25 -0
- package/dist/vendor/core/foundation/store/ticker.d.ts +11 -0
- package/dist/vendor/core/foundation/store/ticker.js +27 -0
- package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
- package/dist/vendor/core/foundation/store/with-optional.js +3 -0
- package/dist/vendor/core/foundation/values/clock.d.ts +4 -0
- package/dist/vendor/core/foundation/values/clock.js +21 -0
- package/dist/vendor/core/foundation/values/compare.d.ts +16 -0
- package/dist/vendor/core/foundation/values/compare.js +70 -0
- package/dist/vendor/core/foundation/values/convert.d.ts +31 -0
- package/dist/vendor/core/foundation/values/convert.js +108 -0
- package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
- package/dist/vendor/core/foundation/values/epoch-day.js +43 -0
- package/dist/vendor/core/foundation/values/index.d.ts +14 -0
- package/dist/vendor/core/foundation/values/index.js +10 -0
- package/dist/vendor/core/foundation/values/iso.d.ts +24 -0
- package/dist/vendor/core/foundation/values/iso.js +111 -0
- package/dist/vendor/core/foundation/values/plain-date-time.d.ts +8 -0
- package/dist/vendor/core/foundation/values/plain-date-time.js +25 -0
- package/dist/vendor/core/foundation/values/plain-date.d.ts +33 -0
- package/dist/vendor/core/foundation/values/plain-date.js +105 -0
- package/dist/vendor/core/foundation/values/plain-time.d.ts +15 -0
- package/dist/vendor/core/foundation/values/plain-time.js +43 -0
- package/dist/vendor/core/foundation/values/types.d.ts +37 -0
- package/dist/vendor/core/foundation/values/types.js +1 -0
- package/dist/vendor/core/foundation/values/week.d.ts +9 -0
- package/dist/vendor/core/foundation/values/week.js +31 -0
- package/dist/vendor/core/foundation/values/year-month.d.ts +10 -0
- package/dist/vendor/core/foundation/values/year-month.js +19 -0
- package/dist/vendor/core/foundation/values/zoned.d.ts +16 -0
- package/dist/vendor/core/foundation/values/zoned.js +152 -0
- package/dist/vendor/core/index.d.ts +5 -0
- package/dist/vendor/core/index.js +5 -0
- package/dist/vendor/core/time/index.d.ts +8 -0
- package/dist/vendor/core/time/index.js +8 -0
- package/dist/vendor/core/time/input/parse.d.ts +19 -0
- package/dist/vendor/core/time/input/parse.js +82 -0
- package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
- package/dist/vendor/core/time/input/time-input-controller.js +547 -0
- package/dist/vendor/core/time/input/time-range-input-controller.d.ts +49 -0
- package/dist/vendor/core/time/input/time-range-input-controller.js +178 -0
- package/dist/vendor/core/time/input/validity.d.ts +7 -0
- package/dist/vendor/core/time/input/validity.js +16 -0
- package/dist/vendor/core/time/panel/time-panel-controller.d.ts +163 -0
- package/dist/vendor/core/time/panel/time-panel-controller.js +809 -0
- package/dist/vendor/core/time/selection/range.d.ts +25 -0
- package/dist/vendor/core/time/selection/range.js +35 -0
- package/dist/vendor/core/time/selection/slots.d.ts +46 -0
- package/dist/vendor/core/time/selection/slots.js +76 -0
- package/dist/vendor/core/time/types.d.ts +11 -0
- package/dist/vendor/core/time/types.js +1 -0
- package/package.json +83 -4
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { toEpochDay } from "../values/plain-date.js";
|
|
2
|
+
import { toSecondOfDay } from "../values/plain-time.js";
|
|
3
|
+
import { wallSeconds } from "../values/plain-date-time.js";
|
|
4
|
+
import { getFormatter } from "./resolve.js";
|
|
5
|
+
const DAY_MS = 86400000;
|
|
6
|
+
const DATE_DEFAULT = {
|
|
7
|
+
year: "numeric",
|
|
8
|
+
month: "numeric",
|
|
9
|
+
day: "numeric",
|
|
10
|
+
};
|
|
11
|
+
const TIME_DEFAULT = { hour: "numeric", minute: "2-digit" };
|
|
12
|
+
const DATE_TIME_DEFAULT = { ...DATE_DEFAULT, ...TIME_DEFAULT };
|
|
13
|
+
function utc(options) {
|
|
14
|
+
return { ...options, timeZone: "UTC" };
|
|
15
|
+
}
|
|
16
|
+
/** Plain values are formatted as UTC, so the host zone never shifts them. */
|
|
17
|
+
export function formatDate(date, locale, options = DATE_DEFAULT) {
|
|
18
|
+
return getFormatter(locale, utc(options)).format(toEpochDay(date) * DAY_MS);
|
|
19
|
+
}
|
|
20
|
+
export function formatTime(time, locale, options = TIME_DEFAULT) {
|
|
21
|
+
return getFormatter(locale, utc(options)).format(toSecondOfDay(time) * 1000);
|
|
22
|
+
}
|
|
23
|
+
export function formatDateTime(value, locale, options = DATE_TIME_DEFAULT) {
|
|
24
|
+
return getFormatter(locale, utc(options)).format(wallSeconds(value) * 1000);
|
|
25
|
+
}
|
|
26
|
+
export function formatDateRange(range, locale, options = DATE_DEFAULT) {
|
|
27
|
+
return getFormatter(locale, utc(options)).formatRange(toEpochDay(range.start) * DAY_MS, toEpochDay(range.end) * DAY_MS);
|
|
28
|
+
}
|
|
29
|
+
/** Same as {@link formatDate} but split into typed parts, for apps that style pieces. */
|
|
30
|
+
export function formatDateToParts(date, locale, options = DATE_DEFAULT) {
|
|
31
|
+
return getFormatter(locale, utc(options)).formatToParts(toEpochDay(date) * DAY_MS);
|
|
32
|
+
}
|
|
33
|
+
export function formatDateRangeToParts(range, locale, options = DATE_DEFAULT) {
|
|
34
|
+
return getFormatter(locale, utc(options)).formatRangeToParts(toEpochDay(range.start) * DAY_MS, toEpochDay(range.end) * DAY_MS);
|
|
35
|
+
}
|
|
36
|
+
/** Order and separators of a numeric date, for segmented inputs and placeholders. */
|
|
37
|
+
export function getDatePartOrder(locale) {
|
|
38
|
+
const parts = getFormatter(locale, utc({ year: "numeric", month: "numeric", day: "numeric" })).formatToParts(toEpochDay(plainDateTimeSample()) * DAY_MS);
|
|
39
|
+
const order = [];
|
|
40
|
+
const literals = [];
|
|
41
|
+
let prefix = "";
|
|
42
|
+
let pending = "";
|
|
43
|
+
for (const part of parts) {
|
|
44
|
+
if (part.type === "literal") {
|
|
45
|
+
pending += part.value;
|
|
46
|
+
}
|
|
47
|
+
else if (part.type === "day" || part.type === "month" || part.type === "year") {
|
|
48
|
+
if (order.length === 0) {
|
|
49
|
+
prefix = pending;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
literals.push(pending);
|
|
53
|
+
}
|
|
54
|
+
pending = "";
|
|
55
|
+
order.push(part.type);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
order,
|
|
60
|
+
separators: [literals[0] ?? "", literals[1] ?? ""],
|
|
61
|
+
prefix,
|
|
62
|
+
suffix: pending,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function plainDateTimeSample() {
|
|
66
|
+
return { calendar: "gregory", year: 2033, month: 11, day: 22 };
|
|
67
|
+
}
|
|
68
|
+
/** A text-mode hint such as `dd/mm/yyyy`, from the locale's part order and the placeholder messages. */
|
|
69
|
+
export function getDateFormatPattern(locale, messages) {
|
|
70
|
+
const { order, separators, prefix, suffix } = getDatePartOrder(locale);
|
|
71
|
+
const words = {
|
|
72
|
+
day: messages.placeholderDay,
|
|
73
|
+
month: messages.placeholderMonth,
|
|
74
|
+
year: messages.placeholderYear,
|
|
75
|
+
};
|
|
76
|
+
return `${prefix}${words[order[0]]}${separators[0]}${words[order[1]]}${separators[1]}${words[order[2]]}${suffix}`;
|
|
77
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** `h11`/`h12` fold into `"h12"`, `h23`/`h24` into `"h23"`. */
|
|
2
|
+
export declare function getHourCycle(locale?: string): "h12" | "h23";
|
|
3
|
+
/** Localized AM and PM markers. */
|
|
4
|
+
export declare function getDayPeriodNames(locale?: string): {
|
|
5
|
+
am: string;
|
|
6
|
+
pm: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The day-period words around a time ("in the morning"), from `Intl`; falls back
|
|
10
|
+
* to the AM/PM names for locales that have no flexible day periods.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDayPeriodLabel(hour: number, locale?: string): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getFormatter } from "./resolve.js";
|
|
2
|
+
/** `h11`/`h12` fold into `"h12"`, `h23`/`h24` into `"h23"`. */
|
|
3
|
+
export function getHourCycle(locale) {
|
|
4
|
+
const formatter = getFormatter(locale, { hour: "numeric", timeZone: "UTC" });
|
|
5
|
+
const cycle = formatter.resolvedOptions().hourCycle;
|
|
6
|
+
if (cycle === "h11" || cycle === "h12") {
|
|
7
|
+
return "h12";
|
|
8
|
+
}
|
|
9
|
+
if (cycle === "h23" || cycle === "h24") {
|
|
10
|
+
return "h23";
|
|
11
|
+
}
|
|
12
|
+
return formatter.formatToParts(0).some((part) => part.type === "dayPeriod") ? "h12" : "h23";
|
|
13
|
+
}
|
|
14
|
+
/** Localized AM and PM markers. */
|
|
15
|
+
export function getDayPeriodNames(locale) {
|
|
16
|
+
const formatter = getFormatter(locale, {
|
|
17
|
+
hour: "numeric",
|
|
18
|
+
hourCycle: "h12",
|
|
19
|
+
timeZone: "UTC",
|
|
20
|
+
});
|
|
21
|
+
const period = (hour) => formatter.formatToParts(hour * 3600000).find((part) => part.type === "dayPeriod")?.value ?? "";
|
|
22
|
+
return { am: period(1), pm: period(13) };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The day-period words around a time ("in the morning"), from `Intl`; falls back
|
|
26
|
+
* to the AM/PM names for locales that have no flexible day periods.
|
|
27
|
+
*/
|
|
28
|
+
export function getDayPeriodLabel(hour, locale) {
|
|
29
|
+
const formatter = getFormatter(locale, {
|
|
30
|
+
hour: "numeric",
|
|
31
|
+
dayPeriod: "long",
|
|
32
|
+
timeZone: "UTC",
|
|
33
|
+
});
|
|
34
|
+
const part = formatter
|
|
35
|
+
.formatToParts(hour * 3600000)
|
|
36
|
+
.find((item) => item.type === "dayPeriod")?.value;
|
|
37
|
+
if (part)
|
|
38
|
+
return part;
|
|
39
|
+
const names = getDayPeriodNames(locale);
|
|
40
|
+
return hour < 12 ? names.am : names.pm;
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { resolveLocale } from "./resolve.js";
|
|
2
|
+
export { getWeekInfo } from "./week-info.js";
|
|
3
|
+
export { getMonthNames, getWeekdayNames } from "./names.js";
|
|
4
|
+
export type { NameWidth } from "./names.js";
|
|
5
|
+
export { getDayPeriodLabel, getDayPeriodNames, getHourCycle } from "./hour-cycle.js";
|
|
6
|
+
export { getTextDirection } from "./direction.js";
|
|
7
|
+
export { formatDate, formatDateRange, formatDateRangeToParts, formatDateToParts, formatDateTime, formatTime, getDatePartOrder, getDateFormatPattern, } from "./format.js";
|
|
8
|
+
export type { DatePartName, DatePartOrder, FormatOptions } from "./format.js";
|
|
9
|
+
export { getLocaleDigits, toLatinDigits, toLocaleDigits } from "./digits.js";
|
|
10
|
+
export { getTimeZoneLabel } from "./zone-label.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { resolveLocale } from "./resolve.js";
|
|
2
|
+
export { getWeekInfo } from "./week-info.js";
|
|
3
|
+
export { getMonthNames, getWeekdayNames } from "./names.js";
|
|
4
|
+
export { getDayPeriodLabel, getDayPeriodNames, getHourCycle } from "./hour-cycle.js";
|
|
5
|
+
export { getTextDirection } from "./direction.js";
|
|
6
|
+
export { formatDate, formatDateRange, formatDateRangeToParts, formatDateToParts, formatDateTime, formatTime, getDatePartOrder, getDateFormatPattern, } from "./format.js";
|
|
7
|
+
export { getLocaleDigits, toLatinDigits, toLocaleDigits } from "./digits.js";
|
|
8
|
+
export { getTimeZoneLabel } from "./zone-label.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DayOfWeek } from "../values/types.js";
|
|
2
|
+
export type NameWidth = "long" | "short" | "narrow";
|
|
3
|
+
/** Twelve month names, January first. */
|
|
4
|
+
export declare function getMonthNames(locale: string | undefined, width: NameWidth): readonly string[];
|
|
5
|
+
/** Seven weekday names starting at `firstDay` (default: the locale's first day). */
|
|
6
|
+
export declare function getWeekdayNames(locale: string | undefined, width: NameWidth, firstDay?: DayOfWeek): readonly string[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { toEpochDay, plainDate } from "../values/plain-date.js";
|
|
2
|
+
import { getFormatter } from "./resolve.js";
|
|
3
|
+
import { getWeekInfo } from "./week-info.js";
|
|
4
|
+
const DAY_MS = 86400000;
|
|
5
|
+
const cache = new Map();
|
|
6
|
+
function memo(key, create) {
|
|
7
|
+
let names = cache.get(key);
|
|
8
|
+
if (!names) {
|
|
9
|
+
names = Object.freeze(create());
|
|
10
|
+
cache.set(key, names);
|
|
11
|
+
}
|
|
12
|
+
return names;
|
|
13
|
+
}
|
|
14
|
+
/** Twelve month names, January first. */
|
|
15
|
+
export function getMonthNames(locale, width) {
|
|
16
|
+
return memo(`m|${locale ?? ""}|${width}`, () => {
|
|
17
|
+
const formatter = getFormatter(locale, { month: width, timeZone: "UTC" });
|
|
18
|
+
return Array.from({ length: 12 }, (_, index) => formatter.format(toEpochDay(plainDate(2021, index + 1, 15)) * DAY_MS));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** Seven weekday names starting at `firstDay` (default: the locale's first day). */
|
|
22
|
+
export function getWeekdayNames(locale, width, firstDay) {
|
|
23
|
+
const start = firstDay ?? getWeekInfo(locale).firstDay;
|
|
24
|
+
return memo(`w|${locale ?? ""}|${width}|${start}`, () => {
|
|
25
|
+
const formatter = getFormatter(locale, { weekday: width, timeZone: "UTC" });
|
|
26
|
+
// 2021-01-04 was a Monday.
|
|
27
|
+
const monday = toEpochDay(plainDate(2021, 1, 4));
|
|
28
|
+
return Array.from({ length: 7 }, (_, index) => formatter.format((monday + ((start - 1 + index) % 7)) * DAY_MS));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical BCP 47 tag. `undefined` means the runtime default (D11); SSR apps
|
|
3
|
+
* should pass a locale explicitly because server and browser defaults differ.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveLocale(locale?: string): string;
|
|
6
|
+
/** Cached formatter. Always Gregorian: Chrono has no other calendars in v1. */
|
|
7
|
+
export declare function getFormatter(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** Internal: locale resolution and a lazy `Intl.DateTimeFormat` cache (plan 03 §3.2). */
|
|
2
|
+
const formatters = new Map();
|
|
3
|
+
// Both caches are filled on first use, never at import. A drag asks on every frame, once per
|
|
4
|
+
// cell label, and building an `Intl` object each time was most of the cost of a frame.
|
|
5
|
+
let runtime;
|
|
6
|
+
const canonical = new Map();
|
|
7
|
+
function runtimeLocale() {
|
|
8
|
+
runtime ??= new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
9
|
+
return runtime;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Canonical BCP 47 tag. `undefined` means the runtime default (D11); SSR apps
|
|
13
|
+
* should pass a locale explicitly because server and browser defaults differ.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveLocale(locale) {
|
|
16
|
+
if (locale === undefined || locale === "") {
|
|
17
|
+
return runtimeLocale();
|
|
18
|
+
}
|
|
19
|
+
let resolved = canonical.get(locale);
|
|
20
|
+
if (resolved === undefined) {
|
|
21
|
+
resolved = Intl.getCanonicalLocales(locale)[0] ?? runtimeLocale();
|
|
22
|
+
canonical.set(locale, resolved);
|
|
23
|
+
}
|
|
24
|
+
return resolved;
|
|
25
|
+
}
|
|
26
|
+
/** Cached formatter. Always Gregorian: Chrono has no other calendars in v1. */
|
|
27
|
+
export function getFormatter(locale, options) {
|
|
28
|
+
const resolved = resolveLocale(locale);
|
|
29
|
+
const key = `${resolved}|${JSON.stringify(options)}`;
|
|
30
|
+
let formatter = formatters.get(key);
|
|
31
|
+
if (!formatter) {
|
|
32
|
+
formatter = new Intl.DateTimeFormat(resolved, {
|
|
33
|
+
...options,
|
|
34
|
+
calendar: "gregory",
|
|
35
|
+
});
|
|
36
|
+
formatters.set(key, formatter);
|
|
37
|
+
}
|
|
38
|
+
return formatter;
|
|
39
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WeekInfo } from "../values/types.js";
|
|
2
|
+
/** The built-in table only, for tests that check it against `Intl`. */
|
|
3
|
+
export declare function getFallbackWeekInfo(region: string | undefined): WeekInfo;
|
|
4
|
+
/** First day, weekend and minimal days of a locale's week (D12). */
|
|
5
|
+
export declare function getWeekInfo(locale?: string): WeekInfo;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { resolveLocale } from "./resolve.js";
|
|
2
|
+
/**
|
|
3
|
+
* CLDR `weekData` for regions that differ from Monday / Sat-Sun (D12). Used
|
|
4
|
+
* only when the runtime has no `Intl.Locale` week info. A test compares it
|
|
5
|
+
* with `Intl` where available.
|
|
6
|
+
*/
|
|
7
|
+
const FIRST_DAY_AND_WEEKEND = [
|
|
8
|
+
[
|
|
9
|
+
"AG AS BD BR BS BT BU BW BZ CA CO DM DO ET GT GU HK HN ID IS JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY RH SG SV TH TT TW UM US VE VI WS ZA ZW",
|
|
10
|
+
7,
|
|
11
|
+
[6, 7],
|
|
12
|
+
],
|
|
13
|
+
["IL SA YD YE", 7, [5, 6]],
|
|
14
|
+
["IN", 7, [7]],
|
|
15
|
+
["BH DZ EG IQ JO KW LY OM QA SD SY", 6, [5, 6]],
|
|
16
|
+
["DJ", 6, [6, 7]],
|
|
17
|
+
["AF", 6, [4, 5]],
|
|
18
|
+
["IR", 6, [5]],
|
|
19
|
+
["MV", 5, [6, 7]],
|
|
20
|
+
["UG", 1, [7]],
|
|
21
|
+
];
|
|
22
|
+
/** Regions whose first week needs 4 days in the year (ISO-like); everyone else uses 1. */
|
|
23
|
+
const MINIMAL_DAYS_4 = new Set("AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA".split(" "));
|
|
24
|
+
const byRegion = new Map();
|
|
25
|
+
function regionTable() {
|
|
26
|
+
if (byRegion.size === 0) {
|
|
27
|
+
for (const [regions, firstDay, weekend] of FIRST_DAY_AND_WEEKEND) {
|
|
28
|
+
for (const region of regions.split(" ")) {
|
|
29
|
+
byRegion.set(region, { firstDay, weekend });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return byRegion;
|
|
34
|
+
}
|
|
35
|
+
function regionOf(locale) {
|
|
36
|
+
return locale.region ?? locale.maximize().region;
|
|
37
|
+
}
|
|
38
|
+
/** The built-in table only, for tests that check it against `Intl`. */
|
|
39
|
+
export function getFallbackWeekInfo(region) {
|
|
40
|
+
const row = region ? regionTable().get(region) : undefined;
|
|
41
|
+
return {
|
|
42
|
+
firstDay: row?.firstDay ?? 1,
|
|
43
|
+
weekend: row?.weekend ?? [6, 7],
|
|
44
|
+
minimalDays: region && MINIMAL_DAYS_4.has(region) ? 4 : 1,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** First day, weekend and minimal days of a locale's week (D12). */
|
|
48
|
+
export function getWeekInfo(locale) {
|
|
49
|
+
const parsed = new Intl.Locale(resolveLocale(locale));
|
|
50
|
+
const fallback = getFallbackWeekInfo(regionOf(parsed));
|
|
51
|
+
const native = parsed.getWeekInfo?.() ?? parsed.weekInfo;
|
|
52
|
+
if (!native) {
|
|
53
|
+
return fallback;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
firstDay: native.firstDay,
|
|
57
|
+
weekend: native.weekend,
|
|
58
|
+
minimalDays: (native.minimalDays ?? fallback.minimalDays),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A readable name for a display zone ("Vietnam Time"), for the time-zone label
|
|
3
|
+
* (plan 08 X11). Falls back from `shortGeneric` to `long`, `short` and the zone
|
|
4
|
+
* id itself; never throws.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getTimeZoneLabel(timeZone: string, locale?: string, at?: number): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getFormatter } from "./resolve.js";
|
|
2
|
+
/**
|
|
3
|
+
* A readable name for a display zone ("Vietnam Time"), for the time-zone label
|
|
4
|
+
* (plan 08 X11). Falls back from `shortGeneric` to `long`, `short` and the zone
|
|
5
|
+
* id itself; never throws.
|
|
6
|
+
*/
|
|
7
|
+
export function getTimeZoneLabel(timeZone, locale, at = 0) {
|
|
8
|
+
for (const style of ["shortGeneric", "long", "short"]) {
|
|
9
|
+
try {
|
|
10
|
+
const part = getFormatter(locale, {
|
|
11
|
+
timeZone,
|
|
12
|
+
timeZoneName: style,
|
|
13
|
+
})
|
|
14
|
+
.formatToParts(at)
|
|
15
|
+
.find((item) => item.type === "timeZoneName")?.value;
|
|
16
|
+
if (part)
|
|
17
|
+
return part;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Try the next style.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return timeZone;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PlainDate } from "../values/types.js";
|
|
2
|
+
/** Inclusive on both ends (D9). */
|
|
3
|
+
export type DateRange = {
|
|
4
|
+
start: PlainDate;
|
|
5
|
+
end: PlainDate;
|
|
6
|
+
};
|
|
7
|
+
/** Swap so that `start <= end` (F13 auto-swap). */
|
|
8
|
+
export declare function normalizeDateRange(a: PlainDate, b: PlainDate): DateRange;
|
|
9
|
+
export declare function isDateInRange(date: PlainDate, range: DateRange): boolean;
|
|
10
|
+
/** Number of days, both ends included. */
|
|
11
|
+
export declare function dateRangeLength(range: DateRange): number;
|
|
12
|
+
export declare function dateRangesOverlap(a: DateRange, b: DateRange): boolean;
|
|
13
|
+
/** The shared days of two ranges, or `null`. */
|
|
14
|
+
export declare function intersectDateRanges(a: DateRange, b: DateRange): DateRange | null;
|
|
15
|
+
/** Pull a date into the range. */
|
|
16
|
+
export declare function clampDate(date: PlainDate, range: DateRange): PlainDate;
|
|
17
|
+
/** Every day of the range, in order. */
|
|
18
|
+
export declare function eachDay(range: DateRange): Generator<PlainDate, void, undefined>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fromEpochDay, toEpochDay } from "../values/plain-date.js";
|
|
2
|
+
import { compare } from "../values/compare.js";
|
|
3
|
+
/** Swap so that `start <= end` (F13 auto-swap). */
|
|
4
|
+
export function normalizeDateRange(a, b) {
|
|
5
|
+
return compare(a, b) <= 0 ? { start: a, end: b } : { start: b, end: a };
|
|
6
|
+
}
|
|
7
|
+
export function isDateInRange(date, range) {
|
|
8
|
+
return compare(date, range.start) >= 0 && compare(date, range.end) <= 0;
|
|
9
|
+
}
|
|
10
|
+
/** Number of days, both ends included. */
|
|
11
|
+
export function dateRangeLength(range) {
|
|
12
|
+
return toEpochDay(range.end) - toEpochDay(range.start) + 1;
|
|
13
|
+
}
|
|
14
|
+
export function dateRangesOverlap(a, b) {
|
|
15
|
+
return compare(a.start, b.end) <= 0 && compare(b.start, a.end) <= 0;
|
|
16
|
+
}
|
|
17
|
+
/** The shared days of two ranges, or `null`. */
|
|
18
|
+
export function intersectDateRanges(a, b) {
|
|
19
|
+
if (!dateRangesOverlap(a, b)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
start: compare(a.start, b.start) >= 0 ? a.start : b.start,
|
|
24
|
+
end: compare(a.end, b.end) <= 0 ? a.end : b.end,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Pull a date into the range. */
|
|
28
|
+
export function clampDate(date, range) {
|
|
29
|
+
if (compare(date, range.start) < 0) {
|
|
30
|
+
return range.start;
|
|
31
|
+
}
|
|
32
|
+
return compare(date, range.end) > 0 ? range.end : date;
|
|
33
|
+
}
|
|
34
|
+
/** Every day of the range, in order. */
|
|
35
|
+
export function* eachDay(range) {
|
|
36
|
+
const last = toEpochDay(range.end);
|
|
37
|
+
for (let day = toEpochDay(range.start); day <= last; day += 1) {
|
|
38
|
+
yield fromEpochDay(day);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { clampDate, dateRangeLength, dateRangesOverlap, eachDay, intersectDateRanges, isDateInRange, normalizeDateRange, } from "./date-range.js";
|
|
2
|
+
export type { DateRange } from "./date-range.js";
|
|
3
|
+
export { intervalDuration, intervalsOverlap, splitIntervalByDay } from "./interval.js";
|
|
4
|
+
export type { Interval, IntervalPiece } from "./interval.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PlainDate, PlainDateTime, ZonedDateTime } from "../values/types.js";
|
|
2
|
+
/** Half-open `[start, end)` (D9). Both ends are the same kind of value. */
|
|
3
|
+
export type Interval<T extends PlainDateTime | ZonedDateTime = PlainDateTime | ZonedDateTime> = {
|
|
4
|
+
start: T;
|
|
5
|
+
end: T;
|
|
6
|
+
};
|
|
7
|
+
export type IntervalPiece<T extends PlainDateTime | ZonedDateTime> = {
|
|
8
|
+
date: PlainDate;
|
|
9
|
+
start: T;
|
|
10
|
+
end: T;
|
|
11
|
+
/** The interval started on an earlier day. */
|
|
12
|
+
continuesBefore: boolean;
|
|
13
|
+
/** The interval ends on a later day. */
|
|
14
|
+
continuesAfter: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function intervalsOverlap<T extends PlainDateTime | ZonedDateTime>(a: Interval<T>, b: Interval<T>): boolean;
|
|
17
|
+
/** Length in milliseconds: elapsed time for zoned values, wall-clock for plain ones. */
|
|
18
|
+
export declare function intervalDuration(interval: Interval): number;
|
|
19
|
+
/**
|
|
20
|
+
* Split an interval at midnight. Zoned intervals are split at local midnight
|
|
21
|
+
* in `timeZone` (default: the start's zone), so 23 and 25 hour days come out
|
|
22
|
+
* with their real length. Empty or reversed intervals return no pieces.
|
|
23
|
+
*/
|
|
24
|
+
export declare function splitIntervalByDay<T extends PlainDateTime | ZonedDateTime>(interval: Interval<T>, timeZone?: string): IntervalPiece<T>[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { compare } from "../values/compare.js";
|
|
2
|
+
import { plainDateTime, wallSeconds } from "../values/plain-date-time.js";
|
|
3
|
+
import { addDays, fromEpochDay, toEpochDay } from "../values/plain-date.js";
|
|
4
|
+
import { plainTime } from "../values/plain-time.js";
|
|
5
|
+
import { toInstant, toZoned, withTimeZone } from "../values/zoned.js";
|
|
6
|
+
export function intervalsOverlap(a, b) {
|
|
7
|
+
return compare(a.start, b.end) < 0 && compare(b.start, a.end) < 0;
|
|
8
|
+
}
|
|
9
|
+
/** Length in milliseconds: elapsed time for zoned values, wall-clock for plain ones. */
|
|
10
|
+
export function intervalDuration(interval) {
|
|
11
|
+
const { start, end } = interval;
|
|
12
|
+
if ("timeZone" in start && "timeZone" in end) {
|
|
13
|
+
return toInstant(end) - toInstant(start);
|
|
14
|
+
}
|
|
15
|
+
return (wallSeconds(end) - wallSeconds(start)) * 1000;
|
|
16
|
+
}
|
|
17
|
+
function isZoned(value) {
|
|
18
|
+
return "timeZone" in value;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Split an interval at midnight. Zoned intervals are split at local midnight
|
|
22
|
+
* in `timeZone` (default: the start's zone), so 23 and 25 hour days come out
|
|
23
|
+
* with their real length. Empty or reversed intervals return no pieces.
|
|
24
|
+
*/
|
|
25
|
+
export function splitIntervalByDay(interval, timeZone) {
|
|
26
|
+
if (compare(interval.start, interval.end) >= 0) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const zoned = isZoned(interval.start);
|
|
30
|
+
const zone = zoned ? (timeZone ?? interval.start.timeZone) : "";
|
|
31
|
+
const start = (zoned ? withTimeZone(interval.start, zone) : interval.start);
|
|
32
|
+
const end = (zoned ? withTimeZone(interval.end, zone) : interval.end);
|
|
33
|
+
const dayStart = (date) => {
|
|
34
|
+
const wall = plainDateTime(date, plainTime(0, 0, 0));
|
|
35
|
+
return zoned ? toZoned(wall, zone) : wall;
|
|
36
|
+
};
|
|
37
|
+
const firstDay = toEpochDay(start);
|
|
38
|
+
const endsAtMidnight = end.hour === 0 && end.minute === 0 && end.second === 0;
|
|
39
|
+
const lastDay = toEpochDay(end) - (endsAtMidnight ? 1 : 0);
|
|
40
|
+
const pieces = [];
|
|
41
|
+
for (let day = firstDay; day <= lastDay; day += 1) {
|
|
42
|
+
const date = fromEpochDay(day);
|
|
43
|
+
const begin = day === firstDay ? interval.start : dayStart(date);
|
|
44
|
+
const finish = day === lastDay ? interval.end : dayStart(addDays(date, 1));
|
|
45
|
+
pieces.push({
|
|
46
|
+
date,
|
|
47
|
+
start: begin,
|
|
48
|
+
end: finish,
|
|
49
|
+
continuesBefore: day > firstDay,
|
|
50
|
+
continuesAfter: day < lastDay,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return pieces;
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute records returned by controllers. `true` means "present with an
|
|
3
|
+
* empty value", `false` and `undefined` mean "absent". Adapters turn a record
|
|
4
|
+
* into framework props; controllers never return event handlers.
|
|
5
|
+
*/
|
|
6
|
+
export type Attributes = Record<string, string | number | boolean | undefined>;
|
|
7
|
+
/** Later records win. `undefined` values never override. */
|
|
8
|
+
export declare function mergeAttributes(...records: (Attributes | undefined)[]): Attributes;
|
|
9
|
+
/** Drop absent attributes and turn every value into a string (`true` becomes `""`). */
|
|
10
|
+
export declare function normalizeAttributes(record: Attributes): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* Split `--chrono-*` CSS custom properties out of an attribute record
|
|
13
|
+
* (plan 05 R2): a record key starting with `--chrono-` is a style property,
|
|
14
|
+
* not an attribute. Numbers become unitless strings.
|
|
15
|
+
*/
|
|
16
|
+
export declare function splitProperties(record: Attributes): {
|
|
17
|
+
attributes: Attributes;
|
|
18
|
+
properties: Record<string, string>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Later records win. `undefined` values never override. */
|
|
2
|
+
export function mergeAttributes(...records) {
|
|
3
|
+
const merged = {};
|
|
4
|
+
for (const record of records) {
|
|
5
|
+
for (const [key, value] of Object.entries(record ?? {})) {
|
|
6
|
+
if (value !== undefined) {
|
|
7
|
+
merged[key] = value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return merged;
|
|
12
|
+
}
|
|
13
|
+
/** Drop absent attributes and turn every value into a string (`true` becomes `""`). */
|
|
14
|
+
export function normalizeAttributes(record) {
|
|
15
|
+
const normalized = {};
|
|
16
|
+
for (const [key, value] of Object.entries(record)) {
|
|
17
|
+
if (value === undefined || value === false) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
normalized[key] = value === true ? "" : String(value);
|
|
21
|
+
}
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Split `--chrono-*` CSS custom properties out of an attribute record
|
|
26
|
+
* (plan 05 R2): a record key starting with `--chrono-` is a style property,
|
|
27
|
+
* not an attribute. Numbers become unitless strings.
|
|
28
|
+
*/
|
|
29
|
+
export function splitProperties(record) {
|
|
30
|
+
const attributes = {};
|
|
31
|
+
const properties = {};
|
|
32
|
+
for (const [key, value] of Object.entries(record)) {
|
|
33
|
+
if (key.startsWith("--chrono-")) {
|
|
34
|
+
if (value !== undefined && value !== false) {
|
|
35
|
+
properties[key] = value === true ? "" : String(value);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (value !== undefined) {
|
|
39
|
+
attributes[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { attributes, properties };
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ControllableOptions<T> = {
|
|
2
|
+
/** Controlled when not `undefined`. */
|
|
3
|
+
value?: T | undefined;
|
|
4
|
+
defaultValue: T;
|
|
5
|
+
onChange?: (value: T) => void;
|
|
6
|
+
/** Suppresses change events for equal values (`isSameDay`, ...). */
|
|
7
|
+
equals?: (a: T, b: T) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export type Controllable<T> = {
|
|
10
|
+
get(): T;
|
|
11
|
+
/** Request a new value. Controlled: only calls `onChange`. Uncontrolled: stores it, then calls `onChange`. */
|
|
12
|
+
set(next: T): void;
|
|
13
|
+
isControlled(): boolean;
|
|
14
|
+
/** Re-sync with the latest props. Notifies subscribers when the visible value changed. */
|
|
15
|
+
sync(options: Partial<Omit<ControllableOptions<T>, "defaultValue">>): void;
|
|
16
|
+
subscribe(listener: (value: T) => void): () => void;
|
|
17
|
+
};
|
|
18
|
+
/** The controlled / uncontrolled convention of plan 02 §2.3. */
|
|
19
|
+
export declare function createControllable<T>(options: ControllableOptions<T>): Controllable<T>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The controlled / uncontrolled convention of plan 02 §2.3. */
|
|
2
|
+
export function createControllable(options) {
|
|
3
|
+
let value = options.value;
|
|
4
|
+
let onChange = options.onChange;
|
|
5
|
+
let equals = options.equals ?? Object.is;
|
|
6
|
+
let internal = options.defaultValue;
|
|
7
|
+
const listeners = new Set();
|
|
8
|
+
const current = () => (value !== undefined ? value : internal);
|
|
9
|
+
const notify = () => {
|
|
10
|
+
const visible = current();
|
|
11
|
+
for (const listener of [...listeners]) {
|
|
12
|
+
listener(visible);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
get: current,
|
|
17
|
+
isControlled: () => value !== undefined,
|
|
18
|
+
set(next) {
|
|
19
|
+
if (equals(current(), next)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (value === undefined) {
|
|
23
|
+
internal = next;
|
|
24
|
+
notify();
|
|
25
|
+
}
|
|
26
|
+
onChange?.(next);
|
|
27
|
+
},
|
|
28
|
+
sync(next) {
|
|
29
|
+
const before = current();
|
|
30
|
+
if ("value" in next) {
|
|
31
|
+
value = next.value;
|
|
32
|
+
}
|
|
33
|
+
if ("onChange" in next) {
|
|
34
|
+
onChange = next.onChange;
|
|
35
|
+
}
|
|
36
|
+
if (next.equals) {
|
|
37
|
+
equals = next.equals;
|
|
38
|
+
}
|
|
39
|
+
if (!equals(before, current())) {
|
|
40
|
+
notify();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
subscribe(listener) {
|
|
44
|
+
listeners.add(listener);
|
|
45
|
+
return () => {
|
|
46
|
+
listeners.delete(listener);
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isBrowser(): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Id source for Core-generated nodes (plan 08-1 Step 2, X11).
|
|
3
|
+
*
|
|
4
|
+
* The engine owns the page-wide counter, so every Core copy and every adapter on
|
|
5
|
+
* the page shares one sequence: ids are `zealakit-<prefix>-<n>` and two bundled
|
|
6
|
+
* copies cannot collide. Adapters still pass framework ids (`useId`, `$props.id()`)
|
|
7
|
+
* for SSR; this is the fallback for direct Core use.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createId(prefix: string): string;
|