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