@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,207 @@
|
|
|
1
|
+
import { addDays, compare, fromEpochDay, fromInstant, fromSecondOfDay, plainDate, plainDateTime, toEpochDay, toInstant, toPlainDateTime, toSecondOfDay, toZoned, } from "../../foundation/index.js";
|
|
2
|
+
import { parseRRule, stringifyRRule } from "./rrule.js";
|
|
3
|
+
import { expandRecurrence, recurrenceWall } from "./series.js";
|
|
4
|
+
const SECONDS_PER_DAY = 86400;
|
|
5
|
+
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
6
|
+
const MIDNIGHT = { hour: 0, minute: 0, second: 0 };
|
|
7
|
+
const wallSeconds = (value) => toEpochDay(value) * SECONDS_PER_DAY + toSecondOfDay(value);
|
|
8
|
+
const fromWallSeconds = (seconds) => {
|
|
9
|
+
const day = Math.floor(seconds / SECONDS_PER_DAY);
|
|
10
|
+
return plainDateTime(fromEpochDay(day), fromSecondOfDay(seconds - day * SECONDS_PER_DAY));
|
|
11
|
+
};
|
|
12
|
+
const dateOf = (value) => plainDate(value.year, value.month, value.day);
|
|
13
|
+
const wall = (value, allDay, timeZone) => recurrenceWall(value, allDay, timeZone);
|
|
14
|
+
function isAllDayInput(value) {
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
return DATE_ONLY.test(value);
|
|
17
|
+
}
|
|
18
|
+
return typeof value === "object" && value !== null && !("hour" in value);
|
|
19
|
+
}
|
|
20
|
+
function zonedValue(value) {
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
return /(?:Z|[+-]\d{2}:?\d{2})(?:\[[^\]]+\])?$/.test(value);
|
|
23
|
+
}
|
|
24
|
+
return typeof value === "object" && value !== null && "timeZone" in value;
|
|
25
|
+
}
|
|
26
|
+
function shiftValue(value, allDay, delta, timeZone) {
|
|
27
|
+
const start = wall(value, allDay, timeZone);
|
|
28
|
+
const shifted = fromWallSeconds(wallSeconds(start) + delta);
|
|
29
|
+
if (allDay) {
|
|
30
|
+
return dateOf(shifted);
|
|
31
|
+
}
|
|
32
|
+
return zonedValue(value) ? toZoned(shifted, timeZone) : shifted;
|
|
33
|
+
}
|
|
34
|
+
function ruleOf(series) {
|
|
35
|
+
return parseRRule(series.rrule);
|
|
36
|
+
}
|
|
37
|
+
function ruleValue(original, rule) {
|
|
38
|
+
return typeof original === "string" ? stringifyRRule(rule) : rule;
|
|
39
|
+
}
|
|
40
|
+
function untilBefore(occurrenceStart, allDay, zoned, timeZone) {
|
|
41
|
+
if (allDay) {
|
|
42
|
+
return addDays(dateOf(occurrenceStart), -1);
|
|
43
|
+
}
|
|
44
|
+
if (zoned) {
|
|
45
|
+
return fromInstant(toInstant(toZoned(occurrenceStart, timeZone)) - 1000, "UTC");
|
|
46
|
+
}
|
|
47
|
+
return fromWallSeconds(wallSeconds(occurrenceStart) - 1);
|
|
48
|
+
}
|
|
49
|
+
/** 0-based index of the edited occurrence within its series. */
|
|
50
|
+
function occurrenceIndex(series, occurrenceStart, timeZone) {
|
|
51
|
+
const allDay = series.allDay ?? isAllDayInput(series.start);
|
|
52
|
+
const start = wall(series.start, allDay, timeZone);
|
|
53
|
+
const range = {
|
|
54
|
+
start: dateOf(start),
|
|
55
|
+
end: addDays(dateOf(occurrenceStart), 1),
|
|
56
|
+
};
|
|
57
|
+
// EXDATE does not reduce COUNT and RDATE is not counted, so index the bare rule.
|
|
58
|
+
const bare = { ...series, exdates: undefined, rdates: undefined };
|
|
59
|
+
const occurrences = expandRecurrence(bare, range, { timeZone });
|
|
60
|
+
return occurrences.filter((item) => compare(item.start, occurrenceStart) < 0)
|
|
61
|
+
.length;
|
|
62
|
+
}
|
|
63
|
+
/** End the old series before `occurrenceStart` (COUNT split or UNTIL). */
|
|
64
|
+
function splitSeries(series, occurrenceStart, timeZone) {
|
|
65
|
+
const shape = series;
|
|
66
|
+
const rule = ruleOf(shape);
|
|
67
|
+
const index = occurrenceIndex(shape, occurrenceStart, timeZone);
|
|
68
|
+
if (index === 0) {
|
|
69
|
+
return { series: undefined, index };
|
|
70
|
+
}
|
|
71
|
+
const next = { ...rule };
|
|
72
|
+
if (rule.count !== undefined) {
|
|
73
|
+
next.count = index;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
next.until = untilBefore(occurrenceStart, shape.allDay ?? isAllDayInput(shape.start), zonedValue(shape.start), timeZone);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
series: { ...shape, rrule: ruleValue(shape.rrule, next) },
|
|
80
|
+
index,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function omitSeriesFields(value) {
|
|
84
|
+
const copy = { ...value };
|
|
85
|
+
delete copy.id;
|
|
86
|
+
delete copy.rrule;
|
|
87
|
+
delete copy.exdates;
|
|
88
|
+
delete copy.rdates;
|
|
89
|
+
return copy;
|
|
90
|
+
}
|
|
91
|
+
function proposalOccurrence(proposal, timeZone) {
|
|
92
|
+
if (proposal.recurrence) {
|
|
93
|
+
return proposal.recurrence.occurrenceStart;
|
|
94
|
+
}
|
|
95
|
+
const value = proposal.from.start;
|
|
96
|
+
if (typeof value === "object" && !("hour" in value)) {
|
|
97
|
+
return plainDateTime(value, MIDNIGHT);
|
|
98
|
+
}
|
|
99
|
+
return toPlainDateTime(value, timeZone);
|
|
100
|
+
}
|
|
101
|
+
function shiftedList(values, occurrenceStart, allDay, delta, timeZone) {
|
|
102
|
+
if (values === undefined || values.length === 0) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const later = values.filter((value) => compare(wall(value, allDay, timeZone), occurrenceStart) >= 0);
|
|
106
|
+
return later.length > 0
|
|
107
|
+
? later.map((value) => shiftValue(value, allDay, delta, timeZone))
|
|
108
|
+
: undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Apply a move or resize to a series (plan 12 RR9). Returns new data; never
|
|
112
|
+
* mutates. Chrono does not choose the scope: the app asks the user and calls
|
|
113
|
+
* this with the answer, then saves the returned objects.
|
|
114
|
+
*/
|
|
115
|
+
export function applyRecurrenceChange(series, proposal, scope, options = {}) {
|
|
116
|
+
const timeZone = options.timeZone ?? "UTC";
|
|
117
|
+
const shape = series;
|
|
118
|
+
const occurrenceStart = proposalOccurrence(proposal, timeZone);
|
|
119
|
+
const allDay = proposal.to.allDay;
|
|
120
|
+
const delta = wallSeconds(wall(proposal.to.start, allDay, timeZone)) -
|
|
121
|
+
wallSeconds(occurrenceStart);
|
|
122
|
+
if (scope === "this") {
|
|
123
|
+
return {
|
|
124
|
+
override: {
|
|
125
|
+
...omitSeriesFields(series),
|
|
126
|
+
recurringId: series.recurringId ?? series.id,
|
|
127
|
+
recurrenceId: occurrenceStart,
|
|
128
|
+
start: proposal.to.start,
|
|
129
|
+
end: proposal.to.end,
|
|
130
|
+
allDay,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (scope === "all") {
|
|
135
|
+
// A resize moves one edge only: the start shifts by `delta`, the end by its own distance.
|
|
136
|
+
const endDelta = wallSeconds(wall(proposal.to.end, allDay, timeZone)) -
|
|
137
|
+
wallSeconds(wall(proposal.from.end, allDay, timeZone));
|
|
138
|
+
return {
|
|
139
|
+
series: {
|
|
140
|
+
...shape,
|
|
141
|
+
start: shiftValue(shape.start, allDay, delta, timeZone),
|
|
142
|
+
end: shiftValue(shape.end, allDay, endDelta, timeZone),
|
|
143
|
+
...(shape.exdates
|
|
144
|
+
? {
|
|
145
|
+
exdates: shape.exdates.map((value) => shiftValue(value, allDay, delta, timeZone)),
|
|
146
|
+
}
|
|
147
|
+
: {}),
|
|
148
|
+
...(shape.rdates
|
|
149
|
+
? {
|
|
150
|
+
rdates: shape.rdates.map((value) => shiftValue(value, allDay, delta, timeZone)),
|
|
151
|
+
}
|
|
152
|
+
: {}),
|
|
153
|
+
},
|
|
154
|
+
overrideIdMap: (options.overrideStarts ?? []).map((value) => ({
|
|
155
|
+
from: wall(value, allDay, timeZone),
|
|
156
|
+
to: shiftValue(value, allDay, delta, timeZone),
|
|
157
|
+
})),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const split = splitSeries(series, occurrenceStart, timeZone);
|
|
161
|
+
const rule = ruleOf(shape);
|
|
162
|
+
const nextRule = { ...rule };
|
|
163
|
+
if (rule.count !== undefined) {
|
|
164
|
+
nextRule.count = rule.count - split.index;
|
|
165
|
+
}
|
|
166
|
+
const exdates = shiftedList(shape.exdates, occurrenceStart, allDay, delta, timeZone);
|
|
167
|
+
const rdates = shiftedList(shape.rdates, occurrenceStart, allDay, delta, timeZone);
|
|
168
|
+
const newSeries = {
|
|
169
|
+
...omitSeriesFields(series),
|
|
170
|
+
start: proposal.to.start,
|
|
171
|
+
end: proposal.to.end,
|
|
172
|
+
allDay,
|
|
173
|
+
rrule: ruleValue(shape.rrule, nextRule),
|
|
174
|
+
...(exdates ? { exdates } : {}),
|
|
175
|
+
...(rdates ? { rdates } : {}),
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
series: split.series,
|
|
179
|
+
newSeries,
|
|
180
|
+
removed: split.series === undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Apply a delete to a series (plan 12 RR9): `"this"` adds an EXDATE,
|
|
185
|
+
* `"following"` ends the series, `"all"` removes it.
|
|
186
|
+
*/
|
|
187
|
+
export function applyRecurrenceDelete(series, occurrenceStart, scope, options = {}) {
|
|
188
|
+
const timeZone = options.timeZone ?? "UTC";
|
|
189
|
+
if (scope === "all") {
|
|
190
|
+
return { removed: true };
|
|
191
|
+
}
|
|
192
|
+
if (scope === "following") {
|
|
193
|
+
const split = splitSeries(series, occurrenceStart, timeZone);
|
|
194
|
+
return {
|
|
195
|
+
series: split.series,
|
|
196
|
+
removed: split.series === undefined,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const shape = series;
|
|
200
|
+
return {
|
|
201
|
+
series: {
|
|
202
|
+
...shape,
|
|
203
|
+
exdates: [...(shape.exdates ?? []), occurrenceStart],
|
|
204
|
+
},
|
|
205
|
+
removedOverrideRecurrenceId: occurrenceStart,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type DateRange, type PlainDateTime } from "../../foundation/index.js";
|
|
2
|
+
import type { RRule, RRuleError } from "./types.js";
|
|
3
|
+
export type RuleOccurrence = {
|
|
4
|
+
start: PlainDateTime;
|
|
5
|
+
end: PlainDateTime;
|
|
6
|
+
allDay: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ExpandRuleOptions = {
|
|
9
|
+
/** DTSTART wall time in the display zone. */
|
|
10
|
+
start: PlainDateTime;
|
|
11
|
+
allDay: boolean;
|
|
12
|
+
timeZone: string;
|
|
13
|
+
/** The series is zoned (wall time follows the zone, DST gaps use "compatible"). */
|
|
14
|
+
zoned: boolean;
|
|
15
|
+
/** Timed series: wall-time duration in seconds. */
|
|
16
|
+
durationSeconds: number;
|
|
17
|
+
/** All-day series: length in days (end is exclusive). */
|
|
18
|
+
durationDays: number;
|
|
19
|
+
range: DateRange;
|
|
20
|
+
onError?: (error: RRuleError) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Expand a parsed rule inside `range` (plan 12 RR4/RR5). DTSTART is always the
|
|
24
|
+
* first occurrence and counts toward COUNT. Occurrences keep DTSTART's wall
|
|
25
|
+
* time; zoned series resolve it through `toZoned(..., "compatible")`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function expandRule(rule: RRule, options: ExpandRuleOptions): RuleOccurrence[];
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { addDays, compare, dayOfWeek, daysInMonth, fromEpochDay, fromSecondOfDay, plainDate, plainDateTime, startOfWeek, toEpochDay, toInstant, toSecondOfDay, toZoned, } from "../../foundation/index.js";
|
|
2
|
+
import { rruleError } from "./types.js";
|
|
3
|
+
const SECONDS_PER_DAY = 86400;
|
|
4
|
+
const DEFAULT_WKST = 1;
|
|
5
|
+
/** Iterations (periods), not produced occurrences (plan 12 §13.5). */
|
|
6
|
+
const ITERATION_CAP = 10_000;
|
|
7
|
+
const wallSeconds = (value) => toEpochDay(value) * SECONDS_PER_DAY + toSecondOfDay(value);
|
|
8
|
+
const fromWallSeconds = (seconds) => {
|
|
9
|
+
const day = Math.floor(seconds / SECONDS_PER_DAY);
|
|
10
|
+
const rest = seconds - day * SECONDS_PER_DAY;
|
|
11
|
+
return plainDateTime(fromEpochDay(day), fromSecondOfDay(rest));
|
|
12
|
+
};
|
|
13
|
+
const datePart = (value) => plainDate(value.year, value.month, value.day);
|
|
14
|
+
const datePartOf = (value) => plainDate(value.year, value.month, value.day);
|
|
15
|
+
const timePart = (value) => plainDateTime(plainDate(1970, 1, 1), {
|
|
16
|
+
hour: value.hour,
|
|
17
|
+
minute: value.minute,
|
|
18
|
+
second: value.second,
|
|
19
|
+
});
|
|
20
|
+
/** `2TU` / `-1FR` inside a month. */
|
|
21
|
+
function nthWeekday(year, month, day, ordinal) {
|
|
22
|
+
const limit = daysInMonth(year, month);
|
|
23
|
+
if (ordinal > 0) {
|
|
24
|
+
const offset = (day - dayOfWeek(plainDate(year, month, 1)) + 7) % 7;
|
|
25
|
+
const result = 1 + offset + (ordinal - 1) * 7;
|
|
26
|
+
return result <= limit ? result : null;
|
|
27
|
+
}
|
|
28
|
+
const offset = (dayOfWeek(plainDate(year, month, limit)) - day + 7) % 7;
|
|
29
|
+
const result = limit - offset + (ordinal + 1) * 7;
|
|
30
|
+
return result >= 1 ? result : null;
|
|
31
|
+
}
|
|
32
|
+
function dayMatchesByDay(year, month, day, entry) {
|
|
33
|
+
if (dayOfWeek(plainDate(year, month, day)) !== entry.day) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (entry.ordinal === undefined) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (entry.ordinal > 0) {
|
|
40
|
+
const first = nthWeekday(year, month, entry.day, 1);
|
|
41
|
+
return (first !== null && Math.floor((day - first) / 7) + 1 === entry.ordinal);
|
|
42
|
+
}
|
|
43
|
+
const last = nthWeekday(year, month, entry.day, -1);
|
|
44
|
+
return last !== null && -Math.floor((last - day) / 7) - 1 === entry.ordinal;
|
|
45
|
+
}
|
|
46
|
+
/** Days of one month selected by BYMONTHDAY / BYDAY, or DTSTART's day. */
|
|
47
|
+
function daysInMonthFor(year, month, defaultDay, rule) {
|
|
48
|
+
const limit = daysInMonth(year, month);
|
|
49
|
+
const result = new Set();
|
|
50
|
+
const byDay = rule.byDay;
|
|
51
|
+
if (rule.byMonthDay !== undefined) {
|
|
52
|
+
for (const entry of rule.byMonthDay) {
|
|
53
|
+
const day = entry > 0 ? entry : limit + 1 + entry;
|
|
54
|
+
if (day >= 1 &&
|
|
55
|
+
day <= limit &&
|
|
56
|
+
(!byDay ||
|
|
57
|
+
byDay.some((item) => dayMatchesByDay(year, month, day, item)))) {
|
|
58
|
+
result.add(day);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [...result].sort((a, b) => a - b);
|
|
62
|
+
}
|
|
63
|
+
if (byDay !== undefined) {
|
|
64
|
+
for (const entry of byDay) {
|
|
65
|
+
if (entry.ordinal === undefined) {
|
|
66
|
+
for (let day = 1; day <= limit; day += 1) {
|
|
67
|
+
if (dayOfWeek(plainDate(year, month, day)) === entry.day) {
|
|
68
|
+
result.add(day);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const day = nthWeekday(year, month, entry.day, entry.ordinal);
|
|
74
|
+
if (day !== null) {
|
|
75
|
+
result.add(day);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return [...result].sort((a, b) => a - b);
|
|
80
|
+
}
|
|
81
|
+
if (defaultDay <= limit) {
|
|
82
|
+
result.add(defaultDay);
|
|
83
|
+
}
|
|
84
|
+
return [...result];
|
|
85
|
+
}
|
|
86
|
+
function matchesMonthFilters(date, rule) {
|
|
87
|
+
if (rule.byMonth !== undefined && !rule.byMonth.includes(date.month)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (rule.byMonthDay !== undefined) {
|
|
91
|
+
const limit = daysInMonth(date.year, date.month);
|
|
92
|
+
const days = rule.byMonthDay.map((entry) => entry > 0 ? entry : limit + 1 + entry);
|
|
93
|
+
if (!days.includes(date.day)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (rule.byDay !== undefined) {
|
|
98
|
+
const weekday = dayOfWeek(date);
|
|
99
|
+
if (!rule.byDay.some((entry) => entry.day === weekday)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
function periodOf(rule, startDate, index) {
|
|
106
|
+
const interval = rule.interval ?? 1;
|
|
107
|
+
if (rule.freq === "DAILY") {
|
|
108
|
+
const date = addDays(startDate, index * interval);
|
|
109
|
+
return {
|
|
110
|
+
anchor: date,
|
|
111
|
+
dates: matchesMonthFilters(date, rule) ? [date] : [],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (rule.freq === "WEEKLY") {
|
|
115
|
+
const wkst = rule.wkst ?? DEFAULT_WKST;
|
|
116
|
+
const weekStart = startOfWeek(startDate, wkst);
|
|
117
|
+
const anchor = addDays(weekStart, index * interval * 7);
|
|
118
|
+
const days = rule.byDay === undefined
|
|
119
|
+
? [dayOfWeek(startDate)]
|
|
120
|
+
: rule.byDay.map((entry) => entry.day);
|
|
121
|
+
const dates = [];
|
|
122
|
+
for (const day of days) {
|
|
123
|
+
const date = addDays(anchor, (day - wkst + 7) % 7);
|
|
124
|
+
if (compare(date, startDate) < 0) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (rule.byMonth !== undefined && !rule.byMonth.includes(date.month)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (rule.byMonthDay !== undefined) {
|
|
131
|
+
const limit = daysInMonth(date.year, date.month);
|
|
132
|
+
const wanted = rule.byMonthDay.map((entry) => entry > 0 ? entry : limit + 1 + entry);
|
|
133
|
+
if (!wanted.includes(date.day)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
dates.push(date);
|
|
138
|
+
}
|
|
139
|
+
dates.sort((a, b) => compare(a, b));
|
|
140
|
+
return { anchor, dates };
|
|
141
|
+
}
|
|
142
|
+
if (rule.freq === "MONTHLY") {
|
|
143
|
+
const index0 = startDate.year * 12 + (startDate.month - 1) + index * interval;
|
|
144
|
+
const year = Math.floor(index0 / 12);
|
|
145
|
+
const month = index0 - year * 12 + 1;
|
|
146
|
+
const anchor = plainDate(year, month, 1);
|
|
147
|
+
if (rule.byMonth !== undefined && !rule.byMonth.includes(month)) {
|
|
148
|
+
return { anchor, dates: [] };
|
|
149
|
+
}
|
|
150
|
+
const dates = daysInMonthFor(year, month, startDate.day, rule).map((day) => plainDate(year, month, day));
|
|
151
|
+
return { anchor, dates };
|
|
152
|
+
}
|
|
153
|
+
const year = startDate.year + index * interval;
|
|
154
|
+
const months = rule.byMonth ?? [startDate.month];
|
|
155
|
+
const dates = [];
|
|
156
|
+
for (const month of months) {
|
|
157
|
+
for (const day of daysInMonthFor(year, month, startDate.day, rule)) {
|
|
158
|
+
dates.push(plainDate(year, month, day));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
dates.sort((a, b) => compare(a, b));
|
|
162
|
+
return { anchor: plainDate(year, 1, 1), dates };
|
|
163
|
+
}
|
|
164
|
+
function pastUntil(candidate, rule, timeZone, zoned) {
|
|
165
|
+
const until = rule.until;
|
|
166
|
+
if (until === undefined) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (until.hour === undefined) {
|
|
170
|
+
return compare(datePart(candidate), until) > 0;
|
|
171
|
+
}
|
|
172
|
+
if (zoned && until.timeZone !== undefined) {
|
|
173
|
+
return (toInstant(toZoned(candidate, timeZone)) >
|
|
174
|
+
toInstant(until));
|
|
175
|
+
}
|
|
176
|
+
return compare(candidate, until) > 0;
|
|
177
|
+
}
|
|
178
|
+
function firstPeriodIndex(rule, startDate, target) {
|
|
179
|
+
const interval = rule.interval ?? 1;
|
|
180
|
+
if (rule.freq === "DAILY") {
|
|
181
|
+
return Math.floor((toEpochDay(target) - toEpochDay(startDate)) / interval);
|
|
182
|
+
}
|
|
183
|
+
if (rule.freq === "WEEKLY") {
|
|
184
|
+
const wkst = rule.wkst ?? DEFAULT_WKST;
|
|
185
|
+
const from = startOfWeek(startDate, wkst);
|
|
186
|
+
const to = startOfWeek(target, wkst);
|
|
187
|
+
return Math.floor((toEpochDay(to) - toEpochDay(from)) / (7 * interval));
|
|
188
|
+
}
|
|
189
|
+
if (rule.freq === "MONTHLY") {
|
|
190
|
+
const from = startDate.year * 12 + (startDate.month - 1);
|
|
191
|
+
const to = target.year * 12 + (target.month - 1);
|
|
192
|
+
return Math.floor((to - from) / interval);
|
|
193
|
+
}
|
|
194
|
+
return Math.floor((target.year - startDate.year) / interval);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Expand a parsed rule inside `range` (plan 12 RR4/RR5). DTSTART is always the
|
|
198
|
+
* first occurrence and counts toward COUNT. Occurrences keep DTSTART's wall
|
|
199
|
+
* time; zoned series resolve it through `toZoned(..., "compatible")`.
|
|
200
|
+
*/
|
|
201
|
+
export function expandRule(rule, options) {
|
|
202
|
+
const { start, allDay, timeZone, zoned, range } = options;
|
|
203
|
+
const startDate = datePart(start);
|
|
204
|
+
const rangeStart = plainDateTime(datePartOf(range.start), {
|
|
205
|
+
hour: 0,
|
|
206
|
+
minute: 0,
|
|
207
|
+
second: 0,
|
|
208
|
+
});
|
|
209
|
+
const rangeEnd = plainDateTime(datePartOf(range.end), {
|
|
210
|
+
hour: 23,
|
|
211
|
+
minute: 59,
|
|
212
|
+
second: 59,
|
|
213
|
+
});
|
|
214
|
+
const rangeEndDay = toEpochDay(range.end);
|
|
215
|
+
const lookbackDays = allDay
|
|
216
|
+
? options.durationDays
|
|
217
|
+
: Math.ceil(options.durationSeconds / SECONDS_PER_DAY);
|
|
218
|
+
// Periods before this cannot reach the range, even for a multi-day occurrence.
|
|
219
|
+
const windowStart = addDays(datePartOf(range.start), -(lookbackDays + 1));
|
|
220
|
+
const dates = new Map();
|
|
221
|
+
const seen = new Set();
|
|
222
|
+
let generated = 0;
|
|
223
|
+
const resolve = (candidate) => {
|
|
224
|
+
if (!zoned) {
|
|
225
|
+
return candidate;
|
|
226
|
+
}
|
|
227
|
+
const resolved = toZoned(candidate, timeZone, "compatible");
|
|
228
|
+
return plainDateTime(plainDate(resolved.year, resolved.month, resolved.day), { hour: resolved.hour, minute: resolved.minute, second: resolved.second });
|
|
229
|
+
};
|
|
230
|
+
const overlaps = (occurrence) => {
|
|
231
|
+
if (compare(occurrence.start, occurrence.end) === 0) {
|
|
232
|
+
return (compare(occurrence.start, rangeStart) >= 0 &&
|
|
233
|
+
compare(occurrence.start, rangeEnd) <= 0);
|
|
234
|
+
}
|
|
235
|
+
return (compare(occurrence.start, rangeEnd) <= 0 &&
|
|
236
|
+
compare(occurrence.end, rangeStart) > 0);
|
|
237
|
+
};
|
|
238
|
+
const add = (candidate, force = false) => {
|
|
239
|
+
const key = wallSeconds(candidate);
|
|
240
|
+
if (seen.has(key)) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
243
|
+
if (!force) {
|
|
244
|
+
if (rule.count !== undefined && generated >= rule.count) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
if (pastUntil(candidate, rule, timeZone, zoned)) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
seen.add(key);
|
|
252
|
+
generated += 1;
|
|
253
|
+
const occurrenceStart = resolve(candidate);
|
|
254
|
+
const occurrenceEnd = allDay
|
|
255
|
+
? plainDateTime(addDays(occurrenceStart, options.durationDays), {
|
|
256
|
+
hour: 0,
|
|
257
|
+
minute: 0,
|
|
258
|
+
second: 0,
|
|
259
|
+
})
|
|
260
|
+
: fromWallSeconds(wallSeconds(occurrenceStart) + options.durationSeconds);
|
|
261
|
+
const occurrence = {
|
|
262
|
+
start: occurrenceStart,
|
|
263
|
+
end: occurrenceEnd,
|
|
264
|
+
allDay,
|
|
265
|
+
};
|
|
266
|
+
if (overlaps(occurrence)) {
|
|
267
|
+
dates.set(key, occurrence);
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
270
|
+
};
|
|
271
|
+
add(start, true);
|
|
272
|
+
if (rule.count !== undefined && generated >= rule.count) {
|
|
273
|
+
return [...dates.values()];
|
|
274
|
+
}
|
|
275
|
+
const jumpTo = rule.count === undefined
|
|
276
|
+
? Math.max(0, firstPeriodIndex(rule, startDate, windowStart) - 1)
|
|
277
|
+
: 0;
|
|
278
|
+
for (let step = jumpTo; step <= ITERATION_CAP + jumpTo; step += 1) {
|
|
279
|
+
const iterations = step - jumpTo + 1;
|
|
280
|
+
if (iterations > ITERATION_CAP) {
|
|
281
|
+
options.onError?.(rruleError("iteration-cap", `The rule needed more than ${ITERATION_CAP} periods; expansion stopped.`, "FREQ"));
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
const period = periodOf(rule, startDate, step);
|
|
285
|
+
if (toEpochDay(period.anchor) > rangeEndDay + 1) {
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
for (const date of period.dates) {
|
|
289
|
+
const candidate = plainDateTime(date, timePart(start));
|
|
290
|
+
if (compare(candidate, start) < 0) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (!add(candidate)) {
|
|
294
|
+
return [...dates.values()];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (rule.count !== undefined && generated >= rule.count) {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return [...dates.values()].sort((a, b) => compare(a.start, b.start));
|
|
302
|
+
}
|