@zealakit/chrono-react 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +1 -0
  2. package/dist/calendar/components.d.ts +2 -2
  3. package/dist/calendar/components.js +10 -12
  4. package/dist/calendar/mini-calendar.js +6 -5
  5. package/dist/calendar/use-calendar.js +1 -3
  6. package/dist/calendar/use-mini-calendar.js +1 -1
  7. package/dist/date/bind-panel.js +1 -1
  8. package/dist/date/components.js +20 -29
  9. package/dist/date/utilities.d.ts +1 -1
  10. package/dist/date/utilities.js +1 -1
  11. package/dist/datetime/components.js +16 -21
  12. package/dist/datetime/use-datetime-panel.js +1 -1
  13. package/dist/shared/defined-options.d.ts +18 -0
  14. package/dist/shared/defined-options.js +9 -0
  15. package/dist/shared/merge-props.js +1 -3
  16. package/dist/shared/part.d.ts +1 -1
  17. package/dist/shared/slot.js +1 -4
  18. package/dist/shared/style-properties.js +1 -1
  19. package/dist/time/bind-panel.js +2 -2
  20. package/dist/time/components.d.ts +2 -2
  21. package/dist/time/components.js +16 -21
  22. package/dist/time/utilities.d.ts +1 -1
  23. package/dist/time/utilities.js +1 -1
  24. package/dist/vendor/core/calendar/availability.d.ts +2 -2
  25. package/dist/vendor/core/calendar/availability.js +4 -5
  26. package/dist/vendor/core/calendar/controllers/calendar-controller.js +93 -145
  27. package/dist/vendor/core/calendar/controllers/drag-engine.js +15 -34
  28. package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +3 -2
  29. package/dist/vendor/core/calendar/controllers/shared.d.ts +9 -5
  30. package/dist/vendor/core/calendar/controllers/shared.js +8 -8
  31. package/dist/vendor/core/calendar/events/agenda-layout.js +4 -3
  32. package/dist/vendor/core/calendar/events/all-day-row.d.ts +1 -1
  33. package/dist/vendor/core/calendar/events/all-day-row.js +5 -5
  34. package/dist/vendor/core/calendar/events/background-layout.d.ts +1 -1
  35. package/dist/vendor/core/calendar/events/background-layout.js +6 -7
  36. package/dist/vendor/core/calendar/events/month-layout.js +6 -5
  37. package/dist/vendor/core/calendar/events/normalize.d.ts +2 -2
  38. package/dist/vendor/core/calendar/events/normalize.js +6 -9
  39. package/dist/vendor/core/calendar/events/now-indicator.d.ts +2 -2
  40. package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +4 -4
  41. package/dist/vendor/core/calendar/events/time-grid-layout.js +8 -15
  42. package/dist/vendor/core/calendar/events/types.d.ts +2 -2
  43. package/dist/vendor/core/calendar/index.d.ts +11 -11
  44. package/dist/vendor/core/calendar/index.js +5 -5
  45. package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +1 -9
  46. package/dist/vendor/core/calendar/interaction/auto-scroll.js +12 -39
  47. package/dist/vendor/core/calendar/interaction/drag-geometry.js +2 -5
  48. package/dist/vendor/core/calendar/interaction/drag-keyboard.js +1 -4
  49. package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +5 -4
  50. package/dist/vendor/core/calendar/interaction/drag-pointer.js +33 -193
  51. package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
  52. package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
  53. package/dist/vendor/core/calendar/interaction/pointer.d.ts +1 -1
  54. package/dist/vendor/core/calendar/interaction/pointer.js +65 -15
  55. package/dist/vendor/core/calendar/interaction/selection.d.ts +1 -1
  56. package/dist/vendor/core/calendar/navigation/navigate.d.ts +3 -3
  57. package/dist/vendor/core/calendar/navigation/navigate.js +1 -3
  58. package/dist/vendor/core/calendar/navigation/range.js +1 -1
  59. package/dist/vendor/core/calendar/navigation/view-definition.d.ts +1 -1
  60. package/dist/vendor/core/calendar/navigation/view-definition.js +2 -1
  61. package/dist/vendor/core/calendar/recurrence/apply.js +7 -8
  62. package/dist/vendor/core/calendar/recurrence/expand.d.ts +1 -1
  63. package/dist/vendor/core/calendar/recurrence/expand.js +14 -18
  64. package/dist/vendor/core/calendar/recurrence/pack.js +4 -7
  65. package/dist/vendor/core/calendar/recurrence/rrule.js +6 -16
  66. package/dist/vendor/core/calendar/recurrence/series.js +1 -3
  67. package/dist/vendor/core/calendar/recurrence/types.d.ts +1 -1
  68. package/dist/vendor/core/calendar/resources/resource-time-grid.js +1 -2
  69. package/dist/vendor/core/calendar/resources/timeline-layout.js +4 -6
  70. package/dist/vendor/core/calendar/resources/types.d.ts +7 -7
  71. package/dist/vendor/core/calendar/views/day.d.ts +5 -5
  72. package/dist/vendor/core/calendar/views/day.js +2 -5
  73. package/dist/vendor/core/calendar/views/mini-calendar.d.ts +8 -8
  74. package/dist/vendor/core/calendar/views/mini-calendar.js +1 -1
  75. package/dist/vendor/core/calendar/views/month-layout.d.ts +1 -1
  76. package/dist/vendor/core/calendar/views/month-layout.js +1 -1
  77. package/dist/vendor/core/calendar/views/time-grid-layout.js +1 -4
  78. package/dist/vendor/core/date/input/date-input-controller.d.ts +15 -15
  79. package/dist/vendor/core/date/input/date-input-controller.js +9 -21
  80. package/dist/vendor/core/date/input/date-range-input-controller.js +2 -5
  81. package/dist/vendor/core/date/input/parse.d.ts +2 -2
  82. package/dist/vendor/core/date/input/parse.js +3 -9
  83. package/dist/vendor/core/date/input/validity.js +1 -1
  84. package/dist/vendor/core/date/panel/panel-controller.d.ts +11 -11
  85. package/dist/vendor/core/date/panel/panel-controller.js +18 -40
  86. package/dist/vendor/core/date/presets.js +1 -2
  87. package/dist/vendor/core/date/selection/multiple.js +2 -5
  88. package/dist/vendor/core/date/selection/range.d.ts +2 -2
  89. package/dist/vendor/core/date/selection/range.js +2 -6
  90. package/dist/vendor/core/datetime/compose.d.ts +3 -3
  91. package/dist/vendor/core/datetime/constraints.d.ts +9 -9
  92. package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +2 -2
  93. package/dist/vendor/core/datetime/input/datetime-input-controller.js +12 -27
  94. package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +5 -16
  95. package/dist/vendor/core/datetime/input/parse.d.ts +2 -2
  96. package/dist/vendor/core/datetime/input/parse.js +2 -5
  97. package/dist/vendor/core/datetime/panel/controller.js +4 -10
  98. package/dist/vendor/core/datetime/panel/range-controller.js +4 -16
  99. package/dist/vendor/core/datetime/zone/day-instants.js +1 -3
  100. package/dist/vendor/core/datetime/zone/resolve.js +2 -4
  101. package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
  102. package/dist/vendor/core/dom/auto-scroll.js +57 -0
  103. package/dist/vendor/core/dom/drag-session.d.ts +25 -0
  104. package/dist/vendor/core/dom/drag-session.js +257 -0
  105. package/dist/vendor/core/foundation/a11y/announcer.d.ts +9 -4
  106. package/dist/vendor/core/foundation/a11y/announcer.js +15 -27
  107. package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +2 -2
  108. package/dist/vendor/core/foundation/a11y/grid-navigation.js +2 -12
  109. package/dist/vendor/core/foundation/a11y/roving-focus.js +23 -2
  110. package/dist/vendor/core/foundation/constraints/availability-rules.js +2 -4
  111. package/dist/vendor/core/foundation/constraints/availability.d.ts +6 -6
  112. package/dist/vendor/core/foundation/constraints/availability.js +6 -16
  113. package/dist/vendor/core/foundation/constraints/date.d.ts +3 -3
  114. package/dist/vendor/core/foundation/constraints/index.d.ts +1 -1
  115. package/dist/vendor/core/foundation/constraints/range.d.ts +4 -4
  116. package/dist/vendor/core/foundation/constraints/range.js +1 -1
  117. package/dist/vendor/core/foundation/constraints/time.d.ts +5 -5
  118. package/dist/vendor/core/foundation/constraints/time.js +1 -1
  119. package/dist/vendor/core/foundation/grid/index.d.ts +2 -2
  120. package/dist/vendor/core/foundation/grid/month-grid.d.ts +2 -2
  121. package/dist/vendor/core/foundation/grid/time-axis.d.ts +3 -3
  122. package/dist/vendor/core/foundation/grid/time-axis.js +1 -1
  123. package/dist/vendor/core/foundation/input/index.d.ts +1 -1
  124. package/dist/vendor/core/foundation/input/index.js +1 -1
  125. package/dist/vendor/core/foundation/input/segment-engine.js +2 -6
  126. package/dist/vendor/core/foundation/locale/direction.js +1 -13
  127. package/dist/vendor/core/foundation/locale/format.js +1 -3
  128. package/dist/vendor/core/foundation/locale/hour-cycle.js +2 -6
  129. package/dist/vendor/core/foundation/locale/index.d.ts +1 -1
  130. package/dist/vendor/core/foundation/locale/index.js +1 -1
  131. package/dist/vendor/core/foundation/locale/resolve.js +12 -2
  132. package/dist/vendor/core/foundation/locale/week-info.js +1 -2
  133. package/dist/vendor/core/foundation/ranges/index.d.ts +1 -1
  134. package/dist/vendor/core/foundation/ranges/index.js +1 -1
  135. package/dist/vendor/core/foundation/ranges/interval.js +1 -3
  136. package/dist/vendor/core/foundation/store/controllable.d.ts +1 -1
  137. package/dist/vendor/core/foundation/store/ids.d.ts +8 -1
  138. package/dist/vendor/core/foundation/store/ids.js +10 -5
  139. package/dist/vendor/core/foundation/store/index.d.ts +2 -2
  140. package/dist/vendor/core/foundation/store/index.js +2 -2
  141. package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
  142. package/dist/vendor/core/foundation/store/with-optional.js +3 -0
  143. package/dist/vendor/core/foundation/values/convert.js +3 -7
  144. package/dist/vendor/core/foundation/values/epoch-day.js +1 -5
  145. package/dist/vendor/core/foundation/values/index.d.ts +1 -1
  146. package/dist/vendor/core/foundation/values/index.js +1 -1
  147. package/dist/vendor/core/foundation/values/iso.js +2 -4
  148. package/dist/vendor/core/foundation/values/plain-time.js +1 -3
  149. package/dist/vendor/core/foundation/values/zoned.js +2 -5
  150. package/dist/vendor/core/time/input/parse.d.ts +1 -1
  151. package/dist/vendor/core/time/input/parse.js +1 -3
  152. package/dist/vendor/core/time/input/time-input-controller.d.ts +18 -18
  153. package/dist/vendor/core/time/input/time-input-controller.js +12 -27
  154. package/dist/vendor/core/time/input/time-range-input-controller.js +3 -10
  155. package/dist/vendor/core/time/input/validity.js +1 -1
  156. package/dist/vendor/core/time/panel/time-panel-controller.d.ts +12 -12
  157. package/dist/vendor/core/time/panel/time-panel-controller.js +19 -49
  158. package/dist/vendor/core/time/selection/range.d.ts +3 -3
  159. package/dist/vendor/core/time/selection/slots.d.ts +9 -9
  160. package/dist/vendor/core/time/selection/slots.js +1 -3
  161. package/package.json +21 -28
  162. package/dist/vendor/core/foundation/store/global-state.d.ts +0 -1
  163. package/dist/vendor/core/foundation/store/global-state.js +0 -21
