@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,119 @@
|
|
|
1
|
+
import { elementHitTest } from "./hit-test.js";
|
|
2
|
+
const LONG_PRESS_MS = 400;
|
|
3
|
+
const TOUCH_SLOP = 8;
|
|
4
|
+
const hasFrames = typeof requestAnimationFrame === "function";
|
|
5
|
+
const schedule = (callback) => hasFrames
|
|
6
|
+
? requestAnimationFrame(callback)
|
|
7
|
+
: setTimeout(callback, 16);
|
|
8
|
+
const cancel = (handle) => hasFrames
|
|
9
|
+
? cancelAnimationFrame(handle)
|
|
10
|
+
: clearTimeout(handle);
|
|
11
|
+
/**
|
|
12
|
+
* Pointer selection pipeline (plan 05 §13.2): drag-select on `[data-chrono-key]`
|
|
13
|
+
* cells. Touch arms a 400 ms long press (canceled by a move past 8 px); a
|
|
14
|
+
* short touch scrolls as usual (E18). Pointer moves are throttled to one per
|
|
15
|
+
* animation frame.
|
|
16
|
+
*/
|
|
17
|
+
export function createSelectionPointer(root, handlers) {
|
|
18
|
+
const hitTest = handlers.hitTest ?? elementHitTest;
|
|
19
|
+
let selecting = false;
|
|
20
|
+
let longPressTimer;
|
|
21
|
+
let frame = 0;
|
|
22
|
+
let startX = 0;
|
|
23
|
+
let startY = 0;
|
|
24
|
+
let lastMove;
|
|
25
|
+
const clearLongPress = () => {
|
|
26
|
+
if (longPressTimer !== undefined) {
|
|
27
|
+
clearTimeout(longPressTimer);
|
|
28
|
+
longPressTimer = undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const onPointerDown = (event) => {
|
|
32
|
+
if (event.button !== 0 || handlers.ignore?.(event)) {
|
|
33
|
+
return; // primary button only: a context-menu click never selects
|
|
34
|
+
}
|
|
35
|
+
const target = hitTest({ x: event.clientX, y: event.clientY });
|
|
36
|
+
if (!target) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (event.pointerType === "touch") {
|
|
40
|
+
startX = event.clientX;
|
|
41
|
+
startY = event.clientY;
|
|
42
|
+
clearLongPress();
|
|
43
|
+
longPressTimer = setTimeout(() => {
|
|
44
|
+
longPressTimer = undefined;
|
|
45
|
+
selecting = true;
|
|
46
|
+
event.target?.setPointerCapture?.(event.pointerId);
|
|
47
|
+
handlers.start(target);
|
|
48
|
+
}, LONG_PRESS_MS);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
selecting = true;
|
|
52
|
+
event.target?.setPointerCapture?.(event.pointerId);
|
|
53
|
+
handlers.start(target);
|
|
54
|
+
};
|
|
55
|
+
const onPointerMove = (event) => {
|
|
56
|
+
if (longPressTimer !== undefined) {
|
|
57
|
+
if (Math.abs(event.clientX - startX) > TOUCH_SLOP ||
|
|
58
|
+
Math.abs(event.clientY - startY) > TOUCH_SLOP) {
|
|
59
|
+
clearLongPress();
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!selecting) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
lastMove = event;
|
|
67
|
+
if (frame !== 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
frame = schedule(() => {
|
|
71
|
+
frame = 0;
|
|
72
|
+
const move = lastMove;
|
|
73
|
+
lastMove = undefined;
|
|
74
|
+
if (!move) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const target = hitTest({ x: move.clientX, y: move.clientY });
|
|
78
|
+
if (target) {
|
|
79
|
+
handlers.extend(target);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const onPointerUp = () => {
|
|
84
|
+
if (longPressTimer !== undefined) {
|
|
85
|
+
clearLongPress();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!selecting) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
selecting = false;
|
|
92
|
+
handlers.confirm();
|
|
93
|
+
};
|
|
94
|
+
const onPointerCancel = () => {
|
|
95
|
+
clearLongPress();
|
|
96
|
+
if (!selecting) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
selecting = false;
|
|
100
|
+
handlers.cancel();
|
|
101
|
+
};
|
|
102
|
+
root.addEventListener("pointerdown", onPointerDown);
|
|
103
|
+
root.addEventListener("pointermove", onPointerMove);
|
|
104
|
+
root.addEventListener("pointerup", onPointerUp);
|
|
105
|
+
root.addEventListener("pointercancel", onPointerCancel);
|
|
106
|
+
return {
|
|
107
|
+
destroy() {
|
|
108
|
+
root.removeEventListener("pointerdown", onPointerDown);
|
|
109
|
+
root.removeEventListener("pointermove", onPointerMove);
|
|
110
|
+
root.removeEventListener("pointerup", onPointerUp);
|
|
111
|
+
root.removeEventListener("pointercancel", onPointerCancel);
|
|
112
|
+
clearLongPress();
|
|
113
|
+
if (frame !== 0) {
|
|
114
|
+
cancel(frame);
|
|
115
|
+
frame = 0;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type PlainDate, type PlainDateTime, type PlainTime, type IntervalPiece } from "../../foundation/index.js";
|
|
2
|
+
export type SelectionCell = {
|
|
3
|
+
date: PlainDate;
|
|
4
|
+
/** Present for a timed slot; absent for a day cell / all-day row. */
|
|
5
|
+
time?: PlainTime;
|
|
6
|
+
};
|
|
7
|
+
export type SelectionOptions = {
|
|
8
|
+
/** Select whole days (month grid / all-day row) instead of a timed range. */
|
|
9
|
+
allDay?: boolean;
|
|
10
|
+
/** Snap granularity for timed selection (plan 05 E14), default 30 minutes. */
|
|
11
|
+
slotDurationMinutes?: number;
|
|
12
|
+
/** Clamp the selection length (E14); clamping is not invalidation. */
|
|
13
|
+
maxDurationMinutes?: number;
|
|
14
|
+
};
|
|
15
|
+
/** The half-open `[start, end)` selection. All-day ends are exclusive midnights. */
|
|
16
|
+
export type SelectionRange = {
|
|
17
|
+
start: PlainDateTime;
|
|
18
|
+
end: PlainDateTime;
|
|
19
|
+
allDay: boolean;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Compute a selection from an anchor cell to a current cell (plan 05 E14):
|
|
23
|
+
* one continuous range, snapped to `slotDurationMinutes`, `end` exclusive and
|
|
24
|
+
* `start + slot` when anchor and current are the same. Dragging backwards
|
|
25
|
+
* swaps. All-day selection spans whole days with an exclusive end.
|
|
26
|
+
*/
|
|
27
|
+
export declare function computeSelection(anchor: SelectionCell, current: SelectionCell, options?: SelectionOptions): SelectionRange;
|
|
28
|
+
/** The per-day pieces of a selection, for the preview elements (plan 05 §2.6). */
|
|
29
|
+
export declare function selectionPieces(range: SelectionRange): IntervalPiece<PlainDateTime>[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { addDays, compare, fromEpochDay, fromSecondOfDay, plainDateTime, plainTime, splitIntervalByDay, } from "../../foundation/index.js";
|
|
2
|
+
import { wallSecondsOf } from "../events/normalize.js";
|
|
3
|
+
const SECONDS_PER_DAY = 86400;
|
|
4
|
+
function fromWallSeconds(seconds) {
|
|
5
|
+
const day = Math.floor(seconds / SECONDS_PER_DAY);
|
|
6
|
+
const secondOfDay = seconds - day * SECONDS_PER_DAY;
|
|
7
|
+
return plainDateTime(fromEpochDay(day), fromSecondOfDay(secondOfDay));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Compute a selection from an anchor cell to a current cell (plan 05 E14):
|
|
11
|
+
* one continuous range, snapped to `slotDurationMinutes`, `end` exclusive and
|
|
12
|
+
* `start + slot` when anchor and current are the same. Dragging backwards
|
|
13
|
+
* swaps. All-day selection spans whole days with an exclusive end.
|
|
14
|
+
*/
|
|
15
|
+
export function computeSelection(anchor, current, options = {}) {
|
|
16
|
+
if (options.allDay) {
|
|
17
|
+
const start = compare(anchor.date, current.date) <= 0 ? anchor.date : current.date;
|
|
18
|
+
const end = compare(anchor.date, current.date) <= 0 ? current.date : anchor.date;
|
|
19
|
+
return {
|
|
20
|
+
start: plainDateTime(start, plainTime(0, 0, 0)),
|
|
21
|
+
end: plainDateTime(addDays(end, 1), plainTime(0, 0, 0)),
|
|
22
|
+
allDay: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const slot = (options.slotDurationMinutes ?? 30) * 60;
|
|
26
|
+
const anchorSeconds = wallSecondsOf(plainDateTime(anchor.date, anchor.time ?? plainTime(0, 0, 0)));
|
|
27
|
+
const currentSeconds = wallSecondsOf(plainDateTime(current.date, current.time ?? plainTime(0, 0, 0)));
|
|
28
|
+
const a = Math.floor(anchorSeconds / slot) * slot;
|
|
29
|
+
const c = Math.floor(currentSeconds / slot) * slot;
|
|
30
|
+
const startSeconds = Math.min(a, c);
|
|
31
|
+
let endSeconds = Math.max(a, c) + slot;
|
|
32
|
+
if (options.maxDurationMinutes !== undefined) {
|
|
33
|
+
const max = options.maxDurationMinutes * 60;
|
|
34
|
+
if (endSeconds - startSeconds > max) {
|
|
35
|
+
endSeconds = startSeconds + max;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
start: fromWallSeconds(startSeconds),
|
|
40
|
+
end: fromWallSeconds(endSeconds),
|
|
41
|
+
allDay: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The per-day pieces of a selection, for the preview elements (plan 05 §2.6). */
|
|
45
|
+
export function selectionPieces(range) {
|
|
46
|
+
return splitIntervalByDay({ start: range.start, end: range.end });
|
|
47
|
+
}
|
|
@@ -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;
|
|
10
|
+
};
|
|
11
|
+
export type NavigationContext = {
|
|
12
|
+
views: Record<string, ViewDefinition>;
|
|
13
|
+
weekStartsOn: DayOfWeek;
|
|
14
|
+
hiddenDays: readonly DayOfWeek[];
|
|
15
|
+
min?: PlainDate;
|
|
16
|
+
max?: PlainDate;
|
|
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,83 @@
|
|
|
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))
|
|
30
|
+
? firstVisibleDay(range, hidden)
|
|
31
|
+
: inside, ctx);
|
|
32
|
+
}
|
|
33
|
+
/** Can the range move one step toward the past (`-1`) or future (`1`) within `min` / `max`? (C10) */
|
|
34
|
+
export function canNavigate(state, direction, ctx) {
|
|
35
|
+
const range = getRange(getDefinition(state, ctx), state.anchor, ctx);
|
|
36
|
+
if (direction === -1) {
|
|
37
|
+
return ctx.min === undefined || compare(range.start, ctx.min) > 0;
|
|
38
|
+
}
|
|
39
|
+
return ctx.max === undefined || compare(range.end, ctx.max) < 0;
|
|
40
|
+
}
|
|
41
|
+
/** Pure navigation: returns the next state. Clamps to `min` / `max`. */
|
|
42
|
+
export function navigate(state, action, ctx) {
|
|
43
|
+
const definition = getDefinition(state, ctx);
|
|
44
|
+
if (action === "prev" || action === "next") {
|
|
45
|
+
const sign = action === "prev" ? -1 : 1;
|
|
46
|
+
if (!canNavigate(state, sign, ctx)) {
|
|
47
|
+
return state;
|
|
48
|
+
}
|
|
49
|
+
const anchor = clampToBounds(addLength(state.anchor, definition.length, sign), ctx);
|
|
50
|
+
const range = getRange(definition, anchor, ctx);
|
|
51
|
+
const focused = settleFocus(addLength(state.focusedDate, definition.length, sign), range, getHiddenDays(definition, ctx), ctx);
|
|
52
|
+
return { ...state, anchor, focusedDate: focused };
|
|
53
|
+
}
|
|
54
|
+
if (action === "today") {
|
|
55
|
+
const anchor = clampToBounds(ctx.today, ctx);
|
|
56
|
+
return { ...state, anchor, focusedDate: anchor };
|
|
57
|
+
}
|
|
58
|
+
if ("goTo" in action) {
|
|
59
|
+
const anchor = clampToBounds(action.goTo, ctx);
|
|
60
|
+
return { ...state, anchor, focusedDate: anchor };
|
|
61
|
+
}
|
|
62
|
+
if ("view" in action) {
|
|
63
|
+
const next = resolveView(ctx.views, action.view);
|
|
64
|
+
const range = getRange(next, state.anchor, ctx);
|
|
65
|
+
const focused = settleFocus(state.focusedDate, range, getHiddenDays(next, ctx), ctx);
|
|
66
|
+
return { view: action.view, anchor: state.anchor, focusedDate: focused };
|
|
67
|
+
}
|
|
68
|
+
const length = dateRangeLength(action.range);
|
|
69
|
+
const custom = {
|
|
70
|
+
...definition,
|
|
71
|
+
id: "custom",
|
|
72
|
+
length: { days: length },
|
|
73
|
+
align: "day",
|
|
74
|
+
months: undefined,
|
|
75
|
+
};
|
|
76
|
+
const anchor = clampToBounds(action.range.start, ctx);
|
|
77
|
+
return {
|
|
78
|
+
view: "custom",
|
|
79
|
+
custom,
|
|
80
|
+
anchor,
|
|
81
|
+
focusedDate: settleFocus(state.focusedDate, getRange(custom, anchor, ctx), getHiddenDays(custom, ctx), ctx),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -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;
|
|
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,61 @@
|
|
|
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?.env;
|
|
45
|
+
return env?.NODE_ENV !== "production";
|
|
46
|
+
}
|
|
47
|
+
/** Look up a view. Unknown ids throw in development and fall back to `month` in production. */
|
|
48
|
+
export function resolveView(views, id) {
|
|
49
|
+
const found = views[id];
|
|
50
|
+
if (found) {
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
if (isDevelopment()) {
|
|
54
|
+
throw new RangeError(`Unknown view "${id}".`);
|
|
55
|
+
}
|
|
56
|
+
return views.month;
|
|
57
|
+
}
|
|
58
|
+
/** Number of month grids a month-layout definition shows. */
|
|
59
|
+
export function getMonthCount(definition) {
|
|
60
|
+
return definition.months ?? definition.length.months ?? 1;
|
|
61
|
+
}
|
|
@@ -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>;
|