asma-ui-core 3.61.2 → 3.61.4

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,62 +1,62 @@
1
- import { cn as P } from "../../../helpers/cn.js";
2
- import { resolveSx as L } from "../../../helpers/sx.js";
3
- import { TOP_LAYER_PROPS as M, TOP_LAYER_RESET_STYLE as Y, getOpenModalDialogAncestor as j, useTopLayerRef as k } from "../../../hooks/useTopLayer.hook.js";
4
- import { cloneElement as C, useRef as D, useState as H } from "react";
5
- import { Fragment as I, jsx as a, jsxs as d } from "react/jsx-runtime";
6
- import { FloatingArrow as N, FloatingPortal as U, arrow as z, autoUpdate as B, flip as G, offset as W, shift as q, useDismiss as J, useFloating as K, useFocus as Q, useHover as V, useInteractions as X, useMergeRefs as Z, useRole as $ } from "@floating-ui/react";
7
- var ee = "#363E4A", ae = (e) => !e.title && e.title !== 0 ? e.children : /* @__PURE__ */ a(te, { ...e }), te = ({ title: e, children: o, placement: m = "top", arrow: n = !1, enterDelay: g = 500, leaveDelay: u = 0, open: f, onOpen: x, onClose: R, disableHoverListener: v, disableFocusListener: F, offsetDistance: _, className: h, slotProps: r }) => {
8
- const [w, y] = H(!1), l = f !== void 0, s = f ?? w, p = D(null), E = (c) => {
9
- l || y(c), c ? x?.() : R?.();
10
- }, { refs: i, floatingStyles: O, context: t } = K({
11
- open: s,
12
- onOpenChange: E,
13
- placement: m,
1
+ import { cn as S } from "../../../helpers/cn.js";
2
+ import { resolveSx as M } from "../../../helpers/sx.js";
3
+ import { TOP_LAYER_PROPS as U, TOP_LAYER_RESET_STYLE as Y, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as k, useTopLayerRef as C } from "../../../hooks/useTopLayer.hook.js";
4
+ import { cloneElement as D, useRef as H, useState as I } from "react";
5
+ import { Fragment as N, jsx as f, jsxs as g } from "react/jsx-runtime";
6
+ import { FloatingArrow as z, FloatingPortal as B, arrow as G, autoUpdate as W, flip as q, offset as J, shift as K, useDismiss as Q, useFloating as V, useFocus as X, useHover as Z, useInteractions as $, useMergeRefs as ee, useRole as oe } from "@floating-ui/react";
7
+ var te = "#363E4A", pe = (e) => !e.title && e.title !== 0 ? e.children : /* @__PURE__ */ f(re, { ...e }), re = ({ title: e, children: t, placement: u = "top", arrow: r = !1, enterDelay: x = 500, leaveDelay: R = 0, open: p, onOpen: v, onClose: y, disableHoverListener: h, disableFocusListener: F, offsetDistance: T, className: _, slotProps: n }) => {
8
+ const [w, E] = I(!1), s = p !== void 0, l = p ?? w, c = H(null), O = (m) => {
9
+ s || E(m), m ? v?.() : y?.();
10
+ }, { refs: a, floatingStyles: P, context: o } = V({
11
+ open: l,
12
+ onOpenChange: O,
13
+ placement: u,
14
14
  strategy: "fixed",
15
- whileElementsMounted: B,
15
+ whileElementsMounted: W,
16
16
  middleware: [
17
- W(_ ?? (n ? 8 : 6)),
18
- G({ padding: 8 }),
17
+ J(T ?? (r ? 8 : 6)),
19
18
  q({ padding: 8 }),
20
- ...n ? [z({ element: p })] : []
19
+ K({ padding: 8 }),
20
+ ...r ? [G({ element: c })] : []
21
21
  ]
22
- }), { getReferenceProps: T, getFloatingProps: b } = X([
23
- V(t, {
24
- enabled: !l && !v,
22
+ }), { getReferenceProps: b, getFloatingProps: A } = $([
23
+ Z(o, {
24
+ enabled: !s && !h,
25
25
  delay: {
26
- open: g,
27
- close: u
26
+ open: x,
27
+ close: R
28
28
  },
29
29
  move: !1
30
30
  }),
31
- Q(t, { enabled: !l && !F }),
32
- J(t),
33
- $(t, { role: "tooltip" })
34
- ]), A = k(i.setFloating), S = s ? j(i.reference.current) : void 0;
35
- return /* @__PURE__ */ d(I, { children: [C(o, T({
36
- ref: Z([i.setReference, o.ref]),
37
- ...o.props
38
- })), s && /* @__PURE__ */ a(U, {
39
- root: S,
40
- children: /* @__PURE__ */ d("div", {
41
- ref: A,
42
- ...M,
43
- ...b(),
31
+ X(o, { enabled: !s && !F }),
32
+ Q(o),
33
+ oe(o, { role: "tooltip" })
34
+ ]), d = l ? j(a.reference.current) : void 0, i = k(d), L = C(a.setFloating, i);
35
+ return /* @__PURE__ */ g(N, { children: [D(t, b({
36
+ ref: ee([a.setReference, t.ref]),
37
+ ...t.props
38
+ })), l && /* @__PURE__ */ f(B, {
39
+ root: d,
40
+ children: /* @__PURE__ */ g("div", {
41
+ ref: L,
42
+ ...i ? U : {},
43
+ ...A(),
44
44
  style: {
45
- ...Y,
46
- ...O,
45
+ ...i ? Y : {},
46
+ ...P,
47
47
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
48
- ...r?.tooltip?.style,
49
- ...L(r?.tooltip?.sx)
48
+ ...n?.tooltip?.style,
49
+ ...M(n?.tooltip?.sx)
50
50
  },
51
- className: P("z-[1500] block max-w-[320px] whitespace-normal break-words rounded-[3px] bg-[#363E4A] px-2 py-1 text-sm leading-5 text-white shadow-[0px_1px_6px_0px_rgba(0,0,0,0.15)]", h, r?.tooltip?.className),
52
- children: [e, n && /* @__PURE__ */ a(N, {
53
- ref: p,
54
- context: t,
55
- fill: ee
51
+ className: S("z-[1500] block max-w-[320px] whitespace-normal break-words rounded-[3px] bg-[#363E4A] px-2 py-1 text-sm leading-5 text-white shadow-[0px_1px_6px_0px_rgba(0,0,0,0.15)]", _, n?.tooltip?.className),
52
+ children: [e, r && /* @__PURE__ */ f(z, {
53
+ ref: c,
54
+ context: o,
55
+ fill: te
56
56
  })]
57
57
  })
58
58
  })] });
59
59
  };
60
60
  export {
61
- ae as StyledTooltip
61
+ pe as StyledTooltip
62
62
  };
@@ -1,182 +1,186 @@
1
1
  import { cn as f } from "../../../helpers/cn.js";
2
- import { resolveSx as ge } from "../../../helpers/sx.js";
3
- import { ChevronDownIcon as xe } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
- import { CloseIcon as ye } from "../../icons/close-icon/CloseIcon.js";
5
- import { ErrorOutlineIcon as be } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
6
- import { TOP_LAYER_PROPS as he, TOP_LAYER_RESET_STYLE as we, getOpenModalDialogAncestor as Ae, useTopLayerRef as ve } from "../../../hooks/useTopLayer.hook.js";
7
- import { outlineClass as Re } from "../field-styles.js";
8
- import { useFormControlContext as ke } from "../../miscellaneous/FormControlContext.js";
9
- import { StyledFormHelperText as Fe } from "../../miscellaneous/StyledFormHelperText.js";
10
- import { Children as C, cloneElement as De, isValidElement as E, useEffect as N, useMemo as Se, useRef as Ce, useState as _ } from "react";
2
+ import { resolveSx as he } from "../../../helpers/sx.js";
3
+ import { ChevronDownIcon as we } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
+ import { CloseIcon as Ae } from "../../icons/close-icon/CloseIcon.js";
5
+ import { ErrorOutlineIcon as ve } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
6
+ import { TOP_LAYER_PROPS as Re, TOP_LAYER_RESET_STYLE as ke, getOpenModalDialogAncestor as Fe, shouldUsePopoverTopLayer as De, useTopLayerRef as Se } from "../../../hooks/useTopLayer.hook.js";
7
+ import { outlineClass as Ce } from "../field-styles.js";
8
+ import { useFormControlContext as Ee } from "../../miscellaneous/FormControlContext.js";
9
+ import { StyledFormHelperText as Ne } from "../../miscellaneous/StyledFormHelperText.js";
10
+ import { Children as E, cloneElement as Pe, isValidElement as N, useEffect as P, useMemo as _e, useRef as H, useState as _ } from "react";
11
11
  import { jsx as n, jsxs as h } from "react/jsx-runtime";
12
- import { FloatingPortal as Ee, autoUpdate as Ne, flip as _e, offset as qe, shift as Pe, size as Te, useClick as Ve, useDismiss as je, useFloating as Be, useInteractions as Ie, useMergeRefs as L, useRole as Ue } from "@floating-ui/react";
13
- var Xe = ({ dataTest: q, value: P, defaultValue: M, onChange: T, error: H, errorText: O, allowClear: V, disabled: Y, readOnly: c, name: m, placeholder: w, displayEmpty: A, multiple: d, renderValue: j, fullWidth: z, className: W, style: $, sx: G, variant: J, children: v, MenuProps: Q, onFocus: X, onBlur: Z, labelId: p }) => {
14
- const a = ke(), B = `${q}-listbox`, g = J === "standard", I = H ?? a?.error ?? !1, s = Y ?? a?.disabled ?? !1, [o, x] = _(!1), [y, R] = _(!1), [ee, U] = _(M), k = P !== void 0, r = k ? P : ee, l = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, i = Ce(null), { refs: u, floatingStyles: te, context: F } = Be({
12
+ import { FloatingPortal as qe, autoUpdate as Te, flip as Le, offset as Ue, shift as Ve, size as je, useClick as Be, useDismiss as Ie, useFloating as Ke, useInteractions as Me, useMergeRefs as Y, useRole as Oe } from "@floating-ui/react";
13
+ var rt = ({ dataTest: q, value: T, defaultValue: z, onChange: L, error: W, errorText: $, allowClear: U, disabled: G, readOnly: c, name: m, placeholder: w, displayEmpty: A, multiple: u, renderValue: V, fullWidth: J, className: Q, style: X, sx: Z, variant: ee, children: v, MenuProps: te, onFocus: re, onBlur: oe, labelId: p }) => {
14
+ const i = Ee(), j = `${q}-listbox`, g = ee === "standard", B = W ?? i?.error ?? !1, s = G ?? i?.disabled ?? !1, [o, y] = _(!1), [x, R] = _(!1), [se, I] = _(z), k = T !== void 0, r = k ? T : se, a = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, l = H(null), K = H(null), ne = (e) => {
15
+ if (y(e), e) return;
16
+ const t = document.activeElement;
17
+ t && t !== document.body && !l.current?.contains(t) || K.current?.focus();
18
+ }, { refs: d, floatingStyles: ae, context: F } = Ke({
15
19
  open: o,
16
- onOpenChange: x,
20
+ onOpenChange: ne,
17
21
  placement: "bottom-start",
18
22
  strategy: "fixed",
19
- whileElementsMounted: Ne,
23
+ whileElementsMounted: Te,
20
24
  middleware: [
21
- qe(4),
22
- _e({ padding: 8 }),
23
- Pe({ padding: 8 }),
24
- Te({ apply({ rects: e, elements: t }) {
25
+ Ue(4),
26
+ Le({ padding: 8 }),
27
+ Ve({ padding: 8 }),
28
+ je({ apply({ rects: e, elements: t }) {
25
29
  t.floating.style.minWidth = `${e.reference.width + 20}px`;
26
30
  } })
27
31
  ]
28
- }), { getReferenceProps: re, getFloatingProps: oe } = Ie([
29
- Ve(F, { enabled: !s && !c }),
30
- je(F),
31
- Ue(F, { role: "listbox" })
32
- ]), se = L([u.setReference]), ne = L([ve(u.setFloating), i]), le = Se(() => o ? Ae(u.reference.current) : void 0, [o, u]);
33
- N(() => a?.setFocused(o || y), [
32
+ }), { getReferenceProps: le, getFloatingProps: ie } = Me([
33
+ Be(F, { enabled: !s && !c }),
34
+ Ie(F),
35
+ Oe(F, { role: "listbox" })
36
+ ]), ce = Y([d.setReference, K]), M = _e(() => o ? Fe(d.reference.current) : void 0, [o, d]), D = De(M), ue = Y([Se(d.setFloating, D), l]);
37
+ P(() => i?.setFocused(o || x), [
34
38
  o,
35
- y,
36
- a
37
- ]), N(() => a?.setFilled(l || !!w || !!A), [
38
- l,
39
+ x,
40
+ i
41
+ ]), P(() => i?.setFilled(a || !!w || !!A), [
42
+ a,
39
43
  w,
40
44
  A,
41
- a
42
- ]), N(() => {
45
+ i
46
+ ]), P(() => {
43
47
  if (!o) return;
44
48
  const e = requestAnimationFrame(() => {
45
- const t = i.current?.querySelector('[role="option"][aria-selected="true"]');
49
+ const t = l.current?.querySelector('[role="option"][aria-selected="true"]');
46
50
  t && (t.scrollIntoView({ block: "nearest" }), t.focus());
47
51
  });
48
52
  return () => cancelAnimationFrame(e);
49
53
  }, [o]);
50
- const ae = (e, t) => {
51
- const b = d ? Array.isArray(r) && r.includes(e) ? r.filter((S) => S !== e) : [...Array.isArray(r) ? r : [], e] : e;
52
- k || U(b), T?.({ target: {
54
+ const de = (e, t) => {
55
+ const b = u ? Array.isArray(r) && r.includes(e) ? r.filter((C) => C !== e) : [...Array.isArray(r) ? r : [], e] : e;
56
+ k || I(b), L?.({ target: {
53
57
  value: b,
54
58
  name: m
55
- } }, t), d || (x(!1), requestAnimationFrame(() => u.domReference.current?.focus()));
56
- }, K = () => {
57
- const e = d ? [] : "";
58
- k || U(e), T?.({ target: {
59
+ } }, t), u || (y(!1), requestAnimationFrame(() => d.domReference.current?.focus()));
60
+ }, O = () => {
61
+ const e = u ? [] : "";
62
+ k || I(e), L?.({ target: {
59
63
  value: e,
60
64
  name: m
61
- } }, null), x(!1), R(!1);
62
- }, ie = C.map(v, (e) => {
63
- if (!E(e)) return e;
65
+ } }, null), y(!1), R(!1);
66
+ }, fe = E.map(v, (e) => {
67
+ if (!N(e)) return e;
64
68
  const t = e.props.value;
65
- return De(e, {
66
- selected: d ? Array.isArray(r) && r.includes(t) : t === r,
67
- onClick: () => ae(t, e.props.children)
69
+ return Pe(e, {
70
+ selected: u ? Array.isArray(r) && r.includes(t) : t === r,
71
+ onClick: () => de(t, e.props.children)
68
72
  });
69
- }), ce = C.toArray(v).find((e) => E(e) && e.props.value === r), de = j ? j(r) : d && Array.isArray(r) ? C.toArray(v).filter((e) => E(e) && r.includes(e.props.value)).map((e) => {
73
+ }), me = E.toArray(v).find((e) => N(e) && e.props.value === r), pe = V ? V(r) : u && Array.isArray(r) ? E.toArray(v).filter((e) => N(e) && r.includes(e.props.value)).map((e) => {
70
74
  const t = e.props.children;
71
75
  return typeof t == "string" || typeof t == "number" ? String(t) : "";
72
- }).join(", ") : ce?.props.children, ue = (e) => {
73
- if ((e.key === "Backspace" || e.key === "Delete") && V && l && !s && !c) {
74
- e.preventDefault(), K();
76
+ }).join(", ") : me?.props.children, ge = (e) => {
77
+ if ((e.key === "Backspace" || e.key === "Delete") && U && a && !s && !c) {
78
+ e.preventDefault(), O();
75
79
  return;
76
80
  }
77
- e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || c || (e.preventDefault(), x(!0), requestAnimationFrame(() => {
78
- if (i.current?.querySelector('[role="option"][aria-selected="true"]')) return;
79
- const t = i.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
81
+ e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || c || (e.preventDefault(), y(!0), requestAnimationFrame(() => {
82
+ if (l.current?.querySelector('[role="option"][aria-selected="true"]')) return;
83
+ const t = l.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
80
84
  t?.length && t[e.key === "ArrowUp" ? t.length - 1 : 0]?.focus();
81
85
  }));
82
- }, fe = (e) => {
83
- const t = i.current ? Array.from(i.current.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) : [];
86
+ }, ye = (e) => {
87
+ const t = l.current ? Array.from(l.current.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) : [];
84
88
  if (t.length === 0) return;
85
- const b = t.findIndex((S) => S === document.activeElement);
89
+ const b = t.findIndex((C) => C === document.activeElement);
86
90
  e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(b + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), document.activeElement?.click());
87
- }, D = g && (o || y), me = s ? "text-delta-300" : D ? "text-gama-500" : "text-delta-800", pe = s ? "text-delta-300" : "text-delta-700";
91
+ }, S = g && (o || x), xe = s ? "text-delta-300" : S ? "text-gama-500" : "text-delta-800", be = s ? "text-delta-300" : "text-delta-700";
88
92
  return /* @__PURE__ */ h("div", {
89
- className: f("group relative inline-flex flex-col", z && "w-full", W),
93
+ className: f("group relative inline-flex flex-col", J && "w-full", Q),
90
94
  style: {
91
95
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
92
- ...ge(G),
93
- ...$
96
+ ...he(Z),
97
+ ...X
94
98
  },
95
99
  children: [
96
100
  /* @__PURE__ */ h("button", {
97
- ref: se,
101
+ ref: ce,
98
102
  type: "button",
99
103
  "data-testid": q,
100
- ...re({ onKeyDown: ue }),
104
+ ...le({ onKeyDown: ge }),
101
105
  role: "combobox",
102
106
  "aria-haspopup": "listbox",
103
107
  "aria-expanded": o,
104
- "aria-controls": B,
108
+ "aria-controls": j,
105
109
  "aria-labelledby": p,
106
110
  "aria-label": p ? void 0 : m,
107
111
  "aria-disabled": s ? !0 : void 0,
108
112
  disabled: s,
109
113
  onFocus: (e) => {
110
- R(!0), X?.(e);
114
+ R(!0), re?.(e);
111
115
  },
112
116
  onBlur: (e) => {
113
- R(!1), Z?.(e);
117
+ R(!1), oe?.(e);
114
118
  },
115
- style: { minWidth: l && !g ? 105 : void 0 },
116
- className: f("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", D ? "bg-gama-50" : "bg-transparent", me, g && "min-w-0", s && "cursor-not-allowed", c && "pointer-events-none"),
119
+ style: { minWidth: a && !g ? 105 : void 0 },
120
+ className: f("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", S ? "bg-gama-50" : "bg-transparent", xe, g && "min-w-0", s && "cursor-not-allowed", c && "pointer-events-none"),
117
121
  children: [
118
122
  /* @__PURE__ */ n("span", {
119
- className: f("min-w-0 flex-1 truncate", !l && "text-delta-500"),
120
- children: l || A ? de : w
123
+ className: f("min-w-0 flex-1 truncate", !a && "text-delta-500"),
124
+ children: a || A ? pe : w
121
125
  }),
122
126
  /* @__PURE__ */ h("span", {
123
127
  className: "flex items-center gap-1",
124
- children: [V && l && !s && /* @__PURE__ */ n("span", {
128
+ children: [U && a && !s && /* @__PURE__ */ n("span", {
125
129
  "aria-hidden": "true",
126
130
  "data-testid": "select-clear-button",
127
131
  className: "flex items-center justify-center rounded-full p-[2px] hover:bg-gama-100",
128
132
  onClick: (e) => {
129
- e.stopPropagation(), K();
133
+ e.stopPropagation(), O();
130
134
  },
131
- children: /* @__PURE__ */ n(ye, {
135
+ children: /* @__PURE__ */ n(Ae, {
132
136
  width: 18,
133
137
  height: 18
134
138
  })
135
- }), /* @__PURE__ */ n(xe, {
139
+ }), /* @__PURE__ */ n(we, {
136
140
  width: 24,
137
141
  height: 24,
138
- className: f("shrink-0 transition-transform", D ? "text-gama-500" : pe, o && "rotate-180")
142
+ className: f("shrink-0 transition-transform", S ? "text-gama-500" : be, o && "rotate-180")
139
143
  })]
140
144
  }),
141
- /* @__PURE__ */ n("div", { className: Re({
142
- focused: o || y,
143
- error: I,
145
+ /* @__PURE__ */ n("div", { className: Ce({
146
+ focused: o || x,
147
+ error: B,
144
148
  disabled: s,
145
149
  readOnly: c,
146
150
  borderless: g
147
151
  }) })
148
152
  ]
149
153
  }),
150
- o && /* @__PURE__ */ n(Ee, {
151
- root: le,
154
+ o && /* @__PURE__ */ n(qe, {
155
+ root: M,
152
156
  children: /* @__PURE__ */ n("ul", {
153
- ref: ne,
154
- id: B,
157
+ ref: ue,
158
+ id: j,
155
159
  role: "listbox",
156
160
  "aria-labelledby": p,
157
161
  "aria-label": p ? void 0 : m,
158
- ...he,
162
+ ...D ? Re : {},
159
163
  style: {
160
- ...we,
161
- ...te,
164
+ ...D ? ke : {},
165
+ ...ae,
162
166
  fontFamily: "Roboto, Helvetica, Arial, sans-serif"
163
167
  },
164
- ...oe(),
165
- onKeyDown: fe,
166
- className: f("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", Q?.className),
167
- children: ie
168
+ ...ie(),
169
+ onKeyDown: ye,
170
+ className: f("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", te?.className),
171
+ children: fe
168
172
  })
169
173
  }),
170
- I && /* @__PURE__ */ h(Fe, {
174
+ B && /* @__PURE__ */ h(Ne, {
171
175
  className: "m-0 flex items-center gap-1 pt-1 text-sm text-error-500",
172
- children: [/* @__PURE__ */ n(be, {
176
+ children: [/* @__PURE__ */ n(ve, {
173
177
  width: 20,
174
178
  height: 20
175
- }), O ?? "Required"]
179
+ }), $ ?? "Required"]
176
180
  })
177
181
  ]
178
182
  });
179
183
  };
180
184
  export {
181
- Xe as StyledSelect
185
+ rt as StyledSelect
182
186
  };
@@ -1,33 +1,33 @@
1
- import { cn as $ } from "../../../helpers/cn.js";
1
+ import { cn as L } from "../../../helpers/cn.js";
2
2
  import { ChevronDownIcon as He } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
3
- import { CloseIcon as Te } from "../../icons/close-icon/CloseIcon.js";
4
- import { CheckIcon as Ye } from "../../icons/check-icon/CheckIcon.js";
5
- import { PlusIconCircle as Oe } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
- import { StyledChip as Be } from "../../data-display/chip/StyledChip.js";
7
- import { StyledCheckbox as q } from "../checkbox/base-ui/StyledCheckbox.js";
8
- import { TOP_LAYER_PROPS as qe, TOP_LAYER_RESET_STYLE as Ge, getOpenModalDialogAncestor as Je, useTopLayerRef as Qe } from "../../../hooks/useTopLayer.hook.js";
9
- import { LoadingIcon as Xe } from "../../../table/shared-components/LoadingIcon.js";
10
- import G from "./StyledSelectAutocomplete.module.js";
11
- import { useEffect as Ze, useMemo as L, useRef as J, useState as w } from "react";
3
+ import { CloseIcon as Ye } from "../../icons/close-icon/CloseIcon.js";
4
+ import { CheckIcon as Oe } from "../../icons/check-icon/CheckIcon.js";
5
+ import { PlusIconCircle as Be } from "../../icons/plus-icon-circle/PlusIconCircle.js";
6
+ import { StyledChip as qe } from "../../data-display/chip/StyledChip.js";
7
+ import { StyledCheckbox as J } from "../checkbox/base-ui/StyledCheckbox.js";
8
+ import { TOP_LAYER_PROPS as Ge, TOP_LAYER_RESET_STYLE as Je, getOpenModalDialogAncestor as Qe, shouldUsePopoverTopLayer as Xe, useTopLayerRef as Ze } from "../../../hooks/useTopLayer.hook.js";
9
+ import { LoadingIcon as Ke } from "../../../table/shared-components/LoadingIcon.js";
10
+ import Q from "./StyledSelectAutocomplete.module.js";
11
+ import { useEffect as et, useMemo as _, useRef as X, useState as w } from "react";
12
12
  import { jsx as s, jsxs as y } from "react/jsx-runtime";
13
- import { FloatingPortal as Ke, autoUpdate as et, flip as tt, offset as rt, shift as lt, size as st, useDismiss as ot, useFloating as at, useInteractions as nt, useMergeRefs as Q, useRole as ct } from "@floating-ui/react";
14
- var it = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), X = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
- function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, getOptionLabel: K, getOptionKey: R, isOptionEqualToValue: _, renderOption: E, renderValue: j, filterOptions: k, loading: z, loadingText: ee = "Loading…", noOptionsText: te = "No options", disabled: D, readOnly: m, size: re = "small", disableClearable: le, disableCloseOnSelect: se, popupIcon: oe, autoHeight: ae, multiple: ne, allowSelectAll: ce, selectAllLabel: F = "Select all", fullWidth: ie, classes: de, inputValue: S, onInputChange: ue, open: W, onOpen: pe, onClose: me, className: fe, wrapperClassName: he, getOptionDisabled: ge, slotProps: U }) {
16
- const o = ne === !0, n = K ?? it, C = (e, t) => _ ? _(e, t) : e === t, [be, xe] = w(!1), a = W ?? be, f = (e) => {
17
- e && (m || D) || (W === void 0 && xe(e), e ? pe?.() : me?.());
18
- }, [we, V] = w(""), h = S ?? we, A = (e, t, r) => {
19
- S === void 0 && V(t), ue?.(e, t, r);
20
- }, [b, I] = w(null), ye = J([]), H = J(null), [ve, Ne] = w(null), [Re, De] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, T = !o && g !== null ? n(g) : "";
21
- Ze(() => {
22
- S !== void 0 || o || V(T);
13
+ import { FloatingPortal as tt, autoUpdate as rt, flip as lt, offset as st, shift as ot, size as at, useDismiss as nt, useFloating as ct, useInteractions as it, useMergeRefs as Z, useRole as dt } from "@floating-ui/react";
14
+ var ut = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), K = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
15
+ function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, getOptionLabel: te, getOptionKey: R, isOptionEqualToValue: E, renderOption: j, renderValue: z, filterOptions: $, loading: F, loadingText: re = "Loading…", noOptionsText: le = "No options", disabled: D, readOnly: m, size: se = "small", disableClearable: oe, disableCloseOnSelect: ae, popupIcon: ne, autoHeight: ce, multiple: ie, allowSelectAll: de, selectAllLabel: W = "Select all", fullWidth: ue, classes: pe, inputValue: S, onInputChange: me, open: U, onOpen: fe, onClose: he, className: ge, wrapperClassName: be, getOptionDisabled: xe, slotProps: T }) {
16
+ const o = ie === !0, n = te ?? ut, C = (e, t) => E ? E(e, t) : e === t, [we, ye] = w(!1), a = U ?? we, f = (e) => {
17
+ e && (m || D) || (U === void 0 && ye(e), e ? fe?.() : he?.());
18
+ }, [ve, V] = w(""), h = S ?? ve, P = (e, t, r) => {
19
+ S === void 0 && V(t), me?.(e, t, r);
20
+ }, [b, k] = w(null), Ne = X([]), H = X(null), [Re, De] = w(null), [Se, Ce] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, Y = !o && g !== null ? n(g) : "";
21
+ et(() => {
22
+ S !== void 0 || o || V(Y);
23
23
  }, [
24
24
  S,
25
25
  o,
26
- T
26
+ Y
27
27
  ]);
28
- const Y = (e) => o ? c.some((t) => C(e, t)) : g !== null && C(e, g), O = L(() => {
28
+ const O = (e) => o ? c.some((t) => C(e, t)) : g !== null && C(e, g), B = _(() => {
29
29
  const e = [...p];
30
- if (k) return k(e, { inputValue: h });
30
+ if ($) return $(e, { inputValue: h });
31
31
  const t = !o && g !== null ? n(g).toLowerCase() : null;
32
32
  if (!h || h.toLowerCase() === t) return e;
33
33
  const r = h.toLowerCase();
@@ -35,60 +35,60 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
35
35
  }, [
36
36
  p,
37
37
  h,
38
- k,
38
+ $,
39
39
  v
40
- ]), i = L(() => O.slice(0, 100), [O]), { refs: P, floatingStyles: Se, context: B } = at({
40
+ ]), i = _(() => B.slice(0, 100), [B]), { refs: A, floatingStyles: Pe, context: q } = ct({
41
41
  open: a,
42
42
  onOpenChange: f,
43
43
  placement: "bottom-start",
44
44
  strategy: "fixed",
45
- whileElementsMounted: et,
45
+ whileElementsMounted: rt,
46
46
  middleware: [
47
- rt(4),
48
- tt({ padding: 8 }),
47
+ st(4),
49
48
  lt({ padding: 8 }),
50
- st({ apply({ rects: e, availableHeight: t }) {
51
- Ne(e.reference.width), De(ae ? t - 8 : Math.min(t - 8, 320));
49
+ ot({ padding: 8 }),
50
+ at({ apply({ rects: e, availableHeight: t }) {
51
+ De(e.reference.width), Ce(ce ? t - 8 : Math.min(t - 8, 320));
52
52
  } })
53
53
  ]
54
- }), { getReferenceProps: Ce, getFloatingProps: Ae, getItemProps: Pe } = nt([ot(B), ct(B, { role: "listbox" })]), $e = Q([P.setReference]), ke = Q([Qe(P.setFloating)]), Ie = L(() => a ? Je(P.reference.current) : void 0, [a, P]), M = (e, t) => {
54
+ }), { getReferenceProps: Ae, getFloatingProps: Le, getItemProps: $e } = it([nt(q), dt(q, { role: "listbox" })]), ke = Z([A.setReference]), G = _(() => a ? Qe(A.reference.current) : void 0, [a, A]), I = Xe(G), Ie = Z([Ze(A.setFloating, I)]), M = (e, t) => {
55
55
  if (o) {
56
56
  const r = c.some((u) => C(t, u)), d = r ? c.filter((u) => !C(t, u)) : [...c, t];
57
- N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), A(e, "", "reset"), se || f(!1);
57
+ N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), P(e, "", "reset"), ae || f(!1);
58
58
  } else
59
- N?.(e, t, "selectOption", { option: t }), A(e, n(t), "reset"), f(!1);
59
+ N?.(e, t, "selectOption", { option: t }), P(e, n(t), "reset"), f(!1);
60
60
  }, Me = (e) => {
61
- N?.(e, o ? [] : null, "clear", void 0), A(e, "", "clear");
62
- }, Le = (e) => {
61
+ N?.(e, o ? [] : null, "clear", void 0), P(e, "", "clear");
62
+ }, _e = (e) => {
63
63
  if (e.key === "Enter" && a && b != null && i[b] != null) {
64
64
  e.preventDefault();
65
65
  const t = i[b];
66
- X(t) || M(e, t);
66
+ K(t) || M(e, t);
67
67
  } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
68
68
  if (e.preventDefault(), !a) {
69
- I(null), f(!0);
69
+ k(null), f(!0);
70
70
  return;
71
71
  }
72
72
  if (i.length === 0) return;
73
73
  const t = e.key === "ArrowDown" ? 1 : -1;
74
- I((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
74
+ k((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
75
75
  }
76
- }, _e = !le && !m && !D && (o ? c.length > 0 : g !== null), Ee = (e) => {
76
+ }, Ee = !oe && !m && !D && (o ? c.length > 0 : g !== null), je = (e) => {
77
77
  e.preventDefault(), !(D || m) && (H.current?.focus(), f(!a));
78
- }, je = o ? j ? j(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(Be, {
78
+ }, ze = o ? z ? z(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(qe, {
79
79
  dataTest: `selected-chip-${n(e)}`,
80
80
  label: n(e),
81
81
  readOnly: m,
82
82
  onDelete: m ? void 0 : (r) => M(r, e)
83
- }, R ? R(e) : `${n(e)}-${t}`)) : void 0, ze = /* @__PURE__ */ y("span", {
83
+ }, R ? R(e) : `${n(e)}-${t}`)) : void 0, Fe = /* @__PURE__ */ y("span", {
84
84
  className: "flex items-center gap-1",
85
85
  children: [
86
- z && /* @__PURE__ */ s(Xe, {
86
+ F && /* @__PURE__ */ s(Ke, {
87
87
  width: 20,
88
88
  height: 20,
89
89
  className: "animate-spin"
90
90
  }),
91
- _e && /* @__PURE__ */ s("button", {
91
+ Ee && /* @__PURE__ */ s("button", {
92
92
  type: "button",
93
93
  "aria-label": "Clear",
94
94
  "data-testid": `${l}-clear`,
@@ -96,7 +96,7 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
96
96
  onMouseDown: (e) => {
97
97
  e.preventDefault(), Me(e);
98
98
  },
99
- children: /* @__PURE__ */ s(Te, {
99
+ children: /* @__PURE__ */ s(Ye, {
100
100
  width: 20,
101
101
  height: 20,
102
102
  className: "text-delta-700"
@@ -108,30 +108,30 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
108
108
  "aria-expanded": a,
109
109
  "data-testid": `${l}-popup-indicator`,
110
110
  className: "flex cursor-pointer items-center border-0 bg-transparent",
111
- onMouseDown: Ee,
112
- children: oe ?? (o ? /* @__PURE__ */ s(Oe, {
111
+ onMouseDown: je,
112
+ children: ne ?? (o ? /* @__PURE__ */ s(Be, {
113
113
  width: 24,
114
114
  height: 24,
115
115
  className: "text-delta-700"
116
116
  }) : /* @__PURE__ */ s(He, {
117
117
  width: 24,
118
118
  height: 24,
119
- className: $(G["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
119
+ className: L(Q["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
120
120
  }))
121
121
  })
122
122
  ]
123
- }), Fe = {
123
+ }), We = {
124
124
  disabled: D,
125
- size: re,
125
+ size: se,
126
126
  fullWidth: !0,
127
127
  value: h,
128
128
  onChange: (e) => {
129
- A(e, e.target.value, "input"), a || f(!0);
129
+ P(e, e.target.value, "input"), a || f(!0);
130
130
  },
131
- onKeyDown: Le,
131
+ onKeyDown: _e,
132
132
  slotProps: {
133
133
  htmlInput: {
134
- ...Ce(),
134
+ ...Ae(),
135
135
  ref: H,
136
136
  onClick: () => f(!0),
137
137
  role: "combobox",
@@ -142,16 +142,16 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
142
142
  readOnly: m
143
143
  },
144
144
  input: {
145
- ref: $e,
146
- startAdornment: je,
147
- endAdornment: ze
145
+ ref: ke,
146
+ startAdornment: ze,
147
+ endAdornment: Fe
148
148
  }
149
149
  }
150
- }, We = $("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-700 first:-mt-1", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300", o && "border-0 border-b border-solid border-delta-200"), Ue = (e, t, r) => {
150
+ }, Ue = L("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-700 first:-mt-1", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300", o && "border-0 border-b border-solid border-delta-200"), Te = (e, t, r) => {
151
151
  const { key: d, ...u } = e;
152
152
  return /* @__PURE__ */ y("li", {
153
153
  ...u,
154
- children: [o ? /* @__PURE__ */ s(q, {
154
+ children: [o ? /* @__PURE__ */ s(J, {
155
155
  dataTest: `${l}-${n(t)}-checkbox`,
156
156
  checked: r.selected,
157
157
  size: "small",
@@ -159,7 +159,7 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
159
159
  decorative: !0
160
160
  }) : /* @__PURE__ */ s("span", {
161
161
  className: "w-5",
162
- children: r.selected && /* @__PURE__ */ s(Ye, {
162
+ children: r.selected && /* @__PURE__ */ s(Oe, {
163
163
  width: 20,
164
164
  height: 20,
165
165
  className: "text-gama-500"
@@ -170,54 +170,54 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
170
170
  })]
171
171
  }, d);
172
172
  }, Ve = (e, t) => {
173
- const r = ge?.(e) ?? X(e), d = {
174
- ...Pe({
173
+ const r = xe?.(e) ?? K(e), d = {
174
+ ...$e({
175
175
  onMouseDown: (x) => x.preventDefault(),
176
176
  onClick: (x) => {
177
177
  r || M(x, e);
178
178
  },
179
- onMouseMove: () => I(r ? null : t)
179
+ onMouseMove: () => k(r ? null : t)
180
180
  }),
181
181
  key: R ? String(R(e)) : `${n(e)}-${t}`,
182
182
  ref: (x) => {
183
- ye.current[t] = x;
183
+ Ne.current[t] = x;
184
184
  },
185
185
  role: "option",
186
186
  id: `${l}-option-${t}`,
187
- "aria-selected": Y(e),
187
+ "aria-selected": O(e),
188
188
  "aria-disabled": r || void 0,
189
189
  "data-active": b === t ? "" : void 0,
190
- className: We
190
+ className: Ue
191
191
  }, u = {
192
- selected: Y(e),
192
+ selected: O(e),
193
193
  index: t,
194
194
  inputValue: h
195
195
  };
196
- return E ? E(d, e, u) : Ue(d, e, u);
196
+ return j ? j(d, e, u) : Te(d, e, u);
197
197
  };
198
198
  return /* @__PURE__ */ y("div", {
199
- className: $(G.styledSelectAutocompleteWrapper, !ie && "w-auto", he, fe),
200
- children: [Z(Fe), a && /* @__PURE__ */ s(Ke, {
201
- root: Ie,
199
+ className: L(Q.styledSelectAutocompleteWrapper, !ue && "w-auto", be, ge),
200
+ children: [ee(We), a && /* @__PURE__ */ s(tt, {
201
+ root: G,
202
202
  children: /* @__PURE__ */ y("ul", {
203
- ref: ke,
204
- ...qe,
203
+ ref: Ie,
204
+ ...I ? Ge : {},
205
205
  style: {
206
- ...Ge,
207
- ...Se,
208
- width: ve ?? void 0,
209
- maxHeight: Re ?? void 0,
206
+ ...I ? Je : {},
207
+ ...Pe,
208
+ width: Re ?? void 0,
209
+ maxHeight: Se ?? void 0,
210
210
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
211
- ...U?.popper?.style
211
+ ...T?.popper?.style
212
212
  },
213
- ...Ae(),
214
- className: $("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white p-0 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", de?.listbox, U?.popper?.className),
215
- children: [ce && o && /* @__PURE__ */ y("div", {
213
+ ...Le(),
214
+ className: L("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white p-0 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", pe?.listbox, T?.popper?.className),
215
+ children: [de && o && /* @__PURE__ */ y("div", {
216
216
  role: "group",
217
217
  className: "flex min-h-12 items-center gap-x-1 border-0 border-b border-solid border-delta-200 px-4 text-sm text-delta-700",
218
- children: [/* @__PURE__ */ s(q, {
218
+ children: [/* @__PURE__ */ s(J, {
219
219
  dataTest: `${l}-select-all`,
220
- "aria-label": F,
220
+ "aria-label": W,
221
221
  checked: p.length > 0 && c.length === p.length,
222
222
  size: "small",
223
223
  hideWrapper: !0,
@@ -228,21 +228,21 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
228
228
  }
229
229
  }), /* @__PURE__ */ s("span", {
230
230
  className: "flex-1 truncate py-2",
231
- children: F
231
+ children: W
232
232
  })]
233
- }), z ? /* @__PURE__ */ s("li", {
233
+ }), F ? /* @__PURE__ */ s("li", {
234
234
  role: "presentation",
235
235
  className: "px-3 py-2 text-sm text-delta-600",
236
- children: ee
236
+ children: re
237
237
  }) : i.length === 0 ? /* @__PURE__ */ s("li", {
238
238
  role: "presentation",
239
239
  className: "px-3 py-2 text-sm text-delta-600",
240
- children: te
240
+ children: le
241
241
  }) : i.map(Ve)]
242
242
  })
243
243
  })]
244
244
  });
245
245
  }
246
246
  export {
247
- Rt as StyledSelectAutocomplete
247
+ St as StyledSelectAutocomplete
248
248
  };
@@ -1,46 +1,46 @@
1
- import { TOP_LAYER_PROPS as _, TOP_LAYER_RESET_STYLE as v, getOpenModalDialogAncestor as x, useTopLayerRef as y } from "../../hooks/useTopLayer.hook.js";
2
- import { useState as L } from "react";
1
+ import { TOP_LAYER_PROPS as T, TOP_LAYER_RESET_STYLE as _, getOpenModalDialogAncestor as y, shouldUsePopoverTopLayer as L, useTopLayerRef as x } from "../../hooks/useTopLayer.hook.js";
2
+ import { useState as S } from "react";
3
3
  import { jsx as l } from "react/jsx-runtime";
4
- import { FloatingPortal as S, autoUpdate as b, flip as A, shift as O, useFloating as F, useMergeRefs as Y } from "@floating-ui/react";
5
- var w = {
6
- ...v,
4
+ import { FloatingPortal as A, autoUpdate as O, flip as b, shift as Y, useFloating as w, useMergeRefs as F } from "@floating-ui/react";
5
+ var M = {
6
+ ..._,
7
7
  background: "transparent",
8
8
  border: 0,
9
9
  overflow: "visible",
10
10
  padding: 0
11
- }, k = ({ open: t = !1, anchorEl: r, id: f, placement: d = "bottom", transition: p, disablePortal: m, className: g, style: c, children: o }) => {
12
- const [n, a] = L(!0);
13
- t && n && a(!1);
14
- const e = x(r), { refs: i, floatingStyles: u, placement: R } = F({
15
- open: t,
16
- placement: d,
17
- strategy: e ? "fixed" : "absolute",
18
- whileElementsMounted: b,
11
+ }, k = ({ open: e = !1, anchorEl: r, id: d, placement: f = "bottom", transition: p, disablePortal: m, className: u, style: c, children: t }) => {
12
+ const [n, s] = S(!0);
13
+ e && n && s(!1);
14
+ const a = y(r), o = L(a), { refs: g, floatingStyles: P, placement: E } = w({
15
+ open: e,
16
+ placement: f,
17
+ strategy: "fixed",
18
+ whileElementsMounted: O,
19
19
  elements: { reference: r ?? void 0 },
20
- middleware: [A({ padding: 8 }), O({ padding: 8 })]
21
- }), E = y(i.setFloating), P = Y([e ? E : i.setFloating]);
22
- if (!(t || p && !n)) return null;
23
- const T = typeof o == "function" ? o({
20
+ middleware: [b({ padding: 8 }), Y({ padding: 8 })]
21
+ }), R = F([x(g.setFloating, o)]);
22
+ if (!(e || p && !n)) return null;
23
+ const v = typeof t == "function" ? t({
24
24
  TransitionProps: {
25
- in: t,
26
- onExited: () => a(!0)
25
+ in: e,
26
+ onExited: () => s(!0)
27
27
  },
28
- placement: R
29
- }) : o, s = /* @__PURE__ */ l("div", {
30
- ref: P,
31
- id: f,
32
- ...e ? _ : {},
28
+ placement: E
29
+ }) : t, i = /* @__PURE__ */ l("div", {
30
+ ref: R,
31
+ id: d,
32
+ ...o ? T : {},
33
33
  style: {
34
- ...e ? w : {},
35
- ...u,
34
+ ...o ? M : {},
35
+ ...P,
36
36
  ...c
37
37
  },
38
- className: g,
39
- children: T
38
+ className: u,
39
+ children: v
40
40
  });
41
- return m ? s : /* @__PURE__ */ l(S, {
42
- root: e,
43
- children: s
41
+ return m ? i : /* @__PURE__ */ l(A, {
42
+ root: a,
43
+ children: i
44
44
  });
45
45
  };
46
46
  export {
@@ -1,65 +1,51 @@
1
- import { cn as u } from "../../../helpers/cn.js";
2
- import { resolveSx as c } from "../../../helpers/sx.js";
3
- import { TOP_LAYER_PROPS as _, TOP_LAYER_RESET_STYLE as L, getOpenModalDialogAncestor as S, useTopLayerRef as T } from "../../../hooks/useTopLayer.hook.js";
4
- import { useFocusTrap as b } from "../../../hooks/useFocusTrap.hook.js";
5
- import { useEffect as m, useRef as k } from "react";
6
- import { jsx as d, jsxs as D } from "react/jsx-runtime";
7
- import { FloatingPortal as P } from "@floating-ui/react";
8
- var O = {
1
+ import { cn as n } from "../../../helpers/cn.js";
2
+ import { resolveSx as f } from "../../../helpers/sx.js";
3
+ import { getOpenModalDialogAncestor as w } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useFocusTrap as h } from "../../../hooks/useFocusTrap.hook.js";
5
+ import { useEffect as b, useRef as k } from "react";
6
+ import { jsx as m, jsxs as E } from "react/jsx-runtime";
7
+ import { FloatingPortal as S } from "@floating-ui/react";
8
+ var _ = {
9
9
  left: "inset-y-0 left-0 h-full",
10
10
  right: "inset-y-0 right-0 h-full",
11
11
  top: "inset-x-0 top-0 w-full",
12
12
  bottom: "inset-x-0 bottom-0 w-full"
13
- }, A = {
13
+ }, D = {
14
14
  left: "-translate-x-full",
15
15
  right: "translate-x-full",
16
16
  top: "-translate-y-full",
17
17
  bottom: "translate-y-full"
18
- }, K = ({ open: e = !1, onClose: n, anchor: a = "left", variant: p = "temporary", hideBackdrop: v, className: y, sx: x, PaperProps: i, ModalProps: E, anchorEl: h, children: R }) => {
19
- const r = p === "temporary", s = S(h), o = s !== void 0, l = k(null), g = T((t) => {
20
- l.current = t instanceof HTMLDivElement ? t : null;
21
- }), w = o ? g : (t) => {
22
- l.current = t;
23
- };
24
- return m(() => {
25
- if (!e || !r) return;
26
- const t = (f) => {
27
- f.key === "Escape" && n?.(f, "escapeKeyDown");
18
+ }, T = ({ open: t = !1, onClose: o, anchor: l = "left", variant: u = "temporary", hideBackdrop: d, className: c, sx: p, PaperProps: a, ModalProps: x, anchorEl: y, children: v }) => {
19
+ const e = u === "temporary", g = w(y), i = k(null);
20
+ return b(() => {
21
+ if (!t || !e) return;
22
+ const r = (s) => {
23
+ s.key === "Escape" && o?.(s, "escapeKeyDown");
28
24
  };
29
- return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
25
+ return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
30
26
  }, [
27
+ t,
31
28
  e,
32
- r,
33
- n
34
- ]), b(e && r, l), m(() => {
35
- if (!e || !o) return;
36
- const t = l.current;
37
- if (!(!t || typeof t.showPopover != "function"))
38
- try {
39
- t.matches(":popover-open") || t.showPopover();
40
- } catch {
41
- }
42
- }, [e, o]), r && !e && !E?.keepMounted ? null : /* @__PURE__ */ D(P, {
43
- root: s,
44
- children: [r && !v && e && /* @__PURE__ */ d("div", {
29
+ o
30
+ ]), h(t && e, i), e && !t && !x?.keepMounted ? null : /* @__PURE__ */ E(S, {
31
+ root: g,
32
+ children: [e && !d && t && /* @__PURE__ */ m("div", {
45
33
  className: "fixed inset-0 z-[1200] bg-[#626e7eb2]",
46
- onClick: (t) => n?.(t, "backdropClick")
47
- }), /* @__PURE__ */ d("div", {
48
- ref: w,
49
- ...o ? _ : {},
50
- role: r ? "dialog" : void 0,
51
- "aria-modal": r && e ? !0 : void 0,
52
- "aria-hidden": !e,
53
- className: u("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", e && "shadow-[0px_4px_40px_0px_#22213366]", O[a], !e && u(A[a], "pointer-events-none"), y, i?.className),
34
+ onClick: (r) => o?.(r, "backdropClick")
35
+ }), /* @__PURE__ */ m("div", {
36
+ ref: i,
37
+ role: e ? "dialog" : void 0,
38
+ "aria-modal": e && t ? !0 : void 0,
39
+ "aria-hidden": !t,
40
+ className: n("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", t && "shadow-[0px_4px_40px_0px_#22213366]", _[l], !t && n(D[l], "pointer-events-none"), c, a?.className),
54
41
  style: {
55
- ...o ? L : {},
56
- ...c(x),
57
- ...c(i?.sx)
42
+ ...f(p),
43
+ ...f(a?.sx)
58
44
  },
59
- children: R
45
+ children: v
60
46
  })]
61
47
  });
62
48
  };
63
49
  export {
64
- K as StyledDrawer
50
+ T as StyledDrawer
65
51
  };
@@ -1,41 +1,44 @@
1
- import { cn as O } from "../../../helpers/cn.js";
2
- import { resolveSx as c } from "../../../helpers/sx.js";
3
- import { TOP_LAYER_PROPS as L, TOP_LAYER_RESET_STYLE as M, getOpenModalDialogAncestor as z, useTopLayerRef as D } from "../../../hooks/useTopLayer.hook.js";
4
- import { useEffect as N, useMemo as k, useState as d } from "react";
5
- import { jsx as u } from "react/jsx-runtime";
6
- import { FloatingPortal as C, autoUpdate as U, flip as Y, offset as H, shift as K, useDismiss as $, useFloating as j, useInteractions as I, useMergeRefs as q } from "@floating-ui/react";
7
- var B = {
1
+ import { cn as E } from "../../../helpers/cn.js";
2
+ import { resolveSx as d } from "../../../helpers/sx.js";
3
+ import { TOP_LAYER_PROPS as M, TOP_LAYER_RESET_STYLE as z, getOpenModalDialogAncestor as D, shouldUsePopoverTopLayer as N, useTopLayerRef as U } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useEffect as k, useMemo as C, useState as m } from "react";
5
+ import { jsx as v } from "react/jsx-runtime";
6
+ import { FloatingPortal as Y, autoUpdate as H, flip as K, offset as $, shift as j, useDismiss as I, useFloating as q, useInteractions as B, useMergeRefs as G } from "@floating-ui/react";
7
+ var J = {
8
8
  vertical: "bottom",
9
9
  horizontal: "left"
10
- }, G = {
10
+ }, Q = {
11
11
  vertical: "top",
12
12
  horizontal: "left"
13
- }, J = (e, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, te = ({ open: e, anchorEl: o, onClose: m, anchorOrigin: l = B, transformOrigin: n = G, id: v, className: g, sx: h, slotProps: r, onClick: y, children: R, keepMounted: P = !1 }) => {
14
- const _ = k(() => J(l, n), [l, n]), [p, x] = d(e);
15
- e && !p && x(!0);
16
- const a = e || P && p, s = z(o), [f, w] = d(s);
17
- o && f !== s && w(s);
18
- const { refs: i, floatingStyles: S, context: T } = j({
13
+ }, V = (e, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, re = ({ open: e, anchorEl: o, onClose: g, anchorOrigin: f = J, transformOrigin: c = Q, id: y, className: h, sx: P, slotProps: a, onClick: R, children: _, keepMounted: x = !1 }) => {
14
+ const T = C(() => V(f, c), [f, c]), [u, w] = m(e);
15
+ e && !u && w(!0);
16
+ const i = e || x && u, n = D(o), [l, L] = m(n);
17
+ o && l !== n && L(n);
18
+ const { refs: p, floatingStyles: S, context: b } = q({
19
19
  open: e,
20
- placement: _,
20
+ placement: T,
21
21
  strategy: "fixed",
22
- whileElementsMounted: U,
22
+ whileElementsMounted: H,
23
23
  elements: { reference: o ?? void 0 },
24
24
  middleware: [
25
- H(4),
26
- Y({ padding: 8 }),
27
- K({ padding: 8 })
25
+ $(4),
26
+ K({ padding: 8 }),
27
+ j({ padding: 8 })
28
28
  ],
29
- onOpenChange: (t, E, F) => {
30
- t || m?.(E ?? {}, F === "escape-key" ? "escapeKeyDown" : "backdropClick");
29
+ onOpenChange: (t, s, O) => {
30
+ t || g?.(s ?? {}, O === "escape-key" ? "escapeKeyDown" : "backdropClick");
31
31
  }
32
- }), { getFloatingProps: b } = I([$(T, {
33
- outsidePress: !0,
32
+ }), { getFloatingProps: A } = B([I(b, {
33
+ outsidePress: (t) => {
34
+ const s = t.target;
35
+ return !(o instanceof Element && s instanceof Node && o.contains(s));
36
+ },
34
37
  escapeKey: !0
35
- })]), A = q([D(i.setFloating)]);
36
- return N(() => {
37
- if (!a) return;
38
- const t = i.floating.current;
38
+ })]), r = N(l), F = G([U(p.setFloating, r)]);
39
+ return k(() => {
40
+ if (!i || !r) return;
41
+ const t = p.floating.current;
39
42
  if (!(!t || typeof t.showPopover != "function"))
40
43
  try {
41
44
  e && !t.matches(":popover-open") && t.showPopover(), !e && t.matches(":popover-open") && t.hidePopover();
@@ -43,28 +46,29 @@ var B = {
43
46
  }
44
47
  }, [
45
48
  e,
46
- a,
47
- i.floating
48
- ]), a ? /* @__PURE__ */ u(C, {
49
- root: f,
50
- children: /* @__PURE__ */ u("div", {
51
- ref: A,
52
- id: v,
53
- ...L,
49
+ i,
50
+ r,
51
+ p.floating
52
+ ]), i ? /* @__PURE__ */ v(Y, {
53
+ root: l,
54
+ children: /* @__PURE__ */ v("div", {
55
+ ref: F,
56
+ id: y,
57
+ ...r ? M : {},
54
58
  style: {
55
- ...M,
59
+ ...r ? z : {},
56
60
  ...e ? S : {},
57
- ...c(h),
58
- ...c(r?.paper?.sx),
59
- ...r?.paper?.style,
61
+ ...d(P),
62
+ ...d(a?.paper?.sx),
63
+ ...a?.paper?.style,
60
64
  ...e ? null : { display: "none" }
61
65
  },
62
- ...e ? b({ onClick: y }) : {},
63
- className: O("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", g ?? "my-1", r?.paper?.className),
64
- children: R
66
+ ...e ? A({ onClick: R }) : {},
67
+ className: E("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", h ?? "my-1", a?.paper?.className),
68
+ children: _
65
69
  })
66
70
  }) : null;
67
71
  };
68
72
  export {
69
- te as StyledPopover
73
+ re as StyledPopover
70
74
  };
@@ -1,25 +1,29 @@
1
- import { useCallback as r } from "react";
2
- var n = { popover: "manual" }, a = {
1
+ import { useCallback as t } from "react";
2
+ var a = { popover: "manual" }, i = {
3
3
  margin: 0,
4
4
  inset: "auto"
5
5
  };
6
- function i(e) {
7
- if (!(e instanceof Element)) return;
8
- const o = e.closest("dialog");
9
- return o instanceof HTMLDialogElement && o.open ? o : void 0;
6
+ function u(o) {
7
+ if (!(o instanceof Element)) return;
8
+ const r = o.closest("dialog");
9
+ return r instanceof HTMLDialogElement && r.open ? r : void 0;
10
10
  }
11
- function p(e) {
12
- return r((o) => {
13
- if (e(o), !!o)
11
+ function p(o) {
12
+ return o == null;
13
+ }
14
+ function c(o, r = !0) {
15
+ return t((e) => {
16
+ if (o(e), !(!e || !r))
14
17
  try {
15
- typeof o.showPopover == "function" && !o.matches(":popover-open") && o.showPopover();
18
+ typeof e.showPopover == "function" && !e.matches(":popover-open") && e.showPopover();
16
19
  } catch {
17
20
  }
18
- }, [e]);
21
+ }, [o, r]);
19
22
  }
20
23
  export {
21
- n as TOP_LAYER_PROPS,
22
- a as TOP_LAYER_RESET_STYLE,
23
- i as getOpenModalDialogAncestor,
24
- p as useTopLayerRef
24
+ a as TOP_LAYER_PROPS,
25
+ i as TOP_LAYER_RESET_STYLE,
26
+ u as getOpenModalDialogAncestor,
27
+ p as shouldUsePopoverTopLayer,
28
+ c as useTopLayerRef
25
29
  };
@@ -1,5 +1,5 @@
1
- import { CSSProperties, ReactElement, ReactNode } from 'react';
2
1
  import { Placement } from '@floating-ui/react';
2
+ import { CSSProperties, ReactElement, ReactNode } from 'react';
3
3
  interface TooltipSlotProps {
4
4
  tooltip?: {
5
5
  sx?: unknown;
@@ -25,9 +25,9 @@ export interface PopperProps {
25
25
  * `TransitionProps` (`in`/`onExited`) so a child `Fade` can animate and unmount. Public props
26
26
  * preserved (DEC-003). TASK-403.
27
27
  *
28
- * When `anchorEl` sits inside an open modal `<dialog>` the popper portals into that dialog and joins
29
- * the top layer instead of the default `document.body` portal a body portal is both occluded by
30
- * the dialog and `inert`, so the popper looks dead on click. See `useTopLayer.hook`.
28
+ * Body-portalled instances join the browser **top layer** (nested under a filter `StyledPopover`
29
+ * otherwise paints under it). When `anchorEl` sits inside an open modal `<dialog>`, portal into
30
+ * that dialog and skip the Popover API see `shouldUsePopoverTopLayer`.
31
31
  */
32
32
  export declare const Popper: ({ open, anchorEl, id, placement, transition, disablePortal, className, style, children, }: PopperProps) => JSX.Element | null;
33
33
  export {};
@@ -28,6 +28,9 @@ export interface DrawerProps {
28
28
  * Sliding edge panel (replaces MUI `Drawer`). Portalled, slides from `anchor`, temporary variant
29
29
  * shows a backdrop and closes on backdrop-click / Escape. Public props preserved (DEC-003). TASK-304.
30
30
  *
31
+ * When the trigger is inside a modal `<dialog>`, portals into that dialog (inertness) and stacks with
32
+ * z-index — no nested Popover API (mobile Safari stacks nested `showPopover` under the dialog).
33
+ *
31
34
  * @figmaNode none — no dedicated Figma drawer/side-sheet. As a modal edge-panel it reuses the DS
32
35
  * **modal family** tokens established by `StyledDialog`: overlay `bg/modal` #626e7eb2 (delta-600 @70%)
33
36
  * + Dialogue-popup elevation (#22213366, 0 4 40). Edge panels are flush (no radius); content is
@@ -35,8 +35,10 @@ export interface StyledPopoverProps {
35
35
  * so the base paper uses the DS floating-surface defaults: white, radius **4** (Figma `menus`/
36
36
  * `text-field` radius token), and the **Float** elevation (drop-shadow `0 1 12 rgba(0,0,0,.15)`).
37
37
  * Styled consumers override the paper — `StyledMenu` adds the delta-300 border + Menus shadow
38
- * (`0 2 4 rgba(34,33,51,.15)`), the date-picker calendar keeps this base. Rendered in the browser
39
- * **top layer** (see `useTopLayerRef`) so it paints above a modal `<dialog>`.
38
+ * (`0 2 4 rgba(34,33,51,.15)`), the date-picker calendar keeps this base. Body-portalled instances
39
+ * join the browser **top layer** (see `useTopLayerRef`); when the anchor is inside a modal
40
+ * `<dialog>`, we portal into that dialog and skip the Popover API (mobile Safari nested top-layer
41
+ * bug — see `shouldUsePopoverTopLayer`).
40
42
  *
41
43
  * Positions against `anchorEl`, flips/shifts on collision, portalled, closes on outside-press/escape
42
44
  * mapping to MUI's `onClose(event, reason)`. `anchorOrigin`/`transformOrigin`/`slotProps.paper`
@@ -1,21 +1,25 @@
1
1
  import { CSSProperties } from 'react';
2
2
  /**
3
3
  * Promote a Floating UI element into the browser **top layer** so it paints above a native modal
4
- * `<dialog>`.
4
+ * `<dialog>` — but **only when the floating node is NOT already portalled into that dialog**.
5
5
  *
6
6
  * `StyledDialog` opens via `<dialog>.showModal()`, which puts the dialog in the top layer. The top
7
7
  * layer sits above the entire normal stacking context, so a popover/menu/listbox portalled to
8
8
  * `document.body` is occluded by the dialog **no matter how high its `z-index`** (and is `inert`
9
- * while the modal is open). The only way to render above it is to also join the top layer — which
10
- * the native Popover API does. We give the floating element `popover="manual"` (manual = we drive
11
- * open/close ourselves, no light-dismiss) and call `showPopover()` the moment it mounts; the top
12
- * layer stacks by call order, so a popover shown after the dialog lands on top.
9
+ * while the modal is open).
13
10
  *
14
- * Usage: spread {@link TOP_LAYER_PROPS} on the floating element, put {@link TOP_LAYER_RESET_STYLE}
15
- * before `...floatingStyles` in its `style`, use `strategy: 'fixed'` on `useFloating`, and pass
16
- * `refs.setFloating` to {@link useTopLayerRef} attach the returned callback as the element `ref`
17
- * (merge with any others). Promoting on the ref callback (not a `useEffect`) guarantees it runs the
18
- * instant the node is connected, before paint.
11
+ * Two complementary fixes:
12
+ * 1. **Portal into the open modal `<dialog>`** (see {@link getOpenModalDialogAncestor}) escapes
13
+ * `inert` and paints inside the dialog's own top-layer entry via normal z-index.
14
+ * 2. **Popover API** (`popover="manual"` + `showPopover()`) only when portalling to `document.body`
15
+ * (e.g. nested under another top-layer `StyledPopover`). Nested `showPopover()` *inside* a modal
16
+ * dialog is unreliable on mobile Safari: it either no-ops (UA keeps
17
+ * `[popover]:not(:popover-open){display:none!important}` → looks like it never opened) or stacks
18
+ * the popover *under* the dialog. Use {@link shouldUsePopoverTopLayer} to gate (1) vs (2).
19
+ *
20
+ * Usage when body-portalled: spread {@link TOP_LAYER_PROPS}, put {@link TOP_LAYER_RESET_STYLE} before
21
+ * `...floatingStyles`, `strategy: 'fixed'`, and pass `refs.setFloating` to {@link useTopLayerRef}.
22
+ * Promoting on the ref callback (not a `useEffect`) runs the instant the node is connected.
19
23
  */
20
24
  export declare const TOP_LAYER_PROPS: {
21
25
  readonly popover: "manual";
@@ -33,17 +37,23 @@ export declare const TOP_LAYER_RESET_STYLE: CSSProperties;
33
37
  * fine, even on top), but it is skipped by hit-testing: pointer clicks fall through to the dialog
34
38
  * behind it and options can't be selected. Promoting to the top layer only fixes painting/z-order,
35
39
  * NOT inertness. The one place a popover is both unclipped *and* interactive is **inside the modal
36
- * dialog's own subtree** (top layerescapes the dialog's `overflow:hidden`; descendant of the
37
- * dialog not inert). So when the trigger lives inside a modal dialog, the floating element must
38
- * portal into that dialog rather than `document.body`. Returns `undefined` for the non-dialog case
39
- * (and for non-modal containers like `MinimizableDialog`, which are plain z-indexed `<div>`s), so
40
- * the caller falls back to the default body portal.
40
+ * dialog's own subtree** (descendant of the dialog not inert; dialog is already fullscreen
41
+ * `inset-0`, so in-dialog `position:fixed` + z-index clears the paper without a nested Popover API
42
+ * entry). Returns `undefined` for the non-dialog case (and for non-modal containers like
43
+ * `MinimizableDialog`, which are plain z-indexed `<div>`s), so the caller falls back to the default
44
+ * body portal.
41
45
  */
42
46
  export declare function getOpenModalDialogAncestor(node: unknown): HTMLElement | undefined;
47
+ /**
48
+ * `true` when the floating node should join the top layer via the Popover API.
49
+ * `false` when it is (or will be) portalled into an open modal `<dialog>` — see hook docs.
50
+ */
51
+ export declare function shouldUsePopoverTopLayer(portalRoot: HTMLElement | undefined | null): boolean;
43
52
  type RefSetter = (node: HTMLElement | null) => void;
44
53
  /**
45
- * Returns a ref callback that wires the node into Floating UI (`setFloating`) and, on mount,
46
- * promotes it to the top layer via the Popover API. Degrades to plain z-index if unsupported.
54
+ * Returns a ref callback that wires the node into Floating UI (`setFloating`) and, when `enabled`,
55
+ * promotes it to the top layer via the Popover API. Pass `enabled: false` inside a modal dialog
56
+ * (see {@link shouldUsePopoverTopLayer}). Degrades to plain z-index if unsupported.
47
57
  */
48
- export declare function useTopLayerRef(setFloating: RefSetter): RefSetter;
58
+ export declare function useTopLayerRef(setFloating: RefSetter, enabled?: boolean): RefSetter;
49
59
  export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.61.2",
6
+ "version": "3.61.4",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",