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