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