@telegraph/combobox 0.0.77 → 0.0.78
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/CHANGELOG.md +11 -0
- package/README.md +474 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.mjs +573 -492
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Combobox/Combobox.d.ts +17 -1
- package/dist/types/Combobox/Combobox.d.ts.map +1 -1
- package/dist/types/Combobox/Combobox.helpers.d.ts +1 -5
- package/dist/types/Combobox/Combobox.helpers.d.ts.map +1 -1
- package/dist/types/Combobox/Combobox.primitives.d.ts +35 -0
- package/dist/types/Combobox/Combobox.primitives.d.ts.map +1 -0
- package/dist/types/Combobox/Combobox.types.d.ts +14 -0
- package/dist/types/Combobox/Combobox.types.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/esm/index.mjs
CHANGED
|
@@ -1,62 +1,330 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { DismissableLayer as
|
|
3
|
-
import * as
|
|
4
|
-
import { useControllableState as
|
|
5
|
-
import * as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { useComposedRefs as
|
|
8
|
-
import { RefToTgphRef as
|
|
9
|
-
import { Lucide as E, Icon as
|
|
10
|
-
import { Input as
|
|
11
|
-
import { Stack as
|
|
1
|
+
import { jsx as l, jsxs as R, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import { DismissableLayer as Z } from "@radix-ui/react-dismissable-layer";
|
|
3
|
+
import * as ee from "@radix-ui/react-portal";
|
|
4
|
+
import { useControllableState as te } from "@radix-ui/react-use-controllable-state";
|
|
5
|
+
import * as oe from "@radix-ui/react-visually-hidden";
|
|
6
|
+
import { Button as B } from "@telegraph/button";
|
|
7
|
+
import { useComposedRefs as $ } from "@telegraph/compose-refs";
|
|
8
|
+
import { RefToTgphRef as re } from "@telegraph/helpers";
|
|
9
|
+
import { Lucide as E, Icon as z } from "@telegraph/icon";
|
|
10
|
+
import { Input as ne } from "@telegraph/input";
|
|
11
|
+
import { Stack as I, Box as G } from "@telegraph/layout";
|
|
12
12
|
import { Menu as Q } from "@telegraph/menu";
|
|
13
|
-
import {
|
|
14
|
-
import { Tag as L } from "@telegraph/tag";
|
|
15
|
-
import { Tooltip as oe } from "@telegraph/tooltip";
|
|
16
|
-
import { Text as M } from "@telegraph/typography";
|
|
13
|
+
import { Text as H } from "@telegraph/typography";
|
|
17
14
|
import s from "react";
|
|
18
|
-
|
|
15
|
+
import { motion as P, AnimatePresence as M } from "@telegraph/motion";
|
|
16
|
+
import { Tag as K } from "@telegraph/tag";
|
|
17
|
+
import { Tooltip as ae } from "@telegraph/tooltip";
|
|
18
|
+
const ie = {
|
|
19
19
|
0: "5",
|
|
20
20
|
1: "6",
|
|
21
21
|
2: "8",
|
|
22
22
|
3: "10"
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
s.isValidElement(
|
|
26
|
-
}),
|
|
27
|
-
return
|
|
28
|
-
var
|
|
29
|
-
const
|
|
23
|
+
}, S = (t) => Array.isArray(t), k = (t) => typeof t == "object" && !Array.isArray(t) || typeof t == "string" || !t, ce = (t) => {
|
|
24
|
+
const o = (a, c = []) => (s.Children.toArray(a).forEach((i) => {
|
|
25
|
+
s.isValidElement(i) && (i.props.value ? c.push(i) : i.props.children && o(i.props.children, c));
|
|
26
|
+
}), c);
|
|
27
|
+
return o(t).map((a) => {
|
|
28
|
+
var n;
|
|
29
|
+
const c = a;
|
|
30
30
|
return {
|
|
31
|
-
value:
|
|
32
|
-
label: ((
|
|
31
|
+
value: c.props.value,
|
|
32
|
+
label: ((n = c.props) == null ? void 0 : n.label) || c.props.children || c.props.value
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
|
-
}, C = (
|
|
36
|
-
if (e)
|
|
37
|
-
return c === !0 ? e == null ? void 0 : e.value : e;
|
|
38
|
-
}, F = (e, c, r) => {
|
|
39
|
-
if (!e || !c || c.length === 0) return;
|
|
40
|
-
const t = c.find(
|
|
41
|
-
(o) => o.value === C(e, r)
|
|
42
|
-
);
|
|
35
|
+
}, C = (t, o) => {
|
|
43
36
|
if (t)
|
|
44
|
-
return t;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
return o === !0 ? t == null ? void 0 : t.value : t;
|
|
38
|
+
}, F = (t, o, e) => {
|
|
39
|
+
if (!t || !o || o.length === 0) return;
|
|
40
|
+
const r = o.find(
|
|
41
|
+
(a) => a.value === C(t, e)
|
|
42
|
+
);
|
|
43
|
+
if (r)
|
|
44
|
+
return r;
|
|
45
|
+
}, se = ({
|
|
46
|
+
children: t,
|
|
47
|
+
value: o,
|
|
48
|
+
searchQuery: e
|
|
49
|
+
}) => {
|
|
50
|
+
const r = Y(t);
|
|
51
|
+
return (o == null ? void 0 : o.toLowerCase().includes(e.toLowerCase())) || r.some(
|
|
52
|
+
(a) => a.toLowerCase().includes(e.toLowerCase())
|
|
53
|
+
);
|
|
54
|
+
}, Y = (t) => {
|
|
55
|
+
const o = s.Children.toArray(t), e = [];
|
|
56
|
+
return o.forEach((r) => {
|
|
57
|
+
typeof r == "string" && e.push(r), s.isValidElement(r) && r.props.children && e.push(...Y(r.props.children));
|
|
58
|
+
}), e;
|
|
59
|
+
}, le = ({
|
|
60
|
+
icon: t = E.ChevronDown,
|
|
61
|
+
"aria-hidden": o = !0,
|
|
62
|
+
...e
|
|
63
|
+
}) => {
|
|
64
|
+
const r = s.useContext(y);
|
|
65
|
+
return /* @__PURE__ */ l(
|
|
66
|
+
B.Icon,
|
|
67
|
+
{
|
|
68
|
+
as: P.span,
|
|
69
|
+
animate: { rotate: r.open ? 180 : 0 },
|
|
70
|
+
transition: { duration: 150, type: "spring" },
|
|
71
|
+
icon: t,
|
|
72
|
+
"aria-hidden": o,
|
|
73
|
+
...e
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}, ue = ({
|
|
77
|
+
tooltipProps: t,
|
|
78
|
+
...o
|
|
79
|
+
}) => {
|
|
80
|
+
const e = s.useContext(y), r = () => {
|
|
81
|
+
var c, n;
|
|
82
|
+
if (S(e.value)) {
|
|
83
|
+
const i = e.onValueChange;
|
|
84
|
+
i == null || i([]);
|
|
85
|
+
}
|
|
86
|
+
if (k(e.value)) {
|
|
87
|
+
const i = e.onValueChange;
|
|
88
|
+
i == null || i(void 0);
|
|
89
|
+
}
|
|
90
|
+
(n = (c = e.triggerRef) == null ? void 0 : c.current) == null || n.focus();
|
|
91
|
+
};
|
|
92
|
+
return s.useMemo(() => {
|
|
93
|
+
var c;
|
|
94
|
+
if (k(e.value))
|
|
95
|
+
return e.clearable && e.value;
|
|
96
|
+
if (S(e.value))
|
|
97
|
+
return e.clearable && ((c = e.value) == null ? void 0 : c.length) > 0;
|
|
98
|
+
}, [e.clearable, e.value]) ? /* @__PURE__ */ l(ae, { label: "Clear field", ...t, children: /* @__PURE__ */ l(
|
|
99
|
+
B,
|
|
100
|
+
{
|
|
101
|
+
type: "button",
|
|
102
|
+
icon: { icon: E.X, alt: "Clear field" },
|
|
103
|
+
size: "1",
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
onClick: (c) => {
|
|
106
|
+
e.value && (c.stopPropagation(), r());
|
|
107
|
+
},
|
|
108
|
+
onKeyDown: (c) => {
|
|
109
|
+
(c.key === "Enter" || c.key === " ") && (c.stopPropagation(), r());
|
|
110
|
+
},
|
|
111
|
+
"data-tgph-combobox-clear": !0,
|
|
112
|
+
style: {
|
|
113
|
+
// Remove margin to make the clear button flush
|
|
114
|
+
// with the trigger button
|
|
115
|
+
marginTop: "calc(-1 * var(--tgph-spacing-1)",
|
|
116
|
+
marginBottom: "calc(-1 * var(--tgph-spacing-1)"
|
|
117
|
+
},
|
|
118
|
+
...o
|
|
119
|
+
}
|
|
120
|
+
) }) : null;
|
|
121
|
+
}, pe = ({
|
|
122
|
+
children: t,
|
|
123
|
+
...o
|
|
124
|
+
}) => {
|
|
125
|
+
const e = s.useContext(y), r = s.useMemo(() => {
|
|
126
|
+
var i;
|
|
127
|
+
if (!k(e.value)) return;
|
|
128
|
+
const a = F(
|
|
129
|
+
e.value,
|
|
130
|
+
e.options,
|
|
131
|
+
e.legacyBehavior
|
|
132
|
+
), c = (a == null ? void 0 : a.label) || (a == null ? void 0 : a.value) || e.placeholder, n = e.legacyBehavior && ((i = e == null ? void 0 : e.value) == null ? void 0 : i.label);
|
|
133
|
+
return n || c;
|
|
134
|
+
}, [
|
|
135
|
+
e.value,
|
|
136
|
+
e.options,
|
|
137
|
+
e.legacyBehavior,
|
|
138
|
+
e.placeholder
|
|
139
|
+
]);
|
|
140
|
+
return /* @__PURE__ */ l(
|
|
141
|
+
B.Text,
|
|
142
|
+
{
|
|
143
|
+
color: e.value ? "default" : "gray",
|
|
144
|
+
textOverflow: "ellipsis",
|
|
145
|
+
overflow: "hidden",
|
|
146
|
+
...o,
|
|
147
|
+
children: t || r
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}, ge = ({
|
|
151
|
+
children: t,
|
|
152
|
+
...o
|
|
49
153
|
}) => {
|
|
50
|
-
const
|
|
51
|
-
return (
|
|
52
|
-
|
|
154
|
+
const e = s.useContext(y);
|
|
155
|
+
return /* @__PURE__ */ l(B.Text, { color: "gray", ...o, children: t || e.placeholder });
|
|
156
|
+
}, fe = ({ children: t }) => {
|
|
157
|
+
const o = s.useContext(y);
|
|
158
|
+
if (!S(o.value)) return null;
|
|
159
|
+
const e = o.layout || "truncate", a = (o.value.length - 2).toString().split("");
|
|
160
|
+
return /* @__PURE__ */ R(
|
|
161
|
+
I,
|
|
162
|
+
{
|
|
163
|
+
gap: "1",
|
|
164
|
+
w: "full",
|
|
165
|
+
wrap: e === "wrap" ? "wrap" : "nowrap",
|
|
166
|
+
align: "center",
|
|
167
|
+
style: {
|
|
168
|
+
position: "relative",
|
|
169
|
+
flexGrow: 1
|
|
170
|
+
},
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ l(
|
|
173
|
+
M,
|
|
174
|
+
{
|
|
175
|
+
presenceMap: o.value.map((c) => ({
|
|
176
|
+
"tgph-motion-key": C(c, o.legacyBehavior) || "",
|
|
177
|
+
value: !0
|
|
178
|
+
})),
|
|
179
|
+
children: t
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ l(
|
|
183
|
+
M,
|
|
184
|
+
{
|
|
185
|
+
presenceMap: [
|
|
186
|
+
{
|
|
187
|
+
"tgph-motion-key": "combobox-more",
|
|
188
|
+
value: !0
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
children: e === "truncate" && o.value.length > 2 && /* @__PURE__ */ l(
|
|
192
|
+
I,
|
|
193
|
+
{
|
|
194
|
+
as: P.div,
|
|
195
|
+
initial: { opacity: 0 },
|
|
196
|
+
animate: { opacity: 1 },
|
|
197
|
+
exit: { opacity: 0 },
|
|
198
|
+
transition: { duration: 100, type: "spring" },
|
|
199
|
+
h: "full",
|
|
200
|
+
pr: "1",
|
|
201
|
+
pl: "8",
|
|
202
|
+
align: "center",
|
|
203
|
+
"aria-label": `${o.value.length - 2} more selected`,
|
|
204
|
+
position: "absolute",
|
|
205
|
+
right: "0",
|
|
206
|
+
style: {
|
|
207
|
+
backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
|
|
208
|
+
},
|
|
209
|
+
children: /* @__PURE__ */ R(H, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
|
|
210
|
+
"+",
|
|
211
|
+
/* @__PURE__ */ R(
|
|
212
|
+
M,
|
|
213
|
+
{
|
|
214
|
+
presenceMap: a.map((c) => ({
|
|
215
|
+
"tgph-motion-key": c,
|
|
216
|
+
value: !0
|
|
217
|
+
})),
|
|
218
|
+
children: [
|
|
219
|
+
a.map((c) => /* @__PURE__ */ l(
|
|
220
|
+
G,
|
|
221
|
+
{
|
|
222
|
+
as: P.span,
|
|
223
|
+
initial: { opacity: 0 },
|
|
224
|
+
animate: { opacity: 1 },
|
|
225
|
+
exit: { opacity: 0 },
|
|
226
|
+
transition: { duration: 100, type: "spring" },
|
|
227
|
+
w: "2",
|
|
228
|
+
display: "inline-block",
|
|
229
|
+
"tgph-motion-key": c,
|
|
230
|
+
children: c
|
|
231
|
+
},
|
|
232
|
+
c
|
|
233
|
+
)),
|
|
234
|
+
" "
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
"more"
|
|
239
|
+
] })
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
]
|
|
245
|
+
}
|
|
53
246
|
);
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
247
|
+
}, j = s.createContext({
|
|
248
|
+
value: ""
|
|
249
|
+
}), he = ({
|
|
250
|
+
value: t,
|
|
251
|
+
children: o,
|
|
252
|
+
...e
|
|
253
|
+
}) => /* @__PURE__ */ l(j.Provider, { value: { value: t }, children: /* @__PURE__ */ l(
|
|
254
|
+
K.Root,
|
|
255
|
+
{
|
|
256
|
+
as: P.span,
|
|
257
|
+
initializeWithAnimation: !1,
|
|
258
|
+
initial: { opacity: 0, scale: 0.5 },
|
|
259
|
+
animate: { opacity: 1, scale: 1 },
|
|
260
|
+
exit: { opacity: 0, scale: 0.5 },
|
|
261
|
+
transition: { duration: 100, type: "spring" },
|
|
262
|
+
"tgph-motion-key": t,
|
|
263
|
+
size: "1",
|
|
264
|
+
layout: "position",
|
|
265
|
+
...e,
|
|
266
|
+
children: o
|
|
267
|
+
}
|
|
268
|
+
) }), de = ({
|
|
269
|
+
children: t,
|
|
270
|
+
...o
|
|
271
|
+
}) => {
|
|
272
|
+
const e = s.useContext(y), r = s.useContext(j), a = s.useMemo(() => {
|
|
273
|
+
const c = e.options.find(
|
|
274
|
+
(p) => p.value === r.value
|
|
275
|
+
);
|
|
276
|
+
if (c) return c.label || c.value;
|
|
277
|
+
if (!e.value) return;
|
|
278
|
+
const i = e.value.find(
|
|
279
|
+
(p) => C(p, e.legacyBehavior) === r.value
|
|
280
|
+
);
|
|
281
|
+
if (i)
|
|
282
|
+
return i;
|
|
283
|
+
}, [
|
|
284
|
+
e.options,
|
|
285
|
+
e.value,
|
|
286
|
+
r.value,
|
|
287
|
+
e.legacyBehavior
|
|
288
|
+
]);
|
|
289
|
+
return /* @__PURE__ */ l(K.Text, { ...o, children: t || a });
|
|
290
|
+
}, me = ({
|
|
291
|
+
children: t,
|
|
292
|
+
...o
|
|
293
|
+
}) => {
|
|
294
|
+
const e = s.useContext(y), r = s.useContext(j);
|
|
295
|
+
return /* @__PURE__ */ l(
|
|
296
|
+
K.Button,
|
|
297
|
+
{
|
|
298
|
+
icon: { icon: E.X, alt: `Remove ${r.value}` },
|
|
299
|
+
onClick: (a) => {
|
|
300
|
+
if (!e.onValueChange) return;
|
|
301
|
+
const c = e.onValueChange, i = e.value.filter((p) => C(p, e.legacyBehavior) !== r.value);
|
|
302
|
+
c == null || c(i), a.stopPropagation(), a.preventDefault();
|
|
303
|
+
},
|
|
304
|
+
...o,
|
|
305
|
+
children: t
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}, ye = ({
|
|
309
|
+
value: t,
|
|
310
|
+
children: o,
|
|
311
|
+
...e
|
|
312
|
+
}) => /* @__PURE__ */ R(D.Root, { value: t, ...e, children: [
|
|
313
|
+
/* @__PURE__ */ l(D.Text, { children: o }),
|
|
314
|
+
/* @__PURE__ */ l(D.Button, {})
|
|
315
|
+
] }), D = {
|
|
316
|
+
Root: he,
|
|
317
|
+
Text: de,
|
|
318
|
+
Button: me,
|
|
319
|
+
Default: ye
|
|
320
|
+
}, T = {
|
|
321
|
+
TriggerIndicator: le,
|
|
322
|
+
TriggerClear: ue,
|
|
323
|
+
TriggerText: pe,
|
|
324
|
+
TriggerPlaceholder: ge,
|
|
325
|
+
TriggerTagsContainer: fe,
|
|
326
|
+
TriggerTag: D
|
|
327
|
+
}, be = ["ArrowDown", "PageUp", "Home"], xe = ["ArrowUp", "PageDown", "End"], X = ["Enter", " "], y = s.createContext({
|
|
60
328
|
value: void 0,
|
|
61
329
|
onValueChange: () => {
|
|
62
330
|
},
|
|
@@ -71,567 +339,379 @@ const ne = {
|
|
|
71
339
|
disabled: !1,
|
|
72
340
|
options: [],
|
|
73
341
|
legacyBehavior: !1
|
|
74
|
-
}),
|
|
75
|
-
modal:
|
|
76
|
-
closeOnSelect:
|
|
77
|
-
clearable:
|
|
78
|
-
disabled:
|
|
79
|
-
legacyBehavior:
|
|
80
|
-
open:
|
|
81
|
-
onOpenChange:
|
|
82
|
-
defaultOpen:
|
|
83
|
-
value:
|
|
84
|
-
onValueChange:
|
|
85
|
-
errored:
|
|
342
|
+
}), ve = ({
|
|
343
|
+
modal: t = !0,
|
|
344
|
+
closeOnSelect: o = !0,
|
|
345
|
+
clearable: e = !1,
|
|
346
|
+
disabled: r = !1,
|
|
347
|
+
legacyBehavior: a = !1,
|
|
348
|
+
open: c,
|
|
349
|
+
onOpenChange: n,
|
|
350
|
+
defaultOpen: i,
|
|
351
|
+
value: p,
|
|
352
|
+
onValueChange: g,
|
|
353
|
+
errored: b,
|
|
86
354
|
placeholder: v,
|
|
87
|
-
layout:
|
|
355
|
+
layout: d,
|
|
88
356
|
children: u,
|
|
89
|
-
...
|
|
357
|
+
...f
|
|
90
358
|
}) => {
|
|
91
|
-
const
|
|
92
|
-
prop:
|
|
93
|
-
defaultProp:
|
|
94
|
-
onChange:
|
|
95
|
-
}),
|
|
96
|
-
A((
|
|
359
|
+
const m = s.useId(), x = s.useId(), h = s.useRef(null), w = s.useRef(null), L = s.useRef(null), V = s.useMemo(() => ce(u), [u]), [U, N] = s.useState(""), [O = !1, A] = te({
|
|
360
|
+
prop: c,
|
|
361
|
+
defaultProp: i,
|
|
362
|
+
onChange: n
|
|
363
|
+
}), W = s.useCallback(() => {
|
|
364
|
+
A((J) => !J);
|
|
97
365
|
}, [A]);
|
|
98
366
|
return s.useEffect(() => {
|
|
99
|
-
O ||
|
|
100
|
-
}, [O]), /* @__PURE__ */
|
|
101
|
-
|
|
367
|
+
O || N("");
|
|
368
|
+
}, [O]), /* @__PURE__ */ l(
|
|
369
|
+
y.Provider,
|
|
102
370
|
{
|
|
103
371
|
value: {
|
|
104
|
-
contentId:
|
|
105
|
-
triggerId:
|
|
106
|
-
value:
|
|
372
|
+
contentId: m,
|
|
373
|
+
triggerId: x,
|
|
374
|
+
value: p,
|
|
107
375
|
// Need to cast this to avoid type errors
|
|
108
376
|
// because the type of onValueChange is not
|
|
109
377
|
// consistent with the value type
|
|
110
|
-
onValueChange:
|
|
378
|
+
onValueChange: g,
|
|
111
379
|
placeholder: v,
|
|
112
380
|
open: O,
|
|
113
381
|
setOpen: A,
|
|
114
|
-
onOpenToggle:
|
|
115
|
-
closeOnSelect:
|
|
116
|
-
clearable:
|
|
117
|
-
disabled:
|
|
118
|
-
searchQuery:
|
|
119
|
-
setSearchQuery:
|
|
120
|
-
triggerRef:
|
|
382
|
+
onOpenToggle: W,
|
|
383
|
+
closeOnSelect: o,
|
|
384
|
+
clearable: e,
|
|
385
|
+
disabled: r,
|
|
386
|
+
searchQuery: U,
|
|
387
|
+
setSearchQuery: N,
|
|
388
|
+
triggerRef: h,
|
|
121
389
|
searchRef: w,
|
|
122
|
-
contentRef:
|
|
123
|
-
errored:
|
|
124
|
-
layout:
|
|
125
|
-
options:
|
|
126
|
-
legacyBehavior:
|
|
390
|
+
contentRef: L,
|
|
391
|
+
errored: b,
|
|
392
|
+
layout: d,
|
|
393
|
+
options: V,
|
|
394
|
+
legacyBehavior: a
|
|
127
395
|
},
|
|
128
|
-
children: /* @__PURE__ */
|
|
396
|
+
children: /* @__PURE__ */ l(
|
|
129
397
|
Q.Root,
|
|
130
398
|
{
|
|
131
399
|
open: O,
|
|
132
400
|
onOpenChange: A,
|
|
133
|
-
modal:
|
|
134
|
-
...
|
|
401
|
+
modal: t,
|
|
402
|
+
...f,
|
|
135
403
|
children: u
|
|
136
404
|
}
|
|
137
405
|
)
|
|
138
406
|
}
|
|
139
407
|
);
|
|
140
|
-
},
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return i;
|
|
150
|
-
}, [r.options, r.value, e, r.legacyBehavior]);
|
|
151
|
-
return /* @__PURE__ */ S(
|
|
152
|
-
L.Root,
|
|
153
|
-
{
|
|
154
|
-
as: B.span,
|
|
155
|
-
initializeWithAnimation: !1,
|
|
156
|
-
initial: { opacity: 0, scale: 0.5 },
|
|
157
|
-
animate: { opacity: 1, scale: 1 },
|
|
158
|
-
exit: { opacity: 0, scale: 0.5 },
|
|
159
|
-
transition: { duration: 100, type: "spring" },
|
|
160
|
-
"tgph-motion-key": e,
|
|
161
|
-
size: "1",
|
|
162
|
-
layout: "position",
|
|
163
|
-
...c,
|
|
164
|
-
children: [
|
|
165
|
-
/* @__PURE__ */ p(L.Text, { children: t }),
|
|
166
|
-
/* @__PURE__ */ p(
|
|
167
|
-
L.Button,
|
|
168
|
-
{
|
|
169
|
-
icon: { icon: E.X, alt: `Remove ${e}` },
|
|
170
|
-
onClick: (o) => {
|
|
171
|
-
if (!r.onValueChange) return;
|
|
172
|
-
const l = r.onValueChange, n = r.value.filter((a) => C(a, r.legacyBehavior) !== e);
|
|
173
|
-
l == null || l(n), o.stopPropagation(), o.preventDefault();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
}, ue = () => {
|
|
181
|
-
var c;
|
|
182
|
-
const e = s.useContext(x);
|
|
183
|
-
if (e.value && R(e.value)) {
|
|
184
|
-
const r = e.layout || "truncate", t = e.value.length - 2, o = t.toString().split("");
|
|
185
|
-
return e.value.length === 0 ? /* @__PURE__ */ p(I.Text, { color: "gray", children: e.placeholder }) : /* @__PURE__ */ S(
|
|
186
|
-
T,
|
|
187
|
-
{
|
|
188
|
-
gap: "1",
|
|
189
|
-
w: "full",
|
|
190
|
-
wrap: r === "wrap" ? "wrap" : "nowrap",
|
|
191
|
-
align: "center",
|
|
192
|
-
style: {
|
|
193
|
-
position: "relative",
|
|
194
|
-
flexGrow: 1
|
|
195
|
-
},
|
|
196
|
-
children: [
|
|
197
|
-
/* @__PURE__ */ p(
|
|
198
|
-
V,
|
|
199
|
-
{
|
|
200
|
-
presenceMap: e.value.map((l) => ({
|
|
201
|
-
"tgph-motion-key": C(l, e.legacyBehavior) || "",
|
|
202
|
-
value: !0
|
|
203
|
-
})),
|
|
204
|
-
children: e.value.map((l, i) => {
|
|
205
|
-
const n = C(l, e.legacyBehavior);
|
|
206
|
-
if (n && (r === "truncate" && i <= 1 || r === "wrap"))
|
|
207
|
-
return /* @__PURE__ */ p(ee, { children: /* @__PURE__ */ p(le, { value: n }) }, n);
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
),
|
|
211
|
-
/* @__PURE__ */ p(
|
|
212
|
-
V,
|
|
213
|
-
{
|
|
214
|
-
presenceMap: [
|
|
215
|
-
{
|
|
216
|
-
"tgph-motion-key": "combobox-more",
|
|
217
|
-
value: !0
|
|
218
|
-
}
|
|
219
|
-
],
|
|
220
|
-
children: r === "truncate" && e.value.length > 2 && /* @__PURE__ */ p(
|
|
221
|
-
T,
|
|
222
|
-
{
|
|
223
|
-
as: B.div,
|
|
224
|
-
initial: { opacity: 0 },
|
|
225
|
-
animate: { opacity: 1 },
|
|
226
|
-
exit: { opacity: 0 },
|
|
227
|
-
transition: { duration: 100, type: "spring" },
|
|
228
|
-
h: "full",
|
|
229
|
-
pr: "1",
|
|
230
|
-
pl: "8",
|
|
231
|
-
align: "center",
|
|
232
|
-
"aria-label": `${t} more selected`,
|
|
233
|
-
position: "absolute",
|
|
234
|
-
right: "0",
|
|
235
|
-
style: {
|
|
236
|
-
backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
|
|
237
|
-
},
|
|
238
|
-
children: /* @__PURE__ */ S(M, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
|
|
239
|
-
"+",
|
|
240
|
-
/* @__PURE__ */ S(
|
|
241
|
-
V,
|
|
242
|
-
{
|
|
243
|
-
presenceMap: o.map((l) => ({
|
|
244
|
-
"tgph-motion-key": l,
|
|
245
|
-
value: !0
|
|
246
|
-
})),
|
|
247
|
-
children: [
|
|
248
|
-
o.map((l) => /* @__PURE__ */ p(
|
|
249
|
-
_,
|
|
250
|
-
{
|
|
251
|
-
as: B.span,
|
|
252
|
-
initial: { opacity: 0 },
|
|
253
|
-
animate: { opacity: 1 },
|
|
254
|
-
exit: { opacity: 0 },
|
|
255
|
-
transition: { duration: 100, type: "spring" },
|
|
256
|
-
w: "2",
|
|
257
|
-
display: "inline-block",
|
|
258
|
-
"tgph-motion-key": l,
|
|
259
|
-
children: l
|
|
260
|
-
},
|
|
261
|
-
l
|
|
262
|
-
)),
|
|
263
|
-
" "
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
"more"
|
|
268
|
-
] })
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
if (e && k(e.value)) {
|
|
278
|
-
const r = F(
|
|
279
|
-
e.value,
|
|
280
|
-
e.options,
|
|
281
|
-
e.legacyBehavior
|
|
282
|
-
), t = (r == null ? void 0 : r.label) || (r == null ? void 0 : r.value) || e.placeholder, o = e.legacyBehavior && ((c = e == null ? void 0 : e.value) == null ? void 0 : c.label);
|
|
283
|
-
return /* @__PURE__ */ p(
|
|
284
|
-
I.Text,
|
|
285
|
-
{
|
|
286
|
-
color: e.value ? "default" : "gray",
|
|
287
|
-
textOverflow: "ellipsis",
|
|
288
|
-
overflow: "hidden",
|
|
289
|
-
children: o || t
|
|
290
|
-
}
|
|
291
|
-
);
|
|
408
|
+
}, Ce = () => {
|
|
409
|
+
const t = s.useContext(y);
|
|
410
|
+
if (t.value && S(t.value)) {
|
|
411
|
+
const o = t.layout || "truncate";
|
|
412
|
+
return t.value.length === 0 ? /* @__PURE__ */ l(T.TriggerPlaceholder, {}) : /* @__PURE__ */ l(T.TriggerTagsContainer, { children: t.value.map((e, r) => {
|
|
413
|
+
const a = C(e, t.legacyBehavior);
|
|
414
|
+
if (a && (o === "truncate" && r <= 1 || o === "wrap"))
|
|
415
|
+
return /* @__PURE__ */ l(re, { children: /* @__PURE__ */ l(T.TriggerTag.Default, { value: a }) }, a);
|
|
416
|
+
}) });
|
|
292
417
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
418
|
+
if (t && k(t.value))
|
|
419
|
+
return t.value ? /* @__PURE__ */ l(T.TriggerText, {}) : /* @__PURE__ */ l(T.TriggerPlaceholder, {});
|
|
420
|
+
}, Te = ({
|
|
421
|
+
size: t = "2",
|
|
422
|
+
children: o,
|
|
423
|
+
...e
|
|
297
424
|
}) => {
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
300
|
-
if (k(
|
|
425
|
+
const r = s.useContext(y), a = s.useMemo(() => {
|
|
426
|
+
if (r.value) {
|
|
427
|
+
if (k(r.value))
|
|
301
428
|
return F(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
429
|
+
r.value,
|
|
430
|
+
r.options,
|
|
431
|
+
r.legacyBehavior
|
|
305
432
|
);
|
|
306
|
-
if (
|
|
307
|
-
return
|
|
308
|
-
(
|
|
433
|
+
if (S(r.value))
|
|
434
|
+
return r.value.map(
|
|
435
|
+
(n) => F(n, r.options, r.legacyBehavior)
|
|
309
436
|
);
|
|
310
437
|
}
|
|
311
|
-
}, [
|
|
312
|
-
|
|
313
|
-
if (k(t.value))
|
|
314
|
-
return t.clearable && t.value;
|
|
315
|
-
if (R(t.value))
|
|
316
|
-
return t.clearable && ((a = t.value) == null ? void 0 : a.length) > 0;
|
|
317
|
-
}, [t.clearable, t.value]), n = () => {
|
|
318
|
-
var a, f;
|
|
319
|
-
if (R(t.value)) {
|
|
320
|
-
const g = t.onValueChange;
|
|
321
|
-
g == null || g([]);
|
|
322
|
-
}
|
|
323
|
-
if (k(t.value)) {
|
|
324
|
-
const g = t.onValueChange;
|
|
325
|
-
g == null || g(void 0);
|
|
326
|
-
}
|
|
327
|
-
(f = (a = t.triggerRef) == null ? void 0 : a.current) == null || f.focus();
|
|
328
|
-
};
|
|
329
|
-
return /* @__PURE__ */ p(
|
|
438
|
+
}, [r.value, r.options, r.legacyBehavior]), c = s.useCallback(() => a ? k(a) ? (a == null ? void 0 : a.label) || (a == null ? void 0 : a.value) || r.placeholder : S(a) && a.map((n) => (n == null ? void 0 : n.label) || (n == null ? void 0 : n.value)).join(", ") || r.placeholder : r.placeholder, [a, r.placeholder]);
|
|
439
|
+
return /* @__PURE__ */ l(
|
|
330
440
|
Q.Trigger,
|
|
331
441
|
{
|
|
332
|
-
...
|
|
442
|
+
...e,
|
|
333
443
|
asChild: !0,
|
|
334
|
-
onClick: (
|
|
335
|
-
var
|
|
336
|
-
|
|
444
|
+
onClick: (n) => {
|
|
445
|
+
var i, p;
|
|
446
|
+
n.preventDefault(), r.onOpenToggle(), (p = (i = r.triggerRef) == null ? void 0 : i.current) == null || p.focus();
|
|
337
447
|
},
|
|
338
|
-
onKeyDown: (
|
|
339
|
-
if (
|
|
340
|
-
|
|
448
|
+
onKeyDown: (n) => {
|
|
449
|
+
if (n.key === "Tab") {
|
|
450
|
+
n.stopPropagation();
|
|
341
451
|
return;
|
|
342
452
|
}
|
|
343
|
-
if (
|
|
344
|
-
|
|
453
|
+
if (X.includes(n.key)) {
|
|
454
|
+
n.preventDefault();
|
|
345
455
|
return;
|
|
346
456
|
}
|
|
347
|
-
if (
|
|
348
|
-
|
|
457
|
+
if (n.key === "ArrowDown") {
|
|
458
|
+
n.stopPropagation(), n.preventDefault(), r.onOpenToggle();
|
|
349
459
|
return;
|
|
350
460
|
}
|
|
351
461
|
},
|
|
352
|
-
tgphRef:
|
|
353
|
-
children: /* @__PURE__ */
|
|
354
|
-
|
|
462
|
+
tgphRef: r.triggerRef,
|
|
463
|
+
children: /* @__PURE__ */ R(
|
|
464
|
+
B.Root,
|
|
355
465
|
{
|
|
356
|
-
id:
|
|
466
|
+
id: r.triggerId,
|
|
357
467
|
type: "button",
|
|
358
468
|
bg: "surface-1",
|
|
359
469
|
variant: "outline",
|
|
360
470
|
align: "center",
|
|
361
|
-
minH:
|
|
471
|
+
minH: ie[t],
|
|
362
472
|
h: "full",
|
|
363
473
|
w: "full",
|
|
364
474
|
py: "1",
|
|
365
|
-
size:
|
|
366
|
-
color:
|
|
475
|
+
size: t,
|
|
476
|
+
color: r.errored ? "red" : "gray",
|
|
367
477
|
justify: "space-between",
|
|
368
478
|
role: "combobox",
|
|
369
|
-
"aria-label":
|
|
370
|
-
"aria-controls":
|
|
371
|
-
"aria-expanded":
|
|
479
|
+
"aria-label": c(),
|
|
480
|
+
"aria-controls": r.contentId,
|
|
481
|
+
"aria-expanded": r.open,
|
|
372
482
|
"aria-haspopup": "listbox",
|
|
373
483
|
"data-tgph-combobox-trigger": !0,
|
|
374
|
-
"data-tgph-combobox-trigger-open":
|
|
375
|
-
disabled:
|
|
376
|
-
...
|
|
484
|
+
"data-tgph-combobox-trigger-open": r.open,
|
|
485
|
+
disabled: r.disabled,
|
|
486
|
+
...e,
|
|
377
487
|
children: [
|
|
378
|
-
|
|
379
|
-
/* @__PURE__ */
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
type: "button",
|
|
384
|
-
icon: { icon: E.X, alt: "Clear field" },
|
|
385
|
-
size: "1",
|
|
386
|
-
variant: "ghost",
|
|
387
|
-
onClick: (a) => {
|
|
388
|
-
t.value && (a.stopPropagation(), n());
|
|
389
|
-
},
|
|
390
|
-
onKeyDown: (a) => {
|
|
391
|
-
(a.key === "Enter" || a.key === " ") && (a.stopPropagation(), n());
|
|
392
|
-
},
|
|
393
|
-
"data-tgph-combobox-clear": !0,
|
|
394
|
-
style: {
|
|
395
|
-
// Remove margin to make the clear button flush
|
|
396
|
-
// with the trigger button
|
|
397
|
-
marginTop: "calc(-1 * var(--tgph-spacing-1)",
|
|
398
|
-
marginBottom: "calc(-1 * var(--tgph-spacing-1)"
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
) }),
|
|
402
|
-
/* @__PURE__ */ p(
|
|
403
|
-
I.Icon,
|
|
404
|
-
{
|
|
405
|
-
as: B.span,
|
|
406
|
-
animate: { rotate: t.open ? 180 : 0 },
|
|
407
|
-
transition: { duration: 150, type: "spring" },
|
|
408
|
-
icon: E.ChevronDown,
|
|
409
|
-
"aria-hidden": !0
|
|
410
|
-
}
|
|
411
|
-
)
|
|
488
|
+
o ? typeof o == "function" ? o({ value: a }) : o : /* @__PURE__ */ l(Ce, {}),
|
|
489
|
+
/* @__PURE__ */ R(I, { align: "center", gap: "1", children: [
|
|
490
|
+
/* @__PURE__ */ l(T.TriggerClear, {}),
|
|
491
|
+
/* @__PURE__ */ l(T.TriggerIndicator, {})
|
|
412
492
|
] })
|
|
413
493
|
]
|
|
414
494
|
}
|
|
415
495
|
)
|
|
416
496
|
}
|
|
417
497
|
);
|
|
418
|
-
},
|
|
419
|
-
style:
|
|
420
|
-
children:
|
|
421
|
-
tgphRef:
|
|
422
|
-
...
|
|
498
|
+
}, Re = ({
|
|
499
|
+
style: t,
|
|
500
|
+
children: o,
|
|
501
|
+
tgphRef: e,
|
|
502
|
+
...r
|
|
423
503
|
}) => {
|
|
424
|
-
const
|
|
504
|
+
const a = s.useContext(y), c = s.useRef(!1), n = $(e, a.contentRef), i = s.useRef(null), [p, g] = s.useState(0), [b, v] = s.useState(!1), d = s.useCallback(
|
|
425
505
|
(u) => {
|
|
426
|
-
const
|
|
427
|
-
|
|
506
|
+
const f = u == null ? void 0 : u.getBoundingClientRect();
|
|
507
|
+
f && g(f.height), b || v(!0);
|
|
428
508
|
},
|
|
429
|
-
[
|
|
509
|
+
[b]
|
|
430
510
|
);
|
|
431
511
|
return s.useEffect(() => {
|
|
432
|
-
const u = new ResizeObserver((
|
|
433
|
-
for (const
|
|
434
|
-
const
|
|
435
|
-
|
|
512
|
+
const u = new ResizeObserver((f) => {
|
|
513
|
+
for (const m of f) {
|
|
514
|
+
const x = m.target;
|
|
515
|
+
d(x);
|
|
436
516
|
}
|
|
437
517
|
});
|
|
438
|
-
return
|
|
439
|
-
}, [
|
|
440
|
-
|
|
441
|
-
}, [
|
|
518
|
+
return i.current && b && u.observe(i.current), () => u.disconnect();
|
|
519
|
+
}, [b, d]), s.useEffect(() => {
|
|
520
|
+
b === !0 && a.open === !1 && v(!1);
|
|
521
|
+
}, [a.open, b]), s.useEffect(() => {
|
|
442
522
|
let u;
|
|
443
|
-
return
|
|
444
|
-
|
|
523
|
+
return a.open && (u = setTimeout(() => {
|
|
524
|
+
d(i.current);
|
|
445
525
|
}, 10)), () => u && clearTimeout(u);
|
|
446
|
-
}, [
|
|
447
|
-
|
|
526
|
+
}, [a.open, d]), /* @__PURE__ */ l(ee.Root, { asChild: !0, children: /* @__PURE__ */ l(
|
|
527
|
+
Z,
|
|
448
528
|
{
|
|
449
529
|
onEscapeKeyDown: (u) => {
|
|
450
|
-
|
|
530
|
+
a.open && (u.stopPropagation(), u.preventDefault(), a.setOpen(!1));
|
|
451
531
|
},
|
|
452
|
-
children: /* @__PURE__ */
|
|
532
|
+
children: /* @__PURE__ */ l(
|
|
453
533
|
Q.Content,
|
|
454
534
|
{
|
|
455
535
|
className: "tgph",
|
|
456
536
|
mt: "1",
|
|
457
537
|
onCloseAutoFocus: (u) => {
|
|
458
|
-
var
|
|
459
|
-
|
|
538
|
+
var f, m;
|
|
539
|
+
c.current || (m = (f = a.triggerRef) == null ? void 0 : f.current) == null || m.focus(), c.current = !1, u.preventDefault();
|
|
460
540
|
},
|
|
461
541
|
bg: "surface-1",
|
|
462
542
|
style: {
|
|
463
543
|
width: "var(--tgph-combobox-trigger-width)",
|
|
464
544
|
transition: "min-height 200ms ease-in-out",
|
|
465
|
-
minHeight:
|
|
466
|
-
...
|
|
545
|
+
minHeight: p ? `${p}px` : "0",
|
|
546
|
+
...t,
|
|
467
547
|
"--tgph-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
468
548
|
"--tgph-combobox-content-available-width": "var(--radix-popper-available-width)",
|
|
469
549
|
"--tgph-combobox-content-available-height": "calc(var(--radix-popper-available-height) - var(--tgph-spacing-8))",
|
|
470
550
|
"--tgph-combobox-trigger-width": "var(--radix-popper-anchor-width)",
|
|
471
551
|
"--tgph-combobox-trigger-height": "var(--radix-popper-anchor-height)"
|
|
472
552
|
},
|
|
473
|
-
...
|
|
474
|
-
tgphRef:
|
|
553
|
+
...r,
|
|
554
|
+
tgphRef: n,
|
|
475
555
|
"data-tgph-combobox-content": !0,
|
|
476
|
-
"data-tgph-combobox-content-open":
|
|
556
|
+
"data-tgph-combobox-content-open": a.open,
|
|
477
557
|
role: void 0,
|
|
478
558
|
"aria-orientation": void 0,
|
|
479
559
|
onKeyDown: (u) => {
|
|
480
|
-
var
|
|
560
|
+
var m, x, h, w;
|
|
481
561
|
u.stopPropagation();
|
|
482
|
-
const
|
|
562
|
+
const f = (x = (m = a.contentRef) == null ? void 0 : m.current) == null ? void 0 : x.querySelectorAll(
|
|
483
563
|
"[data-tgph-combobox-option]"
|
|
484
564
|
);
|
|
485
|
-
document.activeElement === (
|
|
565
|
+
document.activeElement === (f == null ? void 0 : f[0]) && xe.includes(u.key) && ((w = (h = a.searchRef) == null ? void 0 : h.current) == null || w.focus());
|
|
486
566
|
},
|
|
487
|
-
children: /* @__PURE__ */
|
|
567
|
+
children: /* @__PURE__ */ l(I, { direction: "column", gap: "1", tgphRef: i, children: o })
|
|
488
568
|
}
|
|
489
569
|
)
|
|
490
570
|
}
|
|
491
571
|
) });
|
|
492
|
-
},
|
|
493
|
-
const
|
|
494
|
-
return /* @__PURE__ */
|
|
495
|
-
|
|
572
|
+
}, Se = ({ ...t }) => {
|
|
573
|
+
const o = s.useContext(y);
|
|
574
|
+
return /* @__PURE__ */ l(
|
|
575
|
+
I,
|
|
496
576
|
{
|
|
497
|
-
id:
|
|
577
|
+
id: o.contentId,
|
|
498
578
|
direction: "column",
|
|
499
579
|
gap: "1",
|
|
500
580
|
style: {
|
|
501
581
|
overflowY: "auto",
|
|
502
582
|
// maxHeight defaults to available height - padding from edge of screen
|
|
503
|
-
"--max-height":
|
|
583
|
+
"--max-height": t.maxHeight ? void 0 : "calc(var(--tgph-combobox-content-available-height) - var(--tgph-spacing-12))"
|
|
504
584
|
},
|
|
505
585
|
role: "listbox",
|
|
506
|
-
...
|
|
586
|
+
...t
|
|
507
587
|
}
|
|
508
588
|
);
|
|
509
|
-
},
|
|
510
|
-
value:
|
|
511
|
-
label:
|
|
512
|
-
selected:
|
|
513
|
-
onSelect:
|
|
514
|
-
children:
|
|
515
|
-
...
|
|
589
|
+
}, q = ({
|
|
590
|
+
value: t,
|
|
591
|
+
label: o,
|
|
592
|
+
selected: e,
|
|
593
|
+
onSelect: r,
|
|
594
|
+
children: a,
|
|
595
|
+
...c
|
|
516
596
|
}) => {
|
|
517
|
-
const
|
|
518
|
-
children:
|
|
519
|
-
value:
|
|
520
|
-
searchQuery:
|
|
521
|
-
}), v =
|
|
522
|
-
(u) => C(u,
|
|
523
|
-
) : C(
|
|
524
|
-
var
|
|
597
|
+
const n = s.useContext(y), [i, p] = s.useState(!1), g = n.value, b = !n.searchQuery || se({
|
|
598
|
+
children: o || a,
|
|
599
|
+
value: t,
|
|
600
|
+
searchQuery: n.searchQuery
|
|
601
|
+
}), v = S(g) ? g.some(
|
|
602
|
+
(u) => C(u, n.legacyBehavior) === t
|
|
603
|
+
) : C(g, n.legacyBehavior) === t, d = (u) => {
|
|
604
|
+
var m, x;
|
|
525
605
|
u.stopPropagation();
|
|
526
|
-
const
|
|
527
|
-
if (!(
|
|
528
|
-
if (u.preventDefault(),
|
|
529
|
-
return
|
|
530
|
-
if (k(
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
} else if (
|
|
534
|
-
const
|
|
535
|
-
(
|
|
606
|
+
const f = u;
|
|
607
|
+
if (!(f.key && !X.includes(f.key))) {
|
|
608
|
+
if (u.preventDefault(), n.closeOnSelect === !0 && n.setOpen(!1), r)
|
|
609
|
+
return r(u);
|
|
610
|
+
if (k(g)) {
|
|
611
|
+
const h = n.onValueChange;
|
|
612
|
+
n.legacyBehavior === !0 ? h == null || h({ value: t, label: o }) : h == null || h(t);
|
|
613
|
+
} else if (S(g)) {
|
|
614
|
+
const h = n.onValueChange, w = n.value, L = v ? w.filter(
|
|
615
|
+
(V) => C(V, n.legacyBehavior) !== t
|
|
536
616
|
) : [
|
|
537
617
|
...w,
|
|
538
618
|
// TODO: Remove this once { value, label } option is deprecated
|
|
539
|
-
|
|
619
|
+
n.legacyBehavior === !0 ? { value: t, label: o } : t
|
|
540
620
|
];
|
|
541
|
-
|
|
621
|
+
h == null || h(L);
|
|
542
622
|
}
|
|
543
|
-
(
|
|
623
|
+
(x = (m = n.triggerRef) == null ? void 0 : m.current) == null || x.focus();
|
|
544
624
|
}
|
|
545
625
|
};
|
|
546
|
-
if (
|
|
547
|
-
return /* @__PURE__ */
|
|
626
|
+
if (b)
|
|
627
|
+
return /* @__PURE__ */ l(
|
|
548
628
|
Q.Button,
|
|
549
629
|
{
|
|
550
630
|
type: "button",
|
|
551
|
-
onSelect:
|
|
552
|
-
onKeyDown:
|
|
553
|
-
selected:
|
|
554
|
-
onFocus: () =>
|
|
555
|
-
onBlur: () =>
|
|
631
|
+
onSelect: d,
|
|
632
|
+
onKeyDown: d,
|
|
633
|
+
selected: e === null ? null : e ?? v,
|
|
634
|
+
onFocus: () => p(!0),
|
|
635
|
+
onBlur: () => p(!1),
|
|
556
636
|
role: "option",
|
|
557
637
|
"aria-selected": v ? "true" : "false",
|
|
558
638
|
"data-tgph-combobox-option": !0,
|
|
559
|
-
"data-tgph-combobox-option-focused":
|
|
560
|
-
"data-tgph-combobox-option-value":
|
|
561
|
-
"data-tgph-combobox-option-label":
|
|
562
|
-
...
|
|
563
|
-
children:
|
|
639
|
+
"data-tgph-combobox-option-focused": i,
|
|
640
|
+
"data-tgph-combobox-option-value": t,
|
|
641
|
+
"data-tgph-combobox-option-label": o,
|
|
642
|
+
...c,
|
|
643
|
+
children: o || a || t
|
|
564
644
|
}
|
|
565
645
|
);
|
|
566
|
-
},
|
|
567
|
-
label:
|
|
568
|
-
placeholder:
|
|
569
|
-
tgphRef:
|
|
570
|
-
value:
|
|
571
|
-
onValueChange:
|
|
572
|
-
...
|
|
646
|
+
}, we = ({
|
|
647
|
+
label: t = "Search",
|
|
648
|
+
placeholder: o = "Search",
|
|
649
|
+
tgphRef: e,
|
|
650
|
+
value: r,
|
|
651
|
+
onValueChange: a,
|
|
652
|
+
...c
|
|
573
653
|
}) => {
|
|
574
654
|
var v;
|
|
575
|
-
const
|
|
655
|
+
const n = s.useId(), i = s.useContext(y), p = $(e, i.searchRef), g = r ?? i.searchQuery, b = a ?? i.setSearchQuery;
|
|
576
656
|
return s.useEffect(() => {
|
|
577
|
-
var
|
|
578
|
-
const
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
}, u = (
|
|
657
|
+
var f;
|
|
658
|
+
const d = (m) => {
|
|
659
|
+
var x, h;
|
|
660
|
+
be.includes(m.key) && ((h = (x = i.contentRef) == null ? void 0 : x.current) == null || h.focus({ preventScroll: !0 })), m.key === "Escape" && i.setOpen(!1), m.stopPropagation();
|
|
661
|
+
}, u = (f = i.searchRef) == null ? void 0 : f.current;
|
|
582
662
|
if (u)
|
|
583
|
-
return u.addEventListener("keydown",
|
|
584
|
-
u.removeEventListener("keydown",
|
|
663
|
+
return u.addEventListener("keydown", d), () => {
|
|
664
|
+
u.removeEventListener("keydown", d);
|
|
585
665
|
};
|
|
586
|
-
}, [
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
|
|
666
|
+
}, [i]), /* @__PURE__ */ R(G, { borderBottom: "px", px: "1", pb: "1", children: [
|
|
667
|
+
/* @__PURE__ */ l(oe.Root, { children: /* @__PURE__ */ l(H, { as: "label", htmlFor: n, children: t }) }),
|
|
668
|
+
/* @__PURE__ */ l(
|
|
669
|
+
ne,
|
|
590
670
|
{
|
|
591
|
-
id:
|
|
671
|
+
id: n,
|
|
592
672
|
variant: "ghost",
|
|
593
|
-
placeholder:
|
|
594
|
-
value:
|
|
595
|
-
onChange: (
|
|
596
|
-
|
|
673
|
+
placeholder: o,
|
|
674
|
+
value: g,
|
|
675
|
+
onChange: (d) => {
|
|
676
|
+
b(d.target.value);
|
|
597
677
|
},
|
|
598
|
-
LeadingComponent: /* @__PURE__ */
|
|
599
|
-
TrailingComponent:
|
|
600
|
-
|
|
678
|
+
LeadingComponent: /* @__PURE__ */ l(z, { icon: E.Search, alt: "Search Icon" }),
|
|
679
|
+
TrailingComponent: i != null && i.searchQuery && ((v = i == null ? void 0 : i.searchQuery) == null ? void 0 : v.length) > 0 ? /* @__PURE__ */ l(
|
|
680
|
+
B,
|
|
601
681
|
{
|
|
602
682
|
variant: "ghost",
|
|
603
683
|
color: "gray",
|
|
604
684
|
icon: { icon: E.X, alt: "Clear Search Query" },
|
|
605
685
|
onClick: () => {
|
|
606
|
-
var
|
|
607
|
-
return (
|
|
686
|
+
var d;
|
|
687
|
+
return (d = i.setSearchQuery) == null ? void 0 : d.call(i, "");
|
|
608
688
|
}
|
|
609
689
|
}
|
|
610
690
|
) : null,
|
|
611
691
|
autoFocus: !0,
|
|
612
692
|
"data-tgph-combobox-search": !0,
|
|
613
|
-
"aria-controls":
|
|
614
|
-
...
|
|
615
|
-
tgphRef:
|
|
693
|
+
"aria-controls": i.contentId,
|
|
694
|
+
...c,
|
|
695
|
+
tgphRef: p
|
|
616
696
|
}
|
|
617
697
|
)
|
|
618
698
|
] });
|
|
619
|
-
},
|
|
620
|
-
icon:
|
|
621
|
-
message:
|
|
622
|
-
children:
|
|
623
|
-
...
|
|
699
|
+
}, Ee = ({
|
|
700
|
+
icon: t = { icon: E.Search, alt: "Search Icon" },
|
|
701
|
+
message: o = "No results found",
|
|
702
|
+
children: e,
|
|
703
|
+
...r
|
|
624
704
|
}) => {
|
|
625
|
-
const
|
|
705
|
+
const a = s.useContext(y), [c, n] = s.useState(!1);
|
|
626
706
|
if (s.useEffect(() => {
|
|
627
|
-
var
|
|
628
|
-
const
|
|
707
|
+
var p, g;
|
|
708
|
+
const i = (g = (p = a.contentRef) == null ? void 0 : p.current) == null ? void 0 : g.querySelectorAll(
|
|
629
709
|
"[data-tgph-combobox-option]"
|
|
630
710
|
);
|
|
631
|
-
(
|
|
632
|
-
}, [
|
|
633
|
-
return /* @__PURE__ */
|
|
634
|
-
|
|
711
|
+
(i == null ? void 0 : i.length) === 0 ? n(!0) : n(!1);
|
|
712
|
+
}, [a.searchQuery, a.contentRef, e]), c)
|
|
713
|
+
return /* @__PURE__ */ R(
|
|
714
|
+
I,
|
|
635
715
|
{
|
|
636
716
|
gap: "1",
|
|
637
717
|
align: "center",
|
|
@@ -639,58 +719,59 @@ const ne = {
|
|
|
639
719
|
w: "full",
|
|
640
720
|
my: "8",
|
|
641
721
|
"data-tgph-combobox-empty": !0,
|
|
642
|
-
...
|
|
722
|
+
...r,
|
|
643
723
|
children: [
|
|
644
|
-
|
|
645
|
-
|
|
724
|
+
t === null ? /* @__PURE__ */ l(_, {}) : /* @__PURE__ */ l(z, { ...t }),
|
|
725
|
+
o === null ? /* @__PURE__ */ l(_, {}) : /* @__PURE__ */ l(H, { as: "span", children: o })
|
|
646
726
|
]
|
|
647
727
|
}
|
|
648
728
|
);
|
|
649
|
-
},
|
|
650
|
-
leadingText:
|
|
651
|
-
values:
|
|
652
|
-
onCreate:
|
|
653
|
-
selected:
|
|
654
|
-
legacyBehavior:
|
|
655
|
-
...
|
|
729
|
+
}, ke = ({
|
|
730
|
+
leadingText: t = "Create",
|
|
731
|
+
values: o,
|
|
732
|
+
onCreate: e,
|
|
733
|
+
selected: r = null,
|
|
734
|
+
legacyBehavior: a = !1,
|
|
735
|
+
...c
|
|
656
736
|
}) => {
|
|
657
|
-
const
|
|
658
|
-
(
|
|
659
|
-
(
|
|
737
|
+
const n = s.useContext(y), i = s.useCallback(
|
|
738
|
+
(p) => !o || (o == null ? void 0 : o.length) === 0 ? !1 : o.some(
|
|
739
|
+
(g) => C(g, a) === p
|
|
660
740
|
),
|
|
661
|
-
[
|
|
741
|
+
[o, a]
|
|
662
742
|
);
|
|
663
|
-
if (
|
|
664
|
-
return /* @__PURE__ */
|
|
665
|
-
|
|
743
|
+
if (n.searchQuery && !i(n.searchQuery))
|
|
744
|
+
return /* @__PURE__ */ l(
|
|
745
|
+
q,
|
|
666
746
|
{
|
|
667
747
|
leadingIcon: { icon: E.Plus, "aria-hidden": !0 },
|
|
668
748
|
mx: "1",
|
|
669
|
-
value:
|
|
670
|
-
label: `${
|
|
671
|
-
selected:
|
|
749
|
+
value: n.searchQuery,
|
|
750
|
+
label: `${t} "${n.searchQuery}"`,
|
|
751
|
+
selected: r,
|
|
672
752
|
onSelect: () => {
|
|
673
|
-
var
|
|
674
|
-
if (
|
|
675
|
-
const
|
|
676
|
-
|
|
753
|
+
var p;
|
|
754
|
+
if (e && n.value && n.searchQuery) {
|
|
755
|
+
const g = a === !0 ? { value: n.searchQuery } : n.searchQuery;
|
|
756
|
+
e(g), (p = n.setSearchQuery) == null || p.call(n, "");
|
|
677
757
|
}
|
|
678
758
|
},
|
|
679
|
-
...
|
|
759
|
+
...c
|
|
680
760
|
}
|
|
681
761
|
);
|
|
682
|
-
},
|
|
683
|
-
Object.assign(
|
|
684
|
-
Root:
|
|
685
|
-
Trigger:
|
|
686
|
-
Content:
|
|
687
|
-
Options:
|
|
688
|
-
Option:
|
|
689
|
-
Search:
|
|
690
|
-
Empty:
|
|
691
|
-
Create:
|
|
762
|
+
}, Ie = {};
|
|
763
|
+
Object.assign(Ie, {
|
|
764
|
+
Root: ve,
|
|
765
|
+
Trigger: Te,
|
|
766
|
+
Content: Re,
|
|
767
|
+
Options: Se,
|
|
768
|
+
Option: q,
|
|
769
|
+
Search: we,
|
|
770
|
+
Empty: Ee,
|
|
771
|
+
Create: ke,
|
|
772
|
+
Primitives: T
|
|
692
773
|
});
|
|
693
774
|
export {
|
|
694
|
-
|
|
775
|
+
Ie as Combobox
|
|
695
776
|
};
|
|
696
777
|
//# sourceMappingURL=index.mjs.map
|