asma-ui-core 3.111.0 → 3.113.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/asma-ui-core.css +1 -1
  2. package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +95 -93
  3. package/dist/components/inputs/full-screen-picker/FullScreenPicker.js +93 -0
  4. package/dist/components/inputs/full-screen-picker/PickerLiveRegion.js +34 -0
  5. package/dist/components/inputs/full-screen-picker/pickerCopy.js +34 -0
  6. package/dist/components/inputs/full-screen-picker/useVisualViewportHeight.js +10 -0
  7. package/dist/components/inputs/input-field/StyledInputField.js +147 -157
  8. package/dist/components/inputs/phone-field/CountryCodeOptions.js +28 -24
  9. package/dist/components/inputs/phone-field/CountryCodeSelect.js +82 -75
  10. package/dist/components/inputs/select-autocomplete/SelectAutocompletePicker.js +217 -0
  11. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +270 -220
  12. package/dist/components/inputs/select-autocomplete/draftChanges.js +24 -0
  13. package/dist/components/inputs/select-autocomplete/listboxCursor.js +7 -0
  14. package/dist/components/inputs/select-autocomplete/readFieldName.js +18 -0
  15. package/dist/components/inputs/textarea/StyledTextarea.js +46 -47
  16. package/dist/hooks/useMediaQuery.hook.js +12 -8
  17. package/dist/index.js +137 -133
  18. package/dist/src/components/inputs/dynamic-select/StyledDynamicSelect.d.ts +4 -1
  19. package/dist/src/components/inputs/full-screen-picker/FullScreenPicker.d.ts +62 -0
  20. package/dist/src/components/inputs/full-screen-picker/PickerLiveRegion.d.ts +31 -0
  21. package/dist/src/components/inputs/full-screen-picker/index.d.ts +2 -0
  22. package/dist/src/components/inputs/full-screen-picker/pickerCopy.d.ts +29 -0
  23. package/dist/src/components/inputs/full-screen-picker/useVisualViewportHeight.d.ts +8 -0
  24. package/dist/src/components/inputs/input-field/StyledInputField.d.ts +4 -1
  25. package/dist/src/components/inputs/phone-field/CountryCodeOptions.d.ts +9 -1
  26. package/dist/src/components/inputs/phone-field/CountryCodeSelect.d.ts +4 -3
  27. package/dist/src/components/inputs/phone-field/useCountryPicker.d.ts +2 -1
  28. package/dist/src/components/inputs/select-autocomplete/SelectAutocompletePicker.d.ts +52 -0
  29. package/dist/src/components/inputs/select-autocomplete/StyledSelectAutocomplete.d.ts +21 -2
  30. package/dist/src/components/inputs/select-autocomplete/draftChanges.d.ts +17 -0
  31. package/dist/src/components/inputs/select-autocomplete/listboxCursor.d.ts +9 -0
  32. package/dist/src/components/inputs/select-autocomplete/readFieldName.d.ts +13 -0
  33. package/dist/src/helpers/CharacterCounter.d.ts +2 -1
  34. package/dist/src/hooks/useMediaQuery.hook.d.ts +6 -0
  35. package/dist/src/index.d.ts +1 -0
  36. package/package.json +1 -1
