asma-ui-core 3.74.0 → 3.74.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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +22 -22
- package/dist/components/inputs/select/StyledSelect.js +24 -24
- package/dist/components/inputs/select/StyledSelectItem.js +3 -3
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +43 -43
- package/package.json +1 -1
|
@@ -8,18 +8,18 @@ import { StyledTooltip as L } from "../../../data-display/tooltip/StyledTooltip.
|
|
|
8
8
|
import { StyledInputField as le } from "../../input-field/StyledInputField.js";
|
|
9
9
|
import { StyledSelectAutocomplete as ae } from "../../select-autocomplete/StyledSelectAutocomplete.js";
|
|
10
10
|
import { DynamicInteractiveChipGroup as re } from "./DynamicInteractiveChipGroup.js";
|
|
11
|
-
import { createElement as q, forwardRef as oe, useCallback as
|
|
11
|
+
import { createElement as q, forwardRef as oe, useCallback as f, useState as ne } from "react";
|
|
12
12
|
import { Fragment as E, jsx as l, jsxs as O } from "react/jsx-runtime";
|
|
13
|
-
var ye = oe((
|
|
14
|
-
const [z,
|
|
13
|
+
var ye = oe((k, F) => {
|
|
14
|
+
const [z, S] = ne(!1), { options: h, dataTest: g, value: x, readOnly: u, multiple: o, required: H, onChange: y, size: K, title: v, noOptionsText: _, placeholder: R, disabled: I, helperText: G, disableHelperText: A, error: N, valueKey: P = "value", labelKey: W = "label", renderLabel: i, getOptionTooltip: V, startAdornment: J, autocompleteProps: n, loading: m, maxTags: M, onFocus: Q, onBlur: U } = k, w = h.length < 11, s = (e) => typeof e == "object" ? e?.[W]?.toString() ?? "" : e?.toString() ?? "", p = f((e) => typeof e == "object" ? e?.[P] : e, [P]), D = f((e, t) => p(e) === p(t), [p]), C = (e) => {
|
|
15
15
|
const t = p(e);
|
|
16
16
|
return t == null ? "" : typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? String(t) : e == null ? "" : s(e);
|
|
17
|
-
}, $ =
|
|
18
|
-
|
|
19
|
-
}, [n]), X =
|
|
20
|
-
|
|
17
|
+
}, $ = f((e) => {
|
|
18
|
+
S(!0), n?.onOpen?.(e);
|
|
19
|
+
}, [n]), X = f((e, t) => {
|
|
20
|
+
S(!1), n?.onClose?.(e, t);
|
|
21
21
|
}, [n]);
|
|
22
|
-
if (o && u) return /* @__PURE__ */ l(re, { ...
|
|
22
|
+
if (o && u) return /* @__PURE__ */ l(re, { ...k });
|
|
23
23
|
const T = v ? `${g}-title` : void 0;
|
|
24
24
|
return /* @__PURE__ */ O("div", {
|
|
25
25
|
className: "flex w-full flex-col gap-y-1",
|
|
@@ -40,7 +40,7 @@ var ye = oe((S, F) => {
|
|
|
40
40
|
value: x,
|
|
41
41
|
size: K,
|
|
42
42
|
disableClearable: H,
|
|
43
|
-
options:
|
|
43
|
+
options: h,
|
|
44
44
|
fullWidth: !0,
|
|
45
45
|
classes: { listbox: "max-h-[300px]" },
|
|
46
46
|
getOptionLabel: n?.getOptionLabel ?? s,
|
|
@@ -53,9 +53,9 @@ var ye = oe((S, F) => {
|
|
|
53
53
|
multiple: o,
|
|
54
54
|
renderValue: o ? (e) => {
|
|
55
55
|
if (!Array.isArray(e)) return null;
|
|
56
|
-
const t = e, d = M ??
|
|
56
|
+
const t = e, d = M ?? h.length, a = t.slice(0, d), c = t.length - d;
|
|
57
57
|
return [...a.map((r) => /* @__PURE__ */ l(B, {
|
|
58
|
-
dataTest: `${
|
|
58
|
+
dataTest: `${C(r)}-chip`,
|
|
59
59
|
readOnly: u,
|
|
60
60
|
variant: "outlined",
|
|
61
61
|
label: i ? i(r) : s(r),
|
|
@@ -65,9 +65,9 @@ var ye = oe((S, F) => {
|
|
|
65
65
|
},
|
|
66
66
|
disabled: !!I || !!m,
|
|
67
67
|
onDelete: () => {
|
|
68
|
-
Array.isArray(x) && y(x.filter((
|
|
68
|
+
Array.isArray(x) && y(x.filter((b) => !D(b, r)));
|
|
69
69
|
}
|
|
70
|
-
},
|
|
70
|
+
}, C(r))), c > 0 ? /* @__PURE__ */ l(B, {
|
|
71
71
|
dataTest: "remaining-count-tag-chip",
|
|
72
72
|
label: `+${c}`,
|
|
73
73
|
variant: "outlined",
|
|
@@ -84,11 +84,11 @@ var ye = oe((S, F) => {
|
|
|
84
84
|
renderOption: (e, t, d) => {
|
|
85
85
|
const a = typeof t == "object" ? !!t?.disabled : !1, c = V ? V(t) : null;
|
|
86
86
|
if (o) {
|
|
87
|
-
const
|
|
87
|
+
const b = d.selected;
|
|
88
88
|
return /* @__PURE__ */ q("li", {
|
|
89
89
|
...e,
|
|
90
90
|
role: "option",
|
|
91
|
-
"aria-selected":
|
|
91
|
+
"aria-selected": b,
|
|
92
92
|
key: e.id,
|
|
93
93
|
onClick: a ? void 0 : e.onClick,
|
|
94
94
|
className: j("flex min-h-10 cursor-pointer items-center gap-x-1 bg-white px-2 text-base aria-selected:bg-gama-50 hover:bg-gama-50", a && "cursor-not-allowed bg-delta-50 aria-selected:!bg-delta-50 hover:!bg-delta-50 [&_*]:cursor-not-allowed"),
|
|
@@ -98,13 +98,13 @@ var ye = oe((S, F) => {
|
|
|
98
98
|
title: c,
|
|
99
99
|
children: /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ l(te, {
|
|
100
100
|
disabled: a,
|
|
101
|
-
dataTest: `${
|
|
101
|
+
dataTest: `${C(t)}-checkbox`,
|
|
102
102
|
size: "small",
|
|
103
103
|
decorative: !0,
|
|
104
104
|
className: "min-w-[36px]",
|
|
105
|
-
checked:
|
|
105
|
+
checked: b
|
|
106
106
|
}), i ? i(t) : /* @__PURE__ */ l("span", {
|
|
107
|
-
className: "h-fit text-base text-delta-800",
|
|
107
|
+
className: "line-clamp-2 h-fit min-w-0 flex-1 break-words text-base text-delta-800",
|
|
108
108
|
children: s(t)
|
|
109
109
|
})] })
|
|
110
110
|
}));
|
|
@@ -129,7 +129,7 @@ var ye = oe((S, F) => {
|
|
|
129
129
|
width: 20
|
|
130
130
|
})
|
|
131
131
|
}), i ? i(t) : /* @__PURE__ */ l("span", {
|
|
132
|
-
className: "text-base text-delta-800",
|
|
132
|
+
className: "line-clamp-2 min-w-0 flex-1 break-words text-base text-delta-800",
|
|
133
133
|
children: s(t)
|
|
134
134
|
})] })
|
|
135
135
|
}));
|
|
@@ -147,19 +147,19 @@ var ye = oe((S, F) => {
|
|
|
147
147
|
readOnly: u,
|
|
148
148
|
onFocus: Q,
|
|
149
149
|
onBlur: U,
|
|
150
|
-
onKeyDown:
|
|
150
|
+
onKeyDown: w ? (t) => t.preventDefault() : void 0,
|
|
151
151
|
autoComplete: "off",
|
|
152
152
|
slotProps: {
|
|
153
153
|
...e.slotProps,
|
|
154
154
|
input: {
|
|
155
155
|
...e.slotProps?.input ?? {},
|
|
156
156
|
startAdornment: J ?? e.slotProps?.input?.startAdornment,
|
|
157
|
-
style:
|
|
157
|
+
style: w ? { caretColor: "transparent" } : {}
|
|
158
158
|
},
|
|
159
159
|
htmlInput: {
|
|
160
160
|
...e.slotProps?.htmlInput ?? {},
|
|
161
161
|
...T ? { "aria-labelledby": T } : {},
|
|
162
|
-
style:
|
|
162
|
+
style: w ? { caretColor: "transparent" } : {}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}),
|
|
@@ -11,12 +11,12 @@ import { useFormControlContext as je } from "../../miscellaneous/FormControlCont
|
|
|
11
11
|
import { Children as N, cloneElement as Ke, isValidElement as P, useEffect as _, useId as Me, useMemo as Ye, useRef as $, useState as q } from "react";
|
|
12
12
|
import { jsx as n, jsxs as B } from "react/jsx-runtime";
|
|
13
13
|
import { FloatingPortal as ze, autoUpdate as Oe, flip as We, offset as $e, shift as Ge, size as Je, useClick as Qe, useDismiss as Xe, useFloating as Ze, useInteractions as et, useMergeRefs as G, useRole as tt } from "@floating-ui/react";
|
|
14
|
-
var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, errorText: X, helperText: T, reserveHelperText: Z, expandHelperText: ee = !0, allowClear: U, disabled: te, readOnly: i, name: m, placeholder: w, displayEmpty: A, multiple:
|
|
15
|
-
const c = je(), j = `${H}-listbox`,
|
|
16
|
-
if (
|
|
14
|
+
var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, errorText: X, helperText: T, reserveHelperText: Z, expandHelperText: ee = !0, allowClear: U, disabled: te, readOnly: i, name: m, placeholder: w, displayEmpty: A, multiple: d, renderValue: V, fullWidth: re, className: oe, style: se, sx: ne, variant: le, children: v, MenuProps: ae, onFocus: ie, onBlur: ce, labelId: g }) => {
|
|
15
|
+
const c = je(), j = `${H}-listbox`, b = le === "standard", u = Q ?? c?.error ?? !1, s = te ?? c?.disabled ?? !1, K = u ? X ?? T : T, { show: R, role: de } = Ue("StyledSelect", u, K, Z, i), M = Me(), { fieldRef: ue, rowRef: fe, rowStyle: pe } = Te(ee && R), [o, y] = q(!1), [h, S] = q(!1), [me, Y] = q(J), k = I !== void 0, r = k ? I : me, l = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, a = $(null), z = $(null), ge = (e) => {
|
|
16
|
+
if (y(e), e) return;
|
|
17
17
|
const t = document.activeElement;
|
|
18
18
|
t && t !== document.body && !a.current?.contains(t) || z.current?.focus();
|
|
19
|
-
}, { refs: f, floatingStyles:
|
|
19
|
+
}, { refs: f, floatingStyles: be, context: D } = Ze({
|
|
20
20
|
open: o,
|
|
21
21
|
onOpenChange: ge,
|
|
22
22
|
placement: "bottom-start",
|
|
@@ -30,7 +30,7 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
30
30
|
t.floating.style.minWidth = `${e.reference.width + 20}px`;
|
|
31
31
|
} })
|
|
32
32
|
]
|
|
33
|
-
}), { getReferenceProps:
|
|
33
|
+
}), { getReferenceProps: ye, getFloatingProps: he } = et([
|
|
34
34
|
Qe(D, { enabled: !s && !i }),
|
|
35
35
|
Xe(D),
|
|
36
36
|
tt(D, { role: "listbox" })
|
|
@@ -53,25 +53,25 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
53
53
|
return () => cancelAnimationFrame(e);
|
|
54
54
|
}, [o]);
|
|
55
55
|
const Ae = (e, t) => {
|
|
56
|
-
const x =
|
|
56
|
+
const x = d ? Array.isArray(r) && r.includes(e) ? r.filter((E) => E !== e) : [...Array.isArray(r) ? r : [], e] : e;
|
|
57
57
|
k || Y(x), L?.({ target: {
|
|
58
58
|
value: x,
|
|
59
59
|
name: m
|
|
60
|
-
} }, t),
|
|
60
|
+
} }, t), d || (y(!1), requestAnimationFrame(() => f.domReference.current?.focus()));
|
|
61
61
|
}, W = () => {
|
|
62
|
-
const e =
|
|
62
|
+
const e = d ? [] : "";
|
|
63
63
|
k || Y(e), L?.({ target: {
|
|
64
64
|
value: e,
|
|
65
65
|
name: m
|
|
66
|
-
} }, null),
|
|
66
|
+
} }, null), y(!1), S(!1);
|
|
67
67
|
}, ve = N.map(v, (e) => {
|
|
68
68
|
if (!P(e)) return e;
|
|
69
69
|
const t = e.props.value;
|
|
70
70
|
return Ke(e, {
|
|
71
|
-
selected:
|
|
71
|
+
selected: d ? Array.isArray(r) && r.includes(t) : t === r,
|
|
72
72
|
onClick: () => Ae(t, e.props.children)
|
|
73
73
|
});
|
|
74
|
-
}), Re = N.toArray(v).find((e) => P(e) && e.props.value === r), Se = V ? V(r) :
|
|
74
|
+
}), Re = N.toArray(v).find((e) => P(e) && e.props.value === r), Se = V ? V(r) : d && Array.isArray(r) ? N.toArray(v).filter((e) => P(e) && r.includes(e.props.value)).map((e) => {
|
|
75
75
|
const t = e.props.children;
|
|
76
76
|
return typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
77
77
|
}).join(", ") : Re?.props.children, ke = (e) => {
|
|
@@ -79,7 +79,7 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
79
79
|
e.preventDefault(), W();
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || i || (e.preventDefault(),
|
|
82
|
+
e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || i || (e.preventDefault(), y(!0), requestAnimationFrame(() => {
|
|
83
83
|
if (a.current?.querySelector('[role="option"][aria-selected="true"]')) return;
|
|
84
84
|
const t = a.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
|
|
85
85
|
t?.length && t[e.key === "ArrowUp" ? t.length - 1 : 0]?.focus();
|
|
@@ -89,9 +89,9 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
89
89
|
if (t.length === 0) return;
|
|
90
90
|
const x = t.findIndex((E) => E === document.activeElement);
|
|
91
91
|
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(x + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), document.activeElement?.click());
|
|
92
|
-
}, C =
|
|
92
|
+
}, C = b && (o || h), Fe = s ? "text-delta-300" : C ? "text-gama-500" : "text-delta-800", Ce = s ? "text-delta-300" : "text-delta-700";
|
|
93
93
|
return /* @__PURE__ */ B("div", {
|
|
94
|
-
ref:
|
|
94
|
+
ref: ue,
|
|
95
95
|
className: p("group relative inline-flex flex-col", re && "w-full", oe),
|
|
96
96
|
style: {
|
|
97
97
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
@@ -103,14 +103,14 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
103
103
|
ref: xe,
|
|
104
104
|
type: "button",
|
|
105
105
|
"data-testid": H,
|
|
106
|
-
...
|
|
106
|
+
...ye({ onKeyDown: ke }),
|
|
107
107
|
role: "combobox",
|
|
108
108
|
"aria-haspopup": "listbox",
|
|
109
109
|
"aria-expanded": o,
|
|
110
110
|
"aria-controls": j,
|
|
111
111
|
"aria-labelledby": g,
|
|
112
112
|
"aria-label": g ? void 0 : m,
|
|
113
|
-
"aria-invalid":
|
|
113
|
+
"aria-invalid": u ? !0 : void 0,
|
|
114
114
|
"aria-describedby": R ? M : void 0,
|
|
115
115
|
"aria-disabled": s ? !0 : void 0,
|
|
116
116
|
disabled: s,
|
|
@@ -120,8 +120,8 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
120
120
|
onBlur: (e) => {
|
|
121
121
|
S(!1), ce?.(e);
|
|
122
122
|
},
|
|
123
|
-
style: { minWidth: l && !
|
|
124
|
-
className: p("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", C ? "bg-gama-50" : "bg-transparent", Fe,
|
|
123
|
+
style: { minWidth: l && !b ? 105 : void 0 },
|
|
124
|
+
className: p("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", C ? "bg-gama-50" : "bg-transparent", Fe, b && "min-w-0", s && "cursor-not-allowed", i && "pointer-events-none"),
|
|
125
125
|
children: [
|
|
126
126
|
/* @__PURE__ */ n("span", {
|
|
127
127
|
className: p("min-w-0 flex-1 truncate", !l && "text-delta-500"),
|
|
@@ -148,10 +148,10 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
148
148
|
}),
|
|
149
149
|
/* @__PURE__ */ n("div", { className: Ve({
|
|
150
150
|
focused: o || h,
|
|
151
|
-
error:
|
|
151
|
+
error: u,
|
|
152
152
|
disabled: s,
|
|
153
153
|
readOnly: i,
|
|
154
|
-
borderless:
|
|
154
|
+
borderless: b
|
|
155
155
|
}) })
|
|
156
156
|
]
|
|
157
157
|
}),
|
|
@@ -166,20 +166,20 @@ var gt = ({ dataTest: H, value: I, defaultValue: J, onChange: L, error: Q, error
|
|
|
166
166
|
...F ? _e : {},
|
|
167
167
|
style: {
|
|
168
168
|
...F ? qe : {},
|
|
169
|
-
...
|
|
169
|
+
...be,
|
|
170
170
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif"
|
|
171
171
|
},
|
|
172
172
|
...he(),
|
|
173
173
|
onKeyDown: De,
|
|
174
|
-
className: p("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-
|
|
174
|
+
className: p("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", "[&>li:not(:last-child)]:border-0 [&>li:not(:last-child)]:border-b", "[&>li:not(:last-child)]:border-solid [&>li:not(:last-child)]:border-delta-200", ae?.className),
|
|
175
175
|
children: ve
|
|
176
176
|
})
|
|
177
177
|
}),
|
|
178
178
|
R && /* @__PURE__ */ n(Le, {
|
|
179
179
|
ref: fe,
|
|
180
180
|
id: M,
|
|
181
|
-
role:
|
|
182
|
-
error:
|
|
181
|
+
role: de,
|
|
182
|
+
error: u,
|
|
183
183
|
message: K,
|
|
184
184
|
className: "m-0 mr-[14px] box-border items-center",
|
|
185
185
|
style: pe
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn as l } from "../../../helpers/cn.js";
|
|
2
2
|
import { CheckIcon as n } from "../../icons/check-icon/CheckIcon.js";
|
|
3
3
|
import { jsx as a, jsxs as s } from "react/jsx-runtime";
|
|
4
|
-
var
|
|
4
|
+
var x = ({ children: r, selected: e, disabled: t, className: o, onClick: i }) => /* @__PURE__ */ s("li", {
|
|
5
5
|
role: "option",
|
|
6
6
|
"aria-selected": e ? !0 : void 0,
|
|
7
7
|
"aria-disabled": t ? !0 : void 0,
|
|
@@ -16,10 +16,10 @@ var p = ({ children: r, selected: e, disabled: t, className: o, onClick: i }) =>
|
|
|
16
16
|
className: "text-gama-500"
|
|
17
17
|
})
|
|
18
18
|
}), /* @__PURE__ */ a("span", {
|
|
19
|
-
className: "min-w-0 flex-1
|
|
19
|
+
className: "line-clamp-2 min-w-0 flex-1 break-words",
|
|
20
20
|
children: r
|
|
21
21
|
})]
|
|
22
22
|
});
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
x as StyledSelectItem
|
|
25
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as k } from "../../../helpers/cn.js";
|
|
2
2
|
import { ChevronDownIcon as Oe } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
3
3
|
import { CloseIcon as Be } from "../../icons/close-icon/CloseIcon.js";
|
|
4
4
|
import { CheckIcon as qe } from "../../icons/check-icon/CheckIcon.js";
|
|
@@ -8,17 +8,17 @@ import { StyledCheckbox as Q } from "../checkbox/base-ui/StyledCheckbox.js";
|
|
|
8
8
|
import { TOP_LAYER_PROPS as Qe, TOP_LAYER_RESET_STYLE as Xe, getOpenModalDialogAncestor as Ze, shouldUsePopoverTopLayer as Ke, useTopLayerRef as et } from "../../../hooks/useTopLayer.hook.js";
|
|
9
9
|
import { LoadingIcon as tt } from "../../../table/shared-components/LoadingIcon.js";
|
|
10
10
|
import _ from "./StyledSelectAutocomplete.module.js";
|
|
11
|
-
import { useEffect as
|
|
11
|
+
import { useEffect as lt, useMemo as E, useRef as X, useState as w } from "react";
|
|
12
12
|
import { jsx as s, jsxs as y } from "react/jsx-runtime";
|
|
13
|
-
import { FloatingPortal as
|
|
14
|
-
var mt = (
|
|
15
|
-
function Pt({ dataTest:
|
|
13
|
+
import { FloatingPortal as rt, autoUpdate as st, flip as ot, offset as at, shift as nt, size as ct, useDismiss as it, useFloating as dt, useInteractions as ut, useMergeRefs as Z, useRole as pt } from "@floating-ui/react";
|
|
14
|
+
var mt = (r) => typeof r == "object" && r !== null && "label" in r ? String(r.label) : String(r), K = (r) => typeof r == "object" && r !== null && "disabled" in r && !!r.disabled;
|
|
15
|
+
function Pt({ dataTest: r, options: p, renderInput: ee, value: v, onChange: N, getOptionLabel: te, getOptionKey: R, isOptionEqualToValue: j, renderOption: z, renderValue: F, filterOptions: L, loading: W, loadingText: le = "Loading…", noOptionsText: re = "No options", disabled: D, readOnly: m, error: se, helperText: oe, size: ae = "small", disableClearable: ne, disableCloseOnSelect: ce, popupIcon: ie, autoHeight: de, multiple: ue, allowSelectAll: pe, selectAllLabel: U = "Select all", fullWidth: me, classes: fe, inputValue: S, onInputChange: he, open: T, onOpen: ge, onClose: be, className: xe, wrapperClassName: we, getOptionDisabled: ye, slotProps: V }) {
|
|
16
16
|
const o = ue === !0, n = te ?? mt, C = (e, t) => j ? j(e, t) : e === t, [ve, Ne] = w(!1), a = T ?? ve, f = (e) => {
|
|
17
17
|
e && (m || D) || (T === void 0 && Ne(e), e ? ge?.() : be?.());
|
|
18
|
-
}, [Re, H] = w(""), h = S ?? Re, P = (e, t,
|
|
19
|
-
S === void 0 && H(t), he?.(e, t,
|
|
20
|
-
}, [b,
|
|
21
|
-
|
|
18
|
+
}, [Re, H] = w(""), h = S ?? Re, P = (e, t, l) => {
|
|
19
|
+
S === void 0 && H(t), he?.(e, t, l);
|
|
20
|
+
}, [b, $] = w(null), De = X([]), Y = X(null), [Se, Ce] = w(null), [Pe, Ae] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, O = !o && g !== null ? n(g) : "";
|
|
21
|
+
lt(() => {
|
|
22
22
|
S !== void 0 || o || H(O);
|
|
23
23
|
}, [
|
|
24
24
|
S,
|
|
@@ -27,17 +27,17 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
27
27
|
]);
|
|
28
28
|
const B = (e) => o ? c.some((t) => C(e, t)) : g !== null && C(e, g), q = E(() => {
|
|
29
29
|
const e = [...p];
|
|
30
|
-
if (
|
|
30
|
+
if (L) return L(e, { inputValue: h });
|
|
31
31
|
const t = !o && g !== null ? n(g).toLowerCase() : null;
|
|
32
32
|
if (!h || h.toLowerCase() === t) return e;
|
|
33
|
-
const
|
|
34
|
-
return e.filter((d) => n(d).toLowerCase().includes(
|
|
33
|
+
const l = h.toLowerCase();
|
|
34
|
+
return e.filter((d) => n(d).toLowerCase().includes(l));
|
|
35
35
|
}, [
|
|
36
36
|
p,
|
|
37
37
|
h,
|
|
38
|
-
|
|
38
|
+
L,
|
|
39
39
|
v
|
|
40
|
-
]), i = E(() => q.slice(0, 100), [q]), { refs: A, floatingStyles:
|
|
40
|
+
]), i = E(() => q.slice(0, 100), [q]), { refs: A, floatingStyles: ke, context: G } = dt({
|
|
41
41
|
open: a,
|
|
42
42
|
onOpenChange: f,
|
|
43
43
|
placement: "bottom-start",
|
|
@@ -51,10 +51,10 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
51
51
|
Ce(e.reference.width), Ae(de ? t - 8 : Math.min(t - 8, 320));
|
|
52
52
|
} })
|
|
53
53
|
]
|
|
54
|
-
}), { getReferenceProps:
|
|
54
|
+
}), { getReferenceProps: Le, getFloatingProps: $e, getItemProps: Ie } = ut([it(G), pt(G, { role: "listbox" })]), Me = Z([A.setReference]), J = E(() => a ? Ze(A.reference.current) : void 0, [a, A]), I = Ke(J), _e = Z([et(A.setFloating, I)]), M = (e, t) => {
|
|
55
55
|
if (o) {
|
|
56
|
-
const
|
|
57
|
-
N?.(e, d,
|
|
56
|
+
const l = c.some((u) => C(t, u)), d = l ? c.filter((u) => !C(t, u)) : [...c, t];
|
|
57
|
+
N?.(e, d, l ? "removeOption" : "selectOption", { option: t }), P(e, "", "reset"), ce || f(!1);
|
|
58
58
|
} else
|
|
59
59
|
N?.(e, t, "selectOption", { option: t }), P(e, n(t), "reset"), f(!1);
|
|
60
60
|
}, Ee = (e) => {
|
|
@@ -66,12 +66,12 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
66
66
|
K(t) || M(e, t);
|
|
67
67
|
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
68
68
|
if (e.preventDefault(), !a) {
|
|
69
|
-
|
|
69
|
+
$(null), f(!0);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (i.length === 0) return;
|
|
73
73
|
const t = e.key === "ArrowDown" ? 1 : -1;
|
|
74
|
-
|
|
74
|
+
$((l) => l == null ? t > 0 ? 0 : i.length - 1 : (l + t + i.length) % i.length);
|
|
75
75
|
}
|
|
76
76
|
}, ze = !ne && !m && !D && (o ? c.length > 0 : g !== null), Fe = (e) => {
|
|
77
77
|
e.preventDefault(), !(D || m) && (Y.current?.focus(), f(!a));
|
|
@@ -79,7 +79,7 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
79
79
|
dataTest: `selected-chip-${n(e)}`,
|
|
80
80
|
label: n(e),
|
|
81
81
|
readOnly: m,
|
|
82
|
-
onDelete: m ? void 0 : (
|
|
82
|
+
onDelete: m ? void 0 : (l) => M(l, e)
|
|
83
83
|
}, R ? R(e) : `${n(e)}-${t}`)) : void 0, Ue = /* @__PURE__ */ y("span", {
|
|
84
84
|
className: "flex items-center gap-1",
|
|
85
85
|
children: [
|
|
@@ -91,7 +91,7 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
91
91
|
ze && /* @__PURE__ */ s("button", {
|
|
92
92
|
type: "button",
|
|
93
93
|
"aria-label": "Clear",
|
|
94
|
-
"data-testid": `${
|
|
94
|
+
"data-testid": `${r}-clear`,
|
|
95
95
|
className: "flex min-h-6 min-w-6 cursor-pointer items-center justify-center rounded-full border-0 bg-delta-50",
|
|
96
96
|
onMouseDown: (e) => {
|
|
97
97
|
e.preventDefault(), Ee(e);
|
|
@@ -106,7 +106,7 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
106
106
|
type: "button",
|
|
107
107
|
"aria-label": "Toggle options",
|
|
108
108
|
"aria-expanded": a,
|
|
109
|
-
"data-testid": `${
|
|
109
|
+
"data-testid": `${r}-popup-indicator`,
|
|
110
110
|
className: "flex cursor-pointer items-center border-0 bg-transparent",
|
|
111
111
|
onMouseDown: Fe,
|
|
112
112
|
children: ie ?? (o ? /* @__PURE__ */ s(Ge, {
|
|
@@ -116,7 +116,7 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
116
116
|
}) : /* @__PURE__ */ s(Oe, {
|
|
117
117
|
width: 24,
|
|
118
118
|
height: 24,
|
|
119
|
-
className:
|
|
119
|
+
className: k(_["select-custom-icon"], a && _["select-custom-icon-open"], "text-delta-700")
|
|
120
120
|
}))
|
|
121
121
|
})
|
|
122
122
|
]
|
|
@@ -133,13 +133,13 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
133
133
|
onKeyDown: je,
|
|
134
134
|
slotProps: {
|
|
135
135
|
htmlInput: {
|
|
136
|
-
|
|
136
|
+
...Le(),
|
|
137
137
|
ref: Y,
|
|
138
138
|
onClick: () => f(!0),
|
|
139
139
|
role: "combobox",
|
|
140
140
|
"aria-autocomplete": "list",
|
|
141
141
|
"aria-expanded": a,
|
|
142
|
-
"aria-activedescendant": a && b != null ? `${
|
|
142
|
+
"aria-activedescendant": a && b != null ? `${r}-option-${b}` : void 0,
|
|
143
143
|
autoComplete: "off",
|
|
144
144
|
readOnly: m
|
|
145
145
|
},
|
|
@@ -149,45 +149,45 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
149
149
|
endAdornment: Ue
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
}, Ve =
|
|
152
|
+
}, Ve = k("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-800", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300"), He = (e, t, l) => {
|
|
153
153
|
const { key: d, ...u } = e;
|
|
154
154
|
return /* @__PURE__ */ y("li", {
|
|
155
155
|
...u,
|
|
156
156
|
children: [o ? /* @__PURE__ */ s(Q, {
|
|
157
|
-
dataTest: `${
|
|
158
|
-
checked:
|
|
157
|
+
dataTest: `${r}-${n(t)}-checkbox`,
|
|
158
|
+
checked: l.selected,
|
|
159
159
|
size: "small",
|
|
160
160
|
hideWrapper: !0,
|
|
161
161
|
decorative: !0
|
|
162
162
|
}) : /* @__PURE__ */ s("span", {
|
|
163
163
|
className: "w-5",
|
|
164
|
-
children:
|
|
164
|
+
children: l.selected && /* @__PURE__ */ s(qe, {
|
|
165
165
|
width: 20,
|
|
166
166
|
height: 20,
|
|
167
167
|
className: "text-gama-500"
|
|
168
168
|
})
|
|
169
169
|
}), /* @__PURE__ */ s("span", {
|
|
170
|
-
className: "flex-1
|
|
170
|
+
className: "line-clamp-2 min-w-0 flex-1 break-words",
|
|
171
171
|
children: n(t)
|
|
172
172
|
})]
|
|
173
173
|
}, d);
|
|
174
174
|
}, Ye = (e, t) => {
|
|
175
|
-
const
|
|
175
|
+
const l = ye?.(e) ?? K(e), d = {
|
|
176
176
|
...Ie({
|
|
177
177
|
onMouseDown: (x) => x.preventDefault(),
|
|
178
178
|
onClick: (x) => {
|
|
179
|
-
|
|
179
|
+
l || M(x, e);
|
|
180
180
|
},
|
|
181
|
-
onMouseMove: () =>
|
|
181
|
+
onMouseMove: () => $(l ? null : t)
|
|
182
182
|
}),
|
|
183
183
|
key: R ? String(R(e)) : `${n(e)}-${t}`,
|
|
184
184
|
ref: (x) => {
|
|
185
185
|
De.current[t] = x;
|
|
186
186
|
},
|
|
187
187
|
role: "option",
|
|
188
|
-
id: `${
|
|
188
|
+
id: `${r}-option-${t}`,
|
|
189
189
|
"aria-selected": B(e),
|
|
190
|
-
"aria-disabled":
|
|
190
|
+
"aria-disabled": l || void 0,
|
|
191
191
|
"data-active": b === t ? "" : void 0,
|
|
192
192
|
className: Ve
|
|
193
193
|
}, u = {
|
|
@@ -198,27 +198,27 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
198
198
|
return z ? z(d, e, u) : He(d, e, u);
|
|
199
199
|
};
|
|
200
200
|
return /* @__PURE__ */ y("div", {
|
|
201
|
-
className:
|
|
202
|
-
children: [ee(Te), a && /* @__PURE__ */ s(
|
|
201
|
+
className: k(_.styledSelectAutocompleteWrapper, !me && "w-auto", we, xe),
|
|
202
|
+
children: [ee(Te), a && /* @__PURE__ */ s(rt, {
|
|
203
203
|
root: J,
|
|
204
204
|
children: /* @__PURE__ */ y("ul", {
|
|
205
205
|
ref: _e,
|
|
206
206
|
...I ? Qe : {},
|
|
207
207
|
style: {
|
|
208
208
|
...I ? Xe : {},
|
|
209
|
-
...
|
|
209
|
+
...ke,
|
|
210
210
|
width: Se ?? void 0,
|
|
211
211
|
maxHeight: Pe ?? void 0,
|
|
212
212
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
213
213
|
...V?.popper?.style
|
|
214
214
|
},
|
|
215
|
-
|
|
216
|
-
className:
|
|
215
|
+
...$e(),
|
|
216
|
+
className: k("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-2 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", "[&>li:not(:last-child)]:border-0 [&>li:not(:last-child)]:border-b", "[&>li:not(:last-child)]:border-solid [&>li:not(:last-child)]:border-delta-200", fe?.listbox, V?.popper?.className),
|
|
217
217
|
children: [pe && o && /* @__PURE__ */ y("div", {
|
|
218
218
|
role: "group",
|
|
219
219
|
className: "flex min-h-12 items-center gap-x-1 border-0 border-b border-solid border-delta-200 px-4 text-sm text-delta-700",
|
|
220
220
|
children: [/* @__PURE__ */ s(Q, {
|
|
221
|
-
dataTest: `${
|
|
221
|
+
dataTest: `${r}-select-all`,
|
|
222
222
|
"aria-label": U,
|
|
223
223
|
checked: p.length > 0 && c.length === p.length,
|
|
224
224
|
size: "small",
|
|
@@ -235,11 +235,11 @@ function Pt({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, g
|
|
|
235
235
|
}), W ? /* @__PURE__ */ s("li", {
|
|
236
236
|
role: "presentation",
|
|
237
237
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
238
|
-
children:
|
|
238
|
+
children: le
|
|
239
239
|
}) : i.length === 0 ? /* @__PURE__ */ s("li", {
|
|
240
240
|
role: "presentation",
|
|
241
241
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
242
|
-
children:
|
|
242
|
+
children: re
|
|
243
243
|
}) : i.map(Ye)]
|
|
244
244
|
})
|
|
245
245
|
})]
|