@zealakit/chrono-react 0.0.0-stage → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +624 -2
- package/dist/calendar/components.d.ts +346 -0
- package/dist/calendar/components.js +245 -0
- package/dist/calendar/context.d.ts +636 -0
- package/dist/calendar/context.js +21 -0
- package/dist/calendar/index.d.ts +6 -0
- package/dist/calendar/index.js +6 -0
- package/dist/calendar/mini-calendar.d.ts +60 -0
- package/dist/calendar/mini-calendar.js +50 -0
- package/dist/calendar/options.d.ts +4 -0
- package/dist/calendar/options.js +98 -0
- package/dist/calendar/use-calendar.d.ts +340 -0
- package/dist/calendar/use-calendar.js +156 -0
- package/dist/calendar/use-mini-calendar.d.ts +302 -0
- package/dist/calendar/use-mini-calendar.js +56 -0
- package/dist/calendar/utilities.d.ts +9 -0
- package/dist/calendar/utilities.js +8 -0
- package/dist/date/bind-panel.d.ts +30 -0
- package/dist/date/bind-panel.js +125 -0
- package/dist/date/components.d.ts +197 -0
- package/dist/date/components.js +202 -0
- package/dist/date/context.d.ts +34 -0
- package/dist/date/context.js +19 -0
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.js +4 -0
- package/dist/date/options.d.ts +7 -0
- package/dist/date/options.js +91 -0
- package/dist/date/use-date-input.d.ts +43 -0
- package/dist/date/use-date-input.js +138 -0
- package/dist/date/use-date-panel.d.ts +81 -0
- package/dist/date/use-date-panel.js +21 -0
- package/dist/date/utilities.d.ts +4 -0
- package/dist/date/utilities.js +4 -0
- package/dist/datetime/components.d.ts +121 -0
- package/dist/datetime/components.js +169 -0
- package/dist/datetime/context.d.ts +8 -0
- package/dist/datetime/context.js +18 -0
- package/dist/datetime/index.d.ts +4 -0
- package/dist/datetime/index.js +4 -0
- package/dist/datetime/options.d.ts +5 -0
- package/dist/datetime/options.js +99 -0
- package/dist/datetime/use-datetime-input.d.ts +44 -0
- package/dist/datetime/use-datetime-input.js +145 -0
- package/dist/datetime/use-datetime-panel.d.ts +128 -0
- package/dist/datetime/use-datetime-panel.js +60 -0
- package/dist/datetime/utilities.d.ts +4 -0
- package/dist/datetime/utilities.js +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/shared/merge-props.d.ts +9 -0
- package/dist/shared/merge-props.js +33 -0
- package/dist/shared/modifiers.d.ts +7 -0
- package/dist/shared/modifiers.js +6 -0
- package/dist/shared/part.d.ts +10 -0
- package/dist/shared/part.js +9 -0
- package/dist/shared/slot.d.ts +12 -0
- package/dist/shared/slot.js +60 -0
- package/dist/shared/style-properties.d.ts +8 -0
- package/dist/shared/style-properties.js +13 -0
- package/dist/shared/to-react-props.d.ts +11 -0
- package/dist/shared/to-react-props.js +27 -0
- package/dist/time/bind-panel.d.ts +19 -0
- package/dist/time/bind-panel.js +97 -0
- package/dist/time/components.d.ts +183 -0
- package/dist/time/components.js +174 -0
- package/dist/time/context.d.ts +24 -0
- package/dist/time/context.js +19 -0
- package/dist/time/index.d.ts +4 -0
- package/dist/time/index.js +4 -0
- package/dist/time/options.d.ts +5 -0
- package/dist/time/options.js +85 -0
- package/dist/time/use-time-input.d.ts +43 -0
- package/dist/time/use-time-input.js +138 -0
- package/dist/time/use-time-panel.d.ts +37 -0
- package/dist/time/use-time-panel.js +18 -0
- package/dist/time/utilities.d.ts +4 -0
- package/dist/time/utilities.js +4 -0
- package/dist/vendor/core/calendar/availability.d.ts +39 -0
- package/dist/vendor/core/calendar/availability.js +74 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
- package/dist/vendor/core/calendar/controllers/calendar-controller.js +1448 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
- package/dist/vendor/core/calendar/controllers/drag-engine.js +382 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
- package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +170 -0
- package/dist/vendor/core/calendar/controllers/shared.d.ts +29 -0
- package/dist/vendor/core/calendar/controllers/shared.js +82 -0
- package/dist/vendor/core/calendar/events/agenda-layout.d.ts +21 -0
- package/dist/vendor/core/calendar/events/agenda-layout.js +71 -0
- package/dist/vendor/core/calendar/events/all-day-row.d.ts +22 -0
- package/dist/vendor/core/calendar/events/all-day-row.js +93 -0
- package/dist/vendor/core/calendar/events/background-layout.d.ts +66 -0
- package/dist/vendor/core/calendar/events/background-layout.js +107 -0
- package/dist/vendor/core/calendar/events/index.d.ts +17 -0
- package/dist/vendor/core/calendar/events/index.js +8 -0
- package/dist/vendor/core/calendar/events/month-layout.d.ts +13 -0
- package/dist/vendor/core/calendar/events/month-layout.js +156 -0
- package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
- package/dist/vendor/core/calendar/events/normalize.js +159 -0
- package/dist/vendor/core/calendar/events/now-indicator.d.ts +18 -0
- package/dist/vendor/core/calendar/events/now-indicator.js +19 -0
- package/dist/vendor/core/calendar/events/overflow.d.ts +36 -0
- package/dist/vendor/core/calendar/events/overflow.js +112 -0
- package/dist/vendor/core/calendar/events/sort.d.ts +21 -0
- package/dist/vendor/core/calendar/events/sort.js +35 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +22 -0
- package/dist/vendor/core/calendar/events/time-grid-layout.js +184 -0
- package/dist/vendor/core/calendar/events/types.d.ts +141 -0
- package/dist/vendor/core/calendar/events/types.js +1 -0
- package/dist/vendor/core/calendar/index.d.ts +70 -0
- package/dist/vendor/core/calendar/index.js +37 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +19 -0
- package/dist/vendor/core/calendar/interaction/auto-scroll.js +64 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
- package/dist/vendor/core/calendar/interaction/drag-geometry.js +125 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
- package/dist/vendor/core/calendar/interaction/drag-keyboard.js +56 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +23 -0
- package/dist/vendor/core/calendar/interaction/drag-pointer.js +203 -0
- package/dist/vendor/core/calendar/interaction/event-focus.d.ts +28 -0
- package/dist/vendor/core/calendar/interaction/event-focus.js +44 -0
- package/dist/vendor/core/calendar/interaction/hit-test.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/hit-test.js +26 -0
- package/dist/vendor/core/calendar/interaction/pending.d.ts +17 -0
- package/dist/vendor/core/calendar/interaction/pending.js +17 -0
- package/dist/vendor/core/calendar/interaction/pointer.d.ts +21 -0
- package/dist/vendor/core/calendar/interaction/pointer.js +119 -0
- package/dist/vendor/core/calendar/interaction/selection.d.ts +29 -0
- package/dist/vendor/core/calendar/interaction/selection.js +47 -0
- package/dist/vendor/core/calendar/internal/equal.d.ts +3 -0
- package/dist/vendor/core/calendar/internal/equal.js +43 -0
- package/dist/vendor/core/calendar/navigation/navigate.d.ts +33 -0
- package/dist/vendor/core/calendar/navigation/navigate.js +83 -0
- package/dist/vendor/core/calendar/navigation/range.d.ts +15 -0
- package/dist/vendor/core/calendar/navigation/range.js +52 -0
- package/dist/vendor/core/calendar/navigation/title.d.ts +12 -0
- package/dist/vendor/core/calendar/navigation/title.js +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.d.ts +39 -0
- package/dist/vendor/core/calendar/navigation/view-definition.js +61 -0
- package/dist/vendor/core/calendar/navigation/zoom.d.ts +5 -0
- package/dist/vendor/core/calendar/navigation/zoom.js +11 -0
- package/dist/vendor/core/calendar/recurrence/apply.d.ts +50 -0
- package/dist/vendor/core/calendar/recurrence/apply.js +207 -0
- package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
- package/dist/vendor/core/calendar/recurrence/expand.js +302 -0
- package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
- package/dist/vendor/core/calendar/recurrence/pack.js +251 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/rrule-types.js +8 -0
- package/dist/vendor/core/calendar/recurrence/rrule.d.ts +12 -0
- package/dist/vendor/core/calendar/recurrence/rrule.js +288 -0
- package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
- package/dist/vendor/core/calendar/recurrence/series.js +165 -0
- package/dist/vendor/core/calendar/recurrence/types.d.ts +30 -0
- package/dist/vendor/core/calendar/recurrence/types.js +1 -0
- package/dist/vendor/core/calendar/resources/keys.d.ts +2 -0
- package/dist/vendor/core/calendar/resources/keys.js +2 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/resource-time-grid.js +130 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/timeline-axis.js +98 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/timeline-layout.js +111 -0
- package/dist/vendor/core/calendar/resources/tree.d.ts +10 -0
- package/dist/vendor/core/calendar/resources/tree.js +86 -0
- package/dist/vendor/core/calendar/resources/types.d.ts +177 -0
- package/dist/vendor/core/calendar/resources/types.js +1 -0
- package/dist/vendor/core/calendar/resources/views.d.ts +7 -0
- package/dist/vendor/core/calendar/resources/views.js +45 -0
- package/dist/vendor/core/calendar/resources/windowing.d.ts +11 -0
- package/dist/vendor/core/calendar/resources/windowing.js +17 -0
- package/dist/vendor/core/calendar/views/day.d.ts +37 -0
- package/dist/vendor/core/calendar/views/day.js +39 -0
- package/dist/vendor/core/calendar/views/list-layout.d.ts +8 -0
- package/dist/vendor/core/calendar/views/list-layout.js +5 -0
- package/dist/vendor/core/calendar/views/mini-calendar.d.ts +23 -0
- package/dist/vendor/core/calendar/views/mini-calendar.js +31 -0
- package/dist/vendor/core/calendar/views/month-layout.d.ts +30 -0
- package/dist/vendor/core/calendar/views/month-layout.js +63 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.d.ts +26 -0
- package/dist/vendor/core/calendar/views/time-grid-layout.js +30 -0
- package/dist/vendor/core/date/index.d.ts +9 -0
- package/dist/vendor/core/date/index.js +9 -0
- package/dist/vendor/core/date/input/date-input-controller.d.ts +97 -0
- package/dist/vendor/core/date/input/date-input-controller.js +478 -0
- package/dist/vendor/core/date/input/date-range-input-controller.d.ts +43 -0
- package/dist/vendor/core/date/input/date-range-input-controller.js +189 -0
- package/dist/vendor/core/date/input/parse.d.ts +22 -0
- package/dist/vendor/core/date/input/parse.js +84 -0
- package/dist/vendor/core/date/input/validity.d.ts +6 -0
- package/dist/vendor/core/date/input/validity.js +13 -0
- package/dist/vendor/core/date/panel/panel-controller.d.ts +176 -0
- package/dist/vendor/core/date/panel/panel-controller.js +726 -0
- package/dist/vendor/core/date/presets.d.ts +22 -0
- package/dist/vendor/core/date/presets.js +104 -0
- package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
- package/dist/vendor/core/date/selection/multiple.js +32 -0
- package/dist/vendor/core/date/selection/range.d.ts +29 -0
- package/dist/vendor/core/date/selection/range.js +39 -0
- package/dist/vendor/core/date/types.d.ts +12 -0
- package/dist/vendor/core/date/types.js +1 -0
- package/dist/vendor/core/datetime/compose.d.ts +24 -0
- package/dist/vendor/core/datetime/compose.js +49 -0
- package/dist/vendor/core/datetime/constraints.d.ts +42 -0
- package/dist/vendor/core/datetime/constraints.js +56 -0
- package/dist/vendor/core/datetime/index.d.ts +9 -0
- package/dist/vendor/core/datetime/index.js +9 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +96 -0
- package/dist/vendor/core/datetime/input/datetime-input-controller.js +395 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.d.ts +46 -0
- package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +182 -0
- package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
- package/dist/vendor/core/datetime/input/parse.js +59 -0
- package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
- package/dist/vendor/core/datetime/panel/controller.js +197 -0
- package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
- package/dist/vendor/core/datetime/panel/range-controller.js +217 -0
- package/dist/vendor/core/datetime/types.d.ts +12 -0
- package/dist/vendor/core/datetime/types.js +1 -0
- package/dist/vendor/core/datetime/zone/day-instants.d.ts +19 -0
- package/dist/vendor/core/datetime/zone/day-instants.js +54 -0
- package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
- package/dist/vendor/core/datetime/zone/resolve.js +26 -0
- package/dist/vendor/core/foundation/a11y/announcer.d.ts +7 -0
- package/dist/vendor/core/foundation/a11y/announcer.js +36 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
- package/dist/vendor/core/foundation/a11y/grid-navigation.js +86 -0
- package/dist/vendor/core/foundation/a11y/index.d.ts +8 -0
- package/dist/vendor/core/foundation/a11y/index.js +5 -0
- package/dist/vendor/core/foundation/a11y/labels.d.ts +21 -0
- package/dist/vendor/core/foundation/a11y/labels.js +43 -0
- package/dist/vendor/core/foundation/a11y/messages.d.ts +80 -0
- package/dist/vendor/core/foundation/a11y/messages.js +74 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.d.ts +18 -0
- package/dist/vendor/core/foundation/a11y/roving-focus.js +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
- package/dist/vendor/core/foundation/constraints/availability-rules.js +66 -0
- package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
- package/dist/vendor/core/foundation/constraints/availability.js +490 -0
- package/dist/vendor/core/foundation/constraints/date.d.ts +21 -0
- package/dist/vendor/core/foundation/constraints/date.js +41 -0
- package/dist/vendor/core/foundation/constraints/index.d.ts +9 -0
- package/dist/vendor/core/foundation/constraints/index.js +4 -0
- package/dist/vendor/core/foundation/constraints/range.d.ts +44 -0
- package/dist/vendor/core/foundation/constraints/range.js +70 -0
- package/dist/vendor/core/foundation/constraints/time.d.ts +30 -0
- package/dist/vendor/core/foundation/constraints/time.js +56 -0
- package/dist/vendor/core/foundation/grid/index.d.ts +8 -0
- package/dist/vendor/core/foundation/grid/index.js +4 -0
- package/dist/vendor/core/foundation/grid/month-grid.d.ts +33 -0
- package/dist/vendor/core/foundation/grid/month-grid.js +52 -0
- package/dist/vendor/core/foundation/grid/time-axis.d.ts +25 -0
- package/dist/vendor/core/foundation/grid/time-axis.js +32 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.d.ts +17 -0
- package/dist/vendor/core/foundation/grid/weekday-headers.js +26 -0
- package/dist/vendor/core/foundation/grid/year-grid.d.ts +29 -0
- package/dist/vendor/core/foundation/grid/year-grid.js +40 -0
- package/dist/vendor/core/foundation/index.d.ts +8 -0
- package/dist/vendor/core/foundation/index.js +8 -0
- package/dist/vendor/core/foundation/input/form.d.ts +7 -0
- package/dist/vendor/core/foundation/input/form.js +10 -0
- package/dist/vendor/core/foundation/input/index.d.ts +6 -0
- package/dist/vendor/core/foundation/input/index.js +3 -0
- package/dist/vendor/core/foundation/input/segment-engine.d.ts +33 -0
- package/dist/vendor/core/foundation/input/segment-engine.js +49 -0
- package/dist/vendor/core/foundation/input/tokenize.d.ts +19 -0
- package/dist/vendor/core/foundation/input/tokenize.js +24 -0
- package/dist/vendor/core/foundation/locale/digits.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/digits.js +35 -0
- package/dist/vendor/core/foundation/locale/direction.d.ts +1 -0
- package/dist/vendor/core/foundation/locale/direction.js +37 -0
- package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
- package/dist/vendor/core/foundation/locale/format.js +79 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
- package/dist/vendor/core/foundation/locale/hour-cycle.js +45 -0
- package/dist/vendor/core/foundation/locale/index.d.ts +10 -0
- package/dist/vendor/core/foundation/locale/index.js +8 -0
- package/dist/vendor/core/foundation/locale/names.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/names.js +30 -0
- package/dist/vendor/core/foundation/locale/resolve.d.ts +7 -0
- package/dist/vendor/core/foundation/locale/resolve.js +29 -0
- package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
- package/dist/vendor/core/foundation/locale/week-info.js +61 -0
- package/dist/vendor/core/foundation/locale/zone-label.d.ts +6 -0
- package/dist/vendor/core/foundation/locale/zone-label.js +24 -0
- package/dist/vendor/core/foundation/ranges/date-range.d.ts +18 -0
- package/dist/vendor/core/foundation/ranges/date-range.js +40 -0
- package/dist/vendor/core/foundation/ranges/index.d.ts +4 -0
- package/dist/vendor/core/foundation/ranges/index.js +2 -0
- package/dist/vendor/core/foundation/ranges/interval.d.ts +24 -0
- package/dist/vendor/core/foundation/ranges/interval.js +56 -0
- package/dist/vendor/core/foundation/store/attributes.d.ts +19 -0
- package/dist/vendor/core/foundation/store/attributes.js +43 -0
- package/dist/vendor/core/foundation/store/controllable.d.ts +19 -0
- package/dist/vendor/core/foundation/store/controllable.js +50 -0
- package/dist/vendor/core/foundation/store/env.d.ts +1 -0
- package/dist/vendor/core/foundation/store/env.js +3 -0
- package/dist/vendor/core/foundation/store/global-state.d.ts +1 -0
- package/dist/vendor/core/foundation/store/global-state.js +21 -0
- package/dist/vendor/core/foundation/store/ids.d.ts +2 -0
- package/dist/vendor/core/foundation/store/ids.js +7 -0
- package/dist/vendor/core/foundation/store/index.d.ts +11 -0
- package/dist/vendor/core/foundation/store/index.js +7 -0
- package/dist/vendor/core/foundation/store/store.d.ts +7 -0
- package/dist/vendor/core/foundation/store/store.js +25 -0
- package/dist/vendor/core/foundation/store/ticker.d.ts +11 -0
- package/dist/vendor/core/foundation/store/ticker.js +27 -0
- package/dist/vendor/core/foundation/values/clock.d.ts +4 -0
- package/dist/vendor/core/foundation/values/clock.js +21 -0
- package/dist/vendor/core/foundation/values/compare.d.ts +16 -0
- package/dist/vendor/core/foundation/values/compare.js +70 -0
- package/dist/vendor/core/foundation/values/convert.d.ts +31 -0
- package/dist/vendor/core/foundation/values/convert.js +112 -0
- package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
- package/dist/vendor/core/foundation/values/epoch-day.js +47 -0
- package/dist/vendor/core/foundation/values/index.d.ts +14 -0
- package/dist/vendor/core/foundation/values/index.js +10 -0
- package/dist/vendor/core/foundation/values/iso.d.ts +24 -0
- package/dist/vendor/core/foundation/values/iso.js +113 -0
- package/dist/vendor/core/foundation/values/plain-date-time.d.ts +8 -0
- package/dist/vendor/core/foundation/values/plain-date-time.js +25 -0
- package/dist/vendor/core/foundation/values/plain-date.d.ts +33 -0
- package/dist/vendor/core/foundation/values/plain-date.js +105 -0
- package/dist/vendor/core/foundation/values/plain-time.d.ts +15 -0
- package/dist/vendor/core/foundation/values/plain-time.js +45 -0
- package/dist/vendor/core/foundation/values/types.d.ts +37 -0
- package/dist/vendor/core/foundation/values/types.js +1 -0
- package/dist/vendor/core/foundation/values/week.d.ts +9 -0
- package/dist/vendor/core/foundation/values/week.js +31 -0
- package/dist/vendor/core/foundation/values/year-month.d.ts +10 -0
- package/dist/vendor/core/foundation/values/year-month.js +19 -0
- package/dist/vendor/core/foundation/values/zoned.d.ts +16 -0
- package/dist/vendor/core/foundation/values/zoned.js +155 -0
- package/dist/vendor/core/index.d.ts +5 -0
- package/dist/vendor/core/index.js +5 -0
- package/dist/vendor/core/time/index.d.ts +8 -0
- package/dist/vendor/core/time/index.js +8 -0
- package/dist/vendor/core/time/input/parse.d.ts +19 -0
- package/dist/vendor/core/time/input/parse.js +84 -0
- package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
- package/dist/vendor/core/time/input/time-input-controller.js +562 -0
- package/dist/vendor/core/time/input/time-range-input-controller.d.ts +49 -0
- package/dist/vendor/core/time/input/time-range-input-controller.js +185 -0
- package/dist/vendor/core/time/input/validity.d.ts +7 -0
- package/dist/vendor/core/time/input/validity.js +16 -0
- package/dist/vendor/core/time/panel/time-panel-controller.d.ts +163 -0
- package/dist/vendor/core/time/panel/time-panel-controller.js +839 -0
- package/dist/vendor/core/time/selection/range.d.ts +25 -0
- package/dist/vendor/core/time/selection/range.js +35 -0
- package/dist/vendor/core/time/selection/slots.d.ts +46 -0
- package/dist/vendor/core/time/selection/slots.js +78 -0
- package/dist/vendor/core/time/types.d.ts +11 -0
- package/dist/vendor/core/time/types.js +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type Attributes, type Availability, type AvailabilitySpec, type DateInput, type HiddenInput, type Messages, type PlainDate } from "../../foundation/index.js";
|
|
2
|
+
import type { DateValue, PartName } from "../types.js";
|
|
3
|
+
import { type ParseContext } from "./parse.js";
|
|
4
|
+
import { type DateValidity } from "./validity.js";
|
|
5
|
+
export type FormatContext = {
|
|
6
|
+
locale?: string;
|
|
7
|
+
};
|
|
8
|
+
export type DateInputOptions = {
|
|
9
|
+
id?: string;
|
|
10
|
+
value?: DateValue;
|
|
11
|
+
defaultValue?: DateValue;
|
|
12
|
+
onValueChange?: (value: DateValue) => void;
|
|
13
|
+
/** On blur or Enter with a valid value. */
|
|
14
|
+
onValueCommit?: (value: PlainDate) => void;
|
|
15
|
+
mode?: "segmented" | "text";
|
|
16
|
+
/** The value ↑/↓ starts from on an empty part (default today). */
|
|
17
|
+
placeholderValue?: DateInput;
|
|
18
|
+
parse?: (text: string, context: ParseContext) => PlainDate | null;
|
|
19
|
+
format?: (date: PlainDate, context: FormatContext) => string;
|
|
20
|
+
onInvalidInput?: (text: string) => void;
|
|
21
|
+
name?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
min?: DateInput;
|
|
26
|
+
max?: DateInput;
|
|
27
|
+
isDateDisabled?: (date: PlainDate) => boolean;
|
|
28
|
+
isDateUnavailable?: (date: PlainDate) => boolean;
|
|
29
|
+
/** Availability model (plan 11 V7): fully unavailable days are not selectable. */
|
|
30
|
+
availability?: AvailabilitySpec | Availability;
|
|
31
|
+
locale?: string;
|
|
32
|
+
timeZone?: string;
|
|
33
|
+
now?: number;
|
|
34
|
+
messages?: Partial<Messages>;
|
|
35
|
+
/** Internal: called when focus tries to leave the first (-1) or last (1) part. */
|
|
36
|
+
onFocusEdge?: (direction: 1 | -1) => void;
|
|
37
|
+
};
|
|
38
|
+
export type SegmentView = {
|
|
39
|
+
type: PartName | "literal";
|
|
40
|
+
text: string;
|
|
41
|
+
value: number | null;
|
|
42
|
+
placeholder: string;
|
|
43
|
+
min: number;
|
|
44
|
+
max: number;
|
|
45
|
+
valueText: string;
|
|
46
|
+
editable: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type DateInputState = {
|
|
49
|
+
id: string;
|
|
50
|
+
mode: "segmented" | "text";
|
|
51
|
+
segments: SegmentView[];
|
|
52
|
+
text: string;
|
|
53
|
+
value: DateValue;
|
|
54
|
+
validity: DateValidity;
|
|
55
|
+
/** The part that holds the tab stop (and receives focus after typing). */
|
|
56
|
+
focusedPart: PartName;
|
|
57
|
+
/** Text-mode hint such as `dd/mm/yyyy`. */
|
|
58
|
+
pattern: string;
|
|
59
|
+
required: boolean;
|
|
60
|
+
readOnly: boolean;
|
|
61
|
+
disabled: boolean;
|
|
62
|
+
direction: "ltr" | "rtl";
|
|
63
|
+
locale?: string;
|
|
64
|
+
messages: Messages;
|
|
65
|
+
hidden: HiddenInput[];
|
|
66
|
+
};
|
|
67
|
+
export type KeyModifiers = {
|
|
68
|
+
shift: boolean;
|
|
69
|
+
ctrl: boolean;
|
|
70
|
+
meta: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type DateInputController = {
|
|
73
|
+
getState(): DateInputState;
|
|
74
|
+
subscribe(listener: (state: DateInputState) => void): () => void;
|
|
75
|
+
setOptions(options: Partial<DateInputOptions>): void;
|
|
76
|
+
/** Keyboard input on a segment. Returns true when the key was consumed. */
|
|
77
|
+
handleKeyDown(part: PartName, key: string, modifiers: KeyModifiers): boolean;
|
|
78
|
+
focusPart(part: PartName): void;
|
|
79
|
+
/** Finish pending typing (a 2-digit year). Call when focus leaves a part. */
|
|
80
|
+
settle(): void;
|
|
81
|
+
paste(text: string): boolean;
|
|
82
|
+
setText(text: string): void;
|
|
83
|
+
/** Text mode: parse on blur, Enter and paste. Returns true when the text became a date or was empty. */
|
|
84
|
+
commitText(): boolean;
|
|
85
|
+
/** Fire `onValueCommit` for a valid value (blur, Enter). */
|
|
86
|
+
commit(): void;
|
|
87
|
+
clear(): void;
|
|
88
|
+
/** Restore `defaultValue` (form reset). */
|
|
89
|
+
reset(): void;
|
|
90
|
+
handleTextKeyDown(key: string): boolean;
|
|
91
|
+
getRootAttributes(): Attributes;
|
|
92
|
+
getSegmentAttributes(segment: SegmentView): Attributes;
|
|
93
|
+
getTextFieldAttributes(): Attributes;
|
|
94
|
+
getClearButtonAttributes(): Attributes;
|
|
95
|
+
destroy(): void;
|
|
96
|
+
};
|
|
97
|
+
export declare function createDateInputController(initial?: DateInputOptions): DateInputController;
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import { backspace, compileAvailability, createControllable, createId, daysInMonth, defaultMessages, emptySegment, formatDate, getDateFormatPattern, getDatePartOrder, getHiddenInputs, getMonthNames, getTextDirection, isSameDay, isValidDate, mergeMessages, plainDate, resolveLocale, segmentOf, stepSegment, toIsoString, toLatinDigits, toLocaleDigits, toPlainDate, today as readToday, typeDigit, } from "../../foundation/index.js";
|
|
2
|
+
import { parseDate, resolveTwoDigitYear, } from "./parse.js";
|
|
3
|
+
import { getValidity, isInvalid } from "./validity.js";
|
|
4
|
+
const PARTS = ["day", "month", "year"];
|
|
5
|
+
const sameNullable = (a, b) => a === b || (a !== null && b !== null && isSameDay(a, b));
|
|
6
|
+
export function createDateInputController(initial = {}) {
|
|
7
|
+
let options = initial;
|
|
8
|
+
const id = options.id ?? createId("chrono-date-input");
|
|
9
|
+
const todayNow = () => readToday(options.timeZone, options.now);
|
|
10
|
+
const bound = (value) => value === undefined ? undefined : toPlainDate(value, options.timeZone);
|
|
11
|
+
const availabilityOf = () => options.availability === undefined
|
|
12
|
+
? undefined
|
|
13
|
+
: compileAvailability(options.availability, {
|
|
14
|
+
timeZone: options.timeZone,
|
|
15
|
+
now: options.now,
|
|
16
|
+
});
|
|
17
|
+
const constraints = () => ({
|
|
18
|
+
min: bound(options.min),
|
|
19
|
+
max: bound(options.max),
|
|
20
|
+
isDateDisabled: options.isDateDisabled,
|
|
21
|
+
isDateUnavailable: (date) => (options.isDateUnavailable?.(date) ?? false) ||
|
|
22
|
+
availabilityOf()?.getDayStatus(date) === "unavailable",
|
|
23
|
+
});
|
|
24
|
+
const localeOf = () => options.locale === undefined ? undefined : resolveLocale(options.locale);
|
|
25
|
+
const control = createControllable({
|
|
26
|
+
value: options.value,
|
|
27
|
+
defaultValue: options.defaultValue ?? null,
|
|
28
|
+
onChange: (value) => options.onValueChange?.(value),
|
|
29
|
+
equals: sameNullable,
|
|
30
|
+
});
|
|
31
|
+
let parts = {
|
|
32
|
+
day: emptySegment,
|
|
33
|
+
month: emptySegment,
|
|
34
|
+
year: emptySegment,
|
|
35
|
+
};
|
|
36
|
+
let text = "";
|
|
37
|
+
/** The value `text` currently stands for; a different value from outside re-formats it. */
|
|
38
|
+
let textValue = null;
|
|
39
|
+
let invalidText = false;
|
|
40
|
+
let focusedPart = getDatePartOrder(localeOf()).order[0];
|
|
41
|
+
let lastCommitted = control.get();
|
|
42
|
+
let state;
|
|
43
|
+
const listeners = new Set();
|
|
44
|
+
const formatValue = (date) => options.format
|
|
45
|
+
? options.format(date, { locale: localeOf() })
|
|
46
|
+
: formatDate(date, localeOf(), {
|
|
47
|
+
year: "numeric",
|
|
48
|
+
month: "2-digit",
|
|
49
|
+
day: "2-digit",
|
|
50
|
+
});
|
|
51
|
+
const parseContext = () => ({
|
|
52
|
+
locale: localeOf(),
|
|
53
|
+
today: todayNow(),
|
|
54
|
+
});
|
|
55
|
+
const parseText = (value) => {
|
|
56
|
+
if (options.parse) {
|
|
57
|
+
if (value.trim() === "")
|
|
58
|
+
return { error: "empty" };
|
|
59
|
+
const date = options.parse(value, parseContext());
|
|
60
|
+
return date ? { date } : { error: "unparseable" };
|
|
61
|
+
}
|
|
62
|
+
return parseDate(value, parseContext());
|
|
63
|
+
};
|
|
64
|
+
const syncParts = (value) => {
|
|
65
|
+
parts = value
|
|
66
|
+
? {
|
|
67
|
+
day: segmentOf(value.day),
|
|
68
|
+
month: segmentOf(value.month),
|
|
69
|
+
year: segmentOf(value.year),
|
|
70
|
+
}
|
|
71
|
+
: { day: emptySegment, month: emptySegment, year: emptySegment };
|
|
72
|
+
text = value ? formatValue(value) : "";
|
|
73
|
+
textValue = value;
|
|
74
|
+
invalidText = false;
|
|
75
|
+
};
|
|
76
|
+
syncParts(control.get());
|
|
77
|
+
const derive = () => {
|
|
78
|
+
const { day, month, year } = parts;
|
|
79
|
+
if (day.value === null || month.value === null || year.value === null) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return isValidDate(year.value, month.value, day.value)
|
|
83
|
+
? plainDate(year.value, month.value, day.value)
|
|
84
|
+
: null;
|
|
85
|
+
};
|
|
86
|
+
const filledCount = () => PARTS.filter((part) => parts[part].value !== null).length;
|
|
87
|
+
const def = (part) => {
|
|
88
|
+
if (part === "month")
|
|
89
|
+
return { min: 1, max: 12, maxDigits: 2, pageStep: 3 };
|
|
90
|
+
if (part === "year")
|
|
91
|
+
return { min: 1, max: 9999, maxDigits: 4, pageStep: 10 };
|
|
92
|
+
const { month, year } = parts;
|
|
93
|
+
const max = month.value === null ? 31 : daysInMonth(year.value ?? 2000, month.value);
|
|
94
|
+
return { min: 1, max, maxDigits: 2, pageStep: 7 };
|
|
95
|
+
};
|
|
96
|
+
const validityNow = () => {
|
|
97
|
+
if (options.mode === "text") {
|
|
98
|
+
if (text.trim() === "")
|
|
99
|
+
return "empty";
|
|
100
|
+
if (invalidText)
|
|
101
|
+
return "invalid-date";
|
|
102
|
+
const value = control.get();
|
|
103
|
+
return value ? getValidity(3, value, constraints()) : "invalid-date";
|
|
104
|
+
}
|
|
105
|
+
const date = derive();
|
|
106
|
+
return getValidity(filledCount(), date, constraints());
|
|
107
|
+
};
|
|
108
|
+
const compute = () => {
|
|
109
|
+
const locale = localeOf();
|
|
110
|
+
const messages = mergeMessages(defaultMessages, options.messages);
|
|
111
|
+
const { order, separators, prefix, suffix } = getDatePartOrder(locale);
|
|
112
|
+
const names = getMonthNames(locale, "long");
|
|
113
|
+
const placeholders = {
|
|
114
|
+
day: messages.placeholderDay,
|
|
115
|
+
month: messages.placeholderMonth,
|
|
116
|
+
year: messages.placeholderYear,
|
|
117
|
+
};
|
|
118
|
+
const display = (part) => {
|
|
119
|
+
const segment = parts[part];
|
|
120
|
+
if (segment.buffer !== "")
|
|
121
|
+
return toLocaleDigits(segment.buffer, locale);
|
|
122
|
+
if (segment.value === null)
|
|
123
|
+
return placeholders[part];
|
|
124
|
+
return toLocaleDigits(String(segment.value).padStart(part === "year" ? 4 : 2, "0"), locale);
|
|
125
|
+
};
|
|
126
|
+
const literal = (value) => ({
|
|
127
|
+
type: "literal",
|
|
128
|
+
text: value,
|
|
129
|
+
value: null,
|
|
130
|
+
placeholder: "",
|
|
131
|
+
min: 0,
|
|
132
|
+
max: 0,
|
|
133
|
+
valueText: "",
|
|
134
|
+
editable: false,
|
|
135
|
+
});
|
|
136
|
+
const segments = [];
|
|
137
|
+
if (prefix)
|
|
138
|
+
segments.push(literal(prefix));
|
|
139
|
+
order.forEach((part, index) => {
|
|
140
|
+
const segment = parts[part];
|
|
141
|
+
const bounds = def(part);
|
|
142
|
+
const shown = display(part);
|
|
143
|
+
segments.push({
|
|
144
|
+
type: part,
|
|
145
|
+
text: shown,
|
|
146
|
+
value: segment.value,
|
|
147
|
+
placeholder: placeholders[part],
|
|
148
|
+
min: bounds.min,
|
|
149
|
+
max: bounds.max,
|
|
150
|
+
valueText: segment.value === null
|
|
151
|
+
? messages.empty
|
|
152
|
+
: part === "month"
|
|
153
|
+
? names[segment.value - 1]
|
|
154
|
+
: shown,
|
|
155
|
+
editable: true,
|
|
156
|
+
});
|
|
157
|
+
const separator = separators[index];
|
|
158
|
+
if (index < 2 && separator)
|
|
159
|
+
segments.push(literal(separator));
|
|
160
|
+
});
|
|
161
|
+
if (suffix)
|
|
162
|
+
segments.push(literal(suffix));
|
|
163
|
+
const value = control.get();
|
|
164
|
+
return {
|
|
165
|
+
id,
|
|
166
|
+
mode: options.mode ?? "segmented",
|
|
167
|
+
segments,
|
|
168
|
+
text,
|
|
169
|
+
value,
|
|
170
|
+
validity: validityNow(),
|
|
171
|
+
focusedPart,
|
|
172
|
+
pattern: getDateFormatPattern(locale, messages),
|
|
173
|
+
required: options.required ?? false,
|
|
174
|
+
readOnly: options.readOnly ?? false,
|
|
175
|
+
disabled: options.disabled ?? false,
|
|
176
|
+
direction: getTextDirection(locale),
|
|
177
|
+
locale,
|
|
178
|
+
messages,
|
|
179
|
+
hidden: getHiddenInputs([
|
|
180
|
+
[options.name, value ? toIsoString(value) : null],
|
|
181
|
+
]),
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
const refresh = () => {
|
|
185
|
+
const next = compute();
|
|
186
|
+
if (state && JSON.stringify(state) === JSON.stringify(next))
|
|
187
|
+
return;
|
|
188
|
+
state = next;
|
|
189
|
+
for (const listener of [...listeners])
|
|
190
|
+
listener(state);
|
|
191
|
+
};
|
|
192
|
+
state = compute();
|
|
193
|
+
/** Push the parts into the value after an edit. */
|
|
194
|
+
const afterEdit = () => {
|
|
195
|
+
const next = derive();
|
|
196
|
+
if (!sameNullable(next, control.get()))
|
|
197
|
+
control.set(next);
|
|
198
|
+
refresh();
|
|
199
|
+
};
|
|
200
|
+
const orderParts = () => [...getDatePartOrder(localeOf()).order];
|
|
201
|
+
const settlePart = (part) => {
|
|
202
|
+
const segment = parts[part];
|
|
203
|
+
if (part !== "year" || segment.buffer === "")
|
|
204
|
+
return;
|
|
205
|
+
const typed = Number(segment.buffer);
|
|
206
|
+
const resolved = segment.buffer.length === 2
|
|
207
|
+
? resolveTwoDigitYear(typed, todayNow().year)
|
|
208
|
+
: typed;
|
|
209
|
+
parts = {
|
|
210
|
+
...parts,
|
|
211
|
+
year: {
|
|
212
|
+
value: resolved >= 1 && resolved <= 9999 ? resolved : null,
|
|
213
|
+
buffer: "",
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
const settleAll = () => {
|
|
218
|
+
for (const part of PARTS)
|
|
219
|
+
settlePart(part);
|
|
220
|
+
};
|
|
221
|
+
const moveFocus = (part, step) => {
|
|
222
|
+
const list = orderParts();
|
|
223
|
+
const index = list.indexOf(part) + step;
|
|
224
|
+
const target = list[index];
|
|
225
|
+
if (target)
|
|
226
|
+
focusedPart = target;
|
|
227
|
+
else
|
|
228
|
+
options.onFocusEdge?.(step);
|
|
229
|
+
};
|
|
230
|
+
const setSegment = (part, segment) => {
|
|
231
|
+
parts = { ...parts, [part]: segment };
|
|
232
|
+
};
|
|
233
|
+
const controller = {
|
|
234
|
+
getState: () => state,
|
|
235
|
+
subscribe(listener) {
|
|
236
|
+
listeners.add(listener);
|
|
237
|
+
return () => {
|
|
238
|
+
listeners.delete(listener);
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
setOptions(next) {
|
|
242
|
+
options = { ...options, ...next };
|
|
243
|
+
control.sync({ value: options.value });
|
|
244
|
+
if (options.mode === "text") {
|
|
245
|
+
if (!sameNullable(textValue, control.get())) {
|
|
246
|
+
syncParts(control.get());
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else if (!sameNullable(derive(), control.get())) {
|
|
250
|
+
syncParts(control.get());
|
|
251
|
+
}
|
|
252
|
+
refresh();
|
|
253
|
+
},
|
|
254
|
+
focusPart(part) {
|
|
255
|
+
if (focusedPart !== part) {
|
|
256
|
+
focusedPart = part;
|
|
257
|
+
refresh();
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
settle() {
|
|
261
|
+
settleAll();
|
|
262
|
+
afterEdit();
|
|
263
|
+
},
|
|
264
|
+
handleKeyDown(part, key, modifiers) {
|
|
265
|
+
if (options.disabled)
|
|
266
|
+
return false;
|
|
267
|
+
if (modifiers.ctrl || modifiers.meta)
|
|
268
|
+
return false;
|
|
269
|
+
const rtl = state.direction === "rtl";
|
|
270
|
+
if (key === "ArrowLeft" || key === "ArrowRight") {
|
|
271
|
+
settlePart(part);
|
|
272
|
+
moveFocus(part, (key === "ArrowRight") !== rtl ? 1 : -1);
|
|
273
|
+
afterEdit();
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
if (key === "Enter") {
|
|
277
|
+
settleAll();
|
|
278
|
+
afterEdit();
|
|
279
|
+
controller.commit();
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (options.readOnly)
|
|
283
|
+
return false;
|
|
284
|
+
const latin = toLatinDigits(key, localeOf());
|
|
285
|
+
if (/^\d$/.test(latin)) {
|
|
286
|
+
const result = typeDigit(def(part), parts[part], Number(latin));
|
|
287
|
+
let segment = result.segment;
|
|
288
|
+
// A year is pending until it has four digits or is settled on blur.
|
|
289
|
+
if (part === "year" && segment.buffer.length < 4) {
|
|
290
|
+
segment = { value: null, buffer: segment.buffer };
|
|
291
|
+
}
|
|
292
|
+
setSegment(part, segment);
|
|
293
|
+
if (result.advance) {
|
|
294
|
+
settlePart(part);
|
|
295
|
+
moveFocus(part, 1);
|
|
296
|
+
}
|
|
297
|
+
afterEdit();
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
const pv = toPlainDate(options.placeholderValue ?? todayNow(), options.timeZone);
|
|
301
|
+
const bounds = def(part);
|
|
302
|
+
if (key === "ArrowUp" ||
|
|
303
|
+
key === "ArrowDown" ||
|
|
304
|
+
key === "PageUp" ||
|
|
305
|
+
key === "PageDown") {
|
|
306
|
+
settlePart(part);
|
|
307
|
+
const direction = key === "ArrowUp" || key === "PageUp" ? 1 : -1;
|
|
308
|
+
const amount = key.startsWith("Page") ? bounds.pageStep : 1;
|
|
309
|
+
const wasComplete = derive() !== null;
|
|
310
|
+
setSegment(part, stepSegment(bounds, parts[part], direction * amount, pv[part]));
|
|
311
|
+
if (wasComplete && part !== "day") {
|
|
312
|
+
const { day, month, year } = parts;
|
|
313
|
+
const limit = daysInMonth(year.value ?? 2000, month.value ?? 1);
|
|
314
|
+
if (day.value > limit)
|
|
315
|
+
setSegment("day", segmentOf(limit));
|
|
316
|
+
}
|
|
317
|
+
afterEdit();
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
if (key === "Home" || key === "End") {
|
|
321
|
+
setSegment(part, segmentOf(key === "Home" ? bounds.min : bounds.max));
|
|
322
|
+
afterEdit();
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
if (key === "Backspace" || key === "Delete") {
|
|
326
|
+
setSegment(part, key === "Backspace" ? backspace(parts[part]) : emptySegment);
|
|
327
|
+
afterEdit();
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
},
|
|
332
|
+
paste(value) {
|
|
333
|
+
if (options.disabled || options.readOnly)
|
|
334
|
+
return false;
|
|
335
|
+
const result = parseText(value);
|
|
336
|
+
if ("date" in result) {
|
|
337
|
+
syncParts(result.date);
|
|
338
|
+
invalidText = false;
|
|
339
|
+
afterEdit();
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
options.onInvalidInput?.(value);
|
|
343
|
+
return false;
|
|
344
|
+
},
|
|
345
|
+
setText(value) {
|
|
346
|
+
text = value;
|
|
347
|
+
invalidText = false;
|
|
348
|
+
refresh();
|
|
349
|
+
},
|
|
350
|
+
commitText() {
|
|
351
|
+
const result = parseText(text);
|
|
352
|
+
if ("date" in result) {
|
|
353
|
+
invalidText = false;
|
|
354
|
+
control.set(result.date);
|
|
355
|
+
text = formatValue(result.date);
|
|
356
|
+
textValue = result.date;
|
|
357
|
+
refresh();
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
if (result.error === "empty") {
|
|
361
|
+
invalidText = false;
|
|
362
|
+
text = "";
|
|
363
|
+
textValue = null;
|
|
364
|
+
control.set(null);
|
|
365
|
+
refresh();
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
invalidText = true;
|
|
369
|
+
options.onInvalidInput?.(text);
|
|
370
|
+
refresh();
|
|
371
|
+
return false;
|
|
372
|
+
},
|
|
373
|
+
handleTextKeyDown(key) {
|
|
374
|
+
if (key === "Enter") {
|
|
375
|
+
controller.commitText();
|
|
376
|
+
controller.commit();
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
if (key === "Escape") {
|
|
380
|
+
const before = text;
|
|
381
|
+
const value = control.get();
|
|
382
|
+
text = value ? formatValue(value) : "";
|
|
383
|
+
invalidText = false;
|
|
384
|
+
refresh();
|
|
385
|
+
return before !== text;
|
|
386
|
+
}
|
|
387
|
+
return false;
|
|
388
|
+
},
|
|
389
|
+
commit() {
|
|
390
|
+
if (options.mode === "text")
|
|
391
|
+
controller.commitText();
|
|
392
|
+
else {
|
|
393
|
+
settleAll();
|
|
394
|
+
afterEdit();
|
|
395
|
+
}
|
|
396
|
+
const value = control.get();
|
|
397
|
+
if (value &&
|
|
398
|
+
state.validity === "valid" &&
|
|
399
|
+
!sameNullable(value, lastCommitted)) {
|
|
400
|
+
lastCommitted = value;
|
|
401
|
+
options.onValueCommit?.(value);
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
clear() {
|
|
405
|
+
if (options.disabled || options.readOnly)
|
|
406
|
+
return;
|
|
407
|
+
syncParts(null);
|
|
408
|
+
focusedPart = orderParts()[0];
|
|
409
|
+
control.set(null);
|
|
410
|
+
lastCommitted = null;
|
|
411
|
+
refresh();
|
|
412
|
+
},
|
|
413
|
+
reset() {
|
|
414
|
+
const value = options.defaultValue ?? null;
|
|
415
|
+
syncParts(value);
|
|
416
|
+
focusedPart = orderParts()[0];
|
|
417
|
+
control.set(value);
|
|
418
|
+
lastCommitted = value;
|
|
419
|
+
refresh();
|
|
420
|
+
},
|
|
421
|
+
getRootAttributes: () => ({
|
|
422
|
+
role: "group",
|
|
423
|
+
"data-chrono-date-input": true,
|
|
424
|
+
"data-mode": state.mode,
|
|
425
|
+
"data-disabled": state.disabled,
|
|
426
|
+
"data-readonly": state.readOnly,
|
|
427
|
+
"data-invalid": isInvalid(state.validity),
|
|
428
|
+
"aria-disabled": state.disabled ? "true" : undefined,
|
|
429
|
+
dir: state.direction,
|
|
430
|
+
}),
|
|
431
|
+
getSegmentAttributes(segment) {
|
|
432
|
+
if (segment.type === "literal") {
|
|
433
|
+
return { "aria-hidden": "true", "data-chrono-literal": true };
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
role: "spinbutton",
|
|
437
|
+
"aria-label": state.messages[segment.type],
|
|
438
|
+
"aria-valuenow": segment.value ?? undefined,
|
|
439
|
+
"aria-valuemin": segment.min,
|
|
440
|
+
"aria-valuemax": segment.max,
|
|
441
|
+
"aria-valuetext": segment.valueText,
|
|
442
|
+
"aria-readonly": state.readOnly ? "true" : undefined,
|
|
443
|
+
"aria-disabled": state.disabled ? "true" : undefined,
|
|
444
|
+
"aria-required": state.required ? "true" : undefined,
|
|
445
|
+
"aria-invalid": isInvalid(state.validity) ? "true" : undefined,
|
|
446
|
+
tabindex: state.disabled
|
|
447
|
+
? undefined
|
|
448
|
+
: segment.type === state.focusedPart
|
|
449
|
+
? 0
|
|
450
|
+
: -1,
|
|
451
|
+
inputmode: "numeric",
|
|
452
|
+
"data-placeholder": segment.value === null && segment.text === segment.placeholder,
|
|
453
|
+
"data-invalid": isInvalid(state.validity),
|
|
454
|
+
"data-chrono-part": segment.type,
|
|
455
|
+
};
|
|
456
|
+
},
|
|
457
|
+
getTextFieldAttributes: () => ({
|
|
458
|
+
type: "text",
|
|
459
|
+
autocomplete: "off",
|
|
460
|
+
spellcheck: "false",
|
|
461
|
+
placeholder: state.pattern,
|
|
462
|
+
"aria-invalid": isInvalid(state.validity) ? "true" : undefined,
|
|
463
|
+
"aria-required": state.required ? "true" : undefined,
|
|
464
|
+
"data-invalid": isInvalid(state.validity),
|
|
465
|
+
disabled: state.disabled,
|
|
466
|
+
readonly: state.readOnly,
|
|
467
|
+
}),
|
|
468
|
+
getClearButtonAttributes: () => ({
|
|
469
|
+
type: "button",
|
|
470
|
+
"aria-label": state.messages.clear,
|
|
471
|
+
"data-disabled": state.disabled || state.validity === "empty",
|
|
472
|
+
}),
|
|
473
|
+
destroy() {
|
|
474
|
+
listeners.clear();
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
return controller;
|
|
478
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Attributes, type DateRange, type HiddenInput } from "../../foundation/index.js";
|
|
2
|
+
import { type PickConstraints, type RangeReason } from "../selection/range.js";
|
|
3
|
+
import type { DateRangeValue } from "../types.js";
|
|
4
|
+
import { type DateInputController, type DateInputOptions, type DateInputState } from "./date-input-controller.js";
|
|
5
|
+
import { type DateValidity } from "./validity.js";
|
|
6
|
+
export type DateRangeInputOptions = Omit<DateInputOptions, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "name"> & {
|
|
7
|
+
value?: DateRangeValue;
|
|
8
|
+
defaultValue?: DateRangeValue;
|
|
9
|
+
onValueChange?: (value: DateRangeValue) => void;
|
|
10
|
+
onValueCommit?: (value: DateRange) => void;
|
|
11
|
+
name?: string;
|
|
12
|
+
startName?: string;
|
|
13
|
+
endName?: string;
|
|
14
|
+
minDays?: PickConstraints["minDays"];
|
|
15
|
+
maxDays?: PickConstraints["maxDays"];
|
|
16
|
+
allowUnavailableInside?: boolean;
|
|
17
|
+
allowDisabledInside?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type RangeValidity = DateValidity | RangeReason;
|
|
20
|
+
export type DateRangeInputState = {
|
|
21
|
+
id: string;
|
|
22
|
+
value: DateRangeValue;
|
|
23
|
+
validity: RangeValidity;
|
|
24
|
+
start: DateInputState;
|
|
25
|
+
end: DateInputState;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
readOnly: boolean;
|
|
28
|
+
hidden: HiddenInput[];
|
|
29
|
+
messages: DateInputState["messages"];
|
|
30
|
+
};
|
|
31
|
+
export type DateRangeInputController = {
|
|
32
|
+
getState(): DateRangeInputState;
|
|
33
|
+
subscribe(listener: (state: DateRangeInputState) => void): () => void;
|
|
34
|
+
setOptions(options: Partial<DateRangeInputOptions>): void;
|
|
35
|
+
getStart(): DateInputController;
|
|
36
|
+
getEnd(): DateInputController;
|
|
37
|
+
commit(): void;
|
|
38
|
+
clear(): void;
|
|
39
|
+
reset(): void;
|
|
40
|
+
getRootAttributes(): Attributes;
|
|
41
|
+
destroy(): void;
|
|
42
|
+
};
|
|
43
|
+
export declare function createDateRangeInputController(initial?: DateRangeInputOptions): DateRangeInputController;
|