asma-ui-core 3.86.0 → 3.86.2

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.
Files changed (44) hide show
  1. package/dist/asma-ui-core.css +1 -1
  2. package/dist/components/data-display/chip/StyledChip.js +28 -27
  3. package/dist/components/data-display/tooltip/StyledTooltip.js +76 -47
  4. package/dist/components/feedback/dialog/StyledDialog.js +62 -58
  5. package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +113 -105
  6. package/dist/components/feedback/minimizable-dialog/components/FullscreenBtn.js +10 -12
  7. package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +75 -67
  8. package/dist/components/feedback/snack-bar/StyledSnackbar.js +12 -10
  9. package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +69 -71
  10. package/dist/components/inputs/input-field/StyledInputField.js +10 -9
  11. package/dist/components/inputs/phone-field/CountryCodeOptions.js +16 -15
  12. package/dist/components/inputs/phone-field/CountryCodeSelect.js +98 -85
  13. package/dist/components/inputs/phone-field/useCountryPicker.js +44 -24
  14. package/dist/components/inputs/select/StyledSelect.js +15 -14
  15. package/dist/components/inputs/select/StyledSelectItem.js +4 -4
  16. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +199 -172
  17. package/dist/components/inputs/slider/StyledSlider.js +158 -107
  18. package/dist/components/navigation/listbox/Listbox.js +104 -54
  19. package/dist/components/navigation/menu/StyledMenu.js +22 -18
  20. package/dist/components/navigation/menu/StyledMenuItem.js +6 -6
  21. package/dist/components/utils/accordion/base-ui/StyledAccordionDetails.js +26 -22
  22. package/dist/components/utils/copy-wrapper/CopyWrapper.module.js +2 -2
  23. package/dist/components/utils/popover/StyledPopover.js +102 -52
  24. package/dist/datetime/components/date-picker/StyledDatePicker.js +40 -34
  25. package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +5 -4
  26. package/dist/datetime/components/time-picker/StyledTimePicker.js +69 -56
  27. package/dist/helpers/focusable.js +5 -0
  28. package/dist/hooks/useFocusTrap.hook.js +24 -19
  29. package/dist/src/components/data-display/chip/StyledChip.d.ts +2 -0
  30. package/dist/src/components/inputs/dynamic-select/StyledDynamicSelect.d.ts +3 -4
  31. package/dist/src/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.test.d.ts +1 -0
  32. package/dist/src/components/inputs/phone-field/CountryCodeOptions.d.ts +1 -1
  33. package/dist/src/components/inputs/phone-field/useCountryPicker.d.ts +5 -2
  34. package/dist/src/components/inputs/slider/StyledSlider.d.ts +4 -1
  35. package/dist/src/components/navigation/listbox/Listbox.d.ts +3 -2
  36. package/dist/src/components/navigation/menu/StyledMenu.d.ts +3 -2
  37. package/dist/src/components/utils/accordion/base-ui/StyledAccordionDetails.d.ts +2 -1
  38. package/dist/src/components/utils/popover/StyledPopover.d.ts +9 -2
  39. package/dist/src/helpers/focusable.d.ts +8 -0
  40. package/dist/src/hooks/useFocusTrap.hook.d.ts +2 -1
  41. package/dist/table/components/columns/action-column/components/RowActionMenu.js +30 -34
  42. package/dist/table/components/table-footer/TablePagination.js +18 -17
  43. package/dist/table/components/table-footer/TableRowCountSelect.js +5 -4
  44. package/package.json +1 -1
