@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,99 @@
|
|
|
1
|
+
import { type Attributes, type Messages, type PlainDate, type PlainDateTime, type ZonedDateTime } from "../../foundation/index.js";
|
|
2
|
+
import type { AllDayRowSegment, CalendarEventInput, CalendarEvents, NormalizedEvent } from "../events/types.js";
|
|
3
|
+
import { type EditValue } from "../interaction/drag-geometry.js";
|
|
4
|
+
import { type EditKind, type Shortcuts } from "../interaction/drag-keyboard.js";
|
|
5
|
+
import type { HitTarget } from "../interaction/hit-test.js";
|
|
6
|
+
import type { RecurrenceInfo } from "../recurrence/types.js";
|
|
7
|
+
import { type PendingChange } from "../interaction/pending.js";
|
|
8
|
+
import type { Modifiers } from "./shared.js";
|
|
9
|
+
export type ChangeValue = {
|
|
10
|
+
start: PlainDateTime | ZonedDateTime | PlainDate;
|
|
11
|
+
end: PlainDateTime | ZonedDateTime | PlainDate;
|
|
12
|
+
allDay: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** The proposal a drop emits (plan 09 M2). Values use the types the event used; all-day ends are exclusive. */
|
|
15
|
+
export type EventChangeProposal<TEvent extends CalendarEventInput = CalendarEventInput> = {
|
|
16
|
+
kind: EditKind;
|
|
17
|
+
event: TEvent;
|
|
18
|
+
from: ChangeValue;
|
|
19
|
+
to: ChangeValue;
|
|
20
|
+
source: "pointer" | "keyboard";
|
|
21
|
+
/** The series occurrence this change belongs to (plan 12 RR8). */
|
|
22
|
+
recurrence?: RecurrenceInfo<TEvent>;
|
|
23
|
+
};
|
|
24
|
+
export type DragState<TEvent extends CalendarEventInput = CalendarEventInput> = {
|
|
25
|
+
kind: EditKind;
|
|
26
|
+
/** The segment key the drag started on. */
|
|
27
|
+
segmentKey: string;
|
|
28
|
+
/** The normalized event key. */
|
|
29
|
+
eventKey: string;
|
|
30
|
+
eventId: string | number;
|
|
31
|
+
source: "pointer" | "keyboard";
|
|
32
|
+
from: EditValue;
|
|
33
|
+
to: EditValue;
|
|
34
|
+
/** `false`: the target is not allowed, or `validateEventChange` said no. */
|
|
35
|
+
valid: boolean;
|
|
36
|
+
preview: {
|
|
37
|
+
events: CalendarEvents<TEvent>;
|
|
38
|
+
allDayRow: AllDayRowSegment<TEvent>[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type DragOptions<TEvent extends CalendarEventInput> = {
|
|
42
|
+
editable?: boolean;
|
|
43
|
+
isEventEditable?: (event: TEvent, kind: EditKind) => boolean;
|
|
44
|
+
snapDuration?: number;
|
|
45
|
+
allowAllDayConversion?: boolean;
|
|
46
|
+
defaultTimedDuration?: number;
|
|
47
|
+
onEventChange?: (proposal: EventChangeProposal<TEvent>) => void | boolean | Promise<boolean>;
|
|
48
|
+
validateEventChange?: (proposal: EventChangeProposal<TEvent>) => boolean;
|
|
49
|
+
pendingTimeout?: number;
|
|
50
|
+
keyboardShortcuts?: Partial<Shortcuts> | false;
|
|
51
|
+
getEventLabel?: (event: TEvent) => string;
|
|
52
|
+
announcer?: HTMLElement | false;
|
|
53
|
+
};
|
|
54
|
+
export type DragContext<TEvent extends CalendarEventInput> = {
|
|
55
|
+
options(): DragOptions<TEvent> & {
|
|
56
|
+
timeGrid?: {
|
|
57
|
+
step?: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
layoutKind(): "month" | "time-grid" | "list";
|
|
61
|
+
timeZone(): string;
|
|
62
|
+
locale(): string | undefined;
|
|
63
|
+
messages(): Messages;
|
|
64
|
+
rtl(): boolean;
|
|
65
|
+
normalized(): NormalizedEvent<TEvent>[];
|
|
66
|
+
segmentEvent(segmentKey: string): TEvent | undefined;
|
|
67
|
+
/** The normalized occurrence a segment key belongs to (plan 12 RR7). */
|
|
68
|
+
segmentNormalized(segmentKey: string): NormalizedEvent<TEvent> | undefined;
|
|
69
|
+
buildPreview(event: NormalizedEvent<TEvent>): DragState<TEvent>["preview"];
|
|
70
|
+
refresh(): void;
|
|
71
|
+
};
|
|
72
|
+
/** Pointer and keyboard editing of events, and the accepted changes still pending (plan 09). */
|
|
73
|
+
export declare function createDragEngine<TEvent extends CalendarEventInput>(ctx: DragContext<TEvent>): {
|
|
74
|
+
readonly drag: DragState<TEvent> | null;
|
|
75
|
+
readonly pending: PendingChange[];
|
|
76
|
+
isEditing: () => boolean;
|
|
77
|
+
canEdit: (norm: NormalizedEvent<TEvent>, kind: EditKind) => boolean;
|
|
78
|
+
canEditSegment(segmentKey: string, kind: EditKind): boolean;
|
|
79
|
+
/** Start an edit. `hit` is where the pointer grabbed the event (pointer drags). */
|
|
80
|
+
start(kind: EditKind, segmentKey: string, source: "pointer" | "keyboard", hit?: HitTarget): boolean;
|
|
81
|
+
update(hit: HitTarget): void;
|
|
82
|
+
drop(): void;
|
|
83
|
+
cancel(): void;
|
|
84
|
+
/** Keyboard editing keys. Returns `true` when the key was consumed. */
|
|
85
|
+
handleKey(key: string, modifiers: Modifiers): boolean;
|
|
86
|
+
/** The edit a shortcut starts for the focused event, or `null`. */
|
|
87
|
+
shortcut(key: string, modifiers: Modifiers & {
|
|
88
|
+
alt?: boolean;
|
|
89
|
+
}): EditKind | null;
|
|
90
|
+
/** A pending change shows the event at its new position (plan 09 M3). */
|
|
91
|
+
override(norm: NormalizedEvent<TEvent>): NormalizedEvent<TEvent>;
|
|
92
|
+
pendingSignature: () => string;
|
|
93
|
+
/** `events` changed: resolve pending changes, cancel a drag whose event vanished (M14). */
|
|
94
|
+
onEventsChanged(incoming: readonly NormalizedEvent<TEvent>[]): void;
|
|
95
|
+
attributes(segmentKey: string): Attributes;
|
|
96
|
+
resizeHandle(segmentKey: string, edge: "start" | "end"): Attributes;
|
|
97
|
+
dispose(): void;
|
|
98
|
+
};
|
|
99
|
+
export type DragEngine<TEvent extends CalendarEventInput> = ReturnType<typeof createDragEngine<TEvent>>;
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { announce, formatDateTime, formatMessage, fromInstant, parseCellKey, plainDate, plainDateTime, toInstant, toZoned, } from "../../foundation/index.js";
|
|
2
|
+
import { grabOf, moveEvent, nudgeEvent, resizeEvent, toSeconds, } from "../interaction/drag-geometry.js";
|
|
3
|
+
import { DEFAULT_SHORTCUTS, editStep, matchShortcut, } from "../interaction/drag-keyboard.js";
|
|
4
|
+
import { unresolved } from "../interaction/pending.js";
|
|
5
|
+
const isZonedInput = (value) => (typeof value === "object" && value !== null && "timeZone" in value) ||
|
|
6
|
+
(typeof value === "string" && /\[|Z$|[+-]\d{2}:?\d{2}$/.test(value));
|
|
7
|
+
/** Pointer and keyboard editing of events, and the accepted changes still pending (plan 09). */
|
|
8
|
+
export function createDragEngine(ctx) {
|
|
9
|
+
let drag = null;
|
|
10
|
+
let pending = [];
|
|
11
|
+
let grab = { dayOffset: 0, minuteOffset: 0 };
|
|
12
|
+
let lastAnnounce = 0;
|
|
13
|
+
let token = 0;
|
|
14
|
+
const timers = new Map();
|
|
15
|
+
const shortcuts = () => {
|
|
16
|
+
const configured = ctx.options().keyboardShortcuts;
|
|
17
|
+
return configured === false
|
|
18
|
+
? false
|
|
19
|
+
: { ...DEFAULT_SHORTCUTS, ...configured };
|
|
20
|
+
};
|
|
21
|
+
const geometry = () => {
|
|
22
|
+
const options = ctx.options();
|
|
23
|
+
const slot = options.timeGrid?.step ?? 30;
|
|
24
|
+
return {
|
|
25
|
+
view: ctx.layoutKind() === "month" ? "month" : "time-grid",
|
|
26
|
+
snap: options.snapDuration ?? slot,
|
|
27
|
+
slot,
|
|
28
|
+
allowAllDayConversion: options.allowAllDayConversion ?? true,
|
|
29
|
+
defaultTimedDuration: options.defaultTimedDuration ?? 60,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const normalizedOf = (segmentKey) => ctx.segmentNormalized(segmentKey);
|
|
33
|
+
const canEdit = (norm, kind) => {
|
|
34
|
+
const options = ctx.options();
|
|
35
|
+
if (!options.editable || ctx.layoutKind() === "list")
|
|
36
|
+
return false;
|
|
37
|
+
const event = norm.event;
|
|
38
|
+
if (event.editable === false)
|
|
39
|
+
return false;
|
|
40
|
+
if (kind === "move" ? event.movable === false : event.resizable === false)
|
|
41
|
+
return false;
|
|
42
|
+
return options.isEventEditable
|
|
43
|
+
? options.isEventEditable(event, kind)
|
|
44
|
+
: true;
|
|
45
|
+
};
|
|
46
|
+
const editValueOf = (norm) => ({
|
|
47
|
+
start: norm.start,
|
|
48
|
+
end: norm.end,
|
|
49
|
+
allDay: norm.allDay,
|
|
50
|
+
});
|
|
51
|
+
const toChange = (norm, value) => {
|
|
52
|
+
const date = (v) => plainDate(v.year, v.month, v.day);
|
|
53
|
+
if (value.allDay) {
|
|
54
|
+
return { start: date(value.start), end: date(value.end), allDay: true };
|
|
55
|
+
}
|
|
56
|
+
if (isZonedInput(norm.event.start)) {
|
|
57
|
+
const zone = ctx.timeZone();
|
|
58
|
+
return {
|
|
59
|
+
start: toZoned(value.start, zone),
|
|
60
|
+
end: toZoned(value.end, zone),
|
|
61
|
+
allDay: false,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return { start: value.start, end: value.end, allDay: false };
|
|
65
|
+
};
|
|
66
|
+
const proposalOf = (state, norm) => ({
|
|
67
|
+
kind: state.kind,
|
|
68
|
+
event: norm.event,
|
|
69
|
+
from: toChange(norm, state.from),
|
|
70
|
+
to: toChange(norm, state.to),
|
|
71
|
+
source: state.source,
|
|
72
|
+
recurrence: norm.recurrence,
|
|
73
|
+
});
|
|
74
|
+
/** A zoned event keeps its real duration across DST (plan 09 §13.2); plain events keep wall time. */
|
|
75
|
+
const keepRealDuration = (norm, to) => {
|
|
76
|
+
if (to.allDay || !isZonedInput(norm.event.start))
|
|
77
|
+
return to;
|
|
78
|
+
const zone = ctx.timeZone();
|
|
79
|
+
const duration = toInstant(toZoned(norm.end, zone)) - toInstant(toZoned(norm.start, zone));
|
|
80
|
+
const start = toZoned(to.start, zone);
|
|
81
|
+
const end = fromInstant(toInstant(start) + duration, zone);
|
|
82
|
+
return { ...to, end: plainDateTime(end, end) };
|
|
83
|
+
};
|
|
84
|
+
const rangeText = (value) => {
|
|
85
|
+
const locale = ctx.locale();
|
|
86
|
+
const format = {
|
|
87
|
+
weekday: "long",
|
|
88
|
+
hour: "numeric",
|
|
89
|
+
minute: "2-digit",
|
|
90
|
+
};
|
|
91
|
+
return value.allDay
|
|
92
|
+
? formatDateTime(value.start, locale, {
|
|
93
|
+
weekday: "long",
|
|
94
|
+
day: "numeric",
|
|
95
|
+
month: "long",
|
|
96
|
+
})
|
|
97
|
+
: `${formatDateTime(value.start, locale, format)} – ${formatDateTime(value.end, locale, { hour: "numeric", minute: "2-digit" })}`;
|
|
98
|
+
};
|
|
99
|
+
const say = (template, value, norm) => {
|
|
100
|
+
const label = norm
|
|
101
|
+
? (ctx.options().getEventLabel?.(norm.event) ?? String(norm.id))
|
|
102
|
+
: "";
|
|
103
|
+
announce(formatMessage(ctx.messages()[template], {
|
|
104
|
+
event: label,
|
|
105
|
+
range: rangeText(value),
|
|
106
|
+
}), ctx.options().announcer);
|
|
107
|
+
};
|
|
108
|
+
const build = (kind, segmentKey, norm, from, candidate, source) => {
|
|
109
|
+
const to = candidate
|
|
110
|
+
? kind === "move"
|
|
111
|
+
? keepRealDuration(norm, candidate)
|
|
112
|
+
: candidate
|
|
113
|
+
: from;
|
|
114
|
+
const partial = { kind, from, to, source };
|
|
115
|
+
const valid = candidate !== null &&
|
|
116
|
+
(ctx.options().validateEventChange?.(proposalOf(partial, norm)) ?? true);
|
|
117
|
+
const preview = ctx.buildPreview({
|
|
118
|
+
...norm,
|
|
119
|
+
key: `${norm.key}:preview`,
|
|
120
|
+
start: to.start,
|
|
121
|
+
end: to.end,
|
|
122
|
+
allDay: to.allDay,
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
...partial,
|
|
126
|
+
segmentKey,
|
|
127
|
+
eventKey: norm.key,
|
|
128
|
+
eventId: norm.id,
|
|
129
|
+
valid,
|
|
130
|
+
preview,
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const targetOf = (hit) => {
|
|
134
|
+
const { date, time } = parseCellKey(hit.cellKey);
|
|
135
|
+
return { date, time, allDayRow: hit.allDay };
|
|
136
|
+
};
|
|
137
|
+
const removePending = (eventKey, expected) => {
|
|
138
|
+
const timer = timers.get(eventKey);
|
|
139
|
+
if (timer !== undefined) {
|
|
140
|
+
clearTimeout(timer);
|
|
141
|
+
timers.delete(eventKey);
|
|
142
|
+
}
|
|
143
|
+
const before = pending.length;
|
|
144
|
+
pending = pending.filter((change) => change.eventKey !== eventKey ||
|
|
145
|
+
(expected !== undefined && tokens.get(eventKey) !== expected));
|
|
146
|
+
if (pending.length !== before)
|
|
147
|
+
tokens.delete(eventKey);
|
|
148
|
+
ctx.refresh();
|
|
149
|
+
};
|
|
150
|
+
const tokens = new Map();
|
|
151
|
+
const commit = (state, norm) => {
|
|
152
|
+
const proposal = proposalOf(state, norm);
|
|
153
|
+
let result;
|
|
154
|
+
try {
|
|
155
|
+
result = ctx.options().onEventChange?.(proposal);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error("[chrono] onEventChange threw; the change is rejected.", error);
|
|
159
|
+
say("changeCancelled", state.from);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (result === false) {
|
|
163
|
+
say("changeCancelled", state.from);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const mine = ++token;
|
|
167
|
+
tokens.set(norm.key, mine);
|
|
168
|
+
pending = [
|
|
169
|
+
...pending.filter((change) => change.eventKey !== norm.key),
|
|
170
|
+
{ eventKey: norm.key, eventId: norm.id, to: state.to },
|
|
171
|
+
];
|
|
172
|
+
const timer = timers.get(norm.key);
|
|
173
|
+
if (timer !== undefined)
|
|
174
|
+
clearTimeout(timer);
|
|
175
|
+
timers.set(norm.key, setTimeout(() => removePending(norm.key, mine), ctx.options().pendingTimeout ?? 10_000));
|
|
176
|
+
say(state.kind === "move" ? "movedTo" : "resizedTo", state.to);
|
|
177
|
+
if (result && typeof result.then === "function") {
|
|
178
|
+
result.then((ok) => {
|
|
179
|
+
if (ok === false)
|
|
180
|
+
removePending(norm.key, mine);
|
|
181
|
+
}, (error) => {
|
|
182
|
+
console.error("[chrono] onEventChange rejected; the change is dropped.", error);
|
|
183
|
+
removePending(norm.key, mine);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
const engine = {
|
|
188
|
+
get drag() {
|
|
189
|
+
return drag;
|
|
190
|
+
},
|
|
191
|
+
get pending() {
|
|
192
|
+
return pending;
|
|
193
|
+
},
|
|
194
|
+
isEditing: () => drag !== null && drag.source === "keyboard",
|
|
195
|
+
canEdit,
|
|
196
|
+
canEditSegment(segmentKey, kind) {
|
|
197
|
+
const norm = normalizedOf(segmentKey);
|
|
198
|
+
return !!norm && canEdit(norm, kind);
|
|
199
|
+
},
|
|
200
|
+
/** Start an edit. `hit` is where the pointer grabbed the event (pointer drags). */
|
|
201
|
+
start(kind, segmentKey, source, hit) {
|
|
202
|
+
const norm = normalizedOf(segmentKey);
|
|
203
|
+
if (!norm || !canEdit(norm, kind) || drag)
|
|
204
|
+
return false;
|
|
205
|
+
const from = editValueOf(norm);
|
|
206
|
+
grab = hit
|
|
207
|
+
? grabOf(from, targetOf(hit))
|
|
208
|
+
: { dayOffset: 0, minuteOffset: 0 };
|
|
209
|
+
drag = build(kind, segmentKey, norm, from, from, source);
|
|
210
|
+
say(kind === "move" ? "moving" : "resizing", from, norm);
|
|
211
|
+
ctx.refresh();
|
|
212
|
+
return true;
|
|
213
|
+
},
|
|
214
|
+
update(hit) {
|
|
215
|
+
if (!drag)
|
|
216
|
+
return;
|
|
217
|
+
const norm = ctx.normalized().find((n) => n.key === drag?.eventKey);
|
|
218
|
+
if (!norm)
|
|
219
|
+
return;
|
|
220
|
+
const target = targetOf(hit);
|
|
221
|
+
const g = geometry();
|
|
222
|
+
const candidate = drag.kind === "move"
|
|
223
|
+
? moveEvent(drag.from, grab, target, g)
|
|
224
|
+
: resizeEvent(drag.from, drag.kind === "resize-start" ? "start" : "end", target, g);
|
|
225
|
+
const next = build(drag.kind, drag.segmentKey, norm, drag.from, candidate, drag.source);
|
|
226
|
+
if (toSeconds(next.to.start) === toSeconds(drag.to.start) &&
|
|
227
|
+
toSeconds(next.to.end) === toSeconds(drag.to.end) &&
|
|
228
|
+
next.to.allDay === drag.to.allDay &&
|
|
229
|
+
next.valid === drag.valid) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
drag = next;
|
|
233
|
+
const now = Date.now();
|
|
234
|
+
if (now - lastAnnounce >= 500) {
|
|
235
|
+
lastAnnounce = now;
|
|
236
|
+
say(drag.valid
|
|
237
|
+
? drag.kind === "move"
|
|
238
|
+
? "moving"
|
|
239
|
+
: "resizing"
|
|
240
|
+
: "notAllowedHere", drag.to, norm);
|
|
241
|
+
}
|
|
242
|
+
ctx.refresh();
|
|
243
|
+
},
|
|
244
|
+
drop() {
|
|
245
|
+
const current = drag;
|
|
246
|
+
if (!current)
|
|
247
|
+
return;
|
|
248
|
+
const norm = ctx.normalized().find((n) => n.key === current.eventKey);
|
|
249
|
+
drag = null;
|
|
250
|
+
if (norm &&
|
|
251
|
+
current.valid &&
|
|
252
|
+
(toSeconds(current.to.start) !== toSeconds(current.from.start) ||
|
|
253
|
+
toSeconds(current.to.end) !== toSeconds(current.from.end) ||
|
|
254
|
+
current.to.allDay !== current.from.allDay)) {
|
|
255
|
+
commit(current, norm);
|
|
256
|
+
}
|
|
257
|
+
else if (norm && !current.valid) {
|
|
258
|
+
say("notAllowedHere", current.to);
|
|
259
|
+
}
|
|
260
|
+
ctx.refresh();
|
|
261
|
+
},
|
|
262
|
+
cancel() {
|
|
263
|
+
if (!drag)
|
|
264
|
+
return;
|
|
265
|
+
const from = drag.from;
|
|
266
|
+
drag = null;
|
|
267
|
+
say("changeCancelled", from);
|
|
268
|
+
ctx.refresh();
|
|
269
|
+
},
|
|
270
|
+
/** Keyboard editing keys. Returns `true` when the key was consumed. */
|
|
271
|
+
handleKey(key, modifiers) {
|
|
272
|
+
const current = drag;
|
|
273
|
+
if (!current)
|
|
274
|
+
return false;
|
|
275
|
+
if (key === "Tab")
|
|
276
|
+
return true; // focus cannot leave mid-edit
|
|
277
|
+
const step = editStep(current.kind, key, {
|
|
278
|
+
timeGrid: ctx.layoutKind() === "time-grid" && !current.to.allDay,
|
|
279
|
+
snap: geometry().snap,
|
|
280
|
+
rtl: ctx.rtl(),
|
|
281
|
+
});
|
|
282
|
+
void modifiers;
|
|
283
|
+
if (!step)
|
|
284
|
+
return false;
|
|
285
|
+
const norm = ctx.normalized().find((n) => n.key === current.eventKey);
|
|
286
|
+
if (!norm)
|
|
287
|
+
return false;
|
|
288
|
+
if (step.type === "cancel") {
|
|
289
|
+
engine.cancel();
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
if (step.type === "drop") {
|
|
293
|
+
if (!current.valid) {
|
|
294
|
+
say("notAllowedHere", current.to);
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
engine.drop();
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
const moved = nudgeEvent(current.to, current.kind, step, geometry());
|
|
301
|
+
drag = build(current.kind, current.segmentKey, norm, current.from, moved, "keyboard");
|
|
302
|
+
say(drag.valid
|
|
303
|
+
? drag.kind === "move"
|
|
304
|
+
? "moving"
|
|
305
|
+
: "resizing"
|
|
306
|
+
: "notAllowedHere", drag.to, norm);
|
|
307
|
+
ctx.refresh();
|
|
308
|
+
return true;
|
|
309
|
+
},
|
|
310
|
+
/** The edit a shortcut starts for the focused event, or `null`. */
|
|
311
|
+
shortcut(key, modifiers) {
|
|
312
|
+
return matchShortcut(key, modifiers, shortcuts());
|
|
313
|
+
},
|
|
314
|
+
/** A pending change shows the event at its new position (plan 09 M3). */
|
|
315
|
+
override(norm) {
|
|
316
|
+
const change = pending.find((item) => item.eventKey === norm.key);
|
|
317
|
+
return change
|
|
318
|
+
? {
|
|
319
|
+
...norm,
|
|
320
|
+
start: change.to.start,
|
|
321
|
+
end: change.to.end,
|
|
322
|
+
allDay: change.to.allDay,
|
|
323
|
+
}
|
|
324
|
+
: norm;
|
|
325
|
+
},
|
|
326
|
+
pendingSignature: () => pending
|
|
327
|
+
.map((c) => `${c.eventKey}@${toSeconds(c.to.start)}-${toSeconds(c.to.end)}${c.to.allDay ? "d" : ""}`)
|
|
328
|
+
.join(","),
|
|
329
|
+
/** `events` changed: resolve pending changes, cancel a drag whose event vanished (M14). */
|
|
330
|
+
onEventsChanged(incoming) {
|
|
331
|
+
const remaining = unresolved(pending, incoming);
|
|
332
|
+
if (remaining.length !== pending.length) {
|
|
333
|
+
for (const change of pending) {
|
|
334
|
+
if (!remaining.includes(change)) {
|
|
335
|
+
const timer = timers.get(change.eventKey);
|
|
336
|
+
if (timer !== undefined)
|
|
337
|
+
clearTimeout(timer);
|
|
338
|
+
timers.delete(change.eventKey);
|
|
339
|
+
tokens.delete(change.eventKey);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
pending = remaining;
|
|
343
|
+
}
|
|
344
|
+
if (drag && !incoming.some((n) => n.key === drag?.eventKey)) {
|
|
345
|
+
drag = null;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
attributes(segmentKey) {
|
|
349
|
+
const norm = ctx.segmentNormalized(segmentKey);
|
|
350
|
+
const editable = !!norm && (canEdit(norm, "move") || canEdit(norm, "resize-end"));
|
|
351
|
+
const keys = shortcuts();
|
|
352
|
+
return {
|
|
353
|
+
"data-editable": editable,
|
|
354
|
+
"data-dragging": !!drag && !!norm && drag.eventKey === norm.key,
|
|
355
|
+
"data-pending": !!norm && pending.some((c) => c.eventKey === norm.key),
|
|
356
|
+
"aria-keyshortcuts": editable && keys
|
|
357
|
+
? `${keys.move.toUpperCase()} ${keys.resizeEnd.toUpperCase()} Shift+${keys.resizeEnd.toUpperCase()}`
|
|
358
|
+
: undefined,
|
|
359
|
+
"aria-description": editable
|
|
360
|
+
? ctx.messages().editInstructions
|
|
361
|
+
: undefined,
|
|
362
|
+
};
|
|
363
|
+
},
|
|
364
|
+
resizeHandle(segmentKey, edge) {
|
|
365
|
+
const norm = normalizedOf(segmentKey);
|
|
366
|
+
return {
|
|
367
|
+
"data-chrono-resize": edge,
|
|
368
|
+
"aria-hidden": "true",
|
|
369
|
+
"data-disabled": !norm ||
|
|
370
|
+
!canEdit(norm, edge === "start" ? "resize-start" : "resize-end"),
|
|
371
|
+
};
|
|
372
|
+
},
|
|
373
|
+
dispose() {
|
|
374
|
+
for (const timer of timers.values())
|
|
375
|
+
clearTimeout(timer);
|
|
376
|
+
timers.clear();
|
|
377
|
+
drag = null;
|
|
378
|
+
pending = [];
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
return engine;
|
|
382
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type Attributes, type DateInput, type DateRange, type DayOfWeek, type Messages, type PlainDate, type WeekdayHeader } from "../../foundation/index.js";
|
|
2
|
+
import { type CalendarTitle } from "../navigation/title.js";
|
|
3
|
+
import { type CalendarDay } from "../views/day.js";
|
|
4
|
+
import type { MonthLayout } from "../views/month-layout.js";
|
|
5
|
+
import { type Modifiers } from "./shared.js";
|
|
6
|
+
export type MonthValue = {
|
|
7
|
+
year: number;
|
|
8
|
+
month: number;
|
|
9
|
+
};
|
|
10
|
+
export type MiniCalendarOptions = {
|
|
11
|
+
id?: string;
|
|
12
|
+
month?: MonthValue;
|
|
13
|
+
defaultMonth?: MonthValue;
|
|
14
|
+
onMonthChange?: (month: MonthValue) => void;
|
|
15
|
+
/** Follow the main calendar when its date leaves the Mini Calendar's month (C11). */
|
|
16
|
+
syncWith?: {
|
|
17
|
+
date: PlainDate;
|
|
18
|
+
visibleRange: DateRange;
|
|
19
|
+
};
|
|
20
|
+
/** For example "has events". */
|
|
21
|
+
isMarked?: (date: PlainDate) => boolean;
|
|
22
|
+
/** Called when a day is clicked or activated with Enter (F2). */
|
|
23
|
+
onNavigate?: (date: PlainDate) => void;
|
|
24
|
+
locale?: string;
|
|
25
|
+
weekStartsOn?: DayOfWeek;
|
|
26
|
+
timeZone?: string;
|
|
27
|
+
now?: number;
|
|
28
|
+
min?: DateInput;
|
|
29
|
+
max?: DateInput;
|
|
30
|
+
weekNumbers?: "iso" | "locale" | false;
|
|
31
|
+
messages?: Partial<Messages>;
|
|
32
|
+
selectedDate?: DateInput;
|
|
33
|
+
highlightedDates?: readonly DateInput[] | ((date: PlainDate) => boolean);
|
|
34
|
+
};
|
|
35
|
+
export type MiniCalendarState = {
|
|
36
|
+
id: string;
|
|
37
|
+
month: MonthValue;
|
|
38
|
+
title: CalendarTitle;
|
|
39
|
+
today: PlainDate;
|
|
40
|
+
focusedDate: PlainDate;
|
|
41
|
+
layout: MonthLayout;
|
|
42
|
+
canGoPrev: boolean;
|
|
43
|
+
canGoNext: boolean;
|
|
44
|
+
direction: "ltr" | "rtl";
|
|
45
|
+
locale?: string;
|
|
46
|
+
messages: Messages;
|
|
47
|
+
};
|
|
48
|
+
export type MiniCalendarController = {
|
|
49
|
+
getState(): MiniCalendarState;
|
|
50
|
+
subscribe(listener: (state: MiniCalendarState) => void): () => void;
|
|
51
|
+
setOptions(options: Partial<MiniCalendarOptions>): void;
|
|
52
|
+
prev(): void;
|
|
53
|
+
next(): void;
|
|
54
|
+
focusDate(date: PlainDate): void;
|
|
55
|
+
activateDate(date: PlainDate, source: "pointer" | "keyboard"): void;
|
|
56
|
+
handleKeyDown(key: string, modifiers: Modifiers): boolean;
|
|
57
|
+
getRootAttributes(): Attributes;
|
|
58
|
+
getTitleAttributes(): Attributes;
|
|
59
|
+
getNavAttributes(kind: "prev" | "next"): Attributes;
|
|
60
|
+
getGridAttributes(): Attributes;
|
|
61
|
+
getColumnHeaderAttributes(header: WeekdayHeader): Attributes;
|
|
62
|
+
getCellAttributes(day: CalendarDay): Attributes;
|
|
63
|
+
getWeekNumberAttributes(weekNumber: number): Attributes;
|
|
64
|
+
destroy(): void;
|
|
65
|
+
};
|
|
66
|
+
export declare function createMiniCalendarController(initial?: MiniCalendarOptions): MiniCalendarController;
|