asma-ui-core 3.132.0 → 3.133.1
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/asma-ui-core.css +1 -1
- package/dist/components/utils/popover/PopoverSheet.js +168 -151
- package/dist/datetime/components/time-picker/StyledTimePicker.js +102 -88
- package/dist/datetime/components/time-picker/StyledTimePicker.module.js +6 -6
- package/dist/datetime/components/time-picker/TimePickerInput.js +44 -44
- package/dist/datetime/components/time-picker/TimePickerPopper.js +22 -20
- package/dist/datetime/components/time-picker/components/TimePickerBody.js +23 -19
- package/dist/datetime/components/time-picker/components/TimePickerColumn.js +25 -18
- package/dist/datetime/components/time-picker/components/TimePickerPanel.js +13 -11
- package/dist/datetime/components/time-picker/helpers/disabledTime.js +13 -0
- package/dist/src/datetime/components/time-picker/TimePickerInput.d.ts +2 -0
- package/dist/src/datetime/components/time-picker/components/TimePickerPanel.d.ts +4 -0
- package/dist/src/datetime/components/time-picker/helpers/disabledTime.d.ts +35 -0
- package/dist/src/datetime/components/time-picker/types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -1,227 +1,244 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { firstTabbable as
|
|
3
|
-
import { TOP_LAYER_PROPS as
|
|
1
|
+
import { cn as Me } from "../../../helpers/cn.js";
|
|
2
|
+
import { firstTabbable as re } from "../../../helpers/focusable.js";
|
|
3
|
+
import { TOP_LAYER_PROPS as Se, TOP_LAYER_RESET_STYLE as Ce, getOpenModalDialogAncestor as Ie, shouldUsePopoverTopLayer as _e, useTopLayerRef as We } from "../../../hooks/useTopLayer.hook.js";
|
|
4
4
|
import { StyledButton as ke } from "../../inputs/button/StyledButton.js";
|
|
5
|
-
import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as
|
|
6
|
-
import { isKeyboardModality as
|
|
7
|
-
import { useDebouncedValue as
|
|
8
|
-
import { useFocusTrap as
|
|
9
|
-
import { useMobileMediaQuery as
|
|
10
|
-
import { SHEET_TEXT as
|
|
11
|
-
import { formatResultsLabel as
|
|
12
|
-
import { StyledBottomSheet as
|
|
13
|
-
import { PopoverAnatomy as
|
|
14
|
-
import { useCallback as
|
|
15
|
-
import { Fragment as
|
|
16
|
-
import { FloatingPortal as
|
|
17
|
-
var
|
|
5
|
+
import { OverlayBackOwnerContext as He, requestCloseTopOverlayBack as Be, useBackCloses as De } from "../../../hooks/useBackCloses.hook.js";
|
|
6
|
+
import { isKeyboardModality as qe, trackInputModality as Xe } from "../../inputs/full-screen-picker/inputModality.js";
|
|
7
|
+
import { useDebouncedValue as $e } from "../../../hooks/useDebouncedValue.hook.js";
|
|
8
|
+
import { useFocusTrap as Ke } from "../../../hooks/useFocusTrap.hook.js";
|
|
9
|
+
import { useMobileMediaQuery as Ne } from "../../../hooks/useMediaQuery.hook.js";
|
|
10
|
+
import { SHEET_TEXT as je } from "../bottom-sheet/sheetCopy.js";
|
|
11
|
+
import { formatResultsLabel as Ue } from "../bottom-sheet/formatResultsLabel.js";
|
|
12
|
+
import { StyledBottomSheet as Ve } from "../bottom-sheet/StyledBottomSheet.js";
|
|
13
|
+
import { PopoverAnatomy as Ye } from "./PopoverAnatomy.js";
|
|
14
|
+
import { useCallback as p, useEffect as b, useId as ze, useRef as g, useState as l } from "react";
|
|
15
|
+
import { Fragment as ie, jsx as h, jsxs as se } from "react/jsx-runtime";
|
|
16
|
+
import { FloatingPortal as Ge, autoUpdate as Qe, flip as Je, offset as Ze, shift as et, size as tt, useDismiss as ot, useFloating as nt, useInteractions as rt, useMergeRefs as it } from "@floating-ui/react";
|
|
17
|
+
var H = 240, st = {
|
|
18
18
|
info: 472,
|
|
19
19
|
action: 472
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
}, ae = 0.6, ce = "calc(100vw - 32px)", at = () => {
|
|
21
|
+
let o;
|
|
22
|
+
return {
|
|
23
|
+
name: "holdAlignedEdge",
|
|
24
|
+
fn: ({ x: v, rects: w, placement: f }) => {
|
|
25
|
+
const u = f.endsWith("-end"), E = w.floating.width, { x, width: R } = w.reference;
|
|
26
|
+
return !(o !== void 0 && o.x >= x - 1 && o.x <= x + R + 1) || o?.atEnd !== u || o.viewportWidth !== window.innerWidth ? (o = {
|
|
27
|
+
x: u ? v + E : v,
|
|
28
|
+
atEnd: u,
|
|
29
|
+
viewportWidth: window.innerWidth
|
|
30
|
+
}, {}) : { x: u ? o.x - E : o.x };
|
|
31
|
+
},
|
|
32
|
+
release: () => {
|
|
33
|
+
o = void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, Tt = ({ dataTest: o, renderTrigger: v, variant: w = "info", title: f, children: u, viewResultsAction: E, resetAction: x, footerActions: R, resultCount: O, locale: M = "en", closeLabel: B = je[M].close, ariaLabel: D, onOpenChange: q, className: X, align: $ = "auto", ignoreOutside: K }) => {
|
|
37
|
+
const y = ze(), N = `${y}-title`, [n, le] = l(!1), [j, de] = l(), [ue, U] = l(), [fe, me] = l("start"), [S, V] = l(), [pe, Y] = l(H), [z] = l(at), m = Ne(), r = w === "action", ge = m && !r, A = m && r, T = p((e) => {
|
|
38
|
+
le(e), q?.(e);
|
|
39
|
+
}, [q]), { refs: C, floatingStyles: he, context: ve, placement: G, isPositioned: we } = nt({
|
|
40
|
+
open: n,
|
|
41
|
+
onOpenChange: T,
|
|
42
|
+
placement: `${S ?? "bottom"}-${fe}`,
|
|
27
43
|
strategy: "fixed",
|
|
28
|
-
whileElementsMounted:
|
|
44
|
+
whileElementsMounted: Qe,
|
|
29
45
|
middleware: [
|
|
30
|
-
|
|
31
|
-
...
|
|
46
|
+
Ze(8),
|
|
47
|
+
...ge || S ? [] : [Je({
|
|
32
48
|
padding: 8,
|
|
33
49
|
crossAxis: !1,
|
|
34
50
|
flipAlignment: !1
|
|
35
51
|
})],
|
|
36
|
-
|
|
37
|
-
et({
|
|
52
|
+
z,
|
|
53
|
+
et({ padding: 8 }),
|
|
54
|
+
tt({
|
|
38
55
|
padding: 8,
|
|
39
56
|
apply({ availableHeight: e, rects: t }) {
|
|
40
|
-
U(Math.min(e, Math.round(window.innerHeight *
|
|
57
|
+
U(Math.min(e, Math.round(window.innerHeight * ae))), m || Y((c) => Math.max(c, t.floating.width));
|
|
41
58
|
}
|
|
42
59
|
})
|
|
43
60
|
]
|
|
44
61
|
});
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
}, []),
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, [
|
|
54
|
-
const
|
|
62
|
+
n && we && !S && V(G.startsWith("top") ? "top" : "bottom");
|
|
63
|
+
const I = _e(j), d = g(null), [i, Ee] = l(null), xe = p((e) => {
|
|
64
|
+
d.current = e, Ee(e);
|
|
65
|
+
}, []), ye = it([We(C.setFloating, I), xe]), F = g(null), Pe = p((e) => {
|
|
66
|
+
F.current = e, C.setReference(e);
|
|
67
|
+
}, [C]), Q = g(null), _ = K?.length ? K.join(",") : void 0, J = g(_);
|
|
68
|
+
b(() => {
|
|
69
|
+
J.current = _;
|
|
70
|
+
}, [_]);
|
|
71
|
+
const P = p((e) => {
|
|
55
72
|
if (!(e instanceof Element)) return !1;
|
|
56
|
-
if (
|
|
57
|
-
const t =
|
|
73
|
+
if (d.current?.contains(e) || F.current?.contains(e) || Q.current === e) return !0;
|
|
74
|
+
const t = J.current;
|
|
58
75
|
return t !== void 0 && e.closest(t) !== null;
|
|
59
|
-
}, []),
|
|
60
|
-
|
|
61
|
-
}, []), { getFloatingProps:
|
|
62
|
-
enabled: !
|
|
76
|
+
}, []), Z = g(null), be = p((e) => {
|
|
77
|
+
Q.current = e.target, e.target instanceof HTMLElement && d.current?.contains(e.target) && (Z.current = e.target);
|
|
78
|
+
}, []), { getFloatingProps: Re } = rt([ot(ve, {
|
|
79
|
+
enabled: !A,
|
|
63
80
|
escapeKey: !1,
|
|
64
81
|
outsidePress: (e) => {
|
|
65
82
|
const t = e.target;
|
|
66
83
|
if (!(t instanceof Element)) return !0;
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
return !
|
|
84
|
+
if (P(t) || t.closest("[data-floating-ui-portal]")) return !1;
|
|
85
|
+
const c = t.closest('dialog[open], [role="dialog"]');
|
|
86
|
+
return !c || c.contains(d.current);
|
|
70
87
|
}
|
|
71
|
-
})]),
|
|
72
|
-
|
|
73
|
-
}, [
|
|
74
|
-
|
|
75
|
-
active:
|
|
76
|
-
requestClose:
|
|
77
|
-
ownerRef:
|
|
78
|
-
}),
|
|
79
|
-
if (!
|
|
88
|
+
})]), a = p(() => {
|
|
89
|
+
T(!1);
|
|
90
|
+
}, [T]);
|
|
91
|
+
De({
|
|
92
|
+
active: n,
|
|
93
|
+
requestClose: a,
|
|
94
|
+
ownerRef: d
|
|
95
|
+
}), b(() => {
|
|
96
|
+
if (!n || A) return;
|
|
80
97
|
const e = (t) => {
|
|
81
|
-
t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(),
|
|
98
|
+
t.key !== "Escape" || t.defaultPrevented || t.isComposing || (t.preventDefault(), t.stopImmediatePropagation(), Be(t));
|
|
82
99
|
};
|
|
83
100
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
84
|
-
}, [
|
|
85
|
-
const [
|
|
86
|
-
|
|
87
|
-
if (!
|
|
101
|
+
}, [n, A]), Ke(n && r && i !== null, d);
|
|
102
|
+
const [ee, Ae] = l(!1);
|
|
103
|
+
b(() => {
|
|
104
|
+
if (!i || r && !ee) return;
|
|
88
105
|
const e = requestAnimationFrame(() => {
|
|
89
|
-
(
|
|
106
|
+
(r ? re(i) : i)?.focus({ preventScroll: !0 });
|
|
90
107
|
});
|
|
91
108
|
return () => {
|
|
92
109
|
cancelAnimationFrame(e);
|
|
93
110
|
};
|
|
94
111
|
}, [
|
|
112
|
+
i,
|
|
95
113
|
r,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (!r) return;
|
|
114
|
+
ee
|
|
115
|
+
]), b(() => {
|
|
116
|
+
if (!i) return;
|
|
100
117
|
let e = 0;
|
|
101
118
|
const t = () => {
|
|
102
119
|
cancelAnimationFrame(e), e = requestAnimationFrame(() => {
|
|
103
|
-
const
|
|
104
|
-
if (!
|
|
105
|
-
const
|
|
106
|
-
(
|
|
120
|
+
const s = document.activeElement;
|
|
121
|
+
if (!i.isConnected || s && s !== document.body && P(s)) return;
|
|
122
|
+
const k = Z.current;
|
|
123
|
+
(k?.isConnected && i.contains(k) ? k : re(i) ?? i).focus({ preventScroll: !0 });
|
|
107
124
|
});
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
!
|
|
125
|
+
}, c = (s) => {
|
|
126
|
+
s.relatedTarget === null && a();
|
|
127
|
+
}, oe = (s) => {
|
|
128
|
+
s.relatedTarget === null && P(s.target) && t();
|
|
129
|
+
}, ne = (s) => {
|
|
130
|
+
!i.isConnected || P(s.target) || (r ? t() : a());
|
|
114
131
|
};
|
|
115
|
-
return
|
|
116
|
-
cancelAnimationFrame(e), document.removeEventListener("focusout",
|
|
132
|
+
return r ? document.addEventListener("focusout", oe) : i.addEventListener("focusout", c), document.addEventListener("focusin", ne), () => {
|
|
133
|
+
cancelAnimationFrame(e), document.removeEventListener("focusout", oe), i.removeEventListener("focusout", c), document.removeEventListener("focusin", ne);
|
|
117
134
|
};
|
|
118
135
|
}, [
|
|
136
|
+
i,
|
|
119
137
|
r,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
h
|
|
138
|
+
a,
|
|
139
|
+
P
|
|
123
140
|
]);
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
141
|
+
const W = g(!1);
|
|
142
|
+
b(() => {
|
|
143
|
+
if (n) {
|
|
144
|
+
Xe(), W.current = !0;
|
|
128
145
|
return;
|
|
129
146
|
}
|
|
130
|
-
if (!
|
|
131
|
-
|
|
132
|
-
const e =
|
|
147
|
+
if (!W.current) return;
|
|
148
|
+
W.current = !1;
|
|
149
|
+
const e = F.current;
|
|
133
150
|
if (!e) return;
|
|
134
151
|
const t = requestAnimationFrame(() => {
|
|
135
|
-
document.activeElement === document.body && e.focus({ focusVisible:
|
|
152
|
+
document.activeElement === document.body && e.focus({ focusVisible: qe() });
|
|
136
153
|
});
|
|
137
154
|
return () => {
|
|
138
155
|
cancelAnimationFrame(t);
|
|
139
156
|
};
|
|
140
|
-
}, [
|
|
141
|
-
const
|
|
157
|
+
}, [n]);
|
|
158
|
+
const te = {
|
|
142
159
|
ref: Pe,
|
|
143
|
-
isOpen:
|
|
160
|
+
isOpen: n,
|
|
144
161
|
triggerProps: {
|
|
145
162
|
onClick: (e) => {
|
|
146
|
-
if (
|
|
147
|
-
|
|
163
|
+
if (n) {
|
|
164
|
+
a();
|
|
148
165
|
return;
|
|
149
166
|
}
|
|
150
|
-
|
|
151
|
-
const t = e.currentTarget.getBoundingClientRect(),
|
|
152
|
-
|
|
167
|
+
de(Ie(e.currentTarget));
|
|
168
|
+
const t = e.currentTarget.getBoundingClientRect(), c = t.left + t.width / 2 > window.innerWidth / 2;
|
|
169
|
+
me($ === "auto" ? c ? "end" : "start" : $), V(void 0), z.release(), Y(H), U(Math.round(window.innerHeight * ae)), Ae(e.detail === 0), T(!0);
|
|
153
170
|
},
|
|
154
|
-
"aria-expanded":
|
|
155
|
-
"aria-controls":
|
|
156
|
-
"aria-haspopup":
|
|
157
|
-
"aria-describedby": !
|
|
171
|
+
"aria-expanded": n,
|
|
172
|
+
"aria-controls": n ? y : void 0,
|
|
173
|
+
"aria-haspopup": r ? "dialog" : void 0,
|
|
174
|
+
"aria-describedby": !r && n ? y : void 0
|
|
158
175
|
}
|
|
159
|
-
},
|
|
160
|
-
dataTest: `${
|
|
176
|
+
}, L = (e) => typeof e == "function" ? e({ close: a }) : e, Te = $e(O, 500), Fe = E ?? (O === void 0 ? void 0 : /* @__PURE__ */ h(ke, {
|
|
177
|
+
dataTest: `${o}-view-results`,
|
|
161
178
|
type: "button",
|
|
162
179
|
variant: "text",
|
|
163
|
-
onClick:
|
|
164
|
-
children:
|
|
165
|
-
})),
|
|
166
|
-
return
|
|
167
|
-
id:
|
|
168
|
-
dataTest:
|
|
169
|
-
open:
|
|
170
|
-
onClose:
|
|
180
|
+
onClick: a,
|
|
181
|
+
children: Ue(Te, M)
|
|
182
|
+
})), Le = m ? ce : st[w], Oe = m ? ce : void 0;
|
|
183
|
+
return A ? /* @__PURE__ */ se(ie, { children: [v(te), /* @__PURE__ */ h(Ve, {
|
|
184
|
+
id: y,
|
|
185
|
+
dataTest: o,
|
|
186
|
+
open: n,
|
|
187
|
+
onClose: a,
|
|
171
188
|
registerBackClose: !1,
|
|
172
|
-
ownerRef:
|
|
173
|
-
triggerRef:
|
|
174
|
-
title:
|
|
189
|
+
ownerRef: d,
|
|
190
|
+
triggerRef: F,
|
|
191
|
+
title: f,
|
|
175
192
|
ariaLabel: D,
|
|
176
|
-
viewResultsAction:
|
|
177
|
-
resetAction:
|
|
178
|
-
footerActions:
|
|
179
|
-
resultCount:
|
|
180
|
-
locale:
|
|
193
|
+
viewResultsAction: E,
|
|
194
|
+
resetAction: x,
|
|
195
|
+
footerActions: R,
|
|
196
|
+
resultCount: O,
|
|
197
|
+
locale: M,
|
|
181
198
|
closeLabel: B,
|
|
182
199
|
className: X,
|
|
183
|
-
children:
|
|
184
|
-
})] }) : /* @__PURE__ */ ie
|
|
200
|
+
children: u
|
|
201
|
+
})] }) : /* @__PURE__ */ se(ie, { children: [v(te), n && /* @__PURE__ */ h(Ge, {
|
|
185
202
|
root: j,
|
|
186
|
-
children: /* @__PURE__ */
|
|
187
|
-
...
|
|
188
|
-
onFocusCapture:
|
|
189
|
-
ref:
|
|
190
|
-
id:
|
|
191
|
-
"data-placement":
|
|
192
|
-
"data-test":
|
|
193
|
-
"data-testid":
|
|
194
|
-
role:
|
|
195
|
-
"aria-labelledby":
|
|
196
|
-
"aria-label":
|
|
197
|
-
tabIndex:
|
|
198
|
-
...
|
|
203
|
+
children: /* @__PURE__ */ h("div", {
|
|
204
|
+
...Re(),
|
|
205
|
+
onFocusCapture: be,
|
|
206
|
+
ref: ye,
|
|
207
|
+
id: y,
|
|
208
|
+
"data-placement": G,
|
|
209
|
+
"data-test": o,
|
|
210
|
+
"data-testid": o,
|
|
211
|
+
role: r ? "dialog" : void 0,
|
|
212
|
+
"aria-labelledby": r && f ? N : void 0,
|
|
213
|
+
"aria-label": r && !f ? D : void 0,
|
|
214
|
+
tabIndex: r ? void 0 : -1,
|
|
215
|
+
...I ? Se : {},
|
|
199
216
|
style: {
|
|
200
|
-
...
|
|
201
|
-
...
|
|
202
|
-
minWidth:
|
|
217
|
+
...I ? Ce : {},
|
|
218
|
+
...he,
|
|
219
|
+
minWidth: m ? H : pe,
|
|
203
220
|
width: Oe,
|
|
204
|
-
maxWidth:
|
|
221
|
+
maxWidth: Le,
|
|
205
222
|
maxHeight: ue
|
|
206
223
|
},
|
|
207
|
-
className:
|
|
208
|
-
children: /* @__PURE__ */
|
|
209
|
-
value:
|
|
210
|
-
children: /* @__PURE__ */
|
|
211
|
-
dataTest:
|
|
212
|
-
title:
|
|
224
|
+
className: Me("z-[1300]", "box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", X),
|
|
225
|
+
children: /* @__PURE__ */ h(He.Provider, {
|
|
226
|
+
value: d,
|
|
227
|
+
children: /* @__PURE__ */ h(Ye, {
|
|
228
|
+
dataTest: o,
|
|
229
|
+
title: f,
|
|
213
230
|
titleId: N,
|
|
214
|
-
viewResultsAction:
|
|
215
|
-
resetAction: x
|
|
216
|
-
footerActions:
|
|
231
|
+
viewResultsAction: L(Fe),
|
|
232
|
+
resetAction: L(x),
|
|
233
|
+
footerActions: L(R),
|
|
217
234
|
closeLabel: B,
|
|
218
|
-
onClose:
|
|
219
|
-
children:
|
|
235
|
+
onClose: a,
|
|
236
|
+
children: L(u)
|
|
220
237
|
})
|
|
221
238
|
})
|
|
222
239
|
})
|
|
223
240
|
})] });
|
|
224
241
|
};
|
|
225
242
|
export {
|
|
226
|
-
|
|
243
|
+
Tt as PopoverSheet
|
|
227
244
|
};
|
|
@@ -1,125 +1,139 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { isOverlayBackEnabled as
|
|
3
|
-
import { useIsMobileView as
|
|
4
|
-
import { StyledDrawer as
|
|
5
|
-
import { useBackNavigationClose as
|
|
6
|
-
import { usePopupState as
|
|
7
|
-
import { ClickAwayListener as
|
|
8
|
-
import { isBeforeMinTime as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { cn as I } from "../../../helpers/cn.js";
|
|
2
|
+
import { isOverlayBackEnabled as J, useBackCloses as Q } from "../../../hooks/useBackCloses.hook.js";
|
|
3
|
+
import { useIsMobileView as U } from "../../hooks/useWindowWidthSize.hook.js";
|
|
4
|
+
import { StyledDrawer as X } from "../../../components/navigation/drawer/StyledDrawer.js";
|
|
5
|
+
import { useBackNavigationClose as Y } from "../../hooks/useBackNavigationClose.hook.js";
|
|
6
|
+
import { usePopupState as Z } from "../../../hooks/usePopupState.js";
|
|
7
|
+
import { ClickAwayListener as _ } from "../../../components/mui-compat/ClickAwayListener.js";
|
|
8
|
+
import { isBeforeMinTime as V } from "./helpers/minTime.js";
|
|
9
|
+
import { isTimeRejected as A } from "./helpers/disabledTime.js";
|
|
10
|
+
import { TimePickerPanel as $ } from "./components/TimePickerPanel.js";
|
|
11
|
+
import { TimePickerPopper as ee } from "./TimePickerPopper.js";
|
|
12
|
+
import { getTimeFromValue as S } from "./helpers/getTimeFromValue.js";
|
|
13
|
+
import { timePickerWidthProps as R } from "./helpers/timePickerWidth.js";
|
|
14
|
+
import { TimePickerInput as oe } from "./TimePickerInput.js";
|
|
15
|
+
import { useEffect as ie, useState as x } from "react";
|
|
16
|
+
import { jsx as n, jsxs as q } from "react/jsx-runtime";
|
|
17
|
+
import { format as g, isBefore as te, isValid as re } from "date-fns";
|
|
18
|
+
var Te = (t) => {
|
|
19
|
+
const { value: s, onSelect: r, notBeforeTime: k, minTime: f, required: w, isTimeDisabled: y, disabledTimeReason: B } = t, i = Z({
|
|
19
20
|
variant: "popper",
|
|
20
21
|
popupId: "time-picker-popper"
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
active:
|
|
24
|
-
requestClose:
|
|
25
|
-
}),
|
|
26
|
-
open:
|
|
27
|
-
onClose:
|
|
22
|
+
}), d = U();
|
|
23
|
+
Q({
|
|
24
|
+
active: i.isOpen,
|
|
25
|
+
requestClose: i.close
|
|
26
|
+
}), Y({
|
|
27
|
+
open: d && i.isOpen && !J(),
|
|
28
|
+
onClose: i.close
|
|
28
29
|
});
|
|
29
|
-
const { isOpen:
|
|
30
|
-
|
|
31
|
-
if (!
|
|
32
|
-
const e = (
|
|
33
|
-
|
|
30
|
+
const { isOpen: O, anchorEl: D, close: E } = i;
|
|
31
|
+
ie(() => {
|
|
32
|
+
if (!O || d) return;
|
|
33
|
+
const e = (o) => {
|
|
34
|
+
D?.contains(document.activeElement) && (o.key === "Escape" ? (o.preventDefault(), o.stopPropagation(), E()) : o.key === "Tab" && E());
|
|
34
35
|
};
|
|
35
36
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
36
37
|
}, [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
O,
|
|
39
|
+
D,
|
|
40
|
+
E,
|
|
41
|
+
d
|
|
41
42
|
]);
|
|
42
|
-
const
|
|
43
|
+
const N = s ? g(s, "HH:mm") : "", [b, p] = x(N), [T, a] = x(!1), [h, l] = x(!1), c = T ? b : N, v = (e) => !e || !k || !re(k) || !te(e, k), C = (e) => !A(e, y), m = c.length === 5 ? S(c, s) : null, F = !h || c === "" || m !== null, K = !h || !m || v(m), H = !!w && h && c === "", W = h && A(m ?? void 0, y) ? B : void 0, L = (e) => {
|
|
43
44
|
if (e === "") return !0;
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
},
|
|
47
|
-
const
|
|
48
|
-
if (a(!0),
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
45
|
+
const o = S(e, s);
|
|
46
|
+
return o !== null && v(o) && C(o);
|
|
47
|
+
}, z = (e) => {
|
|
48
|
+
const o = e.target.value;
|
|
49
|
+
if (a(!0), p(o), (H || L(o)) && l(!1), o.length !== 5) return;
|
|
50
|
+
const u = S(o, s);
|
|
51
|
+
if (!u) {
|
|
51
52
|
r(void 0);
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
if (!V(u, f)) {
|
|
56
|
+
if (!C(u)) {
|
|
57
|
+
r(void 0);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
v(u) ? (r(u), a(!1), i.close()) : r(void 0);
|
|
61
|
+
}
|
|
62
|
+
}, j = (e) => {
|
|
63
|
+
if (e && V(e, f)) return;
|
|
64
|
+
if (!C(e)) {
|
|
65
|
+
l(!0);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const o = v(e);
|
|
69
|
+
if (l(!o), o) {
|
|
70
|
+
r(e), p(e ? g(e, "HH:mm") : ""), a(!1);
|
|
60
71
|
return;
|
|
61
72
|
}
|
|
62
|
-
r(void 0),
|
|
63
|
-
},
|
|
64
|
-
if (
|
|
65
|
-
|
|
73
|
+
r(void 0), p(e ? g(e, "HH:mm") : ""), a(!0);
|
|
74
|
+
}, G = () => {
|
|
75
|
+
if (w && c === "" && !i.isOpen) {
|
|
76
|
+
T && r(void 0), l(!0);
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
r(void 0),
|
|
71
|
-
}, P = /* @__PURE__ */ n(
|
|
72
|
-
...
|
|
73
|
-
popupState:
|
|
74
|
-
localValue:
|
|
75
|
-
isValidTime:
|
|
76
|
-
isValidEndTime:
|
|
77
|
-
isMissingTime:
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
T && (m && V(m, f) ? a(!1) : b === "" ? r(void 0) : L(b) || l(!0));
|
|
80
|
+
}, M = () => {
|
|
81
|
+
r(void 0), p(""), a(!1), l(!!w);
|
|
82
|
+
}, P = /* @__PURE__ */ n(oe, {
|
|
83
|
+
...t,
|
|
84
|
+
popupState: i,
|
|
85
|
+
localValue: c,
|
|
86
|
+
isValidTime: F,
|
|
87
|
+
isValidEndTime: K,
|
|
88
|
+
isMissingTime: H,
|
|
89
|
+
disabledTimeError: W,
|
|
90
|
+
handleChange: z,
|
|
91
|
+
handleBlur: G
|
|
80
92
|
});
|
|
81
|
-
return
|
|
82
|
-
className:
|
|
83
|
-
...
|
|
93
|
+
return t.disabled || t.readOnly || t.lockedReason ? P : d ? /* @__PURE__ */ q("div", {
|
|
94
|
+
className: I("relative h-auto", typeof t.width == "number" && "w-auto"),
|
|
95
|
+
...R(t.width),
|
|
84
96
|
children: [/* @__PURE__ */ n("div", {
|
|
85
97
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
86
98
|
children: P
|
|
87
|
-
}), /* @__PURE__ */ n(
|
|
99
|
+
}), /* @__PURE__ */ n(X, {
|
|
88
100
|
anchor: "bottom",
|
|
89
|
-
open:
|
|
90
|
-
onClose:
|
|
91
|
-
anchorEl:
|
|
101
|
+
open: i.isOpen,
|
|
102
|
+
onClose: i.close,
|
|
103
|
+
anchorEl: i.anchorEl,
|
|
92
104
|
registerBackClose: !1,
|
|
93
105
|
children: /* @__PURE__ */ n("div", {
|
|
94
106
|
className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
|
|
95
|
-
children: /* @__PURE__ */ n(
|
|
96
|
-
dataTest:
|
|
107
|
+
children: /* @__PURE__ */ n($, {
|
|
108
|
+
dataTest: t.dataTest,
|
|
97
109
|
value: s,
|
|
98
|
-
minTime:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
minTime: f,
|
|
111
|
+
isTimeDisabled: y,
|
|
112
|
+
disabledTimeReason: B,
|
|
113
|
+
onSelect: j,
|
|
114
|
+
handleClear: M,
|
|
115
|
+
onConfirm: i.close
|
|
102
116
|
})
|
|
103
117
|
})
|
|
104
118
|
})]
|
|
105
|
-
}) : /* @__PURE__ */ n(
|
|
119
|
+
}) : /* @__PURE__ */ n(_, {
|
|
106
120
|
mouseEvent: "onMouseDown",
|
|
107
|
-
onClickAway:
|
|
108
|
-
children: /* @__PURE__ */
|
|
109
|
-
className:
|
|
110
|
-
...
|
|
121
|
+
onClickAway: i.close,
|
|
122
|
+
children: /* @__PURE__ */ q("div", {
|
|
123
|
+
className: I("relative h-auto", typeof t.width == "number" && "w-auto"),
|
|
124
|
+
...R(t.width),
|
|
111
125
|
children: [/* @__PURE__ */ n("div", {
|
|
112
126
|
className: "m-0 flex h-fit items-center justify-center p-0",
|
|
113
127
|
children: P
|
|
114
|
-
}),
|
|
115
|
-
...
|
|
116
|
-
popupState:
|
|
117
|
-
handleClear:
|
|
118
|
-
onSelect:
|
|
128
|
+
}), i.isOpen && /* @__PURE__ */ n(ee, {
|
|
129
|
+
...t,
|
|
130
|
+
popupState: i,
|
|
131
|
+
handleClear: M,
|
|
132
|
+
onSelect: j
|
|
119
133
|
})]
|
|
120
134
|
})
|
|
121
135
|
});
|
|
122
136
|
};
|
|
123
137
|
export {
|
|
124
|
-
|
|
138
|
+
Te as StyledTimePicker
|
|
125
139
|
};
|