@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,43 @@
|
|
|
1
|
+
/** Structural equality for plain data snapshots (no functions, no cycles). */
|
|
2
|
+
export const deepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
3
|
+
/**
|
|
4
|
+
* State comparison (plan 05 R1). `events`, `more` and `allDayRow` hold the
|
|
5
|
+
* app's event objects (possibly cyclic, large or with `Date`s), so they are
|
|
6
|
+
* compared by reference — the controller memoizes layout results so unchanged
|
|
7
|
+
* inputs return the same arrays. Everything else is JSON-safe and compared
|
|
8
|
+
* structurally.
|
|
9
|
+
*/
|
|
10
|
+
const REFERENCE_FIELDS = [
|
|
11
|
+
"events",
|
|
12
|
+
"more",
|
|
13
|
+
"allDayRow",
|
|
14
|
+
"drag",
|
|
15
|
+
"pending",
|
|
16
|
+
"resources",
|
|
17
|
+
"backgrounds",
|
|
18
|
+
];
|
|
19
|
+
export function statesEqual(prev, next) {
|
|
20
|
+
if (prev === next) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
const a = prev;
|
|
24
|
+
const b = next;
|
|
25
|
+
for (const key of REFERENCE_FIELDS) {
|
|
26
|
+
if (a[key] !== b[key]) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const restA = {};
|
|
31
|
+
const restB = {};
|
|
32
|
+
for (const key of Object.keys(a)) {
|
|
33
|
+
if (!REFERENCE_FIELDS.includes(key)) {
|
|
34
|
+
restA[key] = a[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const key of Object.keys(b)) {
|
|
38
|
+
if (!REFERENCE_FIELDS.includes(key)) {
|
|
39
|
+
restB[key] = b[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify(restA) === JSON.stringify(restB);
|
|
43
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type DateRange, type DayOfWeek, type PlainDate } from "../../foundation/index.js";
|
|
2
|
+
import { type ViewDefinition } from "./view-definition.js";
|
|
3
|
+
export type NavigationState = {
|
|
4
|
+
view: string;
|
|
5
|
+
/** The date the visible range is built around. */
|
|
6
|
+
anchor: PlainDate;
|
|
7
|
+
focusedDate: PlainDate;
|
|
8
|
+
/** Ad-hoc definition made by `{ range }` navigation (`setRange`). */
|
|
9
|
+
custom?: ViewDefinition | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type NavigationContext = {
|
|
12
|
+
views: Record<string, ViewDefinition>;
|
|
13
|
+
weekStartsOn: DayOfWeek;
|
|
14
|
+
hiddenDays: readonly DayOfWeek[];
|
|
15
|
+
min?: PlainDate | undefined;
|
|
16
|
+
max?: PlainDate | undefined;
|
|
17
|
+
today: PlainDate;
|
|
18
|
+
};
|
|
19
|
+
export type NavigationAction = "prev" | "next" | "today" | {
|
|
20
|
+
goTo: PlainDate;
|
|
21
|
+
} | {
|
|
22
|
+
view: string;
|
|
23
|
+
} | {
|
|
24
|
+
range: DateRange;
|
|
25
|
+
};
|
|
26
|
+
export declare function getDefinition(state: NavigationState, ctx: NavigationContext): ViewDefinition;
|
|
27
|
+
export declare function getHiddenDays(definition: ViewDefinition, ctx: NavigationContext): DayOfWeek[];
|
|
28
|
+
/** First non-hidden day of the range (or the first day when all are hidden). */
|
|
29
|
+
export declare function firstVisibleDay(range: DateRange, hidden: readonly DayOfWeek[]): PlainDate;
|
|
30
|
+
/** Can the range move one step toward the past (`-1`) or future (`1`) within `min` / `max`? (C10) */
|
|
31
|
+
export declare function canNavigate(state: NavigationState, direction: 1 | -1, ctx: NavigationContext): boolean;
|
|
32
|
+
/** Pure navigation: returns the next state. Clamps to `min` / `max`. */
|
|
33
|
+
export declare function navigate(state: NavigationState, action: NavigationAction, ctx: NavigationContext): NavigationState;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { clampDate, compare, dateRangeLength, dayOfWeek, eachDay, } from "../../foundation/index.js";
|
|
2
|
+
import { addLength, getRange } from "./range.js";
|
|
3
|
+
import { resolveView } from "./view-definition.js";
|
|
4
|
+
export function getDefinition(state, ctx) {
|
|
5
|
+
return state.custom ?? resolveView(ctx.views, state.view);
|
|
6
|
+
}
|
|
7
|
+
export function getHiddenDays(definition, ctx) {
|
|
8
|
+
return [...(definition.hiddenDays ?? []), ...ctx.hiddenDays];
|
|
9
|
+
}
|
|
10
|
+
function clampToBounds(date, ctx) {
|
|
11
|
+
let result = date;
|
|
12
|
+
if (ctx.min && compare(result, ctx.min) < 0)
|
|
13
|
+
result = ctx.min;
|
|
14
|
+
if (ctx.max && compare(result, ctx.max) > 0)
|
|
15
|
+
result = ctx.max;
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
/** First non-hidden day of the range (or the first day when all are hidden). */
|
|
19
|
+
export function firstVisibleDay(range, hidden) {
|
|
20
|
+
for (const date of eachDay(range)) {
|
|
21
|
+
if (!hidden.includes(dayOfWeek(date)))
|
|
22
|
+
return date;
|
|
23
|
+
}
|
|
24
|
+
return range.start;
|
|
25
|
+
}
|
|
26
|
+
/** Keep the focus where it is when possible; otherwise pull it into the range onto a visible day. */
|
|
27
|
+
function settleFocus(focused, range, hidden, ctx) {
|
|
28
|
+
const inside = clampDate(focused, range);
|
|
29
|
+
return clampToBounds(hidden.includes(dayOfWeek(inside)) ? firstVisibleDay(range, hidden) : inside, ctx);
|
|
30
|
+
}
|
|
31
|
+
/** Can the range move one step toward the past (`-1`) or future (`1`) within `min` / `max`? (C10) */
|
|
32
|
+
export function canNavigate(state, direction, ctx) {
|
|
33
|
+
const range = getRange(getDefinition(state, ctx), state.anchor, ctx);
|
|
34
|
+
if (direction === -1) {
|
|
35
|
+
return ctx.min === undefined || compare(range.start, ctx.min) > 0;
|
|
36
|
+
}
|
|
37
|
+
return ctx.max === undefined || compare(range.end, ctx.max) < 0;
|
|
38
|
+
}
|
|
39
|
+
/** Pure navigation: returns the next state. Clamps to `min` / `max`. */
|
|
40
|
+
export function navigate(state, action, ctx) {
|
|
41
|
+
const definition = getDefinition(state, ctx);
|
|
42
|
+
if (action === "prev" || action === "next") {
|
|
43
|
+
const sign = action === "prev" ? -1 : 1;
|
|
44
|
+
if (!canNavigate(state, sign, ctx)) {
|
|
45
|
+
return state;
|
|
46
|
+
}
|
|
47
|
+
const anchor = clampToBounds(addLength(state.anchor, definition.length, sign), ctx);
|
|
48
|
+
const range = getRange(definition, anchor, ctx);
|
|
49
|
+
const focused = settleFocus(addLength(state.focusedDate, definition.length, sign), range, getHiddenDays(definition, ctx), ctx);
|
|
50
|
+
return { ...state, anchor, focusedDate: focused };
|
|
51
|
+
}
|
|
52
|
+
if (action === "today") {
|
|
53
|
+
const anchor = clampToBounds(ctx.today, ctx);
|
|
54
|
+
return { ...state, anchor, focusedDate: anchor };
|
|
55
|
+
}
|
|
56
|
+
if ("goTo" in action) {
|
|
57
|
+
const anchor = clampToBounds(action.goTo, ctx);
|
|
58
|
+
return { ...state, anchor, focusedDate: anchor };
|
|
59
|
+
}
|
|
60
|
+
if ("view" in action) {
|
|
61
|
+
const next = resolveView(ctx.views, action.view);
|
|
62
|
+
const range = getRange(next, state.anchor, ctx);
|
|
63
|
+
const focused = settleFocus(state.focusedDate, range, getHiddenDays(next, ctx), ctx);
|
|
64
|
+
return { view: action.view, anchor: state.anchor, focusedDate: focused };
|
|
65
|
+
}
|
|
66
|
+
const length = dateRangeLength(action.range);
|
|
67
|
+
const custom = {
|
|
68
|
+
...definition,
|
|
69
|
+
id: "custom",
|
|
70
|
+
length: { days: length },
|
|
71
|
+
align: "day",
|
|
72
|
+
months: undefined,
|
|
73
|
+
};
|
|
74
|
+
const anchor = clampToBounds(action.range.start, ctx);
|
|
75
|
+
return {
|
|
76
|
+
view: "custom",
|
|
77
|
+
custom,
|
|
78
|
+
anchor,
|
|
79
|
+
focusedDate: settleFocus(state.focusedDate, getRange(custom, anchor, ctx), getHiddenDays(custom, ctx), ctx),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type DateRange, type DayOfWeek, type PlainDate } from "../../foundation/index.js";
|
|
2
|
+
import { type ViewDefinition, type ViewLength } from "./view-definition.js";
|
|
3
|
+
export type RangeContext = {
|
|
4
|
+
weekStartsOn: DayOfWeek;
|
|
5
|
+
};
|
|
6
|
+
/** Move `date` forward (`1`) or backward (`-1`) by one view length. */
|
|
7
|
+
export declare function addLength(date: PlainDate, length: ViewLength, sign: 1 | -1): PlainDate;
|
|
8
|
+
/** The logical period of a view around `anchor` (for example Nov 1-30). */
|
|
9
|
+
export declare function getRange(definition: ViewDefinition, anchor: PlainDate, ctx: RangeContext): DateRange;
|
|
10
|
+
/**
|
|
11
|
+
* What is on screen: month layouts add the adjacent days that complete their
|
|
12
|
+
* weeks. Hidden days stay inside the range (hidden, not removed), so fetching
|
|
13
|
+
* is stable.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getVisibleRange(definition: ViewDefinition, range: DateRange, ctx: RangeContext): DateRange;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { addDays, addMonths, addWeeks, endOfWeek, getMonths, startOfMonth, startOfWeek, startOfYear, } from "../../foundation/index.js";
|
|
2
|
+
import { getMonthCount } from "./view-definition.js";
|
|
3
|
+
function alignStart(definition, anchor, ctx) {
|
|
4
|
+
switch (definition.align) {
|
|
5
|
+
case "week":
|
|
6
|
+
return startOfWeek(anchor, ctx.weekStartsOn);
|
|
7
|
+
case "month":
|
|
8
|
+
return startOfMonth(anchor);
|
|
9
|
+
case "year":
|
|
10
|
+
return startOfYear(anchor);
|
|
11
|
+
default:
|
|
12
|
+
return anchor;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Move `date` forward (`1`) or backward (`-1`) by one view length. */
|
|
16
|
+
export function addLength(date, length, sign) {
|
|
17
|
+
if (length.months !== undefined)
|
|
18
|
+
return addMonths(date, sign * length.months);
|
|
19
|
+
if (length.weeks !== undefined)
|
|
20
|
+
return addWeeks(date, sign * length.weeks);
|
|
21
|
+
return addDays(date, sign * (length.days ?? 1));
|
|
22
|
+
}
|
|
23
|
+
/** The logical period of a view around `anchor` (for example Nov 1-30). */
|
|
24
|
+
export function getRange(definition, anchor, ctx) {
|
|
25
|
+
const start = alignStart(definition, anchor, ctx);
|
|
26
|
+
const next = addLength(start, definition.length, 1);
|
|
27
|
+
return { start, end: addDays(next, -1) };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What is on screen: month layouts add the adjacent days that complete their
|
|
31
|
+
* weeks. Hidden days stay inside the range (hidden, not removed), so fetching
|
|
32
|
+
* is stable.
|
|
33
|
+
*/
|
|
34
|
+
export function getVisibleRange(definition, range, ctx) {
|
|
35
|
+
if (definition.layout !== "month") {
|
|
36
|
+
return range;
|
|
37
|
+
}
|
|
38
|
+
if (definition.length.months === undefined) {
|
|
39
|
+
return {
|
|
40
|
+
start: startOfWeek(range.start, ctx.weekStartsOn),
|
|
41
|
+
end: endOfWeek(range.end, ctx.weekStartsOn),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const grids = getMonths(range.start, getMonthCount(definition), {
|
|
45
|
+
weekStartsOn: ctx.weekStartsOn,
|
|
46
|
+
fixedWeeks: definition.fixedWeeks,
|
|
47
|
+
});
|
|
48
|
+
const first = grids[0]?.weeks[0]?.days[0]?.date ?? range.start;
|
|
49
|
+
const lastWeeks = grids[grids.length - 1]?.weeks ?? [];
|
|
50
|
+
const last = lastWeeks[lastWeeks.length - 1]?.days[6]?.date ?? range.end;
|
|
51
|
+
return { start: first, end: last };
|
|
52
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DateRange } from "../../foundation/index.js";
|
|
2
|
+
import type { ViewDefinition } from "./view-definition.js";
|
|
3
|
+
export type CalendarTitle = {
|
|
4
|
+
text: string;
|
|
5
|
+
parts: Intl.DateTimeFormatPart[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Title of a range: "November 2026" for one month, "Nov 2026 - Jan 2027" for
|
|
9
|
+
* several, "Tuesday, November 17, 2026" for one day, "Nov 16 - 22, 2026" for
|
|
10
|
+
* a span of days. `parts` lets apps style pieces.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getCalendarTitle(range: DateRange, definition: ViewDefinition, locale?: string): CalendarTitle;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { formatDateRangeToParts, formatDateToParts, isSameDay, isSameMonth, } from "../../foundation/index.js";
|
|
2
|
+
const join = (parts) => parts.map((part) => part.value).join("");
|
|
3
|
+
/**
|
|
4
|
+
* Title of a range: "November 2026" for one month, "Nov 2026 - Jan 2027" for
|
|
5
|
+
* several, "Tuesday, November 17, 2026" for one day, "Nov 16 - 22, 2026" for
|
|
6
|
+
* a span of days. `parts` lets apps style pieces.
|
|
7
|
+
*/
|
|
8
|
+
export function getCalendarTitle(range, definition, locale) {
|
|
9
|
+
let parts;
|
|
10
|
+
const wholeMonths = definition.layout === "month" && definition.length.months !== undefined;
|
|
11
|
+
if (wholeMonths && isSameMonth(range.start, range.end)) {
|
|
12
|
+
parts = formatDateToParts(range.start, locale, {
|
|
13
|
+
month: "long",
|
|
14
|
+
year: "numeric",
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
else if (wholeMonths) {
|
|
18
|
+
parts = formatDateRangeToParts(range, locale, {
|
|
19
|
+
month: "short",
|
|
20
|
+
year: "numeric",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else if (isSameDay(range.start, range.end)) {
|
|
24
|
+
parts = formatDateToParts(range.start, locale, {
|
|
25
|
+
weekday: "long",
|
|
26
|
+
month: "long",
|
|
27
|
+
day: "numeric",
|
|
28
|
+
year: "numeric",
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
parts = formatDateRangeToParts(range, locale, {
|
|
33
|
+
month: "short",
|
|
34
|
+
day: "numeric",
|
|
35
|
+
year: "numeric",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return { text: join(parts), parts };
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DayOfWeek } from "../../foundation/index.js";
|
|
2
|
+
import type { ResourceLayoutBuilder, TimelineSlotDuration, TimelineUnit } from "../resources/types.js";
|
|
3
|
+
/** Base layouts, plus the names resource packs add (plan 10 IG1). */
|
|
4
|
+
export type ViewLayout = "month" | "time-grid" | "list" | (string & {});
|
|
5
|
+
/** Exactly one of `days`, `weeks`, `months`. */
|
|
6
|
+
export type ViewLength = {
|
|
7
|
+
days?: number;
|
|
8
|
+
weeks?: number;
|
|
9
|
+
months?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Every view, built-in or custom, is data (C3). */
|
|
12
|
+
export type ViewDefinition = {
|
|
13
|
+
id: string;
|
|
14
|
+
layout: ViewLayout;
|
|
15
|
+
length: ViewLength;
|
|
16
|
+
/** Where a range starts relative to the anchor date. */
|
|
17
|
+
align: "day" | "week" | "month" | "year";
|
|
18
|
+
hiddenDays?: DayOfWeek[];
|
|
19
|
+
/** Month layout only: how many month grids to show. */
|
|
20
|
+
months?: number | undefined;
|
|
21
|
+
/** Month layout only: always render 6 rows per month. */
|
|
22
|
+
fixedWeeks?: boolean;
|
|
23
|
+
/** Resource packs (plan 10 IG1): builds the layout; never serialized. */
|
|
24
|
+
layoutBuilder?: ResourceLayoutBuilder;
|
|
25
|
+
/** Timeline: the axis slot length (plan 10 R6). */
|
|
26
|
+
slot?: TimelineSlotDuration;
|
|
27
|
+
/** Timeline: header rows, coarser first. */
|
|
28
|
+
headerRows?: TimelineUnit[];
|
|
29
|
+
};
|
|
30
|
+
export type CustomViews = Record<string, Omit<ViewDefinition, "id">>;
|
|
31
|
+
export declare const BUILT_IN_VIEW_IDS: readonly ["month", "week", "workWeek", "day", "agenda", "multiMonth"];
|
|
32
|
+
/** Built-in definitions. `workWeek` hides the given weekend (C9). */
|
|
33
|
+
export declare function getBuiltInViews(weekend: readonly DayOfWeek[]): Record<string, ViewDefinition>;
|
|
34
|
+
/** Merge app definitions over the built-ins. */
|
|
35
|
+
export declare function resolveViews(custom: CustomViews | undefined, weekend: readonly DayOfWeek[]): Record<string, ViewDefinition>;
|
|
36
|
+
/** Look up a view. Unknown ids throw in development and fall back to `month` in production. */
|
|
37
|
+
export declare function resolveView(views: Record<string, ViewDefinition>, id: string): ViewDefinition;
|
|
38
|
+
/** Number of month grids a month-layout definition shows. */
|
|
39
|
+
export declare function getMonthCount(definition: ViewDefinition): number;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const BUILT_IN_VIEW_IDS = [
|
|
2
|
+
"month",
|
|
3
|
+
"week",
|
|
4
|
+
"workWeek",
|
|
5
|
+
"day",
|
|
6
|
+
"agenda",
|
|
7
|
+
"multiMonth",
|
|
8
|
+
];
|
|
9
|
+
/** Built-in definitions. `workWeek` hides the given weekend (C9). */
|
|
10
|
+
export function getBuiltInViews(weekend) {
|
|
11
|
+
const view = (id, layout, length, align, extra = {}) => [id, { id, layout, length, align, ...extra }];
|
|
12
|
+
return Object.fromEntries([
|
|
13
|
+
view("month", "month", { months: 1 }, "month", { fixedWeeks: true }),
|
|
14
|
+
view("week", "time-grid", { weeks: 1 }, "week"),
|
|
15
|
+
view("workWeek", "time-grid", { weeks: 1 }, "week", {
|
|
16
|
+
hiddenDays: [...weekend],
|
|
17
|
+
}),
|
|
18
|
+
view("day", "time-grid", { days: 1 }, "day"),
|
|
19
|
+
view("agenda", "list", { days: 7 }, "day"),
|
|
20
|
+
view("multiMonth", "month", { months: 3 }, "month", {
|
|
21
|
+
months: 3,
|
|
22
|
+
fixedWeeks: true,
|
|
23
|
+
}),
|
|
24
|
+
]);
|
|
25
|
+
}
|
|
26
|
+
function assertDefinition(definition) {
|
|
27
|
+
const keys = ["days", "weeks", "months"].filter((key) => definition.length[key] !== undefined);
|
|
28
|
+
const value = keys.length === 1 ? definition.length[keys[0]] : undefined;
|
|
29
|
+
if (value === undefined || !Number.isInteger(value) || value < 1) {
|
|
30
|
+
throw new RangeError(`View "${definition.id}": length must be one positive integer.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Merge app definitions over the built-ins. */
|
|
34
|
+
export function resolveViews(custom, weekend) {
|
|
35
|
+
const views = getBuiltInViews(weekend);
|
|
36
|
+
for (const [id, definition] of Object.entries(custom ?? {})) {
|
|
37
|
+
const merged = { ...views[id], ...definition, id };
|
|
38
|
+
assertDefinition(merged);
|
|
39
|
+
views[id] = merged;
|
|
40
|
+
}
|
|
41
|
+
return views;
|
|
42
|
+
}
|
|
43
|
+
function isDevelopment() {
|
|
44
|
+
const env = globalThis.process
|
|
45
|
+
?.env;
|
|
46
|
+
return env?.NODE_ENV !== "production";
|
|
47
|
+
}
|
|
48
|
+
/** Look up a view. Unknown ids throw in development and fall back to `month` in production. */
|
|
49
|
+
export function resolveView(views, id) {
|
|
50
|
+
const found = views[id];
|
|
51
|
+
if (found) {
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
if (isDevelopment()) {
|
|
55
|
+
throw new RangeError(`Unknown view "${id}".`);
|
|
56
|
+
}
|
|
57
|
+
return views.month;
|
|
58
|
+
}
|
|
59
|
+
/** Number of month grids a month-layout definition shows. */
|
|
60
|
+
export function getMonthCount(definition) {
|
|
61
|
+
return definition.months ?? definition.length.months ?? 1;
|
|
62
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The view id one zoom step away (plan 10 R8): `-1` = finer (`zoomIn`), `1` =
|
|
3
|
+
* coarser (`zoomOut`). `undefined` at the ends or when `current` is not a level.
|
|
4
|
+
*/
|
|
5
|
+
export declare function zoomTarget(levels: readonly string[], current: string, direction: -1 | 1): string | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The view id one zoom step away (plan 10 R8): `-1` = finer (`zoomIn`), `1` =
|
|
3
|
+
* coarser (`zoomOut`). `undefined` at the ends or when `current` is not a level.
|
|
4
|
+
*/
|
|
5
|
+
export function zoomTarget(levels, current, direction) {
|
|
6
|
+
const index = levels.indexOf(current);
|
|
7
|
+
if (index < 0) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return levels[index + direction];
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type DateInput, type DateTimeInput, type PlainDateTime } from "../../foundation/index.js";
|
|
2
|
+
import type { EventChangeProposal } from "../controllers/drag-engine.js";
|
|
3
|
+
import type { CalendarEventInput, EventId } from "../events/types.js";
|
|
4
|
+
export type RecurrenceScope = "this" | "following" | "all";
|
|
5
|
+
/** The override object for a "this occurrence" change; the app assigns its id. */
|
|
6
|
+
export type RecurrenceOverride<T extends CalendarEventInput> = Omit<T, "id" | "rrule" | "exdates" | "rdates"> & {
|
|
7
|
+
recurringId: EventId;
|
|
8
|
+
recurrenceId: PlainDateTime;
|
|
9
|
+
start: DateTimeInput | DateInput;
|
|
10
|
+
end: DateTimeInput | DateInput;
|
|
11
|
+
allDay: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type RecurrenceChangeResult<T extends CalendarEventInput> = {
|
|
14
|
+
/** The old series, ended or with new dates. */
|
|
15
|
+
series?: T;
|
|
16
|
+
/** The "this occurrence" replacement. */
|
|
17
|
+
override?: RecurrenceOverride<T>;
|
|
18
|
+
/** The "following occurrences" series; the app assigns its id. */
|
|
19
|
+
newSeries?: Omit<T, "id">;
|
|
20
|
+
/** The series disappeared (`all` delete, or `following` from its first occurrence). */
|
|
21
|
+
removed?: boolean;
|
|
22
|
+
/** Old occurrence start → new start, for stored overrides (RR9). */
|
|
23
|
+
overrideIdMap?: {
|
|
24
|
+
from: PlainDateTime;
|
|
25
|
+
to: DateTimeInput | DateInput;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
export type RecurrenceDeleteResult<T extends CalendarEventInput> = {
|
|
29
|
+
series?: T;
|
|
30
|
+
removed?: boolean;
|
|
31
|
+
/** The override row the app should delete for `"this"` (RR9). */
|
|
32
|
+
removedOverrideRecurrenceId?: PlainDateTime;
|
|
33
|
+
};
|
|
34
|
+
export type ApplyRecurrenceOptions = {
|
|
35
|
+
/** Display zone for overrides and until instants. */
|
|
36
|
+
timeZone?: string;
|
|
37
|
+
/** Stored override starts, shifted by an `"all"` change. */
|
|
38
|
+
overrideStarts?: readonly (DateTimeInput | DateInput)[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Apply a move or resize to a series (plan 12 RR9). Returns new data; never
|
|
42
|
+
* mutates. Chrono does not choose the scope: the app asks the user and calls
|
|
43
|
+
* this with the answer, then saves the returned objects.
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyRecurrenceChange<T extends CalendarEventInput>(series: T, proposal: EventChangeProposal<T>, scope: RecurrenceScope, options?: ApplyRecurrenceOptions): RecurrenceChangeResult<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Apply a delete to a series (plan 12 RR9): `"this"` adds an EXDATE,
|
|
48
|
+
* `"following"` ends the series, `"all"` removes it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function applyRecurrenceDelete<T extends CalendarEventInput>(series: T, occurrenceStart: PlainDateTime, scope: RecurrenceScope, options?: ApplyRecurrenceOptions): RecurrenceDeleteResult<T>;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { addDays, compare, fromEpochDay, fromInstant, fromSecondOfDay, plainDate, plainDateTime, toEpochDay, toInstant, toPlainDateTime, toSecondOfDay, toZoned, } from "../../foundation/index.js";
|
|
2
|
+
import { parseRRule, stringifyRRule } from "./rrule.js";
|
|
3
|
+
import { expandRecurrence, recurrenceWall } from "./series.js";
|
|
4
|
+
import { withOptional } from "../../foundation/store/with-optional.js";
|
|
5
|
+
const SECONDS_PER_DAY = 86400;
|
|
6
|
+
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
7
|
+
const MIDNIGHT = { hour: 0, minute: 0, second: 0 };
|
|
8
|
+
const wallSeconds = (value) => toEpochDay(value) * SECONDS_PER_DAY + toSecondOfDay(value);
|
|
9
|
+
const fromWallSeconds = (seconds) => {
|
|
10
|
+
const day = Math.floor(seconds / SECONDS_PER_DAY);
|
|
11
|
+
return plainDateTime(fromEpochDay(day), fromSecondOfDay(seconds - day * SECONDS_PER_DAY));
|
|
12
|
+
};
|
|
13
|
+
const dateOf = (value) => plainDate(value.year, value.month, value.day);
|
|
14
|
+
const wall = (value, allDay, timeZone) => recurrenceWall(value, allDay, timeZone);
|
|
15
|
+
function isAllDayInput(value) {
|
|
16
|
+
if (typeof value === "string") {
|
|
17
|
+
return DATE_ONLY.test(value);
|
|
18
|
+
}
|
|
19
|
+
return typeof value === "object" && value !== null && !("hour" in value);
|
|
20
|
+
}
|
|
21
|
+
function zonedValue(value) {
|
|
22
|
+
if (typeof value === "string") {
|
|
23
|
+
return /(?:Z|[+-]\d{2}:?\d{2})(?:\[[^\]]+\])?$/.test(value);
|
|
24
|
+
}
|
|
25
|
+
return typeof value === "object" && value !== null && "timeZone" in value;
|
|
26
|
+
}
|
|
27
|
+
function shiftValue(value, allDay, delta, timeZone) {
|
|
28
|
+
const start = wall(value, allDay, timeZone);
|
|
29
|
+
const shifted = fromWallSeconds(wallSeconds(start) + delta);
|
|
30
|
+
if (allDay) {
|
|
31
|
+
return dateOf(shifted);
|
|
32
|
+
}
|
|
33
|
+
return zonedValue(value) ? toZoned(shifted, timeZone) : shifted;
|
|
34
|
+
}
|
|
35
|
+
function ruleOf(series) {
|
|
36
|
+
return parseRRule(series.rrule);
|
|
37
|
+
}
|
|
38
|
+
function ruleValue(original, rule) {
|
|
39
|
+
return typeof original === "string" ? stringifyRRule(rule) : rule;
|
|
40
|
+
}
|
|
41
|
+
function untilBefore(occurrenceStart, allDay, zoned, timeZone) {
|
|
42
|
+
if (allDay) {
|
|
43
|
+
return addDays(dateOf(occurrenceStart), -1);
|
|
44
|
+
}
|
|
45
|
+
if (zoned) {
|
|
46
|
+
return fromInstant(toInstant(toZoned(occurrenceStart, timeZone)) - 1000, "UTC");
|
|
47
|
+
}
|
|
48
|
+
return fromWallSeconds(wallSeconds(occurrenceStart) - 1);
|
|
49
|
+
}
|
|
50
|
+
/** 0-based index of the edited occurrence within its series. */
|
|
51
|
+
function occurrenceIndex(series, occurrenceStart, timeZone) {
|
|
52
|
+
const allDay = series.allDay ?? isAllDayInput(series.start);
|
|
53
|
+
const start = wall(series.start, allDay, timeZone);
|
|
54
|
+
const range = {
|
|
55
|
+
start: dateOf(start),
|
|
56
|
+
end: addDays(dateOf(occurrenceStart), 1),
|
|
57
|
+
};
|
|
58
|
+
// EXDATE does not reduce COUNT and RDATE is not counted, so index the bare rule.
|
|
59
|
+
const bare = { ...series, exdates: undefined, rdates: undefined };
|
|
60
|
+
const occurrences = expandRecurrence(bare, range, { timeZone });
|
|
61
|
+
return occurrences.filter((item) => compare(item.start, occurrenceStart) < 0).length;
|
|
62
|
+
}
|
|
63
|
+
/** End the old series before `occurrenceStart` (COUNT split or UNTIL). */
|
|
64
|
+
function splitSeries(series, occurrenceStart, timeZone) {
|
|
65
|
+
const shape = series;
|
|
66
|
+
const rule = ruleOf(shape);
|
|
67
|
+
const index = occurrenceIndex(shape, occurrenceStart, timeZone);
|
|
68
|
+
if (index === 0) {
|
|
69
|
+
return { series: undefined, index };
|
|
70
|
+
}
|
|
71
|
+
const next = { ...rule };
|
|
72
|
+
if (rule.count !== undefined) {
|
|
73
|
+
next.count = index;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
next.until = untilBefore(occurrenceStart, shape.allDay ?? isAllDayInput(shape.start), zonedValue(shape.start), timeZone);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
series: { ...shape, rrule: ruleValue(shape.rrule, next) },
|
|
80
|
+
index,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function omitSeriesFields(value) {
|
|
84
|
+
const copy = { ...value };
|
|
85
|
+
delete copy.id;
|
|
86
|
+
delete copy.rrule;
|
|
87
|
+
delete copy.exdates;
|
|
88
|
+
delete copy.rdates;
|
|
89
|
+
return copy;
|
|
90
|
+
}
|
|
91
|
+
function proposalOccurrence(proposal, timeZone) {
|
|
92
|
+
if (proposal.recurrence) {
|
|
93
|
+
return proposal.recurrence.occurrenceStart;
|
|
94
|
+
}
|
|
95
|
+
const value = proposal.from.start;
|
|
96
|
+
if (typeof value === "object" && !("hour" in value)) {
|
|
97
|
+
return plainDateTime(value, MIDNIGHT);
|
|
98
|
+
}
|
|
99
|
+
return toPlainDateTime(value, timeZone);
|
|
100
|
+
}
|
|
101
|
+
function shiftedList(values, occurrenceStart, allDay, delta, timeZone) {
|
|
102
|
+
if (values === undefined || values.length === 0) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const later = values.filter((value) => compare(wall(value, allDay, timeZone), occurrenceStart) >= 0);
|
|
106
|
+
return later.length > 0
|
|
107
|
+
? later.map((value) => shiftValue(value, allDay, delta, timeZone))
|
|
108
|
+
: undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Apply a move or resize to a series (plan 12 RR9). Returns new data; never
|
|
112
|
+
* mutates. Chrono does not choose the scope: the app asks the user and calls
|
|
113
|
+
* this with the answer, then saves the returned objects.
|
|
114
|
+
*/
|
|
115
|
+
export function applyRecurrenceChange(series, proposal, scope, options = {}) {
|
|
116
|
+
const timeZone = options.timeZone ?? "UTC";
|
|
117
|
+
const shape = series;
|
|
118
|
+
const occurrenceStart = proposalOccurrence(proposal, timeZone);
|
|
119
|
+
const allDay = proposal.to.allDay;
|
|
120
|
+
const delta = wallSeconds(wall(proposal.to.start, allDay, timeZone)) - wallSeconds(occurrenceStart);
|
|
121
|
+
if (scope === "this") {
|
|
122
|
+
return {
|
|
123
|
+
override: {
|
|
124
|
+
...omitSeriesFields(series),
|
|
125
|
+
recurringId: series.recurringId ?? series.id,
|
|
126
|
+
recurrenceId: occurrenceStart,
|
|
127
|
+
start: proposal.to.start,
|
|
128
|
+
end: proposal.to.end,
|
|
129
|
+
allDay,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (scope === "all") {
|
|
134
|
+
// A resize moves one edge only: the start shifts by `delta`, the end by its own distance.
|
|
135
|
+
const endDelta = wallSeconds(wall(proposal.to.end, allDay, timeZone)) -
|
|
136
|
+
wallSeconds(wall(proposal.from.end, allDay, timeZone));
|
|
137
|
+
return {
|
|
138
|
+
series: {
|
|
139
|
+
...shape,
|
|
140
|
+
start: shiftValue(shape.start, allDay, delta, timeZone),
|
|
141
|
+
end: shiftValue(shape.end, allDay, endDelta, timeZone),
|
|
142
|
+
...(shape.exdates
|
|
143
|
+
? {
|
|
144
|
+
exdates: shape.exdates.map((value) => shiftValue(value, allDay, delta, timeZone)),
|
|
145
|
+
}
|
|
146
|
+
: {}),
|
|
147
|
+
...(shape.rdates
|
|
148
|
+
? {
|
|
149
|
+
rdates: shape.rdates.map((value) => shiftValue(value, allDay, delta, timeZone)),
|
|
150
|
+
}
|
|
151
|
+
: {}),
|
|
152
|
+
},
|
|
153
|
+
overrideIdMap: (options.overrideStarts ?? []).map((value) => ({
|
|
154
|
+
from: wall(value, allDay, timeZone),
|
|
155
|
+
to: shiftValue(value, allDay, delta, timeZone),
|
|
156
|
+
})),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const split = splitSeries(series, occurrenceStart, timeZone);
|
|
160
|
+
const rule = ruleOf(shape);
|
|
161
|
+
const nextRule = { ...rule };
|
|
162
|
+
if (rule.count !== undefined) {
|
|
163
|
+
nextRule.count = rule.count - split.index;
|
|
164
|
+
}
|
|
165
|
+
const exdates = shiftedList(shape.exdates, occurrenceStart, allDay, delta, timeZone);
|
|
166
|
+
const rdates = shiftedList(shape.rdates, occurrenceStart, allDay, delta, timeZone);
|
|
167
|
+
const newSeries = {
|
|
168
|
+
...omitSeriesFields(series),
|
|
169
|
+
start: proposal.to.start,
|
|
170
|
+
end: proposal.to.end,
|
|
171
|
+
allDay,
|
|
172
|
+
rrule: ruleValue(shape.rrule, nextRule),
|
|
173
|
+
...(exdates ? { exdates } : {}),
|
|
174
|
+
...(rdates ? { rdates } : {}),
|
|
175
|
+
};
|
|
176
|
+
return withOptional({
|
|
177
|
+
series: split.series,
|
|
178
|
+
newSeries,
|
|
179
|
+
removed: split.series === undefined,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Apply a delete to a series (plan 12 RR9): `"this"` adds an EXDATE,
|
|
184
|
+
* `"following"` ends the series, `"all"` removes it.
|
|
185
|
+
*/
|
|
186
|
+
export function applyRecurrenceDelete(series, occurrenceStart, scope, options = {}) {
|
|
187
|
+
const timeZone = options.timeZone ?? "UTC";
|
|
188
|
+
if (scope === "all") {
|
|
189
|
+
return { removed: true };
|
|
190
|
+
}
|
|
191
|
+
if (scope === "following") {
|
|
192
|
+
const split = splitSeries(series, occurrenceStart, timeZone);
|
|
193
|
+
return withOptional({
|
|
194
|
+
series: split.series,
|
|
195
|
+
removed: split.series === undefined,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const shape = series;
|
|
199
|
+
return {
|
|
200
|
+
series: {
|
|
201
|
+
...shape,
|
|
202
|
+
exdates: [...(shape.exdates ?? []), occurrenceStart],
|
|
203
|
+
},
|
|
204
|
+
removedOverrideRecurrenceId: occurrenceStart,
|
|
205
|
+
};
|
|
206
|
+
}
|