@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
@@ -4,15 +4,15 @@ export type TimeStep = {
4
4
  seconds?: number;
5
5
  };
6
6
  export type TimeConstraints = {
7
- min?: PlainTime;
8
- max?: PlainTime;
9
- step?: TimeStep;
7
+ min?: PlainTime | undefined;
8
+ max?: PlainTime | undefined;
9
+ step?: TimeStep | undefined;
10
10
  /** Half-open `[start, end)`. */
11
11
  disabledRanges?: readonly {
12
12
  start: PlainTime;
13
13
  end: PlainTime;
14
- }[];
15
- isTimeDisabled?: (time: PlainTime) => boolean;
14
+ }[] | undefined;
15
+ isTimeDisabled?: ((time: PlainTime) => boolean) | undefined;
16
16
  };
17
17
  export type TimeStatusReason = "before-min" | "after-max" | "off-step" | "disabled-range" | "disabled";
18
18
  export type TimeStatus = {
@@ -1,5 +1,5 @@
1
1
  import { compare } from "../values/compare.js";
2
- import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay, } from "../values/plain-time.js";
2
+ import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay } from "../values/plain-time.js";
3
3
  /** Step length in seconds; `0` when no step is set. */
4
4
  export function stepToSeconds(step) {
5
5
  const seconds = (step?.minutes ?? 0) * 60 + (step?.seconds ?? 0);
@@ -1,7 +1,7 @@
1
1
  export { getMonthGrid, getMonths } from "./month-grid.js";
2
- export type { GridDay, GridWeek, MonthGrid, MonthGridOptions, } from "./month-grid.js";
2
+ export type { GridDay, GridWeek, MonthGrid, MonthGridOptions } from "./month-grid.js";
3
3
  export { getDecadeGrid, getYearGrid } from "./year-grid.js";
4
- export type { DecadeCell, DecadeGrid, MonthCell, YearGrid, } from "./year-grid.js";
4
+ export type { DecadeCell, DecadeGrid, MonthCell, YearGrid } from "./year-grid.js";
5
5
  export { getWeekdayHeaders } from "./weekday-headers.js";
6
6
  export type { WeekdayHeader } from "./weekday-headers.js";
7
7
  export { getTimeAxis } from "./time-axis.js";
@@ -21,9 +21,9 @@ export type MonthGridOptions = {
21
21
  /** Source of the weekend days (default Saturday and Sunday) and of locale week numbers. */
22
22
  weekInfo?: Pick<WeekInfo, "weekend"> & Partial<Pick<WeekInfo, "firstDay" | "minimalDays">>;
23
23
  /** Always render 6 rows so the grid height is stable. */
24
- fixedWeeks?: boolean;
24
+ fixedWeeks?: boolean | undefined;
25
25
  today?: PlainDate;
26
- weekNumbers?: "iso" | "locale";
26
+ weekNumbers?: "iso" | "locale" | undefined;
27
27
  };
28
28
  export declare function getMonthGrid(year: number, month: number, options: MonthGridOptions): MonthGrid;
29
29
  /** `count` consecutive month grids starting at `start`'s month. */
@@ -11,15 +11,15 @@ export type TimeSlot = {
11
11
  working: boolean;
12
12
  };
13
13
  export type TimeAxisOptions = {
14
- start?: PlainTime;
14
+ start?: PlainTime | undefined;
15
15
  /** Exclusive. Omit for the end of the day (24:00). */
16
- end?: PlainTime;
16
+ end?: PlainTime | undefined;
17
17
  step: TimeStep;
18
18
  /** Half-open `[start, end)` ranges; an `end` of 00:00 means 24:00. */
19
19
  workingHours?: readonly {
20
20
  start: PlainTime;
21
21
  end: PlainTime;
22
- }[];
22
+ }[] | undefined;
23
23
  };
24
24
  /** Wall-time slots. DST is handled at layout time, where real days are known. */
25
25
  export declare function getTimeAxis(options: TimeAxisOptions): TimeSlot[];
@@ -1,5 +1,5 @@
1
1
  import { stepToSeconds } from "../constraints/time.js";
2
- import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay, } from "../values/plain-time.js";
2
+ import { SECONDS_PER_DAY, fromSecondOfDay, toSecondOfDay } from "../values/plain-time.js";
3
3
  /** Wall-time slots. DST is handled at layout time, where real days are known. */
