@leonardaustin/ui 0.26.2 → 0.27.0

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.
@@ -1,7 +1,7 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { mergeRefs as t } from "../../lib/mergeRefs.js";
3
- import { calendarDateFromParts as n, calendarDateParts as r } from "../../lib/calendar.js";
4
- import { MONTHS_LONG as i } from "../../lib/months.js";
3
+ import { MONTHS_LONG as n } from "../../lib/months.js";
4
+ import { calendarDateFromParts as r, calendarDateParts as i } from "../../lib/calendar.js";
5
5
  import { useRef as a, useState as o } from "react";
6
6
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
7
  import { ChevronLeft as l, ChevronRight as u } from "lucide-react";
@@ -16,8 +16,8 @@ var d = [
16
16
  "Su"
17
17
  ];
18
18
  function f(e, t, n) {
19
- let i = r(e, n), a = r(t, n);
20
- return i.year === a.year && i.month === a.month && i.day === a.day;
19
+ let r = i(e, n), a = i(t, n);
20
+ return r.year === a.year && r.month === a.month && r.day === a.day;
21
21
  }
22
22
  function p(e, t, n) {
23
23
  if (!t || !n) return !1;
@@ -34,7 +34,7 @@ function h(e, t) {
34
34
  function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEnd: x, hoverDate: S, onSelect: C, onMonthChange: w, onHover: T, minDate: E, maxDate: D, className: O, ref: k, ...A }) {
35
35
  let j = m(g, _), M = h(g, _), N = /* @__PURE__ */ new Date(), P = a(null), [F, I] = o(null);
36
36
  function L() {
37
- return F !== null && F >= 1 && F <= j ? F : y && r(y, v).year === g && r(y, v).month - 1 === _ ? r(y, v).day : b && r(b, v).year === g && r(b, v).month - 1 === _ ? r(b, v).day : r(N, v).year === g && r(N, v).month - 1 === _ ? r(N, v).day : 1;
37
+ return F !== null && F >= 1 && F <= j ? F : y && i(y, v).year === g && i(y, v).month - 1 === _ ? i(y, v).day : b && i(b, v).year === g && i(b, v).month - 1 === _ ? i(b, v).day : i(N, v).year === g && i(N, v).month - 1 === _ ? i(N, v).day : 1;
38
38
  }
39
39
  let R = L();
40
40
  function z(e, t) {
@@ -85,7 +85,7 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
85
85
  className: "text-text-primary text-xs font-semibold",
86
86
  "aria-live": "polite",
87
87
  children: [
88
- i[_],
88
+ n[_],
89
89
  " ",
90
90
  g
91
91
  ]
@@ -103,9 +103,9 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
103
103
  children: [d.map((e) => /* @__PURE__ */ s("div", {
104
104
  className: "text-text-tertiary text-2xs flex h-8 items-center justify-center font-medium",
105
105
  children: e
106
- }, e)), H.map((t, r) => {
107
- if (t === null) return /* @__PURE__ */ s("div", { className: "h-8" }, `empty-${r}`);
108
- let a = n({
106
+ }, e)), H.map((t, i) => {
107
+ if (t === null) return /* @__PURE__ */ s("div", { className: "h-8" }, `empty-${i}`);
108
+ let a = r({
109
109
  year: g,
110
110
  month: _ + 1,
111
111
  day: t,
@@ -119,7 +119,7 @@ function g({ year: g, month: _, timeZone: v, selected: y, rangeStart: b, rangeEn
119
119
  "data-day": t,
120
120
  disabled: !!m,
121
121
  tabIndex: t === R ? 0 : -1,
122
- "aria-label": `${i[_]} ${t}, ${g}`,
122
+ "aria-label": `${n[_]} ${t}, ${g}`,
123
123
  "aria-current": o ? "date" : void 0,
124
124
  onClick: () => C(a),
125
125
  onKeyDown: (e) => z(e, t),
@@ -13,7 +13,7 @@ export interface DatePickerProps extends Omit<ComponentPropsWithRef<"div">, "chi
13
13
  /** Called with the chosen date. */
14
14
  onValueChange?: (date: Date | null) => void;
15
15
  placeholder?: string;
16
- /** Format function for display. Defaults to "MMM D, YYYY". */
16
+ /** Formats the trigger date. Defaults to en-GB, e.g. "25 Oct 2026". */
17
17
  format?: (date: Date) => string;
18
18
  }
19
19
  export declare function DatePicker({ controlSize, label, timeZone, value: valueProp, defaultValue, onValueChange, placeholder, format, ref, ...rest }: DatePickerProps): import("react/jsx-runtime").JSX.Element;
@@ -3,19 +3,14 @@ import { mergeRefs as t } from "../../lib/mergeRefs.js";
3
3
  import { useControlSize as n } from "../../providers/ControlSizeContext.js";
4
4
  import { useControllableState as r } from "../../hooks/useControllableState.js";
5
5
  import { usePopover as i } from "../../hooks/usePopover.js";
6
- import { calendarDateParts as a } from "../../lib/calendar.js";
7
- import { MONTHS_SHORT as o } from "../../lib/months.js";
6
+ import { calendarDateParts as a, formatPickerDate as o } from "../../lib/calendar.js";
8
7
  import { CalendarGrid as s } from "./CalendarGrid.js";
9
8
  import { useMemo as c, useState as l } from "react";
10
9
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
10
  import { Calendar as f } from "lucide-react";
12
11
  //#region src/components/ui/DatePicker.tsx
13
- function p(e, t) {
14
- let { year: n, month: r, day: i } = a(e, t);
15
- return `${o[r - 1]} ${i}, ${n}`;
16
- }
17
- function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ = null, onValueChange: v, placeholder: y = "Select date...", format: b, ref: x, ...S }) {
18
- let C = n(o), [w, T] = r({
12
+ function p({ controlSize: p, label: m, timeZone: h, value: g, defaultValue: _ = null, onValueChange: v, placeholder: y = "Select date...", format: b, ref: x, ...S }) {
13
+ let C = n(p), [w, T] = r({
19
14
  value: g,
20
15
  defaultValue: _,
21
16
  onChange: v
@@ -53,7 +48,7 @@ function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ =
53
48
  onClick: H,
54
49
  "data-control-size": C,
55
50
  className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
56
- children: w ? b ? b(w) : p(w, h) : /* @__PURE__ */ u("span", {
51
+ children: w ? b ? b(w) : o(w, h) : /* @__PURE__ */ u("span", {
57
52
  className: "text-text-placeholder",
58
53
  children: y
59
54
  })
@@ -81,4 +76,4 @@ function m({ controlSize: o, label: m, timeZone: h, value: g, defaultValue: _ =
81
76
  });
82
77
  }
83
78
  //#endregion
84
- export { m as DatePicker };
79
+ export { p as DatePicker };
@@ -17,5 +17,7 @@ export interface DateRangePickerProps extends Omit<ComponentPropsWithRef<"div">,
17
17
  onValueChange?: (range: DateRange) => void;
18
18
  /** Text shown when no range is selected. Defaults to "Select date range...". */
19
19
  placeholder?: string;
20
+ /** Formats each date in the trigger. Defaults to en-GB, e.g. "25 Oct 2026". */
21
+ format?: (date: Date) => string;
20
22
  }
21
- export declare function DateRangePicker({ controlSize, label, value: valueProp, defaultValue, onValueChange, placeholder, ref, className, ...rest }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
23
+ export declare function DateRangePicker({ controlSize, label, value: valueProp, defaultValue, onValueChange, placeholder, format, ref, className, ...rest }: DateRangePickerProps): import("react/jsx-runtime").JSX.Element;
@@ -3,79 +3,73 @@ import { mergeRefs as t } from "../../lib/mergeRefs.js";
3
3
  import { useControlSize as n } from "../../providers/ControlSizeContext.js";
4
4
  import { useControllableState as r } from "../../hooks/useControllableState.js";
5
5
  import { usePopover as i } from "../../hooks/usePopover.js";
6
- import { MONTHS_SHORT as a } from "../../lib/months.js";
6
+ import { formatPickerDate as a } from "../../lib/calendar.js";
7
7
  import { CalendarGrid as o } from "./CalendarGrid.js";
8
8
  import { useMemo as s, useState as c } from "react";
9
9
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
10
  import { Calendar as d } from "lucide-react";
11
11
  //#region src/components/ui/DateRangePicker.tsx
12
- function f(e) {
13
- return `${a[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`;
14
- }
15
- function p(e) {
16
- return e.start && e.end ? `${f(e.start)} – ${f(e.end)}` : e.start ? f(e.start) : "";
17
- }
18
- var m = {
12
+ var f = {
19
13
  start: null,
20
14
  end: null
21
15
  };
22
- function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueChange: _, placeholder: v = "Select date range...", ref: y, className: b, ...x }) {
23
- let S = n(a), [C, w] = r({
16
+ function p({ controlSize: p, label: m, value: h, defaultValue: g = f, onValueChange: _, placeholder: v = "Select date range...", format: y = a, ref: b, className: x, ...S }) {
17
+ let C = n(p), [w, T] = r({
24
18
  value: h,
25
19
  defaultValue: g,
26
20
  onChange: _
27
- }), { open: T, show: E, close: D, rootRef: O, anchorRef: k, triggerRef: A, popupRef: j, labelId: M, popupId: N, triggerAria: P } = i({
21
+ }), { open: E, show: D, close: O, rootRef: k, anchorRef: ee, triggerRef: te, popupRef: A, labelId: j, popupId: M, triggerAria: N } = i({
28
22
  haspopup: "dialog",
29
- labelled: !!f
30
- }), F = s(() => t(y, O), [y, O]), I = /* @__PURE__ */ new Date(), [L, R] = c(C.start?.getFullYear() ?? I.getFullYear()), [z, B] = c(C.start?.getMonth() ?? I.getMonth()), [V, H] = c(null), [U, W] = c("start"), [G, K] = c(C.start), [q, J] = c(C.end), Y = z === 11 ? L + 1 : L, X = z === 11 ? 0 : z + 1;
31
- function Z() {
32
- if (T) {
33
- D("toggle");
23
+ labelled: !!m
24
+ }), P = s(() => t(b, k), [b, k]), F = /* @__PURE__ */ new Date(), [I, L] = c(w.start?.getFullYear() ?? F.getFullYear()), [R, z] = c(w.start?.getMonth() ?? F.getMonth()), [B, V] = c(null), [H, U] = c("start"), [W, G] = c(w.start), [K, q] = c(w.end), J = R === 11 ? I + 1 : I, Y = R === 11 ? 0 : R + 1;
25
+ function X() {
26
+ if (E) {
27
+ O("toggle");
34
28
  return;
35
29
  }
36
- K(C.start), J(C.end), W("start"), C.start && (R(C.start.getFullYear()), B(C.start.getMonth())), E();
30
+ G(w.start), q(w.end), U("start"), w.start && (L(w.start.getFullYear()), z(w.start.getMonth())), D();
37
31
  }
38
- function Q(e) {
39
- U === "start" ? (K(e), J(null), W("end")) : (G && e < G ? (J(G), K(e)) : J(e), W("start"), w({
40
- start: G && e < G ? e : G,
41
- end: G && e < G ? G : e
42
- }), D("select"));
32
+ function Z(e) {
33
+ H === "start" ? (G(e), q(null), U("end")) : (W && e < W ? (q(W), G(e)) : q(e), U("start"), T({
34
+ start: W && e < W ? e : W,
35
+ end: W && e < W ? W : e
36
+ }), O("select"));
43
37
  }
44
- function $() {
45
- z === 0 ? (R(L - 1), B(11)) : B(z - 1);
38
+ function ne() {
39
+ R === 0 ? (L(I - 1), z(11)) : z(R - 1);
46
40
  }
47
- function ee() {
48
- z === 11 ? (R(L + 1), B(0)) : B(z + 1);
41
+ function re() {
42
+ R === 11 ? (L(I + 1), z(0)) : z(R + 1);
49
43
  }
50
- let te = C.start || C.end ? p(C) : "";
44
+ let { start: Q, end: $ } = w;
51
45
  return /* @__PURE__ */ u("div", {
52
- ...x,
53
- ref: F,
54
- className: e("flex flex-col gap-1.5", b),
55
- children: [f && /* @__PURE__ */ l("span", {
56
- id: M,
46
+ ...S,
47
+ ref: P,
48
+ className: e("flex flex-col gap-1.5", x),
49
+ children: [m && /* @__PURE__ */ l("span", {
50
+ id: j,
57
51
  className: "ui-field-label text-xs font-medium",
58
- children: f
52
+ children: m
59
53
  }), /* @__PURE__ */ u("div", {
60
54
  className: "relative",
61
- ref: k,
55
+ ref: ee,
62
56
  children: [
63
57
  /* @__PURE__ */ l("button", {
64
58
  type: "button",
65
- ref: A,
66
- ...P,
67
- onClick: Z,
68
- "data-control-size": S,
59
+ ref: te,
60
+ ...N,
61
+ onClick: X,
62
+ "data-control-size": C,
69
63
  className: e("ui-sized-control flex h-7 w-full cursor-pointer items-center rounded-md text-xs", "bg-bg-secondary border-border text-text-primary border", "hover:bg-bg-hover hover:border-border-strong", "transition-colors duration-[100ms]", "px-2 pr-7"),
70
- children: te || /* @__PURE__ */ l("span", {
64
+ children: Q ? $ ? `${y(Q)} – ${y($)}` : y(Q) : /* @__PURE__ */ l("span", {
71
65
  className: "text-text-placeholder",
72
66
  children: v
73
67
  })
74
68
  }),
75
69
  /* @__PURE__ */ l(d, { className: "text-text-tertiary pointer-events-none absolute top-1/2 right-2 h-3 w-3 -translate-y-1/2" }),
76
- T && /* @__PURE__ */ u("div", {
77
- ref: j,
78
- id: N,
70
+ E && /* @__PURE__ */ u("div", {
71
+ ref: A,
72
+ id: M,
79
73
  role: "dialog",
80
74
  "aria-label": "Choose date range",
81
75
  className: e("ui-glass ui-glass-popover bg-bg-tertiary border-border-strong animate-scale-in fixed top-0 left-0 z-[100] rounded-md border shadow-lg", "p-3"),
@@ -84,7 +78,7 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
84
78
  children: [
85
79
  /* @__PURE__ */ l("button", {
86
80
  type: "button",
87
- onClick: $,
81
+ onClick: ne,
88
82
  "aria-label": "Previous month",
89
83
  className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
90
84
  children: /* @__PURE__ */ l("span", {
@@ -95,11 +89,11 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
95
89
  /* @__PURE__ */ l("span", {
96
90
  className: "text-text-tertiary text-2xs",
97
91
  "aria-live": "polite",
98
- children: U === "start" ? "Select start date" : "Select end date"
92
+ children: H === "start" ? "Select start date" : "Select end date"
99
93
  }),
100
94
  /* @__PURE__ */ l("button", {
101
95
  type: "button",
102
- onClick: ee,
96
+ onClick: re,
103
97
  "aria-label": "Next month",
104
98
  className: "text-text-tertiary hover:text-text-primary hover:bg-bg-hover flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-[100ms]",
105
99
  children: /* @__PURE__ */ l("span", {
@@ -111,27 +105,27 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
111
105
  }), /* @__PURE__ */ u("div", {
112
106
  className: "flex gap-4",
113
107
  children: [/* @__PURE__ */ l(o, {
114
- year: L,
115
- month: z,
116
- rangeStart: G,
117
- rangeEnd: q,
118
- hoverDate: U === "end" ? V : null,
119
- onSelect: Q,
108
+ year: I,
109
+ month: R,
110
+ rangeStart: W,
111
+ rangeEnd: K,
112
+ hoverDate: H === "end" ? B : null,
113
+ onSelect: Z,
120
114
  onMonthChange: (e, t) => {
121
- R(e), B(t);
115
+ L(e), z(t);
122
116
  },
123
- onHover: H
117
+ onHover: V
124
118
  }), /* @__PURE__ */ l(o, {
125
- year: Y,
126
- month: X,
127
- rangeStart: G,
128
- rangeEnd: q,
129
- hoverDate: U === "end" ? V : null,
130
- onSelect: Q,
119
+ year: J,
120
+ month: Y,
121
+ rangeStart: W,
122
+ rangeEnd: K,
123
+ hoverDate: H === "end" ? B : null,
124
+ onSelect: Z,
131
125
  onMonthChange: (e, t) => {
132
- t === 0 ? (R(e - 1), B(11)) : (R(e), B(t - 1));
126
+ t === 0 ? (L(e - 1), z(11)) : (L(e), z(t - 1));
133
127
  },
134
- onHover: H
128
+ onHover: V
135
129
  })]
136
130
  })]
137
131
  })
@@ -140,4 +134,4 @@ function h({ controlSize: a, label: f, value: h, defaultValue: g = m, onValueCha
140
134
  });
141
135
  }
142
136
  //#endregion
143
- export { h as DateRangePicker };
137
+ export { p as DateRangePicker };
@@ -4,8 +4,8 @@ import { clamp as n } from "../../lib/math.js";
4
4
  import { useControlSize as r } from "../../providers/ControlSizeContext.js";
5
5
  import { useControllableState as i } from "../../hooks/useControllableState.js";
6
6
  import { usePopover as a } from "../../hooks/usePopover.js";
7
- import { calendarDateFromParts as o, calendarDateParts as s } from "../../lib/calendar.js";
8
- import { MONTHS_SHORT as c } from "../../lib/months.js";
7
+ import { MONTHS_SHORT as o } from "../../lib/months.js";
8
+ import { calendarDateFromParts as s, calendarDateParts as c } from "../../lib/calendar.js";
9
9
  import { CalendarGrid as l } from "./CalendarGrid.js";
10
10
  import { useId as u, useMemo as d, useState as f } from "react";
11
11
  import { jsx as p, jsxs as m } from "react/jsx-runtime";
@@ -40,8 +40,8 @@ function v(e, t) {
40
40
  timeZoneName: "short",
41
41
  hourCycle: "h23"
42
42
  }).format(e);
43
- let n = c[e.getMonth()], r = e.getDate(), i = e.getFullYear(), { hour12: a, period: o } = g(e.getHours());
44
- return `${n} ${r}, ${i} ${a}:${String(e.getMinutes()).padStart(2, "0")} ${o}`;
43
+ let n = o[e.getMonth()], r = e.getDate(), i = e.getFullYear(), { hour12: a, period: s } = g(e.getHours());
44
+ return `${n} ${r}, ${i} ${a}:${String(e.getMinutes()).padStart(2, "0")} ${s}`;
45
45
  }
46
46
  function y(e) {
47
47
  return String(e).padStart(2, "0");
@@ -58,14 +58,14 @@ function b({ value: e, defaultValue: t = null, onValueChange: n, ...r }) {
58
58
  onValueChange: o
59
59
  }, r.timeZone ?? "browser-local");
60
60
  }
61
- function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S, placeholder: C = "Select date & time...", ref: w, className: T, ...E }) {
61
+ function x({ controlSize: i, label: o, timeZone: b, value: x, onValueChange: S, placeholder: C = "Select date & time...", ref: w, className: T, ...E }) {
62
62
  let D = r(i), { open: O, show: k, close: A, rootRef: j, anchorRef: ee, triggerRef: te, popupRef: ne, labelId: re, popupId: ie, triggerAria: ae } = a({
63
63
  haspopup: "dialog",
64
- labelled: !!c
65
- }), oe = d(() => t(w, j), [w, j]), [M, N] = f(null), [P, F] = f(!1), [I, L] = f("reject"), R = u(), z = s(x ?? /* @__PURE__ */ new Date(), b), B = x ? g(s(x, b).hour) : {
64
+ labelled: !!o
65
+ }), oe = d(() => t(w, j), [w, j]), [M, N] = f(null), [P, F] = f(!1), [I, L] = f("reject"), R = u(), z = c(x ?? /* @__PURE__ */ new Date(), b), B = x ? g(c(x, b).hour) : {
66
66
  hour12: 12,
67
67
  period: "PM"
68
- }, [V, H] = f(z.year), [U, W] = f(z.month - 1), [G, K] = f(String(B.hour12)), [q, J] = f(x ? y(s(x, b).minute) : "00"), [Y, X] = f(B.period), [Z, Q] = f(x);
68
+ }, [V, H] = f(z.year), [U, W] = f(z.month - 1), [G, K] = f(String(B.hour12)), [q, J] = f(x ? y(c(x, b).minute) : "00"), [Y, X] = f(B.period), [Z, Q] = f(x);
69
69
  function se(e) {
70
70
  Q(e);
71
71
  }
@@ -78,28 +78,28 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
78
78
  function le() {
79
79
  if (!Z) return;
80
80
  let e = n(parseInt(G, 10) || 12, 1, 12), t = n(parseInt(q, 10) || 0, 0, 59), r = _(e, Y), i = {
81
- ...s(Z, b),
81
+ ...c(Z, b),
82
82
  hour: r,
83
83
  minute: t,
84
84
  second: 0,
85
85
  millisecond: 0
86
- }, a = x ? s(x, b) : null, c;
86
+ }, a = x ? c(x, b) : null, o;
87
87
  try {
88
- c = I === "reject" && x && a && [
88
+ o = I === "reject" && x && a && [
89
89
  "year",
90
90
  "month",
91
91
  "day",
92
92
  "hour",
93
93
  "minute"
94
- ].every((e) => a[e] === i[e]) ? new Date(x) : o(i, b, I);
95
- let e = s(c, b);
94
+ ].every((e) => a[e] === i[e]) ? new Date(x) : s(i, b, I);
95
+ let e = c(o, b);
96
96
  if (e.hour !== r || e.minute !== t || e.day !== i.day) throw RangeError("This time does not exist in the selected timezone");
97
97
  } catch (e) {
98
98
  let t = e instanceof Error ? e.message : "Invalid date and time";
99
99
  N(t), F(t.includes("twice"));
100
100
  return;
101
101
  }
102
- N(null), S(c), A("select");
102
+ N(null), S(o), A("select");
103
103
  }
104
104
  function $() {
105
105
  if (O) {
@@ -107,14 +107,14 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
107
107
  return;
108
108
  }
109
109
  if (x) {
110
- H(s(x, b).year), W(s(x, b).month - 1), Q(x);
111
- let e = g(s(x, b).hour);
112
- K(String(e.hour12)), X(e.period), J(y(s(x, b).minute));
110
+ H(c(x, b).year), W(c(x, b).month - 1), Q(x);
111
+ let e = g(c(x, b).hour);
112
+ K(String(e.hour12)), X(e.period), J(y(c(x, b).minute));
113
113
  }
114
114
  N(null);
115
115
  let e = !1;
116
116
  if (x && b) try {
117
- o(s(x, b), b, "reject");
117
+ s(c(x, b), b, "reject");
118
118
  } catch (t) {
119
119
  e = t instanceof Error && t.message.includes("twice");
120
120
  }
@@ -124,10 +124,10 @@ function x({ controlSize: i, label: c, timeZone: b, value: x, onValueChange: S,
124
124
  ...E,
125
125
  ref: oe,
126
126
  className: e("flex flex-col gap-1.5", T),
127
- children: [c && /* @__PURE__ */ p("span", {
127
+ children: [o && /* @__PURE__ */ p("span", {
128
128
  id: re,
129
129
  className: "ui-field-label text-xs font-medium",
130
- children: c
130
+ children: o
131
131
  }), /* @__PURE__ */ m("div", {
132
132
  className: "relative",
133
133
  ref: ee,
@@ -155,6 +155,8 @@ export declare function getMonthWeeks(date: Date, weekStartsOn?: Weekday): Date[
155
155
  export declare function getViewRange(view: CalendarView, date: Date, options?: CalendarViewOptions): DateRange;
156
156
  /** The anchor date one page before (-1) or after (1) `date`. */
157
157
  export declare function shiftDate(view: CalendarView, date: Date, direction: -1 | 1, options?: CalendarViewOptions): Date;
158
+ /** Default picker display in en-GB order, e.g. "25 Oct 2026". */
159
+ export declare function formatPickerDate(date: Date, timeZone?: string): string;
158
160
  /** Cached `Intl.DateTimeFormat`. */
159
161
  export declare function getFormatter(locale: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
160
162
  export interface FormatOptions {
@@ -1,8 +1,9 @@
1
1
  import { clamp as e } from "./math.js";
2
+ import { MONTHS_SHORT as t } from "./months.js";
2
3
  //#region src/lib/calendar.ts
3
- var t = /* @__PURE__ */ new Map();
4
- function n(e, n) {
5
- if (!n) return {
4
+ var n = /* @__PURE__ */ new Map();
5
+ function r(e, t) {
6
+ if (!t) return {
6
7
  year: e.getFullYear(),
7
8
  month: e.getMonth() + 1,
8
9
  day: e.getDate(),
@@ -11,9 +12,9 @@ function n(e, n) {
11
12
  second: e.getSeconds(),
12
13
  millisecond: e.getMilliseconds()
13
14
  };
14
- let r = t.get(n);
15
+ let r = n.get(t);
15
16
  r || (r = new Intl.DateTimeFormat("en-GB-u-ca-iso8601-nu-latn", {
16
- timeZone: n,
17
+ timeZone: t,
17
18
  year: "numeric",
18
19
  month: "2-digit",
19
20
  day: "2-digit",
@@ -21,7 +22,7 @@ function n(e, n) {
21
22
  minute: "2-digit",
22
23
  second: "2-digit",
23
24
  hourCycle: "h23"
24
- }), t.set(n, r));
25
+ }), n.set(t, r));
25
26
  let i = {};
26
27
  for (let t of r.formatToParts(e)) t.type !== "literal" && (i[t.type] = Number(t.value));
27
28
  return {
@@ -34,12 +35,12 @@ function n(e, n) {
34
35
  millisecond: e.getUTCMilliseconds()
35
36
  };
36
37
  }
37
- function r(e) {
38
+ function i(e) {
38
39
  let t = /* @__PURE__ */ new Date(0);
39
40
  return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, e.millisecond), t.getTime();
40
41
  }
41
- function i(e, t, i = "compatible") {
42
- let a = r(e), o = new Date(a);
42
+ function a(e, t, n = "compatible") {
43
+ let a = i(e), o = new Date(a);
43
44
  if (!Object.values(e).every(Number.isInteger) || o.getUTCFullYear() !== e.year || o.getUTCMonth() + 1 !== e.month || o.getUTCDate() !== e.day || o.getUTCHours() !== e.hour || o.getUTCMinutes() !== e.minute || o.getUTCSeconds() !== e.second || o.getUTCMilliseconds() !== e.millisecond) throw RangeError("Invalid civil date and time");
44
45
  if (!t) {
45
46
  let t = /* @__PURE__ */ new Date(0);
@@ -53,152 +54,156 @@ function i(e, t, i = "compatible") {
53
54
  24,
54
55
  48
55
56
  ]) {
56
- let i = a + e * 36e5;
57
- s.add(r(n(new Date(i), t)) - i);
57
+ let n = a + e * 36e5;
58
+ s.add(i(r(new Date(n), t)) - n);
58
59
  }
59
- let c = [...s].map((e) => a - e).sort((e, t) => e - t), l = c.filter((e) => r(n(new Date(e), t)) === a);
60
+ let c = [...s].map((e) => a - e).sort((e, t) => e - t), l = c.filter((e) => i(r(new Date(e), t)) === a);
60
61
  if (l.length === 1) return new Date(l[0]);
61
- if (i === "reject") throw RangeError(l.length ? "This time occurs twice in the selected timezone" : "This time does not exist in the selected timezone");
62
- return l.length ? new Date(i === "later" ? l[l.length - 1] : l[0]) : new Date(i === "earlier" ? c[0] : c[c.length - 1]);
62
+ if (n === "reject") throw RangeError(l.length ? "This time occurs twice in the selected timezone" : "This time does not exist in the selected timezone");
63
+ return l.length ? new Date(n === "later" ? l[l.length - 1] : l[0]) : new Date(n === "earlier" ? c[0] : c[c.length - 1]);
63
64
  }
64
- var a = 1440, o = 6e4, s = [
65
+ var o = 1440, s = 6e4, c = [
65
66
  1,
66
67
  2,
67
68
  3,
68
69
  4,
69
70
  5
70
71
  ];
71
- function c(e) {
72
+ function l(e) {
72
73
  return new Date(e.getFullYear(), e.getMonth(), e.getDate());
73
74
  }
74
- function l(e, t) {
75
+ function u(e, t) {
75
76
  return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t, e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
76
77
  }
77
- function u(e, t) {
78
+ function d(e, t) {
78
79
  return new Date(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes() + t, e.getSeconds(), e.getMilliseconds());
79
80
  }
80
- function d(e, t) {
81
+ function f(e, t) {
81
82
  let n = new Date(e.getFullYear(), e.getMonth() + t, 1), r = new Date(n.getFullYear(), n.getMonth() + 1, 0).getDate();
82
83
  return new Date(n.getFullYear(), n.getMonth(), Math.min(e.getDate(), r), e.getHours(), e.getMinutes());
83
84
  }
84
- function f(e, t = 1) {
85
- let n = c(e);
86
- return l(n, -((n.getDay() - t + 7) % 7));
85
+ function p(e, t = 1) {
86
+ let n = l(e);
87
+ return u(n, -((n.getDay() - t + 7) % 7));
87
88
  }
88
- function p(e) {
89
+ function m(e) {
89
90
  return new Date(e.getFullYear(), e.getMonth(), 1);
90
91
  }
91
- function m(e, t) {
92
+ function h(e, t) {
92
93
  return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
93
94
  }
94
- function h(e, t) {
95
+ function g(e, t) {
95
96
  let n = Date.UTC(e.getFullYear(), e.getMonth(), e.getDate()), r = Date.UTC(t.getFullYear(), t.getMonth(), t.getDate());
96
97
  return Math.round((n - r) / 864e5);
97
98
  }
98
- function g(e) {
99
- return e.getHours() * 60 + e.getMinutes() + e.getSeconds() / 60 + e.getMilliseconds() / o;
99
+ function _(e) {
100
+ return e.getHours() * 60 + e.getMinutes() + e.getSeconds() / 60 + e.getMilliseconds() / s;
100
101
  }
101
- function _(e, t) {
102
- let n = v(e, t);
103
- if (!m(n, e) || g(n) <= t) return n;
102
+ function v(e, t) {
103
+ let n = y(e, t);
104
+ if (!h(n, e) || _(n) <= t) return n;
104
105
  let r = Math.floor(t);
105
- for (; r > 0 && g(v(e, r - 1)) !== r - 1;) r--;
106
- return /* @__PURE__ */ new Date(n.getTime() - (t - r) * o);
106
+ for (; r > 0 && _(y(e, r - 1)) !== r - 1;) r--;
107
+ return /* @__PURE__ */ new Date(n.getTime() - (t - r) * s);
107
108
  }
108
- function v(e, t) {
109
+ function y(e, t) {
109
110
  let n = Math.floor(t);
110
111
  return new Date(e.getFullYear(), e.getMonth(), e.getDate(), 0, n, Math.round((t - n) * 60));
111
112
  }
112
- function y(e) {
113
+ function b(e) {
113
114
  let t = /^(\d{1,2}):(\d{2})$/.exec(e.trim());
114
115
  if (!t) throw RangeError(`Invalid time "${e}", expected HH:mm`);
115
116
  let n = Number(t[1]), r = Number(t[2]);
116
117
  if (r > 59 || n > 24 || n === 24 && r > 0) throw RangeError(`Invalid time "${e}"`);
117
118
  return n * 60 + r;
118
119
  }
119
- function b(e) {
120
+ function x(e) {
120
121
  let t = Math.round(e), n = Math.floor(t / 60), r = t % 60;
121
122
  return `${String(n).padStart(2, "0")}:${String(r).padStart(2, "0")}`;
122
123
  }
123
- function x(e) {
124
+ function S(e) {
124
125
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
125
126
  }
126
- function S(e) {
127
+ function C(e) {
127
128
  let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
128
129
  if (!t) throw RangeError(`Invalid date key "${e}"`);
129
130
  let n = new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3]));
130
- if (x(n) !== e) throw RangeError(`Invalid date key "${e}"`);
131
+ if (S(n) !== e) throw RangeError(`Invalid date key "${e}"`);
131
132
  return n;
132
133
  }
133
- function C(e, t, n = "round") {
134
+ function w(e, t, n = "round") {
134
135
  if (t <= 0) return e;
135
136
  let r = n === "floor" ? Math.floor : n === "ceil" ? Math.ceil : Math.round, i = e / t;
136
137
  return r(n === "floor" ? i + 1e-9 : n === "ceil" ? i - 1e-9 : i) * t;
137
138
  }
138
- function w(e, t, n = "round") {
139
- return v(c(e), C(g(e), t, n));
139
+ function T(e, t, n = "round") {
140
+ return y(l(e), w(_(e), t, n));
140
141
  }
141
- function T(e) {
142
+ function E(e) {
142
143
  return e === "day" || e === "threeDay" || e === "workWeek" || e === "week";
143
144
  }
144
- function E(e, t, n = {}) {
145
- let r = n.weekStartsOn ?? 1, i = c(t);
145
+ function D(e, t, n = {}) {
146
+ let r = n.weekStartsOn ?? 1, i = l(t);
146
147
  switch (e) {
147
148
  case "day":
148
149
  case "timeline": return [i];
149
150
  case "threeDay": return [
150
151
  i,
151
- l(i, 1),
152
- l(i, 2)
152
+ u(i, 1),
153
+ u(i, 2)
153
154
  ];
154
155
  case "week": {
155
- let e = f(i, r);
156
- return Array.from({ length: 7 }, (t, n) => l(e, n));
156
+ let e = p(i, r);
157
+ return Array.from({ length: 7 }, (t, n) => u(e, n));
157
158
  }
158
159
  case "workWeek": {
159
- let e = new Set(n.workWeekDays ?? s), t = f(i, r), a = Array.from({ length: 7 }, (e, n) => l(t, n)).filter((t) => e.has(t.getDay()));
160
+ let e = new Set(n.workWeekDays ?? c), t = p(i, r), a = Array.from({ length: 7 }, (e, n) => u(t, n)).filter((t) => e.has(t.getDay()));
160
161
  return a.length ? a : [i];
161
162
  }
162
163
  case "agenda": {
163
164
  let e = Math.max(1, Math.floor(n.agendaDays ?? 7));
164
- return Array.from({ length: e }, (e, t) => l(i, t));
165
+ return Array.from({ length: e }, (e, t) => u(i, t));
165
166
  }
166
- case "month": return D(t, r).flat();
167
+ case "month": return O(t, r).flat();
167
168
  }
168
169
  }
169
- function D(e, t = 1) {
170
- let n = p(e), r = new Date(n.getFullYear(), n.getMonth() + 1, 0), i = f(n, t), a = [], o = i;
170
+ function O(e, t = 1) {
171
+ let n = m(e), r = new Date(n.getFullYear(), n.getMonth() + 1, 0), i = p(n, t), a = [], o = i;
171
172
  for (; o <= r || a.length === 0;) {
172
- let e = Array.from({ length: 7 }, (e, t) => l(o, t));
173
- a.push(e), o = l(o, 7);
173
+ let e = Array.from({ length: 7 }, (e, t) => u(o, t));
174
+ a.push(e), o = u(o, 7);
174
175
  }
175
176
  return a;
176
177
  }
177
- function O(e, t, n = {}) {
178
- let r = E(e, t, n);
178
+ function k(e, t, n = {}) {
179
+ let r = D(e, t, n);
179
180
  return {
180
181
  start: r[0],
181
- end: l(r[r.length - 1], 1)
182
+ end: u(r[r.length - 1], 1)
182
183
  };
183
184
  }
184
- function k(e, t, n, r = {}) {
185
+ function A(e, t, n, r = {}) {
185
186
  switch (e) {
186
187
  case "day":
187
- case "timeline": return l(t, n);
188
- case "threeDay": return l(t, 3 * n);
188
+ case "timeline": return u(t, n);
189
+ case "threeDay": return u(t, 3 * n);
189
190
  case "week":
190
- case "workWeek": return l(t, 7 * n);
191
- case "agenda": return l(t, Math.max(1, r.agendaDays ?? 7) * n);
192
- case "month": return d(t, n);
191
+ case "workWeek": return u(t, 7 * n);
192
+ case "agenda": return u(t, Math.max(1, r.agendaDays ?? 7) * n);
193
+ case "month": return f(t, n);
193
194
  }
194
195
  }
195
- var A = /* @__PURE__ */ new Map();
196
- function j(e, t) {
197
- let n = `${e}|${JSON.stringify(t)}`, r = A.get(n);
198
- return r || (r = new Intl.DateTimeFormat(e, t), A.set(n, r)), r;
196
+ function j(e, n) {
197
+ let { year: i, month: a, day: o } = r(e, n);
198
+ return `${o} ${t[a - 1]} ${i}`;
199
199
  }
200
- function M(e, t = {}) {
201
- return j(t.locale ?? "en-GB", {
200
+ var M = /* @__PURE__ */ new Map();
201
+ function N(e, t) {
202
+ let n = `${e}|${JSON.stringify(t)}`, r = M.get(n);
203
+ return r || (r = new Intl.DateTimeFormat(e, t), M.set(n, r)), r;
204
+ }
205
+ function P(e, t = {}) {
206
+ return N(t.locale ?? "en-GB", {
202
207
  timeZone: t.timeZone,
203
208
  timeZoneName: t.timeZone ? "short" : void 0,
204
209
  hour: t.hour12 ? "numeric" : "2-digit",
@@ -206,71 +211,71 @@ function M(e, t = {}) {
206
211
  hourCycle: t.hour12 ? "h12" : "h23"
207
212
  }).format(e);
208
213
  }
209
- function N(e, t, n = {}) {
210
- return `${M(e, n)}–${M(t, n)}`;
214
+ function F(e, t, n = {}) {
215
+ return `${P(e, n)}–${P(t, n)}`;
211
216
  }
212
- function P(e, t = {}) {
213
- if (!t.hour12) return b(e);
214
- let n = v(new Date(2e3, 0, 1), e);
215
- return j(t.locale ?? "en-GB", {
217
+ function I(e, t = {}) {
218
+ if (!t.hour12) return x(e);
219
+ let n = y(new Date(2e3, 0, 1), e);
220
+ return N(t.locale ?? "en-GB", {
216
221
  hour: "numeric",
217
222
  minute: e % 60 ? "2-digit" : void 0,
218
223
  hour12: !0
219
224
  }).format(n);
220
225
  }
221
- function F(e, t = "en-GB") {
222
- return j(t, {
226
+ function L(e, t = "en-GB") {
227
+ return N(t, {
223
228
  weekday: "long",
224
229
  day: "numeric",
225
230
  month: "long",
226
231
  year: "numeric"
227
232
  }).format(e);
228
233
  }
229
- function I(e, t, n = {}) {
234
+ function R(e, t, n = {}) {
230
235
  let r = n.locale ?? "en-GB";
231
- if (e === "month") return j(r, {
236
+ if (e === "month") return N(r, {
232
237
  month: "long",
233
238
  year: "numeric"
234
239
  }).format(t);
235
- let i = E(e, t, n), a = i[0], o = i[i.length - 1];
236
- if (i.length === 1) return F(a, r);
237
- let s = a.getFullYear() === o.getFullYear(), c = s && a.getMonth() === o.getMonth(), l = j(r, {
240
+ let i = D(e, t, n), a = i[0], o = i[i.length - 1];
241
+ if (i.length === 1) return L(a, r);
242
+ let s = a.getFullYear() === o.getFullYear(), c = s && a.getMonth() === o.getMonth(), l = N(r, {
238
243
  day: "numeric",
239
244
  month: "long",
240
245
  year: "numeric"
241
246
  });
242
247
  if (c) return `${a.getDate()} – ${l.format(o)}`;
243
- let u = j(r, s ? {
248
+ let u = N(r, s ? {
244
249
  day: "numeric",
245
250
  month: "short"
246
251
  } : {
247
252
  day: "numeric",
248
253
  month: "short",
249
254
  year: "numeric"
250
- }), d = j(r, {
255
+ }), d = N(r, {
251
256
  day: "numeric",
252
257
  month: "short",
253
258
  year: "numeric"
254
259
  });
255
260
  return `${u.format(a)} – ${d.format(o)}`;
256
261
  }
257
- function L(e, t, n, r) {
262
+ function z(e, t, n, r) {
258
263
  return e < r && n < t;
259
264
  }
260
- function R(e, t, n) {
261
- let r = c(n), i = l(r, 1), o = e.getTime(), s = Math.max(t.getTime(), o);
262
- if (s === o) {
263
- if (o < r.getTime() || o >= i.getTime()) return null;
264
- } else if (!L(o, s, r.getTime(), i.getTime())) return null;
265
- let u = o < r.getTime(), d = s > i.getTime();
265
+ function B(e, t, n) {
266
+ let r = l(n), i = u(r, 1), a = e.getTime(), s = Math.max(t.getTime(), a);
267
+ if (s === a) {
268
+ if (a < r.getTime() || a >= i.getTime()) return null;
269
+ } else if (!z(a, s, r.getTime(), i.getTime())) return null;
270
+ let c = a < r.getTime(), d = s > i.getTime();
266
271
  return {
267
- startMinute: u ? 0 : g(e),
268
- endMinute: s >= i.getTime() ? a : Math.max(g(t), u ? 0 : g(e)),
269
- continuesBefore: u,
272
+ startMinute: c ? 0 : _(e),
273
+ endMinute: s >= i.getTime() ? o : Math.max(_(t), c ? 0 : _(e)),
274
+ continuesBefore: c,
270
275
  continuesAfter: d
271
276
  };
272
277
  }
273
- function z(e) {
278
+ function V(e) {
274
279
  let t = e.filter(([e, t]) => t > e).map(([e, t]) => [e, t]).sort((e, t) => e[0] - t[0]), n = [];
275
280
  for (let [e, r] of t) {
276
281
  let t = n[n.length - 1];
@@ -278,12 +283,12 @@ function z(e) {
278
283
  }
279
284
  return n;
280
285
  }
281
- function B(e, t, n) {
286
+ function H(e, t, n) {
282
287
  let r = [], i = e;
283
- for (let [e, a] of z(n)) if (!(a <= i) && (e >= t || (e > i && r.push([i, Math.min(e, t)]), i = Math.max(i, a), i >= t))) break;
288
+ for (let [e, a] of V(n)) if (!(a <= i) && (e >= t || (e > i && r.push([i, Math.min(e, t)]), i = Math.max(i, a), i >= t))) break;
284
289
  return i < t && r.push([i, t]), r;
285
290
  }
286
- function V(e, t = 0) {
291
+ function U(e, t = 0) {
287
292
  let n = e.map((e) => ({
288
293
  id: e.id,
289
294
  start: e.start,
@@ -292,7 +297,7 @@ function V(e, t = 0) {
292
297
  let e = a.length;
293
298
  for (let t of i) {
294
299
  let n = 1;
295
- for (let r = t.column + 1; r < e && !i.some((e) => e.column === r && L(t.start, t.end, e.start, e.end)); r++) n++;
300
+ for (let r = t.column + 1; r < e && !i.some((e) => e.column === r && z(t.start, t.end, e.start, e.end)); r++) n++;
296
301
  r.set(t.id, {
297
302
  column: t.column,
298
303
  columns: e,
@@ -311,7 +316,7 @@ function V(e, t = 0) {
311
316
  }
312
317
  return s(), r;
313
318
  }
314
- function H(e) {
319
+ function W(e) {
315
320
  let t = [...e].sort((e, t) => e.start - t.start || t.end - e.end || (e.id < t.id ? -1 : 1)), n = [], r = /* @__PURE__ */ new Map();
316
321
  for (let e of t) {
317
322
  let t = Math.max(e.end, e.start + 1e-6), i = n.findIndex((t) => t <= e.start);
@@ -322,39 +327,39 @@ function H(e) {
322
327
  count: n.length
323
328
  };
324
329
  }
325
- function U(e) {
330
+ function G(e) {
326
331
  return e === void 0 ? [] : typeof e == "string" ? [e] : e;
327
332
  }
328
- function W(e, t, { emptyMatchesAll: n }) {
333
+ function K(e, t, { emptyMatchesAll: n }) {
329
334
  if (t === void 0) return !0;
330
- let r = U(e);
335
+ let r = G(e);
331
336
  return r.length === 0 ? n : r.includes(t);
332
337
  }
333
- function G(e, t, n) {
334
- let r = U(e);
338
+ function q(e, t, n) {
339
+ let r = G(e);
335
340
  if (t === void 0 || n === void 0 || t === n) return r.length ? [...r] : void 0;
336
341
  if (r.length === 0) return;
337
342
  let i = r.map((e) => e === t ? n : e);
338
343
  return [...new Set(i)];
339
344
  }
340
- function K(e, t, n = []) {
345
+ function J(e, t, n = []) {
341
346
  let r = /* @__PURE__ */ new Set(), i = e.start.getTime(), a = e.end.getTime();
342
- for (let e of [...t, ...n]) if (L(e.start.getTime(), e.end.getTime(), i, a) && !("kind" in e && e.kind === "unavailable")) for (let t of U(e.resourceId)) r.add(t);
347
+ for (let e of [...t, ...n]) if (z(e.start.getTime(), e.end.getTime(), i, a) && !("kind" in e && e.kind === "unavailable")) for (let t of G(e.resourceId)) r.add(t);
343
348
  return r;
344
349
  }
345
- function q(e, t, n = {}) {
346
- let { fromDateKey: r, wallDateAtMinutes: i, toDateKey: o, startOfWeek: s, startOfDay: c, addDays: l, differenceInDays: u, weekday: d } = $(n.timeZone), f = n.weekStartsOn ?? 1, p = [], m = t.start.getTime(), h = t.end.getTime();
350
+ function Y(e, t, n = {}) {
351
+ let { fromDateKey: r, wallDateAtMinutes: i, toDateKey: a, startOfWeek: s, startOfDay: c, addDays: l, differenceInDays: u, weekday: d } = $(n.timeZone), f = n.weekStartsOn ?? 1, p = [], m = t.start.getTime(), h = t.end.getTime();
347
352
  for (let n of e) {
348
- let e = y(n.startTime), g = y(n.endTime);
349
- g <= e && (g += a);
353
+ let e = b(n.startTime), g = b(n.endTime);
354
+ g <= e && (g += o);
350
355
  let _ = r(n.startDate), v = (t) => {
351
- let r = i(t, e), a = i(t, g);
352
- if (a <= r || !L(r.getTime(), a.getTime(), m, h)) return;
353
- let s = o(t);
356
+ let r = i(t, e), o = i(t, g);
357
+ if (o <= r || !z(r.getTime(), o.getTime(), m, h)) return;
358
+ let s = a(t);
354
359
  p.push({
355
360
  id: n.recurrence ? `${n.id}@${s}` : n.id,
356
361
  start: r,
357
- end: a,
362
+ end: o,
358
363
  kind: n.kind ?? "available",
359
364
  resourceId: n.resourceId,
360
365
  label: n.label,
@@ -364,117 +369,117 @@ function q(e, t, n = {}) {
364
369
  occurrenceKey: n.recurrence ? s : void 0,
365
370
  data: n.data
366
371
  });
367
- }, b = n.recurrence;
368
- if (!b) {
372
+ }, y = n.recurrence;
373
+ if (!y) {
369
374
  v(_);
370
375
  continue;
371
376
  }
372
- let x = Math.max(1, Math.floor(b.interval ?? 1)), S = new Set(b.weekdays);
377
+ let x = Math.max(1, Math.floor(y.interval ?? 1)), S = new Set(y.weekdays);
373
378
  if (S.size === 0) continue;
374
- let C = new Set(b.exclusions ?? []), w = b.until ? r(b.until) : null, T = s(_, f), E = c(t.start);
379
+ let C = new Set(y.exclusions ?? []), w = y.until ? r(y.until) : null, T = s(_, f), E = c(t.start);
375
380
  E = l(E, -1), E < _ && (E = _);
376
381
  let D = c(t.end);
377
- for (; E <= D && (!w || E <= w);) S.has(d(E)) && Math.floor(u(s(E, f), T) / 7) % x === 0 && !C.has(o(E)) && v(E), E = l(E, 1);
382
+ for (; E <= D && (!w || E <= w);) S.has(d(E)) && Math.floor(u(s(E, f), T) / 7) % x === 0 && !C.has(a(E)) && v(E), E = l(E, 1);
378
383
  }
379
384
  return p.sort((e, t) => e.start.getTime() - t.start.getTime());
380
385
  }
381
- function J(t, n, r, i, a) {
382
- let s = C(n, i, "floor"), c = C(r, i, "floor"), l = e(Math.min(s, c), a.min, a.max - i), u = e(Math.max(s, c) + i, l + i, a.max), d = _(t, l), f = _(t, u);
383
- return f <= d && (f = new Date(d.getTime() + i * o)), {
386
+ function X(t, n, r, i, a) {
387
+ let o = w(n, i, "floor"), c = w(r, i, "floor"), l = e(Math.min(o, c), a.min, a.max - i), u = e(Math.max(o, c) + i, l + i, a.max), d = v(t, l), f = v(t, u);
388
+ return f <= d && (f = new Date(d.getTime() + i * s)), {
384
389
  start: d,
385
390
  end: f
386
391
  };
387
392
  }
388
- function Y(t, n, r, i, a, s) {
389
- let c = (t.end.getTime() - t.start.getTime()) / o, l = C(r - i, a), u = g(t.start);
390
- u >= s.min && u + c <= s.max && (l = e(l, s.min, s.max - c));
391
- let d = v(n, l);
393
+ function Z(t, n, r, i, a, o) {
394
+ let c = (t.end.getTime() - t.start.getTime()) / s, l = w(r - i, a), u = _(t.start);
395
+ u >= o.min && u + c <= o.max && (l = e(l, o.min, o.max - c));
396
+ let d = y(n, l);
392
397
  return {
393
398
  start: d,
394
- end: new Date(d.getTime() + c * o)
399
+ end: new Date(d.getTime() + c * s)
395
400
  };
396
401
  }
397
- function X(t, n, r, i, o) {
398
- let s = c(n), l = t.start.getTime() >= s.getTime() ? g(t.start) + i : i;
399
- return _(s, e(C(r, i), Math.min(l, a), Math.max(o.max, l)));
402
+ function Q(t, n, r, i, a) {
403
+ let s = l(n), c = t.start.getTime() >= s.getTime() ? _(t.start) + i : i;
404
+ return v(s, e(w(r, i), Math.min(c, o), Math.max(a.max, c)));
400
405
  }
401
- function Z(e, t) {
406
+ function ee(e, t) {
402
407
  return {
403
- start: l(e.start, t),
404
- end: l(e.end, t)
408
+ start: u(e.start, t),
409
+ end: u(e.end, t)
405
410
  };
406
411
  }
407
- function Q(e, t) {
412
+ function te(e, t) {
408
413
  return e.start.getTime() === t.start.getTime() && e.end.getTime() === t.end.getTime();
409
414
  }
410
- function ee(e) {
411
- return e.allDay ? !0 : e.end.getTime() >= l(e.start, 1).getTime();
415
+ function ne(e) {
416
+ return e.allDay ? !0 : e.end.getTime() >= u(e.start, 1).getTime();
412
417
  }
413
418
  function $(t) {
414
- let r = (e) => n(e, t), c = (e) => i(e, t), l = (e) => {
415
- let t = r(e);
419
+ let n = (e) => r(e, t), i = (e) => a(e, t), l = (e) => {
420
+ let t = n(e);
416
421
  return `${String(t.year).padStart(4, "0")}-${String(t.month).padStart(2, "0")}-${String(t.day).padStart(2, "0")}`;
417
- }, d = (e) => c({
418
- ...r(e),
422
+ }, u = (e) => i({
423
+ ...n(e),
419
424
  hour: 0,
420
425
  minute: 0,
421
426
  second: 0,
422
427
  millisecond: 0
423
428
  }), f = (e, t) => {
424
429
  if (t === 0) return new Date(e);
425
- let n = r(e), i = new Date(Date.UTC(n.year, n.month - 1, n.day + t));
426
- return c({
427
- ...n,
428
- year: i.getUTCFullYear(),
429
- month: i.getUTCMonth() + 1,
430
- day: i.getUTCDate()
430
+ let r = n(e), a = new Date(Date.UTC(r.year, r.month - 1, r.day + t));
431
+ return i({
432
+ ...r,
433
+ year: a.getUTCFullYear(),
434
+ month: a.getUTCMonth() + 1,
435
+ day: a.getUTCDate()
431
436
  });
432
437
  }, p = (e, t) => {
433
- let n = r(e), i = new Date(Date.UTC(n.year, n.month - 1 + t, 1)), a = new Date(Date.UTC(i.getUTCFullYear(), i.getUTCMonth() + 1, 0)).getUTCDate();
434
- return c({
435
- ...n,
436
- year: i.getUTCFullYear(),
437
- month: i.getUTCMonth() + 1,
438
- day: Math.min(n.day, a)
438
+ let r = n(e), a = new Date(Date.UTC(r.year, r.month - 1 + t, 1)), o = new Date(Date.UTC(a.getUTCFullYear(), a.getUTCMonth() + 1, 0)).getUTCDate();
439
+ return i({
440
+ ...r,
441
+ year: a.getUTCFullYear(),
442
+ month: a.getUTCMonth() + 1,
443
+ day: Math.min(r.day, o)
439
444
  });
440
445
  }, m = (e) => {
441
- let t = r(e);
446
+ let t = n(e);
442
447
  return new Date(Date.UTC(t.year, t.month - 1, t.day)).getUTCDay();
443
- }, h = (e, t = 1) => f(d(e), -((m(e) - t + 7) % 7)), _ = (e) => c({
444
- ...r(d(e)),
448
+ }, h = (e, t = 1) => f(u(e), -((m(e) - t + 7) % 7)), g = (e) => i({
449
+ ...n(u(e)),
445
450
  day: 1
446
- }), y = (e, t) => {
447
- let n = r(e), i = r(t);
448
- return Math.round((Date.UTC(n.year, n.month - 1, n.day) - Date.UTC(i.year, i.month - 1, i.day)) / 864e5);
451
+ }), v = (e, t) => {
452
+ let r = n(e), i = n(t);
453
+ return Math.round((Date.UTC(r.year, r.month - 1, r.day) - Date.UTC(i.year, i.month - 1, i.day)) / 864e5);
449
454
  }, b = (e, t) => {
450
- let n = r(e), i = new Date(Date.UTC(n.year, n.month - 1, n.day, 0, Math.floor(t), 0, Math.round((t - Math.floor(t)) * o)));
451
- return c({
452
- year: i.getUTCFullYear(),
453
- month: i.getUTCMonth() + 1,
454
- day: i.getUTCDate(),
455
- hour: i.getUTCHours(),
456
- minute: i.getUTCMinutes(),
457
- second: i.getUTCSeconds(),
458
- millisecond: i.getUTCMilliseconds()
455
+ let r = n(e), a = new Date(Date.UTC(r.year, r.month - 1, r.day, 0, Math.floor(t), 0, Math.round((t - Math.floor(t)) * s)));
456
+ return i({
457
+ year: a.getUTCFullYear(),
458
+ month: a.getUTCMonth() + 1,
459
+ day: a.getUTCDate(),
460
+ hour: a.getUTCHours(),
461
+ minute: a.getUTCMinutes(),
462
+ second: a.getUTCSeconds(),
463
+ millisecond: a.getUTCMilliseconds()
459
464
  });
460
465
  }, x = (e, t) => {
461
- let n = r(e);
462
- return y(e, t) * a + n.hour * 60 + n.minute + n.second / 60 + n.millisecond / o;
466
+ let r = n(e);
467
+ return v(e, t) * o + r.hour * 60 + r.minute + r.second / 60 + r.millisecond / s;
463
468
  }, S = (e, n) => {
464
469
  let r = b(e, n), i = x(r, e);
465
470
  if (!t || i <= n + 1e-8) return r;
466
- let a = Math.floor(r.getTime() - (i - n) * o), s = r.getTime();
467
- for (; a < s;) {
468
- let t = Math.floor((a + s) / 2);
469
- x(new Date(t), e) < n ? a = t + 1 : s = t;
471
+ let a = Math.floor(r.getTime() - (i - n) * s), o = r.getTime();
472
+ for (; a < o;) {
473
+ let t = Math.floor((a + o) / 2);
474
+ x(new Date(t), e) < n ? a = t + 1 : o = t;
470
475
  }
471
- return new Date(s);
472
- }, w = (e) => {
476
+ return new Date(o);
477
+ }, C = (e) => {
473
478
  if (!Number.isFinite(e.min) || !Number.isFinite(e.max) || e.max <= e.min) throw RangeError("Calendar time bounds must contain a positive interval of real instants");
474
- }, T = t ? (e, t) => new Date(d(e).getTime() + t * o) : v, E = t ? (e) => (e.getTime() - d(e).getTime()) / o : g, D = t ? (e, t) => new Date(e.getTime() + t * o) : u, O = (e) => {
479
+ }, T = t ? (e, t) => new Date(u(e).getTime() + t * s) : y, E = t ? (e) => (e.getTime() - u(e).getTime()) / s : _, D = t ? (e, t) => new Date(e.getTime() + t * s) : d, O = (e) => {
475
480
  let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
476
481
  if (!t) throw RangeError(`Invalid date key "${e}"`);
477
- let n = c({
482
+ let n = i({
478
483
  year: +t[1],
479
484
  month: +t[2],
480
485
  day: +t[3],
@@ -486,30 +491,30 @@ function $(t) {
486
491
  if (l(n) !== e) throw RangeError(`Invalid date key "${e}"`);
487
492
  return n;
488
493
  }, k = (e, t = 1) => {
489
- let n = _(e), r = p(n, 1), i = [];
494
+ let n = g(e), r = p(n, 1), i = [];
490
495
  for (let e = h(n, t); e < r; e = f(e, 7)) i.push(Array.from({ length: 7 }, (t, n) => f(e, n)));
491
496
  return i;
492
497
  }, A = (e, t, n = {}) => {
493
- let r = d(t);
498
+ let r = u(t);
494
499
  if (e === "month") return k(r, n.weekStartsOn).flat();
495
500
  if (e === "week" || e === "workWeek") {
496
501
  let t = h(r, n.weekStartsOn), i = Array.from({ length: 7 }, (e, n) => f(t, n));
497
502
  if (e === "week") return i;
498
- let a = new Set(n.workWeekDays ?? s), o = i.filter((e) => a.has(m(e)));
503
+ let a = new Set(n.workWeekDays ?? c), o = i.filter((e) => a.has(m(e)));
499
504
  return o.length ? o : [r];
500
505
  }
501
506
  let i = e === "threeDay" ? 3 : e === "agenda" ? Math.max(1, Math.floor(n.agendaDays ?? 7)) : 1;
502
507
  return Array.from({ length: i }, (e, t) => f(r, t));
503
- }, M = (e, n, r) => {
504
- if (!t) return R(e, n, r);
505
- let i = d(r).getTime(), a = f(d(r), 1).getTime(), s = e.getTime(), c = Math.max(s, n.getTime());
506
- return (c === s ? s < i || s >= a : !L(s, c, i, a)) ? null : {
507
- startMinute: Math.max(0, (s - i) / o),
508
- endMinute: Math.min(a - i, c - i) / o,
509
- continuesBefore: s < i,
508
+ }, j = (e, n, r) => {
509
+ if (!t) return B(e, n, r);
510
+ let i = u(r).getTime(), a = f(u(r), 1).getTime(), o = e.getTime(), c = Math.max(o, n.getTime());
511
+ return (c === o ? o < i || o >= a : !z(o, c, i, a)) ? null : {
512
+ startMinute: Math.max(0, (o - i) / s),
513
+ endMinute: Math.min(a - i, c - i) / s,
514
+ continuesBefore: o < i,
510
515
  continuesAfter: c > a
511
516
  };
512
- }, N = (e) => !!e.allDay || e.end >= f(e.start, 1), P = (e, n) => j(e, {
517
+ }, M = (e) => !!e.allDay || e.end >= f(e.start, 1), P = (e, n) => N(e, {
513
518
  ...n,
514
519
  ...t ? { timeZone: t } : {}
515
520
  }), F = (e, t = "en-GB") => P(t, {
@@ -517,16 +522,16 @@ function $(t) {
517
522
  day: "numeric",
518
523
  month: "long",
519
524
  year: "numeric"
520
- }).format(e), z = (e, n, i = {}) => {
521
- if (!t) return I(e, n, i);
525
+ }).format(e), I = (e, r, i = {}) => {
526
+ if (!t) return R(e, r, i);
522
527
  let a = i.locale ?? "en-GB";
523
528
  if (e === "month") return P(a, {
524
529
  month: "long",
525
530
  year: "numeric"
526
- }).format(n);
527
- let o = A(e, n, i), s = o[0], c = o[o.length - 1];
531
+ }).format(r);
532
+ let o = A(e, r, i), s = o[0], c = o[o.length - 1];
528
533
  if (o.length === 1) return F(s, a);
529
- let l = r(s), u = r(c);
534
+ let l = n(s), u = n(c);
530
535
  return l.year === u.year && l.month === u.month ? `${l.day} – ${P(a, {
531
536
  day: "numeric",
532
537
  month: "long",
@@ -540,14 +545,14 @@ function $(t) {
540
545
  month: "short",
541
546
  year: "numeric"
542
547
  }).format(c)}`;
543
- }, B = (n, i, s, c, l, u) => {
544
- if (!t) return Y(n, i, s, c, l, u);
545
- w(u);
546
- let d = (n.end.getTime() - n.start.getTime()) / o, f = C(s - c, l), p = (e) => {
547
- let t = T(i, e), n = r(t);
548
- return y(t, i) * a + n.hour * 60 + n.minute;
549
- }, m = b(n.start, p(u.min)), h = b(n.start, p(u.max));
550
- n.start >= m && n.end <= h && d <= u.max - u.min && (f = e(f, u.min, u.max - d));
548
+ }, L = (r, i, a, c, l, u) => {
549
+ if (!t) return Z(r, i, a, c, l, u);
550
+ C(u);
551
+ let d = (r.end.getTime() - r.start.getTime()) / s, f = w(a - c, l), p = (e) => {
552
+ let t = T(i, e), r = n(t);
553
+ return v(t, i) * o + r.hour * 60 + r.minute;
554
+ }, m = b(r.start, p(u.min)), h = b(r.start, p(u.max));
555
+ r.start >= m && r.end <= h && d <= u.max - u.min && (f = e(f, u.min, u.max - d));
551
556
  let g = T(i, f);
552
557
  return {
553
558
  start: g,
@@ -555,17 +560,17 @@ function $(t) {
555
560
  };
556
561
  };
557
562
  return {
558
- parts: r,
563
+ parts: n,
559
564
  weekday: m,
560
- startOfDay: d,
565
+ startOfDay: u,
561
566
  addDays: f,
562
567
  addMonths: p,
563
568
  addMinutes: D,
564
569
  startOfWeek: h,
565
- startOfMonth: _,
570
+ startOfMonth: g,
566
571
  toDateKey: l,
567
572
  fromDateKey: O,
568
- differenceInDays: y,
573
+ differenceInDays: v,
569
574
  isSameDay: (e, t) => l(e) === l(t),
570
575
  dateAtMinutes: T,
571
576
  wallDateAtMinutes: b,
@@ -582,30 +587,30 @@ function $(t) {
582
587
  shiftDate: (e, t, n, r = {}) => e === "month" ? p(t, n) : f(t, n * (e === "threeDay" ? 3 : e === "week" || e === "workWeek" ? 7 : e === "agenda" ? Math.max(1, r.agendaDays ?? 7) : 1)),
583
588
  getFormatter: P,
584
589
  formatLongDate: F,
585
- formatRangeTitle: z,
586
- daySegment: M,
587
- isAllDayLike: N,
588
- eventsOnDay: (e, t) => e.filter((e) => M(e.start, e.end, t)).sort((e, t) => Number(N(t)) - Number(N(e)) || e.start.getTime() - t.start.getTime() || t.end.getTime() - e.end.getTime() || e.title.localeCompare(t.title)),
590
+ formatRangeTitle: I,
591
+ daySegment: j,
592
+ isAllDayLike: M,
593
+ eventsOnDay: (e, t) => e.filter((e) => j(e.start, e.end, t)).sort((e, t) => Number(M(t)) - Number(M(e)) || e.start.getTime() - t.start.getTime() || t.end.getTime() - e.end.getTime() || e.title.localeCompare(t.title)),
589
594
  computeCreateRange: (n, r, i, a, o) => {
590
- if (!t) return J(n, r, i, a, o);
591
- let s = C(r, a, "floor"), c = C(i, a, "floor");
592
- w(o);
595
+ if (!t) return X(n, r, i, a, o);
596
+ let s = w(r, a, "floor"), c = w(i, a, "floor");
597
+ C(o);
593
598
  let l = Math.min(a, o.max - o.min), u = e(Math.min(s, c), o.min, o.max - l);
594
599
  return {
595
600
  start: T(n, u),
596
601
  end: T(n, e(Math.max(s, c) + a, u + l, o.max))
597
602
  };
598
603
  },
599
- computeMoveRange: B,
600
- computeResizeEnd: (n, r, i, a, s) => {
601
- if (!t) return X(n, r, i, a, s);
602
- w(s);
603
- let c = Math.max(0, (n.start.getTime() - d(r).getTime()) / o) + a;
604
- return T(r, e(C(i, a), c, Math.max(s.max, c)));
604
+ computeMoveRange: L,
605
+ computeResizeEnd: (n, r, i, a, o) => {
606
+ if (!t) return Q(n, r, i, a, o);
607
+ C(o);
608
+ let c = Math.max(0, (n.start.getTime() - u(r).getTime()) / s) + a;
609
+ return T(r, e(w(i, a), c, Math.max(o.max, c)));
605
610
  },
606
- computeNudgeRange: (e, t, n) => B(e, d(e.start), E(e.start) + t, 0, 1, n),
611
+ computeNudgeRange: (e, t, n) => L(e, u(e.start), E(e.start) + t, 0, 1, n),
607
612
  shiftRangeDays: (e, n) => {
608
- if (!t) return Z(e, n);
613
+ if (!t) return ee(e, n);
609
614
  if (e.allDay) return {
610
615
  start: f(e.start, n),
611
616
  end: f(e.end, n)
@@ -618,15 +623,15 @@ function $(t) {
618
623
  },
619
624
  dayBounds: (e, n) => {
620
625
  if (!t) return n;
621
- let r = d(e).getTime(), i = {
622
- min: (S(e, n.min).getTime() - r) / o,
623
- max: (S(e, n.max).getTime() - r) / o
626
+ let r = u(e).getTime(), i = {
627
+ min: (S(e, n.min).getTime() - r) / s,
628
+ max: (S(e, n.max).getTime() - r) / s
624
629
  };
625
- return w(i), i;
630
+ return C(i), i;
626
631
  }
627
632
  };
628
633
  }
629
- function te(e, t, n, r, i = !0) {
634
+ function re(e, t, n, r, i = !0) {
630
635
  let a = Math.max(5, t), o = (e) => Array.from({ length: Math.ceil((e.max - e.min) / a) }, (t, n) => e.min + n * a);
631
636
  if (!i) return {
632
637
  reference: void 0,
@@ -640,7 +645,7 @@ function te(e, t, n, r, i = !0) {
640
645
  let s = $(n.timeZone), c = /* @__PURE__ */ new Map(), l = e.map(({ day: e, bounds: t }) => {
641
646
  let i = s.toDateKey(e), a = c.get(i);
642
647
  if (a) return a;
643
- let l = o(t), u = l.map((t) => s.dateAtMinutes(e, t)), d = u.map((e) => M(e, n)), f = j(n.locale ?? "en-GB", {
648
+ let l = o(t), u = l.map((t) => s.dateAtMinutes(e, t)), d = u.map((e) => P(e, n)), f = N(n.locale ?? "en-GB", {
644
649
  timeZone: n.timeZone,
645
650
  timeZoneName: "short"
646
651
  }), p = new Set(u.map((e) => f.formatToParts(e).find((e) => e.type === "timeZoneName")?.value)), m = t.max - t.min === r.max - r.min && p.size === 1, h = {
@@ -663,4 +668,4 @@ function te(e, t, n, r, i = !0) {
663
668
  };
664
669
  }
665
670
  //#endregion
666
- export { l as addDays, u as addMinutes, d as addMonths, i as calendarDateFromParts, n as calendarDateParts, $ as createCalendarDateMath, v as dateAtMinutes, h as differenceInDays, q as expandAvailabilityRules, P as formatHourLabel, I as formatRangeTitle, M as formatTime, b as formatTimeOfDay, N as formatTimeRange, S as fromDateKey, K as getActiveResourceIds, O as getViewRange, E as getVisibleDays, ee as isAllDayLike, m as isSameDay, T as isTimeGridView, V as layoutOverlaps, W as matchesResource, g as minutesOfDay, H as packLanes, y as parseTime, L as rangesOverlap, G as replaceResource, U as resourceIdsOf, Q as sameRange, te as selectCalendarTimeAxis, k as shiftDate, w as snapDate, C as snapMinutes, c as startOfDay, p as startOfMonth, f as startOfWeek, B as subtractIntervals, x as toDateKey };
671
+ export { u as addDays, d as addMinutes, f as addMonths, a as calendarDateFromParts, r as calendarDateParts, $ as createCalendarDateMath, y as dateAtMinutes, g as differenceInDays, Y as expandAvailabilityRules, I as formatHourLabel, j as formatPickerDate, R as formatRangeTitle, P as formatTime, x as formatTimeOfDay, F as formatTimeRange, C as fromDateKey, J as getActiveResourceIds, k as getViewRange, D as getVisibleDays, ne as isAllDayLike, h as isSameDay, E as isTimeGridView, U as layoutOverlaps, K as matchesResource, _ as minutesOfDay, W as packLanes, b as parseTime, z as rangesOverlap, q as replaceResource, G as resourceIdsOf, te as sameRange, re as selectCalendarTimeAxis, A as shiftDate, T as snapDate, w as snapMinutes, l as startOfDay, m as startOfMonth, p as startOfWeek, H as subtractIntervals, S as toDateKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonardaustin/ui",
3
- "version": "0.26.2",
3
+ "version": "0.27.0",
4
4
  "description": "Reusable React component library and application shell for Leonard Austin projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",