@loczer/storefront-sdk 0.195.0 → 0.196.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,21 +1,20 @@
1
1
  import { cn as e } from "../../../../lib/utils.js";
2
- import { useIsTouchDevice as t } from "./useIsTouchDevice.js";
3
- import * as n from "react";
4
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
5
- import { Check as o, ChevronDown as s, ChevronUp as c } from "lucide-react";
6
- import { createPortal as l } from "react-dom";
7
- import { IMaskInput as u } from "react-imask";
8
- import d, { InputMask as f } from "imask";
2
+ import * as t from "react";
3
+ import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import { Check as a, ChevronDown as o, ChevronUp as s } from "lucide-react";
5
+ import { createPortal as c } from "react-dom";
6
+ import { IMaskInput as l } from "react-imask";
7
+ import u, { InputMask as d } from "imask";
9
8
  //#region src/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.tsx
10
- var p = d;
11
- typeof p.InputMask != "function" && (p.InputMask = f);
12
- var m = {
9
+ var f = u;
10
+ typeof f.InputMask != "function" && (f.InputMask = d);
11
+ var p = {
13
12
  left: 0,
14
13
  top: 0,
15
14
  width: 0,
16
15
  strategy: "fixed"
17
16
  };
18
- function h(e, t, n) {
17
+ function m(e, t, n) {
19
18
  let r = e.getBoundingClientRect(), i = t.offsetHeight, a = window.innerWidth ?? 0, o = window.innerHeight ?? 0, s = r.width, c = r.left;
20
19
  c + s > a - 8 && (c = Math.max(8, a - s - 8)), c < 8 && (c = 8);
21
20
  let l = r.bottom + 8, u = l + i > o - 8, d = r.top - i - 8;
@@ -33,19 +32,19 @@ function h(e, t, n) {
33
32
  strategy: "absolute"
34
33
  };
35
34
  }
36
- function g(e) {
35
+ function h(e) {
37
36
  return String(e).padStart(2, "0");
38
37
  }
39
- function _(e) {
38
+ function g(e) {
40
39
  let t = e.trim();
41
40
  if (!t) return null;
42
41
  let n = /^(\d{1,2}):(\d{2})$/.exec(t);
43
42
  if (!n) return null;
44
43
  let r = Number(n[1]), i = Number(n[2]);
45
- return !Number.isFinite(r) || !Number.isFinite(i) || r < 0 || r > 23 || i < 0 || i > 59 ? null : `${g(r)}:${g(i)}`;
44
+ return !Number.isFinite(r) || !Number.isFinite(i) || r < 0 || r > 23 || i < 0 || i > 59 ? null : `${h(r)}:${h(i)}`;
46
45
  }
47
- function v(e) {
48
- let t = _(e);
46
+ function _(e) {
47
+ let t = g(e);
49
48
  if (t) return `parsed:${t}`;
50
49
  let n = e.replace(/\D/g, "");
51
50
  if (!n) return "empty";
@@ -53,9 +52,9 @@ function v(e) {
53
52
  let r = n.slice(-2), i = n.slice(0, -2);
54
53
  return `hour-minute:${Number(i)}:${r}`;
55
54
  }
56
- function y(e, t) {
57
- let n = _(e);
58
- return n ? x(t.find((e) => e.value === n)) ? {
55
+ function v(e, t) {
56
+ let n = g(e);
57
+ return n ? b(t.find((e) => e.value === n)) ? {
59
58
  parsed: n,
60
59
  selectableValue: n
61
60
  } : {
@@ -63,117 +62,117 @@ function y(e, t) {
63
62
  selectableValue: null
64
63
  } : null;
65
64
  }
66
- function b(e) {
65
+ function y(e) {
67
66
  let t = /^(\d{2}):(\d{2})$/.exec(e);
68
67
  if (!t) return null;
69
68
  let n = Number(t[1]), r = Number(t[2]);
70
69
  return !Number.isFinite(n) || !Number.isFinite(r) ? null : n * 60 + r;
71
70
  }
72
- function x(e) {
71
+ function b(e) {
73
72
  return e ? !e.disabled : !1;
74
73
  }
75
- function S(e, t, n) {
74
+ function x(e, t, n) {
76
75
  let r = e ? n.findIndex((t) => t.value === e) : -1;
77
76
  r === -1 && (r = t === 1 ? -1 : n.length);
78
77
  for (let e = r + t; e >= 0 && e < n.length; e += t) {
79
78
  let t = n[e];
80
- if (x(t)) return t.value;
79
+ if (b(t)) return t.value;
81
80
  }
82
81
  return null;
83
82
  }
84
- function C(e, t, r, i) {
85
- n.useEffect(() => {
86
- if (!t || !r) return;
87
- let n = e.current, a = n?.ownerDocument.defaultView?.IntersectionObserver;
88
- if (!n || !a) return;
83
+ function S(e, n, r, i) {
84
+ t.useEffect(() => {
85
+ if (!n || !r) return;
86
+ let t = e.current, a = t?.ownerDocument.defaultView?.IntersectionObserver;
87
+ if (!t || !a) return;
89
88
  let o = !0, s = new a((e) => {
90
89
  if (!o) return;
91
90
  let t = e[0];
92
91
  t && !t.isIntersecting && i(!1);
93
92
  });
94
- return s.observe(n), () => {
93
+ return s.observe(t), () => {
95
94
  o = !1, s.disconnect();
96
95
  };
97
96
  }, [
98
97
  r,
99
- t,
98
+ n,
100
99
  i,
101
100
  e
102
101
  ]);
103
102
  }
104
- function w(e, t) {
103
+ function C(e, t) {
105
104
  let n = null, r = Infinity, i = -Infinity;
106
105
  for (let a of t) {
107
- if (!x(a)) continue;
108
- let t = b(a.value);
106
+ if (!b(a)) continue;
107
+ let t = y(a.value);
109
108
  if (t == null) continue;
110
109
  let o = Math.abs(t - e);
111
110
  (o < r || o === r && t > i) && (n = a, r = o, i = t);
112
111
  }
113
112
  return n;
114
113
  }
115
- function T({ direction: t, viewportRef: r, speed: a = 400, className: o }) {
116
- let [l, u] = n.useState(!0), d = n.useRef(void 0), f = n.useRef(void 0), p = n.useRef(!1), m = n.useCallback(() => {
117
- let e = r.current;
114
+ function w({ direction: n, viewportRef: i, speed: a = 400, className: c }) {
115
+ let [l, u] = t.useState(!0), d = t.useRef(void 0), f = t.useRef(void 0), p = t.useRef(!1), m = t.useCallback(() => {
116
+ let e = i.current;
118
117
  if (!e) {
119
118
  u(!0);
120
119
  return;
121
120
  }
122
- let { scrollTop: n, scrollHeight: i, clientHeight: a } = e, o = n > 2, s = n < i - a - 2;
123
- if (!(i > a + 2)) {
121
+ let { scrollTop: t, scrollHeight: r, clientHeight: a } = e, o = t > 2, s = t < r - a - 2;
122
+ if (!(r > a + 2)) {
124
123
  u(!0);
125
124
  return;
126
125
  }
127
- u(t === "up" ? !o : !s);
128
- }, [t, r]);
129
- n.useEffect(() => {
130
- let e = r.current;
126
+ u(n === "up" ? !o : !s);
127
+ }, [n, i]);
128
+ t.useEffect(() => {
129
+ let e = i.current;
131
130
  if (!e) return;
132
131
  m();
133
132
  let t = () => m(), n = () => m();
134
133
  e.addEventListener("scroll", t, { passive: !0 });
135
- let i = new ResizeObserver(n);
136
- i.observe(e);
134
+ let r = new ResizeObserver(n);
135
+ r.observe(e);
137
136
  let a = new MutationObserver(n);
138
137
  return a.observe(e, {
139
138
  childList: !0,
140
139
  subtree: !0
141
140
  }), () => {
142
- e.removeEventListener("scroll", t), i.disconnect(), a.disconnect();
141
+ e.removeEventListener("scroll", t), r.disconnect(), a.disconnect();
143
142
  };
144
- }, [r, m]);
145
- let h = n.useCallback(() => {
143
+ }, [i, m]);
144
+ let h = t.useCallback(() => {
146
145
  d.current &&= (cancelAnimationFrame(d.current), void 0), p.current = !1, f.current = void 0;
147
- }, []), g = n.useCallback((e) => {
148
- let n = r.current;
149
- if (!n || l || !p.current) {
146
+ }, []), g = t.useCallback((e) => {
147
+ let t = i.current;
148
+ if (!t || l || !p.current) {
150
149
  h();
151
150
  return;
152
151
  }
153
152
  f.current ||= e;
154
- let i = a * (e - f.current) / 1e3;
155
- if (i < .1) {
153
+ let r = a * (e - f.current) / 1e3;
154
+ if (r < .1) {
156
155
  d.current = requestAnimationFrame(g);
157
156
  return;
158
157
  }
159
- let o = n.scrollTop, s = n.scrollHeight - n.clientHeight, c;
160
- c = t === "up" ? Math.max(0, o - i) : Math.min(s, o + i), n.scrollTo({ top: c }), f.current = e, (t === "up" ? c > 1 : c < s - 1) && Math.abs(c - o) > .01 ? d.current = requestAnimationFrame(g) : (h(), setTimeout(m, 16));
158
+ let o = t.scrollTop, s = t.scrollHeight - t.clientHeight, c;
159
+ c = n === "up" ? Math.max(0, o - r) : Math.min(s, o + r), t.scrollTo({ top: c }), f.current = e, (n === "up" ? c > 1 : c < s - 1) && Math.abs(c - o) > .01 ? d.current = requestAnimationFrame(g) : (h(), setTimeout(m, 16));
161
160
  }, [
162
161
  m,
163
- t,
162
+ n,
164
163
  l,
165
164
  a,
166
165
  h,
167
- r
168
- ]), _ = n.useCallback(() => {
169
- l || !r.current || p.current || (p.current = !0, f.current = void 0, d.current = requestAnimationFrame(g));
166
+ i
167
+ ]), _ = t.useCallback(() => {
168
+ l || !i.current || p.current || (p.current = !0, f.current = void 0, d.current = requestAnimationFrame(g));
170
169
  }, [
171
170
  l,
172
171
  g,
173
- r
172
+ i
174
173
  ]);
175
- return n.useEffect(() => h, [h]), /* @__PURE__ */ i("div", {
176
- className: e("flex items-center justify-center py-1 select-none", l ? "cursor-default opacity-40" : "cursor-pointer opacity-100 hover:bg-accent/20", o),
174
+ return t.useEffect(() => h, [h]), /* @__PURE__ */ r("div", {
175
+ className: e("flex items-center justify-center py-1 select-none", l ? "cursor-default opacity-40" : "cursor-pointer opacity-100 hover:bg-accent/20", c),
177
176
  onPointerEnter: () => {
178
177
  l || _();
179
178
  },
@@ -183,17 +182,17 @@ function T({ direction: t, viewportRef: r, speed: a = 400, className: o }) {
183
182
  onPointerLeave: () => {
184
183
  h();
185
184
  },
186
- children: i(t === "up" ? c : s, {
185
+ children: r(n === "up" ? s : o, {
187
186
  "aria-hidden": !0,
188
187
  className: "h-4 w-4 opacity-50"
189
188
  })
190
189
  });
191
190
  }
192
- function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeholder: f = "Select time", className: p, inputClassName: g, disabled: _, readOnly: v, open: y, onOpenChange: b, triggerTestId: S, contentTestId: w, isHydrated: E, portalContainer: D }) {
193
- let O = n.useId(), A = t ?? `hours-picker-${O}`, j = n.useRef(null), M = n.useRef(null), N = n.useCallback((e) => {
191
+ function T({ id: o, value: s, onChange: l, onValueUpdate: u, options: d, placeholder: f = "Select time", className: h, inputClassName: g, disabled: _, readOnly: v, open: y, onOpenChange: x, triggerTestId: C, contentTestId: T, isHydrated: E, portalContainer: D }) {
192
+ let k = t.useId(), A = o ?? `hours-picker-${k}`, j = t.useRef(null), M = t.useRef(null), N = t.useCallback((e) => {
194
193
  M.current = e;
195
- }, []), P = n.useRef(null), F = n.useRef(!1), [I, L] = n.useState(null), R = n.useRef(null), z = n.useRef(null), B = n.useRef(null), [V, H] = n.useState(m), [U, W] = n.useState(!1), G = y ?? U, K = b ?? W, q = n.useRef(!1);
196
- q.current = G, n.useEffect(() => {
194
+ }, []), P = t.useRef(null), F = t.useRef(!1), [I, L] = t.useState(null), R = t.useRef(null), z = t.useRef(null), B = t.useRef(null), [V, H] = t.useState(p), [U, W] = t.useState(!1), G = y ?? U, K = x ?? W, q = t.useRef(!1);
195
+ q.current = G, t.useEffect(() => {
197
196
  if (!G || _ || v) return;
198
197
  let e = j.current;
199
198
  e instanceof HTMLInputElement && (typeof document < "u" && document.activeElement === e || e.focus({ preventScroll: !0 }));
@@ -202,19 +201,19 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
202
201
  G,
203
202
  v
204
203
  ]);
205
- let J = n.useCallback((e) => {
204
+ let J = t.useCallback((e) => {
206
205
  P.current = e, L(e);
207
- }, []), Y = n.useCallback(() => {
206
+ }, []), Y = t.useCallback(() => {
208
207
  F.current = !0;
209
208
  }, []);
210
- n.useEffect(() => {
209
+ t.useEffect(() => {
211
210
  if (!G) return;
212
211
  let e = d.find((e) => e.value === s);
213
- if (e && x(e)) {
212
+ if (e && b(e)) {
214
213
  J(e.value);
215
214
  return;
216
215
  }
217
- let t = d.find((e) => x(e));
216
+ let t = d.find((e) => b(e));
218
217
  J(t?.value ?? null);
219
218
  }, [
220
219
  G,
@@ -222,24 +221,24 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
222
221
  J,
223
222
  s
224
223
  ]);
225
- let X = n.useCallback((e) => {
224
+ let X = t.useCallback((e) => {
226
225
  if (e === null) {
227
226
  u && u(null);
228
227
  return;
229
228
  }
230
- x(d.find((t) => t.value === e)) && u && u(e);
231
- }, [u, d]), Z = n.useCallback((e) => {
229
+ b(d.find((t) => t.value === e)) && u && u(e);
230
+ }, [u, d]), Z = t.useCallback((e) => {
232
231
  if (e === null) {
233
- u && u(null), c(null);
232
+ u && u(null), l(null);
234
233
  return;
235
234
  }
236
- x(d.find((t) => t.value === e)) && (u && u(e), c(e));
235
+ b(d.find((t) => t.value === e)) && (u && u(e), l(e));
237
236
  }, [
238
- c,
237
+ l,
239
238
  u,
240
239
  d
241
240
  ]);
242
- n.useEffect(() => {
241
+ t.useEffect(() => {
243
242
  if (!G) return;
244
243
  let e = R.current?.ownerDocument ?? document, t = e.defaultView ?? window, n = (e) => {
245
244
  let t = e.target;
@@ -256,7 +255,7 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
256
255
  return e.addEventListener("pointerdown", n, !0), t.addEventListener("keydown", r, !0), () => {
257
256
  e.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", r, !0);
258
257
  };
259
- }, [G, K]), n.useEffect(() => {
258
+ }, [G, K]), t.useEffect(() => {
260
259
  if (!G) return;
261
260
  let e = z.current;
262
261
  if (!e) return;
@@ -275,13 +274,13 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
275
274
  return e.addEventListener("wheel", t, { passive: !1 }), () => {
276
275
  e.removeEventListener("wheel", t);
277
276
  };
278
- }, [G]), C(j, G, y === void 0 || b !== void 0, K);
279
- let Q = n.useCallback(() => {
277
+ }, [G]), S(j, G, y === void 0 || x !== void 0, K);
278
+ let Q = t.useCallback(() => {
280
279
  if (typeof window > "u") return;
281
280
  let e = j.current, t = z.current;
282
- !(e instanceof HTMLElement) || !t || H(h(e, t, D));
281
+ !(e instanceof HTMLElement) || !t || H(m(e, t, D));
283
282
  }, [D]);
284
- n.useLayoutEffect(() => {
283
+ t.useLayoutEffect(() => {
285
284
  if (!G || _ || typeof window > "u") return;
286
285
  Q();
287
286
  let e = window.requestAnimationFrame(Q);
@@ -292,7 +291,7 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
292
291
  _,
293
292
  G,
294
293
  Q
295
- ]), n.useEffect(() => {
294
+ ]), t.useEffect(() => {
296
295
  if (!G) return;
297
296
  let e = B.current;
298
297
  if (!e) return;
@@ -322,7 +321,7 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
322
321
  e.scrollTop = a;
323
322
  });
324
323
  return () => cancelAnimationFrame(t);
325
- }, [G, d]), n.useEffect(() => {
324
+ }, [G, d]), t.useEffect(() => {
326
325
  if (!G || !I || !F.current) return;
327
326
  let e = B.current;
328
327
  if (!e) return;
@@ -336,13 +335,13 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
336
335
  r > e.scrollTop + e.clientHeight && (e.scrollTop = Math.max(0, r - e.clientHeight));
337
336
  }, [I, G]);
338
337
  let $ = d.find((e) => e.value === s);
339
- return /* @__PURE__ */ i("div", {
338
+ return /* @__PURE__ */ r("div", {
340
339
  "data-slot": "hours-picker-input",
341
- className: e("w-[150px]", p),
340
+ className: e("w-[150px]", h),
342
341
  ref: R,
343
- children: /* @__PURE__ */ a("div", {
342
+ children: /* @__PURE__ */ i("div", {
344
343
  className: "relative",
345
- children: [/* @__PURE__ */ i(k, {
344
+ children: [/* @__PURE__ */ r(O, {
346
345
  id: A,
347
346
  placeholder: f,
348
347
  value: s,
@@ -355,7 +354,7 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
355
354
  open: G,
356
355
  setOpen: K,
357
356
  inputClassName: g,
358
- triggerTestId: S,
357
+ triggerTestId: C,
359
358
  isHydrated: E,
360
359
  highlightedValueRef: P,
361
360
  setHighlightedValue: J,
@@ -365,9 +364,9 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
365
364
  },
366
365
  onDraftValueHandlerChange: N
367
366
  }), G ? (() => {
368
- let t = /* @__PURE__ */ i(r, { children: /* @__PURE__ */ a("div", {
367
+ let t = /* @__PURE__ */ r(n, { children: /* @__PURE__ */ i("div", {
369
368
  ref: z,
370
- "data-testid": w,
369
+ "data-testid": T,
371
370
  "data-state": "open",
372
371
  className: e("pointer-events-auto z-[60] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md", "data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95"),
373
372
  style: {
@@ -377,17 +376,17 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
377
376
  width: V.width
378
377
  },
379
378
  children: [
380
- /* @__PURE__ */ i(T, {
379
+ /* @__PURE__ */ r(w, {
381
380
  direction: "up",
382
381
  viewportRef: B
383
382
  }),
384
- /* @__PURE__ */ i("div", {
383
+ /* @__PURE__ */ r("div", {
385
384
  ref: B,
386
385
  role: "listbox",
387
386
  className: "max-h-64 overflow-y-auto p-1 [overscroll-behavior:contain] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
388
387
  children: d.map((t) => {
389
388
  let n = t.value === s;
390
- return /* @__PURE__ */ a("div", {
389
+ return /* @__PURE__ */ i("div", {
391
390
  role: "option",
392
391
  "aria-selected": n,
393
392
  "data-value": t.value,
@@ -406,15 +405,15 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
406
405
  onPointerMove: (e) => {
407
406
  F.current && e.movementX === 0 && e.movementY === 0 || (F.current = !1, J(t.value));
408
407
  },
409
- children: [/* @__PURE__ */ i("span", {
408
+ children: [/* @__PURE__ */ r("span", {
410
409
  className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
411
- children: n ? /* @__PURE__ */ i(o, {
410
+ children: n ? /* @__PURE__ */ r(a, {
412
411
  "aria-hidden": !0,
413
412
  className: "h-4 w-4"
414
413
  }) : null
415
- }), /* @__PURE__ */ a("div", {
414
+ }), /* @__PURE__ */ i("div", {
416
415
  className: "flex flex-col",
417
- children: [/* @__PURE__ */ i("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ i("span", {
416
+ children: [/* @__PURE__ */ r("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ r("span", {
418
417
  "data-slot": "description",
419
418
  className: "text-xs text-muted-foreground",
420
419
  children: t.description
@@ -423,42 +422,42 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
423
422
  }, t.value);
424
423
  })
425
424
  }),
426
- /* @__PURE__ */ i(T, {
425
+ /* @__PURE__ */ r(w, {
427
426
  direction: "down",
428
427
  viewportRef: B
429
428
  })
430
429
  ]
431
430
  }) });
432
- return typeof document > "u" ? t : l(t, D ?? document.body);
431
+ return typeof document > "u" ? t : c(t, D ?? document.body);
433
432
  })() : null]
434
433
  })
435
434
  });
436
435
  }
437
- E.displayName = "HourPickerInput";
438
- function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeholder: p = "Select time", className: g, inputClassName: _, disabled: v, readOnly: y, open: b, onOpenChange: w, triggerTestId: E, contentTestId: D, isHydrated: O, portalContainer: k }) {
439
- let A = n.useId(), j = t ?? `hours-picker-${A}`, M = n.useRef(null), N = n.useRef(null), P = n.useRef(null), F = n.useRef(null), [I, L] = n.useState(m), [R, z] = n.useState(null), [B, V] = n.useState(!1), H = b ?? B, U = w ?? V, W = n.useRef(!1);
436
+ T.displayName = "HourPickerInput";
437
+ function E({ id: s, value: l, onChange: u, onValueUpdate: d, options: f, placeholder: h = "Select time", className: g, inputClassName: _, disabled: v, readOnly: y, open: C, onOpenChange: T, triggerTestId: E, contentTestId: D, isHydrated: O, portalContainer: k }) {
438
+ let A = t.useId(), j = s ?? `hours-picker-${A}`, M = t.useRef(null), N = t.useRef(null), P = t.useRef(null), F = t.useRef(null), [I, L] = t.useState(p), [R, z] = t.useState(null), [B, V] = t.useState(!1), H = C ?? B, U = T ?? V, W = t.useRef(!1);
440
439
  W.current = H;
441
- let G = n.useCallback((e) => {
442
- x(f.find((t) => t.value === e)) && (d && d(e), u(e));
440
+ let G = t.useCallback((e) => {
441
+ b(f.find((t) => t.value === e)) && (d && d(e), u(e));
443
442
  }, [
444
443
  u,
445
444
  d,
446
445
  f
447
446
  ]);
448
- n.useEffect(() => {
447
+ t.useEffect(() => {
449
448
  if (!H) return;
450
- let e = f.find((e) => e.value === c);
451
- if (x(e)) {
449
+ let e = f.find((e) => e.value === l);
450
+ if (b(e)) {
452
451
  z(e.value);
453
452
  return;
454
453
  }
455
- let t = f.find((e) => x(e));
454
+ let t = f.find((e) => b(e));
456
455
  z(t?.value ?? null);
457
456
  }, [
458
457
  f,
459
458
  H,
460
- c
461
- ]), n.useEffect(() => {
459
+ l
460
+ ]), t.useEffect(() => {
462
461
  if (!H || !R) return;
463
462
  let e = F.current;
464
463
  if (!e) return;
@@ -470,13 +469,13 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
470
469
  return;
471
470
  }
472
471
  r > e.scrollTop + e.clientHeight && (e.scrollTop = Math.max(0, r - e.clientHeight));
473
- }, [R, H]), C(M, H, b === void 0 || w !== void 0, U);
474
- let K = n.useCallback(() => {
472
+ }, [R, H]), S(M, H, C === void 0 || T !== void 0, U);
473
+ let K = t.useCallback(() => {
475
474
  if (typeof window > "u") return;
476
475
  let e = M.current, t = P.current;
477
- !(e instanceof HTMLElement) || !t || L(h(e, t, k));
476
+ !(e instanceof HTMLElement) || !t || L(m(e, t, k));
478
477
  }, [k]);
479
- n.useLayoutEffect(() => {
478
+ t.useLayoutEffect(() => {
480
479
  if (!H || v || typeof window > "u") return;
481
480
  K();
482
481
  let e = window.requestAnimationFrame(K);
@@ -487,7 +486,7 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
487
486
  v,
488
487
  H,
489
488
  K
490
- ]), n.useEffect(() => {
489
+ ]), t.useEffect(() => {
491
490
  if (!H) return;
492
491
  let e = N.current?.ownerDocument ?? document, t = e.defaultView ?? window, n = (e) => {
493
492
  let t = e.target;
@@ -503,12 +502,12 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
503
502
  e.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", r, !0);
504
503
  };
505
504
  }, [H, U]);
506
- let q = f.find((e) => e.value === c), J = q?.selectedLabel ?? q?.label ?? c, Y = f.findIndex((e) => e.value === R), X = Y >= 0 ? `${j}-option-${Y}` : void 0;
507
- return /* @__PURE__ */ a("div", {
505
+ let q = f.find((e) => e.value === l), J = q?.compactSelectedLabel ?? q?.selectedLabel ?? q?.label ?? l, Y = f.findIndex((e) => e.value === R), X = Y >= 0 ? `${j}-option-${Y}` : void 0;
506
+ return /* @__PURE__ */ i("div", {
508
507
  "data-slot": "hours-picker-field",
509
508
  className: e("w-[150px]", g),
510
509
  ref: N,
511
- children: [/* @__PURE__ */ a("button", {
510
+ children: [/* @__PURE__ */ i("button", {
512
511
  ref: M,
513
512
  id: j,
514
513
  type: "button",
@@ -520,7 +519,7 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
520
519
  disabled: v,
521
520
  "data-testid": E,
522
521
  "data-hydrated": O ? "true" : void 0,
523
- className: e("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", "hover:bg-accent hover:text-accent-foreground", !c && "text-muted-foreground", H && "ring-2 ring-primary ring-offset-2", _),
522
+ className: e("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", !l && "text-muted-foreground", H && "ring-2 ring-primary ring-offset-2", _),
524
523
  onClick: () => {
525
524
  v || y || U(!H);
526
525
  },
@@ -535,7 +534,7 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
535
534
  U(!0);
536
535
  return;
537
536
  }
538
- let t = S(R ?? c, e.key === "ArrowDown" ? 1 : -1, f);
537
+ let t = x(R ?? l, e.key === "ArrowDown" ? 1 : -1, f);
539
538
  if (!t) return;
540
539
  z(t), d?.(t);
541
540
  return;
@@ -545,18 +544,18 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
545
544
  U(!0);
546
545
  return;
547
546
  }
548
- let t = f.find((e) => e.value === R), n = x(t) ? t.value : f.find((e) => x(e))?.value;
547
+ let t = f.find((e) => e.value === R), n = b(t) ? t.value : f.find((e) => b(e))?.value;
549
548
  n && (G(n), U(!1));
550
549
  },
551
- children: [/* @__PURE__ */ i("span", {
550
+ children: [/* @__PURE__ */ r("span", {
552
551
  className: "line-clamp-1 text-left",
553
- children: c ? J : p
554
- }), /* @__PURE__ */ i(s, {
552
+ children: l ? J : h
553
+ }), /* @__PURE__ */ r(o, {
555
554
  "aria-hidden": !0,
556
555
  className: "h-4 w-4 shrink-0 opacity-50"
557
556
  })]
558
557
  }), H ? (() => {
559
- let t = /* @__PURE__ */ i(r, { children: /* @__PURE__ */ a("div", {
558
+ let t = /* @__PURE__ */ r(n, { children: /* @__PURE__ */ i("div", {
560
559
  ref: P,
561
560
  id: `${j}-content`,
562
561
  "data-testid": D,
@@ -569,23 +568,23 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
569
568
  width: I.width
570
569
  },
571
570
  children: [
572
- /* @__PURE__ */ i(T, {
571
+ /* @__PURE__ */ r(w, {
573
572
  direction: "up",
574
573
  viewportRef: F
575
574
  }),
576
- /* @__PURE__ */ i("div", {
575
+ /* @__PURE__ */ r("div", {
577
576
  ref: F,
578
577
  role: "listbox",
579
578
  className: "max-h-64 overflow-y-auto p-1 [overscroll-behavior:contain] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
580
579
  children: f.map((t, n) => {
581
- let r = t.value === c, s = t.value === R;
582
- return /* @__PURE__ */ a("div", {
580
+ let o = t.value === l, s = t.value === R;
581
+ return /* @__PURE__ */ i("div", {
583
582
  id: `${j}-option-${n}`,
584
583
  role: "option",
585
- "aria-selected": r,
584
+ "aria-selected": o,
586
585
  "aria-disabled": t.disabled || void 0,
587
586
  "data-value": t.value,
588
- "data-state": r ? "checked" : "unchecked",
587
+ "data-state": o ? "checked" : "unchecked",
589
588
  "data-disabled": t.disabled ? "" : void 0,
590
589
  className: e("relative flex w-full select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none cursor-pointer", t.disabled && "pointer-events-none opacity-50", s && "bg-accent text-accent-foreground"),
591
590
  onMouseDown: (e) => {
@@ -594,15 +593,15 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
594
593
  onClick: () => {
595
594
  t.disabled || y || (z(t.value), G(t.value), U(!1), M.current?.focus({ preventScroll: !0 }));
596
595
  },
597
- children: [/* @__PURE__ */ i("span", {
596
+ children: [/* @__PURE__ */ r("span", {
598
597
  className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
599
- children: r ? /* @__PURE__ */ i(o, {
598
+ children: o ? /* @__PURE__ */ r(a, {
600
599
  "aria-hidden": !0,
601
600
  className: "h-4 w-4"
602
601
  }) : null
603
- }), /* @__PURE__ */ a("div", {
602
+ }), /* @__PURE__ */ i("div", {
604
603
  className: "flex flex-col",
605
- children: [/* @__PURE__ */ i("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ i("span", {
604
+ children: [/* @__PURE__ */ r("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ r("span", {
606
605
  "data-slot": "description",
607
606
  className: "text-xs text-muted-foreground",
608
607
  children: t.description
@@ -611,34 +610,34 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
611
610
  }, t.value);
612
611
  })
613
612
  }),
614
- /* @__PURE__ */ i(T, {
613
+ /* @__PURE__ */ r(w, {
615
614
  direction: "down",
616
615
  viewportRef: F
617
616
  })
618
617
  ]
619
618
  }) });
620
- return typeof document > "u" ? t : l(t, k ?? document.body);
619
+ return typeof document > "u" ? t : c(t, k ?? document.body);
621
620
  })() : null]
622
621
  });
623
622
  }
624
- function O(e) {
625
- return t() ? /* @__PURE__ */ i(D, { ...e }) : /* @__PURE__ */ i(E, { ...e });
623
+ function D({ compact: e = !1, ...t }) {
624
+ return r(e ? E : T, { ...t });
626
625
  }
627
- O.displayName = "HourPickerField";
628
- function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, options: d, selectedLabel: f, disabled: p, readOnly: m, open: h, setOpen: _, inputClassName: S, triggerTestId: C, isHydrated: T, highlightedValueRef: E, setHighlightedValue: D, markKeyboardNavigation: O, inputRef: k, onDraftValueHandlerChange: A }) {
629
- let j = n.useRef(!1), M = n.useRef(!1), N = n.useRef(!1), P = n.useRef(null), F = n.useRef(null), I = n.useRef(!1), [L, R] = n.useState(() => o || "");
630
- n.useEffect(() => (A((e) => {
631
- R(e);
626
+ D.displayName = "HourPickerField";
627
+ function O({ id: n, placeholder: a, value: s, onValueUpdate: c, onCommit: u, options: d, selectedLabel: f, disabled: p, readOnly: m, open: g, setOpen: x, inputClassName: S, triggerTestId: w, isHydrated: T, highlightedValueRef: E, setHighlightedValue: D, markKeyboardNavigation: O, inputRef: k, onDraftValueHandlerChange: A }) {
628
+ let j = t.useRef(!1), M = t.useRef(!1), N = t.useRef(!1), P = t.useRef(null), F = t.useRef(null), I = t.useRef(!1), [L, R] = t.useState(() => s || ""), [z, B] = t.useState(!1);
629
+ t.useEffect(() => (A((e) => {
630
+ R(e), B(!1);
632
631
  }), () => {
633
632
  A(null);
634
633
  }), [A]);
635
- let z = n.useCallback((e) => {
636
- let t = E.current ?? o ?? "", n = d.findIndex((e) => e.value === t);
634
+ let V = t.useCallback((e) => {
635
+ let t = E.current ?? s ?? "", n = d.findIndex((e) => e.value === t);
637
636
  n === -1 && (n = e === 1 ? -1 : d.length);
638
637
  for (let t = n + e; t >= 0 && t < d.length; t += e) {
639
638
  let e = d[t];
640
- if (x(e)) {
641
- D(e.value), P.current = e.value, R(e.value), c(e.value);
639
+ if (b(e)) {
640
+ D(e.value), P.current = e.value, R(e.value), B(!1), c(e.value);
642
641
  return;
643
642
  }
644
643
  }
@@ -647,22 +646,22 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
647
646
  c,
648
647
  d,
649
648
  D,
650
- o
649
+ s
651
650
  ]);
652
- n.useEffect(() => {
653
- j.current || R(o || "");
654
- }, [o]), n.useEffect(() => {
655
- F.current = v(L);
656
- }, [L]), n.useEffect(() => {
657
- o === null && (I.current = !1);
658
- }, [o]);
659
- let B = o != null && f != null, V = e("peer flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "transition-colors group-hover:bg-accent", !B && "group-hover:text-accent-foreground", !L && "text-muted-foreground", h && "ring-2 ring-primary ring-offset-2", "[&_[data-slot='description']]:hidden", S, B && "text-transparent focus:text-foreground");
660
- return /* @__PURE__ */ a("div", {
661
- className: "relative group",
651
+ t.useEffect(() => {
652
+ j.current || (R(s || ""), B(!1));
653
+ }, [s]), t.useEffect(() => {
654
+ F.current = _(L);
655
+ }, [L]), t.useEffect(() => {
656
+ s === null && (I.current = !1);
657
+ }, [s]);
658
+ let H = s != null && f != null && !z, U = e("peer flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "transition-[border-color,box-shadow]", !L && "text-muted-foreground", H && "text-transparent", g && "ring-2 ring-primary ring-offset-2", "[&_[data-slot='description']]:hidden", S);
659
+ return /* @__PURE__ */ i("div", {
660
+ className: "relative",
662
661
  children: [
663
- /* @__PURE__ */ i(u, {
664
- id: t,
665
- "data-testid": C,
662
+ /* @__PURE__ */ r(l, {
663
+ id: n,
664
+ "data-testid": w,
666
665
  "data-hydrated": T ? "true" : void 0,
667
666
  type: "text",
668
667
  disabled: p,
@@ -679,21 +678,22 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
679
678
  dispatch: (e, t) => {
680
679
  let n = (t.value + e).replace(/\D/g, "");
681
680
  if (n.length <= 2 || n.length >= 4) return t.compiledMasks[0];
682
- let r = g(Number(n.slice(0, 2)));
681
+ let r = h(Number(n.slice(0, 2)));
683
682
  return d.some((e) => e.value.startsWith(`${r}:`)) ? t.compiledMasks[0] : t.compiledMasks[1];
684
683
  },
685
- placeholder: r,
684
+ placeholder: a,
686
685
  value: L,
687
- className: V,
686
+ className: U,
688
687
  onAccept: (e, t, n) => {
689
688
  if (!n) return;
690
- let r = typeof e == "string" ? e : String(e ?? ""), i = r.replace(/\D/g, ""), a = v(r);
689
+ B(!0);
690
+ let r = typeof e == "string" ? e : String(e ?? ""), i = r.replace(/\D/g, ""), a = _(r);
691
691
  if (F.current !== a) {
692
692
  if (F.current = a, R(r), i.length !== 0) {
693
693
  I.current = !1;
694
694
  return;
695
695
  }
696
- o && !I.current && (I.current = !0, l(null));
696
+ s && !I.current && (I.current = !0, u(null));
697
697
  }
698
698
  },
699
699
  onComplete: (e, t, n) => {
@@ -703,65 +703,65 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
703
703
  P.current = null;
704
704
  return;
705
705
  }
706
- let i = y(r, d);
706
+ let i = v(r, d);
707
707
  if (!i) return;
708
708
  if (i.selectableValue) {
709
- if (D(i.selectableValue), R(i.selectableValue), o === i.selectableValue) return;
710
- l(i.selectableValue);
709
+ if (D(i.selectableValue), R(i.selectableValue), B(!1), s === i.selectableValue) return;
710
+ u(i.selectableValue);
711
711
  return;
712
712
  }
713
- let a = b(i.parsed);
713
+ let a = y(i.parsed);
714
714
  if (a == null) return;
715
- let s = w(a, d);
716
- s && D(s.value);
715
+ let o = C(a, d);
716
+ o && D(o.value);
717
717
  },
718
718
  onPointerDown: () => {
719
- M.current = !0, !p && (h || _(!0));
719
+ M.current = !0, !p && (g || x(!0));
720
720
  },
721
721
  onMouseDown: (e) => {
722
- M.current = !0, N.current = typeof document < "u" && document.activeElement === e.currentTarget, !p && (h || _(!0));
722
+ M.current = !0, N.current = typeof document < "u" && document.activeElement === e.currentTarget, !p && (g || x(!0));
723
723
  },
724
724
  onClick: () => {
725
- p || h || _(!0);
725
+ p || g || x(!0);
726
726
  },
727
727
  onKeyDown: (e) => {
728
728
  if (!p) {
729
- if (e.key === "Tab" && h && !e.defaultPrevented) {
730
- _(!1);
729
+ if (e.key === "Tab" && g && !e.defaultPrevented) {
730
+ x(!1);
731
731
  return;
732
732
  }
733
733
  if (e.key === "Escape") {
734
- if (!h) return;
735
- e.preventDefault(), _(!1);
734
+ if (!g) return;
735
+ e.preventDefault(), x(!1);
736
736
  return;
737
737
  }
738
- if (!h && !e.defaultPrevented && (e.key.length === 1 || e.key === "Backspace" || e.key === "Delete") && !e.ctrlKey && !e.metaKey && !e.altKey && _(!0), e.key === "ArrowDown" || e.key === "ArrowUp") {
739
- if (O(), e.preventDefault(), !h) {
740
- _(!0);
738
+ if (!g && !e.defaultPrevented && (e.key.length === 1 || e.key === "Backspace" || e.key === "Delete") && !e.ctrlKey && !e.metaKey && !e.altKey && x(!0), e.key === "ArrowDown" || e.key === "ArrowUp") {
739
+ if (O(), e.preventDefault(), !g) {
740
+ x(!0);
741
741
  return;
742
742
  }
743
- z(e.key === "ArrowDown" ? 1 : -1);
743
+ V(e.key === "ArrowDown" ? 1 : -1);
744
744
  return;
745
745
  }
746
746
  if (e.key === "Enter") {
747
747
  O();
748
- let t = y(L, d);
748
+ let t = v(L, d);
749
749
  if (!t) {
750
- if (!h || L.trim() !== "") return;
751
- let t = d.find((e) => e.value === E.current), n = (x(t) ? t?.value : void 0) ?? d.find((e) => x(e))?.value;
750
+ if (!g || L.trim() !== "") return;
751
+ let t = d.find((e) => e.value === E.current), n = (b(t) ? t?.value : void 0) ?? d.find((e) => b(e))?.value;
752
752
  if (!n) return;
753
- e.preventDefault(), D(n), R(n), l(n), _(!1);
753
+ e.preventDefault(), D(n), R(n), B(!1), u(n), x(!1);
754
754
  return;
755
755
  }
756
756
  if (t.selectableValue) {
757
- e.preventDefault(), D(t.selectableValue), R(t.selectableValue), l(t.selectableValue), _(!1);
757
+ e.preventDefault(), D(t.selectableValue), R(t.selectableValue), B(!1), u(t.selectableValue), x(!1);
758
758
  return;
759
759
  }
760
- let n = b(t.parsed);
760
+ let n = y(t.parsed);
761
761
  if (n == null) return;
762
- let r = w(n, d);
762
+ let r = C(n, d);
763
763
  if (!r) return;
764
- e.preventDefault(), D(r.value), R(r.value), l(r.value), _(!1);
764
+ e.preventDefault(), D(r.value), R(r.value), B(!1), u(r.value), x(!1);
765
765
  return;
766
766
  }
767
767
  }
@@ -772,43 +772,43 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
772
772
  let t = e.currentTarget;
773
773
  requestAnimationFrame(() => t.select());
774
774
  }
775
- p || h || _(!0);
775
+ p || g || x(!0);
776
776
  },
777
777
  onBlur: () => {
778
- j.current = !1;
778
+ j.current = !1, B(!1);
779
779
  let e = L.trim();
780
780
  if (!e) {
781
- R(o || "");
781
+ R(s || "");
782
782
  return;
783
783
  }
784
- let t = y(e, d);
784
+ let t = v(e, d);
785
785
  if (!t) {
786
- R(o || "");
786
+ R(s || "");
787
787
  return;
788
788
  }
789
789
  if (!t.selectableValue) {
790
- R(o || "");
790
+ R(s || "");
791
791
  return;
792
792
  }
793
- R(t.selectableValue), o !== t.selectableValue && l(t.selectableValue);
793
+ R(t.selectableValue), s !== t.selectableValue && u(t.selectableValue);
794
794
  }
795
795
  }),
796
- o && f != null ? /* @__PURE__ */ i("span", {
796
+ H ? /* @__PURE__ */ r("span", {
797
797
  "aria-hidden": "true",
798
798
  "data-slot": "hours-picker-input-selected-label",
799
- className: e("pointer-events-none absolute inset-y-0 left-3 right-10 flex min-w-0 items-center text-base transition-colors group-hover:text-accent-foreground peer-focus:hidden md:text-sm", p && "opacity-50"),
800
- children: /* @__PURE__ */ i("span", {
799
+ className: e("pointer-events-none absolute inset-y-0 left-3 right-10 flex min-w-0 items-center bg-background text-base text-foreground md:text-sm", p && "opacity-50"),
800
+ children: /* @__PURE__ */ r("span", {
801
801
  className: "min-w-0 truncate",
802
802
  children: f
803
803
  })
804
804
  }) : null,
805
- /* @__PURE__ */ i("button", {
805
+ /* @__PURE__ */ r("button", {
806
806
  type: "button",
807
807
  tabIndex: -1,
808
808
  disabled: p,
809
809
  "data-slot": "hours-picker-input-toggle",
810
810
  className: e("absolute right-1 top-1/2 inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"),
811
- "aria-label": h ? "Close time picker" : "Open time picker",
811
+ "aria-label": g ? "Close time picker" : "Open time picker",
812
812
  onPointerDown: (e) => {
813
813
  e.preventDefault();
814
814
  },
@@ -816,9 +816,9 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
816
816
  e.preventDefault();
817
817
  },
818
818
  onClick: () => {
819
- p || _(!h);
819
+ p || x(!g);
820
820
  },
821
- children: /* @__PURE__ */ i(s, {
821
+ children: /* @__PURE__ */ r(o, {
822
822
  "aria-hidden": !0,
823
823
  className: "size-4"
824
824
  })
@@ -827,4 +827,4 @@ function k({ id: t, placeholder: r, value: o, onValueUpdate: c, onCommit: l, opt
827
827
  });
828
828
  }
829
829
  //#endregion
830
- export { O as HourPickerField, E as HourPickerInput };
830
+ export { D as HourPickerField, T as HourPickerInput };