@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,6 +1,7 @@
1
1
  import { addDays, addMonths, addYears, compare, compileAvailability, createControllable, createId, daysInMonth, defaultMessages, endOfMonth, formatDate, formatDateRange, getDateLabel, getDateStatus, getMonthNames, getMonths, getTextDirection, getWeekInfo, getWeekdayHeaders, isSameDay, mergeMessages, nextFocusedDate, plainDate, plainDateTime, plainTime, resolveLocale, startOfMonth, toIsoString, toPlainDate, today as readToday, } from "../../foundation/index.js";
2
2
  import { isBlocked, pickRange, previewRange, } from "../selection/range.js";
3
3
  import { addBetween, toggleDate } from "../selection/multiple.js";
4
+ import { withOptional } from "../../foundation/store/with-optional.js";
4
5
  const LEVELS = ["day", "month", "year"];
5
6
  const NAV_KEYS = new Set([
6
7
  "ArrowLeft",
@@ -19,12 +20,8 @@ const monthOf = (date) => ({
19
20
  });
20
21
  const sameNullable = (a, b) => a === b || (a !== null && b !== null && isSameDay(a, b));
21
22
  const sameRangeValue = (a, b) => a === b ||
22
- (a !== null &&
23
- b !== null &&
24
- sameNullable(a.start, b.start) &&
25
- sameNullable(a.end, b.end));
26
- const sameMulti = (a, b) => a.length === b.length &&
27
- a.every((date, index) => isSameDay(date, b[index]));
23
+ (a !== null && b !== null && sameNullable(a.start, b.start) && sameNullable(a.end, b.end));
24
+ const sameMulti = (a, b) => a.length === b.length && a.every((date, index) => isSameDay(date, b[index]));
28
25
  const isDraft = (value) => value !== null && value.start !== null && value.end === null;
29
26
  function createPanel(kind, initial) {
30
27
  let options = initial;
@@ -45,8 +42,7 @@ function createPanel(kind, initial) {
45
42
  }
46
43
  return availability
47
44
  .getIntervals(plainDateTime(date, plainTime(0, 0)), plainDateTime(addDays(date, 1), plainTime(0, 0)))
48
- .find((piece) => piece.status === "unavailable" && piece.rules.length > 0)
49
- ?.rules[0]?.reason;
45
+ .find((piece) => piece.status === "unavailable" && piece.rules.length > 0)?.rules[0]?.reason;
50
46
  };
51
47
  const constraints = () => ({
52
48
  min: bound(options.min),
@@ -67,7 +63,7 @@ function createPanel(kind, initial) {
67
63
  LEVELS.indexOf(options.minLevel ?? "day"),
68
64
  LEVELS.indexOf(options.maxLevel ?? "year"),
69
65
  ];
70
- const emptyValue = () => kind === "single" ? null : kind === "range" ? null : [];
66
+ const emptyValue = () => (kind === "single" ? null : kind === "range" ? null : []);
71
67
  const valueControl = createControllable({
72
68
  value: options.value,
73
69
  defaultValue: options.defaultValue ?? emptyValue(),
@@ -116,8 +112,7 @@ function createPanel(kind, initial) {
116
112
  return anchor;
117
113
  const today = todayNow();
118
114
  const month = monthControl.get();
119
- return sameMonth(monthOf(today), month) &&
120
- getDateStatus(today, constraints()).selectable
115
+ return sameMonth(monthOf(today), month) && getDateStatus(today, constraints()).selectable
121
116
  ? today
122
117
  : firstSelectable();
123
118
  })();
@@ -137,8 +132,7 @@ function createPanel(kind, initial) {
137
132
  if (level === "day") {
138
133
  const last = addMonths(plainDate(month.year, month.month, 1), monthCount() - 1);
139
134
  const first = plainDate(month.year, month.month, 1);
140
- if (compare(focusedDate, first) < 0 ||
141
- compare(focusedDate, endOfMonth(last)) > 0) {
135
+ if (compare(focusedDate, first) < 0 || compare(focusedDate, endOfMonth(last)) > 0) {
142
136
  focusedDate = plainDate(month.year, month.month, Math.min(focusedDate.day, daysInMonth(month.year, month.month)));
143
137
  }
144
138
  }
@@ -229,8 +223,7 @@ function createPanel(kind, initial) {
229
223
  selected,
230
224
  disabled: status.disabled,
231
225
  unavailable: status.unavailable,
232
- partiallyAvailable: !status.unavailable &&
233
- availabilityOf()?.getDayStatus(day.date) === "partial",
226
+ partiallyAvailable: !status.unavailable && availabilityOf()?.getDayStatus(day.date) === "partial",
234
227
  blocked: !hidden && blockedFor(day.date),
235
228
  focused: !hidden && isSameDay(day.date, focusedDate),
236
229
  rangeStart: isStart,
@@ -261,11 +254,8 @@ function createPanel(kind, initial) {
261
254
  year: "numeric",
262
255
  }),
263
256
  text: names[index],
264
- selected: anchor !== undefined &&
265
- anchor.year === month.year &&
266
- anchor.month === m,
267
- disabled: (minDate !== undefined &&
268
- compare(endOfMonth(monthStart), minDate) < 0) ||
257
+ selected: anchor !== undefined && anchor.year === month.year && anchor.month === m,
258
+ disabled: (minDate !== undefined && compare(endOfMonth(monthStart), minDate) < 0) ||
269
259
  (maxDate !== undefined && compare(monthStart, maxDate) > 0),
270
260
  focused: focusedDate.year === month.year && focusedDate.month === m,
271
261
  current: today.year === month.year && today.month === m,
@@ -325,7 +315,7 @@ function createPanel(kind, initial) {
325
315
  : kind === "single" && value !== null
326
316
  ? 1
327
317
  : 0;
328
- return {
318
+ return withOptional({
329
319
  id,
330
320
  kind,
331
321
  level,
@@ -350,7 +340,7 @@ function createPanel(kind, initial) {
350
340
  locale,
351
341
  messages,
352
342
  count: countValue,
353
- };
343
+ });
354
344
  };
355
345
  const refresh = () => {
356
346
  const next = compute();
@@ -427,9 +417,7 @@ function createPanel(kind, initial) {
427
417
  focusedDate = date;
428
418
  if (level !== "day") {
429
419
  // Drill down: a month goes to the day level of that month, a year to its months.
430
- monthControl.set(level === "month"
431
- ? monthOf(date)
432
- : { year: date.year, month: monthControl.get().month });
420
+ monthControl.set(level === "month" ? monthOf(date) : { year: date.year, month: monthControl.get().month });
433
421
  setLevelClamped(LEVELS[LEVELS.indexOf(level) - 1]);
434
422
  refresh();
435
423
  return;
@@ -599,9 +587,7 @@ function createPanel(kind, initial) {
599
587
  getTitleAttributes: () => ({ id: titleId, "aria-live": "polite" }),
600
588
  getLevelButtonAttributes: () => ({
601
589
  type: "button",
602
- "aria-label": state.level === "day"
603
- ? state.messages.chooseMonth
604
- : state.messages.chooseYear,
590
+ "aria-label": state.level === "day" ? state.messages.chooseMonth : state.messages.chooseYear,
605
591
  "aria-disabled": state.canGoUp ? undefined : "true",
606
592
  "data-disabled": !state.canGoUp,
607
593
  "data-level": state.level,
@@ -642,7 +628,7 @@ function createPanel(kind, initial) {
642
628
  const unselectable = day.disabled || day.unavailable || day.blocked;
643
629
  return {
644
630
  role: "gridcell",
645
- "aria-label": getDateLabel(day.date, state.locale, {
631
+ "aria-label": getDateLabel(day.date, state.locale, withOptional({
646
632
  today: day.today,
647
633
  selected: day.selected && !day.rangeStart && !day.rangeEnd && !day.inRange,
648
634
  unavailable: day.unavailable,
@@ -652,12 +638,8 @@ function createPanel(kind, initial) {
652
638
  rangeStart: day.rangeStart,
653
639
  rangeEnd: day.rangeEnd,
654
640
  inRange: day.inRange,
655
- }, state.messages),
656
- "aria-selected": day.selected
657
- ? "true"
658
- : unselectable
659
- ? undefined
660
- : "false",
641
+ }), state.messages),
642
+ "aria-selected": day.selected ? "true" : unselectable ? undefined : "false",
661
643
  "aria-current": day.today ? "date" : undefined,
662
644
  "aria-disabled": unselectable ? "true" : undefined,
663
645
  tabindex: day.focused ? 0 : -1,
@@ -680,11 +662,7 @@ function createPanel(kind, initial) {
680
662
  getLevelCellAttributes: (cell) => ({
681
663
  role: "gridcell",
682
664
  "aria-label": cell.label,
683
- "aria-selected": cell.selected
684
- ? "true"
685
- : cell.disabled
686
- ? undefined
687
- : "false",
665
+ "aria-selected": cell.selected ? "true" : cell.disabled ? undefined : "false",
688
666
  "aria-current": cell.current ? "date" : undefined,
689
667
  "aria-disabled": cell.disabled ? "true" : undefined,
690
668
  tabindex: cell.focused ? 0 : -1,
@@ -95,8 +95,7 @@ export function matchPreset(value, presets, ctx) {
95
95
  return null;
96
96
  for (const preset of presets) {
97
97
  const range = getPresetRange(preset, ctx);
98
- if (isSameDay(range.start, value.start) &&
99
- isSameDay(range.end, value.end)) {
98
+ if (isSameDay(range.start, value.start) && isSameDay(range.end, value.end)) {
100
99
  return preset;
101
100
  }
102
101
  }
@@ -16,15 +16,12 @@ export function toggleDate(value, date, constraints, maxSelected) {
16
16
  }
17
17
  /** Add every selectable day between `from` and `to` (either direction), stopping at `maxSelected`. */
18
18
  export function addBetween(value, from, to, constraints, maxSelected) {
19
- const range = compare(from, to) <= 0
20
- ? { start: from, end: to }
21
- : { start: to, end: from };
19
+ const range = compare(from, to) <= 0 ? { start: from, end: to } : { start: to, end: from };
22
20
  const next = [...value];
23
21
  for (const day of eachDay(range)) {
24
22
  if (maxSelected !== undefined && next.length >= maxSelected)
25
23
  break;
26
- if (getDateStatus(day, constraints).selectable &&
27
- !next.some((item) => isSameDay(item, day))) {
24
+ if (getDateStatus(day, constraints).selectable && !next.some((item) => isSameDay(item, day))) {
28
25
  next.push(day);
29
26
  }
30
27
  }
@@ -2,8 +2,8 @@ import { type DateRange, type DateRangeConstraints, type DateRangeReason, type P
2
2
  import type { DateRangeValue } from "../types.js";
3
3
  /** Range constraints whose day limits may depend on the start (plan 06 A23). */
4
4
  export type PickConstraints = Omit<DateRangeConstraints, "minDays" | "maxDays"> & {
5
- minDays?: number | ((start: PlainDate) => number);
6
- maxDays?: number | ((start: PlainDate) => number);
5
+ minDays?: number | ((start: PlainDate) => number) | undefined;
6
+ maxDays?: number | ((start: PlainDate) => number) | undefined;
7
7
  };
8
8
  export type RangeReason = DateRangeReason | "end-before-start";
9
9
  export type PickResult = {
@@ -17,9 +17,7 @@ export function pickRange(value, date, constraints) {
17
17
  ? { kind: "draft", value: { start: date, end: null } }
18
18
  : { kind: "invalid", reason: "start-invalid" };
19
19
  }
20
- const range = compare(date, start) < 0
21
- ? { start: date, end: start }
22
- : { start, end: date };
20
+ const range = compare(date, start) < 0 ? { start: date, end: start } : { start, end: date };
23
21
  const check = checkPicked(range, constraints);
24
22
  return check.valid
25
23
  ? { kind: "complete", value: range }
@@ -32,8 +30,6 @@ export function isBlocked(start, day, constraints) {
32
30
  }
33
31
  /** The previewed range for a draft, or null when the target is blocked. */
34
32
  export function previewRange(start, target, constraints) {
35
- const range = compare(target, start) < 0
36
- ? { start: target, end: start }
37
- : { start, end: target };
33
+ const range = compare(target, start) < 0 ? { start: target, end: start } : { start, end: target };
38
34
  return checkPicked(range, constraints).valid ? range : null;
39
35
  }
@@ -5,9 +5,9 @@ export type Draft = {
5
5
  time: PlainTime | null;
6
6
  };
7
7
  export type Zone = {
8
- timeZone?: string;
9
- valueTimeZone?: string;
10
- disambiguation?: Disambiguation;
8
+ timeZone?: string | undefined;
9
+ valueTimeZone?: string | undefined;
10
+ disambiguation?: Disambiguation | undefined;
11
11
  };
12
12
  export type Composed = {
13
13
  value: PlainDateTime | ZonedDateTime | null;
@@ -1,17 +1,17 @@
1
1
  import { type DateTimeInput, type PlainDate, type PlainDateTime, type PlainTime, type ZonedDateTime } from "../foundation/index.js";
2
2
  export type BoundsOptions = {
3
- min?: DateTimeInput;
4
- max?: DateTimeInput;
3
+ min?: DateTimeInput | undefined;
4
+ max?: DateTimeInput | undefined;
5
5
  /** `min` becomes now in `timeZone` (plan 08 X5). */
6
- disablePast?: boolean;
6
+ disablePast?: boolean | undefined;
7
7
  /** The display zone; plain values are read in it, zoned ones converted to it. */
8
- timeZone?: string;
9
- now?: number;
8
+ timeZone?: string | undefined;
9
+ now?: number | undefined;
10
10
  };
11
11
  /** Wall-time bounds in the display zone. Both ends are inclusive. */
12
12
  export type Bounds = {
13
- min?: PlainDateTime;
14
- max?: PlainDateTime;
13
+ min?: PlainDateTime | undefined;
14
+ max?: PlainDateTime | undefined;
15
15
  };
16
16
  export declare function getBounds(options: BoundsOptions): Bounds;
17
17
  /** A day outside `[min.day, max.day]` is disabled; boundary days stay enabled. */
@@ -31,8 +31,8 @@ export type DateTimeRangeCheck = {
31
31
  };
32
32
  export type DateTimeRangeLimits = {
33
33
  /** Minutes. */
34
- minDuration?: number;
35
- maxDuration?: number;
34
+ minDuration?: number | undefined;
35
+ maxDuration?: number | undefined;
36
36
  bounds?: Bounds;
37
37
  };
38
38
  /**
@@ -13,7 +13,7 @@ export type DateTimeSegmentView = SegmentView | TimeSegmentView;
13
13
  export type DateTimeInputOptions = {
14
14
  id?: string;
15
15
  value?: DateTimeValue;
16
- defaultValue?: DateTimeValue;
16
+ defaultValue?: DateTimeValue | undefined;
17
17
  onValueChange?: (value: DateTimeValue, info: {
18
18
  adjusted: boolean;
19
19
  }) => void;
@@ -36,7 +36,7 @@ export type DateTimeInputOptions = {
36
36
  /** Availability model (plan 11 V7–V8): dates and times of the draft day. */
37
37
  availability?: AvailabilitySpec | Availability;
38
38
  onInvalidInput?: (text: string) => void;
39
- name?: string;
39
+ name?: string | undefined;
40
40
  /** Replaces the hidden input's value (for example to send UTC). */
41
41
  formValue?: (value: NonNullable<DateTimeValue>) => string;
42
42
  required?: boolean;
@@ -1,10 +1,11 @@
1
1
  import { compare, compileAvailability, createControllable, createId, defaultMessages, getHiddenInputs, getTimeZoneLabel, mergeMessages, nowZoned, toInstant, } from "../../foundation/index.js";
2
2
  import { createDateInputController, } from "../../date/index.js";
3
3
  import { createTimeInputController, } from "../../time/index.js";
4
- import { compose, decompose, sameDateTime, } from "../compose.js";
5
- import { getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
4
+ import { compose, decompose, sameDateTime } from "../compose.js";
5
+ import { getBounds, isDayDisabled, timeBoundsFor } from "../constraints.js";
6
6
  import { formatOffset } from "../zone/day-instants.js";
7
7
  import { parseDateTime } from "./parse.js";
8
+ import { withOptional } from "../../foundation/index.js";
8
9
  const DATE_PARTS = new Set(["day", "month", "year"]);
9
10
  const isDatePart = (part) => DATE_PARTS.has(part);
10
11
  /** The text between the date and the time of a locale ("," + space, or a space). */
@@ -104,15 +105,11 @@ export function createDateTimeInputController(initial = {}) {
104
105
  step: options.step,
105
106
  min: limit.min,
106
107
  max: limit.max,
107
- isTimeDisabled: date
108
- ? (t) => options.isTimeDisabled?.(t, date) ?? false
109
- : undefined,
108
+ isTimeDisabled: date ? (t) => options.isTimeDisabled?.(t, date) ?? false : undefined,
110
109
  isTimeUnavailable: date
111
110
  ? (t) => {
112
111
  const availability = availabilityOf();
113
- return availability
114
- ? !availability.isTimeAvailable(date, t)
115
- : false;
112
+ return availability ? !availability.isTimeAvailable(date, t) : false;
116
113
  }
117
114
  : undefined,
118
115
  onInvalidInput: options.onInvalidInput,
@@ -126,9 +123,7 @@ export function createDateTimeInputController(initial = {}) {
126
123
  const dateCtl = createDateInputController(dateOptions());
127
124
  const timeCtl = createTimeInputController(timeOptions());
128
125
  const firstLast = (group, which) => {
129
- const parts = (group === "date"
130
- ? dateCtl.getState().segments
131
- : timeCtl.getState().segments)
126
+ const parts = (group === "date" ? dateCtl.getState().segments : timeCtl.getState().segments)
132
127
  .filter((segment) => segment.type !== "literal")
133
128
  .map((segment) => segment.type);
134
129
  return (which === "first" ? parts[0] : parts[parts.length - 1]);
@@ -215,7 +210,7 @@ export function createDateTimeInputController(initial = {}) {
215
210
  };
216
211
  const value = control.get();
217
212
  const at = options.now ?? (value && "timeZone" in value ? toInstant(value) : 0);
218
- return {
213
+ return withOptional({
219
214
  id,
220
215
  mode,
221
216
  segments: [...dateState.segments, literal, ...timeState.segments],
@@ -225,19 +220,15 @@ export function createDateTimeInputController(initial = {}) {
225
220
  validity: validity(),
226
221
  adjusted: current.adjusted,
227
222
  focusedPart: focusedGroup === "date" ? dateState.focusedPart : timeState.focusedPart,
228
- zoneLabel: options.timeZone
229
- ? getTimeZoneLabel(options.timeZone, options.locale, at)
230
- : null,
223
+ zoneLabel: options.timeZone ? getTimeZoneLabel(options.timeZone, options.locale, at) : null,
231
224
  required: options.required ?? false,
232
225
  readOnly: options.readOnly ?? false,
233
226
  disabled: options.disabled ?? false,
234
227
  direction: dateState.direction,
235
228
  locale: dateState.locale,
236
229
  messages,
237
- hidden: getHiddenInputs([
238
- [options.name, value ? formString(value) : null],
239
- ]),
240
- };
230
+ hidden: getHiddenInputs([[options.name, value ? formString(value) : null]]),
231
+ });
241
232
  };
242
233
  const emit = () => {
243
234
  const next = compute();
@@ -319,9 +310,7 @@ export function createDateTimeInputController(initial = {}) {
319
310
  dateCtl.commit();
320
311
  timeCtl.commit();
321
312
  const value = control.get();
322
- if (value &&
323
- state.validity === "valid" &&
324
- !sameDateTime(value, lastCommitted)) {
313
+ if (value && state.validity === "valid" && !sameDateTime(value, lastCommitted)) {
325
314
  lastCommitted = value;
326
315
  options.onValueCommit?.(value);
327
316
  }
@@ -365,11 +354,7 @@ export function createDateTimeInputController(initial = {}) {
365
354
  return {
366
355
  ...base,
367
356
  // One tab stop for the whole group, not one per sub-controller.
368
- tabindex: state.disabled
369
- ? undefined
370
- : segment.type === state.focusedPart
371
- ? 0
372
- : -1,
357
+ tabindex: state.disabled ? undefined : segment.type === state.focusedPart ? 0 : -1,
373
358
  };
374
359
  },
375
360
  getDateFieldAttributes: () => ({
@@ -1,12 +1,9 @@
1
1
  import { createControllable, createId, getHiddenInputs, } from "../../foundation/index.js";
2
2
  import { sameDateTime } from "../compose.js";
3
- import { checkDateTimeRange, getBounds, } from "../constraints.js";
3
+ import { checkDateTimeRange, getBounds } from "../constraints.js";
4
4
  import { createDateTimeInputController, } from "./datetime-input-controller.js";
5
5
  const sameRange = (a, b) => a === b ||
6
- (a !== null &&
7
- b !== null &&
8
- sameDateTime(a.start, b.start) &&
9
- sameDateTime(a.end, b.end));
6
+ (a !== null && b !== null && sameDateTime(a.start, b.start) && sameDateTime(a.end, b.end));
10
7
  /** Two date-time inputs in one group (plan 08 X10). */
11
8
  export function createDateTimeRangeInputController(initial = {}) {
12
9
  let options = initial;
@@ -23,9 +20,7 @@ export function createDateTimeRangeInputController(initial = {}) {
23
20
  // The fields only format the hidden value; this range names the inputs.
24
21
  return {
25
22
  ...shared,
26
- name: options.name || options.startName || options.endName
27
- ? "value"
28
- : undefined,
23
+ name: options.name || options.startName || options.endName ? "value" : undefined,
29
24
  };
30
25
  };
31
26
  const combine = (start, end) => start === null && end === null ? null : { start, end };
@@ -97,14 +92,8 @@ export function createDateTimeRangeInputController(initial = {}) {
97
92
  disabled: start.disabled,
98
93
  readOnly: start.readOnly,
99
94
  hidden: getHiddenInputs([
100
- [
101
- options.startName ?? (name ? `${name}-start` : undefined),
102
- start.hidden[0]?.value ?? null,
103
- ],
104
- [
105
- options.endName ?? (name ? `${name}-end` : undefined),
106
- end.hidden[0]?.value ?? null,
107
- ],
95
+ [options.startName ?? (name ? `${name}-start` : undefined), start.hidden[0]?.value ?? null],
96
+ [options.endName ?? (name ? `${name}-end` : undefined), end.hidden[0]?.value ?? null],
108
97
  ]),
109
98
  messages: start.messages,
110
99
  };
@@ -1,8 +1,8 @@
1
1
  import { type PlainDate, type PlainTime } from "../../foundation/index.js";
2
2
  export type DateTimeParseContext = {
3
- locale?: string;
3
+ locale?: string | undefined;
4
4
  /** The display zone; an ISO string with an offset or `Z` is converted into it. */
5
- timeZone?: string;
5
+ timeZone?: string | undefined;
6
6
  today?: PlainDate;
7
7
  };
8
8
  /** `date` and `time` are `null` when the text holds only the other one (plan 08 §13.2). */
@@ -33,8 +33,7 @@ export function parseDateTime(text, context = {}) {
33
33
  let timePart = "";
34
34
  const withColon = TIME_TAIL.exec(trimmed);
35
35
  const hourOnly = HOUR_TAIL.exec(trimmed);
36
- if (withColon &&
37
- (!withColon[2] || dayPeriodOf(withColon[2], context.locale))) {
36
+ if (withColon && (!withColon[2] || dayPeriodOf(withColon[2], context.locale))) {
38
37
  timePart = withColon[0];
39
38
  datePart = trimmed.slice(0, withColon.index);
40
39
  }
@@ -53,7 +52,5 @@ export function parseDateTime(text, context = {}) {
53
52
  if (datePart === "")
54
53
  return { date: null, time: time.time };
55
54
  const date = parseDate(datePart, context);
56
- return "date" in date
57
- ? { date: date.date, time: time.time }
58
- : fail(date.error);
55
+ return "date" in date ? { date: date.date, time: time.time } : fail(date.error);
59
56
  }
@@ -2,7 +2,7 @@ import { compare, compileAvailability, createControllable, createId, defaultMess
2
2
  import { createDatePanelController, } from "../../date/index.js";
3
3
  import { createTimePanelController, } from "../../time/index.js";
4
4
  import { compose, decompose, sameDateTime, } from "../compose.js";
5
- import { getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
5
+ import { getBounds, isDayDisabled, timeBoundsFor } from "../constraints.js";
6
6
  /** Date and time panels composed by one controller (plan 08 X6–X8). */
7
7
  export function createDateTimePanelController(initial = {}) {
8
8
  let options = initial;
@@ -37,9 +37,7 @@ export function createDateTimePanelController(initial = {}) {
37
37
  return false;
38
38
  return !options.isTimeDisabled?.(time, date);
39
39
  };
40
- const defaultTime = () => options.defaultTime === undefined
41
- ? null
42
- : toPlainTime(options.defaultTime);
40
+ const defaultTime = () => options.defaultTime === undefined ? null : toPlainTime(options.defaultTime);
43
41
  const availabilityOf = () => options.availability === undefined
44
42
  ? undefined
45
43
  : compileAvailability(options.availability, {
@@ -78,9 +76,7 @@ export function createDateTimePanelController(initial = {}) {
78
76
  now: options.now,
79
77
  min: limit.min,
80
78
  max: limit.max,
81
- isTimeDisabled: date
82
- ? (time) => options.isTimeDisabled?.(time, date) ?? false
83
- : undefined,
79
+ isTimeDisabled: date ? (time) => options.isTimeDisabled?.(time, date) ?? false : undefined,
84
80
  isTimeUnavailable: date
85
81
  ? (time) => {
86
82
  const availability = availabilityOf();
@@ -165,9 +161,7 @@ export function createDateTimePanelController(initial = {}) {
165
161
  control.sync({ value: options.value });
166
162
  const current = control.get();
167
163
  if (!sameDateTime(composed.value, current)) {
168
- draft = current
169
- ? decompose(current, zone())
170
- : { date: null, time: null };
164
+ draft = current ? decompose(current, zone()) : { date: null, time: null };
171
165
  }
172
166
  update();
173
167
  },
@@ -4,10 +4,7 @@ import { createTimePanelController, } from "../../time/index.js";
4
4
  import { compose, decompose, sameDateTime } from "../compose.js";
5
5
  import { checkDateTimeRange, getBounds, isDayDisabled, timeBoundsFor, } from "../constraints.js";
6
6
  const sameRange = (a, b) => a === b ||
7
- (a !== null &&
8
- b !== null &&
9
- sameDateTime(a.start, b.start) &&
10
- sameDateTime(a.end, b.end));
7
+ (a !== null && b !== null && sameDateTime(a.start, b.start) && sameDateTime(a.end, b.end));
11
8
  /** A date range panel and two time panels composed by one controller (plan 08 X9). */
12
9
  export function createDateTimeRangePanelController(initial = {}) {
13
10
  let options = initial;
@@ -69,14 +66,10 @@ export function createDateTimeRangePanelController(initial = {}) {
69
66
  now: options.now,
70
67
  min: limit.min,
71
68
  max: limit.max,
72
- isTimeDisabled: (t) => (date ? options.isTimeDisabled?.(t, date) : false) ||
73
- (kind === "end" && endBreaks(t)),
69
+ isTimeDisabled: (t) => (date ? options.isTimeDisabled?.(t, date) : false) || (kind === "end" && endBreaks(t)),
74
70
  value: time,
75
71
  onValueChange: (next) => {
76
- draft =
77
- kind === "start"
78
- ? { ...draft, startTime: next }
79
- : { ...draft, endTime: next };
72
+ draft = kind === "start" ? { ...draft, startTime: next } : { ...draft, endTime: next };
80
73
  update();
81
74
  },
82
75
  onValueCommit: kind === "end" ? () => commitNow() : undefined,
@@ -115,12 +108,7 @@ export function createDateTimeRangePanelController(initial = {}) {
115
108
  const listeners = new Set();
116
109
  const evaluate = () => {
117
110
  const { start, end } = composeBoth();
118
- const filled = [
119
- draft.range?.start,
120
- draft.range?.end,
121
- draft.startTime,
122
- draft.endTime,
123
- ].filter(Boolean).length;
111
+ const filled = [draft.range?.start, draft.range?.end, draft.startTime, draft.endTime].filter(Boolean).length;
124
112
  if (filled === 0)
125
113
  return { value: null, validity: "empty", duration: null };
126
114
  if (!start || !end)
@@ -1,7 +1,5 @@
1
1
  import { fromSecondOfDay, plainDateTime, toInstant, toZoned, } from "../../foundation/index.js";
2
- const wallEquals = (zoned, time) => zoned.hour === time.hour &&
3
- zoned.minute === time.minute &&
4
- zoned.second === time.second;
2
+ const wallEquals = (zoned, time) => zoned.hour === time.hour && zoned.minute === time.minute && zoned.second === time.second;
5
3
  const pad = (n) => String(n).padStart(2, "0");
6
4
  /** `+07:00` for an offset in minutes. */
7
5
  export function formatOffset(minutes) {
@@ -17,10 +17,8 @@ export function resolveWall(wall, zone, disambiguation = "compatible") {
17
17
  return {
18
18
  zoned,
19
19
  adjusted: !sameWall(zoned, wall),
20
- ambiguous: earlier.offset !== later.offset &&
21
- sameWall(earlier, wall) &&
22
- sameWall(later, wall),
20
+ ambiguous: earlier.offset !== later.offset && sameWall(earlier, wall) && sameWall(later, wall),
23
21
  };
24
22
  }
25
23
  /** The same instant in the zone the app stores values in (plan 08 X2). */
26
- export const toValueZone = (zoned, valueTimeZone) => valueTimeZone === undefined ? zoned : withTimeZone(zoned, valueTimeZone);
24
+ export const toValueZone = (zoned, valueTimeZone) => (valueTimeZone === undefined ? zoned : withTimeZone(zoned, valueTimeZone));
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Candidate A.4 `auto-scroll` — private `src/dom/` module (D35, plan 08-2 Step 4).
3
+ *
4
+ * Edge auto-scroll maths for any pointer drag: speed by distance, the nearest
5
+ * scrollable ancestor, and the per-frame scroll deltas. **Stateless**: it owns
6
+ * no loop, no listener and no timer — the drag session that owns the single
7
+ * frame loop applies `autoScrollStep` in it (NP9). The calendar layer passes
8
+ * the container it already resolved; datagrid will be the 2nd consumer
9
+ * (plan 10).
10
+ *
11
+ * No Chrono types and no DOM access at import time.
12
+ */
13
+ /** Schedule one frame (rAF, or a 16 ms timer where rAF is unavailable). */
14
+ export declare const scheduleFrame: (callback: () => void) => number;
15
+ /** Cancel a frame scheduled by {@link scheduleFrame}. */
16
+ export declare const cancelFrame: (handle: number) => void;
17
+ /** `speed(d) = d >= 40 ? 0 : round(20 · (1 − d / 40))` pixels per frame. */
18
+ export declare function autoScrollSpeed(distance: number): number;
19
+ /** The nearest scrollable ancestor of `element`, or `null`. */
20
+ export declare function scrollParent(element: Element | null): HTMLElement | null;
21
+ export type ScrollDelta = {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ /**
26
+ * The scroll deltas for this pointer position, read from the container's rect.
27
+ * The caller writes them (`scrollLeft`/`scrollTop`) in its own frame loop.
28
+ */
29
+ export declare function autoScrollStep(container: HTMLElement | null, point: {
30
+ x: number;
31
+ y: number;
32
+ }): ScrollDelta;
33
+ /** Scroll `container` one step toward `point`; the caller owns the frame loop. */
34
+ export declare function applyAutoScroll(container: HTMLElement, point: {
35
+ x: number;
36
+ y: number;
37
+ }): void;