@@ -1,212 +1,228 @@
1
- import { cn as E } from "../../../helpers/cn.js";
2
- import { TOP_LAYER_PROPS as nt, TOP_LAYER_RESET_STYLE as at, getOpenModalDialogAncestor as it, shouldUsePopoverTopLayer as ct, useTopLayerRef as dt } from "../../../hooks/useTopLayer.hook.js";
3
- import { ChevronDownIcon as ut } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
- import { CloseIcon as pt } from "../../icons/close-icon/CloseIcon.js";
5
- import { CheckIcon as ft } from "../../icons/check-icon/CheckIcon.js";
6
- import { PlusIconCircle as mt } from "../../icons/plus-icon-circle/PlusIconCircle.js";
7
- import { StyledChip as ht } from "../../data-display/chip/StyledChip.js";
8
- import { StyledCheckbox as ue } from "../checkbox/base-ui/StyledCheckbox.js";
9
- import { useBackCloses as bt } from "../../../hooks/useBackCloses.hook.js";
10
- import { fieldWidthStyle as gt } from "../field-styles.js";
11
- import { LoadingIcon as xt } from "../../../table/shared-components/LoadingIcon.js";
12
- import B from "./StyledSelectAutocomplete.module.js";
13
- import { useEffect as pe, useMemo as U, useRef as fe, useState as D } from "react";
14
- import { jsx as o, jsxs as I } from "react/jsx-runtime";
15
- import { FloatingPortal as yt, autoUpdate as wt, flip as kt, offset as vt, shift as Dt, size as It, useDismiss as Nt, useFloating as Ct, useInteractions as At, useMergeRefs as me, useRole as St } from "@floating-ui/react";
16
- var Mt = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), Rt = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
17
- function qt({ dataTest: l, options: b, renderInput: he, value: N, onChange: C, getOptionLabel: be, getOptionKey: A, isOptionEqualToValue: V, renderOption: T, renderValue: Y, filterOptions: O, loading: q, loadingText: ge = "Loading…", noOptionsText: xe = "No options", disabled: S, readOnly: g, error: ye, helperText: we, size: ke = "small", rowSize: ve = "compact", disableClearable: De, disableCloseOnSelect: Ie, popupIcon: Ne, autoHeight: Ce, multiple: Ae, allowSelectAll: M, selectAllLabel: Se = "Select all", width: G = "full", fullWidth: Pt, classes: Me, inputValue: R, onInputChange: Re, open: J, onOpen: Pe, onClose: _e, className: $e, wrapperClassName: Le, getOptionDisabled: Ee, slotProps: Q }) {
18
- const s = Ae === !0, d = be ?? Mt, P = (e, t) => V ? V(e, t) : e === t, [Oe, We] = D(!1), n = J ?? Oe, c = (e) => {
19
- e && (g || S) || (J === void 0 && We(e), e ? Pe?.() : (x(null), _e?.()));
20
- }, [Fe, X] = D(""), m = R ?? Fe, _ = (e, t, a) => {
21
- R === void 0 && X(t), Re?.(e, t, a);
22
- }, [r, x] = D(null), Z = `${l}-listbox`, K = fe([]), ee = fe(null), [je, ze] = D(null), [te, He] = D(null), i = s ? Array.isArray(N) ? N : [] : [], y = s ? null : N ?? null, le = !s && y !== null ? d(y) : "";
23
- pe(() => {
24
- R !== void 0 || s || X(le);
1
+ import { cn as D } from "../../../helpers/cn.js";
2
+ import { TOP_LAYER_PROPS as xt, TOP_LAYER_RESET_STYLE as yt, getOpenModalDialogAncestor as kt, shouldUsePopoverTopLayer as vt, useTopLayerRef as wt } from "../../../hooks/useTopLayer.hook.js";
3
+ import { ChevronDownIcon as Dt } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
4
+ import { CloseIcon as It } from "../../icons/close-icon/CloseIcon.js";
5
+ import { CheckIcon as Nt } from "../../icons/check-icon/CheckIcon.js";
6
+ import { PlusIconCircle as Pt } from "../../icons/plus-icon-circle/PlusIconCircle.js";
7
+ import { StyledChip as At } from "../../data-display/chip/StyledChip.js";
8
+ import { StyledCheckbox as ve } from "../checkbox/base-ui/StyledCheckbox.js";
9
+ import { useFullScreenPickerMediaQuery as Ct } from "../../../hooks/useMediaQuery.hook.js";
10
+ import { useBackCloses as St } from "../../../hooks/useBackCloses.hook.js";
11
+ import { fieldWidthStyle as Rt } from "../field-styles.js";
12
+ import { LoadingIcon as Mt } from "../../../table/shared-components/LoadingIcon.js";
13
+ import { PickerLiveRegion as $t, useAnnouncer as _t } from "../full-screen-picker/PickerLiveRegion.js";
14
+ import { getPickerText as Ft } from "../full-screen-picker/pickerCopy.js";
15
+ import { readFieldName as Lt } from "./readFieldName.js";
16
+ import { getDraftChanges as Et } from "./draftChanges.js";
17
+ import { nextActiveIndex as Wt } from "./listboxCursor.js";
18
+ import { SelectAutocompletePicker as jt } from "./SelectAutocompletePicker.js";
19
+ import J from "./StyledSelectAutocomplete.module.js";
20
+ import { useEffect as we, useMemo as X, useRef as De, useState as I } from "react";
21
+ import { Fragment as zt, jsx as o, jsxs as N } from "react/jsx-runtime";
22
+ import { FloatingPortal as Ht, autoUpdate as Bt, flip as Ut, offset as Vt, shift as Ot, size as Yt, useDismiss as qt, useFloating as Qt, useInteractions as Tt, useMergeRefs as Ie, useRole as Gt } from "@floating-ui/react";
23
+ var Jt = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), Xt = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
24
+ function vl({ dataTest: l, options: h, renderInput: Ne, value: $, onChange: P, getOptionLabel: Pe, getOptionKey: A, isOptionEqualToValue: Z, renderOption: j, renderValue: K, filterOptions: _, loading: z, loadingText: ee = "Loading…", noOptionsText: te = "No options", disabled: F, readOnly: b, error: Ae, helperText: Ce, size: Se = "small", rowSize: Re = "compact", disableClearable: le, disableCloseOnSelect: Me, popupIcon: $e, autoHeight: _e, multiple: Fe, allowSelectAll: C, selectAllLabel: re = "Select all", width: oe = "full", fullWidth: Zt, classes: Le, inputValue: L, onInputChange: Ee, open: se, onOpen: We, onClose: je, className: ze, wrapperClassName: He, getOptionDisabled: Be, slotProps: ne, pickerTitle: H, pickerText: Ue, locale: Ve = "en", disableFullScreenPicker: Oe }) {
25
+ const r = Fe === !0, k = Ct() && !Oe, [ae, Ye] = I({
26
+ label: "",
27
+ name: ""
28
+ }), [qe, Qe] = _t(), B = Ft(Ve, Ue), d = Pe ?? Jt, v = (e, t) => Z ? Z(e, t) : e === t, [Te, Ge] = I(!1), s = se ?? Te, i = (e) => {
29
+ e && (b || F) || (se === void 0 && Ge(e), e && Ye(Lt(V.current)), e ? We?.() : (y(null), je?.()));
30
+ }, [Je, ie] = I(""), g = L ?? Je, S = (e, t, a) => {
31
+ L === void 0 && ie(t), Ee?.(e, t, a);
32
+ }, [n, y] = I(null), U = `${l}-listbox`, ce = De([]), V = De(null), [Xe, Ze] = I(null), [de, Ke] = I(null), c = r ? Array.isArray($) ? $ : [] : [], x = r ? null : $ ?? null, ue = !r && x !== null ? d(x) : "";
33
+ we(() => {
34
+ L !== void 0 || r || ie(ue);
25
35
  }, [
26
- R,
27
- s,
28
- le
36
+ L,
37
+ r,
38
+ ue
29
39
  ]);
30
- const W = (e) => s ? i.some((t) => P(e, t)) : y !== null && P(e, y), $ = (e) => Ee?.(e) ?? Rt(e), se = U(() => {
31
- const e = [...b];
32
- if (O) return O(e, { inputValue: m });
33
- const t = !s && y !== null ? d(y).toLowerCase() : null;
34
- if (!m || m.toLowerCase() === t) return e;
35
- const a = m.toLowerCase();
36
- return e.filter((p) => d(p).toLowerCase().includes(a));
40
+ const O = (e) => r ? c.some((t) => v(e, t)) : x !== null && v(e, x), R = (e) => Be?.(e) ?? Xt(e), pe = X(() => {
41
+ const e = [...h];
42
+ if (_) return _(e, { inputValue: g });
43
+ const t = !r && x !== null ? d(x).toLowerCase() : null;
44
+ if (!g || g.toLowerCase() === t) return e;
45
+ const a = g.toLowerCase();
46
+ return e.filter((u) => d(u).toLowerCase().includes(a));
37
47
  }, [
38
- b,
39
- m,
40
- O,
41
- N
42
- ]), u = U(() => se.slice(0, 100), [se]), re = u.flatMap((e, t) => $(e) ? [] : [t]), F = M && s ? [-1, ...re] : re, oe = u.map((e, t) => t), h = M && s ? [-1, ...oe] : oe, k = u.findIndex(W);
43
- pe(() => {
44
- if (!n) return;
45
- const e = r ?? k;
48
+ h,
49
+ g,
50
+ _,
51
+ $
52
+ ]), p = X(() => pe.slice(0, 100), [pe]), fe = p.flatMap((e, t) => R(e) ? [] : [t]), Y = C && r ? [-1, ...fe] : fe, me = p.map((e, t) => t), E = C && r ? [-1, ...me] : me, M = p.findIndex(O);
53
+ we(() => {
54
+ if (!s) return;
55
+ const e = n ?? M;
46
56
  if (e < 0) return;
47
- const t = requestAnimationFrame(() => K.current[e]?.scrollIntoView({ block: "nearest" }));
57
+ const t = requestAnimationFrame(() => ce.current[e]?.scrollIntoView({ block: "nearest" }));
48
58
  return () => cancelAnimationFrame(t);
49
59
  }, [
50
- r,
51
60
  n,
52
- te,
53
- k
61
+ s,
62
+ de,
63
+ M
54
64
  ]);
55
- const { refs: L, floatingStyles: Be, context: ne } = Ct({
56
- open: n,
57
- onOpenChange: c,
65
+ const { refs: W, floatingStyles: et, context: he } = Qt({
66
+ open: s,
67
+ onOpenChange: i,
58
68
  placement: "bottom-start",
59
69
  strategy: "fixed",
60
- whileElementsMounted: wt,
70
+ whileElementsMounted: Bt,
61
71
  middleware: [
62
- vt(0),
63
- kt({ padding: 8 }),
64
- Dt({ padding: 8 }),
65
- It({ apply({ rects: e, availableHeight: t }) {
66
- ze(e.reference.width), He(Ce ? t - 8 : Math.min(t - 8, 320));
72
+ Vt(0),
73
+ Ut({ padding: 8 }),
74
+ Ot({ padding: 8 }),
75
+ Yt({ apply({ rects: e, availableHeight: t }) {
76
+ Ze(e.reference.width), Ke(_e ? t - 8 : Math.min(t - 8, 320));
67
77
  } })
68
78
  ]
69
- }), { getReferenceProps: Ue, getFloatingProps: Ve, getItemProps: Te } = At([Nt(ne), St(ne, { role: "listbox" })]);
70
- bt({
71
- active: n,
72
- requestClose: () => c(!1)
79
+ }), { getReferenceProps: tt, getFloatingProps: lt, getItemProps: rt } = Tt([qt(he, { enabled: !k }), Gt(he, { role: "listbox" })]);
80
+ St({
81
+ active: s && !k,
82
+ requestClose: () => i(!1)
73
83
  });
74
- const Ye = me([L.setReference]), ae = U(() => n ? it(L.reference.current) : void 0, [n, L]), j = ct(ae), qe = me([dt(L.setFloating, j)]), Ge = (e) => F.includes(k) ? k : F[e === 1 ? 0 : F.length - 1] ?? null, Je = (e) => {
75
- h.length !== 0 && x((t) => {
76
- const a = h.indexOf(t ?? k);
77
- return a === -1 ? h[e === 1 ? 0 : h.length - 1] ?? null : h[Math.min(Math.max(a + e, 0), h.length - 1)] ?? null;
78
- });
79
- }, v = (e, t, a = !s || !Ie) => {
80
- if (s) {
81
- const p = i.some((f) => P(t, f)), w = p ? i.filter((f) => !P(t, f)) : [...i, t];
82
- C?.(e, w, p ? "removeOption" : "selectOption", { option: t }), _(e, "", "reset"), a && c(!1);
84
+ const ot = Ie([W.setReference]), be = X(() => s ? kt(W.reference.current) : void 0, [s, W]), q = vt(be), st = Ie([wt(W.setFloating, q)]), nt = (e) => Y.includes(M) ? M : Y[e === 1 ? 0 : Y.length - 1] ?? null, at = (e) => {
85
+ E.length !== 0 && y((t) => Wt(E, t, M, e));
86
+ }, w = (e, t, a = !r || !Me) => {
87
+ if (r) {
88
+ const u = c.some((m) => v(t, m)), f = u ? c.filter((m) => !v(t, m)) : [...c, t];
89
+ P?.(e, f, u ? "removeOption" : "selectOption", { option: t }), S(e, "", "reset"), a && i(!1);
83
90
  } else
84
- C?.(e, t, "selectOption", { option: t }), _(e, d(t), "reset"), a && c(!1);
85
- }, ie = (e) => {
86
- C?.(e, s ? [] : null, "clear", void 0), _(e, "", "clear");
87
- }, z = (e) => {
88
- const t = b.length > 0 && i.length === b.length;
89
- C?.(e, t ? [] : b, t ? "clear" : "selectOption", void 0);
90
- }, Qe = (e) => {
91
- if (e.key === "Backspace" && m === "" && ce) {
92
- const t = i[i.length - 1];
93
- s ? t !== void 0 && v(e, t, !1) : ie(e);
94
- } else if (e.key === "Enter" && !n)
95
- e.preventDefault(), c(!0);
96
- else if (e.key === "Enter" && r === -1)
97
- e.preventDefault(), z(e);
98
- else if (e.key === "Enter" && r != null && u[r] != null) {
91
+ P?.(e, t, "selectOption", { option: t }), S(e, d(t), "reset"), a && i(!1);
92
+ }, Q = (e) => {
93
+ P?.(e, r ? [] : null, "clear", void 0), S(e, "", "clear");
94
+ }, it = (e) => {
95
+ Q(e), i(!1), Qe(B.cleared);
96
+ }, ct = (e, t) => {
97
+ for (const { value: a, reason: u, option: f } of Et(c, t, v)) P?.(e, a, u, f === void 0 ? void 0 : { option: f });
98
+ S(e, "", "reset"), i(!1);
99
+ }, T = (e) => {
100
+ const t = h.length > 0 && c.length === h.length;
101
+ P?.(e, t ? [] : h, t ? "clear" : "selectOption", void 0);
102
+ }, dt = (e) => {
103
+ if (e.key === "Backspace" && g === "" && ge) {
104
+ const t = c[c.length - 1];
105
+ r ? t !== void 0 && w(e, t, !1) : Q(e);
106
+ } else if (e.key === "Enter" && !s)
107
+ e.preventDefault(), i(!0);
108
+ else if (e.key === "Enter" && n === -1)
109
+ e.preventDefault(), T(e);
110
+ else if (e.key === "Enter" && n != null && p[n] != null) {
99
111
  e.preventDefault();
100
- const t = u[r];
101
- $(t) || v(e, t, !0);
112
+ const t = p[n];
113
+ R(t) || w(e, t, !0);
102
114
  } else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
103
- if (e.preventDefault(), !n) {
104
- x(Ge(e.key === "ArrowDown" ? 1 : -1)), c(!0);
115
+ if (e.preventDefault(), !s) {
116
+ y(nt(e.key === "ArrowDown" ? 1 : -1)), i(!0);
105
117
  return;
106
118
  }
107
- Je(e.key === "ArrowDown" ? 1 : -1);
119
+ at(e.key === "ArrowDown" ? 1 : -1);
108
120
  } else if (e.key === "Home" || e.key === "End")
109
- e.preventDefault(), x(h[e.key === "Home" ? 0 : h.length - 1] ?? null);
110
- else if (e.key === " " && r === -1)
111
- e.preventDefault(), z(e);
112
- else if (e.key === " " && r != null && u[r] != null) {
121
+ e.preventDefault(), y(E[e.key === "Home" ? 0 : E.length - 1] ?? null);
122
+ else if (e.key === " " && n === -1)
123
+ e.preventDefault(), T(e);
124
+ else if (e.key === " " && n != null && p[n] != null) {
113
125
  e.preventDefault();
114
- const t = u[r];
115
- $(t) || v(e, t, !1);
116
- } else e.key === "Escape" && n ? (e.preventDefault(), e.stopPropagation(), c(!1)) : e.key === "Tab" && c(!1);
117
- }, ce = !De && !g && !S && (s ? i.length > 0 : y !== null);
118
- let de;
119
- n && r != null && (r === -1 || u[r] !== void 0) && (de = r === -1 ? `${l}-select-all` : `${l}-option-${r}`);
120
- const Xe = (e) => {
121
- e.preventDefault(), !(S || g) && (ee.current?.focus(), c(!n));
122
- }, Ze = s ? Y ? Y(i, ({ index: e }) => ({ "data-index": e })) : i.map((e, t) => /* @__PURE__ */ o(ht, {
126
+ const t = p[n];
127
+ R(t) || w(e, t, !1);
128
+ } else e.key === "Escape" && s ? (e.preventDefault(), e.stopPropagation(), i(!1)) : e.key === "Tab" && i(!1);
129
+ }, ge = !le && !b && !F && (r ? c.length > 0 : x !== null);
130
+ let xe;
131
+ s && n != null && (n === -1 || p[n] !== void 0) && (xe = n === -1 ? `${l}-select-all` : `${l}-option-${n}`);
132
+ const ut = (e) => {
133
+ e.preventDefault(), !(F || b) && (V.current?.focus(), i(!s));
134
+ }, pt = r ? K ? K(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ o(At, {
123
135
  dataTest: `selected-chip-${d(e)}`,
124
136
  label: d(e),
125
- readOnly: g,
137
+ readOnly: b,
126
138
  deleteButtonTabIndex: -1,
127
- onDelete: g ? void 0 : (a) => v(a, e)
128
- }, A ? A(e) : `${d(e)}-${t}`)) : void 0, Ke = /* @__PURE__ */ I("span", {
139
+ onDelete: b ? void 0 : (a) => w(a, e)
140
+ }, A ? A(e) : `${d(e)}-${t}`)) : void 0, ft = /* @__PURE__ */ N("span", {
129
141
  className: "flex items-center gap-1",
130
142
  children: [
131
- q && /* @__PURE__ */ o(xt, {
143
+ z && /* @__PURE__ */ o(Mt, {
132
144
  width: 20,
133
145
  height: 20,
134
146
  className: "animate-spin"
135
147
  }),
136
- ce && /* @__PURE__ */ o("button", {
148
+ ge && /* @__PURE__ */ o("button", {
137
149
  type: "button",
138
150
  tabIndex: -1,
139
151
  "aria-label": "Clear",
140
152
  "data-testid": `${l}-clear`,
141
153
  className: "invisible flex min-h-6 min-w-6 cursor-pointer items-center justify-center rounded-full border-0 bg-delta-50 group-focus-within:visible",
142
154
  onMouseDown: (e) => e.preventDefault(),
143
- onClick: ie,
144
- children: /* @__PURE__ */ o(pt, {
155
+ onClick: Q,
156
+ children: /* @__PURE__ */ o(It, {
145
157
  width: 20,
146
158
  height: 20,
147
159
  className: "text-delta-700"
148
160
  })
149
161
  }),
150
- g ? null : /* @__PURE__ */ o("button", {
162
+ b ? null : /* @__PURE__ */ o("button", {
151
163
  type: "button",
152
164
  tabIndex: -1,
153
165
  "aria-label": "Toggle options",
154
- "aria-expanded": n,
166
+ "aria-expanded": s,
155
167
  "data-testid": `${l}-popup-indicator`,
156
168
  className: "flex cursor-pointer items-center border-0 bg-transparent",
157
169
  onMouseDown: (e) => e.preventDefault(),
158
- onClick: Xe,
159
- children: Ne ?? (s ? /* @__PURE__ */ o(mt, {
170
+ onClick: ut,
171
+ children: $e ?? (r ? /* @__PURE__ */ o(Pt, {
160
172
  width: 24,
161
173
  height: 24,
162
174
  className: "text-delta-700"
163
- }) : /* @__PURE__ */ o(ut, {
175
+ }) : /* @__PURE__ */ o(Dt, {
164
176
  width: 24,
165
177
  height: 24,
166
- className: E(B["select-custom-icon"], n && B["select-custom-icon-open"], "text-delta-700")
178
+ className: D(J["select-custom-icon"], s && J["select-custom-icon-open"], "text-delta-700")
167
179
  }))
168
180
  })
169
181
  ]
170
- }), et = {
171
- disabled: S,
172
- size: ke,
182
+ }), mt = {
183
+ disabled: F,
184
+ size: Se,
173
185
  fullWidth: !0,
174
- error: ye,
175
- helperText: we,
176
- value: m,
186
+ error: Ae,
187
+ helperText: Ce,
188
+ value: g,
177
189
  onChange: (e) => {
178
- x(null), _(e, e.target.value, "input"), n || c(!0);
190
+ k || (y(null), S(e, e.target.value, "input"), s || i(!0));
179
191
  },
180
- onKeyDown: Qe,
192
+ onKeyDown: dt,
181
193
  slotProps: {
182
194
  htmlInput: {
183
- ...Ue(),
184
- ref: ee,
185
- onClick: () => c(!0),
195
+ ...tt(),
196
+ ref: V,
197
+ onClick: () => i(!0),
186
198
  role: "combobox",
187
199
  "aria-autocomplete": "list",
188
- "aria-expanded": n,
189
- "aria-controls": n ? Z : void 0,
190
- "aria-activedescendant": de,
200
+ "aria-expanded": s,
201
+ "aria-controls": s ? U : void 0,
202
+ "aria-activedescendant": xe,
191
203
  autoComplete: "off",
192
- readOnly: g
204
+ readOnly: b,
205
+ ...k ? {
206
+ inputMode: "none",
207
+ "aria-haspopup": "dialog"
208
+ } : {}
193
209
  },
194
210
  input: {
195
- ref: Ye,
196
- startAdornment: Ze,
197
- endAdornment: Ke
211
+ ref: ot,
212
+ startAdornment: pt,
213
+ endAdornment: ft
198
214
  }
199
215
  }
200
- }, tt = E("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-2 text-base text-delta-800", ve === "regular" ? "min-h-12" : "min-h-10", "aria-selected:bg-gama-50 hover:bg-delta-50", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300"), lt = (e, t, a) => {
201
- const { key: p, ...w } = e;
202
- return /* @__PURE__ */ I("li", {
203
- ...w,
216
+ }, ye = D("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-2 text-base text-delta-800", Re === "regular" ? "min-h-12" : "min-h-10", "aria-selected:bg-gama-50 hover:bg-delta-50", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300"), ke = (e, t, a) => {
217
+ const { key: u, ...f } = e;
218
+ return /* @__PURE__ */ N("li", {
219
+ ...f,
204
220
  children: [
205
221
  e["data-active"] !== void 0 && /* @__PURE__ */ o("span", {
206
222
  "aria-hidden": "true",
207
223
  className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
208
224
  }),
209
- s ? /* @__PURE__ */ o(ue, {
225
+ r ? /* @__PURE__ */ o(ve, {
210
226
  dataTest: `${l}-${d(t)}-checkbox`,
211
227
  checked: a.selected,
212
228
  size: "medium",
@@ -214,109 +230,143 @@ function qt({ dataTest: l, options: b, renderInput: he, value: N, onChange: C, g
214
230
  hideWrapper: !0,
215
231
  decorative: !0
216
232
  }) : /* @__PURE__ */ o("span", {
217
- className: "w-5",
218
- children: a.selected && /* @__PURE__ */ o(ft, {
233
+ className: D("w-5", a.inPicker && "flex"),
234
+ children: a.selected && /* @__PURE__ */ o(Nt, {
219
235
  width: 20,
220
236
  height: 20,
221
237
  className: "text-gama-500"
222
238
  })
223
239
  }),
224
240
  /* @__PURE__ */ o("span", {
225
- className: "line-clamp-2 min-w-0 flex-1 break-words",
241
+ className: D(!a.inPicker && "line-clamp-2", "min-w-0 flex-1 break-words"),
226
242
  children: d(t)
227
243
  })
228
244
  ]
229
- }, p);
230
- }, st = (e, t) => {
231
- const a = $(e), p = {
232
- ...Te({
233
- onMouseDown: (f) => f.preventDefault(),
234
- onClick: (f) => {
235
- a || v(f, e);
245
+ }, u);
246
+ }, ht = (e, t) => {
247
+ const a = R(e), u = {
248
+ ...rt({
249
+ onMouseDown: (m) => m.preventDefault(),
250
+ onClick: (m) => {
251
+ a || w(m, e);
236
252
  },
237
- onMouseMove: () => x(null)
253
+ onMouseMove: () => y(null)
238
254
  }),
239
255
  key: A ? String(A(e)) : `${d(e)}-${t}`,
240
- ref: (f) => {
241
- K.current[t] = f;
256
+ ref: (m) => {
257
+ ce.current[t] = m;
242
258
  },
243
259
  role: "option",
244
260
  id: `${l}-option-${t}`,
245
- "aria-selected": W(e),
261
+ "aria-selected": O(e),
246
262
  "aria-disabled": a || void 0,
247
- "data-active": r === t ? "" : void 0,
248
- className: tt
249
- }, w = {
250
- selected: W(e),
263
+ "data-active": n === t ? "" : void 0,
264
+ className: ye
265
+ }, f = {
266
+ selected: O(e),
251
267
  index: t,
252
- inputValue: m
268
+ inputValue: g
253
269
  };
254
- return T ? T(p, e, w) : lt(p, e, w);
255
- }, rt = !!(M && s), H = b.length > 0 && i.length === b.length, ot = i.length > 0 && !H;
256
- return /* @__PURE__ */ I("div", {
257
- className: E(B.styledSelectAutocompleteWrapper, Le, $e),
258
- "data-field-width": G,
259
- style: gt(G),
260
- children: [he(et), n && /* @__PURE__ */ o(yt, {
261
- root: ae,
262
- children: /* @__PURE__ */ I("ul", {
263
- ref: qe,
264
- ...j ? nt : {},
265
- style: {
266
- ...j ? at : {},
267
- ...Be,
268
- width: je ?? void 0,
269
- maxHeight: te ?? void 0,
270
- fontFamily: "Roboto, Helvetica, Arial, sans-serif",
271
- ...Q?.popper?.style
272
- },
273
- ...Ve(),
274
- id: Z,
275
- role: "listbox",
276
- "aria-multiselectable": s ? !0 : void 0,
277
- className: E("z-[1300] m-0 list-none overflow-auto rounded border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", rt && "py-0", "[&>li:not(:last-child)]:shadow-[inset_0_-1px_0_var(--colors-delta-200)]", Me?.listbox, Q?.popper?.className),
278
- children: [M && s && /* @__PURE__ */ I("li", {
279
- id: `${l}-select-all`,
280
- role: "option",
281
- "aria-selected": H,
282
- "data-active": r === -1 ? "" : void 0,
283
- tabIndex: -1,
284
- onMouseDown: (e) => e.preventDefault(),
285
- onClick: z,
286
- onMouseMove: () => x(null),
287
- className: "relative box-border flex h-8 cursor-pointer items-center gap-x-3 bg-[var(--colors-gray-10)] px-3 text-xs font-semibold uppercase tracking-[0.2px] text-delta-600 hover:bg-delta-50",
288
- children: [
289
- r === -1 && /* @__PURE__ */ o("span", {
290
- "aria-hidden": "true",
291
- className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
292
- }),
293
- /* @__PURE__ */ o(ue, {
294
- dataTest: `${l}-select-all`,
295
- checked: H,
296
- indeterminate: ot,
297
- size: "medium",
298
- checkboxClassName: "!h-4 !w-4",
299
- hideWrapper: !0,
300
- decorative: !0
301
- }),
302
- /* @__PURE__ */ o("span", {
303
- className: "flex-1 truncate",
304
- children: Se
305
- })
306
- ]
307
- }), q ? /* @__PURE__ */ o("li", {
308
- role: "presentation",
309
- className: "px-3 py-2 text-sm text-delta-600",
310
- children: ge
311
- }) : u.length === 0 ? /* @__PURE__ */ o("li", {
312
- role: "presentation",
313
- className: "px-3 py-2 text-sm text-delta-600",
314
- children: xe
315
- }) : u.map(st)]
270
+ return j ? j(u, e, f) : ke(u, e, f);
271
+ }, bt = !!(C && r), G = h.length > 0 && c.length === h.length, gt = c.length > 0 && !G;
272
+ return /* @__PURE__ */ N("div", {
273
+ className: D(J.styledSelectAutocompleteWrapper, He, ze),
274
+ "data-field-width": oe,
275
+ style: Rt(oe),
276
+ children: [
277
+ Ne(mt),
278
+ k && /* @__PURE__ */ N(zt, { children: [/* @__PURE__ */ o($t, {
279
+ announcement: qe,
280
+ dataTest: `${l}-live`
281
+ }), /* @__PURE__ */ o(jt, {
282
+ open: s,
283
+ dataTest: l,
284
+ listboxId: U,
285
+ title: H ?? (ae.label || void 0),
286
+ name: typeof H == "string" ? H : ae.name || B.search,
287
+ text: B,
288
+ options: h,
289
+ multiple: r,
290
+ value: r ? c : x,
291
+ clearable: !le && !b,
292
+ isEqual: v,
293
+ isOptionDisabled: R,
294
+ getLabel: d,
295
+ getOptionKey: A,
296
+ filterOptions: _,
297
+ renderOptionRow: j ?? ke,
298
+ optionRowClassName: ye,
299
+ loading: z,
300
+ loadingText: ee,
301
+ noOptionsText: te,
302
+ allowSelectAll: C,
303
+ selectAllLabel: re,
304
+ onSelect: w,
305
+ onClear: it,
306
+ onApply: ct,
307
+ onCancel: () => i(!1)
308
+ })] }),
309
+ s && !k && /* @__PURE__ */ o(Ht, {
310
+ root: be,
311
+ children: /* @__PURE__ */ N("ul", {
312
+ ref: st,
313
+ ...q ? xt : {},
314
+ style: {
315
+ ...q ? yt : {},
316
+ ...et,
317
+ width: Xe ?? void 0,
318
+ maxHeight: de ?? void 0,
319
+ fontFamily: "Roboto, Helvetica, Arial, sans-serif",
320
+ ...ne?.popper?.style
321
+ },
322
+ ...lt(),
323
+ id: U,
324
+ role: "listbox",
325
+ "aria-multiselectable": r ? !0 : void 0,
326
+ className: D("z-[1300] m-0 list-none overflow-auto rounded border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", bt && "py-0", "[&>li:not(:last-child)]:shadow-[inset_0_-1px_0_var(--colors-delta-200)]", Le?.listbox, ne?.popper?.className),
327
+ children: [C && r && /* @__PURE__ */ N("li", {
328
+ id: `${l}-select-all`,
329
+ role: "option",
330
+ "aria-selected": G,
331
+ "data-active": n === -1 ? "" : void 0,
332
+ tabIndex: -1,
333
+ onMouseDown: (e) => e.preventDefault(),
334
+ onClick: T,
335
+ onMouseMove: () => y(null),
336
+ className: "relative box-border flex h-8 cursor-pointer items-center gap-x-3 bg-[var(--colors-gray-10)] px-3 text-xs font-semibold uppercase tracking-[0.2px] text-delta-600 hover:bg-delta-50",
337
+ children: [
338
+ n === -1 && /* @__PURE__ */ o("span", {
339
+ "aria-hidden": "true",
340
+ className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
341
+ }),
342
+ /* @__PURE__ */ o(ve, {
343
+ dataTest: `${l}-select-all`,
344
+ checked: G,
345
+ indeterminate: gt,
346
+ size: "medium",
347
+ checkboxClassName: "!h-4 !w-4",
348
+ hideWrapper: !0,
349
+ decorative: !0
350
+ }),
351
+ /* @__PURE__ */ o("span", {
352
+ className: "flex-1 truncate",
353
+ children: re
354
+ })
355
+ ]
356
+ }), z ? /* @__PURE__ */ o("li", {
357
+ role: "presentation",
358
+ className: "px-3 py-2 text-sm text-delta-600",
359
+ children: ee
360
+ }) : p.length === 0 ? /* @__PURE__ */ o("li", {
361
+ role: "presentation",
362
+ className: "px-3 py-2 text-sm text-delta-600",
363
+ children: te
364
+ }) : p.map(ht)]
365
+ })
316
366
  })
317
- })]
367
+ ]
318
368
  });
319
369
  }
320
370
  export {
321
- qt as StyledSelectAutocomplete
371
+ vl as StyledSelectAutocomplete
322
372
  };
@@ -0,0 +1,24 @@
1
+ var u = (t, r, s) => {
2
+ if (r.length === 0) return t.length > 0 ? [{
3
+ value: [],
4
+ reason: "clear"
5
+ }] : [];
6
+ const c = [];
7
+ let o = [...t];
8
+ for (const e of t)
9
+ r.some((n) => s(e, n)) || (o = o.filter((n) => !s(n, e)), c.push({
10
+ value: o,
11
+ reason: "removeOption",
12
+ option: e
13
+ }));
14
+ for (const e of r)
15
+ t.some((n) => s(e, n)) || (o = [...o, e], c.push({
16
+ value: o,
17
+ reason: "selectOption",
18
+ option: e
19
+ }));
20
+ return c;
21
+ };
22
+ export {
23
+ u as getDraftChanges
24
+ };