@@ -1,5 +1,5 @@
1
1
  import { compileAvailability, addDays, announce, createControllable, createTicker, dayOfWeek, defaultMessages, formatMessage, fromEpochDay, fromSecondOfDay, getTextDirection, getWeekInfo, isDateInRange, isSameDay, mergeMessages, nowZoned, parseCellKey, plainDateTime, plainDate, resolveLocale, toIsoString, toPlainDate, toPlainDateTime, toPlainTime, toSecondOfDay, today as readToday, } from "../../foundation/index.js";
2
- import { resolveCalendarAvailability, } from "../availability.js";
2
+ import { resolveCalendarAvailability } from "../availability.js";
3
3
  import { backgroundAttributes, layoutBackgrounds, layoutTimelineBackgrounds, } from "../events/background-layout.js";
4
4
  import { statesEqual } from "../internal/equal.js";
5
5
  import { canNavigate, firstVisibleDay, getDefinition, getHiddenDays, navigate, } from "../navigation/navigate.js";
@@ -8,19 +8,20 @@ import { getCalendarTitle } from "../navigation/title.js";
8
8
  import { resolveViews, } from "../navigation/view-definition.js";
9
9
  import { isOutside } from "../views/day.js";
10
10
  import { getListLayout } from "../views/list-layout.js";
