@telegraph/combobox 0.0.1

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.
@@ -0,0 +1,1673 @@
1
+ import { jsx as u, jsxs as T, Fragment as W } from "react/jsx-runtime";
2
+ import { useControllableState as ge } from "@radix-ui/react-use-controllable-state";
3
+ import * as be from "@radix-ui/react-visually-hidden";
4
+ import { Icon as Y, Lucide as _ } from "@telegraph/icon";
5
+ import * as he from "react";
6
+ import p from "react";
7
+ import { Text as N } from "@telegraph/typography";
8
+ import { useComposedRefs as z } from "@telegraph/compose-refs";
9
+ import { RefToTgphRef as re } from "@telegraph/helpers";
10
+ import { Input as ye } from "@telegraph/input";
11
+ import { Menu as D } from "@telegraph/menu";
12
+ import { Tag as P } from "@telegraph/tag";
13
+ import { motion as S, AnimatePresence as F } from "framer-motion";
14
+ function oe(r) {
15
+ var t, e, a = "";
16
+ if (typeof r == "string" || typeof r == "number") a += r;
17
+ else if (typeof r == "object") if (Array.isArray(r)) {
18
+ var i = r.length;
19
+ for (t = 0; t < i; t++) r[t] && (e = oe(r[t])) && (a && (a += " "), a += e);
20
+ } else for (e in r) r[e] && (a && (a += " "), a += e);
21
+ return a;
22
+ }
23
+ function $() {
24
+ for (var r, t, e = 0, a = "", i = arguments.length; e < i; e++) (r = arguments[e]) && (t = oe(r)) && (a && (a += " "), a += t);
25
+ return a;
26
+ }
27
+ function fe(r, t) {
28
+ typeof r == "function" ? r(t) : r != null && (r.current = t);
29
+ }
30
+ function me(...r) {
31
+ return (t) => r.forEach((e) => fe(e, t));
32
+ }
33
+ function ae(...r) {
34
+ return he.useCallback(me(...r), r);
35
+ }
36
+ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
37
+ const t = [];
38
+ let e = null;
39
+ for (let a = 0; a < j.length; a++) {
40
+ const i = j[a];
41
+ if (r[i])
42
+ e = r[i], t.push(e);
43
+ else if (e !== null)
44
+ t.push(e);
45
+ else {
46
+ let o = null;
47
+ for (let n = a + 1; n < j.length; n++)
48
+ if (r[j[n]]) {
49
+ o = r[j[n]];
50
+ break;
51
+ }
52
+ if (o !== null) {
53
+ for (let n = 0; n <= a; n++)
54
+ t.push(o);
55
+ e = o;
56
+ }
57
+ }
58
+ }
59
+ return t;
60
+ }, we = (r) => typeof r == "object" && (r.sm || r.md || r.lg || r.xl || r["2xl"]), y = ({
61
+ value: r,
62
+ prop: t
63
+ }) => {
64
+ if (!r) return "";
65
+ if (t.valueType === "static")
66
+ return r.toString();
67
+ const e = t.type === "color" ? "" : `-${t.type}`;
68
+ return r === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${r})`;
69
+ }, I = {
70
+ top: 0,
71
+ right: 1,
72
+ bottom: 2,
73
+ left: 3
74
+ }, x = {
75
+ topLeft: 0,
76
+ topRight: 1,
77
+ bottomRight: 2,
78
+ bottomLeft: 3
79
+ }, xe = ({
80
+ cssVariables: r,
81
+ value: t,
82
+ prop: e,
83
+ direction: a = "all"
84
+ }) => {
85
+ const i = r[`--tgph-${e.rule}`] || "", o = i ? i.split(" ") : [], n = [
86
+ (o == null ? void 0 : o[0]) || 0,
87
+ (o == null ? void 0 : o[1]) || 0,
88
+ (o == null ? void 0 : o[2]) || 0,
89
+ (o == null ? void 0 : o[3]) || 0
90
+ ];
91
+ return a === "all" ? y({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[x.topLeft] = y({
92
+ value: t,
93
+ prop: e
94
+ }), n[x.topRight] = y({
95
+ value: t,
96
+ prop: e
97
+ })), a === "right" && (n[x.topRight] = y({
98
+ value: t,
99
+ prop: e
100
+ }), n[x.bottomRight] = y({
101
+ value: t,
102
+ prop: e
103
+ })), a === "bottom" && (n[x.bottomRight] = y({
104
+ value: t,
105
+ prop: e
106
+ }), n[x.bottomLeft] = y({
107
+ value: t,
108
+ prop: e
109
+ })), a === "left" && (n[x.bottomLeft] = y({
110
+ value: t,
111
+ prop: e
112
+ }), n[x.topLeft] = y({
113
+ value: t,
114
+ prop: e
115
+ })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[x[a]] = y({
116
+ value: t,
117
+ prop: e
118
+ }))) : (a === "x" && (n[I.left] = y({
119
+ value: t,
120
+ prop: e
121
+ }), n[I.right] = y({
122
+ value: t,
123
+ prop: e
124
+ })), a === "y" && (n[I.top] = y({
125
+ value: t,
126
+ prop: e
127
+ }), n[I.bottom] = y({
128
+ value: t,
129
+ prop: e
130
+ })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[I[a]] = y({
131
+ value: t,
132
+ prop: e
133
+ }))), n.join(" "));
134
+ }, G = ({
135
+ prop: r,
136
+ value: t,
137
+ cssVariables: e
138
+ }) => r.direction ? xe({
139
+ cssVariables: e,
140
+ prop: r,
141
+ value: t,
142
+ direction: r.direction,
143
+ type: r.type
144
+ }) : y({ value: t, prop: r }), ne = ({
145
+ props: r,
146
+ ref: t,
147
+ propsMap: e
148
+ }) => {
149
+ if (!t.current) return;
150
+ const a = {};
151
+ Object.entries(r).forEach(([i, o]) => {
152
+ const n = e[i];
153
+ n && (typeof o == "string" || typeof o == "boolean" ? a[`--tgph-${n.rule}`] = G({
154
+ prop: n,
155
+ key: i,
156
+ value: o,
157
+ cssVariables: a
158
+ }) : we(o) && ve(o).forEach((l, c) => {
159
+ l && (a[`--tgph-${n.rule}-${j[c]}`] = G({
160
+ prop: n,
161
+ key: i,
162
+ value: l,
163
+ cssVariables: a
164
+ }));
165
+ })), Object.entries(a).forEach(([l, c]) => {
166
+ t.current && t.current.style.setProperty(l, c);
167
+ });
168
+ });
169
+ }, U = {
170
+ display: {
171
+ rule: "display",
172
+ type: "block-display",
173
+ valueType: "static"
174
+ },
175
+ h: {
176
+ rule: "height",
177
+ type: "spacing"
178
+ },
179
+ w: {
180
+ rule: "width",
181
+ type: "spacing"
182
+ },
183
+ maxH: {
184
+ rule: "max-height",
185
+ type: "spacing"
186
+ },
187
+ maxW: {
188
+ rule: "max-width",
189
+ type: "spacing"
190
+ },
191
+ p: {
192
+ rule: "padding",
193
+ type: "spacing",
194
+ direction: "all"
195
+ },
196
+ m: {
197
+ rule: "margin",
198
+ type: "spacing",
199
+ direction: "all"
200
+ },
201
+ pt: {
202
+ rule: "padding",
203
+ type: "spacing",
204
+ direction: "top"
205
+ },
206
+ pl: {
207
+ rule: "padding",
208
+ type: "spacing",
209
+ direction: "left"
210
+ },
211
+ pb: {
212
+ rule: "padding",
213
+ type: "spacing",
214
+ direction: "bottom"
215
+ },
216
+ pr: {
217
+ rule: "padding",
218
+ type: "spacing",
219
+ direction: "right"
220
+ },
221
+ px: {
222
+ rule: "padding",
223
+ type: "spacing",
224
+ direction: "x"
225
+ },
226
+ py: {
227
+ rule: "padding",
228
+ type: "spacing",
229
+ direction: "y"
230
+ },
231
+ mt: {
232
+ rule: "margin",
233
+ type: "spacing",
234
+ direction: "top"
235
+ },
236
+ ml: {
237
+ rule: "margin",
238
+ type: "spacing",
239
+ direction: "left"
240
+ },
241
+ mb: {
242
+ rule: "margin",
243
+ type: "spacing",
244
+ direction: "bottom"
245
+ },
246
+ mr: {
247
+ rule: "margin",
248
+ type: "spacing",
249
+ direction: "right"
250
+ },
251
+ mx: {
252
+ rule: "margin",
253
+ type: "spacing",
254
+ direction: "x"
255
+ },
256
+ my: {
257
+ rule: "margin",
258
+ type: "spacing",
259
+ direction: "y"
260
+ },
261
+ bg: {
262
+ rule: "background-color",
263
+ type: "color"
264
+ },
265
+ rounded: {
266
+ rule: "border-radius",
267
+ type: "rounded",
268
+ direction: "all"
269
+ },
270
+ roundedTopLeft: {
271
+ rule: "border-radius",
272
+ type: "rounded",
273
+ direction: "topLeft",
274
+ ordering: "clockwise"
275
+ },
276
+ roundedBottomLeft: {
277
+ rule: "border-radius",
278
+ type: "rounded",
279
+ direction: "bottomLeft",
280
+ ordering: "clockwise"
281
+ },
282
+ roundedBottomRight: {
283
+ rule: "border-radius",
284
+ type: "rounded",
285
+ direction: "bottomRight",
286
+ ordering: "clockwise"
287
+ },
288
+ roundedTopRight: {
289
+ rule: "border-radius",
290
+ type: "rounded",
291
+ direction: "topRight",
292
+ ordering: "clockwise"
293
+ },
294
+ roundedTop: {
295
+ rule: "border-radius",
296
+ type: "rounded",
297
+ direction: "top",
298
+ ordering: "clockwise"
299
+ },
300
+ roundedBottom: {
301
+ rule: "border-radius",
302
+ type: "rounded",
303
+ direction: "bottom",
304
+ ordering: "clockwise"
305
+ },
306
+ roundedLeft: {
307
+ rule: "border-radius",
308
+ type: "rounded",
309
+ direction: "left",
310
+ ordering: "clockwise"
311
+ },
312
+ roundedRight: {
313
+ rule: "border-radius",
314
+ type: "rounded",
315
+ direction: "right",
316
+ ordering: "clockwise"
317
+ },
318
+ border: {
319
+ rule: "border-width",
320
+ type: "spacing",
321
+ direction: "all",
322
+ default: "px"
323
+ },
324
+ borderTop: {
325
+ rule: "border-width",
326
+ type: "spacing",
327
+ direction: "top",
328
+ default: "px"
329
+ },
330
+ borderLeft: {
331
+ rule: "border-width",
332
+ type: "spacing",
333
+ direction: "left",
334
+ default: "px"
335
+ },
336
+ borderBottom: {
337
+ rule: "border-width",
338
+ type: "spacing",
339
+ direction: "bottom",
340
+ default: "px"
341
+ },
342
+ borderRight: {
343
+ rule: "border-width",
344
+ type: "spacing",
345
+ direction: "right",
346
+ default: "px"
347
+ },
348
+ borderX: {
349
+ rule: "border-width",
350
+ type: "spacing",
351
+ direction: "x",
352
+ default: "px"
353
+ },
354
+ borderY: {
355
+ rule: "border-width",
356
+ type: "spacing",
357
+ direction: "y",
358
+ default: "px"
359
+ },
360
+ borderColor: {
361
+ rule: "border-color",
362
+ type: "color",
363
+ default: "gray-4"
364
+ },
365
+ borderStyle: {
366
+ rule: "border-style",
367
+ type: "border-style",
368
+ default: "solid"
369
+ },
370
+ shadow: {
371
+ rule: "box-shadow",
372
+ type: "shadow"
373
+ }
374
+ }, Re = ({
375
+ as: r,
376
+ className: t,
377
+ tgphRef: e,
378
+ ...a
379
+ }) => {
380
+ const i = r || "div", o = p.useRef(null), n = ae(e, o), l = p.useMemo(() => {
381
+ const c = { borderColor: !0, ...a };
382
+ return Object.keys(c).reduce(
383
+ (d, s) => (Object.keys(U).some((g) => g === s) ? d.box[s] = c[s] : d.rest[s] = c[s], d),
384
+ { box: {}, rest: {} }
385
+ );
386
+ }, [a]);
387
+ return p.useLayoutEffect(() => {
388
+ ne({
389
+ props: l.box,
390
+ ref: o,
391
+ propsMap: U
392
+ });
393
+ }, [l.box]), /* @__PURE__ */ u(
394
+ i,
395
+ {
396
+ className: $("tgph-box", t),
397
+ ref: n,
398
+ ...l.rest
399
+ }
400
+ );
401
+ }, J = {
402
+ display: {
403
+ rule: "display",
404
+ type: "flex-display",
405
+ valueType: "static"
406
+ },
407
+ direction: {
408
+ rule: "flex-direction",
409
+ type: "flex-direction",
410
+ valueType: "static"
411
+ },
412
+ align: {
413
+ rule: "align-items",
414
+ type: "align-items",
415
+ valueType: "static"
416
+ },
417
+ justify: {
418
+ rule: "justify-content",
419
+ type: "justify-content",
420
+ valueType: "static"
421
+ },
422
+ wrap: {
423
+ rule: "flex-wrap",
424
+ type: "flex-wrap",
425
+ valueType: "static"
426
+ },
427
+ gap: {
428
+ rule: "gap",
429
+ type: "spacing",
430
+ valueType: "variable"
431
+ }
432
+ }, ke = ({
433
+ className: r,
434
+ tgphRef: t,
435
+ ...e
436
+ }) => {
437
+ const a = p.useRef(null), i = ae(t, a), o = p.useMemo(
438
+ () => Object.keys(e).reduce(
439
+ (n, l) => (Object.keys(J).some((c) => c === l) ? n.stack[l] = e[l] : n.rest[l] = e[l], n),
440
+ { stack: {}, rest: {} }
441
+ ),
442
+ [e]
443
+ );
444
+ return p.useLayoutEffect(() => {
445
+ ne({
446
+ props: o.stack,
447
+ ref: a,
448
+ propsMap: J
449
+ });
450
+ }, [o.stack, i]), /* @__PURE__ */ u(
451
+ Re,
452
+ {
453
+ className: $("tgph-stack", r),
454
+ tgphRef: i,
455
+ ...o.rest
456
+ }
457
+ );
458
+ }, Ce = {
459
+ solid: {
460
+ gray: "bg-gray-9 hover:bg-gray-10 focus:bg-gray-11 data-[tgph-button-active=true]:!bg-gray-11",
461
+ red: "bg-red-9 hover:bg-red-10 focus:bg-red-11 data-[tgph-button-active=true]:!bg-red-11",
462
+ accent: "bg-accent-9 hover:bg-accent-10 focus:bg-accent-11 data-[tgph-button-active=true]:!bg-accent-11",
463
+ green: "bg-green-9 hover:bg-green-10 focus:bg-green-11 data-[tgph-button-active=true]:!bg-green-11",
464
+ blue: "bg-blue-9 hover:bg-blue-10 focus:bg-blue-11 data-[tgph-button-active=true]:!bg-blue-11",
465
+ yellow: "bg-yellow-9 hover:bg-yellow-10 focus:bg-yellow-11 data-[tgph-button-active=true]:!bg-yellow-11",
466
+ purple: "bg-purple-9 hover:bg-purple-10 focus:bg-purple-11 data-[tgph-button-active=true]:!bg-purple-11",
467
+ disabled: "bg-gray-2"
468
+ },
469
+ soft: {
470
+ gray: "bg-gray-3 hover:bg-gray-4 focus:bg-gray-5 data-[tgph-button-active=true]:!bg-gray-5",
471
+ red: "bg-red-3 hover:bg-red-4 focus:bg-red-5 data-[tgph-button-active=true]:!bg-red-5",
472
+ accent: "bg-accent-3 hover:bg-accent-4 focus:bg-accent-6 data-[tgph-button-active=true]:!bg-accent-6",
473
+ green: "bg-green-3 hover:bg-green-4 focus:bg-green-5 data-[tgph-button-active=true]:!bg-green-5",
474
+ blue: "bg-blue-3 hover:bg-blue-4 focus:bg-blue-5 data-[tgph-button-active=true]:!bg-blue-5",
475
+ yellow: "bg-yellow-3 hover:bg-yellow-4 focus:bg-yellow-5 data-[tgph-button-active=true]:!bg-yellow-5",
476
+ purple: "bg-purple-3 hover:bg-purple-4 focus:bg-purple-5 data-[tgph-button-active=true]:!bg-purple-5",
477
+ disabled: "bg-gray-2"
478
+ },
479
+ outline: {
480
+ gray: "bg-transparent shadow-[inset_0_0_0_1px] shadow-gray-6 hover:shadow-gray-7 focus:shadow-gray-8 data-[tgph-button-active=true]:!shadow-gray-8",
481
+ red: "bg-transparent shadow-[inset_0_0_0_1px] shadow-red-6 hover:shadow-red-7 focus:shadow-red-8 data-[tgph-button-active=true]:!shadow-red-8",
482
+ accent: "bg-transparent shadow-[inset_0_0_0_1px] shadow-accent-6 hover:shadow-accent-7 focus:shadow-accent-8 data-[tgph-button-active=true]:!shadow-accent-8",
483
+ green: "bg-transparent shadow-[inset_0_0_0_1px] shadow-green-6 hover:shadow-green-7 focus:shadow-green-8 data-[tgph-button-active=true]:!shadow-green-8",
484
+ blue: "bg-transparent shadow-[inset_0_0_0_1px] shadow-blue-6 hover:shadow-blue-7 focus:shadow-blue-8 data-[tgph-button-active=true]:!shadow-blue-8",
485
+ yellow: "bg-transparent shadow-[inset_0_0_0_1px] shadow-yellow-6 hover:shadow-yellow-7 focus:shadow-yellow-8 data-[tgph-button-active=true]:!shadow-yellow-8",
486
+ purple: "bg-transparent shadow-[inset_0_0_0_1px] shadow-purple-6 hover:shadow-purple-7 focus:shadow-purple-8 data-[tgph-button-active=true]:!shadow-purple-8",
487
+ disabled: "bg-gray-2"
488
+ },
489
+ ghost: {
490
+ gray: "bg-transparent hover:bg-gray-3 focus:bg-gray-4 data-[tgph-button-active=true]:!bg-gray-4 [&data-[tgph-button-active=true]>span]:!text-gray-12",
491
+ red: "bg-transparent hover:bg-red-3 focus:bg-red-4 data-[tgph-button-active=true]:!bg-red-4",
492
+ accent: "bg-transparent hover:bg-accent-3 focus:bg-accent-4 data-[tgph-button-active=true]:!bg-accent-4",
493
+ green: "bg-transparent hover:bg-green-3 focus:bg-green-4 data-[tgph-button-active=true]:!bg-green-4",
494
+ blue: "bg-transparent hover:bg-blue-3 focus:bg-blue-4 data-[tgph-button-active=true]:!bg-blue-4",
495
+ yellow: "bg-transparent hover:bg-yellow-3 focus:bg-yellow-4 data-[tgph-button-active=true]:!bg-yellow-4",
496
+ purple: "bg-transparent hover:bg-purple-3 focus:bg-purple-4 data-[tgph-button-active=true]:!bg-purple-4",
497
+ disabled: "bg-transparent"
498
+ }
499
+ }, V = {
500
+ default: {
501
+ 1: {
502
+ w: "auto",
503
+ h: "6",
504
+ gap: "1",
505
+ px: "2"
506
+ },
507
+ 2: {
508
+ w: "auto",
509
+ h: "8",
510
+ gap: "2",
511
+ px: "3"
512
+ },
513
+ 3: {
514
+ w: "auto",
515
+ h: "10",
516
+ gap: "3",
517
+ px: "4"
518
+ }
519
+ },
520
+ "icon-only": {
521
+ 1: {
522
+ w: "6",
523
+ h: "6",
524
+ gap: "0",
525
+ px: "0"
526
+ },
527
+ 2: {
528
+ w: "8",
529
+ h: "8",
530
+ gap: "0",
531
+ px: "0"
532
+ },
533
+ 3: {
534
+ w: "10",
535
+ h: "10",
536
+ gap: "0",
537
+ px: "0"
538
+ }
539
+ }
540
+ }, Le = {
541
+ 1: "1",
542
+ 2: "2",
543
+ 3: "3"
544
+ }, Te = {
545
+ solid: {
546
+ gray: "white",
547
+ red: "white",
548
+ accent: "white",
549
+ green: "white",
550
+ blue: "white",
551
+ yellow: "white",
552
+ purple: "white",
553
+ disabled: "disabled"
554
+ },
555
+ soft: {
556
+ gray: "default",
557
+ red: "red",
558
+ accent: "accent",
559
+ green: "green",
560
+ blue: "blue",
561
+ yellow: "yellow",
562
+ purple: "purple",
563
+ disabled: "disabled"
564
+ },
565
+ outline: {
566
+ gray: "default",
567
+ red: "red",
568
+ accent: "accent",
569
+ green: "green",
570
+ blue: "blue",
571
+ yellow: "yellow",
572
+ purple: "purple",
573
+ disabled: "disabled"
574
+ },
575
+ ghost: {
576
+ gray: "gray",
577
+ red: "red",
578
+ accent: "accent",
579
+ green: "green",
580
+ blue: "blue",
581
+ yellow: "yellow",
582
+ purple: "purple",
583
+ disabled: "disabled"
584
+ }
585
+ }, Se = {
586
+ 1: "1",
587
+ 2: "2",
588
+ 3: "3"
589
+ }, je = {
590
+ solid: {
591
+ gray: "white",
592
+ red: "white",
593
+ accent: "white",
594
+ green: "white",
595
+ blue: "white",
596
+ yellow: "white",
597
+ purple: "white",
598
+ disabled: "disabled"
599
+ },
600
+ soft: {
601
+ accent: "accent",
602
+ gray: "gray",
603
+ red: "red",
604
+ green: "green",
605
+ blue: "blue",
606
+ yellow: "yellow",
607
+ purple: "purple",
608
+ disabled: "disabled"
609
+ },
610
+ outline: {
611
+ accent: "accent",
612
+ gray: "gray",
613
+ red: "red",
614
+ green: "green",
615
+ blue: "blue",
616
+ yellow: "yellow",
617
+ purple: "purple",
618
+ disabled: "disabled"
619
+ },
620
+ ghost: {
621
+ accent: "accent",
622
+ gray: "default",
623
+ red: "red",
624
+ green: "green",
625
+ blue: "blue",
626
+ yellow: "yellow",
627
+ purple: "purple",
628
+ disabled: "disabled"
629
+ }
630
+ }, Oe = {
631
+ default: "secondary",
632
+ "icon-only": "primary"
633
+ }, K = p.createContext({
634
+ variant: "solid",
635
+ size: "2",
636
+ color: "gray",
637
+ state: "default",
638
+ layout: "default",
639
+ active: !1
640
+ }), ie = ({
641
+ as: r,
642
+ variant: t = "solid",
643
+ size: e = "2",
644
+ color: a = "gray",
645
+ state: i = "default",
646
+ active: o = !1,
647
+ disabled: n,
648
+ className: l,
649
+ ...c
650
+ }) => {
651
+ const d = n ? "disabled" : i, s = d === "disabled" ? "disabled" : a, g = p.useMemo(() => {
652
+ var m;
653
+ const b = p.Children.toArray(c == null ? void 0 : c.children);
654
+ if ((b == null ? void 0 : b.length) === 1 && p.isValidElement(b[0])) {
655
+ const h = b[0];
656
+ if ((m = h == null ? void 0 : h.props) != null && m.icon)
657
+ return "icon-only";
658
+ }
659
+ return "default";
660
+ }, [c == null ? void 0 : c.children]);
661
+ return /* @__PURE__ */ u(
662
+ K.Provider,
663
+ {
664
+ value: { variant: t, size: e, color: s, state: d, layout: g, active: o },
665
+ children: /* @__PURE__ */ u(
666
+ ke,
667
+ {
668
+ as: r || "button",
669
+ className: $(
670
+ "appearance-none border-0 cursor-pointer bg-none box-border [font-family:inherit]",
671
+ "transition-colors no-underline",
672
+ d === "disabled" && "cursor-not-allowed",
673
+ Ce[t][s],
674
+ V[g][e],
675
+ l
676
+ ),
677
+ h: V[g][e].h,
678
+ w: V[g][e].w,
679
+ gap: V[g][e].gap,
680
+ px: V[g][e].px,
681
+ display: "inline-flex",
682
+ align: "center",
683
+ justify: "center",
684
+ rounded: "3",
685
+ "data-tgph-button": !0,
686
+ "data-tgph-button-layout": g,
687
+ "data-tgph-button-active": o,
688
+ disabled: n,
689
+ ...c
690
+ }
691
+ )
692
+ }
693
+ );
694
+ }, H = ({
695
+ size: r,
696
+ color: t,
697
+ variant: e,
698
+ icon: a,
699
+ alt: i,
700
+ "aria-hidden": o,
701
+ ...n
702
+ }) => {
703
+ const l = p.useContext(K), c = {
704
+ size: r ?? Se[l.size],
705
+ color: t ?? je[l.variant][l.color],
706
+ variant: e ?? Oe[l.layout]
707
+ };
708
+ return /* @__PURE__ */ u(
709
+ Y,
710
+ {
711
+ icon: a,
712
+ "data-button-icon": !0,
713
+ ...i ? { alt: i } : { "aria-hidden": o },
714
+ ...c,
715
+ ...n
716
+ }
717
+ );
718
+ }, le = ({
719
+ as: r,
720
+ color: t,
721
+ size: e,
722
+ weight: a = "medium",
723
+ className: i,
724
+ ...o
725
+ }) => {
726
+ const n = p.useContext(K);
727
+ return /* @__PURE__ */ u(
728
+ N,
729
+ {
730
+ as: r || "span",
731
+ color: t ?? Te[n.variant][n.color],
732
+ size: e ?? Le[n.size],
733
+ weight: a,
734
+ className: $("no-underline whitespace-nowrap", i),
735
+ internal_optionalAs: !0,
736
+ "data-button-text": !0,
737
+ ...o
738
+ }
739
+ );
740
+ }, ce = ({
741
+ leadingIcon: r,
742
+ trailingIcon: t,
743
+ icon: e,
744
+ children: a,
745
+ ...i
746
+ }) => {
747
+ const o = r || e;
748
+ return /* @__PURE__ */ T(ie, { ...i, children: [
749
+ o && /* @__PURE__ */ u(H, { ...o }),
750
+ a && /* @__PURE__ */ u(le, { children: a }),
751
+ t && /* @__PURE__ */ u(H, { ...t })
752
+ ] });
753
+ };
754
+ Object.assign(ce, {
755
+ Root: ie,
756
+ Icon: H,
757
+ Text: le
758
+ });
759
+ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
760
+ const t = [];
761
+ let e = null;
762
+ for (let a = 0; a < O.length; a++) {
763
+ const i = O[a];
764
+ if (r[i])
765
+ e = r[i], t.push(e);
766
+ else if (e !== null)
767
+ t.push(e);
768
+ else {
769
+ let o = null;
770
+ for (let n = a + 1; n < O.length; n++)
771
+ if (r[O[n]]) {
772
+ o = r[O[n]];
773
+ break;
774
+ }
775
+ if (o !== null) {
776
+ for (let n = 0; n <= a; n++)
777
+ t.push(o);
778
+ e = o;
779
+ }
780
+ }
781
+ }
782
+ return t;
783
+ }, $e = (r) => typeof r == "object" && (r.sm || r.md || r.lg || r.xl || r["2xl"]), f = ({
784
+ value: r,
785
+ prop: t
786
+ }) => {
787
+ if (!r) return "";
788
+ if (t.valueType === "static")
789
+ return r.toString();
790
+ const e = t.type === "color" ? "" : `-${t.type}`;
791
+ return r === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${r})`;
792
+ }, A = {
793
+ top: 0,
794
+ right: 1,
795
+ bottom: 2,
796
+ left: 3
797
+ }, R = {
798
+ topLeft: 0,
799
+ topRight: 1,
800
+ bottomRight: 2,
801
+ bottomLeft: 3
802
+ }, Ee = ({
803
+ cssVariables: r,
804
+ value: t,
805
+ prop: e,
806
+ direction: a = "all"
807
+ }) => {
808
+ const i = r[`--tgph-${e.rule}`] || "", o = i ? i.split(" ") : [], n = [
809
+ (o == null ? void 0 : o[0]) || 0,
810
+ (o == null ? void 0 : o[1]) || 0,
811
+ (o == null ? void 0 : o[2]) || 0,
812
+ (o == null ? void 0 : o[3]) || 0
813
+ ];
814
+ return a === "all" ? f({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[R.topLeft] = f({
815
+ value: t,
816
+ prop: e
817
+ }), n[R.topRight] = f({
818
+ value: t,
819
+ prop: e
820
+ })), a === "right" && (n[R.topRight] = f({
821
+ value: t,
822
+ prop: e
823
+ }), n[R.bottomRight] = f({
824
+ value: t,
825
+ prop: e
826
+ })), a === "bottom" && (n[R.bottomRight] = f({
827
+ value: t,
828
+ prop: e
829
+ }), n[R.bottomLeft] = f({
830
+ value: t,
831
+ prop: e
832
+ })), a === "left" && (n[R.bottomLeft] = f({
833
+ value: t,
834
+ prop: e
835
+ }), n[R.topLeft] = f({
836
+ value: t,
837
+ prop: e
838
+ })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[R[a]] = f({
839
+ value: t,
840
+ prop: e
841
+ }))) : (a === "x" && (n[A.left] = f({
842
+ value: t,
843
+ prop: e
844
+ }), n[A.right] = f({
845
+ value: t,
846
+ prop: e
847
+ })), a === "y" && (n[A.top] = f({
848
+ value: t,
849
+ prop: e
850
+ }), n[A.bottom] = f({
851
+ value: t,
852
+ prop: e
853
+ })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[A[a]] = f({
854
+ value: t,
855
+ prop: e
856
+ }))), n.join(" "));
857
+ }, Z = ({
858
+ prop: r,
859
+ value: t,
860
+ cssVariables: e
861
+ }) => r.direction ? Ee({
862
+ cssVariables: e,
863
+ prop: r,
864
+ value: t,
865
+ direction: r.direction,
866
+ type: r.type
867
+ }) : f({ value: t, prop: r }), pe = ({
868
+ props: r,
869
+ ref: t,
870
+ propsMap: e
871
+ }) => {
872
+ if (!t.current) return;
873
+ const a = {};
874
+ Object.entries(r).forEach(([i, o]) => {
875
+ const n = e[i];
876
+ n && (typeof o == "string" || typeof o == "boolean" ? a[`--tgph-${n.rule}`] = Z({
877
+ prop: n,
878
+ key: i,
879
+ value: o,
880
+ cssVariables: a
881
+ }) : $e(o) && _e(o).forEach((l, c) => {
882
+ l && (a[`--tgph-${n.rule}-${O[c]}`] = Z({
883
+ prop: n,
884
+ key: i,
885
+ value: l,
886
+ cssVariables: a
887
+ }));
888
+ })), Object.entries(a).forEach(([l, c]) => {
889
+ t.current && t.current.style.setProperty(l, c);
890
+ });
891
+ });
892
+ }, ee = {
893
+ display: {
894
+ rule: "display",
895
+ type: "block-display",
896
+ valueType: "static"
897
+ },
898
+ h: {
899
+ rule: "height",
900
+ type: "spacing"
901
+ },
902
+ w: {
903
+ rule: "width",
904
+ type: "spacing"
905
+ },
906
+ maxH: {
907
+ rule: "max-height",
908
+ type: "spacing"
909
+ },
910
+ maxW: {
911
+ rule: "max-width",
912
+ type: "spacing"
913
+ },
914
+ p: {
915
+ rule: "padding",
916
+ type: "spacing",
917
+ direction: "all"
918
+ },
919
+ m: {
920
+ rule: "margin",
921
+ type: "spacing",
922
+ direction: "all"
923
+ },
924
+ pt: {
925
+ rule: "padding",
926
+ type: "spacing",
927
+ direction: "top"
928
+ },
929
+ pl: {
930
+ rule: "padding",
931
+ type: "spacing",
932
+ direction: "left"
933
+ },
934
+ pb: {
935
+ rule: "padding",
936
+ type: "spacing",
937
+ direction: "bottom"
938
+ },
939
+ pr: {
940
+ rule: "padding",
941
+ type: "spacing",
942
+ direction: "right"
943
+ },
944
+ px: {
945
+ rule: "padding",
946
+ type: "spacing",
947
+ direction: "x"
948
+ },
949
+ py: {
950
+ rule: "padding",
951
+ type: "spacing",
952
+ direction: "y"
953
+ },
954
+ mt: {
955
+ rule: "margin",
956
+ type: "spacing",
957
+ direction: "top"
958
+ },
959
+ ml: {
960
+ rule: "margin",
961
+ type: "spacing",
962
+ direction: "left"
963
+ },
964
+ mb: {
965
+ rule: "margin",
966
+ type: "spacing",
967
+ direction: "bottom"
968
+ },
969
+ mr: {
970
+ rule: "margin",
971
+ type: "spacing",
972
+ direction: "right"
973
+ },
974
+ mx: {
975
+ rule: "margin",
976
+ type: "spacing",
977
+ direction: "x"
978
+ },
979
+ my: {
980
+ rule: "margin",
981
+ type: "spacing",
982
+ direction: "y"
983
+ },
984
+ bg: {
985
+ rule: "background-color",
986
+ type: "color"
987
+ },
988
+ rounded: {
989
+ rule: "border-radius",
990
+ type: "rounded",
991
+ direction: "all"
992
+ },
993
+ roundedTopLeft: {
994
+ rule: "border-radius",
995
+ type: "rounded",
996
+ direction: "topLeft",
997
+ ordering: "clockwise"
998
+ },
999
+ roundedBottomLeft: {
1000
+ rule: "border-radius",
1001
+ type: "rounded",
1002
+ direction: "bottomLeft",
1003
+ ordering: "clockwise"
1004
+ },
1005
+ roundedBottomRight: {
1006
+ rule: "border-radius",
1007
+ type: "rounded",
1008
+ direction: "bottomRight",
1009
+ ordering: "clockwise"
1010
+ },
1011
+ roundedTopRight: {
1012
+ rule: "border-radius",
1013
+ type: "rounded",
1014
+ direction: "topRight",
1015
+ ordering: "clockwise"
1016
+ },
1017
+ roundedTop: {
1018
+ rule: "border-radius",
1019
+ type: "rounded",
1020
+ direction: "top",
1021
+ ordering: "clockwise"
1022
+ },
1023
+ roundedBottom: {
1024
+ rule: "border-radius",
1025
+ type: "rounded",
1026
+ direction: "bottom",
1027
+ ordering: "clockwise"
1028
+ },
1029
+ roundedLeft: {
1030
+ rule: "border-radius",
1031
+ type: "rounded",
1032
+ direction: "left",
1033
+ ordering: "clockwise"
1034
+ },
1035
+ roundedRight: {
1036
+ rule: "border-radius",
1037
+ type: "rounded",
1038
+ direction: "right",
1039
+ ordering: "clockwise"
1040
+ },
1041
+ border: {
1042
+ rule: "border-width",
1043
+ type: "spacing",
1044
+ direction: "all",
1045
+ default: "px"
1046
+ },
1047
+ borderTop: {
1048
+ rule: "border-width",
1049
+ type: "spacing",
1050
+ direction: "top",
1051
+ default: "px"
1052
+ },
1053
+ borderLeft: {
1054
+ rule: "border-width",
1055
+ type: "spacing",
1056
+ direction: "left",
1057
+ default: "px"
1058
+ },
1059
+ borderBottom: {
1060
+ rule: "border-width",
1061
+ type: "spacing",
1062
+ direction: "bottom",
1063
+ default: "px"
1064
+ },
1065
+ borderRight: {
1066
+ rule: "border-width",
1067
+ type: "spacing",
1068
+ direction: "right",
1069
+ default: "px"
1070
+ },
1071
+ borderX: {
1072
+ rule: "border-width",
1073
+ type: "spacing",
1074
+ direction: "x",
1075
+ default: "px"
1076
+ },
1077
+ borderY: {
1078
+ rule: "border-width",
1079
+ type: "spacing",
1080
+ direction: "y",
1081
+ default: "px"
1082
+ },
1083
+ borderColor: {
1084
+ rule: "border-color",
1085
+ type: "color",
1086
+ default: "gray-4"
1087
+ },
1088
+ borderStyle: {
1089
+ rule: "border-style",
1090
+ type: "border-style",
1091
+ default: "solid"
1092
+ },
1093
+ shadow: {
1094
+ rule: "box-shadow",
1095
+ type: "shadow"
1096
+ }
1097
+ }, X = ({
1098
+ as: r,
1099
+ className: t,
1100
+ tgphRef: e,
1101
+ ...a
1102
+ }) => {
1103
+ const i = r || "div", o = p.useRef(null), n = z(e, o), l = p.useMemo(() => {
1104
+ const c = { borderColor: !0, ...a };
1105
+ return Object.keys(c).reduce(
1106
+ (d, s) => (Object.keys(ee).some((g) => g === s) ? d.box[s] = c[s] : d.rest[s] = c[s], d),
1107
+ { box: {}, rest: {} }
1108
+ );
1109
+ }, [a]);
1110
+ return p.useLayoutEffect(() => {
1111
+ pe({
1112
+ props: l.box,
1113
+ ref: o,
1114
+ propsMap: ee
1115
+ });
1116
+ }, [l.box]), /* @__PURE__ */ u(
1117
+ i,
1118
+ {
1119
+ className: $("tgph-box", t),
1120
+ ref: n,
1121
+ ...l.rest
1122
+ }
1123
+ );
1124
+ }, te = {
1125
+ display: {
1126
+ rule: "display",
1127
+ type: "flex-display",
1128
+ valueType: "static"
1129
+ },
1130
+ direction: {
1131
+ rule: "flex-direction",
1132
+ type: "flex-direction",
1133
+ valueType: "static"
1134
+ },
1135
+ align: {
1136
+ rule: "align-items",
1137
+ type: "align-items",
1138
+ valueType: "static"
1139
+ },
1140
+ justify: {
1141
+ rule: "justify-content",
1142
+ type: "justify-content",
1143
+ valueType: "static"
1144
+ },
1145
+ wrap: {
1146
+ rule: "flex-wrap",
1147
+ type: "flex-wrap",
1148
+ valueType: "static"
1149
+ },
1150
+ gap: {
1151
+ rule: "gap",
1152
+ type: "spacing",
1153
+ valueType: "variable"
1154
+ }
1155
+ }, L = ({
1156
+ className: r,
1157
+ tgphRef: t,
1158
+ ...e
1159
+ }) => {
1160
+ const a = p.useRef(null), i = z(t, a), o = p.useMemo(
1161
+ () => Object.keys(e).reduce(
1162
+ (n, l) => (Object.keys(te).some((c) => c === l) ? n.stack[l] = e[l] : n.rest[l] = e[l], n),
1163
+ { stack: {}, rest: {} }
1164
+ ),
1165
+ [e]
1166
+ );
1167
+ return p.useLayoutEffect(() => {
1168
+ pe({
1169
+ props: o.stack,
1170
+ ref: a,
1171
+ propsMap: te
1172
+ });
1173
+ }, [o.stack, i]), /* @__PURE__ */ u(
1174
+ X,
1175
+ {
1176
+ className: $("tgph-stack", r),
1177
+ tgphRef: i,
1178
+ ...o.rest
1179
+ }
1180
+ );
1181
+ }, Q = (r) => Array.isArray(r), q = (r) => typeof r == "object" && !Array.isArray(r), Ie = ["ArrowDown", "PageUp", "Home"], Ve = ["ArrowUp", "PageDown", "End"], w = p.createContext({
1182
+ onValueChange: () => {
1183
+ },
1184
+ contentId: "",
1185
+ triggerId: "",
1186
+ open: !1,
1187
+ setOpen: () => {
1188
+ },
1189
+ onOpenToggle: () => {
1190
+ }
1191
+ }), Ae = ({
1192
+ modal: r = !0,
1193
+ closeOnSelect: t = !0,
1194
+ open: e,
1195
+ onOpenChange: a,
1196
+ defaultOpen: i,
1197
+ value: o,
1198
+ onValueChange: n,
1199
+ errored: l,
1200
+ placeholder: c,
1201
+ layout: d,
1202
+ ...s
1203
+ }) => {
1204
+ const g = p.useId(), m = p.useId(), b = p.useRef(null), h = p.useRef(null), v = p.useRef(null), [k, E] = p.useState(""), [C = !1, B] = ge({
1205
+ prop: e,
1206
+ defaultProp: i,
1207
+ onChange: a
1208
+ }), se = p.useCallback(() => {
1209
+ B((de) => !de);
1210
+ }, [B]);
1211
+ return p.useEffect(() => {
1212
+ C || E("");
1213
+ }, [C]), /* @__PURE__ */ u(
1214
+ w.Provider,
1215
+ {
1216
+ value: {
1217
+ contentId: g,
1218
+ triggerId: m,
1219
+ value: o,
1220
+ onValueChange: n,
1221
+ placeholder: c,
1222
+ open: C,
1223
+ setOpen: B,
1224
+ onOpenToggle: se,
1225
+ closeOnSelect: t,
1226
+ searchQuery: k,
1227
+ setSearchQuery: E,
1228
+ triggerRef: b,
1229
+ searchRef: h,
1230
+ contentRef: v,
1231
+ errored: l,
1232
+ layout: d
1233
+ },
1234
+ children: /* @__PURE__ */ u(
1235
+ D.Root,
1236
+ {
1237
+ open: C,
1238
+ onOpenChange: B,
1239
+ modal: r,
1240
+ ...s
1241
+ }
1242
+ )
1243
+ }
1244
+ );
1245
+ }, Qe = ({ label: r, value: t, ...e }) => {
1246
+ const a = p.useContext(w);
1247
+ return /* @__PURE__ */ T(
1248
+ P.Root,
1249
+ {
1250
+ size: "1",
1251
+ as: S.span,
1252
+ initial: { opacity: 0, transform: "scale(0.8)" },
1253
+ animate: { opacity: 1, transform: "scale(1)" },
1254
+ exit: { opacity: 0, transform: "scale(0.5)" },
1255
+ layout: "position",
1256
+ transition: {
1257
+ duration: 0.2,
1258
+ type: "spring",
1259
+ bounce: 0,
1260
+ layout: {
1261
+ duration: 0.05,
1262
+ type: "spring",
1263
+ bounce: 0
1264
+ }
1265
+ },
1266
+ ...e,
1267
+ children: [
1268
+ /* @__PURE__ */ u(P.Text, { children: r || t }),
1269
+ /* @__PURE__ */ u(
1270
+ P.Button,
1271
+ {
1272
+ as: "span",
1273
+ role: "button",
1274
+ icon: { icon: _.X, alt: `Remove ${t}` },
1275
+ onClick: (i) => {
1276
+ const o = a.onValueChange, l = a.value.filter((c) => c.value !== t);
1277
+ o(l), i.stopPropagation();
1278
+ }
1279
+ }
1280
+ )
1281
+ ]
1282
+ }
1283
+ );
1284
+ }, Me = ({
1285
+ size: r = "1"
1286
+ }) => {
1287
+ var a, i;
1288
+ const t = p.useContext(w), e = r === "1" ? "6" : r === "2" ? "8" : "10";
1289
+ if (t.value && Q(t.value)) {
1290
+ const o = t.value, n = t.layout || "truncate", l = o.length - 2, c = l.toString().split("");
1291
+ return o.length === 0 ? /* @__PURE__ */ u(L, { h: e, align: "center", children: /* @__PURE__ */ u(M.Text, { color: "gray", children: t.placeholder }) }) : /* @__PURE__ */ T(
1292
+ L,
1293
+ {
1294
+ gap: "1",
1295
+ w: "full",
1296
+ my: "1",
1297
+ wrap: n === "wrap" ? "wrap" : "nowrap",
1298
+ align: "center",
1299
+ style: {
1300
+ position: "relative",
1301
+ flexGrow: 1
1302
+ },
1303
+ children: [
1304
+ /* @__PURE__ */ u(F, { initial: !1, mode: "popLayout", children: o.map((d, s) => {
1305
+ if (n === "truncate" && s <= 1 || n === "wrap")
1306
+ return /* @__PURE__ */ u(re, { children: /* @__PURE__ */ u(Qe, { ...d }) }, d.value);
1307
+ }) }),
1308
+ /* @__PURE__ */ u(F, { children: n === "truncate" && o.length > 2 && /* @__PURE__ */ u(
1309
+ L,
1310
+ {
1311
+ as: S.div,
1312
+ initial: { opacity: 0 },
1313
+ animate: { opacity: 1 },
1314
+ exit: { opacity: 0 },
1315
+ transition: { duration: 0.2, type: "spring", bounce: 0 },
1316
+ h: "full",
1317
+ pr: "1",
1318
+ pl: "8",
1319
+ align: "center",
1320
+ "aria-label": `${l} more selected`,
1321
+ style: {
1322
+ position: "absolute",
1323
+ right: 0,
1324
+ backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
1325
+ },
1326
+ children: /* @__PURE__ */ T(N, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
1327
+ "+",
1328
+ /* @__PURE__ */ u(F, { mode: "wait", initial: !1, children: c.map((d) => /* @__PURE__ */ u(
1329
+ X,
1330
+ {
1331
+ as: S.span,
1332
+ w: "2",
1333
+ display: "inline-block",
1334
+ initial: {
1335
+ opacity: 0.5
1336
+ },
1337
+ animate: {
1338
+ opacity: 1
1339
+ },
1340
+ exit: {
1341
+ opacity: 0.5
1342
+ },
1343
+ transition: { duration: 0.1, type: "spring", bounce: 0 },
1344
+ children: d
1345
+ },
1346
+ d
1347
+ )) }),
1348
+ " ",
1349
+ "more"
1350
+ ] })
1351
+ },
1352
+ "truncated text"
1353
+ ) })
1354
+ ]
1355
+ }
1356
+ );
1357
+ }
1358
+ return /* @__PURE__ */ u(L, { h: e, align: "center", my: "1", children: /* @__PURE__ */ u(M.Text, { color: t.value ? "default" : "gray", children: ((a = t == null ? void 0 : t.value) == null ? void 0 : a.label) || ((i = t == null ? void 0 : t.value) == null ? void 0 : i.value) || t.placeholder }) });
1359
+ }, Be = ({ size: r = "1", ...t }) => {
1360
+ const e = p.useContext(w), a = p.useCallback(() => {
1361
+ var i, o, n;
1362
+ return e.value ? q(e.value) ? ((i = e.value) == null ? void 0 : i.label) || ((o = e.value) == null ? void 0 : o.value) || e.placeholder : ((n = e.value) == null ? void 0 : n.map((l) => l.label).join(", ")) || e.placeholder : e.placeholder;
1363
+ }, [e.value, e.placeholder]);
1364
+ return /* @__PURE__ */ u(
1365
+ D.Anchor,
1366
+ {
1367
+ ...t,
1368
+ asChild: !0,
1369
+ onClick: (i) => {
1370
+ var o, n;
1371
+ i.preventDefault(), e.onOpenToggle(), (n = (o = e.triggerRef) == null ? void 0 : o.current) == null || n.focus();
1372
+ },
1373
+ onKeyDown: (i) => {
1374
+ i.key === "ArrowDown" && e.onOpenToggle(), (i.key === "Enter" || i.key === " ") && i.preventDefault();
1375
+ },
1376
+ tgphRef: e.triggerRef,
1377
+ children: /* @__PURE__ */ u(re, { children: /* @__PURE__ */ T(
1378
+ M.Root,
1379
+ {
1380
+ id: e.triggerId,
1381
+ variant: "outline",
1382
+ w: "full",
1383
+ h: "full",
1384
+ color: e.errored ? "red" : "gray",
1385
+ justify: "space-between",
1386
+ role: "combobox",
1387
+ "aria-label": a(),
1388
+ "aria-controls": e.contentId,
1389
+ "aria-expanded": e.open,
1390
+ "aria-haspopup": "listbox",
1391
+ "data-tgph-combobox-trigger": !0,
1392
+ "data-tgph-comobox-trigger-open": e.open,
1393
+ children: [
1394
+ /* @__PURE__ */ u(Me, { size: r }),
1395
+ /* @__PURE__ */ u(
1396
+ M.Icon,
1397
+ {
1398
+ as: S.div,
1399
+ icon: _.ChevronDown,
1400
+ animate: { rotate: e.open ? "180deg" : "0deg" },
1401
+ transition: { duration: 0.2, type: "spring", bounce: 0 },
1402
+ "aria-hidden": !0
1403
+ }
1404
+ )
1405
+ ]
1406
+ }
1407
+ ) })
1408
+ }
1409
+ );
1410
+ }, Ne = ({
1411
+ tgphRef: r,
1412
+ style: t,
1413
+ children: e,
1414
+ ...a
1415
+ }) => {
1416
+ const i = p.useContext(w), o = p.useRef(!1), n = z(r, i.contentRef), l = p.useRef(null), [c, d] = p.useState(0), [s, g] = p.useState(!1), m = p.useCallback(
1417
+ (b) => {
1418
+ const h = b.getBoundingClientRect();
1419
+ h && d(h.height), s || g(!0);
1420
+ },
1421
+ [s]
1422
+ );
1423
+ return p.useEffect(() => {
1424
+ const b = new ResizeObserver((h) => {
1425
+ for (const v of h) {
1426
+ const k = v.target;
1427
+ m(k);
1428
+ }
1429
+ });
1430
+ return l.current && s && b.observe(l.current), () => b.disconnect();
1431
+ }, [s, m]), p.useEffect(() => {
1432
+ s === !0 && i.open === !1 && g(!1);
1433
+ }, [i.open, s]), /* @__PURE__ */ u(
1434
+ D.Content,
1435
+ {
1436
+ as: S.div,
1437
+ mt: "1",
1438
+ initial: {
1439
+ opacity: 0,
1440
+ scale: 0.8,
1441
+ height: "auto"
1442
+ },
1443
+ animate: {
1444
+ opacity: 1,
1445
+ scale: 1,
1446
+ // Set height based on the internalContentRef so that
1447
+ // we get smooth animations when the content changes
1448
+ height: c ? `${c}px` : "auto"
1449
+ },
1450
+ exit: { opacity: 0, scale: 0 },
1451
+ transition: { duration: 0.2, type: "spring", bounce: 0 },
1452
+ onInteractOutside: () => {
1453
+ i.setOpen(!1), o.current = !0;
1454
+ },
1455
+ onAnimationComplete: () => {
1456
+ if (!s && l) {
1457
+ const b = l.current;
1458
+ m(b);
1459
+ }
1460
+ },
1461
+ onCloseAutoFocus: (b) => {
1462
+ var h, v;
1463
+ o.current || (v = (h = i.triggerRef) == null ? void 0 : h.current) == null || v.focus(), o.current = !1, b.preventDefault();
1464
+ },
1465
+ onKeyDown: (b) => {
1466
+ var v, k, E, C;
1467
+ const h = (k = (v = i.contentRef) == null ? void 0 : v.current) == null ? void 0 : k.querySelectorAll(
1468
+ "[data-tgph-combobox-option]"
1469
+ );
1470
+ document.activeElement === (h == null ? void 0 : h[0]) && Ve.includes(b.key) && ((C = (E = i.searchRef) == null ? void 0 : E.current) == null || C.focus()), b.key === "Escape" && i.setOpen(!1);
1471
+ },
1472
+ style: {
1473
+ width: "var(--tgph-comobobox-trigger-width)",
1474
+ ...t,
1475
+ "--tgph-comobobox-content-transform-origin": "var(--radix-popper-transform-origin)",
1476
+ "--tgph-combobox-content-available-width": "var(--radix-popper-available-width)",
1477
+ "--tgph-combobox-content-available-height": "calc(var(--radix-popper-available-height) - var(--tgph-spacing-8))",
1478
+ "--tgph-comobobox-trigger-width": "var(--radix-popper-anchor-width)",
1479
+ "--tgph-combobox-trigger-height": "var(--radix-popper-anchor-height)"
1480
+ },
1481
+ ...a,
1482
+ tgphRef: n,
1483
+ "data-tgph-combobox-content": !0,
1484
+ "data-tgph-combobox-content-open": s,
1485
+ role: void 0,
1486
+ "aria-orientation": void 0,
1487
+ children: /* @__PURE__ */ u(L, { direction: "column", gap: "1", tgphRef: l, children: e })
1488
+ }
1489
+ );
1490
+ }, ze = ({ ...r }) => {
1491
+ const t = p.useContext(w);
1492
+ return /* @__PURE__ */ u(
1493
+ L,
1494
+ {
1495
+ id: t.contentId,
1496
+ direction: "column",
1497
+ gap: "1",
1498
+ style: {
1499
+ overflowY: "auto"
1500
+ },
1501
+ role: "listbox",
1502
+ ...r
1503
+ }
1504
+ );
1505
+ }, ue = ({
1506
+ value: r,
1507
+ label: t,
1508
+ selected: e,
1509
+ onSelect: a,
1510
+ ...i
1511
+ }) => {
1512
+ const o = p.useContext(w), [n, l] = p.useState(!1), c = o.value ?? [], d = Q(c) ? !o.searchQuery || r.includes(o.searchQuery.toLowerCase()) : !o.searchQuery || r.toLowerCase().includes(o.searchQuery.toLowerCase()), s = Q(c) ? c.some((g) => g.value === r) : c.value === r;
1513
+ if (d)
1514
+ return /* @__PURE__ */ u(
1515
+ D.Button,
1516
+ {
1517
+ onSelect: (g) => {
1518
+ var m, b;
1519
+ if (!o.closeOnSelect && g.preventDefault(), a)
1520
+ return a(g);
1521
+ if (Q(c)) {
1522
+ const h = o.onValueChange, v = s ? c.filter((k) => k.value !== r) : [...c, { value: r, label: t }];
1523
+ h(v);
1524
+ } else if (q(c)) {
1525
+ const h = o.onValueChange;
1526
+ h({ value: r, label: t });
1527
+ }
1528
+ (b = (m = o.triggerRef) == null ? void 0 : m.current) == null || b.focus();
1529
+ },
1530
+ selected: e === null ? null : e ?? s,
1531
+ onFocus: () => l(!0),
1532
+ onBlur: () => l(!1),
1533
+ role: "option",
1534
+ "aria-selected": s ? "true" : "false",
1535
+ "data-tgph-combobox-option": !0,
1536
+ "data-tgph-combobox-option-focused": n,
1537
+ "data-tgph-combobox-option-value": r,
1538
+ "data-tgph-combobox-option-label": t,
1539
+ ...i,
1540
+ children: t || r
1541
+ }
1542
+ );
1543
+ }, De = ({
1544
+ label: r = "Search",
1545
+ placeholder: t = "Search",
1546
+ tgphRef: e,
1547
+ ...a
1548
+ }) => {
1549
+ var l;
1550
+ const i = p.useId(), o = p.useContext(w), n = z(e, o.searchRef);
1551
+ return p.useEffect(() => {
1552
+ var s;
1553
+ const c = (g) => {
1554
+ var m, b;
1555
+ Ie.includes(g.key) && ((b = (m = o.contentRef) == null ? void 0 : m.current) == null || b.focus({ preventScroll: !0 })), g.key === "Escape" && o.setOpen(!1), g.stopPropagation();
1556
+ }, d = (s = o.searchRef) == null ? void 0 : s.current;
1557
+ if (d)
1558
+ return d.addEventListener("keydown", c), () => {
1559
+ d.removeEventListener("keydown", c);
1560
+ };
1561
+ }, [o]), /* @__PURE__ */ T(X, { borderBottom: !0, px: "1", pb: "1", children: [
1562
+ /* @__PURE__ */ u(be.Root, { children: /* @__PURE__ */ u(N, { as: "label", htmlFor: i, children: r }) }),
1563
+ /* @__PURE__ */ u(
1564
+ ye,
1565
+ {
1566
+ id: i,
1567
+ variant: "ghost",
1568
+ placeholder: t,
1569
+ value: o.searchQuery,
1570
+ onChange: (c) => {
1571
+ var d;
1572
+ (d = o == null ? void 0 : o.setSearchQuery) == null || d.call(o, c.target.value);
1573
+ },
1574
+ LeadingComponent: /* @__PURE__ */ u(Y, { icon: _.Search, alt: "Search Icon" }),
1575
+ TrailingComponent: o != null && o.searchQuery && ((l = o == null ? void 0 : o.searchQuery) == null ? void 0 : l.length) > 0 ? /* @__PURE__ */ u(
1576
+ M,
1577
+ {
1578
+ as: S.button,
1579
+ initial: { opacity: 0 },
1580
+ animate: { opacity: 1 },
1581
+ transition: { duration: 0.2, type: "spring", bounce: 0 },
1582
+ variant: "ghost",
1583
+ color: "gray",
1584
+ icon: { icon: _.X, alt: "Clear Search Query" },
1585
+ onClick: () => {
1586
+ var c;
1587
+ return (c = o.setSearchQuery) == null ? void 0 : c.call(o, "");
1588
+ }
1589
+ }
1590
+ ) : null,
1591
+ autoFocus: !0,
1592
+ "data-tgph-combobox-search": !0,
1593
+ "aria-controls": o.contentId,
1594
+ ...a,
1595
+ tgphRef: n
1596
+ }
1597
+ )
1598
+ ] });
1599
+ }, Pe = ({
1600
+ icon: r = { icon: _.Search, alt: "Search Icon" },
1601
+ message: t = "No results found",
1602
+ children: e,
1603
+ ...a
1604
+ }) => {
1605
+ const i = p.useContext(w), [o, n] = p.useState(!1);
1606
+ if (p.useEffect(() => {
1607
+ var c, d;
1608
+ const l = (d = (c = i.contentRef) == null ? void 0 : c.current) == null ? void 0 : d.querySelectorAll(
1609
+ "[data-tgph-combobox-option]"
1610
+ );
1611
+ (l == null ? void 0 : l.length) === 0 ? n(!0) : n(!1);
1612
+ }, [i.searchQuery, i.contentRef, e]), o)
1613
+ return /* @__PURE__ */ T(
1614
+ L,
1615
+ {
1616
+ as: S.div,
1617
+ initial: { opacity: 0, scale: 0.8 },
1618
+ animate: { opacity: 1, scale: 1 },
1619
+ transition: { duration: 0.2, type: "spring", bounce: 0 },
1620
+ gap: "1",
1621
+ align: "center",
1622
+ justify: "center",
1623
+ w: "full",
1624
+ my: "8",
1625
+ "data-tgph-combobox-empty": !0,
1626
+ ...a,
1627
+ children: [
1628
+ r === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(Y, { ...r }),
1629
+ t === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(N, { as: "span", children: t })
1630
+ ]
1631
+ }
1632
+ );
1633
+ }, Fe = ({
1634
+ leadingText: r = "Create",
1635
+ values: t,
1636
+ onCreate: e,
1637
+ selected: a = null,
1638
+ ...i
1639
+ }) => {
1640
+ const o = p.useContext(w), n = p.useCallback(
1641
+ (l) => !t || (t == null ? void 0 : t.length) === 0 ? !1 : t.some((c) => c.value === l),
1642
+ [t]
1643
+ );
1644
+ if (o.searchQuery && !n(o.searchQuery))
1645
+ return /* @__PURE__ */ u(
1646
+ ue,
1647
+ {
1648
+ leadingIcon: { icon: _.Plus, "aria-hidden": !0 },
1649
+ mx: "1",
1650
+ value: o.searchQuery,
1651
+ label: `${r} "${o.searchQuery}"`,
1652
+ selected: a,
1653
+ onSelect: () => {
1654
+ e && o.value && o.searchQuery && (q(o.value) && e({ value: o.searchQuery }), Q(o.value) && e({ value: o.searchQuery }));
1655
+ },
1656
+ ...i
1657
+ }
1658
+ );
1659
+ }, He = {};
1660
+ Object.assign(He, {
1661
+ Root: Ae,
1662
+ Trigger: Be,
1663
+ Content: Ne,
1664
+ Options: ze,
1665
+ Option: ue,
1666
+ Search: De,
1667
+ Empty: Pe,
1668
+ Create: Fe
1669
+ });
1670
+ export {
1671
+ He as Combobox
1672
+ };
1673
+ //# sourceMappingURL=index.mjs.map