4
4
  export function getTimeAxis(options) {
5
5
  const size = stepToSeconds(options.step);
@@ -1,4 +1,4 @@
1
- export { backspace, emptySegment, segmentOf, stepSegment, typeDigit, } from "./segment-engine.js";
1
+ export { backspace, emptySegment, segmentOf, stepSegment, typeDigit } from "./segment-engine.js";
2
2
  export type { SegmentDef, SegmentValue } from "./segment-engine.js";
3
3
  export { fold, tokenize } from "./tokenize.js";
4
4
  export type { Token } from "./tokenize.js";
@@ -1,3 +1,3 @@
1
- export { backspace, emptySegment, segmentOf, stepSegment, typeDigit, } from "./segment-engine.js";
1
+ export { backspace, emptySegment, segmentOf, stepSegment, typeDigit } from "./segment-engine.js";
2
2
  export { fold, tokenize } from "./tokenize.js";
3
3
  export { getHiddenInputs } from "./form.js";
@@ -12,9 +12,7 @@ export const segmentOf = (value) => ({
12
12
  * part cannot take another digit.
13
13
  */
14
14
  export function typeDigit(def, segment, digit) {
15
- let buffer = segment.buffer.length >= def.maxDigits
16
- ? String(digit)
17
- : segment.buffer + digit;
15
+ let buffer = segment.buffer.length >= def.maxDigits ? String(digit) : segment.buffer + digit;
18
16
  if (Number(buffer) > def.max) {
19
17
  buffer = String(digit);
20
18
  }
@@ -25,9 +23,7 @@ export function typeDigit(def, segment, digit) {
25
23
  }
26
24
  return {
27
25
  segment: { value: n >= def.min ? n : null, buffer },
28
- advance: n >= def.min &&
29
- (buffer.length >= def.maxDigits ||
30
- (def.maxDigits === 2 && n * 10 > def.max)),
26
+ advance: n >= def.min && (buffer.length >= def.maxDigits || (def.maxDigits === 2 && n * 10 > def.max)),
31
27
  };
32
28
  }
33
29
  /** Step by `delta`, wrapping inside `[min, max]`. An empty part starts at `start`. */
@@ -10,19 +10,7 @@ const RTL_SCRIPTS = new Set([
10
10
  "Mand",
11
11
  "Samr",
12
12
  ]);
13
- const RTL_LANGUAGES = new Set([
14
- "ar",
15
- "he",
16
- "fa",
17
- "ur",
18
- "ps",
19
- "sd",
20
- "ug",
21
- "yi",
22
- "dv",
23
- "ckb",
24
- "ku",
25
- ]);
13
+ const RTL_LANGUAGES = new Set(["ar", "he", "fa", "ur", "ps", "sd", "ug", "yi", "dv", "ckb", "ku"]);
26
14
  export function getTextDirection(locale) {
27
15
  const parsed = new Intl.Locale(resolveLocale(locale));
28
16
  const direction = parsed.getTextInfo?.().direction ?? parsed.textInfo?.direction;
@@ -44,9 +44,7 @@ export function getDatePartOrder(locale) {
44
44
  if (part.type === "literal") {
45
45
  pending += part.value;
46
46
  }
47
- else if (part.type === "day" ||
48
- part.type === "month" ||
49
- part.type === "year") {
47
+ else if (part.type === "day" || part.type === "month" || part.type === "year") {
50
48
  if (order.length === 0) {
51
49
  prefix = pending;
52
50
  }
@@ -9,9 +9,7 @@ export function getHourCycle(locale) {
9
9
  if (cycle === "h23" || cycle === "h24") {
10
10
  return "h23";
11
11
  }
12
- return formatter.formatToParts(0).some((part) => part.type === "dayPeriod")
13
- ? "h12"
14
- : "h23";
12
+ return formatter.formatToParts(0).some((part) => part.type === "dayPeriod") ? "h12" : "h23";
15
13
  }
16
14
  /** Localized AM and PM markers. */
17
15
  export function getDayPeriodNames(locale) {
@@ -20,9 +18,7 @@ export function getDayPeriodNames(locale) {
20
18
  hourCycle: "h12",
21
19
  timeZone: "UTC",
22
20
  });
23
- const period = (hour) => formatter
24
- .formatToParts(hour * 3600000)
25
- .find((part) => part.type === "dayPeriod")?.value ?? "";
21
+ const period = (hour) => formatter.formatToParts(hour * 3600000).find((part) => part.type === "dayPeriod")?.value ?? "";
26
22
  return { am: period(1), pm: period(13) };
27
23
  }
28
24
  /**
@@ -2,7 +2,7 @@ export { resolveLocale } from "./resolve.js";
2
2
  export { getWeekInfo } from "./week-info.js";
3
3
  export { getMonthNames, getWeekdayNames } from "./names.js";
4
4
  export type { NameWidth } from "./names.js";
5
- export { getDayPeriodLabel, getDayPeriodNames, getHourCycle, } from "./hour-cycle.js";
5
+ export { getDayPeriodLabel, getDayPeriodNames, getHourCycle } from "./hour-cycle.js";
6
6
  export { getTextDirection } from "./direction.js";
7
7
  export { formatDate, formatDateRange, formatDateRangeToParts, formatDateToParts, formatDateTime, formatTime, getDatePartOrder, getDateFormatPattern, } from "./format.js";
8
8
  export type { DatePartName, DatePartOrder, FormatOptions } from "./format.js";
@@ -1,7 +1,7 @@
1
1
  export { resolveLocale } from "./resolve.js";
2
2
  export { getWeekInfo } from "./week-info.js";
3
3
  export { getMonthNames, getWeekdayNames } from "./names.js";
4
- export { getDayPeriodLabel, getDayPeriodNames, getHourCycle, } from "./hour-cycle.js";
4
+ export { getDayPeriodLabel, getDayPeriodNames, getHourCycle } from "./hour-cycle.js";
5
5
  export { getTextDirection } from "./direction.js";
6
6
  export { formatDate, formatDateRange, formatDateRangeToParts, formatDateToParts, formatDateTime, formatTime, getDatePartOrder, getDateFormatPattern, } from "./format.js";
7
7
  export { getLocaleDigits, toLatinDigits, toLocaleDigits } from "./digits.js";
@@ -1,7 +1,12 @@
1
1
  /** Internal: locale resolution and a lazy `Intl.DateTimeFormat` cache (plan 03 §3.2). */
2
2
  const formatters = new Map();
3
+ // Both caches are filled on first use, never at import. A drag asks on every frame, once per
4
+ // cell label, and building an `Intl` object each time was most of the cost of a frame.
5
+ let runtime;
6
+ const canonical = new Map();
3
7
  function runtimeLocale() {
4
- return new Intl.DateTimeFormat().resolvedOptions().locale;
8
+ runtime ??= new Intl.DateTimeFormat().resolvedOptions().locale;
9
+ return runtime;
5
10
  }
6
11
  /**
7
12
  * Canonical BCP 47 tag. `undefined` means the runtime default (D11); SSR apps
@@ -11,7 +16,12 @@ export function resolveLocale(locale) {
11
16
  if (locale === undefined || locale === "") {
12
17
  return runtimeLocale();
13
18
  }
14
- return Intl.getCanonicalLocales(locale)[0] ?? runtimeLocale();
19
+ let resolved = canonical.get(locale);
20
+ if (resolved === undefined) {
21
+ resolved = Intl.getCanonicalLocales(locale)[0] ?? runtimeLocale();
22
+ canonical.set(locale, resolved);
23
+ }
24
+ return resolved;
15
25
  }
16
26
  /** Cached formatter. Always Gregorian: Chrono has no other calendars in v1. */
17
27
  export function getFormatter(locale, options) {
@@ -55,7 +55,6 @@ export function getWeekInfo(locale) {
55
55
  return {
56
56
  firstDay: native.firstDay,
57
57
  weekend: native.weekend,
58
- minimalDays: (native.minimalDays ??
59
- fallback.minimalDays),
58
+ minimalDays: (native.minimalDays ?? fallback.minimalDays),
60
59
  };
61
60
  }
@@ -1,4 +1,4 @@
1
1
  export { clampDate, dateRangeLength, dateRangesOverlap, eachDay, intersectDateRanges, isDateInRange, normalizeDateRange, } from "./date-range.js";
2
2
  export type { DateRange } from "./date-range.js";
3
- export { intervalDuration, intervalsOverlap, splitIntervalByDay, } from "./interval.js";
3
+ export { intervalDuration, intervalsOverlap, splitIntervalByDay } from "./interval.js";
4
4
  export type { Interval, IntervalPiece } from "./interval.js";
@@ -1,2 +1,2 @@
1
1
  export { clampDate, dateRangeLength, dateRangesOverlap, eachDay, intersectDateRanges, isDateInRange, normalizeDateRange, } from "./date-range.js";
2
- export { intervalDuration, intervalsOverlap, splitIntervalByDay, } from "./interval.js";
2
+ export { intervalDuration, intervalsOverlap, splitIntervalByDay } from "./interval.js";
@@ -27,9 +27,7 @@ export function splitIntervalByDay(interval, timeZone) {
27
27
  return [];
28
28
  }
29
29
  const zoned = isZoned(interval.start);
30
- const zone = zoned
31
- ? (timeZone ?? interval.start.timeZone)
32
- : "";
30
+ const zone = zoned ? (timeZone ?? interval.start.timeZone) : "";
33
31
  const start = (zoned ? withTimeZone(interval.start, zone) : interval.start);
34
32
  const end = (zoned ? withTimeZone(interval.end, zone) : interval.end);
35
33
  const dayStart = (date) => {
@@ -1,6 +1,6 @@
1
1
  export type ControllableOptions<T> = {
2
2
  /** Controlled when not `undefined`. */
3
- value?: T;
3
+ value?: T | undefined;
4
4
  defaultValue: T;
5
5
  onChange?: (value: T) => void;
6
6
  /** Suppresses change events for equal values (`isSameDay`, ...). */
@@ -1,2 +1,9 @@
1
- /** A page-wide counter; adapters pass framework ids for SSR instead. */
1
+ /**
2
+ * Id source for Core-generated nodes (plan 08-1 Step 2, X11).
3
+ *
4
+ * The engine owns the page-wide counter, so every Core copy and every adapter on
5
+ * the page shares one sequence: ids are `zealakit-<prefix>-<n>` and two bundled
6
+ * copies cannot collide. Adapters still pass framework ids (`useId`, `$props.id()`)
7
+ * for SSR; this is the fallback for direct Core use.
8
+ */
2
9
  export declare function createId(prefix: string): string;
@@ -1,7 +1,12 @@
1
- import { getGlobalState } from "./global-state.js";
2
- /** A page-wide counter; adapters pass framework ids for SSR instead. */
1
+ import { createId as engineCreateId } from "@zealakit/ui-engine";
2
+ /**
3
+ * Id source for Core-generated nodes (plan 08-1 Step 2, X11).
4
+ *
5
+ * The engine owns the page-wide counter, so every Core copy and every adapter on
6
+ * the page shares one sequence: ids are `zealakit-<prefix>-<n>` and two bundled
7
+ * copies cannot collide. Adapters still pass framework ids (`useId`, `$props.id()`)
8
+ * for SSR; this is the fallback for direct Core use.
9
+ */
3
10
  export function createId(prefix) {
4
- const state = getGlobalState("ids", () => ({ count: 0 }));
5
- state.count += 1;
6
- return `${prefix}-${state.count}`;
11
+ return engineCreateId(prefix);
7
12
  }
@@ -2,10 +2,10 @@ export { createStore } from "./store.js";
2
2
  export type { Store } from "./store.js";
3
3
  export { createControllable } from "./controllable.js";
4
4
  export type { Controllable, ControllableOptions } from "./controllable.js";
5
- export { getGlobalState } from "./global-state.js";
6
5
  export { isBrowser } from "./env.js";
7
- export { mergeAttributes, normalizeAttributes, splitProperties, } from "./attributes.js";
6
+ export { mergeAttributes, normalizeAttributes, splitProperties } from "./attributes.js";
8
7
  export type { Attributes } from "./attributes.js";
9
8
  export { createTicker } from "./ticker.js";
10
9
  export type { Ticker } from "./ticker.js";
11
10
  export { createId } from "./ids.js";
11
+ export { withOptional } from "./with-optional.js";
@@ -1,7 +1,7 @@
1
1
  export { createStore } from "./store.js";
2
2
  export { createControllable } from "./controllable.js";
3
- export { getGlobalState } from "./global-state.js";
4
3
  export { isBrowser } from "./env.js";
5
- export { mergeAttributes, normalizeAttributes, splitProperties, } from "./attributes.js";
4
+ export { mergeAttributes, normalizeAttributes, splitProperties } from "./attributes.js";
6
5
  export { createTicker } from "./ticker.js";
7
6
  export { createId } from "./ids.js";
7
+ export { withOptional } from "./with-optional.js";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * For `exactOptionalPropertyTypes`: Chrono's state and result objects carry
3
+ * optional keys with the value `undefined`, which their public types declare as
4
+ * "absent or T". `withOptional` returns the object unchanged while still
5
+ * checking every property against `T`: the only thing it forgives is
6
+ * `undefined` on a property that `T` marks optional.
7
+ *
8
+ * `T` comes from where the result is used (`NoInfer` keeps the argument from
9
+ * widening it). Internal; never exported from the package.
10
+ */
11
+ type Loose<T> = T extends unknown ? {
12
+ [K in keyof T]: Record<never, never> extends Pick<T, K> ? T[K] | undefined : T[K];
13
+ } : never;
14
+ export declare function withOptional<T extends object>(value: Loose<NoInfer<T>>): T;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ export function withOptional(value) {
2
+ return value;
3
+ }
@@ -1,4 +1,4 @@
1
- import { parseIsoDate, parseIsoDateTime, parseIsoTime, parseIsoZoned, } from "./iso.js";
1
+ import { parseIsoDate, parseIsoDateTime, parseIsoTime, parseIsoZoned } from "./iso.js";
2
2
  import { datePart, plainDateTime, timePart } from "./plain-date-time.js";
3
3
  import { addDays, plainDate } from "./plain-date.js";
4
4
  import { plainTime } from "./plain-time.js";
@@ -78,9 +78,7 @@ export function fromInclusiveEndDate(lastDay, timeZone = "UTC") {
78
78
  */
79
79
  export function fromTemporalLike(object) {
80
80
  const t = object;
81
- if (t.calendarId !== undefined &&
82
- t.calendarId !== "iso8601" &&
83
- t.calendarId !== "gregory") {
81
+ if (t.calendarId !== undefined && t.calendarId !== "iso8601" && t.calendarId !== "gregory") {
84
82
  throw new RangeError(`Calendar "${t.calendarId}" is not supported.`);
85
83
  }
86
84
  const hasDate = t.year !== undefined && t.month !== undefined && t.day !== undefined;
@@ -88,9 +86,7 @@ export function fromTemporalLike(object) {
88
86
  if (!hasDate && !hasTime) {
89
87
  throw new TypeError("Not a Temporal-like date or time object.");
90
88
  }
91
- const time = hasTime
92
- ? plainTime(t.hour, t.minute, t.second ?? 0)
93
- : undefined;
89
+ const time = hasTime ? plainTime(t.hour, t.minute, t.second ?? 0) : undefined;
94
90
  if (!hasDate) {
95
91
  return time;
96
92
  }
@@ -27,11 +27,7 @@ export function civilFromDays(epochDay) {
27
27
  const z = epochDay + 719468;
28
28
  const era = Math.floor(z / 146097);
29
29
  const doe = z - era * 146097;
30
- const yoe = Math.floor((doe -
31
- Math.floor(doe / 1460) +
32
- Math.floor(doe / 36524) -
33
- Math.floor(doe / 146096)) /
34
- 365);
30
+ const yoe = Math.floor((doe - Math.floor(doe / 1460) + Math.floor(doe / 36524) - Math.floor(doe / 146096)) / 365);
35
31
  const doy = doe - (365 * yoe + Math.floor(yoe / 4) - Math.floor(yoe / 100));
36
32
  const mp = Math.floor((5 * doy + 2) / 153);
37
33
  const day = doy - Math.floor((153 * mp + 2) / 5) + 1;
@@ -1,6 +1,6 @@
1
1
  export type { DateInput, DateTimeInput, DayOfWeek, Disambiguation, Overflow, PlainDate, PlainDateTime, PlainTime, TimeInput, WeekInfo, ZonedDateTime, } from "./types.js";
2
2
  export { addDays, addMonths, addWeeks, addYears, dayOfWeek, dayOfWeekFromEpochDay, dayOfYear, daysInMonth, daysInYear, diffDays, endOfMonth, endOfWeek, endOfYear, fromEpochDay, isLeapYear, isValidDate, plainDate, startOfMonth, startOfWeek, startOfYear, toEpochDay, } from "./plain-date.js";
3
- export { addMinutes, addSeconds, fromSecondOfDay, plainTime, toSecondOfDay, } from "./plain-time.js";
3
+ export { addMinutes, addSeconds, fromSecondOfDay, plainTime, toSecondOfDay } from "./plain-time.js";
4
4
  export { plainDateTime } from "./plain-date-time.js";
5
5
  export { compare, isAfter, isBefore, isSameDay, isSameMonth, isSameTime, isSameYear, maxValue, minValue, } from "./compare.js";
6
6
  export { getIsoWeek, getLocaleWeek } from "./week.js";
@@ -1,5 +1,5 @@
1
1
  export { addDays, addMonths, addWeeks, addYears, dayOfWeek, dayOfWeekFromEpochDay, dayOfYear, daysInMonth, daysInYear, diffDays, endOfMonth, endOfWeek, endOfYear, fromEpochDay, isLeapYear, isValidDate, plainDate, startOfMonth, startOfWeek, startOfYear, toEpochDay, } from "./plain-date.js";
2
- export { addMinutes, addSeconds, fromSecondOfDay, plainTime, toSecondOfDay, } from "./plain-time.js";
2
+ export { addMinutes, addSeconds, fromSecondOfDay, plainTime, toSecondOfDay } from "./plain-time.js";
3
3
  export { plainDateTime } from "./plain-date-time.js";
4
4
  export { compare, isAfter, isBefore, isSameDay, isSameMonth, isSameTime, isSameYear, maxValue, minValue, } from "./compare.js";
5
5
  export { getIsoWeek, getLocaleWeek } from "./week.js";
@@ -1,7 +1,7 @@
1
1
  import { plainDateTime } from "./plain-date-time.js";
2
2
  import { plainDate } from "./plain-date.js";
3
3
  import { plainTime } from "./plain-time.js";
4
- import { fromInstant, isValidTimeZone, parseOffsetId, toInstant, } from "./zoned.js";
4
+ import { fromInstant, isValidTimeZone, parseOffsetId, toInstant } from "./zoned.js";
5
5
  const DATE = "(\\d{4})-(\\d{2})-(\\d{2})";
6
6
  const TIME = "(\\d{2}):(\\d{2})(?::(\\d{2})(?:[.,]\\d{1,9})?)?";
7
7
  const DATE_RE = new RegExp(`^${DATE}$`);
@@ -33,9 +33,7 @@ export function parseIsoTime(text) {
33
33
  /** `YYYY-MM-DDTHH:mm[:ss]`. */
34
34
  export function parseIsoDateTime(text) {
35
35
  const match = DATE_TIME_RE.exec(text);
36
- return match
37
- ? plainDateTime(dateFrom(match), timeFrom(match, 4))
38
- : invalid("date-time", text);
36
+ return match ? plainDateTime(dateFrom(match), timeFrom(match, 4)) : invalid("date-time", text);
39
37
  }
40
38
  function offsetFrom(text) {
41
39
  return text === "Z" ? 0 : parseOffsetId(text);
@@ -20,9 +20,7 @@ export function toSecondOfDay(time) {
20
20
  return time.hour * 3600 + time.minute * 60 + time.second;
21
21
  }
22
22
  export function fromSecondOfDay(secondOfDay) {
23
- if (!Number.isInteger(secondOfDay) ||
24
- secondOfDay < 0 ||
25
- secondOfDay >= SECONDS_PER_DAY) {
23
+ if (!Number.isInteger(secondOfDay) || secondOfDay < 0 || secondOfDay >= SECONDS_PER_DAY) {
26
24
  throw new RangeError(`Second of day out of range: ${secondOfDay}.`);
27
25
  }
28
26
  return Object.freeze({
@@ -1,4 +1,4 @@
1
- import { civilFromDays, daysFromCivil, floorDiv, MAX_YEAR, MIN_YEAR, } from "./epoch-day.js";
1
+ import { civilFromDays, daysFromCivil, floorDiv, MAX_YEAR, MIN_YEAR } from "./epoch-day.js";
2
2
  import { plainDateTime, wallSeconds } from "./plain-date-time.js";
3
3
  import { fromSecondOfDay } from "./plain-time.js";
4
4
  import { fromEpochDay, plainDate } from "./plain-date.js";
@@ -136,10 +136,7 @@ export function toZoned(dateTime, timeZone, disambiguation = "compatible") {
136
136
  throw new RangeError(`${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute} is ambiguous in ${timeZone}.`);
137
137
  }
138
138
  // Larger offset = earlier instant.
139
- offset =
140
- disambiguation === "later"
141
- ? Math.min(before, after)
142
- : Math.max(before, after);
139
+ offset = disambiguation === "later" ? Math.min(before, after) : Math.max(before, after);
143
140
  }
144
141
  else {
145
142
  if (disambiguation === "reject") {
@@ -1,7 +1,7 @@
1
1
  import { type PlainTime } from "../../foundation/index.js";
2
2
  import type { HourCycle, TimeGranularity } from "../types.js";
3
3
  export type TimeParseContext = {
4
- locale?: string;
4
+ locale?: string | undefined;
5
5
  hourCycle?: HourCycle;
6
6
  granularity?: TimeGranularity;
7
7
  };
@@ -63,9 +63,7 @@ export function parseTime(text, context = {}) {
63
63
  else
64
64
  return { error: "unparseable" };
65
65
  }
66
- else if (numbers.length >= 1 &&
67
- numbers.length <= 3 &&
68
- separators >= numbers.length - 1) {
66
+ else if (numbers.length >= 1 && numbers.length <= 3 && separators >= numbers.length - 1) {
69
67
  hour = numbers[0].value;
70
68
  minute = numbers[1]?.value ?? 0;
71
69
  second = numbers[2]?.value ?? 0;
@@ -5,43 +5,43 @@ import { type TimeValidity } from "./validity.js";
5
5
  export type TimeInputOptions = {
6
6
  id?: string;
7
7
  value?: TimeValue;
8
- defaultValue?: TimeValue;
8
+ defaultValue?: TimeValue | undefined;
9
9
  onValueChange?: (value: TimeValue) => void;
10
10
  /** On blur or Enter with a valid value. */
11
11
  onValueCommit?: (value: PlainTime) => void;
12
- mode?: "segmented" | "text";
13
- granularity?: TimeGranularity;
14
- hourCycle?: HourCycle;
12
+ mode?: "segmented" | "text" | undefined;
13
+ granularity?: TimeGranularity | undefined;
14
+ hourCycle?: HourCycle | undefined;
15
15
  step?: {
16
16
  minutes?: number;
17
17
  seconds?: number;
18
- };
18
+ } | undefined;
19
19
  /** The value ↑/↓ starts from on an empty part (default: now, rounded down to the step). */
20
20
  placeholderValue?: TimeInput;
21
21
  parse?: (text: string, context: TimeParseContext) => PlainTime | null;
22
22
  format?: (time: PlainTime, context: {
23
- locale?: string;
23
+ locale?: string | undefined;
24
24
  hourCycle: HourCycle;
25
25
  }) => string;
26
- onInvalidInput?: (text: string) => void;
26
+ onInvalidInput?: ((text: string) => void) | undefined;
27
27
  name?: string;
28
- required?: boolean;
29
- readOnly?: boolean;
30
- disabled?: boolean;
31
- min?: TimeInput;
32
- max?: TimeInput;
28
+ required?: boolean | undefined;
29
+ readOnly?: boolean | undefined;
30
+ disabled?: boolean | undefined;
31
+ min?: TimeInput | undefined;
32
+ max?: TimeInput | undefined;
33
33
  disabledRanges?: readonly {
34
34
  start: TimeInput;
35
35
  end: TimeInput;
36
36
  }[];
37
- isTimeDisabled?: (time: PlainTime) => boolean;
38
- isTimeUnavailable?: (time: PlainTime) => boolean;
37
+ isTimeDisabled?: ((time: PlainTime) => boolean) | undefined;
38
+ isTimeUnavailable?: ((time: PlainTime) => boolean) | undefined;
39
39
  /** Availability model (plan 11 V6): `daily` rules only. */
40
40
  availability?: AvailabilitySpec | Availability;
41
- locale?: string;
42
- timeZone?: string;
43
- now?: number;
44
- messages?: Partial<Messages>;
41
+ locale?: string | undefined;
42
+ timeZone?: string | undefined;
43
+ now?: number | undefined;
44
+ messages?: Partial<Messages> | undefined;
45
45
  /** Internal: called when focus tries to leave the first (-1) or last (1) part. */
46
46
  onFocusEdge?: (direction: 1 | -1) => void;
47
47
  };