@telegraph/combobox 0.0.76 → 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 +28 -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 +536 -462
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/Combobox/Combobox.d.ts +26 -5
- 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 +10 -10
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
|
|
10
|
-
import { Input as
|
|
11
|
-
import { Stack as I, Box 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
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
const
|
|
13
|
+
import { Text as H } from "@telegraph/typography";
|
|
14
|
+
import s from "react";
|
|
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
|
-
|
|
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
26
|
}), c);
|
|
27
|
-
return
|
|
28
|
-
var
|
|
29
|
-
const c =
|
|
27
|
+
return o(t).map((a) => {
|
|
28
|
+
var n;
|
|
29
|
+
const c = a;
|
|
30
30
|
return {
|
|
31
31
|
value: c.props.value,
|
|
32
|
-
label: ((
|
|
32
|
+
label: ((n = c.props) == null ? void 0 : n.label) || c.props.children || c.props.value
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
|
-
}, C = (t,
|
|
35
|
+
}, C = (t, o) => {
|
|
36
36
|
if (t)
|
|
37
|
-
return
|
|
38
|
-
}, F = (t,
|
|
39
|
-
if (!t || !
|
|
40
|
-
const
|
|
41
|
-
(
|
|
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
42
|
);
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
},
|
|
43
|
+
if (r)
|
|
44
|
+
return r;
|
|
45
|
+
}, se = ({
|
|
46
46
|
children: t,
|
|
47
|
-
value:
|
|
47
|
+
value: o,
|
|
48
48
|
searchQuery: e
|
|
49
49
|
}) => {
|
|
50
|
-
const
|
|
51
|
-
return (
|
|
52
|
-
(
|
|
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
53
|
);
|
|
54
|
-
},
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
typeof
|
|
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
58
|
}), e;
|
|
59
|
-
},
|
|
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
|
|
153
|
+
}) => {
|
|
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
|
+
}
|
|
246
|
+
);
|
|
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,405 +339,210 @@ const ne = {
|
|
|
71
339
|
disabled: !1,
|
|
72
340
|
options: [],
|
|
73
341
|
legacyBehavior: !1
|
|
74
|
-
}),
|
|
342
|
+
}), ve = ({
|
|
75
343
|
modal: t = !0,
|
|
76
|
-
closeOnSelect:
|
|
344
|
+
closeOnSelect: o = !0,
|
|
77
345
|
clearable: e = !1,
|
|
78
|
-
disabled:
|
|
79
|
-
legacyBehavior:
|
|
346
|
+
disabled: r = !1,
|
|
347
|
+
legacyBehavior: a = !1,
|
|
80
348
|
open: c,
|
|
81
|
-
onOpenChange:
|
|
82
|
-
defaultOpen:
|
|
83
|
-
value:
|
|
84
|
-
onValueChange:
|
|
85
|
-
errored:
|
|
349
|
+
onOpenChange: n,
|
|
350
|
+
defaultOpen: i,
|
|
351
|
+
value: p,
|
|
352
|
+
onValueChange: g,
|
|
353
|
+
errored: b,
|
|
86
354
|
placeholder: v,
|
|
87
355
|
layout: d,
|
|
88
356
|
children: u,
|
|
89
|
-
...
|
|
357
|
+
...f
|
|
90
358
|
}) => {
|
|
91
|
-
const m =
|
|
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({
|
|
92
360
|
prop: c,
|
|
93
|
-
defaultProp:
|
|
94
|
-
onChange:
|
|
95
|
-
}),
|
|
96
|
-
A((
|
|
361
|
+
defaultProp: i,
|
|
362
|
+
onChange: n
|
|
363
|
+
}), W = s.useCallback(() => {
|
|
364
|
+
A((J) => !J);
|
|
97
365
|
}, [A]);
|
|
98
|
-
return
|
|
99
|
-
O ||
|
|
100
|
-
}, [O]), /* @__PURE__ */
|
|
101
|
-
|
|
366
|
+
return s.useEffect(() => {
|
|
367
|
+
O || N("");
|
|
368
|
+
}, [O]), /* @__PURE__ */ l(
|
|
369
|
+
y.Provider,
|
|
102
370
|
{
|
|
103
371
|
value: {
|
|
104
372
|
contentId: m,
|
|
105
|
-
triggerId:
|
|
106
|
-
value:
|
|
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:
|
|
382
|
+
onOpenToggle: W,
|
|
383
|
+
closeOnSelect: o,
|
|
116
384
|
clearable: e,
|
|
117
|
-
disabled:
|
|
118
|
-
searchQuery:
|
|
119
|
-
setSearchQuery:
|
|
385
|
+
disabled: r,
|
|
386
|
+
searchQuery: U,
|
|
387
|
+
setSearchQuery: N,
|
|
120
388
|
triggerRef: h,
|
|
121
389
|
searchRef: w,
|
|
122
|
-
contentRef:
|
|
123
|
-
errored:
|
|
390
|
+
contentRef: L,
|
|
391
|
+
errored: b,
|
|
124
392
|
layout: d,
|
|
125
|
-
options:
|
|
126
|
-
legacyBehavior:
|
|
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
401
|
modal: t,
|
|
134
|
-
...
|
|
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 o;
|
|
150
|
-
}, [e.options, e.value, t, e.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": t,
|
|
161
|
-
size: "1",
|
|
162
|
-
layout: "position",
|
|
163
|
-
...a,
|
|
164
|
-
children: [
|
|
165
|
-
/* @__PURE__ */ p(L.Text, { children: l }),
|
|
166
|
-
/* @__PURE__ */ p(
|
|
167
|
-
L.Button,
|
|
168
|
-
{
|
|
169
|
-
icon: { icon: R.X, alt: `Remove ${t}` },
|
|
170
|
-
onClick: (r) => {
|
|
171
|
-
if (!e.onValueChange) return;
|
|
172
|
-
const c = e.onValueChange, n = e.value.filter((s) => C(s, e.legacyBehavior) !== t);
|
|
173
|
-
c == null || c(n), r.stopPropagation(), r.preventDefault();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
}, ue = () => {
|
|
181
|
-
var a;
|
|
182
|
-
const t = i.useContext(x);
|
|
183
|
-
if (t.value && k(t.value)) {
|
|
184
|
-
const e = t.layout || "truncate", l = t.value.length - 2, r = l.toString().split("");
|
|
185
|
-
return t.value.length === 0 ? /* @__PURE__ */ p(E.Text, { color: "gray", children: t.placeholder }) : /* @__PURE__ */ S(
|
|
186
|
-
I,
|
|
187
|
-
{
|
|
188
|
-
gap: "1",
|
|
189
|
-
w: "full",
|
|
190
|
-
wrap: e === "wrap" ? "wrap" : "nowrap",
|
|
191
|
-
align: "center",
|
|
192
|
-
style: {
|
|
193
|
-
position: "relative",
|
|
194
|
-
flexGrow: 1
|
|
195
|
-
},
|
|
196
|
-
children: [
|
|
197
|
-
/* @__PURE__ */ p(
|
|
198
|
-
P,
|
|
199
|
-
{
|
|
200
|
-
presenceMap: t.value.map((c) => ({
|
|
201
|
-
"tgph-motion-key": C(c, t.legacyBehavior) || "",
|
|
202
|
-
value: !0
|
|
203
|
-
})),
|
|
204
|
-
children: t.value.map((c, o) => {
|
|
205
|
-
const n = C(c, t.legacyBehavior);
|
|
206
|
-
if (n && (e === "truncate" && o <= 1 || e === "wrap"))
|
|
207
|
-
return /* @__PURE__ */ p(ee, { children: /* @__PURE__ */ p(le, { value: n }) }, n);
|
|
208
|
-
})
|
|
209
|
-
}
|
|
210
|
-
),
|
|
211
|
-
/* @__PURE__ */ p(
|
|
212
|
-
P,
|
|
213
|
-
{
|
|
214
|
-
presenceMap: [
|
|
215
|
-
{
|
|
216
|
-
"tgph-motion-key": "combobox-more",
|
|
217
|
-
value: !0
|
|
218
|
-
}
|
|
219
|
-
],
|
|
220
|
-
children: e === "truncate" && t.value.length > 2 && /* @__PURE__ */ p(
|
|
221
|
-
I,
|
|
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": `${l} 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
|
-
P,
|
|
242
|
-
{
|
|
243
|
-
presenceMap: r.map((c) => ({
|
|
244
|
-
"tgph-motion-key": c,
|
|
245
|
-
value: !0
|
|
246
|
-
})),
|
|
247
|
-
children: [
|
|
248
|
-
r.map((c) => /* @__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": c,
|
|
259
|
-
children: c
|
|
260
|
-
},
|
|
261
|
-
c
|
|
262
|
-
)),
|
|
263
|
-
" "
|
|
264
|
-
]
|
|
265
|
-
}
|
|
266
|
-
),
|
|
267
|
-
"more"
|
|
268
|
-
] })
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
);
|
|
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
|
+
}) });
|
|
276
417
|
}
|
|
277
|
-
if (t &&
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var o;
|
|
296
|
-
if (!e.value) return e.placeholder;
|
|
297
|
-
if (T(e.value)) {
|
|
298
|
-
const n = F(
|
|
299
|
-
e.value,
|
|
300
|
-
e.options,
|
|
301
|
-
e.legacyBehavior
|
|
302
|
-
);
|
|
303
|
-
return (n == null ? void 0 : n.label) || e.placeholder;
|
|
304
|
-
}
|
|
305
|
-
if (k(e.value))
|
|
306
|
-
return ((o = e.value) == null ? void 0 : o.map((n) => {
|
|
307
|
-
const s = F(
|
|
308
|
-
n,
|
|
309
|
-
e.options,
|
|
310
|
-
e.legacyBehavior
|
|
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
|
|
424
|
+
}) => {
|
|
425
|
+
const r = s.useContext(y), a = s.useMemo(() => {
|
|
426
|
+
if (r.value) {
|
|
427
|
+
if (k(r.value))
|
|
428
|
+
return F(
|
|
429
|
+
r.value,
|
|
430
|
+
r.options,
|
|
431
|
+
r.legacyBehavior
|
|
432
|
+
);
|
|
433
|
+
if (S(r.value))
|
|
434
|
+
return r.value.map(
|
|
435
|
+
(n) => F(n, r.options, r.legacyBehavior)
|
|
311
436
|
);
|
|
312
|
-
return s == null ? void 0 : s.label;
|
|
313
|
-
}).join(", ")) || e.placeholder;
|
|
314
|
-
}, [
|
|
315
|
-
e.value,
|
|
316
|
-
e.placeholder,
|
|
317
|
-
e.options,
|
|
318
|
-
e.legacyBehavior
|
|
319
|
-
]), r = i.useMemo(() => {
|
|
320
|
-
var o;
|
|
321
|
-
if (T(e.value))
|
|
322
|
-
return e.clearable && e.value;
|
|
323
|
-
if (k(e.value))
|
|
324
|
-
return e.clearable && ((o = e.value) == null ? void 0 : o.length) > 0;
|
|
325
|
-
}, [e.clearable, e.value]), c = () => {
|
|
326
|
-
var o, n;
|
|
327
|
-
if (k(e.value)) {
|
|
328
|
-
const s = e.onValueChange;
|
|
329
|
-
s == null || s([]);
|
|
330
|
-
}
|
|
331
|
-
if (T(e.value)) {
|
|
332
|
-
const s = e.onValueChange;
|
|
333
|
-
s == null || s(void 0);
|
|
334
437
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
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(
|
|
338
440
|
Q.Trigger,
|
|
339
441
|
{
|
|
340
|
-
...
|
|
442
|
+
...e,
|
|
341
443
|
asChild: !0,
|
|
342
|
-
onClick: (
|
|
343
|
-
var
|
|
344
|
-
|
|
444
|
+
onClick: (n) => {
|
|
445
|
+
var i, p;
|
|
446
|
+
n.preventDefault(), r.onOpenToggle(), (p = (i = r.triggerRef) == null ? void 0 : i.current) == null || p.focus();
|
|
345
447
|
},
|
|
346
|
-
onKeyDown: (
|
|
347
|
-
if (
|
|
348
|
-
|
|
448
|
+
onKeyDown: (n) => {
|
|
449
|
+
if (n.key === "Tab") {
|
|
450
|
+
n.stopPropagation();
|
|
349
451
|
return;
|
|
350
452
|
}
|
|
351
|
-
if (
|
|
352
|
-
|
|
453
|
+
if (X.includes(n.key)) {
|
|
454
|
+
n.preventDefault();
|
|
353
455
|
return;
|
|
354
456
|
}
|
|
355
|
-
if (
|
|
356
|
-
|
|
457
|
+
if (n.key === "ArrowDown") {
|
|
458
|
+
n.stopPropagation(), n.preventDefault(), r.onOpenToggle();
|
|
357
459
|
return;
|
|
358
460
|
}
|
|
359
461
|
},
|
|
360
|
-
tgphRef:
|
|
361
|
-
children: /* @__PURE__ */
|
|
362
|
-
|
|
462
|
+
tgphRef: r.triggerRef,
|
|
463
|
+
children: /* @__PURE__ */ R(
|
|
464
|
+
B.Root,
|
|
363
465
|
{
|
|
364
|
-
id:
|
|
466
|
+
id: r.triggerId,
|
|
365
467
|
type: "button",
|
|
366
468
|
bg: "surface-1",
|
|
367
469
|
variant: "outline",
|
|
368
470
|
align: "center",
|
|
369
|
-
minH:
|
|
471
|
+
minH: ie[t],
|
|
370
472
|
h: "full",
|
|
371
473
|
w: "full",
|
|
372
474
|
py: "1",
|
|
373
475
|
size: t,
|
|
374
|
-
color:
|
|
476
|
+
color: r.errored ? "red" : "gray",
|
|
375
477
|
justify: "space-between",
|
|
376
478
|
role: "combobox",
|
|
377
|
-
"aria-label":
|
|
378
|
-
"aria-controls":
|
|
379
|
-
"aria-expanded":
|
|
479
|
+
"aria-label": c(),
|
|
480
|
+
"aria-controls": r.contentId,
|
|
481
|
+
"aria-expanded": r.open,
|
|
380
482
|
"aria-haspopup": "listbox",
|
|
381
483
|
"data-tgph-combobox-trigger": !0,
|
|
382
|
-
"data-tgph-combobox-trigger-open":
|
|
383
|
-
disabled:
|
|
484
|
+
"data-tgph-combobox-trigger-open": r.open,
|
|
485
|
+
disabled: r.disabled,
|
|
486
|
+
...e,
|
|
384
487
|
children: [
|
|
385
|
-
/* @__PURE__ */
|
|
386
|
-
/* @__PURE__ */
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
{
|
|
390
|
-
type: "button",
|
|
391
|
-
icon: { icon: R.X, alt: "Clear field" },
|
|
392
|
-
size: "1",
|
|
393
|
-
variant: "ghost",
|
|
394
|
-
onClick: (o) => {
|
|
395
|
-
e.value && (o.stopPropagation(), c());
|
|
396
|
-
},
|
|
397
|
-
onKeyDown: (o) => {
|
|
398
|
-
(o.key === "Enter" || o.key === " ") && (o.stopPropagation(), c());
|
|
399
|
-
},
|
|
400
|
-
"data-tgph-combobox-clear": !0,
|
|
401
|
-
style: {
|
|
402
|
-
// Remove margin to make the clear button flush
|
|
403
|
-
// with the trigger button
|
|
404
|
-
marginTop: "calc(-1 * var(--tgph-spacing-1)",
|
|
405
|
-
marginBottom: "calc(-1 * var(--tgph-spacing-1)"
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
) }),
|
|
409
|
-
/* @__PURE__ */ p(
|
|
410
|
-
E.Icon,
|
|
411
|
-
{
|
|
412
|
-
as: B.span,
|
|
413
|
-
animate: { rotate: e.open ? 180 : 0 },
|
|
414
|
-
transition: { duration: 150, type: "spring" },
|
|
415
|
-
icon: R.ChevronDown,
|
|
416
|
-
"aria-hidden": !0
|
|
417
|
-
}
|
|
418
|
-
)
|
|
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, {})
|
|
419
492
|
] })
|
|
420
493
|
]
|
|
421
494
|
}
|
|
422
495
|
)
|
|
423
496
|
}
|
|
424
497
|
);
|
|
425
|
-
},
|
|
498
|
+
}, Re = ({
|
|
426
499
|
style: t,
|
|
427
|
-
children:
|
|
500
|
+
children: o,
|
|
428
501
|
tgphRef: e,
|
|
429
|
-
...
|
|
502
|
+
...r
|
|
430
503
|
}) => {
|
|
431
|
-
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(
|
|
432
505
|
(u) => {
|
|
433
|
-
const
|
|
434
|
-
|
|
506
|
+
const f = u == null ? void 0 : u.getBoundingClientRect();
|
|
507
|
+
f && g(f.height), b || v(!0);
|
|
435
508
|
},
|
|
436
|
-
[
|
|
509
|
+
[b]
|
|
437
510
|
);
|
|
438
|
-
return
|
|
439
|
-
const u = new ResizeObserver((
|
|
440
|
-
for (const m of
|
|
441
|
-
const
|
|
442
|
-
d(
|
|
511
|
+
return s.useEffect(() => {
|
|
512
|
+
const u = new ResizeObserver((f) => {
|
|
513
|
+
for (const m of f) {
|
|
514
|
+
const x = m.target;
|
|
515
|
+
d(x);
|
|
443
516
|
}
|
|
444
517
|
});
|
|
445
|
-
return
|
|
446
|
-
}, [
|
|
447
|
-
|
|
448
|
-
}, [
|
|
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(() => {
|
|
449
522
|
let u;
|
|
450
|
-
return
|
|
451
|
-
d(
|
|
523
|
+
return a.open && (u = setTimeout(() => {
|
|
524
|
+
d(i.current);
|
|
452
525
|
}, 10)), () => u && clearTimeout(u);
|
|
453
|
-
}, [
|
|
454
|
-
|
|
526
|
+
}, [a.open, d]), /* @__PURE__ */ l(ee.Root, { asChild: !0, children: /* @__PURE__ */ l(
|
|
527
|
+
Z,
|
|
455
528
|
{
|
|
456
529
|
onEscapeKeyDown: (u) => {
|
|
457
|
-
|
|
530
|
+
a.open && (u.stopPropagation(), u.preventDefault(), a.setOpen(!1));
|
|
458
531
|
},
|
|
459
|
-
children: /* @__PURE__ */
|
|
532
|
+
children: /* @__PURE__ */ l(
|
|
460
533
|
Q.Content,
|
|
461
534
|
{
|
|
462
535
|
className: "tgph",
|
|
463
536
|
mt: "1",
|
|
464
537
|
onCloseAutoFocus: (u) => {
|
|
465
|
-
var
|
|
466
|
-
c.current || (m = (
|
|
538
|
+
var f, m;
|
|
539
|
+
c.current || (m = (f = a.triggerRef) == null ? void 0 : f.current) == null || m.focus(), c.current = !1, u.preventDefault();
|
|
467
540
|
},
|
|
468
541
|
bg: "surface-1",
|
|
469
542
|
style: {
|
|
470
543
|
width: "var(--tgph-combobox-trigger-width)",
|
|
471
544
|
transition: "min-height 200ms ease-in-out",
|
|
472
|
-
minHeight:
|
|
545
|
+
minHeight: p ? `${p}px` : "0",
|
|
473
546
|
...t,
|
|
474
547
|
"--tgph-combobox-content-transform-origin": "var(--radix-popper-transform-origin)",
|
|
475
548
|
"--tgph-combobox-content-available-width": "var(--radix-popper-available-width)",
|
|
@@ -477,31 +550,31 @@ const ne = {
|
|
|
477
550
|
"--tgph-combobox-trigger-width": "var(--radix-popper-anchor-width)",
|
|
478
551
|
"--tgph-combobox-trigger-height": "var(--radix-popper-anchor-height)"
|
|
479
552
|
},
|
|
480
|
-
...
|
|
481
|
-
tgphRef:
|
|
553
|
+
...r,
|
|
554
|
+
tgphRef: n,
|
|
482
555
|
"data-tgph-combobox-content": !0,
|
|
483
|
-
"data-tgph-combobox-content-open":
|
|
556
|
+
"data-tgph-combobox-content-open": a.open,
|
|
484
557
|
role: void 0,
|
|
485
558
|
"aria-orientation": void 0,
|
|
486
559
|
onKeyDown: (u) => {
|
|
487
|
-
var m,
|
|
560
|
+
var m, x, h, w;
|
|
488
561
|
u.stopPropagation();
|
|
489
|
-
const
|
|
562
|
+
const f = (x = (m = a.contentRef) == null ? void 0 : m.current) == null ? void 0 : x.querySelectorAll(
|
|
490
563
|
"[data-tgph-combobox-option]"
|
|
491
564
|
);
|
|
492
|
-
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());
|
|
493
566
|
},
|
|
494
|
-
children: /* @__PURE__ */
|
|
567
|
+
children: /* @__PURE__ */ l(I, { direction: "column", gap: "1", tgphRef: i, children: o })
|
|
495
568
|
}
|
|
496
569
|
)
|
|
497
570
|
}
|
|
498
571
|
) });
|
|
499
|
-
},
|
|
500
|
-
const
|
|
501
|
-
return /* @__PURE__ */
|
|
572
|
+
}, Se = ({ ...t }) => {
|
|
573
|
+
const o = s.useContext(y);
|
|
574
|
+
return /* @__PURE__ */ l(
|
|
502
575
|
I,
|
|
503
576
|
{
|
|
504
|
-
id:
|
|
577
|
+
id: o.contentId,
|
|
505
578
|
direction: "column",
|
|
506
579
|
gap: "1",
|
|
507
580
|
style: {
|
|
@@ -513,131 +586,131 @@ const ne = {
|
|
|
513
586
|
...t
|
|
514
587
|
}
|
|
515
588
|
);
|
|
516
|
-
},
|
|
589
|
+
}, q = ({
|
|
517
590
|
value: t,
|
|
518
|
-
label:
|
|
591
|
+
label: o,
|
|
519
592
|
selected: e,
|
|
520
|
-
onSelect:
|
|
521
|
-
children:
|
|
593
|
+
onSelect: r,
|
|
594
|
+
children: a,
|
|
522
595
|
...c
|
|
523
596
|
}) => {
|
|
524
|
-
const
|
|
525
|
-
children:
|
|
597
|
+
const n = s.useContext(y), [i, p] = s.useState(!1), g = n.value, b = !n.searchQuery || se({
|
|
598
|
+
children: o || a,
|
|
526
599
|
value: t,
|
|
527
|
-
searchQuery:
|
|
528
|
-
}), v =
|
|
529
|
-
(u) => C(u,
|
|
530
|
-
) : C(
|
|
531
|
-
var m,
|
|
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;
|
|
532
605
|
u.stopPropagation();
|
|
533
|
-
const
|
|
534
|
-
if (!(
|
|
535
|
-
if (u.preventDefault(),
|
|
536
|
-
return
|
|
537
|
-
if (
|
|
538
|
-
const h =
|
|
539
|
-
|
|
540
|
-
} else if (
|
|
541
|
-
const h =
|
|
542
|
-
(
|
|
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
|
|
543
616
|
) : [
|
|
544
617
|
...w,
|
|
545
618
|
// TODO: Remove this once { value, label } option is deprecated
|
|
546
|
-
|
|
619
|
+
n.legacyBehavior === !0 ? { value: t, label: o } : t
|
|
547
620
|
];
|
|
548
|
-
h == null || h(
|
|
621
|
+
h == null || h(L);
|
|
549
622
|
}
|
|
550
|
-
(
|
|
623
|
+
(x = (m = n.triggerRef) == null ? void 0 : m.current) == null || x.focus();
|
|
551
624
|
}
|
|
552
625
|
};
|
|
553
|
-
if (
|
|
554
|
-
return /* @__PURE__ */
|
|
626
|
+
if (b)
|
|
627
|
+
return /* @__PURE__ */ l(
|
|
555
628
|
Q.Button,
|
|
556
629
|
{
|
|
557
630
|
type: "button",
|
|
558
631
|
onSelect: d,
|
|
559
632
|
onKeyDown: d,
|
|
560
633
|
selected: e === null ? null : e ?? v,
|
|
561
|
-
onFocus: () =>
|
|
562
|
-
onBlur: () =>
|
|
634
|
+
onFocus: () => p(!0),
|
|
635
|
+
onBlur: () => p(!1),
|
|
563
636
|
role: "option",
|
|
564
637
|
"aria-selected": v ? "true" : "false",
|
|
565
638
|
"data-tgph-combobox-option": !0,
|
|
566
|
-
"data-tgph-combobox-option-focused":
|
|
639
|
+
"data-tgph-combobox-option-focused": i,
|
|
567
640
|
"data-tgph-combobox-option-value": t,
|
|
568
|
-
"data-tgph-combobox-option-label":
|
|
641
|
+
"data-tgph-combobox-option-label": o,
|
|
569
642
|
...c,
|
|
570
|
-
children:
|
|
643
|
+
children: o || a || t
|
|
571
644
|
}
|
|
572
645
|
);
|
|
573
|
-
},
|
|
646
|
+
}, we = ({
|
|
574
647
|
label: t = "Search",
|
|
575
|
-
placeholder:
|
|
648
|
+
placeholder: o = "Search",
|
|
576
649
|
tgphRef: e,
|
|
577
|
-
value:
|
|
578
|
-
onValueChange:
|
|
650
|
+
value: r,
|
|
651
|
+
onValueChange: a,
|
|
579
652
|
...c
|
|
580
653
|
}) => {
|
|
581
654
|
var v;
|
|
582
|
-
const
|
|
583
|
-
return
|
|
584
|
-
var
|
|
655
|
+
const n = s.useId(), i = s.useContext(y), p = $(e, i.searchRef), g = r ?? i.searchQuery, b = a ?? i.setSearchQuery;
|
|
656
|
+
return s.useEffect(() => {
|
|
657
|
+
var f;
|
|
585
658
|
const d = (m) => {
|
|
586
|
-
var
|
|
587
|
-
|
|
588
|
-
}, u = (
|
|
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;
|
|
589
662
|
if (u)
|
|
590
663
|
return u.addEventListener("keydown", d), () => {
|
|
591
664
|
u.removeEventListener("keydown", d);
|
|
592
665
|
};
|
|
593
|
-
}, [
|
|
594
|
-
/* @__PURE__ */
|
|
595
|
-
/* @__PURE__ */
|
|
596
|
-
|
|
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,
|
|
597
670
|
{
|
|
598
|
-
id:
|
|
671
|
+
id: n,
|
|
599
672
|
variant: "ghost",
|
|
600
|
-
placeholder:
|
|
601
|
-
value:
|
|
673
|
+
placeholder: o,
|
|
674
|
+
value: g,
|
|
602
675
|
onChange: (d) => {
|
|
603
|
-
|
|
676
|
+
b(d.target.value);
|
|
604
677
|
},
|
|
605
|
-
LeadingComponent: /* @__PURE__ */
|
|
606
|
-
TrailingComponent:
|
|
607
|
-
|
|
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,
|
|
608
681
|
{
|
|
609
682
|
variant: "ghost",
|
|
610
683
|
color: "gray",
|
|
611
|
-
icon: { icon:
|
|
684
|
+
icon: { icon: E.X, alt: "Clear Search Query" },
|
|
612
685
|
onClick: () => {
|
|
613
686
|
var d;
|
|
614
|
-
return (d =
|
|
687
|
+
return (d = i.setSearchQuery) == null ? void 0 : d.call(i, "");
|
|
615
688
|
}
|
|
616
689
|
}
|
|
617
690
|
) : null,
|
|
618
691
|
autoFocus: !0,
|
|
619
692
|
"data-tgph-combobox-search": !0,
|
|
620
|
-
"aria-controls":
|
|
693
|
+
"aria-controls": i.contentId,
|
|
621
694
|
...c,
|
|
622
|
-
tgphRef:
|
|
695
|
+
tgphRef: p
|
|
623
696
|
}
|
|
624
697
|
)
|
|
625
698
|
] });
|
|
626
|
-
},
|
|
627
|
-
icon: t = { icon:
|
|
628
|
-
message:
|
|
699
|
+
}, Ee = ({
|
|
700
|
+
icon: t = { icon: E.Search, alt: "Search Icon" },
|
|
701
|
+
message: o = "No results found",
|
|
629
702
|
children: e,
|
|
630
|
-
...
|
|
703
|
+
...r
|
|
631
704
|
}) => {
|
|
632
|
-
const
|
|
633
|
-
if (
|
|
634
|
-
var
|
|
635
|
-
const
|
|
705
|
+
const a = s.useContext(y), [c, n] = s.useState(!1);
|
|
706
|
+
if (s.useEffect(() => {
|
|
707
|
+
var p, g;
|
|
708
|
+
const i = (g = (p = a.contentRef) == null ? void 0 : p.current) == null ? void 0 : g.querySelectorAll(
|
|
636
709
|
"[data-tgph-combobox-option]"
|
|
637
710
|
);
|
|
638
|
-
(
|
|
639
|
-
}, [
|
|
640
|
-
return /* @__PURE__ */
|
|
711
|
+
(i == null ? void 0 : i.length) === 0 ? n(!0) : n(!1);
|
|
712
|
+
}, [a.searchQuery, a.contentRef, e]), c)
|
|
713
|
+
return /* @__PURE__ */ R(
|
|
641
714
|
I,
|
|
642
715
|
{
|
|
643
716
|
gap: "1",
|
|
@@ -646,58 +719,59 @@ const ne = {
|
|
|
646
719
|
w: "full",
|
|
647
720
|
my: "8",
|
|
648
721
|
"data-tgph-combobox-empty": !0,
|
|
649
|
-
...
|
|
722
|
+
...r,
|
|
650
723
|
children: [
|
|
651
|
-
t === null ? /* @__PURE__ */
|
|
652
|
-
|
|
724
|
+
t === null ? /* @__PURE__ */ l(_, {}) : /* @__PURE__ */ l(z, { ...t }),
|
|
725
|
+
o === null ? /* @__PURE__ */ l(_, {}) : /* @__PURE__ */ l(H, { as: "span", children: o })
|
|
653
726
|
]
|
|
654
727
|
}
|
|
655
728
|
);
|
|
656
|
-
},
|
|
729
|
+
}, ke = ({
|
|
657
730
|
leadingText: t = "Create",
|
|
658
|
-
values:
|
|
731
|
+
values: o,
|
|
659
732
|
onCreate: e,
|
|
660
|
-
selected:
|
|
661
|
-
legacyBehavior:
|
|
733
|
+
selected: r = null,
|
|
734
|
+
legacyBehavior: a = !1,
|
|
662
735
|
...c
|
|
663
736
|
}) => {
|
|
664
|
-
const
|
|
665
|
-
(
|
|
666
|
-
(
|
|
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
|
|
667
740
|
),
|
|
668
|
-
[
|
|
741
|
+
[o, a]
|
|
669
742
|
);
|
|
670
|
-
if (
|
|
671
|
-
return /* @__PURE__ */
|
|
672
|
-
|
|
743
|
+
if (n.searchQuery && !i(n.searchQuery))
|
|
744
|
+
return /* @__PURE__ */ l(
|
|
745
|
+
q,
|
|
673
746
|
{
|
|
674
|
-
leadingIcon: { icon:
|
|
747
|
+
leadingIcon: { icon: E.Plus, "aria-hidden": !0 },
|
|
675
748
|
mx: "1",
|
|
676
|
-
value:
|
|
677
|
-
label: `${t} "${
|
|
678
|
-
selected:
|
|
749
|
+
value: n.searchQuery,
|
|
750
|
+
label: `${t} "${n.searchQuery}"`,
|
|
751
|
+
selected: r,
|
|
679
752
|
onSelect: () => {
|
|
680
|
-
var
|
|
681
|
-
if (e &&
|
|
682
|
-
const
|
|
683
|
-
e(
|
|
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, "");
|
|
684
757
|
}
|
|
685
758
|
},
|
|
686
759
|
...c
|
|
687
760
|
}
|
|
688
761
|
);
|
|
689
|
-
},
|
|
690
|
-
Object.assign(
|
|
691
|
-
Root:
|
|
692
|
-
Trigger:
|
|
693
|
-
Content:
|
|
694
|
-
Options:
|
|
695
|
-
Option:
|
|
696
|
-
Search:
|
|
697
|
-
Empty:
|
|
698
|
-
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
|
|
699
773
|
});
|
|
700
774
|
export {
|
|
701
|
-
|
|
775
|
+
Ie as Combobox
|
|
702
776
|
};
|
|
703
777
|
//# sourceMappingURL=index.mjs.map
|