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