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