11
- import { getMonthLayout, } from "../views/month-layout.js";
11
+ import { getMonthLayout } from "../views/month-layout.js";
12
12
  import { getTimeGridLayout, } from "../views/time-grid-layout.js";
13
13
  import { applyEventLimit, layoutAgenda, layoutAllDayRow, layoutMonthEvents, layoutTimeGridEvents, normalizeEvents, wallSecondsOf, } from "../events/index.js";
14
14
  import { getNowIndicator } from "../events/now-indicator.js";
15
15
  import { computeSelection, selectionPieces, } from "../interaction/selection.js";
16
16
  import { enterCell as enterInteractionCell, stepFocus, } from "../interaction/event-focus.js";
17
- import { createSelectionPointer, } from "../interaction/pointer.js";
18
- import { createDragPointer, } from "../interaction/drag-pointer.js";
17
+ import { createSelectionPointer } from "../interaction/pointer.js";
18
+ import { createDragPointer } from "../interaction/drag-pointer.js";
19
19
  import { warnOnce } from "../events/normalize.js";
20
20
  import { zoomTarget } from "../navigation/zoom.js";
21
21
  import { resourceCellKey } from "../resources/keys.js";
22
- import { createDragEngine, } from "./drag-engine.js";
22
+ import { createDragEngine } from "./drag-engine.js";
23
23
  import { cellAttributes, columnHeaderAttributes, dayAttributes, isNavKey, keyOf, moveInMonthGrid, navAttributes, nextId, toHighlighter, weekNumberAttributes, } from "./shared.js";
24
+ import { withOptional } from "../../foundation/store/with-optional.js";
24
25
  const day1 = (month) => ({
25
26
  calendar: "gregory",
26
27
  year: month.year,
@@ -50,12 +51,8 @@ export function createCalendarController(initial = {}) {
50
51
  views: resolveViews(options.views, weekInfo.weekend),
51
52
  weekStartsOn,
52
53
  hiddenDays: options.hiddenDays ?? [],
53
- min: options.min === undefined
54
- ? undefined
55
- : toPlainDate(options.min, timeZone),
56
- max: options.max === undefined
57
- ? undefined
58
- : toPlainDate(options.max, timeZone),
54
+ min: options.min === undefined ? undefined : toPlainDate(options.min, timeZone),
55
+ max: options.max === undefined ? undefined : toPlainDate(options.max, timeZone),
59
56
  today,
60
57
  },
61
58
  };
@@ -67,9 +64,7 @@ export function createCalendarController(initial = {}) {
67
64
  onChange: (view) => options.onViewChange?.(view),
68
65
  });
