asma-ui-core 3.108.3 → 3.109.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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/data-display/interactive-chip/StyledInteractiveChip.js +18 -18
- package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +52 -51
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +66 -65
- package/dist/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.js +13 -12
- package/dist/components/inputs/dynamic-select/components/DynamicSelectTitle.js +9 -0
- package/dist/components/inputs/select/StyledSelect.js +56 -50
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +102 -96
- package/dist/components/navigation/drawer/StyledDrawer.js +55 -51
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +158 -118
- package/dist/components/utils/popover/PopoverSheet.js +95 -85
- package/dist/components/utils/popover/StyledPopover.js +81 -71
- package/dist/datetime/components/date-picker/StyledDatePicker.js +36 -27
- package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +9 -8
- package/dist/datetime/components/time-picker/StyledTimePicker.js +75 -64
- package/dist/datetime/hooks/useBackNavigationClose.hook.js +19 -0
- package/dist/src/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.d.ts +2 -2
- package/dist/src/components/inputs/dynamic-select/components/DynamicSelectTitle.d.ts +14 -0
- package/dist/src/components/inputs/dynamic-select/types.d.ts +8 -2
- package/dist/src/components/navigation/drawer/StyledDrawer.d.ts +2 -0
- package/dist/src/components/utils/bottom-sheet/StyledBottomSheet.d.ts +6 -2
- package/dist/src/components/utils/popover/StyledPopover.d.ts +3 -1
- package/dist/src/datetime/hooks/useBackNavigationClose.hook.d.ts +5 -0
- package/package.json +1 -1
|
@@ -3,46 +3,52 @@ import { resolveSx as je } from "../../../helpers/sx.js";
|
|
|
3
3
|
import { TOP_LAYER_PROPS as Ue, TOP_LAYER_RESET_STYLE as Ve, getOpenModalDialogAncestor as re, shouldUsePopoverTopLayer as qe, useTopLayerRef as Ye } from "../../../hooks/useTopLayer.hook.js";
|
|
4
4
|
import { ChevronDownIcon as ze } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
5
5
|
import { CloseIcon as Ke } from "../../icons/close-icon/CloseIcon.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { useBackCloses as We } from "../../../hooks/useBackCloses.hook.js";
|
|
7
|
+
import { HelperRow as Ge } from "../../../helpers/HelperRow.js";
|
|
8
|
+
import { useHelperRowBudget as Je } from "../../../helpers/useHelperRowBudget.js";
|
|
9
|
+
import { useHelperSlot as Qe } from "../../../helpers/useHelperSlot.js";
|
|
10
|
+
import { outlineClass as Xe } from "../field-styles.js";
|
|
11
|
+
import { useFormControlContext as Ze } from "../../miscellaneous/FormControlContext.js";
|
|
12
|
+
import { Children as se, cloneElement as et, isValidElement as p, useEffect as H, useId as tt, useRef as ot, useState as x } from "react";
|
|
12
13
|
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
13
|
-
import { FloatingPortal as
|
|
14
|
-
var
|
|
15
|
-
const u =
|
|
16
|
-
K(e), e ||
|
|
17
|
-
}, { refs: { domReference: De, reference: J, setFloating: Se, setReference: Ce }, floatingStyles: Fe, context: P } =
|
|
14
|
+
import { FloatingPortal as rt, autoUpdate as st, flip as nt, offset as lt, shift as it, size as at, useClick as ct, useDismiss as dt, useFloating as ut, useInteractions as ft, useMergeRefs as pt, useRole as mt } from "@floating-ui/react";
|
|
15
|
+
var It = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, errorText: ie, helperText: j, reserveHelperText: ae, expandHelperText: ce = !0, allowClear: U, disabled: de, readOnly: c, name: w, placeholder: S, displayEmpty: C, multiple: d, renderValue: V, fullWidth: ue, className: fe, style: pe, sx: me, variant: ge, children: q, MenuProps: be, onFocus: ye, onBlur: he, labelId: v }) => {
|
|
16
|
+
const u = Ze(), A = `${T}-listbox`, R = ge === "standard", m = le ?? u?.error ?? !1, n = de ?? u?.disabled ?? !1, Y = m ? ie ?? j : j, { show: F, role: xe } = Qe("StyledSelect", m, Y, ae, c), z = tt(), { fieldRef: we, rowRef: ve, rowStyle: Ae } = Je(ce && F), [r, K] = x(!1), [k, I] = x(!1), [g, b] = x(null), [Re, W] = x(ne), O = M !== void 0, o = O ? M : Re, i = Array.isArray(o) ? o.length > 0 : o !== void 0 && o !== "" && o !== null, y = se.toArray(q), G = (e) => d ? Array.isArray(o) && o.includes(e) : e === o, s = y.flatMap((e, t) => p(e) && !e.props.disabled ? [t] : []), _ = y.findIndex((e) => p(e) && G(e.props.value)), ke = (e = 1) => s.includes(_) ? _ : s[e === 1 ? 0 : s.length - 1] ?? null, D = g === null ? void 0 : `${A}-option-${g}`, E = ot(null), f = (e) => {
|
|
17
|
+
K(e), e || b(null);
|
|
18
|
+
}, { refs: { domReference: De, reference: J, setFloating: Se, setReference: Ce }, floatingStyles: Fe, context: P } = ut({
|
|
18
19
|
open: r,
|
|
19
|
-
onOpenChange:
|
|
20
|
+
onOpenChange: f,
|
|
20
21
|
placement: "bottom-start",
|
|
21
22
|
strategy: "fixed",
|
|
22
|
-
whileElementsMounted:
|
|
23
|
+
whileElementsMounted: st,
|
|
23
24
|
middleware: [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
lt(0),
|
|
26
|
+
nt({ padding: 8 }),
|
|
27
|
+
it({ padding: 8 }),
|
|
28
|
+
at({ apply({ rects: e, elements: t }) {
|
|
28
29
|
t.floating.style.minWidth = `${e.reference.width}px`;
|
|
29
30
|
} })
|
|
30
31
|
]
|
|
31
|
-
}), { getReferenceProps: Ie, getFloatingProps: Oe } =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
])
|
|
36
|
-
|
|
32
|
+
}), { getReferenceProps: Ie, getFloatingProps: Oe } = ft([
|
|
33
|
+
ct(P, { enabled: !n && !c }),
|
|
34
|
+
dt(P),
|
|
35
|
+
mt(P, { role: "listbox" })
|
|
36
|
+
]);
|
|
37
|
+
We({
|
|
38
|
+
active: r,
|
|
39
|
+
requestClose: () => f(!1)
|
|
40
|
+
});
|
|
41
|
+
const [Q, X] = x(), N = qe(Q), _e = pt([Ye(Se, N), E]);
|
|
42
|
+
H(() => u?.setFocused(r || k), [
|
|
37
43
|
r,
|
|
38
44
|
k,
|
|
39
45
|
u
|
|
40
|
-
]),
|
|
46
|
+
]), H(() => u?.setFilled(i || !!S || !!C), [
|
|
41
47
|
i,
|
|
42
48
|
S,
|
|
43
49
|
C,
|
|
44
50
|
u
|
|
45
|
-
]),
|
|
51
|
+
]), H(() => {
|
|
46
52
|
if (!r) return;
|
|
47
53
|
const e = requestAnimationFrame(() => {
|
|
48
54
|
const t = D ? document.getElementById(D) : E.current?.querySelector('[role="option"][aria-selected="true"]');
|
|
@@ -55,37 +61,37 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
55
61
|
O || W(oe), $?.({ target: {
|
|
56
62
|
value: oe,
|
|
57
63
|
name: w
|
|
58
|
-
} }, t), a && (
|
|
64
|
+
} }, t), a && (f(!1), requestAnimationFrame(() => De.current?.focus()));
|
|
59
65
|
}, ee = () => {
|
|
60
66
|
const e = d ? [] : "";
|
|
61
67
|
O || W(e), $?.({ target: {
|
|
62
68
|
value: e,
|
|
63
69
|
name: w
|
|
64
|
-
} }, null),
|
|
70
|
+
} }, null), f(!1), I(!1);
|
|
65
71
|
}, Ee = se.map(q, (e, t) => {
|
|
66
|
-
if (!
|
|
72
|
+
if (!p(e)) return e;
|
|
67
73
|
const a = e.props.value;
|
|
68
|
-
return
|
|
74
|
+
return et(e, {
|
|
69
75
|
id: `${A}-option-${t}`,
|
|
70
|
-
active: t ===
|
|
76
|
+
active: t === g,
|
|
71
77
|
selected: G(a),
|
|
72
78
|
onClick: () => {
|
|
73
|
-
|
|
79
|
+
b(null), Z(a, e.props.children);
|
|
74
80
|
}
|
|
75
81
|
});
|
|
76
|
-
}), Pe =
|
|
82
|
+
}), Pe = y.find((e) => p(e) && e.props.value === o), Ne = V ? V(o) : d && Array.isArray(o) ? y.filter((e) => p(e) && o.includes(e.props.value)).map((e) => {
|
|
77
83
|
const t = e.props.children;
|
|
78
84
|
return typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
79
|
-
}).join(", ") : Pe?.props.children,
|
|
80
|
-
s.length !== 0 &&
|
|
85
|
+
}).join(", ") : Pe?.props.children, Be = (e) => {
|
|
86
|
+
s.length !== 0 && b((t) => {
|
|
81
87
|
const a = s.indexOf(t ?? _ ?? -1);
|
|
82
88
|
return a === -1 ? s[e === 1 ? 0 : s.length - 1] ?? null : s[Math.min(Math.max(a + e, 0), s.length - 1)] ?? null;
|
|
83
89
|
});
|
|
84
90
|
}, te = (e) => {
|
|
85
|
-
const t =
|
|
86
|
-
!
|
|
87
|
-
},
|
|
88
|
-
X(re(J.current)),
|
|
91
|
+
const t = g === null ? void 0 : y[g];
|
|
92
|
+
!p(t) || t.props.disabled || Z(t.props.value, t.props.children, e);
|
|
93
|
+
}, He = (e = 1) => {
|
|
94
|
+
X(re(J.current)), b(ke(e)), K(!0);
|
|
89
95
|
}, Le = (e) => {
|
|
90
96
|
if ((e.key === "Backspace" || e.key === "Delete") && U && i && !n && !c) {
|
|
91
97
|
e.preventDefault(), ee();
|
|
@@ -93,12 +99,12 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
93
99
|
}
|
|
94
100
|
if (!(n || c)) {
|
|
95
101
|
if (!r && (e.key === "ArrowDown" || e.key === "ArrowUp")) {
|
|
96
|
-
e.preventDefault(),
|
|
102
|
+
e.preventDefault(), He(e.key === "ArrowDown" ? 1 : -1);
|
|
97
103
|
return;
|
|
98
104
|
}
|
|
99
|
-
r && (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(),
|
|
105
|
+
r && (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), Be(e.key === "ArrowDown" ? 1 : -1)) : e.key === "Home" || e.key === "End" ? (e.preventDefault(), b(s[e.key === "Home" ? 0 : s.length - 1] ?? null)) : e.key === " " ? (e.preventDefault(), te(!1)) : e.key === "Enter" ? (e.preventDefault(), te(!0)) : e.key === "Escape" ? (e.preventDefault(), f(!1)) : e.key === "Tab" && f(!1));
|
|
100
106
|
}
|
|
101
|
-
},
|
|
107
|
+
}, B = R && (r || k), Te = n ? "text-delta-300" : B ? "text-gama-500" : "text-delta-800", Me = n ? "text-delta-300" : "text-delta-700";
|
|
102
108
|
return /* @__PURE__ */ L("div", {
|
|
103
109
|
ref: we,
|
|
104
110
|
className: h("group relative inline-flex flex-col", ue && "w-full", fe),
|
|
@@ -123,7 +129,7 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
123
129
|
"aria-activedescendant": r ? D : void 0,
|
|
124
130
|
"aria-labelledby": v,
|
|
125
131
|
"aria-label": v ? void 0 : w,
|
|
126
|
-
"aria-invalid":
|
|
132
|
+
"aria-invalid": m ? !0 : void 0,
|
|
127
133
|
"aria-describedby": F ? z : void 0,
|
|
128
134
|
"aria-disabled": n ? !0 : void 0,
|
|
129
135
|
disabled: n,
|
|
@@ -134,7 +140,7 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
134
140
|
I(!1), he?.(e);
|
|
135
141
|
},
|
|
136
142
|
style: { minWidth: i && !R ? 105 : void 0 },
|
|
137
|
-
className: h("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", "asma-touch-ready",
|
|
143
|
+
className: h("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", "asma-touch-ready", B ? "bg-gama-50" : "bg-transparent", Te, R && "min-w-0", n && "cursor-not-allowed", c && "pointer-events-none"),
|
|
138
144
|
children: [
|
|
139
145
|
/* @__PURE__ */ l("span", {
|
|
140
146
|
className: h("min-w-0 flex-1 truncate", !i && "text-delta-500"),
|
|
@@ -156,19 +162,19 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
156
162
|
}), /* @__PURE__ */ l(ze, {
|
|
157
163
|
width: 24,
|
|
158
164
|
height: 24,
|
|
159
|
-
className: h("shrink-0 transition-transform",
|
|
165
|
+
className: h("shrink-0 transition-transform", B ? "text-gama-500" : Me, r && "flip-180")
|
|
160
166
|
})]
|
|
161
167
|
}),
|
|
162
|
-
/* @__PURE__ */ l("div", { className:
|
|
168
|
+
/* @__PURE__ */ l("div", { className: Xe({
|
|
163
169
|
focused: r || k,
|
|
164
|
-
error:
|
|
170
|
+
error: m,
|
|
165
171
|
disabled: n,
|
|
166
172
|
readOnly: c,
|
|
167
173
|
borderless: R
|
|
168
174
|
}) })
|
|
169
175
|
]
|
|
170
176
|
}),
|
|
171
|
-
r && /* @__PURE__ */ l(
|
|
177
|
+
r && /* @__PURE__ */ l(rt, {
|
|
172
178
|
root: Q,
|
|
173
179
|
children: /* @__PURE__ */ l("ul", {
|
|
174
180
|
ref: _e,
|
|
@@ -188,11 +194,11 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
188
194
|
children: Ee
|
|
189
195
|
})
|
|
190
196
|
}),
|
|
191
|
-
F && /* @__PURE__ */ l(
|
|
197
|
+
F && /* @__PURE__ */ l(Ge, {
|
|
192
198
|
ref: ve,
|
|
193
199
|
id: z,
|
|
194
200
|
role: xe,
|
|
195
|
-
error:
|
|
201
|
+
error: m,
|
|
196
202
|
message: Y,
|
|
197
203
|
className: "m-0 mr-[14px] box-border items-center",
|
|
198
204
|
style: Ae
|
|
@@ -201,5 +207,5 @@ var Ct = ({ dataTest: T, value: M, defaultValue: ne, onChange: $, error: le, err
|
|
|
201
207
|
});
|
|
202
208
|
};
|
|
203
209
|
export {
|
|
204
|
-
|
|
210
|
+
It as StyledSelect
|
|
205
211
|
};
|
|
@@ -6,18 +6,19 @@ import { CheckIcon as ft } from "../../icons/check-icon/CheckIcon.js";
|
|
|
6
6
|
import { PlusIconCircle as mt } from "../../icons/plus-icon-circle/PlusIconCircle.js";
|
|
7
7
|
import { StyledChip as ht } from "../../data-display/chip/StyledChip.js";
|
|
8
8
|
import { StyledCheckbox as de } from "../checkbox/base-ui/StyledCheckbox.js";
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import { useBackCloses as bt } from "../../../hooks/useBackCloses.hook.js";
|
|
10
|
+
import { LoadingIcon as gt } from "../../../table/shared-components/LoadingIcon.js";
|
|
11
|
+
import B from "./StyledSelectAutocomplete.module.js";
|
|
12
|
+
import { useEffect as ue, useMemo as U, useRef as pe, useState as D } from "react";
|
|
13
|
+
import { jsx as r, jsxs as I } from "react/jsx-runtime";
|
|
14
|
+
import { FloatingPortal as xt, autoUpdate as wt, flip as yt, offset as kt, shift as vt, size as Dt, useDismiss as It, useFloating as Nt, useInteractions as Ct, useMergeRefs as fe, useRole as At } from "@floating-ui/react";
|
|
15
|
+
var St = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), Mt = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
|
|
16
|
+
function Vt({ dataTest: l, options: b, renderInput: me, value: N, onChange: C, getOptionLabel: he, getOptionKey: A, isOptionEqualToValue: V, renderOption: T, renderValue: Y, filterOptions: O, loading: q, loadingText: be = "Loading…", noOptionsText: ge = "No options", disabled: S, readOnly: g, error: xe, helperText: we, size: ye = "small", rowSize: ke = "compact", disableClearable: ve, disableCloseOnSelect: De, popupIcon: Ie, autoHeight: Ne, multiple: Ce, allowSelectAll: M, selectAllLabel: Ae = "Select all", fullWidth: Se, classes: Me, inputValue: R, onInputChange: Re, open: G, onOpen: Pe, onClose: $e, className: _e, wrapperClassName: Le, getOptionDisabled: Ee, slotProps: J }) {
|
|
17
|
+
const s = Ce === !0, d = he ?? St, P = (e, t) => V ? V(e, t) : e === t, [Oe, Fe] = D(!1), n = G ?? Oe, c = (e) => {
|
|
17
18
|
e && (g || S) || (G === void 0 && Fe(e), e ? Pe?.() : (x(null), $e?.()));
|
|
18
|
-
}, [je, Q] = D(""), m = R ?? je, $ = (e, t,
|
|
19
|
-
R === void 0 && Q(t), Re?.(e, t,
|
|
20
|
-
}, [
|
|
19
|
+
}, [je, Q] = D(""), m = R ?? je, $ = (e, t, a) => {
|
|
20
|
+
R === void 0 && Q(t), Re?.(e, t, a);
|
|
21
|
+
}, [o, x] = D(null), X = `${l}-listbox`, Z = pe([]), K = pe(null), [ze, He] = D(null), [ee, We] = D(null), i = s ? Array.isArray(N) ? N : [] : [], w = s ? null : N ?? null, te = !s && w !== null ? d(w) : "";
|
|
21
22
|
ue(() => {
|
|
22
23
|
R !== void 0 || s || Q(te);
|
|
23
24
|
}, [
|
|
@@ -25,108 +26,113 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
25
26
|
s,
|
|
26
27
|
te
|
|
27
28
|
]);
|
|
28
|
-
const F = (e) => s ? i.some((t) => P(e, t)) : w !== null && P(e, w), _ = (e) => Ee?.(e) ??
|
|
29
|
+
const F = (e) => s ? i.some((t) => P(e, t)) : w !== null && P(e, w), _ = (e) => Ee?.(e) ?? Mt(e), le = U(() => {
|
|
29
30
|
const e = [...b];
|
|
30
31
|
if (O) return O(e, { inputValue: m });
|
|
31
|
-
const t = !s && w !== null ?
|
|
32
|
+
const t = !s && w !== null ? d(w).toLowerCase() : null;
|
|
32
33
|
if (!m || m.toLowerCase() === t) return e;
|
|
33
|
-
const
|
|
34
|
-
return e.filter((p) =>
|
|
34
|
+
const a = m.toLowerCase();
|
|
35
|
+
return e.filter((p) => d(p).toLowerCase().includes(a));
|
|
35
36
|
}, [
|
|
36
37
|
b,
|
|
37
38
|
m,
|
|
38
39
|
O,
|
|
39
40
|
N
|
|
40
|
-
]), u =
|
|
41
|
+
]), u = U(() => le.slice(0, 100), [le]), se = u.flatMap((e, t) => _(e) ? [] : [t]), j = M && s ? [-1, ...se] : se, oe = u.map((e, t) => t), h = M && s ? [-1, ...oe] : oe, k = u.findIndex(F);
|
|
41
42
|
ue(() => {
|
|
42
|
-
if (!
|
|
43
|
-
const e =
|
|
43
|
+
if (!n) return;
|
|
44
|
+
const e = o ?? k;
|
|
44
45
|
if (e < 0) return;
|
|
45
46
|
const t = requestAnimationFrame(() => Z.current[e]?.scrollIntoView({ block: "nearest" }));
|
|
46
47
|
return () => cancelAnimationFrame(t);
|
|
47
48
|
}, [
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
o,
|
|
50
|
+
n,
|
|
50
51
|
ee,
|
|
51
52
|
k
|
|
52
53
|
]);
|
|
53
|
-
const { refs: L, floatingStyles:
|
|
54
|
-
open:
|
|
55
|
-
onOpenChange:
|
|
54
|
+
const { refs: L, floatingStyles: Be, context: re } = Nt({
|
|
55
|
+
open: n,
|
|
56
|
+
onOpenChange: c,
|
|
56
57
|
placement: "bottom-start",
|
|
57
58
|
strategy: "fixed",
|
|
58
|
-
whileElementsMounted:
|
|
59
|
+
whileElementsMounted: wt,
|
|
59
60
|
middleware: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
kt(0),
|
|
62
|
+
yt({ padding: 8 }),
|
|
63
|
+
vt({ padding: 8 }),
|
|
64
|
+
Dt({ apply({ rects: e, availableHeight: t }) {
|
|
64
65
|
He(e.reference.width), We(Ne ? t - 8 : Math.min(t - 8, 320));
|
|
65
66
|
} })
|
|
66
67
|
]
|
|
67
|
-
}), { getReferenceProps:
|
|
68
|
+
}), { getReferenceProps: Ue, getFloatingProps: Ve, getItemProps: Te } = Ct([It(re), At(re, { role: "listbox" })]);
|
|
69
|
+
bt({
|
|
70
|
+
active: n,
|
|
71
|
+
requestClose: () => c(!1)
|
|
72
|
+
});
|
|
73
|
+
const Ye = fe([L.setReference]), ne = U(() => n ? it(L.reference.current) : void 0, [n, L]), z = ct(ne), qe = fe([dt(L.setFloating, z)]), Ge = (e) => j.includes(k) ? k : j[e === 1 ? 0 : j.length - 1] ?? null, Je = (e) => {
|
|
68
74
|
h.length !== 0 && x((t) => {
|
|
69
|
-
const
|
|
70
|
-
return
|
|
75
|
+
const a = h.indexOf(t ?? k);
|
|
76
|
+
return a === -1 ? h[e === 1 ? 0 : h.length - 1] ?? null : h[Math.min(Math.max(a + e, 0), h.length - 1)] ?? null;
|
|
71
77
|
});
|
|
72
|
-
}, v = (e, t,
|
|
78
|
+
}, v = (e, t, a = !s || !De) => {
|
|
73
79
|
if (s) {
|
|
74
80
|
const p = i.some((f) => P(t, f)), y = p ? i.filter((f) => !P(t, f)) : [...i, t];
|
|
75
|
-
|
|
81
|
+
C?.(e, y, p ? "removeOption" : "selectOption", { option: t }), $(e, "", "reset"), a && c(!1);
|
|
76
82
|
} else
|
|
77
|
-
|
|
83
|
+
C?.(e, t, "selectOption", { option: t }), $(e, d(t), "reset"), a && c(!1);
|
|
78
84
|
}, ae = (e) => {
|
|
79
|
-
|
|
85
|
+
C?.(e, s ? [] : null, "clear", void 0), $(e, "", "clear");
|
|
80
86
|
}, H = (e) => {
|
|
81
87
|
const t = b.length > 0 && i.length === b.length;
|
|
82
|
-
|
|
88
|
+
C?.(e, t ? [] : b, t ? "clear" : "selectOption", void 0);
|
|
83
89
|
}, Qe = (e) => {
|
|
84
90
|
if (e.key === "Backspace" && m === "" && ie) {
|
|
85
91
|
const t = i[i.length - 1];
|
|
86
92
|
s ? t !== void 0 && v(e, t, !1) : ae(e);
|
|
87
|
-
} else if (e.key === "Enter" && !
|
|
88
|
-
e.preventDefault(),
|
|
89
|
-
else if (e.key === "Enter" &&
|
|
93
|
+
} else if (e.key === "Enter" && !n)
|
|
94
|
+
e.preventDefault(), c(!0);
|
|
95
|
+
else if (e.key === "Enter" && o === -1)
|
|
90
96
|
e.preventDefault(), H(e);
|
|
91
|
-
else if (e.key === "Enter" &&
|
|
97
|
+
else if (e.key === "Enter" && o != null && u[o] != null) {
|
|
92
98
|
e.preventDefault();
|
|
93
|
-
const t = u[
|
|
99
|
+
const t = u[o];
|
|
94
100
|
_(t) || v(e, t, !0);
|
|
95
101
|
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
96
|
-
if (e.preventDefault(), !
|
|
97
|
-
x(Ge(e.key === "ArrowDown" ? 1 : -1)),
|
|
102
|
+
if (e.preventDefault(), !n) {
|
|
103
|
+
x(Ge(e.key === "ArrowDown" ? 1 : -1)), c(!0);
|
|
98
104
|
return;
|
|
99
105
|
}
|
|
100
106
|
Je(e.key === "ArrowDown" ? 1 : -1);
|
|
101
107
|
} else if (e.key === "Home" || e.key === "End")
|
|
102
108
|
e.preventDefault(), x(h[e.key === "Home" ? 0 : h.length - 1] ?? null);
|
|
103
|
-
else if (e.key === " " &&
|
|
109
|
+
else if (e.key === " " && o === -1)
|
|
104
110
|
e.preventDefault(), H(e);
|
|
105
|
-
else if (e.key === " " &&
|
|
111
|
+
else if (e.key === " " && o != null && u[o] != null) {
|
|
106
112
|
e.preventDefault();
|
|
107
|
-
const t = u[
|
|
113
|
+
const t = u[o];
|
|
108
114
|
_(t) || v(e, t, !1);
|
|
109
|
-
} else e.key === "Escape" &&
|
|
115
|
+
} else e.key === "Escape" && n ? (e.preventDefault(), e.stopPropagation(), c(!1)) : e.key === "Tab" && c(!1);
|
|
110
116
|
}, ie = !ve && !g && !S && (s ? i.length > 0 : w !== null);
|
|
111
117
|
let ce;
|
|
112
|
-
|
|
118
|
+
n && o != null && (o === -1 || u[o] !== void 0) && (ce = o === -1 ? `${l}-select-all` : `${l}-option-${o}`);
|
|
113
119
|
const Xe = (e) => {
|
|
114
|
-
e.preventDefault(), !(S || g) && (K.current?.focus(),
|
|
115
|
-
}, Ze = s ? Y ? Y(i, ({ index: e }) => ({ "data-index": e })) : i.map((e, t) => /* @__PURE__ */
|
|
116
|
-
dataTest: `selected-chip-${
|
|
117
|
-
label:
|
|
120
|
+
e.preventDefault(), !(S || g) && (K.current?.focus(), c(!n));
|
|
121
|
+
}, Ze = s ? Y ? Y(i, ({ index: e }) => ({ "data-index": e })) : i.map((e, t) => /* @__PURE__ */ r(ht, {
|
|
122
|
+
dataTest: `selected-chip-${d(e)}`,
|
|
123
|
+
label: d(e),
|
|
118
124
|
readOnly: g,
|
|
119
125
|
deleteButtonTabIndex: -1,
|
|
120
|
-
onDelete: g ? void 0 : (
|
|
121
|
-
},
|
|
126
|
+
onDelete: g ? void 0 : (a) => v(a, e)
|
|
127
|
+
}, A ? A(e) : `${d(e)}-${t}`)) : void 0, Ke = /* @__PURE__ */ I("span", {
|
|
122
128
|
className: "flex items-center gap-1",
|
|
123
129
|
children: [
|
|
124
|
-
q && /* @__PURE__ */
|
|
130
|
+
q && /* @__PURE__ */ r(gt, {
|
|
125
131
|
width: 20,
|
|
126
132
|
height: 20,
|
|
127
133
|
className: "animate-spin"
|
|
128
134
|
}),
|
|
129
|
-
ie && /* @__PURE__ */
|
|
135
|
+
ie && /* @__PURE__ */ r("button", {
|
|
130
136
|
type: "button",
|
|
131
137
|
tabIndex: -1,
|
|
132
138
|
"aria-label": "Clear",
|
|
@@ -134,29 +140,29 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
134
140
|
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",
|
|
135
141
|
onMouseDown: (e) => e.preventDefault(),
|
|
136
142
|
onClick: ae,
|
|
137
|
-
children: /* @__PURE__ */
|
|
143
|
+
children: /* @__PURE__ */ r(pt, {
|
|
138
144
|
width: 20,
|
|
139
145
|
height: 20,
|
|
140
146
|
className: "text-delta-700"
|
|
141
147
|
})
|
|
142
148
|
}),
|
|
143
|
-
g ? null : /* @__PURE__ */
|
|
149
|
+
g ? null : /* @__PURE__ */ r("button", {
|
|
144
150
|
type: "button",
|
|
145
151
|
tabIndex: -1,
|
|
146
152
|
"aria-label": "Toggle options",
|
|
147
|
-
"aria-expanded":
|
|
153
|
+
"aria-expanded": n,
|
|
148
154
|
"data-testid": `${l}-popup-indicator`,
|
|
149
155
|
className: "flex cursor-pointer items-center border-0 bg-transparent",
|
|
150
156
|
onMouseDown: (e) => e.preventDefault(),
|
|
151
157
|
onClick: Xe,
|
|
152
|
-
children: Ie ?? (s ? /* @__PURE__ */
|
|
158
|
+
children: Ie ?? (s ? /* @__PURE__ */ r(mt, {
|
|
153
159
|
width: 24,
|
|
154
160
|
height: 24,
|
|
155
161
|
className: "text-delta-700"
|
|
156
|
-
}) : /* @__PURE__ */
|
|
162
|
+
}) : /* @__PURE__ */ r(ut, {
|
|
157
163
|
width: 24,
|
|
158
164
|
height: 24,
|
|
159
|
-
className: E(
|
|
165
|
+
className: E(B["select-custom-icon"], n && B["select-custom-icon-open"], "text-delta-700")
|
|
160
166
|
}))
|
|
161
167
|
})
|
|
162
168
|
]
|
|
@@ -168,18 +174,18 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
168
174
|
helperText: we,
|
|
169
175
|
value: m,
|
|
170
176
|
onChange: (e) => {
|
|
171
|
-
x(null), $(e, e.target.value, "input"),
|
|
177
|
+
x(null), $(e, e.target.value, "input"), n || c(!0);
|
|
172
178
|
},
|
|
173
179
|
onKeyDown: Qe,
|
|
174
180
|
slotProps: {
|
|
175
181
|
htmlInput: {
|
|
176
|
-
...
|
|
182
|
+
...Ue(),
|
|
177
183
|
ref: K,
|
|
178
|
-
onClick: () =>
|
|
184
|
+
onClick: () => c(!0),
|
|
179
185
|
role: "combobox",
|
|
180
186
|
"aria-autocomplete": "list",
|
|
181
|
-
"aria-expanded":
|
|
182
|
-
"aria-controls":
|
|
187
|
+
"aria-expanded": n,
|
|
188
|
+
"aria-controls": n ? X : void 0,
|
|
183
189
|
"aria-activedescendant": ce,
|
|
184
190
|
autoComplete: "off",
|
|
185
191
|
readOnly: g
|
|
@@ -190,54 +196,54 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
190
196
|
endAdornment: Ke
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
|
-
}, tt = E("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-2 text-base text-delta-800", ke === "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,
|
|
199
|
+
}, tt = E("asma-pressable", "relative box-border flex cursor-pointer items-center gap-x-3 px-3 py-2 text-base text-delta-800", ke === "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) => {
|
|
194
200
|
const { key: p, ...y } = e;
|
|
195
201
|
return /* @__PURE__ */ I("li", {
|
|
196
202
|
...y,
|
|
197
203
|
children: [
|
|
198
|
-
e["data-active"] !== void 0 && /* @__PURE__ */
|
|
204
|
+
e["data-active"] !== void 0 && /* @__PURE__ */ r("span", {
|
|
199
205
|
"aria-hidden": "true",
|
|
200
206
|
className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
|
|
201
207
|
}),
|
|
202
|
-
s ? /* @__PURE__ */
|
|
203
|
-
dataTest: `${l}-${
|
|
204
|
-
checked:
|
|
208
|
+
s ? /* @__PURE__ */ r(de, {
|
|
209
|
+
dataTest: `${l}-${d(t)}-checkbox`,
|
|
210
|
+
checked: a.selected,
|
|
205
211
|
size: "medium",
|
|
206
212
|
checkboxClassName: "!h-4 !w-4",
|
|
207
213
|
hideWrapper: !0,
|
|
208
214
|
decorative: !0
|
|
209
|
-
}) : /* @__PURE__ */
|
|
215
|
+
}) : /* @__PURE__ */ r("span", {
|
|
210
216
|
className: "w-5",
|
|
211
|
-
children:
|
|
217
|
+
children: a.selected && /* @__PURE__ */ r(ft, {
|
|
212
218
|
width: 20,
|
|
213
219
|
height: 20,
|
|
214
220
|
className: "text-gama-500"
|
|
215
221
|
})
|
|
216
222
|
}),
|
|
217
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ r("span", {
|
|
218
224
|
className: "line-clamp-2 min-w-0 flex-1 break-words",
|
|
219
|
-
children:
|
|
225
|
+
children: d(t)
|
|
220
226
|
})
|
|
221
227
|
]
|
|
222
228
|
}, p);
|
|
223
229
|
}, st = (e, t) => {
|
|
224
|
-
const
|
|
230
|
+
const a = _(e), p = {
|
|
225
231
|
...Te({
|
|
226
232
|
onMouseDown: (f) => f.preventDefault(),
|
|
227
233
|
onClick: (f) => {
|
|
228
|
-
|
|
234
|
+
a || v(f, e);
|
|
229
235
|
},
|
|
230
236
|
onMouseMove: () => x(null)
|
|
231
237
|
}),
|
|
232
|
-
key:
|
|
238
|
+
key: A ? String(A(e)) : `${d(e)}-${t}`,
|
|
233
239
|
ref: (f) => {
|
|
234
240
|
Z.current[t] = f;
|
|
235
241
|
},
|
|
236
242
|
role: "option",
|
|
237
243
|
id: `${l}-option-${t}`,
|
|
238
244
|
"aria-selected": F(e),
|
|
239
|
-
"aria-disabled":
|
|
240
|
-
"data-active":
|
|
245
|
+
"aria-disabled": a || void 0,
|
|
246
|
+
"data-active": o === t ? "" : void 0,
|
|
241
247
|
className: tt
|
|
242
248
|
}, y = {
|
|
243
249
|
selected: F(e),
|
|
@@ -245,61 +251,61 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
245
251
|
inputValue: m
|
|
246
252
|
};
|
|
247
253
|
return T ? T(p, e, y) : lt(p, e, y);
|
|
248
|
-
},
|
|
254
|
+
}, ot = !!(M && s), W = b.length > 0 && i.length === b.length, rt = i.length > 0 && !W;
|
|
249
255
|
return /* @__PURE__ */ I("div", {
|
|
250
|
-
className: E(
|
|
251
|
-
children: [me(et),
|
|
256
|
+
className: E(B.styledSelectAutocompleteWrapper, !Se && "w-auto", Le, _e),
|
|
257
|
+
children: [me(et), n && /* @__PURE__ */ r(xt, {
|
|
252
258
|
root: ne,
|
|
253
259
|
children: /* @__PURE__ */ I("ul", {
|
|
254
260
|
ref: qe,
|
|
255
261
|
...z ? nt : {},
|
|
256
262
|
style: {
|
|
257
263
|
...z ? at : {},
|
|
258
|
-
...
|
|
264
|
+
...Be,
|
|
259
265
|
width: ze ?? void 0,
|
|
260
266
|
maxHeight: ee ?? void 0,
|
|
261
267
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
262
268
|
...J?.popper?.style
|
|
263
269
|
},
|
|
264
|
-
...
|
|
270
|
+
...Ve(),
|
|
265
271
|
id: X,
|
|
266
272
|
role: "listbox",
|
|
267
273
|
"aria-multiselectable": s ? !0 : void 0,
|
|
268
|
-
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)]",
|
|
274
|
+
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)]", ot && "py-0", "[&>li:not(:last-child)]:shadow-[inset_0_-1px_0_var(--colors-delta-200)]", Me?.listbox, J?.popper?.className),
|
|
269
275
|
children: [M && s && /* @__PURE__ */ I("li", {
|
|
270
276
|
id: `${l}-select-all`,
|
|
271
277
|
role: "option",
|
|
272
278
|
"aria-selected": W,
|
|
273
|
-
"data-active":
|
|
279
|
+
"data-active": o === -1 ? "" : void 0,
|
|
274
280
|
tabIndex: -1,
|
|
275
281
|
onMouseDown: (e) => e.preventDefault(),
|
|
276
282
|
onClick: H,
|
|
277
283
|
onMouseMove: () => x(null),
|
|
278
284
|
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",
|
|
279
285
|
children: [
|
|
280
|
-
|
|
286
|
+
o === -1 && /* @__PURE__ */ r("span", {
|
|
281
287
|
"aria-hidden": "true",
|
|
282
288
|
className: "border-l-solid pointer-events-none absolute inset-y-0 left-0 border-l-[3px] border-focus-ring"
|
|
283
289
|
}),
|
|
284
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ r(de, {
|
|
285
291
|
dataTest: `${l}-select-all`,
|
|
286
292
|
checked: W,
|
|
287
|
-
indeterminate:
|
|
293
|
+
indeterminate: rt,
|
|
288
294
|
size: "medium",
|
|
289
295
|
checkboxClassName: "!h-4 !w-4",
|
|
290
296
|
hideWrapper: !0,
|
|
291
297
|
decorative: !0
|
|
292
298
|
}),
|
|
293
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ r("span", {
|
|
294
300
|
className: "flex-1 truncate",
|
|
295
|
-
children:
|
|
301
|
+
children: Ae
|
|
296
302
|
})
|
|
297
303
|
]
|
|
298
|
-
}), q ? /* @__PURE__ */
|
|
304
|
+
}), q ? /* @__PURE__ */ r("li", {
|
|
299
305
|
role: "presentation",
|
|
300
306
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
301
307
|
children: be
|
|
302
|
-
}) : u.length === 0 ? /* @__PURE__ */
|
|
308
|
+
}) : u.length === 0 ? /* @__PURE__ */ r("li", {
|
|
303
309
|
role: "presentation",
|
|
304
310
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
305
311
|
children: ge
|
|
@@ -309,5 +315,5 @@ function Ut({ dataTest: l, options: b, renderInput: me, value: N, onChange: A, g
|
|
|
309
315
|
});
|
|
310
316
|
}
|
|
311
317
|
export {
|
|
312
|
-
|
|
318
|
+
Vt as StyledSelectAutocomplete
|
|
313
319
|
};
|