wimui 0.69.1 → 0.70.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/_internal/typeahead.cjs +2 -0
- package/dist/components/_internal/typeahead.d.ts +45 -0
- package/dist/components/_internal/typeahead.js +24 -0
- package/dist/components/ai/ModelSelector/ModelSelector.cjs +1 -1
- package/dist/components/ai/ModelSelector/ModelSelector.js +119 -119
- package/dist/components/form/Cascader/Cascader.cjs +1 -1
- package/dist/components/form/Cascader/Cascader.js +168 -151
- package/dist/components/form/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/form/MultiSelect/MultiSelect.js +131 -111
- package/dist/components/form/Select/useSelect.cjs +1 -1
- package/dist/components/form/Select/useSelect.js +83 -75
- package/dist/components/form/Transfer/Transfer.cjs +1 -1
- package/dist/components/form/Transfer/Transfer.js +147 -141
- package/dist/components/navigation/Menubar/Menubar.cjs +1 -1
- package/dist/components/navigation/Menubar/Menubar.js +133 -122
- package/dist/components/overlay/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/overlay/Dropdown/Dropdown.js +131 -122
- package/dist/components/overlay/Menu/Menu.cjs +1 -1
- package/dist/components/overlay/Menu/Menu.js +100 -89
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +2 -2
|
@@ -4,227 +4,244 @@ import { composeEventHandlers as t } from "../../_internal/composeEventHandlers.
|
|
|
4
4
|
import { Transition as n } from "../../layout/Transition/Transition.js";
|
|
5
5
|
import r from "../../../icon/chevron-right.js";
|
|
6
6
|
import { Icon as i } from "../../media/Icon/Icon.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
7
|
+
import { getRovingIndex as a, isRovingKey as o } from "../../_internal/rovingIndex.js";
|
|
8
|
+
import { useInlineFloating as s } from "../../_internal/useInlineFloating.js";
|
|
9
|
+
import { BaseListItem as c } from "../../_internal/BaseListItem/BaseListItem.js";
|
|
10
|
+
import { InputBase as l } from "../InputBase/InputBase.js";
|
|
11
|
+
import u from "./cascader.module.js";
|
|
12
|
+
import { FieldTemplate as ee } from "../FieldTemplate/FieldTemplate.js";
|
|
13
|
+
import { findTypeaheadIndex as te, isTypeaheadKey as ne, useTypeahead as re } from "../../_internal/typeahead.js";
|
|
14
|
+
import ie, { useEffect as d, useId as ae, useRef as f, useState as p } from "react";
|
|
15
|
+
import m from "classnames";
|
|
16
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
17
|
//#region src/components/form/Cascader/Cascader.tsx
|
|
16
|
-
function
|
|
18
|
+
function _(e) {
|
|
17
19
|
return typeof e == "string" ? e : typeof e == "number" ? String(e) : "";
|
|
18
20
|
}
|
|
19
|
-
var
|
|
20
|
-
let
|
|
21
|
-
|
|
21
|
+
var v = ({ options: v = [], value: y, onChange: b, placeholder: x, label: S, error: C, required: w, layout: oe, className: se, disabled: T = !1, defaultValue: ce, id: le, expandTrigger: ue = "click", separator: E = " / ", allowClear: de = !1, "aria-label": D, "aria-labelledby": fe, "aria-describedby": pe, width: me, fullWidth: he = !1, ...O }) => {
|
|
22
|
+
let ge = ae(), k = le || `wim-cascader-${ge}`, A = S ? `${k}-label` : void 0, j = C ? `${k}-error` : void 0, M = A ?? fe, _e = `${k}-trigger`, N = `${k}-popup`, [P, F] = p(!1), [ve, I] = p(ce || []), [L, R] = p([]), [z, B] = p(-1), [V, H] = p([]), [ye, U] = p(!1), W = f(null), G = f(null), K = y !== void 0, q = K ? y : ve;
|
|
23
|
+
d(() => {
|
|
22
24
|
let e = (e) => {
|
|
23
|
-
|
|
25
|
+
W.current && !W.current.contains(e.target) && F(!1);
|
|
24
26
|
};
|
|
25
27
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
26
|
-
}, []),
|
|
27
|
-
if (
|
|
28
|
-
let e =
|
|
28
|
+
}, []), d(() => {
|
|
29
|
+
if (P && z >= 0) {
|
|
30
|
+
let e = V[z], t = `${k}-menu-${z}-option-${e}`, n = W.current?.querySelector(`#${t}`);
|
|
29
31
|
n && n.scrollIntoView({
|
|
30
32
|
block: "nearest",
|
|
31
33
|
behavior: "smooth"
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
}, [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
z,
|
|
38
|
+
V,
|
|
39
|
+
P,
|
|
40
|
+
k
|
|
39
41
|
]);
|
|
40
|
-
let
|
|
41
|
-
if (!
|
|
42
|
-
let e = !
|
|
43
|
-
|
|
42
|
+
let J = () => {
|
|
43
|
+
if (!T) {
|
|
44
|
+
let e = !P;
|
|
45
|
+
F(e), e ? (R(q || []), B(0), H([a({
|
|
46
|
+
key: "Home",
|
|
47
|
+
current: -1,
|
|
48
|
+
count: v.length,
|
|
49
|
+
isDisabled: (e) => !!v[e]?.disabled
|
|
50
|
+
}) ?? 0])) : B(-1);
|
|
44
51
|
}
|
|
45
|
-
},
|
|
46
|
-
if (!
|
|
47
|
-
let e = [], t =
|
|
48
|
-
for (let n of
|
|
52
|
+
}, be = () => {
|
|
53
|
+
if (!q || q.length === 0) return null;
|
|
54
|
+
let e = [], t = v;
|
|
55
|
+
for (let n of q) {
|
|
49
56
|
let r = t.find((e) => e.value === n);
|
|
50
57
|
if (r) e.push(r.label), t = r.children || [];
|
|
51
58
|
else break;
|
|
52
59
|
}
|
|
53
|
-
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */
|
|
54
|
-
},
|
|
60
|
+
return e.length === 0 ? null : e.map((t, n) => /* @__PURE__ */ g(ie.Fragment, { children: [t, n < e.length - 1 && /* @__PURE__ */ h("span", { children: E })] }, n));
|
|
61
|
+
}, Y = (e, t) => {
|
|
55
62
|
if (e.disabled) return;
|
|
56
|
-
let n = [...
|
|
57
|
-
if (
|
|
58
|
-
if (
|
|
59
|
-
let e = [], t =
|
|
63
|
+
let n = [...L.slice(0, t), e.value];
|
|
64
|
+
if (R(n), !e.children || e.children.length === 0) {
|
|
65
|
+
if (K || I(n), b) {
|
|
66
|
+
let e = [], t = v;
|
|
60
67
|
for (let r of n) {
|
|
61
68
|
let n = t.find((e) => e.value === r);
|
|
62
69
|
n && (e.push(n), t = n.children || []);
|
|
63
70
|
}
|
|
64
|
-
|
|
71
|
+
b(n, e);
|
|
65
72
|
}
|
|
66
|
-
|
|
73
|
+
F(!1), G.current?.focus();
|
|
67
74
|
}
|
|
68
|
-
},
|
|
69
|
-
e?.stopPropagation(), !
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
if (
|
|
74
|
-
if (!
|
|
75
|
-
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(),
|
|
75
|
+
}, xe = (e) => {
|
|
76
|
+
e?.stopPropagation(), !T && (K || I([]), b && b([], []));
|
|
77
|
+
}, Se = (e, t) => {
|
|
78
|
+
ue === "hover" && !e.disabled && R([...L.slice(0, t), e.value]);
|
|
79
|
+
}, X = re(), Ce = (e) => {
|
|
80
|
+
if (U(!0), T) return;
|
|
81
|
+
if (!P) {
|
|
82
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown" || e.key === "ArrowDown" && e.altKey) && (e.preventDefault(), J());
|
|
76
83
|
return;
|
|
77
84
|
}
|
|
78
|
-
let t = [
|
|
79
|
-
for (let e = 0; e <
|
|
80
|
-
let r =
|
|
85
|
+
let t = [v], n = v;
|
|
86
|
+
for (let e = 0; e < L.length; e++) {
|
|
87
|
+
let r = L[e], i = n.find((e) => e.value === r);
|
|
81
88
|
if (i && i.children && i.children.length > 0) t.push(i.children), n = i.children;
|
|
82
89
|
else break;
|
|
83
90
|
}
|
|
84
|
-
let r = t[
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
let r = t[z] || [], i = V[z] || 0, s = (e) => (t) => !!e[t]?.disabled, c = (e) => H((t) => {
|
|
92
|
+
let n = [...t];
|
|
93
|
+
return n[z] = e, n;
|
|
94
|
+
});
|
|
95
|
+
if (ne(e, X.typing())) {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
let t = te({
|
|
98
|
+
query: X.push(e.key),
|
|
99
|
+
current: i,
|
|
100
|
+
count: r.length,
|
|
101
|
+
getText: (e) => {
|
|
102
|
+
let t = r[e]?.label;
|
|
103
|
+
return typeof t == "string" ? t : String(r[e]?.value ?? "");
|
|
104
|
+
},
|
|
105
|
+
isDisabled: s(r)
|
|
106
|
+
});
|
|
107
|
+
t >= 0 && c(t);
|
|
108
|
+
} else if (o(e.key, "vertical")) {
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
let t = a({
|
|
111
|
+
key: e.key,
|
|
112
|
+
current: i,
|
|
113
|
+
count: r.length,
|
|
114
|
+
orientation: "vertical",
|
|
115
|
+
isDisabled: s(r)
|
|
116
|
+
});
|
|
117
|
+
t !== null && c(t);
|
|
118
|
+
} else switch (e.key) {
|
|
98
119
|
case "ArrowRight": {
|
|
99
120
|
e.preventDefault();
|
|
100
121
|
let t = r[i];
|
|
101
|
-
t && t.
|
|
122
|
+
if (t && !t.disabled && t.children && t.children.length > 0) {
|
|
123
|
+
let e = t.children, n = a({
|
|
124
|
+
key: "Home",
|
|
125
|
+
current: -1,
|
|
126
|
+
count: e.length,
|
|
127
|
+
isDisabled: s(e)
|
|
128
|
+
}) ?? 0;
|
|
129
|
+
R([...L.slice(0, z), t.value]), B(z + 1), H((e) => [...e.slice(0, z + 1), n]);
|
|
130
|
+
}
|
|
102
131
|
break;
|
|
103
132
|
}
|
|
104
133
|
case "ArrowLeft":
|
|
105
|
-
e.preventDefault(),
|
|
134
|
+
e.preventDefault(), z > 0 && (B(z - 1), H((e) => e.slice(0, z)));
|
|
106
135
|
break;
|
|
107
136
|
case "Enter":
|
|
108
137
|
case " ": {
|
|
109
138
|
e.preventDefault();
|
|
110
139
|
let t = r[i];
|
|
111
|
-
t &&
|
|
140
|
+
t && !t.disabled && Y(t, z);
|
|
112
141
|
break;
|
|
113
142
|
}
|
|
114
143
|
case "Escape":
|
|
115
|
-
e.preventDefault(),
|
|
116
|
-
break;
|
|
117
|
-
case "Home":
|
|
118
|
-
e.preventDefault(), V((e) => {
|
|
119
|
-
let t = [...e];
|
|
120
|
-
return t[R] = 0, t;
|
|
121
|
-
});
|
|
122
|
-
break;
|
|
123
|
-
case "End":
|
|
124
|
-
e.preventDefault(), V((e) => {
|
|
125
|
-
let t = [...e];
|
|
126
|
-
return t[R] = r.length - 1, t;
|
|
127
|
-
});
|
|
144
|
+
e.preventDefault(), F(!1), B(-1), G.current?.focus();
|
|
128
145
|
break;
|
|
129
|
-
case "Tab":
|
|
146
|
+
case "Tab": P && (F(!1), B(-1));
|
|
130
147
|
}
|
|
131
|
-
},
|
|
132
|
-
for (let e = 0; e <
|
|
133
|
-
let t =
|
|
134
|
-
if (n && n.children && n.children.length > 0)
|
|
148
|
+
}, Z = [v], we = v;
|
|
149
|
+
for (let e = 0; e < L.length; e++) {
|
|
150
|
+
let t = L[e], n = we.find((e) => e.value === t);
|
|
151
|
+
if (n && n.children && n.children.length > 0) Z.push(n.children), we = n.children;
|
|
135
152
|
else break;
|
|
136
153
|
}
|
|
137
|
-
let Q =
|
|
138
|
-
if (!
|
|
139
|
-
let e = [], t =
|
|
140
|
-
for (let n of
|
|
154
|
+
let Q = be(), $ = () => {
|
|
155
|
+
if (!q || q.length === 0) return "";
|
|
156
|
+
let e = [], t = v;
|
|
157
|
+
for (let n of q) {
|
|
141
158
|
let r = t.find((e) => e.value === n);
|
|
142
|
-
if (r) e.push(
|
|
159
|
+
if (r) e.push(_(r.label)), t = r.children || [];
|
|
143
160
|
else break;
|
|
144
161
|
}
|
|
145
|
-
return e.join(
|
|
146
|
-
}, { setReference:
|
|
147
|
-
return /* @__PURE__ */
|
|
148
|
-
label:
|
|
149
|
-
error:
|
|
150
|
-
required:
|
|
151
|
-
layout:
|
|
152
|
-
labelId:
|
|
153
|
-
errorId:
|
|
154
|
-
className:
|
|
155
|
-
children: /* @__PURE__ */
|
|
156
|
-
className:
|
|
157
|
-
ref:
|
|
158
|
-
"data-keyboard-nav":
|
|
159
|
-
...
|
|
160
|
-
onMouseMove: t(
|
|
161
|
-
children: [/* @__PURE__ */
|
|
162
|
-
disabled:
|
|
163
|
-
allowClear:
|
|
162
|
+
return e.join(E);
|
|
163
|
+
}, { setReference: Te, setFloating: Ee, floatingProps: De } = s({ open: P && !T }), Oe = e(W, Te);
|
|
164
|
+
return /* @__PURE__ */ h(ee, {
|
|
165
|
+
label: S,
|
|
166
|
+
error: C,
|
|
167
|
+
required: w,
|
|
168
|
+
layout: oe,
|
|
169
|
+
labelId: A,
|
|
170
|
+
errorId: j,
|
|
171
|
+
className: m("wim-cascader", se),
|
|
172
|
+
children: /* @__PURE__ */ g("div", {
|
|
173
|
+
className: u.root,
|
|
174
|
+
ref: Oe,
|
|
175
|
+
"data-keyboard-nav": ye,
|
|
176
|
+
...O,
|
|
177
|
+
onMouseMove: t(O.onMouseMove, () => U(!1)),
|
|
178
|
+
children: [/* @__PURE__ */ h(l, {
|
|
179
|
+
disabled: T,
|
|
180
|
+
allowClear: de,
|
|
164
181
|
hasValue: !!Q,
|
|
165
|
-
onClear:
|
|
166
|
-
intent:
|
|
167
|
-
width:
|
|
168
|
-
fullWidth:
|
|
182
|
+
onClear: xe,
|
|
183
|
+
intent: C ? "danger" : "default",
|
|
184
|
+
width: me,
|
|
185
|
+
fullWidth: he,
|
|
169
186
|
rightIcons: [{
|
|
170
187
|
name: "ChevronDownIcon",
|
|
171
|
-
rotated:
|
|
188
|
+
rotated: P
|
|
172
189
|
}],
|
|
173
|
-
className:
|
|
174
|
-
children: /* @__PURE__ */
|
|
175
|
-
id:
|
|
176
|
-
ref:
|
|
177
|
-
className:
|
|
178
|
-
onClick:
|
|
179
|
-
onKeyDown:
|
|
180
|
-
tabIndex:
|
|
190
|
+
className: m(P && u.open),
|
|
191
|
+
children: /* @__PURE__ */ h("div", {
|
|
192
|
+
id: _e,
|
|
193
|
+
ref: G,
|
|
194
|
+
className: m(u.trigger, T && u.disabled),
|
|
195
|
+
onClick: J,
|
|
196
|
+
onKeyDown: Ce,
|
|
197
|
+
tabIndex: T ? -1 : 0,
|
|
181
198
|
role: "combobox",
|
|
182
|
-
"aria-expanded":
|
|
183
|
-
"aria-controls":
|
|
199
|
+
"aria-expanded": P,
|
|
200
|
+
"aria-controls": P ? N : void 0,
|
|
184
201
|
"aria-haspopup": "listbox",
|
|
185
|
-
"aria-disabled":
|
|
186
|
-
"aria-labelledby":
|
|
187
|
-
"aria-label":
|
|
188
|
-
"aria-describedby": [
|
|
189
|
-
"aria-required":
|
|
190
|
-
"aria-invalid": !!
|
|
191
|
-
"aria-activedescendant":
|
|
192
|
-
children: /* @__PURE__ */
|
|
193
|
-
className:
|
|
194
|
-
children: Q ||
|
|
202
|
+
"aria-disabled": T,
|
|
203
|
+
"aria-labelledby": M,
|
|
204
|
+
"aria-label": M ? void 0 : D || $() || _(x),
|
|
205
|
+
"aria-describedby": [pe, j].filter(Boolean).join(" ") || void 0,
|
|
206
|
+
"aria-required": w,
|
|
207
|
+
"aria-invalid": !!C,
|
|
208
|
+
"aria-activedescendant": P && z >= 0 ? `${k}-menu-${z}-option-${V[z]}` : void 0,
|
|
209
|
+
children: /* @__PURE__ */ h("div", {
|
|
210
|
+
className: m(u.value, !Q && u.placeholder),
|
|
211
|
+
children: Q || x
|
|
195
212
|
})
|
|
196
213
|
})
|
|
197
|
-
}), /* @__PURE__ */
|
|
198
|
-
show:
|
|
214
|
+
}), /* @__PURE__ */ h(n, {
|
|
215
|
+
show: P && !T,
|
|
199
216
|
preset: "fade",
|
|
200
|
-
id:
|
|
201
|
-
className:
|
|
202
|
-
ref:
|
|
203
|
-
...
|
|
204
|
-
children:
|
|
205
|
-
className:
|
|
217
|
+
id: N,
|
|
218
|
+
className: u.dropdown,
|
|
219
|
+
ref: Ee,
|
|
220
|
+
...De,
|
|
221
|
+
children: Z.map((e, t) => /* @__PURE__ */ h("div", {
|
|
222
|
+
className: u.menu,
|
|
206
223
|
role: "listbox",
|
|
207
|
-
"aria-labelledby":
|
|
208
|
-
"aria-label":
|
|
224
|
+
"aria-labelledby": M,
|
|
225
|
+
"aria-label": M ? void 0 : D || $() || _(x),
|
|
209
226
|
children: e.map((e, n) => {
|
|
210
|
-
let a =
|
|
211
|
-
return /* @__PURE__ */
|
|
212
|
-
className:
|
|
227
|
+
let a = L[t] === e.value, o = z === t && V[t] === n, s = q[t] === e.value, l = e.children && e.children.length > 0;
|
|
228
|
+
return /* @__PURE__ */ h(c, {
|
|
229
|
+
className: m(u.menuItem, s && u.selected),
|
|
213
230
|
active: o || a,
|
|
214
231
|
disabled: e.disabled,
|
|
215
232
|
onClick: (n) => {
|
|
216
|
-
n.stopPropagation(),
|
|
233
|
+
n.stopPropagation(), Y(e, t);
|
|
217
234
|
},
|
|
218
235
|
onMouseEnter: () => {
|
|
219
|
-
|
|
236
|
+
Se(e, t), B(t), H((e) => [...e.slice(0, t), n]);
|
|
220
237
|
},
|
|
221
|
-
rightSection: l ? /* @__PURE__ */
|
|
238
|
+
rightSection: l ? /* @__PURE__ */ h(i, {
|
|
222
239
|
component: r,
|
|
223
240
|
size: "sm"
|
|
224
241
|
}) : void 0,
|
|
225
242
|
role: "option",
|
|
226
|
-
id: `${
|
|
227
|
-
"aria-selected":
|
|
243
|
+
id: `${k}-menu-${t}-option-${n}`,
|
|
244
|
+
"aria-selected": s,
|
|
228
245
|
tabIndex: -1,
|
|
229
246
|
children: e.label
|
|
230
247
|
}, e.value);
|
|
@@ -234,6 +251,6 @@ var _ = ({ options: _ = [], value: v, onChange: y, placeholder: b, label: x, err
|
|
|
234
251
|
})
|
|
235
252
|
});
|
|
236
253
|
};
|
|
237
|
-
|
|
254
|
+
v.displayName = "Cascader";
|
|
238
255
|
//#endregion
|
|
239
|
-
export {
|
|
256
|
+
export { v as Cascader };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../../icon/check.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../_internal/
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../hooks/useMergedRef.cjs"),n=require("../../../icon/check.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../_internal/rovingIndex.cjs"),a=require("../../_internal/useInlineFloating.cjs"),ee=require("../../_internal/BaseListItem/BaseListItem.cjs"),o=require("../InputBase/InputBase.cjs"),s=require("../FieldTemplate/FieldTemplate.cjs"),c=require("../../_internal/typeahead.cjs"),l=require("../../data-display/Chip/Chip.cjs"),u=require("./multiselect.module.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=({options:e=[],value:m,onChange:h,placeholder:g,label:_,error:v,required:y,layout:b,className:x,disabled:S=!1,defaultValue:te=[],allowClear:ne=!1,id:re,width:C,fullWidth:w=!1,...T})=>{let[E,D]=(0,d.useState)(!1),[O,k]=(0,d.useState)(te),[A,j]=(0,d.useState)(-1),[ie,M]=(0,d.useState)(!1),N=(0,d.useRef)(null),P=(0,d.useRef)(null),F=(0,d.useRef)(null),I=(0,d.useId)(),L=re||`wim-multiselect-${I}`,R=`${L}-list`,z=_?`${L}-label`:void 0,B=v?`${L}-error`:void 0,V=`${L}-trigger`,H=m!==void 0,U=H?m:O;(0,d.useEffect)(()=>{let e=e=>{N.current&&!N.current.contains(e.target)&&D(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let W=e=>{if(S||e&&e.target.closest(`[data-chip-delete]`))return;let t=!E;D(t),j(t?X():-1)},G=e=>{if(S)return;let t;t=U?.includes(e)?U.filter(t=>t!==e):[...U||[],e],H||k(t),h&&h(t)},K=(e,t)=>{if(e.stopPropagation(),S)return;let n=(U||[]).filter(e=>e!==t);H||k(n),h&&h(n)},q=e=>{e?.stopPropagation(),!S&&(H||k([]),h&&h([]))},J=e.filter(e=>U?.includes(e.value)),Y=t=>!!e[t]?.disabled,X=()=>i.getRovingIndex({key:`Home`,current:-1,count:e.length,isDisabled:Y})??-1,Z=c.useTypeahead(),ae=t=>{if(M(!0),!S){if(c.isTypeaheadKey(t,Z.typing())){t.preventDefault();let n=c.findTypeaheadIndex({query:Z.push(t.key),current:E?A:-1,count:e.length,getText:t=>e[t].label,isDisabled:Y});n>=0&&(D(!0),j(n))}else if(E&&i.isRovingKey(t.key,`vertical`)){t.preventDefault();let n=i.getRovingIndex({key:t.key,current:A,count:e.length,orientation:`vertical`,isDisabled:Y});n!==null&&j(n)}else switch(t.key){case`ArrowDown`:t.preventDefault(),D(!0),j(X());break;case`Enter`:case` `:t.preventDefault(),E?A>=0&&!Y(A)&&G(e[A].value):(D(!0),j(X()));break;case`Escape`:E&&(t.preventDefault(),D(!1),j(-1),F.current?.focus());break;case`Tab`:E&&(D(!1),j(-1))}}};(0,d.useEffect)(()=>{E&&A>=0&&P.current&&P.current.children[A]?.scrollIntoView({block:`nearest`})},[A,E]);let{"aria-label":oe,"aria-labelledby":Q,"aria-describedby":se,...ce}=T,{setReference:le,setFloating:$,floatingProps:ue}=a.useInlineFloating({open:E&&!S}),de=t.useMergedRef(N,le),fe=t.useMergedRef(P,$);return(0,p.jsx)(s.FieldTemplate,{label:_,error:v,required:y,layout:b,labelId:z,htmlFor:V,errorId:B,className:x,children:(0,p.jsxs)(`div`,{className:(0,f.default)(`wim-multi-select`,u.default.root,w&&u.default.fullWidth),ref:de,onMouseMove:()=>M(!1),"data-keyboard-nav":ie,...ce,children:[(0,p.jsx)(o.InputBase,{disabled:S,allowClear:ne,hasValue:U&&U.length>0,onClear:q,intent:v?`danger`:`default`,width:C,fullWidth:w,rightIcons:[{name:`ChevronDownIcon`,rotated:E}],className:(0,f.default)(E&&u.default.open),children:(0,p.jsx)(`div`,{id:V,"data-testid":`multiselect-trigger`,className:(0,f.default)(u.default.trigger,S&&u.default.disabled),onClick:W,tabIndex:S?-1:0,role:`combobox`,"aria-expanded":E,"aria-haspopup":`listbox`,"aria-controls":E?R:void 0,"aria-disabled":S,"aria-labelledby":z||Q,"aria-describedby":B||se,"aria-required":y,"aria-invalid":!!v,"aria-label":_?void 0:oe||g,onKeyDown:ae,ref:F,"aria-activedescendant":E&&A>=0?`${L}-option-${A}`:void 0,children:(0,p.jsx)(`div`,{className:(0,f.default)(u.default.value,J.length===0&&u.default.placeholder),children:J.length>0?J.map(e=>(0,p.jsx)(l.Chip,{"data-testid":`multiselect-chip`,size:`sm`,intent:`neutral`,variant:`solid`,disabled:S,onDelete:S?void 0:t=>K(t,e.value),children:e.label},e.value)):g})})}),E&&!S&&(0,p.jsx)(`ul`,{id:R,ref:fe,className:u.default.list,...ue,role:`listbox`,"aria-multiselectable":`true`,"aria-labelledby":z||Q||void 0,children:e.map((e,t)=>{let i=U?.includes(e.value),a=t===A;return(0,p.jsx)(ee.BaseListItem,{asChild:!0,id:`${L}-option-${t}`,className:(0,f.default)(u.default.option,i&&u.default.selected),active:a,disabled:e.disabled,onClick:()=>!e.disabled&&G(e.value),onMouseEnter:()=>j(t),rightSection:i?(0,p.jsx)(r.Icon,{component:n.default,size:`sm`}):void 0,role:`option`,"aria-selected":i,tabIndex:-1,children:(0,p.jsx)(`li`,{children:e.label})},e.value)})})]})})};m.displayName=`MultiSelect`,exports.MultiSelect=m;
|