69
66
  const dateControl = createControllable({
70
- value: options.date === undefined
71
- ? undefined
72
- : toPlainDate(options.date, config.timeZone),
67
+ value: options.date === undefined ? undefined : toPlainDate(options.date, config.timeZone),
73
68
  defaultValue: options.defaultDate === undefined
74
69
  ? config.today
75
70
  : toPlainDate(options.defaultDate, config.timeZone),
@@ -77,9 +72,7 @@ export function createCalendarController(initial = {}) {
77
72
  equals: isSameDay,
78
73
  });
79
74
  const selectedEventControl = createControllable({
80
- value: options.selectedEventId === undefined
81
- ? undefined
82
- : options.selectedEventId,
75
+ value: options.selectedEventId === undefined ? undefined : options.selectedEventId,
83
76
  defaultValue: options.defaultSelectedEventId ?? null,
84
77
  onChange: (selected) => options.onSelectedEventChange?.(selected, eventById(selected)),
85
78
  });
@@ -140,9 +133,7 @@ export function createCalendarController(initial = {}) {
140
133
  engine.pendingSignature(),
141
134
  options.recurrence === undefined ? "" : "recurrence",
142
135
  ].join("|");
143
- if (eventsCache &&
144
- eventsCache.source === source &&
145
- eventsCache.key === key) {
136
+ if (eventsCache && eventsCache.source === source && eventsCache.key === key) {
146
137
  return eventsCache.result;
147
138
  }
148
139
  const normalized = normalizeFor(source, visibleRange).map((event) => engine.override(event));
@@ -275,22 +266,10 @@ export function createCalendarController(initial = {}) {
275
266
  };
276
267
  return result;
277
268
  };
278
- const compute = (fix = false) => {
279
- const nav = navState();
280
- const definition = getDefinition(nav, config.nav);
281
- const range = getRange(definition, nav.anchor, config.nav);
269
+ /** Everything a view shows apart from events, selection and the drag preview. */
270
+ const buildView = (nav, definition, range) => {
282
271
  const visibleRange = getVisibleRange(definition, range, config.nav);
283
272
  const hidden = getHiddenDays(definition, config.nav);
284
- const scope = definition.layout === "month" ? visibleRange : range;
285
- if (fix &&
286
- (!isDateInRange(focusedDate, scope) ||
287
- hidden.includes(dayOfWeek(focusedDate)))) {
288
- focusedDate =
289
- isDateInRange(nav.anchor, range) &&
290
- !hidden.includes(dayOfWeek(nav.anchor))
291
- ? nav.anchor
292
- : firstVisibleDay(range, hidden);
293
- }
294
273
  const selectedDate = options.selectedDate === undefined
295
274
  ? undefined
296
275
  : toPlainDate(options.selectedDate, config.timeZone);
@@ -316,31 +295,66 @@ export function createCalendarController(initial = {}) {
316
295
  : definition.layout === "list"
317
296
  ? getListLayout(ctx)
318
297
  : getTimeGridLayout(ctx, options.timeGrid);
298
+ return {
299
+ nav,
300
+ definition,
301
+ range,
302
+ visibleRange,
303
+ hidden,
304
+ layout,
305
+ title: getCalendarTitle(range, definition, config.locale),
306
+ direction: getTextDirection(config.locale),
307
+ cellKey: focusCellKey(layout, focusedDate),
308
+ };
309
+ };
310
+ // A drag rebuilds the state on every frame, but the view only changes with these inputs, so it
311
+ // is built once and keeps its identity. Outside a drag it is always rebuilt, so app functions
312
+ // such as `highlightedDates` are read again.
313
+ let dragInputs = [];
314
+ let dragView;
315
+ const compute = (fix = false) => {
316
+ const nav = navState();
317
+ const inputs = [options, config, nav.view, custom, nav.anchor, focusedDate];
318
+ const reused = engine.drag && inputs.every((input, index) => input === dragInputs[index])
319
+ ? dragView
320
+ : undefined;
321
+ const definition = reused?.definition ?? getDefinition(nav, config.nav);
322
+ const range = reused?.range ?? getRange(definition, nav.anchor, config.nav);
323
+ const visibleRange = reused?.visibleRange ?? getVisibleRange(definition, range, config.nav);
324
+ const hidden = reused?.hidden ?? getHiddenDays(definition, config.nav);
325
+ const scope = definition.layout === "month" ? visibleRange : range;
326
+ if (fix && (!isDateInRange(focusedDate, scope) || hidden.includes(dayOfWeek(focusedDate)))) {
327
+ focusedDate =
328
+ isDateInRange(nav.anchor, range) && !hidden.includes(dayOfWeek(nav.anchor))
329
+ ? nav.anchor
330
+ : firstVisibleDay(range, hidden);
331
+ }
332
+ const view = reused ?? buildView(nav, definition, range);
333
+ dragInputs = inputs;
334
+ dragView = engine.drag ? view : undefined;
335
+ const { layout } = view;
319
336
  const now = nowDateTime();
320
337
  const events = eventsFor(layout, visibleRange, now);
321
338
  const resources = definition.layoutBuilder && layout.kind === "time-grid"
322
339
  ? resourcesFor(definition, range, visibleRange, layout, now)
323
340
  : null;
324
- const currentFocus = focus ?? {
325
- mode: "navigation",
326
- cellKey: focusCellKey(layout, focusedDate),
327
- };
328
- return {
341
+ const currentFocus = focus ?? { mode: "navigation", cellKey: view.cellKey };
342
+ return withOptional({
329
343
  id,
330
344
  view: nav.view,
331
345
  definition,
332
346
  date: nav.anchor,
333
347
  focusedDate,
334
348
  today: config.today,
335
- range,
336
- visibleRange,
337
- title: getCalendarTitle(range, definition, config.locale),
349
+ range: view.range,
350
+ visibleRange: view.visibleRange,
351
+ title: view.title,
338
352
  layout,
339
353
  canGoPrev: canNavigate(nav, -1, config.nav),
340
354
  canGoNext: canNavigate(nav, 1, config.nav),
341
- direction: getTextDirection(config.locale),
355
+ direction: view.direction,
342
356
  locale: config.locale,
343
- hiddenDays: hidden,
357
+ hiddenDays: view.hidden,
344
358
  messages: config.messages,
345
359
  events: events.events,
346
360
  more: events.more,
@@ -353,7 +367,7 @@ export function createCalendarController(initial = {}) {
353
367
  pending: engine.pending,
354
368
  resources,
355
369
  backgrounds: backgroundsFor(layout, resources, visibleRange),
356
- };
370
+ });
357
371
  };
358
372
  const emitRange = () => {
359
373
  if (!started) {
@@ -410,9 +424,7 @@ export function createCalendarController(initial = {}) {
410
424
  return false;
411
425
  }
412
426
  const availability = resolveAvailability();
413
- return availability
414
- ? !availability.isRangeAvailable(proposal.start, proposal.end)
415
- : false;
427
+ return availability ? !availability.isRangeAvailable(proposal.start, proposal.end) : false;
416
428
  };
417
429
  // Moving and resizing events (plan 09). The engine owns the drag and pending changes.
418
430
  let normalizedCache;
@@ -432,16 +444,14 @@ export function createCalendarController(initial = {}) {
432
444
  };
433
445
  const dragOptions = () => {
434
446
  const base = options;
435
- if (base.availabilityBlocksInteraction === false ||
436
- base.availability === undefined) {
447
+ if (base.availabilityBlocksInteraction === false || base.availability === undefined) {
437
448
  return base;
438
449
  }
439
450
  return {
440
451
  ...base,
441
452
  validateEventChange: (proposal) => {
442
453
  const availability = resolveAvailability(proposal.event.id);
443
- if (availability &&
444
- !availability.isRangeAvailable(proposal.to.start, proposal.to.end)) {
454
+ if (availability && !availability.isRangeAvailable(proposal.to.start, proposal.to.end)) {
445
455
  return false;
446
456
  }
447
457
  return base.validateEventChange?.(proposal) ?? true;
@@ -456,10 +466,7 @@ export function createCalendarController(initial = {}) {
456
466
  messages: () => config.messages,
457
467
  rtl: () => getTextDirection(config.locale) === "rtl",
458
468
  normalized: normalizedNow,
459
- segmentEvent: (segmentKey) => [
460
- ...state.events,
461
- ...state.allDayRow,
462
- ].find((segment) => segment.key === segmentKey)?.event,
469
+ segmentEvent: (segmentKey) => [...state.events, ...state.allDayRow].find((segment) => segment.key === segmentKey)?.event,
463
470
  segmentNormalized: (segmentKey) => {
464
471
  let best;
465
472
  for (const item of normalizedNow()) {
@@ -478,9 +485,7 @@ export function createCalendarController(initial = {}) {
478
485
  });
479
486
  const SECONDS_PER_DAY = 86400;
480
487
  // Availability on cells and slots (plan 11 V7, V12): attributes plus a label suffix.
481
- const reasonOf = (rules) => options.getAvailabilityLabel
482
- ? options.getAvailabilityLabel(rules)
483
- : (rules[0]?.reason ?? "");
488
+ const reasonOf = (rules) => options.getAvailabilityLabel ? options.getAvailabilityLabel(rules) : (rules[0]?.reason ?? "");
484
489
  const dayAvailability = (date) => {
485
490
  const availability = resolveAvailability();
486
491
  if (!availability) {
@@ -496,9 +501,7 @@ export function createCalendarController(initial = {}) {
496
501
  const reason = piece ? reasonOf(piece.rules) : "";
497
502
  return {
498
503
  status,
499
- label: reason
500
- ? `${state.messages.unavailable}: ${reason}`
501
- : state.messages.unavailable,
504
+ label: reason ? `${state.messages.unavailable}: ${reason}` : state.messages.unavailable,
502
505
  };
503
506
  };
504
507
  const slotUnavailable = (slot, day) => {
@@ -570,9 +573,7 @@ export function createCalendarController(initial = {}) {
570
573
  ? `${base}|${resources.kind}|${resources.kind === "timeline"
571
574
  ? resources.rows.map((row) => row.key).join(",")
572
575
  : resources.columns.map((column) => column.key).join(",")}`
573
- : `${base}|${layout.kind}|${layout.kind === "time-grid"
574
- ? layout.days.map((day) => day.key).join(",")
575
- : ""}`;
576
+ : `${base}|${layout.kind}|${layout.kind === "time-grid" ? layout.days.map((day) => day.key).join(",") : ""}`;
576
577
  if (backgroundsCache?.key === signature) {
577
578
  return backgroundsCache.value;
578
579
  }
@@ -583,9 +584,7 @@ export function createCalendarController(initial = {}) {
583
584
  value = resources.rows.flatMap((row) => layoutTimelineBackgrounds({
584
585
  availability: availabilityOf(row.resource),
585
586
  timeZone: config.timeZone,
586
- rows: [
587
- { key: row.key, resourceId: String(row.id), resourceKey: row.key },
588
- ],
587
+ rows: [{ key: row.key, resourceId: String(row.id), resourceKey: row.key }],
589
588
  start: axis.start,
590
589
  end,
591
590
  mode,
@@ -594,8 +593,7 @@ export function createCalendarController(initial = {}) {
594
593
  else if (resources?.kind === "resource-time-grid") {
595
594
  const slots = layout.kind === "time-grid" ? layout.slots : [];
596
595
  const dayEnd = slots[slots.length - 1]
597
- ? fromSecondOfDay(slots[slots.length - 1].endSecond %
598
- SECONDS_PER_DAY)
596
+ ? fromSecondOfDay(slots[slots.length - 1].endSecond % SECONDS_PER_DAY)
599
597
  : undefined;
600
598
  value = resources.columns.flatMap((column) => layoutBackgrounds({
601
599
  availability: availabilityOf(column.resource),
@@ -621,8 +619,7 @@ export function createCalendarController(initial = {}) {
621
619
  days: layout.days.map((day) => ({ date: day.date, key: day.key })),
622
620
  dayStart: slots[0]?.start,
623
621
  dayEnd: slots[slots.length - 1]
624
- ? fromSecondOfDay(slots[slots.length - 1].endSecond %
625
- SECONDS_PER_DAY)
622
+ ? fromSecondOfDay(slots[slots.length - 1].endSecond % SECONDS_PER_DAY)
626
623
  : undefined,
627
624
  mode,
628
625
  });
@@ -651,7 +648,7 @@ export function createCalendarController(initial = {}) {
651
648
  focusedDate = target;
652
649
  refresh();
653
650
  };
654
- const visibleDays = () => state.layout.kind === "month" ? [] : state.layout.days;
651
+ const visibleDays = () => (state.layout.kind === "month" ? [] : state.layout.days);
655
652
  const cellItems = (cellKey) => {
656
653
  const segments = segmentList();
657
654
  const keys = segments
@@ -713,12 +710,8 @@ export function createCalendarController(initial = {}) {
713
710
  }
714
711
  // 2. Interaction mode (focus on events inside a cell).
715
712
  if (state.focus.mode === "interaction") {
716
- const edit = state.focus.itemKey
717
- ? engine.shortcut(key, { ...modifiers, alt: false })
718
- : null;
719
- if (edit &&
720
- state.focus.itemKey &&
721
- engine.canEditSegment(state.focus.itemKey, edit)) {
713
+ const edit = state.focus.itemKey ? engine.shortcut(key, { ...modifiers, alt: false }) : null;
714
+ if (edit && state.focus.itemKey && engine.canEditSegment(state.focus.itemKey, edit)) {
722
715
  return engine.start(edit, state.focus.itemKey, "keyboard");
723
716
  }
724
717
  if (key === " ") {
@@ -803,20 +796,8 @@ export function createCalendarController(initial = {}) {
803
796
  return true;
804
797
  }
805
798
  const list = state.definition.layout === "list";
806
- const forward = key === "ArrowRight"
807
- ? !rtl
808
- : key === "ArrowLeft"
809
- ? rtl
810
- : key === "ArrowDown"
811
- ? list
812
- : false;
813
- const backward = key === "ArrowLeft"
814
- ? !rtl
815
- : key === "ArrowRight"
816
- ? rtl
817
- : key === "ArrowUp"
818
- ? list
819
- : false;
799
+ const forward = key === "ArrowRight" ? !rtl : key === "ArrowLeft" ? rtl : key === "ArrowDown" ? list : false;
800
+ const backward = key === "ArrowLeft" ? !rtl : key === "ArrowRight" ? rtl : key === "ArrowUp" ? list : false;
820
801
  if (!forward && !backward) {
821
802
  return true;
822
803
  }
@@ -862,9 +843,7 @@ export function createCalendarController(initial = {}) {
862
843
  start: range.allDay
863
844
  ? plainDate(range.start.year, range.start.month, range.start.day)
864
845
  : range.start,
865
- end: range.allDay
866
- ? plainDate(range.end.year, range.end.month, range.end.day)
867
- : range.end,
846
+ end: range.allDay ? plainDate(range.end.year, range.end.month, range.end.day) : range.end,
868
847
  allDay: range.allDay,
869
848
  source: selectionSource,
870
849
  });
@@ -897,10 +876,8 @@ export function createCalendarController(initial = {}) {
897
876
  selectionSource = source;
898
877
  const allDay = state.definition.layout === "month";
899
878
  // The anchor is the cell the selection starts on (plan 05 E14).
900
- selectionAnchor = allDay
901
- ? { date: target.date }
902
- : { date: target.date, time: target.time };
903
- selection = computeSelection(selectionAnchor, target, {
879
+ selectionAnchor = withOptional(allDay ? { date: target.date } : { date: target.date, time: target.time });
880
+ selection = computeSelection(withOptional(selectionAnchor), target, {
904
881
  allDay,
905
882
  slotDurationMinutes: options.timeGrid?.step ?? 30,
906
883
  maxDurationMinutes: options.maxSelectionDuration,
@@ -976,9 +953,7 @@ export function createCalendarController(initial = {}) {
976
953
  config = readConfig();
977
954
  viewControl.sync({ value: options.view });
978
955
  dateControl.sync({
979
- value: options.date === undefined
980
- ? undefined
981
- : toPlainDate(options.date, config.timeZone),
956
+ value: options.date === undefined ? undefined : toPlainDate(options.date, config.timeZone),
982
957
  });
983
958
  selectedEventControl.sync({ value: options.selectedEventId });
984
959
  collapsedControl.sync({ value: options.collapsedResourceIds });
@@ -1030,16 +1005,11 @@ export function createCalendarController(initial = {}) {
1030
1005
  "data-level": group.level,
1031
1006
  }),
1032
1007
  getTimelineAttributes: () => ({
1033
- role: state.resources?.kind === "timeline" && state.resources.grouped
1034
- ? "treegrid"
1035
- : "grid",
1008
+ role: state.resources?.kind === "timeline" && state.resources.grouped ? "treegrid" : "grid",
1036
1009
  "aria-rowcount": state.resources?.kind === "timeline"
1037
- ? state.resources.window.totalRows +
1038
- state.resources.axis.headerRows.length
1039
- : undefined,
1040
- "aria-colcount": state.resources?.kind === "timeline"
1041
- ? state.resources.window.totalColumns
1010
+ ? state.resources.window.totalRows + state.resources.axis.headerRows.length
1042
1011
  : undefined,
1012
+ "aria-colcount": state.resources?.kind === "timeline" ? state.resources.window.totalColumns : undefined,
1043
1013
  }),
1044
1014
  getTimelineHeaderCellAttributes: (cell) => ({
1045
1015
  role: "columnheader",
@@ -1048,9 +1018,7 @@ export function createCalendarController(initial = {}) {
1048
1018
  "data-header-level": cell.unit,
1049
1019
  }),
1050
1020
  getTimelineRowAttributes: (row) => {
1051
- const headerRows = state.resources?.kind === "timeline"
1052
- ? state.resources.axis.headerRows.length
1053
- : 0;
1021
+ const headerRows = state.resources?.kind === "timeline" ? state.resources.axis.headerRows.length : 0;
1054
1022
  return {
1055
1023
  role: "row",
1056
1024
  "aria-level": row.level + 1,
@@ -1165,9 +1133,7 @@ export function createCalendarController(initial = {}) {
1165
1133
  drop: () => engine.drop(),
1166
1134
  cancel: () => engine.cancel(),
1167
1135
  hitTest: options.hitTest,
1168
- scroll: () => options.autoScroll === false
1169
- ? false
1170
- : (options.scrollContainer ?? null),
1136
+ scroll: () => (options.autoScroll === false ? false : (options.scrollContainer ?? null)),
1171
1137
  });
1172
1138
  }
1173
1139
  if (options.selectable && root && !pointer) {
@@ -1202,11 +1168,7 @@ export function createCalendarController(initial = {}) {
1202
1168
  ? state.messages.previous
1203
1169
  : kind === "next"
1204
1170
  ? state.messages.next
1205
- : state.messages.goToToday, kind === "prev"
1206
- ? !state.canGoPrev
1207
- : kind === "next"
1208
- ? !state.canGoNext
1209
- : false),
1171
+ : state.messages.goToToday, kind === "prev" ? !state.canGoPrev : kind === "next" ? !state.canGoNext : false),
1210
1172
  getViewButtonAttributes: (view) => ({
1211
1173
  type: "button",
1212
1174
  "aria-pressed": state.view === view ? "true" : "false",
@@ -1252,12 +1214,8 @@ export function createCalendarController(initial = {}) {
1252
1214
  getTimeGridAttributes: () => ({
1253
1215
  role: "grid",
1254
1216
  "aria-labelledby": titleId,
1255
- "aria-rowcount": state.layout.kind === "time-grid"
1256
- ? state.layout.slots.length
1257
- : undefined,
1258
- "aria-colcount": state.layout.kind === "time-grid"
1259
- ? state.layout.days.length
1260
- : undefined,
1217
+ "aria-rowcount": state.layout.kind === "time-grid" ? state.layout.slots.length : undefined,
1218
+ "aria-colcount": state.layout.kind === "time-grid" ? state.layout.days.length : undefined,
1261
1219
  }),
1262
1220
  getSlotAttributes: (slot, day) => {
1263
1221
  const slotKey = `${day.key}T${toIsoString(slot.start)}`;
@@ -1269,8 +1227,7 @@ export function createCalendarController(initial = {}) {
1269
1227
  "data-slot-start": toIsoString(slot.start),
1270
1228
  "data-unavailable": slotUnavailable(slot, day),
1271
1229
  "data-working-hours": slot.working &&
1272
- (state.layout.kind !== "time-grid" ||
1273
- state.layout.workingDays.includes(day.dayOfWeek)),
1230
+ (state.layout.kind !== "time-grid" || state.layout.workingDays.includes(day.dayOfWeek)),
1274
1231
  "data-selecting": state.selection !== null && state.layout.kind === "time-grid",
1275
1232
  "data-has-events": slotHasEvents(slot, day),
1276
1233
  };
@@ -1376,17 +1333,13 @@ export function createCalendarController(initial = {}) {
1376
1333
  if (selectionCovered(proposal)) {
1377
1334
  return true;
1378
1335
  }
1379
- return options.validateSelection
1380
- ? !options.validateSelection(proposal)
1381
- : false;
1336
+ return options.validateSelection ? !options.validateSelection(proposal) : false;
1382
1337
  };
1383
1338
  const axisStart = () => state.layout.kind === "time-grid" && state.layout.slots[0]
1384
1339
  ? toSecondOfDay(state.layout.slots[0].start)
1385
1340
  : 0;
1386
- const axisEnd = () => state.layout.kind === "time-grid" &&
1387
- state.layout.slots[state.layout.slots.length - 1]
1388
- ? state.layout.slots[state.layout.slots.length - 1]
1389
- .endSecond
1341
+ const axisEnd = () => state.layout.kind === "time-grid" && state.layout.slots[state.layout.slots.length - 1]
1342
+ ? state.layout.slots[state.layout.slots.length - 1].endSecond
1390
1343
  : 86400;
1391
1344
  const topOf = (value) => (toSecondOfDay(value) - axisStart()) / (axisEnd() - axisStart());
1392
1345
  const heightOf = (start, end) => (toSecondOfDay(end) - toSecondOfDay(start)) / (axisEnd() - axisStart());
@@ -1394,22 +1347,17 @@ export function createCalendarController(initial = {}) {
1394
1347
  const base = {
1395
1348
  role: "button",
1396
1349
  "aria-pressed": selectedEventControl.get() === segment.event.id ? "true" : "false",
1397
- tabindex: state.focus.mode === "interaction" &&
1398
- state.focus.itemKey === segment.key
1399
- ? 0
1400
- : -1,
1350
+ tabindex: state.focus.mode === "interaction" && state.focus.itemKey === segment.key ? 0 : -1,
1401
1351
  "data-chrono-event": true,
1402
1352
  "data-chrono-event-key": segment.key,
1403
1353
  "data-calendar-id": segment.event.calendarId,
1404
1354
  "data-selected": selectedEventControl.get() === segment.event.id,
1405
- "data-focused": state.focus.mode === "interaction" &&
1406
- state.focus.itemKey === segment.key,
1355
+ "data-focused": state.focus.mode === "interaction" && state.focus.itemKey === segment.key,
1407
1356
  "data-all-day": segment.allDay,
1408
1357
  "data-continues-before": segment.continuesBefore,
1409
1358
  "data-continues-after": segment.continuesAfter,
1410
1359
  "data-past": segment.past,
1411
- "data-recurring": segment.recurrence !== undefined ||
1412
- segment.event.recurringId !== undefined,
1360
+ "data-recurring": segment.recurrence !== undefined || segment.event.recurringId !== undefined,
1413
1361
  "data-override": segment.recurrence?.isOverride === true,
1414
1362
  };
1415
1363
  Object.assign(base, engine.attributes(segment.key));
@@ -2,6 +2,7 @@ import { announce, formatDateTime, formatMessage, fromInstant, parseCellKey, pla
2
2
  import { grabOf, moveEvent, nudgeEvent, resizeEvent, toSeconds, } from "../interaction/drag-geometry.js";
3
3
  import { DEFAULT_SHORTCUTS, editStep, matchShortcut, } from "../interaction/drag-keyboard.js";
4
4
  import { unresolved } from "../interaction/pending.js";
5
+ import { withOptional } from "../../foundation/store/with-optional.js";
5
6
  const isZonedInput = (value) => (typeof value === "object" && value !== null && "timeZone" in value) ||
6
7
  (typeof value === "string" && /\[|Z$|[+-]\d{2}:?\d{2}$/.test(value));
7
8
  /** Pointer and keyboard editing of events, and the accepted changes still pending (plan 09). */
@@ -14,9 +15,7 @@ export function createDragEngine(ctx) {
14
15
  const timers = new Map();
15
16
  const shortcuts = () => {
16
17
  const configured = ctx.options().keyboardShortcuts;
17
- return configured === false
18
- ? false
19
- : { ...DEFAULT_SHORTCUTS, ...configured };
18
+ return configured === false ? false : { ...DEFAULT_SHORTCUTS, ...configured };
20
19
  };
21
20
  const geometry = () => {
22
21
  const options = ctx.options();
@@ -39,9 +38,7 @@ export function createDragEngine(ctx) {
39
38
  return false;
40
39
  if (kind === "move" ? event.movable === false : event.resizable === false)
41
40
  return false;
42
- return options.isEventEditable
43
- ? options.isEventEditable(event, kind)
44
- : true;
41
+ return options.isEventEditable ? options.isEventEditable(event, kind) : true;
45
42
  };
46
43
  const editValueOf = (norm) => ({
47
44
  start: norm.start,
@@ -63,7 +60,7 @@ export function createDragEngine(ctx) {
63
60
  }
64
61
  return { start: value.start, end: value.end, allDay: false };
65
62
  };
66
- const proposalOf = (state, norm) => ({
63
+ const proposalOf = (state, norm) => withOptional({
67
64
  kind: state.kind,
68
65
  event: norm.event,
69
66
  from: toChange(norm, state.from),
@@ -97,20 +94,14 @@ export function createDragEngine(ctx) {
97
94
  : `${formatDateTime(value.start, locale, format)} – ${formatDateTime(value.end, locale, { hour: "numeric", minute: "2-digit" })}`;
98
95
  };
99
96
  const say = (template, value, norm) => {
100
- const label = norm
101
- ? (ctx.options().getEventLabel?.(norm.event) ?? String(norm.id))
102
- : "";
97
+ const label = norm ? (ctx.options().getEventLabel?.(norm.event) ?? String(norm.id)) : "";
103
98
  announce(formatMessage(ctx.messages()[template], {
104
99
  event: label,
105
100
  range: rangeText(value),
106
101
  }), ctx.options().announcer);
107
102
  };
108
103
  const build = (kind, segmentKey, norm, from, candidate, source) => {
109
- const to = candidate
110
- ? kind === "move"
111
- ? keepRealDuration(norm, candidate)
112
- : candidate
113
- : from;
104
+ const to = candidate ? (kind === "move" ? keepRealDuration(norm, candidate) : candidate) : from;
114
105
  const partial = { kind, from, to, source };
115
106
  const valid = candidate !== null &&
116
107
  (ctx.options().validateEventChange?.(proposalOf(partial, norm)) ?? true);
@@ -132,7 +123,7 @@ export function createDragEngine(ctx) {
132
123
  };
133
124
  const targetOf = (hit) => {
134
125
  const { date, time } = parseCellKey(hit.cellKey);
135
- return { date, time, allDayRow: hit.allDay };
126
+ return withOptional({ date, time, allDayRow: hit.allDay });
136
127
  };
137
128
  const removePending = (eventKey, expected) => {
138
129
  const timer = timers.get(eventKey);
@@ -203,9 +194,7 @@ export function createDragEngine(ctx) {
203
194
  if (!norm || !canEdit(norm, kind) || drag)
204
195
  return false;
205
196
  const from = editValueOf(norm);
206
- grab = hit
207
- ? grabOf(from, targetOf(hit))
208
- : { dayOffset: 0, minuteOffset: 0 };
197
+ grab = hit ? grabOf(from, targetOf(hit)) : { dayOffset: 0, minuteOffset: 0 };
209
198
  drag = build(kind, segmentKey, norm, from, from, source);
210
199
  say(kind === "move" ? "moving" : "resizing", from, norm);
211
200
  ctx.refresh();
@@ -233,11 +222,7 @@ export function createDragEngine(ctx) {
233
222
  const now = Date.now();
234
223
  if (now - lastAnnounce >= 500) {
235
224
  lastAnnounce = now;
236
- say(drag.valid
237
- ? drag.kind === "move"
238
- ? "moving"
239
- : "resizing"
240
- : "notAllowedHere", drag.to, norm);
225
+ say(drag.valid ? (drag.kind === "move" ? "moving" : "resizing") : "notAllowedHere", drag.to, norm);
241
226
  }
242
227
  ctx.refresh();
243
228
  },
@@ -299,11 +284,7 @@ export function createDragEngine(ctx) {
299
284
  }
300
285
  const moved = nudgeEvent(current.to, current.kind, step, geometry());
301
286
  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);
287
+ say(drag.valid ? (drag.kind === "move" ? "moving" : "resizing") : "notAllowedHere", drag.to, norm);
307
288
  ctx.refresh();
308
289
  return true;
309
290
  },
@@ -356,18 +337,18 @@ export function createDragEngine(ctx) {
356
337
  "aria-keyshortcuts": editable && keys
357
338
  ? `${keys.move.toUpperCase()} ${keys.resizeEnd.toUpperCase()} Shift+${keys.resizeEnd.toUpperCase()}`
358
339
  : undefined,
359
- "aria-description": editable
360
- ? ctx.messages().editInstructions
361
- : undefined,
340
+ "aria-description": editable ? ctx.messages().editInstructions : undefined,
362
341
  };
363
342
  },
364
343
  resizeHandle(segmentKey, edge) {
365
344
  const norm = normalizedOf(segmentKey);
366
345
  return {
367
346
  "data-chrono-resize": edge,
347
+ // E25/E26: our own handle, and never a native drag source.
348
+ "data-zealakit-gesture-handle": "chrono",
349
+ draggable: "false",
368
350
  "aria-hidden": "true",
369
- "data-disabled": !norm ||
370
- !canEdit(norm, edge === "start" ? "resize-start" : "resize-end"),
351
+ "data-disabled": !norm || !canEdit(norm, edge === "start" ? "resize-start" : "resize-end"),
371
352
  };
372
353
  },
373
354
  dispose() {
@@ -4,6 +4,7 @@ import { getCalendarTitle } from "../navigation/title.js";
4
4
  import { isOutside } from "../views/day.js";
5
5
  import { getMiniCalendarLayout } from "../views/mini-calendar.js";
6
6
  import { cellAttributes, columnHeaderAttributes, isNavKey, moveInMonthGrid, nextId, navAttributes, toHighlighter, weekNumberAttributes, } from "./shared.js";
7
+ import { withOptional } from "../../foundation/store/with-optional.js";
7
8
  const MONTH_VIEW = {
8
9
  id: "month",
9
10
  layout: "month",
@@ -44,7 +45,7 @@ export function createMiniCalendarController(initial = {}) {
44
45
  // Keep the day of month where possible, otherwise the first day.
45
46
  focusedDate = plainDate(month.year, month.month, Math.min(focusedDate.day, endOfMonth(first).day));
46
47
  }
47
- return {
48
+ return withOptional({
48
49
  id,
49
50
  month,
50
51
  title: getCalendarTitle({ start: first, end: endOfMonth(first) }, MONTH_VIEW, locale),
@@ -70,7 +71,7 @@ export function createMiniCalendarController(initial = {}) {
70
71
  direction: getTextDirection(locale),
71
72
  locale,
72
73
  messages: mergeMessages(defaultMessages, options.messages),
73
- };
74
+ });
74
75
  };
75
76
  const refresh = () => {
76
77
  const next = compute();