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