@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,30 @@
|
|
|
1
|
+
import type { PlainTime } from "../values/types.js";
|
|
2
|
+
export type TimeStep = {
|
|
3
|
+
minutes?: number;
|
|
4
|
+
seconds?: number;
|
|
5
|
+
};
|
|
6
|
+
export type TimeConstraints = {
|
|
7
|
+
min?: PlainTime | undefined;
|
|
8
|
+
max?: PlainTime | undefined;
|
|
9
|
+
step?: TimeStep | undefined;
|
|
10
|
+
/** Half-open `[start, end)`. */
|
|
11
|
+
disabledRanges?: readonly {
|
|
12
|
+
start: PlainTime;
|
|
13
|
+
end: PlainTime;
|
|
14
|
+
}[] | undefined;
|
|
15
|
+
isTimeDisabled?: ((time: PlainTime) => boolean) | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type TimeStatusReason = "before-min" | "after-max" | "off-step" | "disabled-range" | "disabled";
|
|
18
|
+
export type TimeStatus = {
|
|
19
|
+
selectable: boolean;
|
|
20
|
+
reason?: TimeStatusReason;
|
|
21
|
+
};
|
|
22
|
+
/** Step length in seconds; `0` when no step is set. */
|
|
23
|
+
export declare function stepToSeconds(step: TimeStep | undefined): number;
|
|
24
|
+
/** Order: min, max, step alignment (from midnight), disabled ranges, predicate. */
|
|
25
|
+
export declare function getTimeStatus(time: PlainTime, constraints?: TimeConstraints): TimeStatus;
|
|
26
|
+
/**
|
|
27
|
+
* Snap to a multiple of `step` counted from midnight. A result that would
|
|
28
|
+
* reach 24:00 falls back to the last step inside the day.
|
|
29
|
+
*/
|
|
30
|
+
export declare function snapTime(time: PlainTime, step: TimeStep, mode: "nearest" | "floor" | "ceil"): PlainTime;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { compare } from "../values/compare.js";
|
|
2
|
+
import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay } from "../values/plain-time.js";
|
|
3
|
+
/** Step length in seconds; `0` when no step is set. */
|
|
4
|
+
export function stepToSeconds(step) {
|
|
5
|
+
const seconds = (step?.minutes ?? 0) * 60 + (step?.seconds ?? 0);
|
|
6
|
+
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
7
|
+
throw new RangeError("Time step must be a positive number of minutes or seconds.");
|
|
8
|
+
}
|
|
9
|
+
return seconds;
|
|
10
|
+
}
|
|
11
|
+
/** Order: min, max, step alignment (from midnight), disabled ranges, predicate. */
|
|
12
|
+
export function getTimeStatus(time, constraints = {}) {
|
|
13
|
+
const { min, max, step, disabledRanges, isTimeDisabled } = constraints;
|
|
14
|
+
if (min && compare(time, min) < 0) {
|
|
15
|
+
return { selectable: false, reason: "before-min" };
|
|
16
|
+
}
|
|
17
|
+
if (max && compare(time, max) > 0) {
|
|
18
|
+
return { selectable: false, reason: "after-max" };
|
|
19
|
+
}
|
|
20
|
+
const stepSeconds = stepToSeconds(step);
|
|
21
|
+
if (stepSeconds > 0 && toSecondOfDay(time) % stepSeconds !== 0) {
|
|
22
|
+
return { selectable: false, reason: "off-step" };
|
|
23
|
+
}
|
|
24
|
+
for (const range of disabledRanges ?? []) {
|
|
25
|
+
if (compare(time, range.start) >= 0 && compare(time, range.end) < 0) {
|
|
26
|
+
return { selectable: false, reason: "disabled-range" };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (isTimeDisabled?.(time)) {
|
|
30
|
+
return { selectable: false, reason: "disabled" };
|
|
31
|
+
}
|
|
32
|
+
return { selectable: true };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Snap to a multiple of `step` counted from midnight. A result that would
|
|
36
|
+
* reach 24:00 falls back to the last step inside the day.
|
|
37
|
+
*/
|
|
38
|
+
export function snapTime(time, step, mode) {
|
|
39
|
+
const size = stepToSeconds(step);
|
|
40
|
+
if (size === 0) {
|
|
41
|
+
return time;
|
|
42
|
+
}
|
|
43
|
+
const seconds = toSecondOfDay(time);
|
|
44
|
+
const floor = Math.floor(seconds / size) * size;
|
|
45
|
+
let snapped = floor;
|
|
46
|
+
if (mode === "ceil") {
|
|
47
|
+
snapped = floor === seconds ? floor : floor + size;
|
|
48
|
+
}
|
|
49
|
+
else if (mode === "nearest") {
|
|
50
|
+
snapped = seconds - floor >= size / 2 ? floor + size : floor;
|
|
51
|
+
}
|
|
52
|
+
if (snapped >= SECONDS_PER_DAY) {
|
|
53
|
+
snapped = Math.floor((SECONDS_PER_DAY - 1) / size) * size;
|
|
54
|
+
}
|
|
55
|
+
return fromSecondOfDay(snapped);
|
|
56
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { getMonthGrid, getMonths } from "./month-grid.js";
|
|
2
|
+
export type { GridDay, GridWeek, MonthGrid, MonthGridOptions } from "./month-grid.js";
|
|
3
|
+
export { getDecadeGrid, getYearGrid } from "./year-grid.js";
|
|
4
|
+
export type { DecadeCell, DecadeGrid, MonthCell, YearGrid } from "./year-grid.js";
|
|
5
|
+
export { getWeekdayHeaders } from "./weekday-headers.js";
|
|
6
|
+
export type { WeekdayHeader } from "./weekday-headers.js";
|
|
7
|
+
export { getTimeAxis } from "./time-axis.js";
|
|
8
|
+
export type { TimeAxisOptions, TimeSlot } from "./time-axis.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DayOfWeek, PlainDate, WeekInfo } from "../values/types.js";
|
|
2
|
+
export type GridDay = {
|
|
3
|
+
date: PlainDate;
|
|
4
|
+
dayOfWeek: DayOfWeek;
|
|
5
|
+
outsideMonth: boolean;
|
|
6
|
+
weekend: boolean;
|
|
7
|
+
/** Only set when `today` is passed in the options. */
|
|
8
|
+
today: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type GridWeek = {
|
|
11
|
+
weekNumber: number;
|
|
12
|
+
days: GridDay[];
|
|
13
|
+
};
|
|
14
|
+
export type MonthGrid = {
|
|
15
|
+
year: number;
|
|
16
|
+
month: number;
|
|
17
|
+
weeks: GridWeek[];
|
|
18
|
+
};
|
|
19
|
+
export type MonthGridOptions = {
|
|
20
|
+
weekStartsOn: DayOfWeek;
|
|
21
|
+
/** Source of the weekend days (default Saturday and Sunday) and of locale week numbers. */
|
|
22
|
+
weekInfo?: Pick<WeekInfo, "weekend"> & Partial<Pick<WeekInfo, "firstDay" | "minimalDays">>;
|
|
23
|
+
/** Always render 6 rows so the grid height is stable. */
|
|
24
|
+
fixedWeeks?: boolean | undefined;
|
|
25
|
+
today?: PlainDate;
|
|
26
|
+
weekNumbers?: "iso" | "locale" | undefined;
|
|
27
|
+
};
|
|
28
|
+
export declare function getMonthGrid(year: number, month: number, options: MonthGridOptions): MonthGrid;
|
|
29
|
+
/** `count` consecutive month grids starting at `start`'s month. */
|
|
30
|
+
export declare function getMonths(start: {
|
|
31
|
+
year: number;
|
|
32
|
+
month: number;
|
|
33
|
+
}, count: number, options: MonthGridOptions): MonthGrid[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { compare } from "../values/compare.js";
|
|
2
|
+
import { daysInMonth, dayOfWeekFromEpochDay, fromEpochDay, plainDate, toEpochDay, } from "../values/plain-date.js";
|
|
3
|
+
import { getIsoWeek, getLocaleWeek } from "../values/week.js";
|
|
4
|
+
const DEFAULT_WEEKEND = [6, 7];
|
|
5
|
+
export function getMonthGrid(year, month, options) {
|
|
6
|
+
const first = plainDate(year, month, 1);
|
|
7
|
+
const firstEpoch = toEpochDay(first);
|
|
8
|
+
const lead = (dayOfWeekFromEpochDay(firstEpoch) - options.weekStartsOn + 7) % 7;
|
|
9
|
+
const startEpoch = firstEpoch - lead;
|
|
10
|
+
const used = lead + daysInMonth(year, month);
|
|
11
|
+
const rows = options.fixedWeeks ? 6 : Math.ceil(used / 7);
|
|
12
|
+
const weekend = options.weekInfo?.weekend ?? DEFAULT_WEEKEND;
|
|
13
|
+
const localeRules = {
|
|
14
|
+
firstDay: options.weekInfo?.firstDay ?? options.weekStartsOn,
|
|
15
|
+
minimalDays: options.weekInfo?.minimalDays ?? 1,
|
|
16
|
+
};
|
|
17
|
+
const weeks = [];
|
|
18
|
+
for (let row = 0; row < rows; row += 1) {
|
|
19
|
+
const days = [];
|
|
20
|
+
for (let column = 0; column < 7; column += 1) {
|
|
21
|
+
const epoch = startEpoch + row * 7 + column;
|
|
22
|
+
const date = fromEpochDay(epoch);
|
|
23
|
+
const weekday = dayOfWeekFromEpochDay(epoch);
|
|
24
|
+
days.push({
|
|
25
|
+
date,
|
|
26
|
+
dayOfWeek: weekday,
|
|
27
|
+
outsideMonth: date.month !== month || date.year !== year,
|
|
28
|
+
weekend: weekend.includes(weekday),
|
|
29
|
+
today: options.today ? compare(date, options.today) === 0 : false,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// ISO weeks are named by their Thursday; locale weeks by the row's first day.
|
|
33
|
+
const reference = options.weekNumbers === "locale"
|
|
34
|
+
? days[0]
|
|
35
|
+
: days.find((day) => day.dayOfWeek === 4);
|
|
36
|
+
const weekNumber = options.weekNumbers === "locale"
|
|
37
|
+
? getLocaleWeek(reference.date, localeRules).week
|
|
38
|
+
: getIsoWeek(reference.date).week;
|
|
39
|
+
weeks.push({ weekNumber, days });
|
|
40
|
+
}
|
|
41
|
+
return { year, month, weeks };
|
|
42
|
+
}
|
|
43
|
+
/** `count` consecutive month grids starting at `start`'s month. */
|
|
44
|
+
export function getMonths(start, count, options) {
|
|
45
|
+
const grids = [];
|
|
46
|
+
for (let index = 0; index < count; index += 1) {
|
|
47
|
+
const total = start.year * 12 + (start.month - 1) + index;
|
|
48
|
+
const year = Math.floor(total / 12);
|
|
49
|
+
grids.push(getMonthGrid(year, total - year * 12 + 1, options));
|
|
50
|
+
}
|
|
51
|
+
return grids;
|
|
52
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type TimeStep } from "../constraints/time.js";
|
|
2
|
+
import type { PlainTime } from "../values/types.js";
|
|
3
|
+
export type TimeSlot = {
|
|
4
|
+
index: number;
|
|
5
|
+
start: PlainTime;
|
|
6
|
+
/** Wraps to 00:00:00 for a slot ending at 24:00; use `endSecond` to tell them apart. */
|
|
7
|
+
end: PlainTime;
|
|
8
|
+
startSecond: number;
|
|
9
|
+
/** Seconds since midnight, up to 86400. */
|
|
10
|
+
endSecond: number;
|
|
11
|
+
working: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type TimeAxisOptions = {
|
|
14
|
+
start?: PlainTime | undefined;
|
|
15
|
+
/** Exclusive. Omit for the end of the day (24:00). */
|
|
16
|
+
end?: PlainTime | undefined;
|
|
17
|
+
step: TimeStep;
|
|
18
|
+
/** Half-open `[start, end)` ranges; an `end` of 00:00 means 24:00. */
|
|
19
|
+
workingHours?: readonly {
|
|
20
|
+
start: PlainTime;
|
|
21
|
+
end: PlainTime;
|
|
22
|
+
}[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
/** Wall-time slots. DST is handled at layout time, where real days are known. */
|
|
25
|
+
export declare function getTimeAxis(options: TimeAxisOptions): TimeSlot[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { stepToSeconds } from "../constraints/time.js";
|
|
2
|
+
import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay } from "../values/plain-time.js";
|
|
3
|
+
/** Wall-time slots. DST is handled at layout time, where real days are known. */
|
|
4
|
+
export function getTimeAxis(options) {
|
|
5
|
+
const size = stepToSeconds(options.step);
|
|
6
|
+
if (size <= 0) {
|
|
7
|
+
throw new RangeError("Time axis step must be greater than zero.");
|
|
8
|
+
}
|
|
9
|
+
const from = options.start ? toSecondOfDay(options.start) : 0;
|
|
10
|
+
const to = options.end ? toSecondOfDay(options.end) : SECONDS_PER_DAY;
|
|
11
|
+
if (to <= from) {
|
|
12
|
+
throw new RangeError("Time axis end must be after start.");
|
|
13
|
+
}
|
|
14
|
+
const working = (options.workingHours ?? []).map((range) => {
|
|
15
|
+
const start = toSecondOfDay(range.start);
|
|
16
|
+
const end = toSecondOfDay(range.end);
|
|
17
|
+
return [start, end === 0 && start > 0 ? SECONDS_PER_DAY : end];
|
|
18
|
+
});
|
|
19
|
+
const slots = [];
|
|
20
|
+
for (let startSecond = from, index = 0; startSecond < to; startSecond += size, index += 1) {
|
|
21
|
+
const endSecond = Math.min(startSecond + size, to);
|
|
22
|
+
slots.push({
|
|
23
|
+
index,
|
|
24
|
+
start: fromSecondOfDay(startSecond),
|
|
25
|
+
end: fromSecondOfDay(endSecond % SECONDS_PER_DAY),
|
|
26
|
+
startSecond,
|
|
27
|
+
endSecond,
|
|
28
|
+
working: working.some(([start, end]) => startSecond >= start && startSecond < end),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return slots;
|
|
32
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DayOfWeek } from "../values/types.js";
|
|
2
|
+
export type WeekdayHeader = {
|
|
3
|
+
dayOfWeek: DayOfWeek;
|
|
4
|
+
short: string;
|
|
5
|
+
long: string;
|
|
6
|
+
weekend: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Column headers starting at `weekStartsOn`. `hiddenDays` drops columns (a
|
|
10
|
+
* work week hides Saturday and Sunday). `width` picks the form used for
|
|
11
|
+
* `short`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getWeekdayHeaders(locale: string | undefined, options: {
|
|
14
|
+
weekStartsOn: DayOfWeek;
|
|
15
|
+
hiddenDays?: readonly DayOfWeek[];
|
|
16
|
+
width?: "short" | "narrow";
|
|
17
|
+
}): WeekdayHeader[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getWeekdayNames } from "../locale/names.js";
|
|
2
|
+
import { getWeekInfo } from "../locale/week-info.js";
|
|
3
|
+
/**
|
|
4
|
+
* Column headers starting at `weekStartsOn`. `hiddenDays` drops columns (a
|
|
5
|
+
* work week hides Saturday and Sunday). `width` picks the form used for
|
|
6
|
+
* `short`.
|
|
7
|
+
*/
|
|
8
|
+
export function getWeekdayHeaders(locale, options) {
|
|
9
|
+
const { weekStartsOn, hiddenDays = [], width = "short" } = options;
|
|
10
|
+
const short = getWeekdayNames(locale, width, weekStartsOn);
|
|
11
|
+
const long = getWeekdayNames(locale, "long", weekStartsOn);
|
|
12
|
+
const weekend = getWeekInfo(locale).weekend;
|
|
13
|
+
const headers = [];
|
|
14
|
+
for (let index = 0; index < 7; index += 1) {
|
|
15
|
+
const dayOfWeek = (((weekStartsOn - 1 + index) % 7) + 1);
|
|
16
|
+
if (!hiddenDays.includes(dayOfWeek)) {
|
|
17
|
+
headers.push({
|
|
18
|
+
dayOfWeek,
|
|
19
|
+
short: short[index],
|
|
20
|
+
long: long[index],
|
|
21
|
+
weekend: weekend.includes(dayOfWeek),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type MonthCell = {
|
|
2
|
+
year: number;
|
|
3
|
+
month: number;
|
|
4
|
+
};
|
|
5
|
+
export type YearGrid = {
|
|
6
|
+
year: number;
|
|
7
|
+
columns: number;
|
|
8
|
+
rows: MonthCell[][];
|
|
9
|
+
};
|
|
10
|
+
/** The 12 months of `year`, split into rows (default 4 columns, 3 rows). */
|
|
11
|
+
export declare function getYearGrid(year: number, options?: {
|
|
12
|
+
columns?: number;
|
|
13
|
+
}): YearGrid;
|
|
14
|
+
export type DecadeCell = {
|
|
15
|
+
year: number;
|
|
16
|
+
outsideDecade: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type DecadeGrid = {
|
|
19
|
+
startYear: number;
|
|
20
|
+
endYear: number;
|
|
21
|
+
years: DecadeCell[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `size` years around `year` (default 12): the decade containing it plus one
|
|
25
|
+
* year before and the rest after, so the grid fills evenly.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDecadeGrid(year: number, options?: {
|
|
28
|
+
size?: number;
|
|
29
|
+
}): DecadeGrid;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MAX_YEAR, MIN_YEAR } from "../values/epoch-day.js";
|
|
2
|
+
/** The 12 months of `year`, split into rows (default 4 columns, 3 rows). */
|
|
3
|
+
export function getYearGrid(year, options = {}) {
|
|
4
|
+
const columns = options.columns ?? 4;
|
|
5
|
+
if (!Number.isInteger(columns) || columns < 1 || columns > 12) {
|
|
6
|
+
throw new RangeError("columns must be an integer from 1 to 12.");
|
|
7
|
+
}
|
|
8
|
+
const rows = [];
|
|
9
|
+
for (let month = 1; month <= 12; month += 1) {
|
|
10
|
+
if ((month - 1) % columns === 0) {
|
|
11
|
+
rows.push([]);
|
|
12
|
+
}
|
|
13
|
+
rows[rows.length - 1].push({ year, month });
|
|
14
|
+
}
|
|
15
|
+
return { year, columns, rows };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* `size` years around `year` (default 12): the decade containing it plus one
|
|
19
|
+
* year before and the rest after, so the grid fills evenly.
|
|
20
|
+
*/
|
|
21
|
+
export function getDecadeGrid(year, options = {}) {
|
|
22
|
+
const size = options.size ?? 12;
|
|
23
|
+
if (!Number.isInteger(size) || size < 1) {
|
|
24
|
+
throw new RangeError("size must be a positive integer.");
|
|
25
|
+
}
|
|
26
|
+
const decade = Math.floor(year / 10) * 10;
|
|
27
|
+
const years = [];
|
|
28
|
+
for (let index = 0; index < size; index += 1) {
|
|
29
|
+
const value = decade - 1 + index;
|
|
30
|
+
if (value >= MIN_YEAR && value <= MAX_YEAR) {
|
|
31
|
+
years.push({
|
|
32
|
+
year: value,
|
|
33
|
+
outsideDecade: value < decade || value > decade + 9,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const first = years[0]?.year ?? decade;
|
|
38
|
+
const last = years[years.length - 1]?.year ?? decade;
|
|
39
|
+
return { startYear: first, endYear: last, years };
|
|
40
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./values/index.js";
|
|
2
|
+
export * from "./locale/index.js";
|
|
3
|
+
export * from "./constraints/index.js";
|
|
4
|
+
export * from "./ranges/index.js";
|
|
5
|
+
export * from "./grid/index.js";
|
|
6
|
+
export * from "./a11y/index.js";
|
|
7
|
+
export * from "./store/index.js";
|
|
8
|
+
export * from "./input/index.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./values/index.js";
|
|
2
|
+
export * from "./locale/index.js";
|
|
3
|
+
export * from "./constraints/index.js";
|
|
4
|
+
export * from "./ranges/index.js";
|
|
5
|
+
export * from "./grid/index.js";
|
|
6
|
+
export * from "./a11y/index.js";
|
|
7
|
+
export * from "./store/index.js";
|
|
8
|
+
export * from "./input/index.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** One hidden `<input>` a root renders so plain forms and server actions see the value (plan 06 A15). */
|
|
2
|
+
export type HiddenInput = {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
/** Entries without a name produce nothing; `null` submits as an empty string. */
|
|
7
|
+
export declare function getHiddenInputs(entries: readonly (readonly [string | undefined, string | null])[]): HiddenInput[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Entries without a name produce nothing; `null` submits as an empty string. */
|
|
2
|
+
export function getHiddenInputs(entries) {
|
|
3
|
+
const inputs = [];
|
|
4
|
+
for (const [name, value] of entries) {
|
|
5
|
+
if (name) {
|
|
6
|
+
inputs.push({ name, value: value ?? "" });
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return inputs;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { backspace, emptySegment, segmentOf, stepSegment, typeDigit } from "./segment-engine.js";
|
|
2
|
+
export type { SegmentDef, SegmentValue } from "./segment-engine.js";
|
|
3
|
+
export { fold, tokenize } from "./tokenize.js";
|
|
4
|
+
export type { Token } from "./tokenize.js";
|
|
5
|
+
export { getHiddenInputs } from "./form.js";
|
|
6
|
+
export type { HiddenInput } from "./form.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic segmented-input machine (plan 06 §13.2). Pure: no DOM, no dates.
|
|
3
|
+
* Date and Time describe their parts with a `SegmentDef` and drive these
|
|
4
|
+
* functions from their controllers.
|
|
5
|
+
*/
|
|
6
|
+
export type SegmentDef = {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
/** Typing stops accepting digits at this length. */
|
|
10
|
+
maxDigits: number;
|
|
11
|
+
/** Step used by PageUp / PageDown. */
|
|
12
|
+
pageStep: number;
|
|
13
|
+
};
|
|
14
|
+
/** `value` is null until the typed digits form a number in `[min, max]`. */
|
|
15
|
+
export type SegmentValue = {
|
|
16
|
+
value: number | null;
|
|
17
|
+
buffer: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const emptySegment: SegmentValue;
|
|
20
|
+
export declare const segmentOf: (value: number | null) => SegmentValue;
|
|
21
|
+
/**
|
|
22
|
+
* Type one digit. A buffer that would exceed `max` restarts with the digit
|
|
23
|
+
* (typing `3` then `5` in a month yields `5`). `advance` is true when the
|
|
24
|
+
* part cannot take another digit.
|
|
25
|
+
*/
|
|
26
|
+
export declare function typeDigit(def: SegmentDef, segment: SegmentValue, digit: number): {
|
|
27
|
+
segment: SegmentValue;
|
|
28
|
+
advance: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** Step by `delta`, wrapping inside `[min, max]`. An empty part starts at `start`. */
|
|
31
|
+
export declare function stepSegment(def: SegmentDef, segment: SegmentValue, delta: number, start: number): SegmentValue;
|
|
32
|
+
/** Backspace: drop the last typed digit, or clear a part that has no buffer. */
|
|
33
|
+
export declare function backspace(segment: SegmentValue): SegmentValue;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const emptySegment = Object.freeze({
|
|
2
|
+
value: null,
|
|
3
|
+
buffer: "",
|
|
4
|
+
});
|
|
5
|
+
export const segmentOf = (value) => ({
|
|
6
|
+
value,
|
|
7
|
+
buffer: "",
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Type one digit. A buffer that would exceed `max` restarts with the digit
|
|
11
|
+
* (typing `3` then `5` in a month yields `5`). `advance` is true when the
|
|
12
|
+
* part cannot take another digit.
|
|
13
|
+
*/
|
|
14
|
+
export function typeDigit(def, segment, digit) {
|
|
15
|
+
let buffer = segment.buffer.length >= def.maxDigits ? String(digit) : segment.buffer + digit;
|
|
16
|
+
if (Number(buffer) > def.max) {
|
|
17
|
+
buffer = String(digit);
|
|
18
|
+
}
|
|
19
|
+
const n = Number(buffer);
|
|
20
|
+
if (n < def.min && buffer.length >= def.maxDigits) {
|
|
21
|
+
// "00" in a day or month: nothing valid can follow, start over.
|
|
22
|
+
return { segment: { value: null, buffer: "" }, advance: false };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
segment: { value: n >= def.min ? n : null, buffer },
|
|
26
|
+
advance: n >= def.min && (buffer.length >= def.maxDigits || (def.maxDigits === 2 && n * 10 > def.max)),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Step by `delta`, wrapping inside `[min, max]`. An empty part starts at `start`. */
|
|
30
|
+
export function stepSegment(def, segment, delta, start) {
|
|
31
|
+
if (segment.value === null) {
|
|
32
|
+
return segmentOf(Math.min(def.max, Math.max(def.min, start)));
|
|
33
|
+
}
|
|
34
|
+
const range = def.max - def.min + 1;
|
|
35
|
+
const offset = (((segment.value - def.min + delta) % range) + range) % range;
|
|
36
|
+
return segmentOf(def.min + offset);
|
|
37
|
+
}
|
|
38
|
+
/** Backspace: drop the last typed digit, or clear a part that has no buffer. */
|
|
39
|
+
export function backspace(segment) {
|
|
40
|
+
if (segment.buffer.length > 1) {
|
|
41
|
+
const buffer = segment.buffer.slice(0, -1);
|
|
42
|
+
return { value: Number(buffer) || null, buffer };
|
|
43
|
+
}
|
|
44
|
+
return emptySegment;
|
|
45
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Token = {
|
|
2
|
+
type: "number";
|
|
3
|
+
text: string;
|
|
4
|
+
value: number;
|
|
5
|
+
} | {
|
|
6
|
+
type: "word";
|
|
7
|
+
text: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: "separator";
|
|
10
|
+
text: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Split text into numbers, words and separators. Digits of any supported
|
|
14
|
+
* script count as numbers; every other character (including the CJK date
|
|
15
|
+
* marks 年月日) separates.
|
|
16
|
+
*/
|
|
17
|
+
export declare function tokenize(text: string, locale?: string): Token[];
|
|
18
|
+
/** Lower-case and strip accents, so `März` matches `marz`. */
|
|
19
|
+
export declare const fold: (text: string) => string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { toLatinDigits } from "../locale/digits.js";
|
|
2
|
+
/**
|
|
3
|
+
* Split text into numbers, words and separators. Digits of any supported
|
|
4
|
+
* script count as numbers; every other character (including the CJK date
|
|
5
|
+
* marks 年月日) separates.
|
|
6
|
+
*/
|
|
7
|
+
export function tokenize(text, locale) {
|
|
8
|
+
const tokens = [];
|
|
9
|
+
const pattern = /(\d+)|(\p{L}[\p{L}\p{M}'’.]*)|([^\d\p{L}]+)/gu;
|
|
10
|
+
for (const match of toLatinDigits(text, locale).matchAll(pattern)) {
|
|
11
|
+
if (match[1] !== undefined) {
|
|
12
|
+
tokens.push({ type: "number", text: match[1], value: Number(match[1]) });
|
|
13
|
+
}
|
|
14
|
+
else if (match[2] !== undefined && !/^[年月日]$/u.test(match[2])) {
|
|
15
|
+
tokens.push({ type: "word", text: match[2].replace(/\.$/, "") });
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
tokens.push({ type: "separator", text: match[0] });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return tokens;
|
|
22
|
+
}
|
|
23
|
+
/** Lower-case and strip accents, so `März` matches `marz`. */
|
|
24
|
+
export const fold = (text) => text.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The ten digit characters a locale writes (`ar-EG` gives Arabic-Indic digits). */
|
|
2
|
+
export declare function getLocaleDigits(locale?: string): readonly string[];
|
|
3
|
+
/** Latin digits for any Arabic-Indic, Persian, Devanagari, Bengali or full-width digit. */
|
|
4
|
+
export declare function toLatinDigits(text: string, locale?: string): string;
|
|
5
|
+
/** Display a number with the locale's digits. */
|
|
6
|
+
export declare function toLocaleDigits(text: string, locale?: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const cache = new Map();
|
|
2
|
+
/** The ten digit characters a locale writes (`ar-EG` gives Arabic-Indic digits). */
|
|
3
|
+
export function getLocaleDigits(locale) {
|
|
4
|
+
const key = locale ?? "";
|
|
5
|
+
let digits = cache.get(key);
|
|
6
|
+
if (!digits) {
|
|
7
|
+
const format = new Intl.NumberFormat(locale, { useGrouping: false });
|
|
8
|
+
digits = Object.freeze(Array.from({ length: 10 }, (_, index) => format.format(index)));
|
|
9
|
+
cache.set(key, digits);
|
|
10
|
+
}
|
|
11
|
+
return digits;
|
|
12
|
+
}
|
|
13
|
+
/** Zero code points of common non-Latin decimal digit blocks. */
|
|
14
|
+
const ZEROS = [0x660, 0x6f0, 0x966, 0x9e6, 0xff10];
|
|
15
|
+
/** Latin digits for any Arabic-Indic, Persian, Devanagari, Bengali or full-width digit. */
|
|
16
|
+
export function toLatinDigits(text, locale) {
|
|
17
|
+
const local = getLocaleDigits(locale);
|
|
18
|
+
let result = "";
|
|
19
|
+
for (const char of text) {
|
|
20
|
+
const index = local.indexOf(char);
|
|
21
|
+
if (index > 0) {
|
|
22
|
+
result += String(index);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const code = char.codePointAt(0);
|
|
26
|
+
const zero = ZEROS.find((start) => code >= start && code < start + 10);
|
|
27
|
+
result += zero === undefined ? char : String(code - zero);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
/** Display a number with the locale's digits. */
|
|
32
|
+
export function toLocaleDigits(text, locale) {
|
|
33
|
+
const local = getLocaleDigits(locale);
|
|
34
|
+
return text.replace(/\d/g, (digit) => local[Number(digit)]);
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTextDirection(locale?: string): "ltr" | "rtl";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { resolveLocale } from "./resolve.js";
|
|
2
|
+
const RTL_SCRIPTS = new Set([
|
|
3
|
+
"Arab",
|
|
4
|
+
"Hebr",
|
|
5
|
+
"Thaa",
|
|
6
|
+
"Syrc",
|
|
7
|
+
"Nkoo",
|
|
8
|
+
"Adlm",
|
|
9
|
+
"Rohg",
|
|
10
|
+
"Mand",
|
|
11
|
+
"Samr",
|
|
12
|
+
]);
|
|
13
|
+
const RTL_LANGUAGES = new Set(["ar", "he", "fa", "ur", "ps", "sd", "ug", "yi", "dv", "ckb", "ku"]);
|
|
14
|
+
export function getTextDirection(locale) {
|
|
15
|
+
const parsed = new Intl.Locale(resolveLocale(locale));
|
|
16
|
+
const direction = parsed.getTextInfo?.().direction ?? parsed.textInfo?.direction;
|
|
17
|
+
if (direction === "rtl" || direction === "ltr") {
|
|
18
|
+
return direction;
|
|
19
|
+
}
|
|
20
|
+
const script = parsed.script ?? parsed.maximize().script;
|
|
21
|
+
if (script) {
|
|
22
|
+
return RTL_SCRIPTS.has(script) ? "rtl" : "ltr";
|
|
23
|
+
}
|
|
24
|
+
return RTL_LANGUAGES.has(parsed.language) ? "rtl" : "ltr";
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PlainDate, PlainDateTime, PlainTime } from "../values/types.js";
|
|
2
|
+
import type { Messages } from "../a11y/messages.js";
|
|
3
|
+
/** Intl options minus the two the library controls (UTC wall time, Gregorian). */
|
|
4
|
+
export type FormatOptions = Omit<Intl.DateTimeFormatOptions, "timeZone" | "calendar">;
|
|
5
|
+
/** Plain values are formatted as UTC, so the host zone never shifts them. */
|
|
6
|
+
export declare function formatDate(date: PlainDate, locale?: string, options?: FormatOptions): string;
|
|
7
|
+
export declare function formatTime(time: PlainTime, locale?: string, options?: FormatOptions): string;
|
|
8
|
+
export declare function formatDateTime(value: PlainDateTime, locale?: string, options?: FormatOptions): string;
|
|
9
|
+
export declare function formatDateRange(range: {
|
|
10
|
+
start: PlainDate;
|
|
11
|
+
end: PlainDate;
|
|
12
|
+
}, locale?: string, options?: FormatOptions): string;
|
|
13
|
+
/** Same as {@link formatDate} but split into typed parts, for apps that style pieces. */
|
|
14
|
+
export declare function formatDateToParts(date: PlainDate, locale?: string, options?: FormatOptions): Intl.DateTimeFormatPart[];
|
|
15
|
+
export declare function formatDateRangeToParts(range: {
|
|
16
|
+
start: PlainDate;
|
|
17
|
+
end: PlainDate;
|
|
18
|
+
}, locale?: string, options?: FormatOptions): Intl.DateTimeFormatPart[];
|
|
19
|
+
export type DatePartName = "day" | "month" | "year";
|
|
20
|
+
export type DatePartOrder = {
|
|
21
|
+
order: readonly DatePartName[];
|
|
22
|
+
/** Text between the first and second part, and between the second and third. */
|
|
23
|
+
separators: readonly [string, string];
|
|
24
|
+
/** Text before the first part and after the last part (for example the trailing "." in ko-KR). */
|
|
25
|
+
prefix: string;
|
|
26
|
+
suffix: string;
|
|
27
|
+
};
|
|
28
|
+
/** Order and separators of a numeric date, for segmented inputs and placeholders. */
|
|
29
|
+
export declare function getDatePartOrder(locale?: string): DatePartOrder;
|
|
30
|
+
/** A text-mode hint such as `dd/mm/yyyy`, from the locale's part order and the placeholder messages. */
|
|
31
|
+
export declare function getDateFormatPattern(locale: string | undefined, messages: Pick<Messages, "placeholderDay" | "placeholderMonth" | "placeholderYear">): string;
|