@mattermost/compass-ui 0.1.0-alpha.22 → 0.1.0-alpha.24
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/combobox/Combobox.cjs +1 -1
- package/dist/components/combobox/Combobox.cjs.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +10 -2
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/combobox/Combobox.js +298 -283
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/dropdown/Dropdown.css +1 -1
- package/dist/components/dropdown/Dropdown.module.scss.cjs +1 -1
- package/dist/components/dropdown/Dropdown.module.scss.js +14 -14
- package/dist/components/global-banner/GlobalBanner.css +1 -1
- package/dist/components/global-banner/GlobalBanner.module.scss.cjs +1 -1
- package/dist/components/global-banner/GlobalBanner.module.scss.js +10 -10
- package/dist/components/progress-bar/ProgressBar.cjs +1 -1
- package/dist/components/progress-bar/ProgressBar.cjs.map +1 -1
- package/dist/components/progress-bar/ProgressBar.d.ts +10 -2
- package/dist/components/progress-bar/ProgressBar.d.ts.map +1 -1
- package/dist/components/progress-bar/ProgressBar.js +31 -21
- package/dist/components/progress-bar/ProgressBar.js.map +1 -1
- package/dist/components/thread-footer/ThreadFooter.css +1 -1
- package/dist/components/thread-footer/ThreadFooter.module.scss.cjs +1 -1
- package/dist/components/thread-footer/ThreadFooter.module.scss.js +18 -18
- package/dist/components/toast/Toast.css +1 -1
- package/dist/components/toast/Toast.module.scss.cjs +1 -1
- package/dist/components/toast/Toast.module.scss.js +10 -10
- package/package.json +1 -1
|
@@ -1,300 +1,315 @@
|
|
|
1
1
|
import { jsxs as M, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { useAnchoredPopupPortal as
|
|
15
|
-
import { useOutsideClose as
|
|
16
|
-
import { usePopoverTransition as
|
|
17
|
-
import { mergeMenuItemProps as
|
|
18
|
-
import { mergeClassNames as
|
|
19
|
-
import { toKebab as
|
|
20
|
-
import
|
|
21
|
-
const
|
|
2
|
+
import { forwardRef as Mr, useId as Ir, useRef as O, useCallback as d, useState as I, useMemo as V, useEffect as de } from "react";
|
|
3
|
+
import __Vr from "@mattermost/compass-icons/components/chevron-down.js";const Vr=__Vr&&__Vr.default?__Vr.default:__Vr;
|
|
4
|
+
import __Rr from "@mattermost/compass-icons/components/close-circle.js";const Rr=__Rr&&__Rr.default?__Rr.default:__Rr;
|
|
5
|
+
import __Sr from "@mattermost/compass-icons/components/plus.js";const Sr=__Sr&&__Sr.default?__Sr.default:__Sr;
|
|
6
|
+
import Er from "../chip/Chip.js";
|
|
7
|
+
import Tr from "../chip/ChipGroup.js";
|
|
8
|
+
import me, { IconSlotContext as Lr } from "../icon/Icon.js";
|
|
9
|
+
import Te from "../menu-item/MenuItem.js";
|
|
10
|
+
import Fr, { PopoverMenuScroll as zr } from "../popover-menu/PopoverMenu.js";
|
|
11
|
+
import Cr from "../spinner/Spinner.js";
|
|
12
|
+
import Hr from "../team-avatar/TeamAvatar.js";
|
|
13
|
+
import $r from "../user-avatar/UserAvatar.js";
|
|
14
|
+
import { useAnchoredPopupPortal as Or } from "../../hooks/use-anchored-popup-portal.js";
|
|
15
|
+
import { useOutsideClose as jr } from "../../hooks/use-outside-close.js";
|
|
16
|
+
import { usePopoverTransition as Ur } from "../../hooks/use-popover-transition.js";
|
|
17
|
+
import { mergeMenuItemProps as qr } from "../../utils/menuItemProps.js";
|
|
18
|
+
import { mergeClassNames as Gr } from "../../utils/props.js";
|
|
19
|
+
import { toKebab as Qr } from "../../utils/string.js";
|
|
20
|
+
import o from "./Combobox.module.scss.js";
|
|
21
|
+
const Le = 280, Xr = {
|
|
22
22
|
small: "small",
|
|
23
23
|
medium: "medium",
|
|
24
24
|
large: "large"
|
|
25
|
-
},
|
|
25
|
+
}, Zr = {
|
|
26
26
|
small: "12",
|
|
27
27
|
medium: "16",
|
|
28
28
|
large: "16"
|
|
29
29
|
};
|
|
30
|
-
function
|
|
31
|
-
return typeof
|
|
30
|
+
function Pr(n) {
|
|
31
|
+
return typeof n == "string" ? `${n} selections` : "Selected";
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return `Create "${
|
|
33
|
+
function Wr(n) {
|
|
34
|
+
return `Create "${n}"`;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function W(n) {
|
|
37
|
+
return n.kind === "option" && n.option.disabled === !0;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return b ?
|
|
39
|
+
function Yr(n, b) {
|
|
40
|
+
return b ? n.label.toLowerCase().includes(b.toLowerCase()) : !0;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
42
|
+
function Jr(n) {
|
|
43
|
+
return n == null ? null : Array.isArray(n) ? n[0] ?? null : n === "" ? null : n;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function Kr(n) {
|
|
46
|
+
return n == null ? [] : Array.isArray(n) ? n : n === "" ? [] : [n];
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
50
|
-
if (
|
|
48
|
+
function Br(n) {
|
|
49
|
+
if (n.leadingVisual != null) return n.leadingVisual;
|
|
50
|
+
if (n.leadingAvatar != null)
|
|
51
51
|
return /* @__PURE__ */ a(
|
|
52
|
-
|
|
52
|
+
$r,
|
|
53
53
|
{
|
|
54
|
-
src:
|
|
55
|
-
alt:
|
|
54
|
+
src: n.leadingAvatar.src,
|
|
55
|
+
alt: n.leadingAvatar.alt,
|
|
56
56
|
size: "24"
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
|
-
if (
|
|
59
|
+
if (n.leadingTeamAvatar != null)
|
|
60
60
|
return /* @__PURE__ */ a(
|
|
61
|
-
|
|
61
|
+
Hr,
|
|
62
62
|
{
|
|
63
|
-
src:
|
|
64
|
-
initials:
|
|
65
|
-
alt:
|
|
63
|
+
src: n.leadingTeamAvatar.src,
|
|
64
|
+
initials: n.leadingTeamAvatar.initials ?? (n.leadingTeamAvatar.src ? void 0 : Array.from(n.label).slice(0, 2).join("")),
|
|
65
|
+
alt: n.leadingTeamAvatar.alt,
|
|
66
66
|
size: "24",
|
|
67
67
|
variant: "menu"
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const yn = Mr(function({
|
|
72
72
|
options: b,
|
|
73
|
-
menuItemProps:
|
|
74
|
-
multiple:
|
|
75
|
-
value:
|
|
76
|
-
defaultValue:
|
|
77
|
-
onChange:
|
|
78
|
-
inputValue:
|
|
79
|
-
defaultInputValue:
|
|
73
|
+
menuItemProps: Fe,
|
|
74
|
+
multiple: t = !1,
|
|
75
|
+
value: be,
|
|
76
|
+
defaultValue: ve,
|
|
77
|
+
onChange: j,
|
|
78
|
+
inputValue: Y,
|
|
79
|
+
defaultInputValue: ze = "",
|
|
80
80
|
onInputChange: u,
|
|
81
81
|
label: w,
|
|
82
|
-
placeholder:
|
|
83
|
-
leadingIcon:
|
|
84
|
-
size:
|
|
85
|
-
invalid:
|
|
82
|
+
placeholder: Ce,
|
|
83
|
+
leadingIcon: J,
|
|
84
|
+
size: K = "medium",
|
|
85
|
+
invalid: he = !1,
|
|
86
86
|
disabled: g = !1,
|
|
87
|
-
filter:
|
|
88
|
-
emptyMessage:
|
|
89
|
-
loading:
|
|
90
|
-
loadingMessage:
|
|
87
|
+
filter: U = !0,
|
|
88
|
+
emptyMessage: He = "No results",
|
|
89
|
+
loading: xe = !1,
|
|
90
|
+
loadingMessage: $e = "Loading…",
|
|
91
91
|
selectedOptions: k,
|
|
92
92
|
creatable: R = !1,
|
|
93
|
-
onCreateOption:
|
|
94
|
-
formatCreateLabel:
|
|
95
|
-
clearable:
|
|
96
|
-
|
|
93
|
+
onCreateOption: B,
|
|
94
|
+
formatCreateLabel: Oe = Wr,
|
|
95
|
+
clearable: je = !1,
|
|
96
|
+
openOnFocus: Ue = !1,
|
|
97
|
+
clearLabel: qe = "Clear",
|
|
97
98
|
clearButtonProps: p,
|
|
98
|
-
selectionsLabel:
|
|
99
|
-
listboxLabel:
|
|
100
|
-
className:
|
|
101
|
-
id:
|
|
102
|
-
"aria-label":
|
|
103
|
-
"aria-describedby":
|
|
104
|
-
required:
|
|
105
|
-
onFocus:
|
|
106
|
-
onBlur:
|
|
107
|
-
onKeyDown:
|
|
108
|
-
portalContainer:
|
|
109
|
-
zIndex:
|
|
110
|
-
...
|
|
111
|
-
},
|
|
112
|
-
const
|
|
99
|
+
selectionsLabel: Ge,
|
|
100
|
+
listboxLabel: Qe = "Options",
|
|
101
|
+
className: Xe = "",
|
|
102
|
+
id: Ze,
|
|
103
|
+
"aria-label": _e,
|
|
104
|
+
"aria-describedby": Pe,
|
|
105
|
+
required: We = !1,
|
|
106
|
+
onFocus: ee,
|
|
107
|
+
onBlur: re,
|
|
108
|
+
onKeyDown: ne,
|
|
109
|
+
portalContainer: Ye = null,
|
|
110
|
+
zIndex: Je,
|
|
111
|
+
...Ke
|
|
112
|
+
}, S) {
|
|
113
|
+
const Be = Ir(), te = Ze ?? Be, E = `${te}-listbox`, le = O(null), ge = O(null), N = O(null), er = d(
|
|
113
114
|
(e) => {
|
|
114
|
-
N.current = e, typeof
|
|
115
|
+
N.current = e, typeof S == "function" ? S(e) : S && (S.current = e);
|
|
115
116
|
},
|
|
116
|
-
[
|
|
117
|
-
),
|
|
118
|
-
() =>
|
|
119
|
-
[
|
|
120
|
-
), m =
|
|
117
|
+
[S]
|
|
118
|
+
), ae = be !== void 0, [rr, nr] = I(() => ve !== void 0 ? ve : t ? [] : null), oe = ae ? be : rr, v = t ? null : Jr(oe), s = V(
|
|
119
|
+
() => t ? Kr(oe) : [],
|
|
120
|
+
[t, oe]
|
|
121
|
+
), m = Y !== void 0, [se, T] = I(ze), [c, pe] = I(!1), [tr, ye] = I(!1), [h, y] = I(-1), q = O(!1), L = O(null), Ae = d(
|
|
121
122
|
(e) => {
|
|
122
|
-
e !== h && (
|
|
123
|
+
e !== h && (q.current = !0, y(e));
|
|
123
124
|
},
|
|
124
125
|
[h]
|
|
125
|
-
), [
|
|
126
|
+
), [G, F] = I(null), Q = d(
|
|
126
127
|
(e) => b.find((r) => r.value === e) ?? (k == null ? void 0 : k.find((r) => r.value === e)) ?? (R ? { value: e, label: e } : void 0),
|
|
127
128
|
[b, k, R]
|
|
128
|
-
),
|
|
129
|
-
() => v == null ? void 0 :
|
|
130
|
-
[
|
|
131
|
-
),
|
|
129
|
+
), X = V(
|
|
130
|
+
() => v == null ? void 0 : Q(v),
|
|
131
|
+
[Q, v]
|
|
132
|
+
), ie = m ? Y : t ? se : G !== null ? G : (X == null ? void 0 : X.label) ?? se, ce = m ? Y : t ? se : G !== null ? G : "", z = d(
|
|
132
133
|
(e) => {
|
|
133
|
-
m || (T(e),
|
|
134
|
+
m || (T(e), t || F(e)), u == null || u(e);
|
|
134
135
|
},
|
|
135
|
-
[m,
|
|
136
|
+
[m, t, u]
|
|
136
137
|
), x = d(
|
|
137
138
|
(e) => {
|
|
138
|
-
|
|
139
|
+
ae || nr(e), j == null || j(e);
|
|
139
140
|
},
|
|
140
|
-
[
|
|
141
|
-
),
|
|
142
|
-
if (
|
|
143
|
-
const e = typeof
|
|
144
|
-
return b.filter((r) => e(r,
|
|
145
|
-
}, [b,
|
|
141
|
+
[ae, j]
|
|
142
|
+
), ke = V(() => {
|
|
143
|
+
if (U === !1) return b;
|
|
144
|
+
const e = typeof U == "function" ? U : Yr;
|
|
145
|
+
return b.filter((r) => e(r, ce));
|
|
146
|
+
}, [b, U, ce]), C = R ? ce.trim() : "", Ne = V(() => {
|
|
146
147
|
if (C === "") return !1;
|
|
147
148
|
const e = C.toLowerCase(), r = (f) => f.toLowerCase() === e;
|
|
148
|
-
return [...b, ...k ?? []].some((f) => r(f.label) || r(f.value)) ? !1 : !(
|
|
149
|
+
return [...b, ...k ?? []].some((f) => r(f.label) || r(f.value)) ? !1 : !(t ? s : v != null ? [v] : []).some(r);
|
|
149
150
|
}, [
|
|
150
151
|
C,
|
|
151
152
|
b,
|
|
152
153
|
k,
|
|
153
|
-
|
|
154
|
+
t,
|
|
154
155
|
s,
|
|
155
156
|
v
|
|
156
157
|
]), i = V(
|
|
157
158
|
() => [
|
|
158
|
-
...
|
|
159
|
-
...
|
|
159
|
+
...ke.map((e) => ({ kind: "option", option: e })),
|
|
160
|
+
...Ne ? [{ kind: "create", inputValue: C }] : []
|
|
160
161
|
],
|
|
161
|
-
[
|
|
162
|
+
[ke, Ne, C]
|
|
162
163
|
), D = d(
|
|
163
|
-
(e) => e.kind === "option" ? `${
|
|
164
|
-
[
|
|
165
|
-
), { mounted:
|
|
166
|
-
placement:
|
|
167
|
-
maxHeight:
|
|
168
|
-
style:
|
|
169
|
-
portalRef:
|
|
170
|
-
renderPortal:
|
|
171
|
-
} =
|
|
172
|
-
preferredHeight:
|
|
173
|
-
maxHeightCap:
|
|
174
|
-
portalContainer:
|
|
175
|
-
zIndex:
|
|
176
|
-
}),
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
g ||
|
|
164
|
+
(e) => e.kind === "option" ? `${E}-option-${e.option.value}` : `${E}-create`,
|
|
165
|
+
[E]
|
|
166
|
+
), { mounted: we, visible: lr } = Ur(c), {
|
|
167
|
+
placement: ar,
|
|
168
|
+
maxHeight: or,
|
|
169
|
+
style: sr,
|
|
170
|
+
portalRef: De,
|
|
171
|
+
renderPortal: ir
|
|
172
|
+
} = Or(ge, we, {
|
|
173
|
+
preferredHeight: Le,
|
|
174
|
+
maxHeightCap: Le,
|
|
175
|
+
portalContainer: Ye,
|
|
176
|
+
zIndex: Je
|
|
177
|
+
}), A = d(() => {
|
|
178
|
+
pe(!1), y(-1), !t && !m && (F(null), T(""));
|
|
179
|
+
}, [t, m]), H = d(() => {
|
|
180
|
+
g || pe(!0);
|
|
180
181
|
}, [g]);
|
|
181
|
-
|
|
182
|
-
c &&
|
|
182
|
+
jr(le, c, A, De), de(() => {
|
|
183
|
+
c && y((e) => {
|
|
183
184
|
if (i.length === 0) return -1;
|
|
184
185
|
if (e >= 0 && e < i.length) return e;
|
|
185
186
|
const r = i.findIndex(
|
|
186
|
-
(
|
|
187
|
+
(l) => l.kind === "option" && (t ? s.includes(l.option.value) : l.option.value === v)
|
|
187
188
|
);
|
|
188
189
|
return r >= 0 ? r : 0;
|
|
189
190
|
});
|
|
190
|
-
}, [c, i,
|
|
191
|
-
const
|
|
192
|
-
(e) =>
|
|
193
|
-
[
|
|
194
|
-
),
|
|
191
|
+
}, [c, i, t, s, v]);
|
|
192
|
+
const cr = d(
|
|
193
|
+
(e) => t ? s.includes(e) : v === e,
|
|
194
|
+
[t, s, v]
|
|
195
|
+
), ue = d(
|
|
195
196
|
(e) => {
|
|
196
197
|
var r;
|
|
197
198
|
if (!e.disabled) {
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
x(
|
|
199
|
+
if (t) {
|
|
200
|
+
const l = s.includes(e.value) ? s.filter((_) => _ !== e.value) : [...s, e.value];
|
|
201
|
+
x(l), z(""), A(), (r = N.current) == null || r.focus();
|
|
201
202
|
return;
|
|
202
203
|
}
|
|
203
|
-
x(e.value), m ? u == null || u(e.label) : (T(""),
|
|
204
|
+
x(e.value), m ? u == null || u(e.label) : (T(""), F(null)), A();
|
|
204
205
|
}
|
|
205
206
|
},
|
|
206
207
|
[
|
|
207
|
-
|
|
208
|
+
t,
|
|
208
209
|
s,
|
|
209
210
|
x,
|
|
210
211
|
z,
|
|
211
212
|
m,
|
|
212
213
|
u,
|
|
213
|
-
|
|
214
|
+
A
|
|
214
215
|
]
|
|
215
|
-
),
|
|
216
|
+
), fe = d(
|
|
216
217
|
(e) => {
|
|
217
218
|
var r;
|
|
218
|
-
if (
|
|
219
|
-
z(""),
|
|
219
|
+
if (B ? B(e) : x(t ? [...s, e] : e), t) {
|
|
220
|
+
z(""), A(), (r = N.current) == null || r.focus();
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
|
-
m ? u == null || u(e) : (T(""),
|
|
223
|
+
m ? u == null || u(e) : (T(""), F(null)), A();
|
|
223
224
|
},
|
|
224
225
|
[
|
|
225
|
-
|
|
226
|
-
|
|
226
|
+
B,
|
|
227
|
+
t,
|
|
227
228
|
s,
|
|
228
229
|
x,
|
|
229
230
|
z,
|
|
230
231
|
m,
|
|
231
232
|
u,
|
|
232
|
-
|
|
233
|
+
A
|
|
233
234
|
]
|
|
234
|
-
),
|
|
235
|
+
), ur = d(
|
|
235
236
|
(e) => {
|
|
236
|
-
e.kind === "create" ?
|
|
237
|
+
e.kind === "create" ? fe(e.inputValue) : ue(e.option);
|
|
237
238
|
},
|
|
238
|
-
[
|
|
239
|
-
),
|
|
239
|
+
[fe, ue]
|
|
240
|
+
), fr = d(() => {
|
|
240
241
|
var e;
|
|
241
|
-
x(null), m ? u == null || u("") : (T(""),
|
|
242
|
-
}, [x, m, u]),
|
|
242
|
+
x(null), m ? u == null || u("") : (T(""), F(null)), (e = N.current) == null || e.focus();
|
|
243
|
+
}, [x, m, u]), Me = d(
|
|
243
244
|
(e) => {
|
|
244
|
-
|
|
245
|
+
t && x(s.filter((r) => r !== e));
|
|
245
246
|
},
|
|
246
|
-
[
|
|
247
|
-
),
|
|
247
|
+
[t, s, x]
|
|
248
|
+
), Ie = d(
|
|
248
249
|
(e) => {
|
|
249
|
-
|
|
250
|
-
const r = i.map((
|
|
250
|
+
q.current = !1;
|
|
251
|
+
const r = i.map((l, _) => ({ row: l, i: _ })).filter(({ row: l }) => !W(l));
|
|
251
252
|
if (r.length === 0) {
|
|
252
|
-
|
|
253
|
+
y(-1);
|
|
253
254
|
return;
|
|
254
255
|
}
|
|
255
|
-
|
|
256
|
-
const _ = r.findIndex(({ i:
|
|
256
|
+
y((l) => {
|
|
257
|
+
const _ = r.findIndex(({ i: P }) => P === l), f = _ < 0 ? e > 0 ? 0 : r.length - 1 : (_ + e + r.length) % r.length;
|
|
257
258
|
return r[f].i;
|
|
258
259
|
});
|
|
259
260
|
},
|
|
260
261
|
[i]
|
|
261
262
|
);
|
|
262
|
-
|
|
263
|
-
var r,
|
|
263
|
+
de(() => {
|
|
264
|
+
var r, l;
|
|
264
265
|
if (!c || h < 0) return;
|
|
265
|
-
if (
|
|
266
|
-
|
|
266
|
+
if (q.current) {
|
|
267
|
+
q.current = !1;
|
|
267
268
|
return;
|
|
268
269
|
}
|
|
269
270
|
const e = i[h];
|
|
270
|
-
e && ((
|
|
271
|
+
e && ((l = (r = document.getElementById(D(e))) == null ? void 0 : r.scrollIntoView) == null || l.call(r, { block: "nearest" }));
|
|
271
272
|
}, [c, h, i, D]);
|
|
272
|
-
const
|
|
273
|
+
const dr = (e) => {
|
|
274
|
+
$();
|
|
273
275
|
const r = e.target.value;
|
|
274
|
-
z(r), c || H(),
|
|
275
|
-
},
|
|
276
|
-
|
|
276
|
+
z(r), c || H(), y(0);
|
|
277
|
+
}, $ = () => {
|
|
278
|
+
L.current !== null && (cancelAnimationFrame(L.current), L.current = null);
|
|
279
|
+
};
|
|
280
|
+
de(() => $, []);
|
|
281
|
+
const mr = () => {
|
|
282
|
+
ye(!0), Ue && H(), !t && !m && X && ($(), L.current = requestAnimationFrame(() => {
|
|
277
283
|
var e;
|
|
278
|
-
(e = N.current) == null || e.select();
|
|
279
|
-
});
|
|
280
|
-
},
|
|
281
|
-
var
|
|
284
|
+
L.current = null, (e = N.current) == null || e.select();
|
|
285
|
+
}));
|
|
286
|
+
}, Ve = (e) => {
|
|
287
|
+
var l;
|
|
282
288
|
const r = e.relatedTarget;
|
|
283
|
-
r && ((
|
|
284
|
-
},
|
|
289
|
+
r && ((l = le.current) != null && l.contains(r)) || ($(), ye(!1));
|
|
290
|
+
}, br = (e) => {
|
|
285
291
|
if (!g)
|
|
286
|
-
switch (e.key) {
|
|
292
|
+
switch ($(), e.key) {
|
|
287
293
|
case "ArrowDown":
|
|
288
|
-
e.preventDefault(), c ?
|
|
294
|
+
e.preventDefault(), c ? Ie(1) : H();
|
|
289
295
|
break;
|
|
290
296
|
case "ArrowUp":
|
|
291
|
-
e.preventDefault(), c
|
|
297
|
+
if (e.preventDefault(), c)
|
|
298
|
+
Ie(-1);
|
|
299
|
+
else {
|
|
300
|
+
for (let r = i.length - 1; r >= 0; r--)
|
|
301
|
+
if (!W(i[r])) {
|
|
302
|
+
y(r);
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
H();
|
|
306
|
+
}
|
|
292
307
|
break;
|
|
293
308
|
case "Home":
|
|
294
|
-
c && i.length > 0 && (e.preventDefault(),
|
|
309
|
+
c && i.length > 0 && (e.preventDefault(), y(
|
|
295
310
|
Math.max(
|
|
296
311
|
0,
|
|
297
|
-
i.findIndex((r) => !
|
|
312
|
+
i.findIndex((r) => !W(r))
|
|
298
313
|
)
|
|
299
314
|
));
|
|
300
315
|
break;
|
|
@@ -302,88 +317,88 @@ const xt = Nr(function({
|
|
|
302
317
|
if (c && i.length > 0) {
|
|
303
318
|
e.preventDefault();
|
|
304
319
|
for (let r = i.length - 1; r >= 0; r--)
|
|
305
|
-
if (!
|
|
306
|
-
|
|
320
|
+
if (!W(i[r])) {
|
|
321
|
+
y(r);
|
|
307
322
|
break;
|
|
308
323
|
}
|
|
309
324
|
}
|
|
310
325
|
break;
|
|
311
326
|
case "Enter":
|
|
312
|
-
c && h >= 0 && i[h] && (e.preventDefault(),
|
|
327
|
+
c && h >= 0 && i[h] && (e.preventDefault(), ur(i[h]));
|
|
313
328
|
break;
|
|
314
329
|
case "Escape":
|
|
315
|
-
c && (e.preventDefault(),
|
|
330
|
+
c && (e.preventDefault(), A());
|
|
316
331
|
break;
|
|
317
332
|
case "Backspace":
|
|
318
|
-
|
|
333
|
+
t && ie === "" && s.length > 0 && (e.preventDefault(), Me(s[s.length - 1]));
|
|
319
334
|
break;
|
|
320
335
|
case "Tab":
|
|
321
|
-
|
|
336
|
+
A();
|
|
322
337
|
break;
|
|
323
338
|
}
|
|
324
|
-
}, dr = (e) => {
|
|
325
|
-
ur(), J == null || J(e);
|
|
326
|
-
}, mr = (e) => {
|
|
327
|
-
De(e), K == null || K(e);
|
|
328
|
-
}, br = (e) => {
|
|
329
|
-
fr(e), B == null || B(e);
|
|
330
339
|
}, vr = (e) => {
|
|
340
|
+
mr(), ee == null || ee(e);
|
|
341
|
+
}, hr = (e) => {
|
|
342
|
+
Ve(e), re == null || re(e);
|
|
343
|
+
}, xr = (e) => {
|
|
344
|
+
br(e), ne == null || ne(e);
|
|
345
|
+
}, _r = (e) => {
|
|
331
346
|
var r;
|
|
332
347
|
g || e.target.closest("[data-chip], [data-combobox-clear]") || (e.target !== N.current && (e.preventDefault(), (r = N.current) == null || r.focus()), c || H());
|
|
333
|
-
},
|
|
334
|
-
if (!
|
|
348
|
+
}, Re = t ? s.length > 0 : v != null && v !== "", gr = ie.length > 0, pr = je && !t && Re && !g, yr = tr || c || Re || gr, Se = h >= 0 ? i[h] : void 0, Ar = Se != null ? D(Se) : void 0, Z = V(() => {
|
|
349
|
+
if (!t) return [];
|
|
335
350
|
if (k == null) {
|
|
336
|
-
const e = b.filter((
|
|
351
|
+
const e = b.filter((l) => s.includes(l.value));
|
|
337
352
|
if (!R) return e;
|
|
338
|
-
const r = new Set(e.map((
|
|
353
|
+
const r = new Set(e.map((l) => l.value));
|
|
339
354
|
return [
|
|
340
355
|
...e,
|
|
341
|
-
...s.filter((
|
|
356
|
+
...s.filter((l) => !r.has(l)).map((l) => ({ value: l, label: l }))
|
|
342
357
|
];
|
|
343
358
|
}
|
|
344
|
-
return s.map(
|
|
359
|
+
return s.map(Q).filter((e) => e != null);
|
|
345
360
|
}, [
|
|
346
|
-
|
|
361
|
+
t,
|
|
347
362
|
k,
|
|
348
363
|
b,
|
|
349
364
|
s,
|
|
350
365
|
R,
|
|
351
|
-
|
|
352
|
-
]),
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
w != null &&
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
c ?
|
|
360
|
-
g ?
|
|
361
|
-
|
|
366
|
+
Q
|
|
367
|
+
]), kr = o[`combobox--size-${Qr(K)}`], Nr = t && Z.length > 0, wr = [
|
|
368
|
+
o.combobox,
|
|
369
|
+
kr,
|
|
370
|
+
he ? o["combobox--invalid"] : "",
|
|
371
|
+
w != null && yr ? o["combobox--label-floated"] : "",
|
|
372
|
+
J != null ? o["combobox--has-leading-icon"] : "",
|
|
373
|
+
Nr ? o["combobox--has-chips"] : "",
|
|
374
|
+
c ? o["combobox--open"] : "",
|
|
375
|
+
g ? o["combobox--disabled"] : "",
|
|
376
|
+
Xe
|
|
362
377
|
].filter(Boolean).join(" ");
|
|
363
|
-
return /* @__PURE__ */ M("div", { className:
|
|
364
|
-
/* @__PURE__ */ M("div", { className:
|
|
365
|
-
w != null && /* @__PURE__ */ a("label", { className:
|
|
378
|
+
return /* @__PURE__ */ M("div", { className: wr, ref: le, children: [
|
|
379
|
+
/* @__PURE__ */ M("div", { className: o.combobox__wrapper, ref: ge, children: [
|
|
380
|
+
w != null && /* @__PURE__ */ a("label", { className: o.combobox__label, htmlFor: te, children: w }),
|
|
366
381
|
/* @__PURE__ */ M(
|
|
367
382
|
"div",
|
|
368
383
|
{
|
|
369
|
-
className:
|
|
370
|
-
onMouseDown:
|
|
384
|
+
className: o.combobox__inner,
|
|
385
|
+
onMouseDown: _r,
|
|
371
386
|
children: [
|
|
372
|
-
|
|
373
|
-
/* @__PURE__ */ M("div", { className:
|
|
374
|
-
|
|
375
|
-
|
|
387
|
+
J != null && /* @__PURE__ */ a("span", { className: o["combobox__leading-icon"], "aria-hidden": !0, children: /* @__PURE__ */ a(Lr.Provider, { value: { size: "16" }, children: J }) }),
|
|
388
|
+
/* @__PURE__ */ M("div", { className: o.combobox__value, children: [
|
|
389
|
+
t && Z.length > 0 && /* @__PURE__ */ a(
|
|
390
|
+
Tr,
|
|
376
391
|
{
|
|
377
|
-
"aria-label":
|
|
392
|
+
"aria-label": Ge ?? Pr(w),
|
|
378
393
|
disabled: g,
|
|
379
|
-
children:
|
|
380
|
-
|
|
394
|
+
children: Z.map((e) => /* @__PURE__ */ a(
|
|
395
|
+
Er,
|
|
381
396
|
{
|
|
382
|
-
size:
|
|
397
|
+
size: Xr[K],
|
|
383
398
|
leadingAvatar: e.leadingAvatar,
|
|
384
399
|
leadingIcon: e.leadingAvatar == null ? e.leadingVisual : void 0,
|
|
385
400
|
onRemove: g ? void 0 : (r) => {
|
|
386
|
-
r.stopPropagation(),
|
|
401
|
+
r.stopPropagation(), Me(e.value);
|
|
387
402
|
},
|
|
388
403
|
children: e.label
|
|
389
404
|
},
|
|
@@ -394,130 +409,130 @@ const xt = Nr(function({
|
|
|
394
409
|
/* @__PURE__ */ a(
|
|
395
410
|
"input",
|
|
396
411
|
{
|
|
397
|
-
...
|
|
398
|
-
ref:
|
|
399
|
-
id:
|
|
400
|
-
className:
|
|
412
|
+
...Ke,
|
|
413
|
+
ref: er,
|
|
414
|
+
id: te,
|
|
415
|
+
className: o.combobox__control,
|
|
401
416
|
type: "text",
|
|
402
417
|
role: "combobox",
|
|
403
418
|
autoComplete: "off",
|
|
404
419
|
spellCheck: !1,
|
|
405
420
|
disabled: g,
|
|
406
|
-
placeholder:
|
|
407
|
-
value:
|
|
408
|
-
"aria-label":
|
|
409
|
-
"aria-describedby":
|
|
410
|
-
"aria-required":
|
|
411
|
-
"aria-invalid":
|
|
421
|
+
placeholder: t && Z.length > 0 ? void 0 : Ce,
|
|
422
|
+
value: ie,
|
|
423
|
+
"aria-label": _e,
|
|
424
|
+
"aria-describedby": Pe || void 0,
|
|
425
|
+
"aria-required": We ? !0 : void 0,
|
|
426
|
+
"aria-invalid": he ? !0 : void 0,
|
|
412
427
|
"aria-expanded": c,
|
|
413
|
-
"aria-controls":
|
|
428
|
+
"aria-controls": E,
|
|
414
429
|
"aria-autocomplete": "list",
|
|
415
|
-
"aria-activedescendant":
|
|
416
|
-
"aria-busy":
|
|
417
|
-
onChange:
|
|
418
|
-
onFocus:
|
|
419
|
-
onBlur:
|
|
420
|
-
onKeyDown:
|
|
430
|
+
"aria-activedescendant": Ar,
|
|
431
|
+
"aria-busy": xe || void 0,
|
|
432
|
+
onChange: dr,
|
|
433
|
+
onFocus: vr,
|
|
434
|
+
onBlur: hr,
|
|
435
|
+
onKeyDown: xr
|
|
421
436
|
}
|
|
422
437
|
)
|
|
423
438
|
] }),
|
|
424
|
-
|
|
439
|
+
pr && /* @__PURE__ */ a(
|
|
425
440
|
"button",
|
|
426
441
|
{
|
|
427
442
|
...p,
|
|
428
443
|
type: "button",
|
|
429
|
-
className:
|
|
430
|
-
|
|
444
|
+
className: Gr(
|
|
445
|
+
o.combobox__clear,
|
|
431
446
|
p == null ? void 0 : p.className
|
|
432
447
|
),
|
|
433
|
-
"aria-label":
|
|
448
|
+
"aria-label": qe,
|
|
434
449
|
"data-combobox-clear": "",
|
|
435
|
-
onClick:
|
|
450
|
+
onClick: fr,
|
|
436
451
|
onBlur: (e) => {
|
|
437
452
|
var r;
|
|
438
|
-
(r = p == null ? void 0 : p.onBlur) == null || r.call(p, e),
|
|
453
|
+
(r = p == null ? void 0 : p.onBlur) == null || r.call(p, e), Ve(e);
|
|
439
454
|
},
|
|
440
|
-
children: /* @__PURE__ */ a(
|
|
455
|
+
children: /* @__PURE__ */ a(me, { size: Zr[K], glyph: /* @__PURE__ */ a(Rr, {}) })
|
|
441
456
|
}
|
|
442
457
|
),
|
|
443
|
-
/* @__PURE__ */ a("span", { className:
|
|
458
|
+
/* @__PURE__ */ a("span", { className: o["combobox__trailing-icon"], "aria-hidden": !0, children: /* @__PURE__ */ a(me, { size: "12", glyph: /* @__PURE__ */ a(Vr, {}) }) })
|
|
444
459
|
]
|
|
445
460
|
}
|
|
446
461
|
)
|
|
447
462
|
] }),
|
|
448
|
-
|
|
463
|
+
we && ir(
|
|
449
464
|
/* @__PURE__ */ a(
|
|
450
465
|
"div",
|
|
451
466
|
{
|
|
452
|
-
ref:
|
|
467
|
+
ref: De,
|
|
453
468
|
className: [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
469
|
+
o.combobox__popup,
|
|
470
|
+
ar === "above" ? o["combobox__popup--above"] : "",
|
|
471
|
+
lr ? o["combobox__popup--visible"] : ""
|
|
457
472
|
].filter(Boolean).join(" "),
|
|
458
|
-
style:
|
|
459
|
-
children: /* @__PURE__ */ a(
|
|
473
|
+
style: sr,
|
|
474
|
+
children: /* @__PURE__ */ a(Fr, { className: o.combobox__menu, children: /* @__PURE__ */ M(zr, { maxHeight: or, children: [
|
|
460
475
|
i.length > 0 && /* @__PURE__ */ a(
|
|
461
476
|
"ul",
|
|
462
477
|
{
|
|
463
|
-
id:
|
|
464
|
-
className:
|
|
478
|
+
id: E,
|
|
479
|
+
className: o.combobox__list,
|
|
465
480
|
role: "listbox",
|
|
466
|
-
"aria-multiselectable":
|
|
467
|
-
"aria-label": typeof w == "string" ? w :
|
|
481
|
+
"aria-multiselectable": t || void 0,
|
|
482
|
+
"aria-label": typeof w == "string" ? w : _e ?? Qe,
|
|
468
483
|
children: i.map((e, r) => {
|
|
469
|
-
const
|
|
470
|
-
|
|
484
|
+
const l = r === h, _ = (Dr) => {
|
|
485
|
+
Dr.preventDefault();
|
|
471
486
|
};
|
|
472
487
|
if (e.kind === "create")
|
|
473
488
|
return /* @__PURE__ */ a(
|
|
474
489
|
"li",
|
|
475
490
|
{
|
|
476
|
-
className:
|
|
491
|
+
className: o.combobox__option,
|
|
477
492
|
role: "presentation",
|
|
478
493
|
children: /* @__PURE__ */ a(
|
|
479
|
-
|
|
494
|
+
Te,
|
|
480
495
|
{
|
|
481
496
|
id: D(e),
|
|
482
497
|
role: "option",
|
|
483
|
-
label:
|
|
484
|
-
leadingVisual: /* @__PURE__ */ a(
|
|
485
|
-
active:
|
|
498
|
+
label: Oe(e.inputValue),
|
|
499
|
+
leadingVisual: /* @__PURE__ */ a(me, { glyph: /* @__PURE__ */ a(Sr, {}) }),
|
|
500
|
+
active: l,
|
|
486
501
|
"aria-selected": !1,
|
|
487
502
|
onMouseDown: _,
|
|
488
|
-
onMouseEnter: () =>
|
|
489
|
-
onClick: () =>
|
|
503
|
+
onMouseEnter: () => Ae(r),
|
|
504
|
+
onClick: () => fe(e.inputValue)
|
|
490
505
|
}
|
|
491
506
|
)
|
|
492
507
|
},
|
|
493
508
|
D(e)
|
|
494
509
|
);
|
|
495
|
-
const { option: f } = e,
|
|
510
|
+
const { option: f } = e, P = cr(f.value), Ee = Br(f);
|
|
496
511
|
return /* @__PURE__ */ a(
|
|
497
512
|
"li",
|
|
498
513
|
{
|
|
499
|
-
className:
|
|
514
|
+
className: o.combobox__option,
|
|
500
515
|
role: "presentation",
|
|
501
516
|
children: /* @__PURE__ */ a(
|
|
502
|
-
|
|
517
|
+
Te,
|
|
503
518
|
{
|
|
504
|
-
...
|
|
505
|
-
|
|
519
|
+
...qr(
|
|
520
|
+
Fe,
|
|
506
521
|
f.menuItemProps
|
|
507
522
|
),
|
|
508
523
|
id: D(e),
|
|
509
524
|
role: "option",
|
|
510
525
|
label: f.label,
|
|
511
526
|
secondaryLabel: f.secondaryLabel,
|
|
512
|
-
leadingElement:
|
|
513
|
-
leadingVisual:
|
|
514
|
-
trailingElement:
|
|
515
|
-
active:
|
|
527
|
+
leadingElement: Ee != null,
|
|
528
|
+
leadingVisual: Ee,
|
|
529
|
+
trailingElement: P,
|
|
530
|
+
active: l,
|
|
516
531
|
disabled: f.disabled,
|
|
517
|
-
"aria-selected":
|
|
532
|
+
"aria-selected": P,
|
|
518
533
|
onMouseDown: _,
|
|
519
|
-
onMouseEnter: () =>
|
|
520
|
-
onClick: () =>
|
|
534
|
+
onMouseEnter: () => Ae(r),
|
|
535
|
+
onClick: () => ue(f)
|
|
521
536
|
}
|
|
522
537
|
)
|
|
523
538
|
},
|
|
@@ -526,10 +541,10 @@ const xt = Nr(function({
|
|
|
526
541
|
})
|
|
527
542
|
}
|
|
528
543
|
),
|
|
529
|
-
|
|
530
|
-
/* @__PURE__ */ a(
|
|
531
|
-
/* @__PURE__ */ a("span", { children:
|
|
532
|
-
] }) : i.length === 0 && /* @__PURE__ */ a("p", { className:
|
|
544
|
+
xe ? /* @__PURE__ */ M("div", { className: o.combobox__loading, role: "status", children: [
|
|
545
|
+
/* @__PURE__ */ a(Cr, { size: "16", "aria-hidden": !0 }),
|
|
546
|
+
/* @__PURE__ */ a("span", { children: $e })
|
|
547
|
+
] }) : i.length === 0 && /* @__PURE__ */ a("p", { className: o.combobox__empty, children: He })
|
|
533
548
|
] }) })
|
|
534
549
|
}
|
|
535
550
|
)
|
|
@@ -537,6 +552,6 @@ const xt = Nr(function({
|
|
|
537
552
|
] });
|
|
538
553
|
});
|
|
539
554
|
export {
|
|
540
|
-
|
|
555
|
+
yn as default
|
|
541
556
|
};
|
|
542
557
|
//# sourceMappingURL=Combobox.js.map
|