@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,125 @@
|
|
|
1
|
+
import { fromEpochDay, fromSecondOfDay, plainDateTime, plainTime, toEpochDay, toSecondOfDay, } from "../../foundation/index.js";
|
|
2
|
+
const DAY = 86400;
|
|
3
|
+
const MIDNIGHT = plainTime(0, 0, 0);
|
|
4
|
+
export const toSeconds = (value) => toEpochDay(value) * DAY + toSecondOfDay(value);
|
|
5
|
+
export function fromSeconds(seconds) {
|
|
6
|
+
const day = Math.floor(seconds / DAY);
|
|
7
|
+
return plainDateTime(fromEpochDay(day), fromSecondOfDay(seconds - day * DAY));
|
|
8
|
+
}
|
|
9
|
+
/** Nearest multiple of `size`; an exact tie rounds up (plan 09 §13.2). */
|
|
10
|
+
export const snapTo = (seconds, size) => Math.floor(seconds / size + 0.5) * size;
|
|
11
|
+
const midnight = (date) => plainDateTime(date, MIDNIGHT);
|
|
12
|
+
const shiftDays = (value, days) => fromSeconds(toSeconds(value) + days * DAY);
|
|
13
|
+
const dayDiff = (a, b) => toEpochDay(a) - toEpochDay(b);
|
|
14
|
+
/** How far into the event (in days / minutes) the press happened. */
|
|
15
|
+
export function grabOf(value, target) {
|
|
16
|
+
const press = target.time
|
|
17
|
+
? plainDateTime(target.date, target.time)
|
|
18
|
+
: midnight(target.date);
|
|
19
|
+
const spanDays = Math.max(1, dayDiff(value.end, value.start) +
|
|
20
|
+
(toSecondOfDay(value.end) > 0 && !value.allDay ? 1 : 0));
|
|
21
|
+
return {
|
|
22
|
+
dayOffset: Math.min(Math.max(0, dayDiff(target.date, value.start)), spanDays - 1),
|
|
23
|
+
minuteOffset: Math.max(0, Math.round((toSeconds(press) - toSeconds(value.start)) / 60)),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Move an event so the grabbed part follows the pointer (plan 09 M4, M6). Returns
|
|
28
|
+
* `null` when the target is not allowed (all-day conversion switched off).
|
|
29
|
+
*/
|
|
30
|
+
export function moveEvent(from, grab, target, options) {
|
|
31
|
+
const duration = toSeconds(from.end) - toSeconds(from.start);
|
|
32
|
+
const dayLevel = options.view === "month" || target.allDayRow === true;
|
|
33
|
+
if (dayLevel) {
|
|
34
|
+
if (options.view === "time-grid" && !from.allDay) {
|
|
35
|
+
// A timed event dropped on the all-day row becomes all-day.
|
|
36
|
+
if (!options.allowAllDayConversion)
|
|
37
|
+
return null;
|
|
38
|
+
const days = Math.max(1, Math.ceil(duration / DAY));
|
|
39
|
+
const start = midnight(target.date);
|
|
40
|
+
return { start, end: shiftDays(start, days), allDay: true };
|
|
41
|
+
}
|
|
42
|
+
const delta = dayDiff(target.date, from.start) - grab.dayOffset;
|
|
43
|
+
return {
|
|
44
|
+
start: shiftDays(from.start, delta),
|
|
45
|
+
end: shiftDays(from.end, delta),
|
|
46
|
+
allDay: from.allDay,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!target.time)
|
|
50
|
+
return null;
|
|
51
|
+
const targetSeconds = toSeconds(plainDateTime(target.date, target.time));
|
|
52
|
+
if (from.allDay) {
|
|
53
|
+
// An all-day event dropped in the timed area becomes timed.
|
|
54
|
+
if (!options.allowAllDayConversion)
|
|
55
|
+
return null;
|
|
56
|
+
const start = fromSeconds(snapTo(targetSeconds, options.snap * 60));
|
|
57
|
+
return {
|
|
58
|
+
start,
|
|
59
|
+
end: fromSeconds(toSeconds(start) + options.defaultTimedDuration * 60),
|
|
60
|
+
allDay: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const start = fromSeconds(snapTo(targetSeconds - grab.minuteOffset * 60, options.snap * 60));
|
|
64
|
+
return {
|
|
65
|
+
start,
|
|
66
|
+
end: fromSeconds(toSeconds(start) + duration),
|
|
67
|
+
allDay: false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Move one edge to the pointer (plan 09 M5). The edge never crosses the other one:
|
|
72
|
+
* it stops one snap unit (one day for all-day) away.
|
|
73
|
+
*/
|
|
74
|
+
export function resizeEvent(from, edge, target, options) {
|
|
75
|
+
const snap = options.snap * 60;
|
|
76
|
+
const timedGrid = options.view === "time-grid" && !from.allDay && target.time !== undefined;
|
|
77
|
+
if (timedGrid && target.time) {
|
|
78
|
+
const wall = toSeconds(plainDateTime(target.date, target.time));
|
|
79
|
+
if (edge === "end") {
|
|
80
|
+
const end = Math.max(snapTo(wall + options.slot * 60, snap), toSeconds(from.start) + snap);
|
|
81
|
+
return { ...from, end: fromSeconds(end) };
|
|
82
|
+
}
|
|
83
|
+
const start = Math.min(snapTo(wall, snap), toSeconds(from.end) - snap);
|
|
84
|
+
return { ...from, start: fromSeconds(start) };
|
|
85
|
+
}
|
|
86
|
+
if (from.allDay) {
|
|
87
|
+
if (edge === "end") {
|
|
88
|
+
const end = Math.max(toSeconds(midnight(target.date)) + DAY, toSeconds(from.start) + DAY);
|
|
89
|
+
return { ...from, end: fromSeconds(end) };
|
|
90
|
+
}
|
|
91
|
+
const start = Math.min(toSeconds(midnight(target.date)), toSeconds(from.end) - DAY);
|
|
92
|
+
return { ...from, start: fromSeconds(start) };
|
|
93
|
+
}
|
|
94
|
+
// A timed event in the month grid: move the edge's day, keep its time of day.
|
|
95
|
+
if (edge === "end") {
|
|
96
|
+
const wall = toSeconds(plainDateTime(target.date, plainTime(from.end.hour, from.end.minute, from.end.second)));
|
|
97
|
+
return {
|
|
98
|
+
...from,
|
|
99
|
+
end: fromSeconds(Math.max(wall, toSeconds(from.start) + snap)),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const wall = toSeconds(plainDateTime(target.date, plainTime(from.start.hour, from.start.minute, from.start.second)));
|
|
103
|
+
return {
|
|
104
|
+
...from,
|
|
105
|
+
start: fromSeconds(Math.min(wall, toSeconds(from.end) - snap)),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** A keyboard step (plan 09 M10): shift by days and minutes. */
|
|
109
|
+
export function nudgeEvent(from, kind, step, options) {
|
|
110
|
+
const delta = step.days * DAY + step.minutes * 60;
|
|
111
|
+
const unit = from.allDay ? DAY : options.snap * 60;
|
|
112
|
+
if (kind === "move") {
|
|
113
|
+
return {
|
|
114
|
+
...from,
|
|
115
|
+
start: fromSeconds(toSeconds(from.start) + delta),
|
|
116
|
+
end: fromSeconds(toSeconds(from.end) + delta),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (kind === "resize-end") {
|
|
120
|
+
const end = Math.max(toSeconds(from.end) + delta, toSeconds(from.start) + unit);
|
|
121
|
+
return { ...from, end: fromSeconds(end) };
|
|
122
|
+
}
|
|
123
|
+
const start = Math.min(toSeconds(from.start) + delta, toSeconds(from.end) - unit);
|
|
124
|
+
return { ...from, start: fromSeconds(start) };
|
|
125
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Pure keyboard editing keys (plan 09 M10, §13.3). */
|
|
2
|
+
export type EditKind = "move" | "resize-start" | "resize-end";
|
|
3
|
+
export type Shortcuts = {
|
|
4
|
+
move: string;
|
|
5
|
+
resizeEnd: string;
|
|
6
|
+
resizeStart: string;
|
|
7
|
+
};
|
|
8
|
+
/** `R` resizes the end, `Shift+R` the start. */
|
|
9
|
+
export declare const DEFAULT_SHORTCUTS: Shortcuts;
|
|
10
|
+
export type KeyStep = {
|
|
11
|
+
type: "step";
|
|
12
|
+
days: number;
|
|
13
|
+
minutes: number;
|
|
14
|
+
} | {
|
|
15
|
+
type: "drop";
|
|
16
|
+
} | {
|
|
17
|
+
type: "cancel";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The edit a shortcut starts, or `null`. Matched case-insensitively on `key`; ignored
|
|
21
|
+
* with Ctrl, Alt or Meta so browser shortcuts keep working.
|
|
22
|
+
*/
|
|
23
|
+
export declare function matchShortcut(key: string, modifiers: {
|
|
24
|
+
shift: boolean;
|
|
25
|
+
ctrl: boolean;
|
|
26
|
+
meta: boolean;
|
|
27
|
+
alt?: boolean;
|
|
28
|
+
}, shortcuts: Shortcuts | false): EditKind | null;
|
|
29
|
+
/**
|
|
30
|
+
* What a key does while editing. Time grid: ↑/↓ by `snap` minutes, ←/→ by a day;
|
|
31
|
+
* month and the all-day row: ←/→ by a day, ↑/↓ by a week (a move only: a resize moves
|
|
32
|
+
* its edge along one axis and the other axis moves nothing). `rtl` swaps ←/→.
|
|
33
|
+
*/
|
|
34
|
+
export declare function editStep(kind: EditKind, key: string, context: {
|
|
35
|
+
timeGrid: boolean;
|
|
36
|
+
snap: number;
|
|
37
|
+
rtl?: boolean;
|
|
38
|
+
}): KeyStep | null;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Pure keyboard editing keys (plan 09 M10, §13.3). */
|
|
2
|
+
/** `R` resizes the end, `Shift+R` the start. */
|
|
3
|
+
export const DEFAULT_SHORTCUTS = {
|
|
4
|
+
move: "m",
|
|
5
|
+
resizeEnd: "r",
|
|
6
|
+
resizeStart: "R",
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The edit a shortcut starts, or `null`. Matched case-insensitively on `key`; ignored
|
|
10
|
+
* with Ctrl, Alt or Meta so browser shortcuts keep working.
|
|
11
|
+
*/
|
|
12
|
+
export function matchShortcut(key, modifiers, shortcuts) {
|
|
13
|
+
if (shortcuts === false ||
|
|
14
|
+
modifiers.ctrl ||
|
|
15
|
+
modifiers.meta ||
|
|
16
|
+
modifiers.alt) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const same = (a) => a.toLowerCase() === key.toLowerCase();
|
|
20
|
+
if (same(shortcuts.move) && !modifiers.shift)
|
|
21
|
+
return "move";
|
|
22
|
+
if (same(shortcuts.resizeEnd) && !modifiers.shift)
|
|
23
|
+
return "resize-end";
|
|
24
|
+
if (same(shortcuts.resizeStart) &&
|
|
25
|
+
(modifiers.shift || shortcuts.resizeStart !== shortcuts.resizeEnd)) {
|
|
26
|
+
return "resize-start";
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What a key does while editing. Time grid: ↑/↓ by `snap` minutes, ←/→ by a day;
|
|
32
|
+
* month and the all-day row: ←/→ by a day, ↑/↓ by a week (a move only: a resize moves
|
|
33
|
+
* its edge along one axis and the other axis moves nothing). `rtl` swaps ←/→.
|
|
34
|
+
*/
|
|
35
|
+
export function editStep(kind, key, context) {
|
|
36
|
+
if (key === "Enter")
|
|
37
|
+
return { type: "drop" };
|
|
38
|
+
if (key === "Escape")
|
|
39
|
+
return { type: "cancel" };
|
|
40
|
+
const horizontal = key === "ArrowLeft" ? -1 : key === "ArrowRight" ? 1 : 0;
|
|
41
|
+
const vertical = key === "ArrowUp" ? -1 : key === "ArrowDown" ? 1 : 0;
|
|
42
|
+
if (!horizontal && !vertical)
|
|
43
|
+
return null;
|
|
44
|
+
const side = context.rtl ? -horizontal : horizontal;
|
|
45
|
+
if (context.timeGrid) {
|
|
46
|
+
if (kind === "move") {
|
|
47
|
+
return { type: "step", days: side, minutes: vertical * context.snap };
|
|
48
|
+
}
|
|
49
|
+
// Resizing a time-grid event changes its edge vertically only.
|
|
50
|
+
return { type: "step", days: 0, minutes: vertical * context.snap };
|
|
51
|
+
}
|
|
52
|
+
if (kind === "move") {
|
|
53
|
+
return { type: "step", days: side + vertical * 7, minutes: 0 };
|
|
54
|
+
}
|
|
55
|
+
return { type: "step", days: side, minutes: 0 };
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type HitPoint, type HitTarget } from "./hit-test.js";
|
|
2
|
+
import type { EditKind } from "./drag-keyboard.js";
|
|
3
|
+
export type DragPointerHandlers = {
|
|
4
|
+
/** The press landed on an event (`segmentKey`); can it start this edit? */
|
|
5
|
+
canStart(kind: EditKind, segmentKey: string): boolean;
|
|
6
|
+
/** The drag began on `target`. Return `false` to refuse it. */
|
|
7
|
+
begin(kind: EditKind, segmentKey: string, target: HitTarget): boolean;
|
|
8
|
+
update(target: HitTarget): void;
|
|
9
|
+
drop(): void;
|
|
10
|
+
cancel(): void;
|
|
11
|
+
hitTest?: (point: HitPoint) => HitTarget | null;
|
|
12
|
+
/** Scroll container for auto-scroll; `false` turns it off. */
|
|
13
|
+
scroll?: () => HTMLElement | null | false;
|
|
14
|
+
};
|
|
15
|
+
export type DragPointer = {
|
|
16
|
+
destroy(): void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Pointer pipeline for moving and resizing events (plan 09 M7, M13, M14): primary button
|
|
20
|
+
* only, a 4 px threshold (touch: a 400 ms long press), one active drag per page, throttled
|
|
21
|
+
* to one update per frame, with auto-scroll near the edges.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createDragPointer(root: HTMLElement, handlers: DragPointerHandlers): DragPointer;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { getGlobalState } from "../../foundation/index.js";
|
|
2
|
+
import { createAutoScroll, scrollParent, } from "./auto-scroll.js";
|
|
3
|
+
import { elementHitTest } from "./hit-test.js";
|
|
4
|
+
const LONG_PRESS_MS = 400;
|
|
5
|
+
const THRESHOLD = 4;
|
|
6
|
+
const TOUCH_SLOP = 8;
|
|
7
|
+
const hasFrames = typeof requestAnimationFrame === "function";
|
|
8
|
+
const frame = (callback) => hasFrames
|
|
9
|
+
? requestAnimationFrame(callback)
|
|
10
|
+
: setTimeout(callback, 16);
|
|
11
|
+
const unframe = (handle) => hasFrames
|
|
12
|
+
? cancelAnimationFrame(handle)
|
|
13
|
+
: clearTimeout(handle);
|
|
14
|
+
/** One drag per page, even with two calendars or two copies of core (plan 09 M13). */
|
|
15
|
+
const lock = () => getGlobalState("calendar-drag", () => ({ owner: null }));
|
|
16
|
+
/**
|
|
17
|
+
* Pointer pipeline for moving and resizing events (plan 09 M7, M13, M14): primary button
|
|
18
|
+
* only, a 4 px threshold (touch: a 400 ms long press), one active drag per page, throttled
|
|
19
|
+
* to one update per frame, with auto-scroll near the edges.
|
|
20
|
+
*/
|
|
21
|
+
export function createDragPointer(root, handlers) {
|
|
22
|
+
const hitTest = handlers.hitTest ?? elementHitTest;
|
|
23
|
+
const token = Symbol("drag");
|
|
24
|
+
let pressed = null;
|
|
25
|
+
let dragging = false;
|
|
26
|
+
let longPress;
|
|
27
|
+
let pendingFrame = 0;
|
|
28
|
+
let last;
|
|
29
|
+
let scroller;
|
|
30
|
+
let swallowClick = false;
|
|
31
|
+
const onSelectStart = (event) => event.preventDefault();
|
|
32
|
+
const onTouchMove = (event) => {
|
|
33
|
+
if (event.cancelable)
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
};
|
|
36
|
+
const finish = () => {
|
|
37
|
+
if (longPress !== undefined) {
|
|
38
|
+
clearTimeout(longPress);
|
|
39
|
+
longPress = undefined;
|
|
40
|
+
}
|
|
41
|
+
if (pendingFrame !== 0) {
|
|
42
|
+
unframe(pendingFrame);
|
|
43
|
+
pendingFrame = 0;
|
|
44
|
+
}
|
|
45
|
+
scroller?.stop();
|
|
46
|
+
scroller = undefined;
|
|
47
|
+
document.removeEventListener("selectstart", onSelectStart);
|
|
48
|
+
document.removeEventListener("touchmove", onTouchMove);
|
|
49
|
+
window.removeEventListener("blur", onBlur);
|
|
50
|
+
if (pressed) {
|
|
51
|
+
try {
|
|
52
|
+
pressed.element.releasePointerCapture?.(pressed.id);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// The pointer may already be gone.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (lock().owner === token)
|
|
59
|
+
lock().owner = null;
|
|
60
|
+
pressed = null;
|
|
61
|
+
dragging = false;
|
|
62
|
+
last = undefined;
|
|
63
|
+
};
|
|
64
|
+
const begin = () => {
|
|
65
|
+
if (!pressed || dragging)
|
|
66
|
+
return false;
|
|
67
|
+
if (lock().owner !== null)
|
|
68
|
+
return false;
|
|
69
|
+
const target = hitTest({ x: pressed.x, y: pressed.y });
|
|
70
|
+
if (!target || !handlers.begin(pressed.kind, pressed.key, target))
|
|
71
|
+
return false;
|
|
72
|
+
lock().owner = token;
|
|
73
|
+
dragging = true;
|
|
74
|
+
document.addEventListener("selectstart", onSelectStart);
|
|
75
|
+
if (pressed.touch)
|
|
76
|
+
document.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
77
|
+
window.addEventListener("blur", onBlur);
|
|
78
|
+
try {
|
|
79
|
+
pressed.element.setPointerCapture?.(pressed.id);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// setPointerCapture throws for inactive pointers.
|
|
83
|
+
}
|
|
84
|
+
const container = handlers.scroll?.();
|
|
85
|
+
if (container !== false) {
|
|
86
|
+
scroller = createAutoScroll(() => container ?? scrollParent(root));
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
function onBlur() {
|
|
91
|
+
if (dragging) {
|
|
92
|
+
handlers.cancel();
|
|
93
|
+
finish();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const onDown = (event) => {
|
|
97
|
+
if (event.button !== 0 || pressed)
|
|
98
|
+
return; // primary button; a second pointer is ignored
|
|
99
|
+
const element = event.target?.closest?.("[data-chrono-event-key]");
|
|
100
|
+
if (!element || !root.contains(element))
|
|
101
|
+
return;
|
|
102
|
+
const handle = event.target.closest?.("[data-chrono-resize]");
|
|
103
|
+
const edge = handle?.getAttribute("data-chrono-resize");
|
|
104
|
+
const kind = edge === "start"
|
|
105
|
+
? "resize-start"
|
|
106
|
+
: edge === "end"
|
|
107
|
+
? "resize-end"
|
|
108
|
+
: "move";
|
|
109
|
+
const key = element.getAttribute("data-chrono-event-key") ?? "";
|
|
110
|
+
if (!handlers.canStart(kind, key))
|
|
111
|
+
return;
|
|
112
|
+
pressed = {
|
|
113
|
+
kind,
|
|
114
|
+
key,
|
|
115
|
+
x: event.clientX,
|
|
116
|
+
y: event.clientY,
|
|
117
|
+
id: event.pointerId,
|
|
118
|
+
touch: event.pointerType === "touch",
|
|
119
|
+
element: event.target,
|
|
120
|
+
};
|
|
121
|
+
if (pressed.touch) {
|
|
122
|
+
longPress = setTimeout(() => {
|
|
123
|
+
longPress = undefined;
|
|
124
|
+
if (!begin())
|
|
125
|
+
finish();
|
|
126
|
+
}, LONG_PRESS_MS);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const onMove = (event) => {
|
|
130
|
+
if (!pressed || event.pointerId !== pressed.id)
|
|
131
|
+
return;
|
|
132
|
+
if (!dragging) {
|
|
133
|
+
const slop = pressed.touch ? TOUCH_SLOP : THRESHOLD;
|
|
134
|
+
const far = Math.abs(event.clientX - pressed.x) > slop ||
|
|
135
|
+
Math.abs(event.clientY - pressed.y) > slop;
|
|
136
|
+
if (pressed.touch) {
|
|
137
|
+
if (far && longPress !== undefined)
|
|
138
|
+
finish(); // the finger scrolled: no drag
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!far)
|
|
142
|
+
return;
|
|
143
|
+
if (!begin()) {
|
|
144
|
+
finish();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
last = event;
|
|
149
|
+
scroller?.update({ x: event.clientX, y: event.clientY });
|
|
150
|
+
if (pendingFrame !== 0)
|
|
151
|
+
return;
|
|
152
|
+
pendingFrame = frame(() => {
|
|
153
|
+
pendingFrame = 0;
|
|
154
|
+
const move = last;
|
|
155
|
+
if (!move || !dragging)
|
|
156
|
+
return;
|
|
157
|
+
const target = hitTest({ x: move.clientX, y: move.clientY });
|
|
158
|
+
if (target)
|
|
159
|
+
handlers.update(target);
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
const onUp = (event) => {
|
|
163
|
+
if (!pressed || event.pointerId !== pressed.id)
|
|
164
|
+
return;
|
|
165
|
+
if (dragging) {
|
|
166
|
+
swallowClick = true;
|
|
167
|
+
handlers.drop();
|
|
168
|
+
}
|
|
169
|
+
finish();
|
|
170
|
+
};
|
|
171
|
+
const onCancel = (event) => {
|
|
172
|
+
if (!pressed || event.pointerId !== pressed.id)
|
|
173
|
+
return;
|
|
174
|
+
if (dragging)
|
|
175
|
+
handlers.cancel();
|
|
176
|
+
finish();
|
|
177
|
+
};
|
|
178
|
+
/** The click after a real drag must not select or activate the event. */
|
|
179
|
+
const onClick = (event) => {
|
|
180
|
+
if (swallowClick) {
|
|
181
|
+
swallowClick = false;
|
|
182
|
+
event.stopPropagation();
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
root.addEventListener("pointerdown", onDown);
|
|
187
|
+
root.addEventListener("pointermove", onMove);
|
|
188
|
+
root.addEventListener("pointerup", onUp);
|
|
189
|
+
root.addEventListener("pointercancel", onCancel);
|
|
190
|
+
root.addEventListener("click", onClick, true);
|
|
191
|
+
return {
|
|
192
|
+
destroy() {
|
|
193
|
+
if (dragging)
|
|
194
|
+
handlers.cancel();
|
|
195
|
+
finish();
|
|
196
|
+
root.removeEventListener("pointerdown", onDown);
|
|
197
|
+
root.removeEventListener("pointermove", onMove);
|
|
198
|
+
root.removeEventListener("pointerup", onUp);
|
|
199
|
+
root.removeEventListener("pointercancel", onCancel);
|
|
200
|
+
root.removeEventListener("click", onClick, true);
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure keyboard focus model for the "interactive cell" pattern (plan 05 E11):
|
|
3
|
+
* the calendar is one tab stop; Enter/F2 enters a cell's events, Escape/F2
|
|
4
|
+
* returns to the owning cell. No DOM access — the controller applies the focus.
|
|
5
|
+
*/
|
|
6
|
+
export type FocusMode = "navigation" | "interaction";
|
|
7
|
+
export type FocusState = {
|
|
8
|
+
mode: FocusMode;
|
|
9
|
+
/** The owning cell key (`YYYY-MM-DD` or `YYYY-MM-DDTHH:mm`). */
|
|
10
|
+
cellKey: string;
|
|
11
|
+
/** The focused item key inside interaction mode (an event or "+N more"). */
|
|
12
|
+
itemKey?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Ordered focusable items of a cell: event keys, then the "+N more" key last. */
|
|
15
|
+
export type FocusItems = readonly string[];
|
|
16
|
+
/** Enter interaction mode on the first item of a cell (E11). */
|
|
17
|
+
export declare function enterCell(cellKey: string, items: FocusItems): FocusState;
|
|
18
|
+
/** Whether a key leaves interaction mode back to the owning cell (Escape / F2). */
|
|
19
|
+
export declare function isExitKey(key: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Move focus inside interaction mode (plan 05 §2.5). Returns the next state for
|
|
22
|
+
* ↓/Tab (next, wrapping), ↑/Shift+Tab (previous, wrapping), Home/End
|
|
23
|
+
* (first/last), Escape/F2 (back to navigation), or `null` when the key is not
|
|
24
|
+
* an interaction-movement key (Space/Enter are handled by the controller).
|
|
25
|
+
*/
|
|
26
|
+
export declare function stepFocus(focus: FocusState, key: string, modifiers: {
|
|
27
|
+
shift: boolean;
|
|
28
|
+
}, items: FocusItems): FocusState | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure keyboard focus model for the "interactive cell" pattern (plan 05 E11):
|
|
3
|
+
* the calendar is one tab stop; Enter/F2 enters a cell's events, Escape/F2
|
|
4
|
+
* returns to the owning cell. No DOM access — the controller applies the focus.
|
|
5
|
+
*/
|
|
6
|
+
/** Enter interaction mode on the first item of a cell (E11). */
|
|
7
|
+
export function enterCell(cellKey, items) {
|
|
8
|
+
return { mode: "interaction", cellKey, itemKey: items[0] };
|
|
9
|
+
}
|
|
10
|
+
/** Whether a key leaves interaction mode back to the owning cell (Escape / F2). */
|
|
11
|
+
export function isExitKey(key) {
|
|
12
|
+
return key === "Escape" || key === "F2";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Move focus inside interaction mode (plan 05 §2.5). Returns the next state for
|
|
16
|
+
* ↓/Tab (next, wrapping), ↑/Shift+Tab (previous, wrapping), Home/End
|
|
17
|
+
* (first/last), Escape/F2 (back to navigation), or `null` when the key is not
|
|
18
|
+
* an interaction-movement key (Space/Enter are handled by the controller).
|
|
19
|
+
*/
|
|
20
|
+
export function stepFocus(focus, key, modifiers, items) {
|
|
21
|
+
if (items.length === 0) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const index = Math.max(0, items.indexOf(focus.itemKey ?? ""));
|
|
25
|
+
if (key === "ArrowDown" || (key === "Tab" && !modifiers.shift)) {
|
|
26
|
+
return { ...focus, itemKey: items[(index + 1) % items.length] };
|
|
27
|
+
}
|
|
28
|
+
if (key === "ArrowUp" || (key === "Tab" && modifiers.shift)) {
|
|
29
|
+
return {
|
|
30
|
+
...focus,
|
|
31
|
+
itemKey: items[(index - 1 + items.length) % items.length],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (key === "Home") {
|
|
35
|
+
return { ...focus, itemKey: items[0] };
|
|
36
|
+
}
|
|
37
|
+
if (key === "End") {
|
|
38
|
+
return { ...focus, itemKey: items[items.length - 1] };
|
|
39
|
+
}
|
|
40
|
+
if (isExitKey(key)) {
|
|
41
|
+
return { mode: "navigation", cellKey: focus.cellKey };
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Pointer → cell hit testing (plan 05 E17): by element, never by geometry. */
|
|
2
|
+
export type HitPoint = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export type HitTarget = {
|
|
7
|
+
cellKey: string;
|
|
8
|
+
/** The element is a time-grid all-day-row cell (`data-all-day-cell`). */
|
|
9
|
+
allDay?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The default hit test: the nearest `[data-chrono-key]` among the elements under
|
|
13
|
+
* the point (`document.elementsFromPoint`, so an event or column overlay drawn
|
|
14
|
+
* above the slots does not hide the cell below it). Works with any CSS,
|
|
15
|
+
* transform, zoom and RTL.
|
|
16
|
+
*/
|
|
17
|
+
export declare function elementHitTest(point: HitPoint): HitTarget | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Pointer → cell hit testing (plan 05 E17): by element, never by geometry. */
|
|
2
|
+
/**
|
|
3
|
+
* The default hit test: the nearest `[data-chrono-key]` among the elements under
|
|
4
|
+
* the point (`document.elementsFromPoint`, so an event or column overlay drawn
|
|
5
|
+
* above the slots does not hide the cell below it). Works with any CSS,
|
|
6
|
+
* transform, zoom and RTL.
|
|
7
|
+
*/
|
|
8
|
+
export function elementHitTest(point) {
|
|
9
|
+
if (typeof document === "undefined") {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const stack = typeof document.elementsFromPoint === "function"
|
|
13
|
+
? document.elementsFromPoint(point.x, point.y)
|
|
14
|
+
: [document.elementFromPoint(point.x, point.y)];
|
|
15
|
+
for (const element of stack) {
|
|
16
|
+
const cell = element?.closest?.("[data-chrono-key]");
|
|
17
|
+
const key = cell?.getAttribute("data-chrono-key");
|
|
18
|
+
if (key) {
|
|
19
|
+
return {
|
|
20
|
+
cellKey: key,
|
|
21
|
+
...(cell?.hasAttribute("data-all-day-cell") ? { allDay: true } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CalendarEventInput, NormalizedEvent } from "../events/types.js";
|
|
2
|
+
import { type EditValue } from "./drag-geometry.js";
|
|
3
|
+
/** A change the app has accepted but `events` does not show yet (plan 09 M3). */
|
|
4
|
+
export type PendingChange = {
|
|
5
|
+
/** The normalized event key. */
|
|
6
|
+
eventKey: string;
|
|
7
|
+
eventId: string | number;
|
|
8
|
+
to: EditValue;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A pending change is resolved when the incoming events show the event at the new
|
|
12
|
+
* position (zoned values compare by instant: they are already display wall time), or
|
|
13
|
+
* when the event is gone.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isResolved<T extends CalendarEventInput>(change: PendingChange, incoming: readonly NormalizedEvent<T>[]): boolean;
|
|
16
|
+
/** The pending changes that remain after `incoming` arrived. */
|
|
17
|
+
export declare function unresolved<T extends CalendarEventInput>(pending: readonly PendingChange[], incoming: readonly NormalizedEvent<T>[]): PendingChange[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toSeconds } from "./drag-geometry.js";
|
|
2
|
+
const same = (a, b) => a.allDay === b.allDay &&
|
|
3
|
+
toSeconds(a.start) === toSeconds(b.start) &&
|
|
4
|
+
toSeconds(a.end) === toSeconds(b.end);
|
|
5
|
+
/**
|
|
6
|
+
* A pending change is resolved when the incoming events show the event at the new
|
|
7
|
+
* position (zoned values compare by instant: they are already display wall time), or
|
|
8
|
+
* when the event is gone.
|
|
9
|
+
*/
|
|
10
|
+
export function isResolved(change, incoming) {
|
|
11
|
+
const found = incoming.find((event) => event.id === change.eventId);
|
|
12
|
+
return !found || same(change.to, found);
|
|
13
|
+
}
|
|
14
|
+
/** The pending changes that remain after `incoming` arrived. */
|
|
15
|
+
export function unresolved(pending, incoming) {
|
|
16
|
+
return pending.filter((change) => !isResolved(change, incoming));
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type HitPoint, type HitTarget } from "./hit-test.js";
|
|
2
|
+
export type SelectionPointerHandlers = {
|
|
3
|
+
start(target: HitTarget): void;
|
|
4
|
+
extend(target: HitTarget): void;
|
|
5
|
+
confirm(): void;
|
|
6
|
+
cancel(): void;
|
|
7
|
+
/** Skip a press (for example on an event that is being dragged instead). */
|
|
8
|
+
ignore?: (event: PointerEvent) => boolean;
|
|
9
|
+
/** Tests pass their own; the default uses `elementHitTest`. */
|
|
10
|
+
hitTest?: (point: HitPoint) => HitTarget | null;
|
|
11
|
+
};
|
|
12
|
+
export type SelectionPointer = {
|
|
13
|
+
destroy(): void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Pointer selection pipeline (plan 05 §13.2): drag-select on `[data-chrono-key]`
|
|
17
|
+
* cells. Touch arms a 400 ms long press (canceled by a move past 8 px); a
|
|
18
|
+
* short touch scrolls as usual (E18). Pointer moves are throttled to one per
|
|
19
|
+
* animation frame.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createSelectionPointer(root: HTMLElement, handlers: SelectionPointerHandlers): SelectionPointer;
|