@loczer/storefront-sdk 0.195.0 → 0.197.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.
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +16 -15
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +16 -15
- package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingTimeSlotsStatus.js +4 -4
- package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.d.ts +1 -1
- package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/internal/BookingHourPickerField.js +8 -23
- package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.d.ts +4 -3
- package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.js +308 -324
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.d.ts.map +1 -1
- package/dist/components/BookingPeriodSelector/useBookingPeriodController.js +52 -46
- package/dist/index.d.ts +0 -1
- package/dist/storefront.css +1 -1
- package/package.json +1 -1
- package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.d.ts +0 -2
- package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.d.ts.map +0 -1
- package/dist/components/BookingPeriodSelector/components/internal/useIsTouchDevice.js +0 -21
package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { cn as e } from "../../../../lib/utils.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
11
|
-
typeof
|
|
12
|
-
var
|
|
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
|
|
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
|
|
35
|
+
function h(e) {
|
|
37
36
|
return String(e).padStart(2, "0");
|
|
38
37
|
}
|
|
39
|
-
function
|
|
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 : `${
|
|
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
|
|
48
|
-
let t =
|
|
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
|
|
57
|
-
let n =
|
|
58
|
-
return 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
|
|
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
|
|
71
|
+
function b(e) {
|
|
73
72
|
return e ? !e.disabled : !1;
|
|
74
73
|
}
|
|
75
|
-
function
|
|
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 (
|
|
79
|
+
if (b(t)) return t.value;
|
|
81
80
|
}
|
|
82
81
|
return null;
|
|
83
82
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
if (!
|
|
87
|
-
let
|
|
88
|
-
if (!
|
|
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(
|
|
93
|
+
return s.observe(t), () => {
|
|
95
94
|
o = !1, s.disconnect();
|
|
96
95
|
};
|
|
97
96
|
}, [
|
|
98
97
|
r,
|
|
99
|
-
|
|
98
|
+
n,
|
|
100
99
|
i,
|
|
101
100
|
e
|
|
102
101
|
]);
|
|
103
102
|
}
|
|
104
|
-
function
|
|
103
|
+
function C(e, t) {
|
|
105
104
|
let n = null, r = Infinity, i = -Infinity;
|
|
106
105
|
for (let a of t) {
|
|
107
|
-
if (!
|
|
108
|
-
let t =
|
|
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
|
|
116
|
-
let [l, u] =
|
|
117
|
-
let e =
|
|
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:
|
|
123
|
-
if (!(
|
|
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(
|
|
128
|
-
}, [
|
|
129
|
-
|
|
130
|
-
let e =
|
|
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
|
|
136
|
-
|
|
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),
|
|
141
|
+
e.removeEventListener("scroll", t), r.disconnect(), a.disconnect();
|
|
143
142
|
};
|
|
144
|
-
}, [
|
|
145
|
-
let h =
|
|
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 =
|
|
148
|
-
let
|
|
149
|
-
if (!
|
|
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
|
|
155
|
-
if (
|
|
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 =
|
|
160
|
-
c =
|
|
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
|
-
|
|
162
|
+
n,
|
|
164
163
|
l,
|
|
165
164
|
a,
|
|
166
165
|
h,
|
|
167
|
-
|
|
168
|
-
]), _ =
|
|
169
|
-
l || !
|
|
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
|
-
|
|
172
|
+
i
|
|
174
173
|
]);
|
|
175
|
-
return
|
|
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",
|
|
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:
|
|
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
|
|
193
|
-
let
|
|
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 =
|
|
196
|
-
q.current = G,
|
|
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 =
|
|
204
|
+
let J = t.useCallback((e) => {
|
|
206
205
|
P.current = e, L(e);
|
|
207
|
-
}, []), Y =
|
|
206
|
+
}, []), Y = t.useCallback(() => {
|
|
208
207
|
F.current = !0;
|
|
209
208
|
}, []);
|
|
210
|
-
|
|
209
|
+
t.useEffect(() => {
|
|
211
210
|
if (!G) return;
|
|
212
211
|
let e = d.find((e) => e.value === s);
|
|
213
|
-
if (e &&
|
|
212
|
+
if (e && b(e)) {
|
|
214
213
|
J(e.value);
|
|
215
214
|
return;
|
|
216
215
|
}
|
|
217
|
-
let t = d.find((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 =
|
|
224
|
+
let X = t.useCallback((e) => {
|
|
226
225
|
if (e === null) {
|
|
227
226
|
u && u(null);
|
|
228
227
|
return;
|
|
229
228
|
}
|
|
230
|
-
|
|
231
|
-
}, [u, d]), Z =
|
|
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),
|
|
232
|
+
u && u(null), l(null);
|
|
234
233
|
return;
|
|
235
234
|
}
|
|
236
|
-
|
|
235
|
+
b(d.find((t) => t.value === e)) && (u && u(e), l(e));
|
|
237
236
|
}, [
|
|
238
|
-
|
|
237
|
+
l,
|
|
239
238
|
u,
|
|
240
239
|
d
|
|
241
240
|
]);
|
|
242
|
-
|
|
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]),
|
|
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]),
|
|
279
|
-
let Q =
|
|
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(
|
|
281
|
+
!(e instanceof HTMLElement) || !t || H(m(e, t, D));
|
|
283
282
|
}, [D]);
|
|
284
|
-
|
|
283
|
+
return 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
|
-
]),
|
|
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]),
|
|
324
|
+
}, [G, d]), t.useEffect(() => {
|
|
326
325
|
if (!G || !I || !F.current) return;
|
|
327
326
|
let e = B.current;
|
|
328
327
|
if (!e) return;
|
|
@@ -334,28 +333,25 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
|
|
|
334
333
|
return;
|
|
335
334
|
}
|
|
336
335
|
r > e.scrollTop + e.clientHeight && (e.scrollTop = Math.max(0, r - e.clientHeight));
|
|
337
|
-
}, [I, G])
|
|
338
|
-
let $ = d.find((e) => e.value === s);
|
|
339
|
-
return /* @__PURE__ */ i("div", {
|
|
336
|
+
}, [I, G]), /* @__PURE__ */ r("div", {
|
|
340
337
|
"data-slot": "hours-picker-input",
|
|
341
|
-
className: e("w-[150px]",
|
|
338
|
+
className: e("w-[150px]", h),
|
|
342
339
|
ref: R,
|
|
343
|
-
children: /* @__PURE__ */
|
|
340
|
+
children: /* @__PURE__ */ i("div", {
|
|
344
341
|
className: "relative",
|
|
345
|
-
children: [/* @__PURE__ */
|
|
342
|
+
children: [/* @__PURE__ */ r(O, {
|
|
346
343
|
id: A,
|
|
347
344
|
placeholder: f,
|
|
348
345
|
value: s,
|
|
349
346
|
onValueUpdate: X,
|
|
350
347
|
onCommit: Z,
|
|
351
348
|
options: d,
|
|
352
|
-
selectedLabel: $?.selectedLabel,
|
|
353
349
|
disabled: _,
|
|
354
350
|
readOnly: v,
|
|
355
351
|
open: G,
|
|
356
352
|
setOpen: K,
|
|
357
353
|
inputClassName: g,
|
|
358
|
-
triggerTestId:
|
|
354
|
+
triggerTestId: C,
|
|
359
355
|
isHydrated: E,
|
|
360
356
|
highlightedValueRef: P,
|
|
361
357
|
setHighlightedValue: J,
|
|
@@ -365,9 +361,9 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
|
|
|
365
361
|
},
|
|
366
362
|
onDraftValueHandlerChange: N
|
|
367
363
|
}), G ? (() => {
|
|
368
|
-
let t = /* @__PURE__ */
|
|
364
|
+
let t = /* @__PURE__ */ r(n, { children: /* @__PURE__ */ i("div", {
|
|
369
365
|
ref: z,
|
|
370
|
-
"data-testid":
|
|
366
|
+
"data-testid": T,
|
|
371
367
|
"data-state": "open",
|
|
372
368
|
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
369
|
style: {
|
|
@@ -377,23 +373,23 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
|
|
|
377
373
|
width: V.width
|
|
378
374
|
},
|
|
379
375
|
children: [
|
|
380
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ r(w, {
|
|
381
377
|
direction: "up",
|
|
382
378
|
viewportRef: B
|
|
383
379
|
}),
|
|
384
|
-
/* @__PURE__ */
|
|
380
|
+
/* @__PURE__ */ r("div", {
|
|
385
381
|
ref: B,
|
|
386
382
|
role: "listbox",
|
|
387
383
|
className: "max-h-64 overflow-y-auto p-1 [overscroll-behavior:contain] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
|
|
388
384
|
children: d.map((t) => {
|
|
389
385
|
let n = t.value === s;
|
|
390
|
-
return /* @__PURE__ */
|
|
386
|
+
return /* @__PURE__ */ i("div", {
|
|
391
387
|
role: "option",
|
|
392
388
|
"aria-selected": n,
|
|
393
389
|
"data-value": t.value,
|
|
394
390
|
"data-state": n ? "checked" : "unchecked",
|
|
395
391
|
"data-disabled": t.disabled ? "" : void 0,
|
|
396
|
-
className: e("relative flex w-full select-none items-center rounded-sm py-1.5
|
|
392
|
+
className: e("relative flex w-full select-none items-center justify-center rounded-sm px-2 py-1.5 text-center text-sm outline-none cursor-pointer", t.disabled && "pointer-events-none opacity-50", I === t.value && "bg-accent text-accent-foreground"),
|
|
397
393
|
onMouseDown: (e) => {
|
|
398
394
|
e.preventDefault();
|
|
399
395
|
},
|
|
@@ -406,15 +402,15 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
|
|
|
406
402
|
onPointerMove: (e) => {
|
|
407
403
|
F.current && e.movementX === 0 && e.movementY === 0 || (F.current = !1, J(t.value));
|
|
408
404
|
},
|
|
409
|
-
children: [/* @__PURE__ */
|
|
405
|
+
children: [/* @__PURE__ */ r("span", {
|
|
410
406
|
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
411
|
-
children: n ? /* @__PURE__ */
|
|
407
|
+
children: n ? /* @__PURE__ */ r(a, {
|
|
412
408
|
"aria-hidden": !0,
|
|
413
409
|
className: "h-4 w-4"
|
|
414
410
|
}) : null
|
|
415
|
-
}), /* @__PURE__ */
|
|
416
|
-
className: "flex flex-col",
|
|
417
|
-
children: [/* @__PURE__ */
|
|
411
|
+
}), /* @__PURE__ */ i("div", {
|
|
412
|
+
className: "flex w-full min-w-0 flex-col items-center",
|
|
413
|
+
children: [/* @__PURE__ */ r("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ r("span", {
|
|
418
414
|
"data-slot": "description",
|
|
419
415
|
className: "text-xs text-muted-foreground",
|
|
420
416
|
children: t.description
|
|
@@ -423,42 +419,42 @@ function E({ id: t, value: s, onChange: c, onValueUpdate: u, options: d, placeho
|
|
|
423
419
|
}, t.value);
|
|
424
420
|
})
|
|
425
421
|
}),
|
|
426
|
-
/* @__PURE__ */
|
|
422
|
+
/* @__PURE__ */ r(w, {
|
|
427
423
|
direction: "down",
|
|
428
424
|
viewportRef: B
|
|
429
425
|
})
|
|
430
426
|
]
|
|
431
427
|
}) });
|
|
432
|
-
return typeof document > "u" ? t :
|
|
428
|
+
return typeof document > "u" ? t : c(t, D ?? document.body);
|
|
433
429
|
})() : null]
|
|
434
430
|
})
|
|
435
431
|
});
|
|
436
432
|
}
|
|
437
|
-
|
|
438
|
-
function
|
|
439
|
-
let A =
|
|
433
|
+
T.displayName = "HourPickerInput";
|
|
434
|
+
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 }) {
|
|
435
|
+
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
436
|
W.current = H;
|
|
441
|
-
let G =
|
|
442
|
-
|
|
437
|
+
let G = t.useCallback((e) => {
|
|
438
|
+
b(f.find((t) => t.value === e)) && (d && d(e), u(e));
|
|
443
439
|
}, [
|
|
444
440
|
u,
|
|
445
441
|
d,
|
|
446
442
|
f
|
|
447
443
|
]);
|
|
448
|
-
|
|
444
|
+
t.useEffect(() => {
|
|
449
445
|
if (!H) return;
|
|
450
|
-
let e = f.find((e) => e.value ===
|
|
451
|
-
if (
|
|
446
|
+
let e = f.find((e) => e.value === l);
|
|
447
|
+
if (b(e)) {
|
|
452
448
|
z(e.value);
|
|
453
449
|
return;
|
|
454
450
|
}
|
|
455
|
-
let t = f.find((e) =>
|
|
451
|
+
let t = f.find((e) => b(e));
|
|
456
452
|
z(t?.value ?? null);
|
|
457
453
|
}, [
|
|
458
454
|
f,
|
|
459
455
|
H,
|
|
460
|
-
|
|
461
|
-
]),
|
|
456
|
+
l
|
|
457
|
+
]), t.useEffect(() => {
|
|
462
458
|
if (!H || !R) return;
|
|
463
459
|
let e = F.current;
|
|
464
460
|
if (!e) return;
|
|
@@ -470,13 +466,13 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
470
466
|
return;
|
|
471
467
|
}
|
|
472
468
|
r > e.scrollTop + e.clientHeight && (e.scrollTop = Math.max(0, r - e.clientHeight));
|
|
473
|
-
}, [R, H]),
|
|
474
|
-
let K =
|
|
469
|
+
}, [R, H]), S(M, H, C === void 0 || T !== void 0, U);
|
|
470
|
+
let K = t.useCallback(() => {
|
|
475
471
|
if (typeof window > "u") return;
|
|
476
472
|
let e = M.current, t = P.current;
|
|
477
|
-
!(e instanceof HTMLElement) || !t || L(
|
|
473
|
+
!(e instanceof HTMLElement) || !t || L(m(e, t, k));
|
|
478
474
|
}, [k]);
|
|
479
|
-
|
|
475
|
+
t.useLayoutEffect(() => {
|
|
480
476
|
if (!H || v || typeof window > "u") return;
|
|
481
477
|
K();
|
|
482
478
|
let e = window.requestAnimationFrame(K);
|
|
@@ -487,7 +483,7 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
487
483
|
v,
|
|
488
484
|
H,
|
|
489
485
|
K
|
|
490
|
-
]),
|
|
486
|
+
]), t.useEffect(() => {
|
|
491
487
|
if (!H) return;
|
|
492
488
|
let e = N.current?.ownerDocument ?? document, t = e.defaultView ?? window, n = (e) => {
|
|
493
489
|
let t = e.target;
|
|
@@ -503,12 +499,12 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
503
499
|
e.removeEventListener("pointerdown", n, !0), t.removeEventListener("keydown", r, !0);
|
|
504
500
|
};
|
|
505
501
|
}, [H, U]);
|
|
506
|
-
let q = f.find((e) => e.value ===
|
|
507
|
-
return /* @__PURE__ */
|
|
502
|
+
let q = f.find((e) => e.value === l)?.label ?? l, J = f.findIndex((e) => e.value === R), Y = J >= 0 ? `${j}-option-${J}` : void 0;
|
|
503
|
+
return /* @__PURE__ */ i("div", {
|
|
508
504
|
"data-slot": "hours-picker-field",
|
|
509
505
|
className: e("w-[150px]", g),
|
|
510
506
|
ref: N,
|
|
511
|
-
children: [/* @__PURE__ */
|
|
507
|
+
children: [/* @__PURE__ */ i("button", {
|
|
512
508
|
ref: M,
|
|
513
509
|
id: j,
|
|
514
510
|
type: "button",
|
|
@@ -516,11 +512,11 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
516
512
|
"aria-expanded": H,
|
|
517
513
|
"aria-controls": `${j}-content`,
|
|
518
514
|
"aria-haspopup": "listbox",
|
|
519
|
-
"aria-activedescendant": H ?
|
|
515
|
+
"aria-activedescendant": H ? Y : void 0,
|
|
520
516
|
disabled: v,
|
|
521
517
|
"data-testid": E,
|
|
522
518
|
"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",
|
|
519
|
+
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
520
|
onClick: () => {
|
|
525
521
|
v || y || U(!H);
|
|
526
522
|
},
|
|
@@ -535,7 +531,7 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
535
531
|
U(!0);
|
|
536
532
|
return;
|
|
537
533
|
}
|
|
538
|
-
let t =
|
|
534
|
+
let t = x(R ?? l, e.key === "ArrowDown" ? 1 : -1, f);
|
|
539
535
|
if (!t) return;
|
|
540
536
|
z(t), d?.(t);
|
|
541
537
|
return;
|
|
@@ -545,18 +541,18 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
545
541
|
U(!0);
|
|
546
542
|
return;
|
|
547
543
|
}
|
|
548
|
-
let t = f.find((e) => e.value === R), n =
|
|
544
|
+
let t = f.find((e) => e.value === R), n = b(t) ? t.value : f.find((e) => b(e))?.value;
|
|
549
545
|
n && (G(n), U(!1));
|
|
550
546
|
},
|
|
551
|
-
children: [/* @__PURE__ */
|
|
547
|
+
children: [/* @__PURE__ */ r("span", {
|
|
552
548
|
className: "line-clamp-1 text-left",
|
|
553
|
-
children:
|
|
554
|
-
}), /* @__PURE__ */
|
|
549
|
+
children: l ? q : h
|
|
550
|
+
}), /* @__PURE__ */ r(o, {
|
|
555
551
|
"aria-hidden": !0,
|
|
556
552
|
className: "h-4 w-4 shrink-0 opacity-50"
|
|
557
553
|
})]
|
|
558
554
|
}), H ? (() => {
|
|
559
|
-
let t = /* @__PURE__ */
|
|
555
|
+
let t = /* @__PURE__ */ r(n, { children: /* @__PURE__ */ i("div", {
|
|
560
556
|
ref: P,
|
|
561
557
|
id: `${j}-content`,
|
|
562
558
|
"data-testid": D,
|
|
@@ -569,40 +565,40 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
569
565
|
width: I.width
|
|
570
566
|
},
|
|
571
567
|
children: [
|
|
572
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ r(w, {
|
|
573
569
|
direction: "up",
|
|
574
570
|
viewportRef: F
|
|
575
571
|
}),
|
|
576
|
-
/* @__PURE__ */
|
|
572
|
+
/* @__PURE__ */ r("div", {
|
|
577
573
|
ref: F,
|
|
578
574
|
role: "listbox",
|
|
579
575
|
className: "max-h-64 overflow-y-auto p-1 [overscroll-behavior:contain] [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
|
|
580
576
|
children: f.map((t, n) => {
|
|
581
|
-
let
|
|
582
|
-
return /* @__PURE__ */
|
|
577
|
+
let o = t.value === l, s = t.value === R;
|
|
578
|
+
return /* @__PURE__ */ i("div", {
|
|
583
579
|
id: `${j}-option-${n}`,
|
|
584
580
|
role: "option",
|
|
585
|
-
"aria-selected":
|
|
581
|
+
"aria-selected": o,
|
|
586
582
|
"aria-disabled": t.disabled || void 0,
|
|
587
583
|
"data-value": t.value,
|
|
588
|
-
"data-state":
|
|
584
|
+
"data-state": o ? "checked" : "unchecked",
|
|
589
585
|
"data-disabled": t.disabled ? "" : void 0,
|
|
590
|
-
className: e("relative flex w-full select-none items-center rounded-sm py-1.5
|
|
586
|
+
className: e("relative flex w-full select-none items-center justify-center rounded-sm px-2 py-1.5 text-center text-sm outline-none cursor-pointer", t.disabled && "pointer-events-none opacity-50", s && "bg-accent text-accent-foreground"),
|
|
591
587
|
onMouseDown: (e) => {
|
|
592
588
|
e.preventDefault();
|
|
593
589
|
},
|
|
594
590
|
onClick: () => {
|
|
595
591
|
t.disabled || y || (z(t.value), G(t.value), U(!1), M.current?.focus({ preventScroll: !0 }));
|
|
596
592
|
},
|
|
597
|
-
children: [/* @__PURE__ */
|
|
593
|
+
children: [/* @__PURE__ */ r("span", {
|
|
598
594
|
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center",
|
|
599
|
-
children:
|
|
595
|
+
children: o ? /* @__PURE__ */ r(a, {
|
|
600
596
|
"aria-hidden": !0,
|
|
601
597
|
className: "h-4 w-4"
|
|
602
598
|
}) : null
|
|
603
|
-
}), /* @__PURE__ */
|
|
604
|
-
className: "flex flex-col",
|
|
605
|
-
children: [/* @__PURE__ */
|
|
599
|
+
}), /* @__PURE__ */ i("div", {
|
|
600
|
+
className: "flex w-full min-w-0 flex-col items-center",
|
|
601
|
+
children: [/* @__PURE__ */ r("span", { children: t.label }), t.description == null ? null : /* @__PURE__ */ r("span", {
|
|
606
602
|
"data-slot": "description",
|
|
607
603
|
className: "text-xs text-muted-foreground",
|
|
608
604
|
children: t.description
|
|
@@ -611,220 +607,208 @@ function D({ id: t, value: c, onChange: u, onValueUpdate: d, options: f, placeho
|
|
|
611
607
|
}, t.value);
|
|
612
608
|
})
|
|
613
609
|
}),
|
|
614
|
-
/* @__PURE__ */
|
|
610
|
+
/* @__PURE__ */ r(w, {
|
|
615
611
|
direction: "down",
|
|
616
612
|
viewportRef: F
|
|
617
613
|
})
|
|
618
614
|
]
|
|
619
615
|
}) });
|
|
620
|
-
return typeof document > "u" ? t :
|
|
616
|
+
return typeof document > "u" ? t : c(t, k ?? document.body);
|
|
621
617
|
})() : null]
|
|
622
618
|
});
|
|
623
619
|
}
|
|
624
|
-
function
|
|
625
|
-
return
|
|
620
|
+
function D({ compact: e = !1, ...t }) {
|
|
621
|
+
return r(e ? E : T, { ...t });
|
|
626
622
|
}
|
|
627
|
-
|
|
628
|
-
function
|
|
629
|
-
let
|
|
630
|
-
|
|
631
|
-
|
|
623
|
+
D.displayName = "HourPickerField";
|
|
624
|
+
function O({ id: n, placeholder: a, value: s, onValueUpdate: c, onCommit: u, options: d, disabled: f, readOnly: p, open: m, setOpen: g, inputClassName: x, triggerTestId: S, isHydrated: w, highlightedValueRef: T, setHighlightedValue: E, markKeyboardNavigation: D, inputRef: O, onDraftValueHandlerChange: k }) {
|
|
625
|
+
let A = t.useRef(!1), j = t.useRef(!1), M = t.useRef(!1), N = t.useRef(null), P = t.useRef(null), F = t.useRef(!1), [I, L] = t.useState(() => s || "");
|
|
626
|
+
t.useEffect(() => (k((e) => {
|
|
627
|
+
L(e);
|
|
632
628
|
}), () => {
|
|
633
|
-
|
|
634
|
-
}), [
|
|
635
|
-
let
|
|
636
|
-
let t =
|
|
629
|
+
k(null);
|
|
630
|
+
}), [k]);
|
|
631
|
+
let R = t.useCallback((e) => {
|
|
632
|
+
let t = T.current ?? s ?? "", n = d.findIndex((e) => e.value === t);
|
|
637
633
|
n === -1 && (n = e === 1 ? -1 : d.length);
|
|
638
634
|
for (let t = n + e; t >= 0 && t < d.length; t += e) {
|
|
639
635
|
let e = d[t];
|
|
640
|
-
if (
|
|
641
|
-
|
|
636
|
+
if (b(e)) {
|
|
637
|
+
E(e.value), N.current = e.value, L(e.value), c(e.value);
|
|
642
638
|
return;
|
|
643
639
|
}
|
|
644
640
|
}
|
|
645
641
|
}, [
|
|
646
|
-
|
|
642
|
+
T,
|
|
647
643
|
c,
|
|
648
644
|
d,
|
|
649
|
-
|
|
650
|
-
|
|
645
|
+
E,
|
|
646
|
+
s
|
|
651
647
|
]);
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}, [
|
|
655
|
-
|
|
656
|
-
}, [
|
|
657
|
-
|
|
658
|
-
}, [
|
|
659
|
-
let
|
|
660
|
-
return /* @__PURE__ */
|
|
661
|
-
className: "relative
|
|
662
|
-
children: [
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
mask:
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
if (
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
o && !I.current && (I.current = !0, l(null));
|
|
648
|
+
t.useEffect(() => {
|
|
649
|
+
A.current || L(s || "");
|
|
650
|
+
}, [s]), t.useEffect(() => {
|
|
651
|
+
P.current = _(I);
|
|
652
|
+
}, [I]), t.useEffect(() => {
|
|
653
|
+
s === null && (F.current = !1);
|
|
654
|
+
}, [s]);
|
|
655
|
+
let z = e("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 pr-10 text-left 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]", !I && "text-muted-foreground", m && "ring-2 ring-primary ring-offset-2", "[&_[data-slot='description']]:hidden", x);
|
|
656
|
+
return /* @__PURE__ */ i("div", {
|
|
657
|
+
className: "relative",
|
|
658
|
+
children: [/* @__PURE__ */ r(l, {
|
|
659
|
+
id: n,
|
|
660
|
+
"data-testid": S,
|
|
661
|
+
"data-hydrated": w ? "true" : void 0,
|
|
662
|
+
type: "text",
|
|
663
|
+
disabled: f,
|
|
664
|
+
readOnly: p,
|
|
665
|
+
inputRef: O,
|
|
666
|
+
autoComplete: "off",
|
|
667
|
+
mask: [{
|
|
668
|
+
mask: "00:00",
|
|
669
|
+
lazy: !0
|
|
670
|
+
}, {
|
|
671
|
+
mask: "0:00",
|
|
672
|
+
lazy: !0
|
|
673
|
+
}],
|
|
674
|
+
dispatch: (e, t) => {
|
|
675
|
+
let n = (t.value + e).replace(/\D/g, "");
|
|
676
|
+
if (n.length <= 2 || n.length >= 4) return t.compiledMasks[0];
|
|
677
|
+
let r = h(Number(n.slice(0, 2)));
|
|
678
|
+
return d.some((e) => e.value.startsWith(`${r}:`)) ? t.compiledMasks[0] : t.compiledMasks[1];
|
|
679
|
+
},
|
|
680
|
+
placeholder: a,
|
|
681
|
+
value: I,
|
|
682
|
+
className: z,
|
|
683
|
+
onAccept: (e, t, n) => {
|
|
684
|
+
if (!n) return;
|
|
685
|
+
let r = typeof e == "string" ? e : String(e ?? ""), i = r.replace(/\D/g, ""), a = _(r);
|
|
686
|
+
if (P.current !== a) {
|
|
687
|
+
if (P.current = a, L(r), i.length !== 0) {
|
|
688
|
+
F.current = !1;
|
|
689
|
+
return;
|
|
697
690
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
691
|
+
s && !F.current && (F.current = !0, u(null));
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
onComplete: (e, t, n) => {
|
|
695
|
+
if (!n) return;
|
|
696
|
+
let r = typeof e == "string" ? e : String(e ?? "");
|
|
697
|
+
if (N.current === r) {
|
|
698
|
+
N.current = null;
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
let i = v(r, d);
|
|
702
|
+
if (!i) return;
|
|
703
|
+
if (i.selectableValue) {
|
|
704
|
+
if (E(i.selectableValue), L(i.selectableValue), s === i.selectableValue) return;
|
|
705
|
+
u(i.selectableValue);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
let a = y(i.parsed);
|
|
709
|
+
if (a == null) return;
|
|
710
|
+
let o = C(a, d);
|
|
711
|
+
o && E(o.value);
|
|
712
|
+
},
|
|
713
|
+
onPointerDown: () => {
|
|
714
|
+
j.current = !0, !f && (m || g(!0));
|
|
715
|
+
},
|
|
716
|
+
onMouseDown: (e) => {
|
|
717
|
+
j.current = !0, M.current = typeof document < "u" && document.activeElement === e.currentTarget, !f && (m || g(!0));
|
|
718
|
+
},
|
|
719
|
+
onClick: () => {
|
|
720
|
+
f || m || g(!0);
|
|
721
|
+
},
|
|
722
|
+
onKeyDown: (e) => {
|
|
723
|
+
if (!f) {
|
|
724
|
+
if (e.key === "Tab" && m && !e.defaultPrevented) {
|
|
725
|
+
g(!1);
|
|
704
726
|
return;
|
|
705
727
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
if (D(i.selectableValue), R(i.selectableValue), o === i.selectableValue) return;
|
|
710
|
-
l(i.selectableValue);
|
|
728
|
+
if (e.key === "Escape") {
|
|
729
|
+
if (!m) return;
|
|
730
|
+
e.preventDefault(), g(!1);
|
|
711
731
|
return;
|
|
712
732
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
s && D(s.value);
|
|
717
|
-
},
|
|
718
|
-
onPointerDown: () => {
|
|
719
|
-
M.current = !0, !p && (h || _(!0));
|
|
720
|
-
},
|
|
721
|
-
onMouseDown: (e) => {
|
|
722
|
-
M.current = !0, N.current = typeof document < "u" && document.activeElement === e.currentTarget, !p && (h || _(!0));
|
|
723
|
-
},
|
|
724
|
-
onClick: () => {
|
|
725
|
-
p || h || _(!0);
|
|
726
|
-
},
|
|
727
|
-
onKeyDown: (e) => {
|
|
728
|
-
if (!p) {
|
|
729
|
-
if (e.key === "Tab" && h && !e.defaultPrevented) {
|
|
730
|
-
_(!1);
|
|
733
|
+
if (!m && !e.defaultPrevented && (e.key.length === 1 || e.key === "Backspace" || e.key === "Delete") && !e.ctrlKey && !e.metaKey && !e.altKey && g(!0), e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
734
|
+
if (D(), e.preventDefault(), !m) {
|
|
735
|
+
g(!0);
|
|
731
736
|
return;
|
|
732
737
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
738
|
+
R(e.key === "ArrowDown" ? 1 : -1);
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
if (e.key === "Enter") {
|
|
742
|
+
D();
|
|
743
|
+
let t = v(I, d);
|
|
744
|
+
if (!t) {
|
|
745
|
+
if (!m || I.trim() !== "") return;
|
|
746
|
+
let t = d.find((e) => e.value === T.current), n = (b(t) ? t?.value : void 0) ?? d.find((e) => b(e))?.value;
|
|
747
|
+
if (!n) return;
|
|
748
|
+
e.preventDefault(), E(n), L(n), u(n), g(!1);
|
|
744
749
|
return;
|
|
745
750
|
}
|
|
746
|
-
if (
|
|
747
|
-
|
|
748
|
-
let t = y(L, d);
|
|
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;
|
|
752
|
-
if (!n) return;
|
|
753
|
-
e.preventDefault(), D(n), R(n), l(n), _(!1);
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
if (t.selectableValue) {
|
|
757
|
-
e.preventDefault(), D(t.selectableValue), R(t.selectableValue), l(t.selectableValue), _(!1);
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
let n = b(t.parsed);
|
|
761
|
-
if (n == null) return;
|
|
762
|
-
let r = w(n, d);
|
|
763
|
-
if (!r) return;
|
|
764
|
-
e.preventDefault(), D(r.value), R(r.value), l(r.value), _(!1);
|
|
751
|
+
if (t.selectableValue) {
|
|
752
|
+
e.preventDefault(), E(t.selectableValue), L(t.selectableValue), u(t.selectableValue), g(!1);
|
|
765
753
|
return;
|
|
766
754
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
let t = e.currentTarget;
|
|
773
|
-
requestAnimationFrame(() => t.select());
|
|
774
|
-
}
|
|
775
|
-
p || h || _(!0);
|
|
776
|
-
},
|
|
777
|
-
onBlur: () => {
|
|
778
|
-
j.current = !1;
|
|
779
|
-
let e = L.trim();
|
|
780
|
-
if (!e) {
|
|
781
|
-
R(o || "");
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
let t = y(e, d);
|
|
785
|
-
if (!t) {
|
|
786
|
-
R(o || "");
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
if (!t.selectableValue) {
|
|
790
|
-
R(o || "");
|
|
755
|
+
let n = y(t.parsed);
|
|
756
|
+
if (n == null) return;
|
|
757
|
+
let r = C(n, d);
|
|
758
|
+
if (!r) return;
|
|
759
|
+
e.preventDefault(), E(r.value), L(r.value), u(r.value), g(!1);
|
|
791
760
|
return;
|
|
792
761
|
}
|
|
793
|
-
R(t.selectableValue), o !== t.selectableValue && l(t.selectableValue);
|
|
794
762
|
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
763
|
+
},
|
|
764
|
+
onFocus: (e) => {
|
|
765
|
+
let t = !j.current || !M.current;
|
|
766
|
+
if (j.current = !1, M.current = !1, A.current = !0, t) {
|
|
767
|
+
let t = e.currentTarget;
|
|
768
|
+
requestAnimationFrame(() => t.select());
|
|
769
|
+
}
|
|
770
|
+
f || m || g(!0);
|
|
771
|
+
},
|
|
772
|
+
onBlur: () => {
|
|
773
|
+
A.current = !1;
|
|
774
|
+
let e = I.trim();
|
|
775
|
+
if (!e) {
|
|
776
|
+
L(s || "");
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
let t = v(e, d);
|
|
780
|
+
if (!t) {
|
|
781
|
+
L(s || "");
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (!t.selectableValue) {
|
|
785
|
+
L(s || "");
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
L(t.selectableValue), s !== t.selectableValue && u(t.selectableValue);
|
|
789
|
+
}
|
|
790
|
+
}), /* @__PURE__ */ r("button", {
|
|
791
|
+
type: "button",
|
|
792
|
+
tabIndex: -1,
|
|
793
|
+
disabled: f,
|
|
794
|
+
"data-slot": "hours-picker-input-toggle",
|
|
795
|
+
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"),
|
|
796
|
+
"aria-label": m ? "Close time picker" : "Open time picker",
|
|
797
|
+
onPointerDown: (e) => {
|
|
798
|
+
e.preventDefault();
|
|
799
|
+
},
|
|
800
|
+
onMouseDown: (e) => {
|
|
801
|
+
e.preventDefault();
|
|
802
|
+
},
|
|
803
|
+
onClick: () => {
|
|
804
|
+
f || g(!m);
|
|
805
|
+
},
|
|
806
|
+
children: /* @__PURE__ */ r(o, {
|
|
807
|
+
"aria-hidden": !0,
|
|
808
|
+
className: "size-4"
|
|
825
809
|
})
|
|
826
|
-
]
|
|
810
|
+
})]
|
|
827
811
|
});
|
|
828
812
|
}
|
|
829
813
|
//#endregion
|
|
830
|
-
export {
|
|
814
|
+
export { D as HourPickerField, T as HourPickerInput };
|