@@ -1,123 +1,174 @@
1
- import { cn as u } from "../../../helpers/cn.js";
2
- import { HelperRow as ft } from "../../../helpers/HelperRow.js";
3
- import { useHelperSlot as pt } from "../../../helpers/useHelperSlot.js";
4
- import y from "./StyledSlider.module.js";
5
- import { useId as ht, useRef as O, useState as Q } from "react";
6
- import { jsx as b, jsxs as H } from "react/jsx-runtime";
7
- var U = (i, l, o) => o === l ? 0 : Math.min(100, Math.max(0, (i - l) / (o - l) * 100)), mt = (i) => Array.isArray(i) ? [i[0] ?? 0, i[1] ?? 0] : null, wt = ({ dataTest: i, min: l = 0, max: o = 100, step: h = 1, value: w, defaultValue: W, disabled: s, size: z = "medium", orientation: C = "horizontal", marks: M, name: Z, className: k, classes: d, slotProps: x, error: v, errorText: tt, helperText: L, reserveHelperText: et, ariaLabel: S, ariaLabelledBy: rt, onChange: A, onChangeCommitted: _ }) => {
8
- const j = ht(), n = C === "vertical", a = z === "small" ? 6 : 8, f = O(null), g = O(null), [lt, N] = Q(null), [nt, F] = Q(W ?? l), I = lt ?? w ?? nt, c = mt(I), p = c !== null, B = v ? tt ?? L : L, { show: K, role: ot } = pt("StyledSlider", v, B, et), V = (M === !0 && Number.isFinite(h) && h > 0 && o > l ? Array.from({ length: Math.floor((o - l) / h) + 1 }, (t, r) => ({ value: l + h * r })) : Array.isArray(M) ? M : []).filter((t) => t.value >= l && t.value <= o), X = p ? Math.min(c[0], c[1]) : l, R = p ? Math.max(c[0], c[1]) : I, Y = (t) => p ? t >= X && t <= R : t <= R, $ = p ? U(X, l, o) : 0, q = U(R, l, o) - $, at = n ? {
9
- bottom: `${$}%`,
10
- height: `${q}%`
1
+ import { cn as c } from "../../../helpers/cn.js";
2
+ import { PlusIcon as yt } from "../../icons/plus-icon/PlusIcon.js";
3
+ import { RemoveIcon as xt } from "../../icons/remove-icon/RemoveIcon.js";
4
+ import { StyledButton as tt } from "../button/StyledButton.js";
5
+ import { HelperRow as Nt } from "../../../helpers/HelperRow.js";
6
+ import { useHelperSlot as Mt } from "../../../helpers/useHelperSlot.js";
7
+ import x from "./StyledSlider.module.js";
8
+ import { useId as Pt, useRef as et, useState as rt } from "react";
9
+ import { jsx as i, jsxs as y } from "react/jsx-runtime";
10
+ var j = (m, l, o) => o === l ? 0 : Math.min(100, Math.max(0, (m - l) / (o - l) * 100)), It = (m) => Array.isArray(m) ? [m[0] ?? 0, m[1] ?? 0] : null, Ut = ({ dataTest: m, min: l = 0, max: o = 100, step: h = 1, value: V, defaultValue: lt, disabled: u, size: B = "medium", orientation: F = "horizontal", marks: A, name: at, className: nt, classes: p, slotProps: R, error: N, errorText: ot, helperText: K, reserveHelperText: ct, fromLabel: T, toLabel: D, showButtons: X, ariaLabel: $, ariaLabelledBy: it, onChange: M, onChangeCommitted: k }) => {
11
+ const Y = Pt(), a = F === "vertical", s = B === "small" ? 6 : 8, b = et(null), g = et(null), [st, P] = rt(null), [ut, q] = rt(lt ?? l), v = st ?? V ?? ut, n = It(v), d = n !== null, E = N ? ot ?? K : K, { show: G, role: dt } = Mt("StyledSlider", N, E, ct), H = (A === !0 && Number.isFinite(h) && h > 0 && o > l ? Array.from({ length: Math.floor((o - l) / h) + 1 }, (t, r) => ({ value: l + h * r })) : Array.isArray(A) ? A : []).filter((t) => t.value >= l && t.value <= o), J = d ? Math.min(n[0], n[1]) : l, U = d ? Math.max(n[0], n[1]) : v, O = (t) => d ? t >= J && t <= U : t <= U, ft = d ? Math.min(n[0], n[1]) <= l : v <= l, ht = d ? Math.max(n[0], n[1]) >= o : v >= o, z = d ? j(J, l, o) : 0, Q = j(U, l, o) - z, mt = a ? {
12
+ bottom: `${z}%`,
13
+ height: `${Q}%`
11
14
  } : {
12
- left: `${$}%`,
13
- width: `${q}%`
14
- }, E = (t) => {
15
- const r = U(t, l, o);
16
- return n ? { bottom: `${r}%` } : { left: `${r}%` };
17
- }, T = (t) => {
18
- const r = t.currentTarget.getBoundingClientRect(), e = n ? 1 - (t.clientY - (r.top + a)) / (r.height - a * 2) : (t.clientX - (r.left + a)) / (r.width - a * 2), m = l + Math.round(Math.min(1, Math.max(0, e)) * ((o - l) / h)) * h;
19
- return Math.min(o, Math.max(l, m));
20
- }, ct = (t) => p && Math.abs((c?.[1] ?? l) - t) < Math.abs((c?.[0] ?? l) - t) ? 1 : 0, ut = (t) => {
21
- if (s) return;
22
- const r = T(t), e = ct(r);
23
- f.current = e, g.current = t.pointerId, t.currentTarget.setPointerCapture(t.pointerId);
24
- const m = P(r, e);
25
- N(m), A?.(t, m, e);
26
- }, it = (t) => {
27
- if (s || f.current === null || t.pointerId !== g.current) return;
28
- const r = f.current, e = P(T(t), r);
29
- N(e), A?.(t, e, r);
30
- }, st = (t) => {
31
- if (s || f.current === null || t.pointerId !== g.current) return;
32
- const r = f.current, e = P(T(t), r);
33
- w === void 0 && F(e), _?.(t, e), t.currentTarget.hasPointerCapture(t.pointerId) && t.currentTarget.releasePointerCapture(t.pointerId), N(null), f.current = null, g.current = null;
34
- }, dt = (t) => {
35
- f.current === null || t.pointerId !== g.current || (N(null), f.current = null, g.current = null);
36
- }, P = (t, r) => {
37
- if (!p) return t;
38
- const e = [c?.[0] ?? 0, c?.[1] ?? 0];
15
+ left: `${z}%`,
16
+ width: `${Q}%`
17
+ }, W = (t) => {
18
+ const r = j(t, l, o);
19
+ return a ? { bottom: `${r}%` } : { left: `${r}%` };
20
+ }, C = (t) => {
21
+ const r = t.currentTarget.getBoundingClientRect(), e = a ? 1 - (t.clientY - (r.top + s)) / (r.height - s * 2) : (t.clientX - (r.left + s)) / (r.width - s * 2), f = l + Math.round(Math.min(1, Math.max(0, e)) * ((o - l) / h)) * h;
22
+ return Math.min(o, Math.max(l, f));
23
+ }, pt = (t) => d && Math.abs((n?.[1] ?? l) - t) < Math.abs((n?.[0] ?? l) - t) ? 1 : 0, bt = (t) => {
24
+ if (u) return;
25
+ const r = C(t), e = pt(r);
26
+ b.current = e, g.current = t.pointerId, t.currentTarget.setPointerCapture(t.pointerId);
27
+ const f = I(r, e);
28
+ P(f), M?.(t, f, e);
29
+ }, gt = (t) => {
30
+ if (u || b.current === null || t.pointerId !== g.current) return;
31
+ const r = b.current, e = I(C(t), r);
32
+ P(e), M?.(t, e, r);
33
+ }, vt = (t) => {
34
+ if (u || b.current === null || t.pointerId !== g.current) return;
35
+ const r = b.current, e = I(C(t), r);
36
+ V === void 0 && q(e), k?.(t, e), t.currentTarget.hasPointerCapture(t.pointerId) && t.currentTarget.releasePointerCapture(t.pointerId), P(null), b.current = null, g.current = null;
37
+ }, wt = (t) => {
38
+ b.current === null || t.pointerId !== g.current || (P(null), b.current = null, g.current = null);
39
+ }, Z = (t) => (r) => {
40
+ if (u) return;
41
+ const e = t === "increment" ? h || 1 : -(h || 1);
42
+ let f = 0, w;
43
+ d ? (f = t === "increment" ? 1 : 0, w = t === "increment" ? Math.max(n[0], n[1]) : Math.min(n[0], n[1])) : w = v;
44
+ const L = Math.min(o, Math.max(l, w + e));
45
+ S(M, r, L, f), S(k, r, L, f);
46
+ }, I = (t, r) => {
47
+ if (!d) return t;
48
+ const e = [n?.[0] ?? 0, n?.[1] ?? 0];
39
49
  return e[r] = t, r === 0 && e[0] > e[1] && (e[0] = e[1]), r === 1 && e[1] < e[0] && (e[1] = e[0]), e;
40
- }, G = (t, r, e, m) => {
41
- const J = P(e, m);
42
- w === void 0 && F(J), t && t(r, J, m);
43
- }, D = (t, r) => /* @__PURE__ */ b("input", {
50
+ }, S = (t, r, e, f) => {
51
+ const w = I(e, f);
52
+ V === void 0 && q(w), t && t(r, w, f);
53
+ }, _ = (t, r) => /* @__PURE__ */ i("input", {
44
54
  type: "range",
45
- "data-testid": p ? `${i}-thumb-${t}` : i,
46
- name: Z,
55
+ "data-testid": d ? `${m}-thumb-${t}` : m,
56
+ name: at,
47
57
  min: l,
48
58
  max: o,
49
59
  step: h,
50
60
  value: r,
51
- disabled: s,
52
- "aria-orientation": C,
53
- "aria-label": typeof S == "function" ? S(t) : S,
54
- "aria-labelledby": rt,
55
- "aria-invalid": v ? !0 : void 0,
56
- "aria-describedby": K ? j : void 0,
57
- className: u(y.SliderInput, n ? y.Vertical : y.Horizontal, !n && "z-0", z === "small" && y.Small, s && y.Disabled, d?.thumb, x?.thumb?.className),
58
- onChange: (e) => G(A, e, Number(e.currentTarget.value), t),
59
- onKeyUp: (e) => G(_, e, Number(e.currentTarget.value), t)
61
+ disabled: u,
62
+ "aria-orientation": F,
63
+ "aria-label": typeof $ == "function" ? $(t) : $,
64
+ "aria-labelledby": it,
65
+ "aria-invalid": N ? !0 : void 0,
66
+ "aria-describedby": G ? Y : void 0,
67
+ className: c(x.SliderInput, a ? x.Vertical : x.Horizontal, !a && "z-0", B === "small" && x.Small, u && x.Disabled, p?.thumb, R?.thumb?.className),
68
+ onChange: (e) => S(M, e, Number(e.currentTarget.value), t),
69
+ onKeyUp: (e) => S(k, e, Number(e.currentTarget.value), t)
60
70
  }, t);
61
- return /* @__PURE__ */ H("div", {
62
- className: u("relative flex", n ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", d?.root, k),
63
- children: [
64
- /* @__PURE__ */ H("div", {
65
- className: u("relative", n ? "h-full w-8" : "h-4 w-full", s ? "cursor-default" : "cursor-pointer"),
66
- style: { touchAction: "none" },
67
- onPointerDown: ut,
68
- onPointerMove: it,
69
- onPointerUp: st,
70
- onPointerCancel: dt,
71
- children: [/* @__PURE__ */ H("div", {
72
- className: u("absolute", n ? "left-1/2 w-1 -translate-x-1/2" : "top-[calc(50%+6px)] h-1 -translate-y-1/2"),
73
- style: n ? {
74
- top: a,
75
- bottom: a
76
- } : {
77
- left: a,
78
- right: a
79
- },
71
+ return /* @__PURE__ */ y("div", {
72
+ className: c("flex max-w-[600px] flex-col gap-3", a && "h-full"),
73
+ children: [!a && (T ?? D) && /* @__PURE__ */ y("div", {
74
+ className: "grid w-full grid-cols-2 gap-4",
75
+ children: [!a && T && /* @__PURE__ */ i("span", {
76
+ className: "min-w-0 break-words text-left font-normal text-delta-800",
77
+ children: T
78
+ }), !a && D && /* @__PURE__ */ i("span", {
79
+ className: "min-w-0 break-words text-right font-normal text-delta-800",
80
+ children: D
81
+ })]
82
+ }), /* @__PURE__ */ y("div", {
83
+ className: c("flex", !a && "w-full items-start gap-3", a && "h-full flex-col items-center"),
84
+ children: [
85
+ !a && X && /* @__PURE__ */ i(tt, {
86
+ dataTest: "slider-from-button",
87
+ "aria-label": "Decrease value",
88
+ className: "-mt-0.5 w-8",
89
+ variant: "outlined",
90
+ disabled: u ?? ft,
91
+ startIcon: /* @__PURE__ */ i(xt, {
92
+ width: 24,
93
+ height: 24
94
+ }),
95
+ onClick: Z("decrement")
96
+ }),
97
+ /* @__PURE__ */ y("div", {
98
+ className: c("relative flex", a ? "h-full w-8 flex-col items-center" : "mt-px w-full flex-col", p?.root, nt),
80
99
  children: [
81
- /* @__PURE__ */ b("div", { className: u("absolute inset-0 rounded-full bg-delta-100", d?.rail, x?.rail?.className) }),
82
- /* @__PURE__ */ b("div", {
83
- className: u("absolute rounded-full", n ? "left-0 w-full" : "top-0 h-full", s ? "bg-delta-200" : "bg-gama-500", d?.track),
84
- style: at
100
+ /* @__PURE__ */ y("div", {
101
+ className: c("relative", a ? "h-full w-8" : "h-4 w-full", u ? "cursor-default" : "cursor-pointer"),
102
+ style: { touchAction: "none" },
103
+ onPointerDown: bt,
104
+ onPointerMove: gt,
105
+ onPointerUp: vt,
106
+ onPointerCancel: wt,
107
+ children: [/* @__PURE__ */ y("div", {
108
+ className: c("absolute", a ? "left-1/2 w-1 -translate-x-1/2" : "top-[calc(50%+6px)] h-1 -translate-y-1/2"),
109
+ style: a ? {
110
+ top: s,
111
+ bottom: s
112
+ } : {
113
+ left: s,
114
+ right: s
115
+ },
116
+ children: [
117
+ /* @__PURE__ */ i("div", { className: c("absolute inset-0 rounded-full bg-delta-100", p?.rail, R?.rail?.className) }),
118
+ /* @__PURE__ */ i("div", {
119
+ className: c("absolute rounded-full", a ? "left-0 w-full" : "top-0 h-full", u ? "bg-delta-200" : "bg-gama-500", p?.track),
120
+ style: mt
121
+ }),
122
+ H.map((t) => {
123
+ const r = O(t.value);
124
+ return /* @__PURE__ */ i("span", {
125
+ className: c("absolute z-10 box-border h-2 w-2 -translate-x-1/2 rounded-full border border-solid", a ? "left-1/2 translate-y-1/2" : "top-1/2 -translate-y-1/2", r ? c(u ? "border-delta-200 bg-delta-200" : "border-gama-500 bg-gama-500", p?.markActive) : c("border-delta-300 bg-white", p?.mark)),
126
+ style: W(t.value)
127
+ }, t.value);
128
+ })
129
+ ]
130
+ }), d ? [_(0, n[0]), _(1, n[1])] : _(0, v)]
85
131
  }),
86
- V.map((t) => {
87
- const r = Y(t.value);
88
- return /* @__PURE__ */ b("span", {
89
- className: u("absolute z-10 box-border h-2 w-2 -translate-x-1/2 rounded-full border border-solid", n ? "left-1/2 translate-y-1/2" : "top-1/2 -translate-y-1/2", r ? u(s ? "border-delta-200 bg-delta-200" : "border-gama-500 bg-gama-500", d?.markActive) : u("border-delta-300 bg-white", d?.mark)),
90
- style: E(t.value)
91
- }, t.value);
132
+ H.some((t) => t.label != null) && /* @__PURE__ */ i("div", {
133
+ className: c(a ? "pointer-events-none absolute inset-x-0" : "relative mt-[14px] h-6"),
134
+ style: a ? {
135
+ top: s,
136
+ bottom: s
137
+ } : {
138
+ marginLeft: s,
139
+ marginRight: s
140
+ },
141
+ children: H.map((t) => t.label == null ? null : /* @__PURE__ */ i("span", {
142
+ className: c("absolute text-base font-semibold text-delta-700", a ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", O(t.value) && p?.markLabelActive, p?.markLabel, R?.markLabel?.className),
143
+ style: W(t.value),
144
+ children: t.label
145
+ }, t.value))
146
+ }),
147
+ G && /* @__PURE__ */ i(Nt, {
148
+ id: Y,
149
+ role: dt,
150
+ error: N,
151
+ message: E,
152
+ className: "m-0 items-center"
92
153
  })
93
154
  ]
94
- }), p ? [D(0, c[0]), D(1, c[1])] : D(0, I)]
95
- }),
96
- V.some((t) => t.label != null) && /* @__PURE__ */ b("div", {
97
- className: u(n ? "pointer-events-none absolute inset-x-0" : "relative mt-[14px] h-6"),
98
- style: n ? {
99
- top: a,
100
- bottom: a
101
- } : {
102
- marginLeft: a,
103
- marginRight: a
104
- },
105
- children: V.map((t) => t.label == null ? null : /* @__PURE__ */ b("span", {
106
- className: u("absolute text-base font-semibold text-delta-700", n ? "left-[37px] translate-y-1/2" : "-translate-x-1/2", Y(t.value) && d?.markLabelActive, d?.markLabel, x?.markLabel?.className),
107
- style: E(t.value),
108
- children: t.label
109
- }, t.value))
110
- }),
111
- K && /* @__PURE__ */ b(ft, {
112
- id: j,
113
- role: ot,
114
- error: v,
115
- message: B,
116
- className: "m-0 items-center"
117
- })
118
- ]
155
+ }),
156
+ !a && X && /* @__PURE__ */ i(tt, {
157
+ dataTest: "slider-to-button",
158
+ "aria-label": "Increase value",
159
+ className: "-mt-0.5 w-8",
160
+ variant: "outlined",
161
+ disabled: u ?? ht,
162
+ startIcon: /* @__PURE__ */ i(yt, {
163
+ width: 24,
164
+ height: 24
165
+ }),
166
+ onClick: Z("increment")
167
+ })
168
+ ]
169
+ })]
119
170
  });
120
171
  };
121
172
  export {
122
- wt as StyledSlider
173
+ Ut as StyledSlider
123
174
  };
@@ -1,80 +1,130 @@
1
- import { ClickAwayListener as p } from "../../mui-compat/ClickAwayListener.js";
2
- import { createContext as x, useContext as d, useEffect as b, useMemo as v, useState as m } from "react";
3
- import { jsx as s } from "react/jsx-runtime";
4
- var a = x(null), l = () => {
5
- const t = d(a);
1
+ import { tabbableWithin as L } from "../../../helpers/focusable.js";
2
+ import { ClickAwayListener as $ } from "../../mui-compat/ClickAwayListener.js";
3
+ import { Children as C, cloneElement as D, createContext as O, isValidElement as g, useCallback as B, useContext as S, useEffect as w, useId as M, useMemo as T, useRef as q, useState as k } from "react";
4
+ import { jsx as x } from "react/jsx-runtime";
5
+ var I = O(null), b = () => {
6
+ const t = S(I);
6
7
  if (!t) throw new Error("Listbox.Button/Options/Option must be rendered inside <Listbox>");
7
8
  return t;
8
- }, f = (t, e) => typeof t == "function" ? t(e) : t;
9
- function L({ value: t, onChange: e, children: r }) {
10
- const [o, n] = m(!1), u = v(() => ({
11
- open: o,
9
+ }, h = (t, l) => typeof t == "function" ? t(l) : t;
10
+ function K({ value: t, onChange: l, children: d }) {
11
+ const [s, u] = k(!1), [n, o] = k(null), r = `listbox-${M()}`, p = q(null), a = B(() => {
12
+ u(!1), o(null);
13
+ }, []);
14
+ w(() => {
15
+ if (!s) return;
16
+ const i = (y) => {
17
+ if (y.key !== "Escape") return;
18
+ const e = p.current;
19
+ e?.contains(document.activeElement) && e.querySelector('[role="combobox"]')?.focus(), a();
20
+ };
21
+ return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
22
+ }, [s, a]);
23
+ const f = T(() => ({
24
+ open: s,
12
25
  select: (i) => {
13
- e(i), n(!1);
26
+ l(i), a();
14
27
  },
15
- setOpen: n,
28
+ setOpen: u,
29
+ setActiveIndex: o,
30
+ activeIndex: n,
31
+ listboxId: r,
16
32
  value: t
17
33
  }), [
18
- o,
34
+ s,
19
35
  t,
20
- e
36
+ l,
37
+ n,
38
+ r,
39
+ a
21
40
  ]);
22
- return b(() => {
23
- if (!o) return;
24
- const i = (c) => {
25
- c.key === "Escape" && n(!1);
26
- };
27
- return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
28
- }, [o]), /* @__PURE__ */ s(a.Provider, {
29
- value: u,
30
- children: /* @__PURE__ */ s(p, {
31
- onClickAway: () => n(!1),
32
- children: /* @__PURE__ */ s("div", {
41
+ return /* @__PURE__ */ x(I.Provider, {
42
+ value: f,
43
+ children: /* @__PURE__ */ x($, {
44
+ onClickAway: a,
45
+ children: /* @__PURE__ */ x("div", {
46
+ ref: (i) => {
47
+ p.current = i;
48
+ },
49
+ onBlur: (i) => {
50
+ i.relatedTarget && !i.currentTarget.contains(i.relatedTarget) && a();
51
+ },
33
52
  className: "relative w-full",
34
- children: r
53
+ children: d
35
54
  })
36
55
  })
37
56
  });
38
57
  }
39
- var y = ({ children: t, className: e, ...r }) => {
40
- const { open: o, setOpen: n } = l();
41
- return /* @__PURE__ */ s("button", {
58
+ var N = ({ children: t, className: l, onClick: d, onKeyDown: s, ...u }) => {
59
+ const { activeIndex: n, listboxId: o, open: r, setActiveIndex: p, setOpen: a } = b(), f = () => Array.from(document.querySelectorAll(`#${CSS.escape(o)} [role="option"]:not([aria-disabled="true"])`)), i = (e) => {
60
+ const c = f();
61
+ if (c.length === 0) return;
62
+ const m = c.findIndex((E) => E.id === `${o}-option-${n}`), v = m === -1 ? e === 1 ? 0 : c.length - 1 : Math.min(Math.max(m + e, 0), c.length - 1);
63
+ p(Number(c[v].dataset.index));
64
+ };
65
+ return /* @__PURE__ */ x("button", {
66
+ ...u,
42
67
  type: "button",
43
- className: e,
44
- onClick: () => n(!o),
45
- ...r,
46
- children: f(t, { open: o })
68
+ className: l,
69
+ onClick: (e) => {
70
+ d?.(e), e.defaultPrevented || a(!r);
71
+ },
72
+ onKeyDown: (e) => {
73
+ if (s?.(e), !e.defaultPrevented)
74
+ if (e.key === "ArrowDown" || e.key === "ArrowUp")
75
+ e.preventDefault(), r ? i(e.key === "ArrowDown" ? 1 : -1) : (a(!0), requestAnimationFrame(() => i(e.key === "ArrowDown" ? 1 : -1)));
76
+ else if (r && (e.key === "Home" || e.key === "End")) {
77
+ e.preventDefault();
78
+ const c = f(), m = c[e.key === "Home" ? 0 : c.length - 1];
79
+ m && p(Number(m.dataset.index));
80
+ } else r && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), f().find((c) => c.id === `${o}-option-${n}`)?.click());
81
+ },
82
+ role: "combobox",
83
+ "aria-haspopup": "listbox",
84
+ "aria-expanded": r,
85
+ "aria-controls": r ? o : void 0,
86
+ "aria-activedescendant": r && n !== null ? `${o}-option-${n}` : void 0,
87
+ children: h(t, { open: r })
47
88
  });
48
- }, k = ({ children: t, className: e }) => {
49
- const { open: r } = l();
50
- return r ? /* @__PURE__ */ s("div", {
89
+ }, P = ({ children: t, className: l }) => {
90
+ const { activeIndex: d, listboxId: s, open: u } = b();
91
+ return w(() => {
92
+ d !== null && document.getElementById(`${s}-option-${d}`)?.scrollIntoView({ block: "nearest" });
93
+ }, [d, s]), u ? /* @__PURE__ */ x("div", {
94
+ id: s,
51
95
  role: "listbox",
52
- className: e,
53
- children: t
96
+ className: l,
97
+ children: (() => {
98
+ let n = 0;
99
+ return C.toArray(t).map((o) => g(o) && o.type === A ? D(o, { optionIndex: n++ }) : o);
100
+ })()
54
101
  }) : null;
55
102
  };
56
- function w({ value: t, disabled: e, children: r, className: o }) {
57
- const n = l(), u = n.value === t, i = () => {
58
- e || n.select(t);
103
+ function A({ value: t, disabled: l, children: d, className: s, optionIndex: u = 0 }) {
104
+ const n = b(), o = n.value === t, r = () => {
105
+ l || n.select(t);
59
106
  };
60
- return /* @__PURE__ */ s("div", {
107
+ return /* @__PURE__ */ x("div", {
108
+ id: `${n.listboxId}-option-${u}`,
61
109
  role: "option",
62
- "aria-selected": u,
63
- "aria-disabled": e,
64
- tabIndex: e ? void 0 : 0,
65
- className: o,
66
- onClick: i,
67
- onKeyDown: (c) => {
68
- (c.key === "Enter" || c.key === " ") && (c.preventDefault(), i());
110
+ "aria-selected": o,
111
+ "aria-disabled": l,
112
+ "data-index": u,
113
+ tabIndex: -1,
114
+ className: s,
115
+ onMouseDown: (p) => {
116
+ const a = p.target;
117
+ L(p.currentTarget).some((f) => f.contains(a)) || p.preventDefault();
69
118
  },
70
- children: f(r, { selected: u })
119
+ onClick: r,
120
+ children: h(d, { selected: o })
71
121
  });
72
122
  }
73
- var h = Object.assign(L, {
74
- Button: y,
75
- Option: w,
76
- Options: k
123
+ var H = Object.assign(K, {
124
+ Button: N,
125
+ Option: A,
126
+ Options: P
77
127
  });
78
128
  export {
79
- h as Listbox
129
+ H as Listbox
80
130
  };
@@ -1,30 +1,34 @@
1
- import { cn as S } from "../../../helpers/cn.js";
2
- import { StyledPopover as f } from "../../utils/popover/StyledPopover.js";
3
- import { StyledMenuList as u } from "./StyledMenuList.js";
4
- import { jsx as p } from "react/jsx-runtime";
5
- var v = {
1
+ import { cn as u } from "../../../helpers/cn.js";
2
+ import { StyledPopover as c } from "../../utils/popover/StyledPopover.js";
3
+ import { StyledMenuList as S } from "./StyledMenuList.js";
4
+ import { jsx as o } from "react/jsx-runtime";
5
+ var N = {
6
6
  border: "1px solid var(--colors-delta-300)",
7
7
  boxShadow: "0px 2px 4px 0px rgba(34, 33, 51, 0.15)"
8
- }, h = ({ open: a, anchorEl: o, onClose: t, anchorOrigin: l, transformOrigin: m, id: d, className: s, sx: x, classes: e, slotProps: r, autoFocus: i = !0, onClick: c, children: n, keepMounted: y }) => /* @__PURE__ */ p(f, {
9
- open: a,
10
- anchorEl: o,
8
+ }, h = ({ open: p, anchorEl: m, onClose: t, anchorOrigin: l, transformOrigin: i, id: d, className: s, sx: x, classes: a, slotProps: e, autoFocus: n = !0, onClick: y, children: b, keepMounted: f }) => /* @__PURE__ */ o(c, {
9
+ open: p,
10
+ anchorEl: m,
11
11
  onClose: t,
12
+ tabIntoContent: !1,
12
13
  anchorOrigin: l,
13
- transformOrigin: m,
14
+ transformOrigin: i,
14
15
  id: d,
15
16
  className: s,
16
17
  sx: x,
17
- keepMounted: y,
18
+ keepMounted: f,
18
19
  slotProps: { paper: {
19
- className: S("rounded", e?.paper, r?.paper?.className),
20
- sx: [v, r?.paper?.sx],
21
- style: r?.paper?.style
20
+ className: u("rounded", a?.paper, e?.paper?.className),
21
+ sx: [N, e?.paper?.sx],
22
+ style: e?.paper?.style
22
23
  } },
23
- children: /* @__PURE__ */ p(u, {
24
- autoFocus: i,
25
- className: e?.list,
26
- onClick: c,
27
- children: n
24
+ children: /* @__PURE__ */ o(S, {
25
+ autoFocus: n,
26
+ className: a?.list,
27
+ onClick: y,
28
+ onKeyDown: (r) => {
29
+ r.key === "Tab" && r.target.getAttribute("role") === "menuitem" && t?.(r, "tabKeyDown");
30
+ },
31
+ children: b
28
32
  })
29
33
  });
30
34
  export {
@@ -1,7 +1,7 @@
1
1
  import { cn as r } from "../../../helpers/cn.js";
2
- import { resolveSx as y } from "../../../helpers/sx.js";
2
+ import { resolveSx as c } from "../../../helpers/sx.js";
3
3
  import { jsx as f } from "react/jsx-runtime";
4
- var D = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: l, disabled: e, selected: s, dense: m, className: d, classes: a, sx: u, "data-test": p, "data-testid": x, value: c }) => /* @__PURE__ */ f("li", {
4
+ var g = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: s, disabled: e, selected: l, dense: m, className: d, classes: a, sx: u, "data-test": p, "data-testid": x, value: v }) => /* @__PURE__ */ f("li", {
5
5
  role: "menuitem",
6
6
  "aria-disabled": e ? !0 : void 0,
7
7
  tabIndex: -1,
@@ -9,17 +9,17 @@ var D = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: l, disabled: e, s
9
9
  "data-testid": x,
10
10
  onClick: e ? void 0 : o,
11
11
  onMouseDown: e ? void 0 : i,
12
- onMouseUp: e ? void 0 : l,
12
+ onMouseUp: e ? void 0 : s,
13
13
  onKeyDown: (t) => {
14
14
  e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), o?.(t));
15
15
  },
16
- className: r("box-border flex items-center px-4 text-base outline-none", m ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : "cursor-pointer text-delta-700 hover:bg-delta-50", s && r("bg-gama-50", a?.selected), a?.root, d),
16
+ className: r("box-border flex items-center px-4 text-base outline-none focus-visible:shadow-[inset_3px_0_var(--colors-focus-ring)]", m ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : "cursor-pointer text-delta-700 hover:bg-delta-50", l && r("bg-gama-50", a?.selected), a?.root, d),
17
17
  style: {
18
18
  fontFamily: "Roboto, Helvetica, Arial, sans-serif",
19
- ...y(u)
19
+ ...c(u)
20
20
  },
21
21
  children: n
22
22
  });
23
23
  export {
24
- D as StyledMenuItem
24
+ g as StyledMenuItem
25
25
  };
@@ -1,27 +1,31 @@
1
- import n from "./StyledAccordion.module.js";
2
- import { useAccordionContext as g } from "./AccordionContext.js";
3
- import { clsx as s } from "clsx";
4
- import { useEffect as h, useRef as v, useState as x } from "react";
5
- import { jsx as c } from "react/jsx-runtime";
6
- var C = ({ children: r, className: i, contentClassName: l, ...a }) => {
7
- const { open: d, panelId: m, triggerId: u } = g(), e = v(null), [f, p] = x(0);
8
- return h(() => {
9
- if (!e.current) return;
10
- const t = () => p(e.current?.scrollHeight ?? 0);
1
+ import u from "./StyledAccordion.module.js";
2
+ import { useAccordionContext as h } from "./AccordionContext.js";
3
+ import { clsx as a } from "clsx";
4
+ import { useEffect as x, useLayoutEffect as y, useRef as c, useState as A } from "react";
5
+ import { jsx as d } from "react/jsx-runtime";
6
+ var C = ({ children: s, className: f, contentClassName: m, ...p }) => {
7
+ const { open: e, panelId: g, triggerId: o } = h(), l = c(null), r = c(null), i = c(e), [v, b] = A(0);
8
+ return x(() => {
9
+ if (!r.current) return;
10
+ const t = () => b(r.current?.scrollHeight ?? 0);
11
11
  t();
12
- const o = new ResizeObserver(t);
13
- return o.observe(e.current), () => o.disconnect();
14
- }, [r]), /* @__PURE__ */ c("div", {
15
- ...a,
16
- id: m,
12
+ const n = new ResizeObserver(t);
13
+ return n.observe(r.current), () => n.disconnect();
14
+ }, [s]), y(() => {
15
+ const t = l.current, n = i.current && !e && t?.contains(document.activeElement);
16
+ t?.toggleAttribute("inert", !e), n && document.getElementById(o)?.focus({ preventScroll: !0 }), i.current = e;
17
+ }, [e, o]), /* @__PURE__ */ d("div", {
18
+ ref: l,
19
+ ...p,
20
+ id: g,
17
21
  role: "region",
18
- "aria-labelledby": u,
19
- className: s(n.Panel, i),
20
- style: { "--accordion-panel-height": d ? `${f}px` : "0px" },
21
- children: /* @__PURE__ */ c("div", {
22
- ref: e,
23
- className: s(n.Content, l),
24
- children: r
22
+ "aria-labelledby": o,
23
+ className: a(u.Panel, f),
24
+ style: { "--accordion-panel-height": e ? `${v}px` : "0px" },
25
+ children: /* @__PURE__ */ d("div", {
26
+ ref: r,
27
+ className: a(u.Content, m),
28
+ children: s
25
29
  })
26
30
  });
27
31
  };
@@ -1,6 +1,6 @@
1
1
  var p = {
2
- "copy-wrapper": "_copy-wrapper_1gjzc_1",
3
- "hidden-copy": "_hidden-copy_1gjzc_1"
2
+ "copy-wrapper": "_copy-wrapper_15hst_1",
3
+ "hidden-copy": "_hidden-copy_15hst_1"
4
4
  };
5
5
  export {
6
6
  p as default