@telegraph/combobox 0.0.1 → 0.0.2

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.
@@ -1,71 +1,71 @@
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";
1
+ import { jsx as u, jsxs as S, Fragment as W } from "react/jsx-runtime";
2
+ import { useControllableState as be } from "@radix-ui/react-use-controllable-state";
3
+ import * as he from "@radix-ui/react-visually-hidden";
4
+ import { Icon as K, Lucide as j } from "@telegraph/icon";
5
+ import * as ye from "react";
6
6
  import p from "react";
7
- import { Text as N } from "@telegraph/typography";
8
- import { useComposedRefs as z } from "@telegraph/compose-refs";
7
+ import { Text as P } from "@telegraph/typography";
8
+ import { useComposedRefs as B } from "@telegraph/compose-refs";
9
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) {
10
+ import { Input as fe } from "@telegraph/input";
11
+ import { Menu as N } from "@telegraph/menu";
12
+ import { Tag as z } from "@telegraph/tag";
13
+ import { motion as E, AnimatePresence as F } from "framer-motion";
14
+ function oe(o) {
15
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);
16
+ if (typeof o == "string" || typeof o == "number") a += o;
17
+ else if (typeof o == "object") if (Array.isArray(o)) {
18
+ var i = o.length;
19
+ for (t = 0; t < i; t++) o[t] && (e = oe(o[t])) && (a && (a += " "), a += e);
20
+ } else for (e in o) o[e] && (a && (a += " "), a += e);
21
21
  return a;
22
22
  }
23
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);
24
+ for (var o, t, e = 0, a = "", i = arguments.length; e < i; e++) (o = arguments[e]) && (t = oe(o)) && (a && (a += " "), a += t);
25
25
  return a;
26
26
  }
27
- function fe(r, t) {
28
- typeof r == "function" ? r(t) : r != null && (r.current = t);
27
+ function me(o, t) {
28
+ typeof o == "function" ? o(t) : o != null && (o.current = t);
29
29
  }
30
- function me(...r) {
31
- return (t) => r.forEach((e) => fe(e, t));
30
+ function ve(...o) {
31
+ return (t) => o.forEach((e) => me(e, t));
32
32
  }
33
- function ae(...r) {
34
- return he.useCallback(me(...r), r);
33
+ function ae(...o) {
34
+ return ye.useCallback(ve(...o), o);
35
35
  }
36
- const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
36
+ const O = ["sm", "md", "lg", "xl", "2xl"], we = (o) => {
37
37
  const t = [];
38
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);
39
+ for (let a = 0; a < O.length; a++) {
40
+ const i = O[a];
41
+ if (o[i])
42
+ e = o[i], t.push(e);
43
43
  else if (e !== null)
44
44
  t.push(e);
45
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]];
46
+ let r = null;
47
+ for (let n = a + 1; n < O.length; n++)
48
+ if (o[O[n]]) {
49
+ r = o[O[n]];
50
50
  break;
51
51
  }
52
- if (o !== null) {
52
+ if (r !== null) {
53
53
  for (let n = 0; n <= a; n++)
54
- t.push(o);
55
- e = o;
54
+ t.push(r);
55
+ e = r;
56
56
  }
57
57
  }
58
58
  }
59
59
  return t;
60
- }, we = (r) => typeof r == "object" && (r.sm || r.md || r.lg || r.xl || r["2xl"]), y = ({
61
- value: r,
60
+ }, xe = (o) => typeof o == "object" && (o.sm || o.md || o.lg || o.xl || o["2xl"]), f = ({
61
+ value: o,
62
62
  prop: t
63
63
  }) => {
64
- if (!r) return "";
64
+ if (!o) return "";
65
65
  if (t.valueType === "static")
66
- return r.toString();
66
+ return o.toString();
67
67
  const e = t.type === "color" ? "" : `-${t.type}`;
68
- return r === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${r})`;
68
+ return o === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${o})`;
69
69
  }, I = {
70
70
  top: 0,
71
71
  right: 1,
@@ -76,87 +76,87 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
76
76
  topRight: 1,
77
77
  bottomRight: 2,
78
78
  bottomLeft: 3
79
- }, xe = ({
80
- cssVariables: r,
79
+ }, Re = ({
80
+ cssVariables: o,
81
81
  value: t,
82
82
  prop: e,
83
83
  direction: a = "all"
84
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
85
+ const i = o[`--tgph-${e.rule}`] || "", r = i ? i.split(" ") : [], n = [
86
+ (r == null ? void 0 : r[0]) || 0,
87
+ (r == null ? void 0 : r[1]) || 0,
88
+ (r == null ? void 0 : r[2]) || 0,
89
+ (r == null ? void 0 : r[3]) || 0
90
90
  ];
91
- return a === "all" ? y({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[x.topLeft] = y({
91
+ return a === "all" ? f({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[x.topLeft] = f({
92
92
  value: t,
93
93
  prop: e
94
- }), n[x.topRight] = y({
94
+ }), n[x.topRight] = f({
95
95
  value: t,
96
96
  prop: e
97
- })), a === "right" && (n[x.topRight] = y({
97
+ })), a === "right" && (n[x.topRight] = f({
98
98
  value: t,
99
99
  prop: e
100
- }), n[x.bottomRight] = y({
100
+ }), n[x.bottomRight] = f({
101
101
  value: t,
102
102
  prop: e
103
- })), a === "bottom" && (n[x.bottomRight] = y({
103
+ })), a === "bottom" && (n[x.bottomRight] = f({
104
104
  value: t,
105
105
  prop: e
106
- }), n[x.bottomLeft] = y({
106
+ }), n[x.bottomLeft] = f({
107
107
  value: t,
108
108
  prop: e
109
- })), a === "left" && (n[x.bottomLeft] = y({
109
+ })), a === "left" && (n[x.bottomLeft] = f({
110
110
  value: t,
111
111
  prop: e
112
- }), n[x.topLeft] = y({
112
+ }), n[x.topLeft] = f({
113
113
  value: t,
114
114
  prop: e
115
- })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[x[a]] = y({
115
+ })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[x[a]] = f({
116
116
  value: t,
117
117
  prop: e
118
- }))) : (a === "x" && (n[I.left] = y({
118
+ }))) : (a === "x" && (n[I.left] = f({
119
119
  value: t,
120
120
  prop: e
121
- }), n[I.right] = y({
121
+ }), n[I.right] = f({
122
122
  value: t,
123
123
  prop: e
124
- })), a === "y" && (n[I.top] = y({
124
+ })), a === "y" && (n[I.top] = f({
125
125
  value: t,
126
126
  prop: e
127
- }), n[I.bottom] = y({
127
+ }), n[I.bottom] = f({
128
128
  value: t,
129
129
  prop: e
130
- })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[I[a]] = y({
130
+ })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[I[a]] = f({
131
131
  value: t,
132
132
  prop: e
133
133
  }))), n.join(" "));
134
134
  }, G = ({
135
- prop: r,
135
+ prop: o,
136
136
  value: t,
137
137
  cssVariables: e
138
- }) => r.direction ? xe({
138
+ }) => o.direction ? Re({
139
139
  cssVariables: e,
140
- prop: r,
140
+ prop: o,
141
141
  value: t,
142
- direction: r.direction,
143
- type: r.type
144
- }) : y({ value: t, prop: r }), ne = ({
145
- props: r,
142
+ direction: o.direction,
143
+ type: o.type
144
+ }) : f({ value: t, prop: o }), ne = ({
145
+ props: o,
146
146
  ref: t,
147
147
  propsMap: e
148
148
  }) => {
149
149
  if (!t.current) return;
150
150
  const a = {};
151
- Object.entries(r).forEach(([i, o]) => {
151
+ Object.entries(o).forEach(([i, r]) => {
152
152
  const n = e[i];
153
- n && (typeof o == "string" || typeof o == "boolean" ? a[`--tgph-${n.rule}`] = G({
153
+ n && (typeof r == "string" || typeof r == "boolean" ? a[`--tgph-${n.rule}`] = G({
154
154
  prop: n,
155
155
  key: i,
156
- value: o,
156
+ value: r,
157
157
  cssVariables: a
158
- }) : we(o) && ve(o).forEach((l, c) => {
159
- l && (a[`--tgph-${n.rule}-${j[c]}`] = G({
158
+ }) : xe(r) && we(r).forEach((l, c) => {
159
+ l && (a[`--tgph-${n.rule}-${O[c]}`] = G({
160
160
  prop: n,
161
161
  key: i,
162
162
  value: l,
@@ -371,23 +371,23 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
371
371
  rule: "box-shadow",
372
372
  type: "shadow"
373
373
  }
374
- }, Re = ({
375
- as: r,
374
+ }, ke = ({
375
+ as: o,
376
376
  className: t,
377
377
  tgphRef: e,
378
378
  ...a
379
379
  }) => {
380
- const i = r || "div", o = p.useRef(null), n = ae(e, o), l = p.useMemo(() => {
380
+ const i = o || "div", r = p.useRef(null), n = ae(e, r), l = p.useMemo(() => {
381
381
  const c = { borderColor: !0, ...a };
382
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),
383
+ (d, s) => (Object.keys(U).some((b) => b === s) ? d.box[s] = c[s] : d.rest[s] = c[s], d),
384
384
  { box: {}, rest: {} }
385
385
  );
386
386
  }, [a]);
387
387
  return p.useLayoutEffect(() => {
388
388
  ne({
389
389
  props: l.box,
390
- ref: o,
390
+ ref: r,
391
391
  propsMap: U
392
392
  });
393
393
  }, [l.box]), /* @__PURE__ */ u(
@@ -429,12 +429,12 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
429
429
  type: "spacing",
430
430
  valueType: "variable"
431
431
  }
432
- }, ke = ({
433
- className: r,
432
+ }, Ce = ({
433
+ className: o,
434
434
  tgphRef: t,
435
435
  ...e
436
436
  }) => {
437
- const a = p.useRef(null), i = ae(t, a), o = p.useMemo(
437
+ const a = p.useRef(null), i = ae(t, a), r = p.useMemo(
438
438
  () => Object.keys(e).reduce(
439
439
  (n, l) => (Object.keys(J).some((c) => c === l) ? n.stack[l] = e[l] : n.rest[l] = e[l], n),
440
440
  { stack: {}, rest: {} }
@@ -443,19 +443,19 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
443
443
  );
444
444
  return p.useLayoutEffect(() => {
445
445
  ne({
446
- props: o.stack,
446
+ props: r.stack,
447
447
  ref: a,
448
448
  propsMap: J
449
449
  });
450
- }, [o.stack, i]), /* @__PURE__ */ u(
451
- Re,
450
+ }, [r.stack, i]), /* @__PURE__ */ u(
451
+ ke,
452
452
  {
453
- className: $("tgph-stack", r),
453
+ className: $("tgph-stack", o),
454
454
  tgphRef: i,
455
- ...o.rest
455
+ ...r.rest
456
456
  }
457
457
  );
458
- }, Ce = {
458
+ }, Le = {
459
459
  solid: {
460
460
  gray: "bg-gray-9 hover:bg-gray-10 focus:bg-gray-11 data-[tgph-button-active=true]:!bg-gray-11",
461
461
  red: "bg-red-9 hover:bg-red-10 focus:bg-red-11 data-[tgph-button-active=true]:!bg-red-11",
@@ -477,13 +477,13 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
477
477
  disabled: "bg-gray-2"
478
478
  },
479
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",
480
+ gray: "bg-surface-1 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-surface-1 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-surface-1 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-surface-1 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-surface-1 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-surface-1 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-surface-1 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
487
  disabled: "bg-gray-2"
488
488
  },
489
489
  ghost: {
@@ -537,11 +537,11 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
537
537
  px: "0"
538
538
  }
539
539
  }
540
- }, Le = {
540
+ }, Te = {
541
541
  1: "1",
542
542
  2: "2",
543
543
  3: "3"
544
- }, Te = {
544
+ }, Se = {
545
545
  solid: {
546
546
  gray: "white",
547
547
  red: "white",
@@ -582,11 +582,11 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
582
582
  purple: "purple",
583
583
  disabled: "disabled"
584
584
  }
585
- }, Se = {
585
+ }, Ee = {
586
586
  1: "1",
587
587
  2: "2",
588
588
  3: "3"
589
- }, je = {
589
+ }, Oe = {
590
590
  solid: {
591
591
  gray: "white",
592
592
  red: "white",
@@ -627,10 +627,10 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
627
627
  purple: "purple",
628
628
  disabled: "disabled"
629
629
  }
630
- }, Oe = {
630
+ }, _e = {
631
631
  default: "secondary",
632
632
  "icon-only": "primary"
633
- }, K = p.createContext({
633
+ }, Y = p.createContext({
634
634
  variant: "solid",
635
635
  size: "2",
636
636
  color: "gray",
@@ -638,53 +638,53 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
638
638
  layout: "default",
639
639
  active: !1
640
640
  }), ie = ({
641
- as: r,
641
+ as: o,
642
642
  variant: t = "solid",
643
643
  size: e = "2",
644
644
  color: a = "gray",
645
645
  state: i = "default",
646
- active: o = !1,
646
+ active: r = !1,
647
647
  disabled: n,
648
648
  className: l,
649
649
  ...c
650
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)
651
+ const d = n ? "disabled" : i, s = d === "disabled" ? "disabled" : a, b = p.useMemo(() => {
652
+ var y;
653
+ const g = p.Children.toArray(c == null ? void 0 : c.children);
654
+ if ((g == null ? void 0 : g.length) === 1 && p.isValidElement(g[0])) {
655
+ const h = g[0];
656
+ if ((y = h == null ? void 0 : h.props) != null && y.icon)
657
657
  return "icon-only";
658
658
  }
659
659
  return "default";
660
660
  }, [c == null ? void 0 : c.children]);
661
661
  return /* @__PURE__ */ u(
662
- K.Provider,
662
+ Y.Provider,
663
663
  {
664
- value: { variant: t, size: e, color: s, state: d, layout: g, active: o },
664
+ value: { variant: t, size: e, color: s, state: d, layout: b, active: r },
665
665
  children: /* @__PURE__ */ u(
666
- ke,
666
+ Ce,
667
667
  {
668
- as: r || "button",
668
+ as: o || "button",
669
669
  className: $(
670
670
  "appearance-none border-0 cursor-pointer bg-none box-border [font-family:inherit]",
671
671
  "transition-colors no-underline",
672
672
  d === "disabled" && "cursor-not-allowed",
673
- Ce[t][s],
674
- V[g][e],
673
+ Le[t][s],
674
+ V[b][e],
675
675
  l
676
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,
677
+ h: V[b][e].h,
678
+ w: V[b][e].w,
679
+ gap: V[b][e].gap,
680
+ px: V[b][e].px,
681
681
  display: "inline-flex",
682
682
  align: "center",
683
683
  justify: "center",
684
684
  rounded: "3",
685
685
  "data-tgph-button": !0,
686
- "data-tgph-button-layout": g,
687
- "data-tgph-button-active": o,
686
+ "data-tgph-button-layout": b,
687
+ "data-tgph-button-active": r,
688
688
  disabled: n,
689
689
  ...c
690
690
  }
@@ -692,61 +692,61 @@ const j = ["sm", "md", "lg", "xl", "2xl"], ve = (r) => {
692
692
  }
693
693
  );
694
694
  }, H = ({
695
- size: r,
695
+ size: o,
696
696
  color: t,
697
697
  variant: e,
698
698
  icon: a,
699
699
  alt: i,
700
- "aria-hidden": o,
700
+ "aria-hidden": r,
701
701
  ...n
702
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]
703
+ const l = p.useContext(Y), c = {
704
+ size: o ?? Ee[l.size],
705
+ color: t ?? Oe[l.variant][l.color],
706
+ variant: e ?? _e[l.layout]
707
707
  };
708
708
  return /* @__PURE__ */ u(
709
- Y,
709
+ K,
710
710
  {
711
711
  icon: a,
712
712
  "data-button-icon": !0,
713
- ...i ? { alt: i } : { "aria-hidden": o },
713
+ ...i ? { alt: i } : { "aria-hidden": r },
714
714
  ...c,
715
715
  ...n
716
716
  }
717
717
  );
718
718
  }, le = ({
719
- as: r,
719
+ as: o,
720
720
  color: t,
721
721
  size: e,
722
722
  weight: a = "medium",
723
723
  className: i,
724
- ...o
724
+ ...r
725
725
  }) => {
726
- const n = p.useContext(K);
726
+ const n = p.useContext(Y);
727
727
  return /* @__PURE__ */ u(
728
- N,
728
+ P,
729
729
  {
730
- as: r || "span",
731
- color: t ?? Te[n.variant][n.color],
732
- size: e ?? Le[n.size],
730
+ as: o || "span",
731
+ color: t ?? Se[n.variant][n.color],
732
+ size: e ?? Te[n.size],
733
733
  weight: a,
734
734
  className: $("no-underline whitespace-nowrap", i),
735
735
  internal_optionalAs: !0,
736
736
  "data-button-text": !0,
737
- ...o
737
+ ...r
738
738
  }
739
739
  );
740
740
  }, ce = ({
741
- leadingIcon: r,
741
+ leadingIcon: o,
742
742
  trailingIcon: t,
743
743
  icon: e,
744
744
  children: a,
745
745
  ...i
746
746
  }) => {
747
- const o = r || e;
748
- return /* @__PURE__ */ T(ie, { ...i, children: [
749
- o && /* @__PURE__ */ u(H, { ...o }),
747
+ const r = o || e;
748
+ return /* @__PURE__ */ S(ie, { ...i, children: [
749
+ r && /* @__PURE__ */ u(H, { ...r }),
750
750
  a && /* @__PURE__ */ u(le, { children: a }),
751
751
  t && /* @__PURE__ */ u(H, { ...t })
752
752
  ] });
@@ -756,39 +756,39 @@ Object.assign(ce, {
756
756
  Icon: H,
757
757
  Text: le
758
758
  });
759
- const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
759
+ const D = ce, _ = ["sm", "md", "lg", "xl", "2xl"], je = (o) => {
760
760
  const t = [];
761
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);
762
+ for (let a = 0; a < _.length; a++) {
763
+ const i = _[a];
764
+ if (o[i])
765
+ e = o[i], t.push(e);
766
766
  else if (e !== null)
767
767
  t.push(e);
768
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]];
769
+ let r = null;
770
+ for (let n = a + 1; n < _.length; n++)
771
+ if (o[_[n]]) {
772
+ r = o[_[n]];
773
773
  break;
774
774
  }
775
- if (o !== null) {
775
+ if (r !== null) {
776
776
  for (let n = 0; n <= a; n++)
777
- t.push(o);
778
- e = o;
777
+ t.push(r);
778
+ e = r;
779
779
  }
780
780
  }
781
781
  }
782
782
  return t;
783
- }, $e = (r) => typeof r == "object" && (r.sm || r.md || r.lg || r.xl || r["2xl"]), f = ({
784
- value: r,
783
+ }, $e = (o) => typeof o == "object" && (o.sm || o.md || o.lg || o.xl || o["2xl"]), m = ({
784
+ value: o,
785
785
  prop: t
786
786
  }) => {
787
- if (!r) return "";
787
+ if (!o) return "";
788
788
  if (t.valueType === "static")
789
- return r.toString();
789
+ return o.toString();
790
790
  const e = t.type === "color" ? "" : `-${t.type}`;
791
- return r === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${r})`;
791
+ return o === !0 ? `var(--tgph${e}-${t.default})` : `var(--tgph${e}-${o})`;
792
792
  }, A = {
793
793
  top: 0,
794
794
  right: 1,
@@ -799,87 +799,87 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
799
799
  topRight: 1,
800
800
  bottomRight: 2,
801
801
  bottomLeft: 3
802
- }, Ee = ({
803
- cssVariables: r,
802
+ }, Ie = ({
803
+ cssVariables: o,
804
804
  value: t,
805
805
  prop: e,
806
806
  direction: a = "all"
807
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
808
+ const i = o[`--tgph-${e.rule}`] || "", r = i ? i.split(" ") : [], n = [
809
+ (r == null ? void 0 : r[0]) || 0,
810
+ (r == null ? void 0 : r[1]) || 0,
811
+ (r == null ? void 0 : r[2]) || 0,
812
+ (r == null ? void 0 : r[3]) || 0
813
813
  ];
814
- return a === "all" ? f({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[R.topLeft] = f({
814
+ return a === "all" ? m({ value: t, prop: e }) : (e.ordering === "clockwise" ? (a === "top" && (n[R.topLeft] = m({
815
815
  value: t,
816
816
  prop: e
817
- }), n[R.topRight] = f({
817
+ }), n[R.topRight] = m({
818
818
  value: t,
819
819
  prop: e
820
- })), a === "right" && (n[R.topRight] = f({
820
+ })), a === "right" && (n[R.topRight] = m({
821
821
  value: t,
822
822
  prop: e
823
- }), n[R.bottomRight] = f({
823
+ }), n[R.bottomRight] = m({
824
824
  value: t,
825
825
  prop: e
826
- })), a === "bottom" && (n[R.bottomRight] = f({
826
+ })), a === "bottom" && (n[R.bottomRight] = m({
827
827
  value: t,
828
828
  prop: e
829
- }), n[R.bottomLeft] = f({
829
+ }), n[R.bottomLeft] = m({
830
830
  value: t,
831
831
  prop: e
832
- })), a === "left" && (n[R.bottomLeft] = f({
832
+ })), a === "left" && (n[R.bottomLeft] = m({
833
833
  value: t,
834
834
  prop: e
835
- }), n[R.topLeft] = f({
835
+ }), n[R.topLeft] = m({
836
836
  value: t,
837
837
  prop: e
838
- })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[R[a]] = f({
838
+ })), (a === "topLeft" || a === "topRight" || a === "bottomRight" || a === "bottomLeft") && (n[R[a]] = m({
839
839
  value: t,
840
840
  prop: e
841
- }))) : (a === "x" && (n[A.left] = f({
841
+ }))) : (a === "x" && (n[A.left] = m({
842
842
  value: t,
843
843
  prop: e
844
- }), n[A.right] = f({
844
+ }), n[A.right] = m({
845
845
  value: t,
846
846
  prop: e
847
- })), a === "y" && (n[A.top] = f({
847
+ })), a === "y" && (n[A.top] = m({
848
848
  value: t,
849
849
  prop: e
850
- }), n[A.bottom] = f({
850
+ }), n[A.bottom] = m({
851
851
  value: t,
852
852
  prop: e
853
- })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[A[a]] = f({
853
+ })), (a === "top" || a === "bottom" || a === "left" || a === "right") && (n[A[a]] = m({
854
854
  value: t,
855
855
  prop: e
856
856
  }))), n.join(" "));
857
857
  }, Z = ({
858
- prop: r,
858
+ prop: o,
859
859
  value: t,
860
860
  cssVariables: e
861
- }) => r.direction ? Ee({
861
+ }) => o.direction ? Ie({
862
862
  cssVariables: e,
863
- prop: r,
863
+ prop: o,
864
864
  value: t,
865
- direction: r.direction,
866
- type: r.type
867
- }) : f({ value: t, prop: r }), pe = ({
868
- props: r,
865
+ direction: o.direction,
866
+ type: o.type
867
+ }) : m({ value: t, prop: o }), pe = ({
868
+ props: o,
869
869
  ref: t,
870
870
  propsMap: e
871
871
  }) => {
872
872
  if (!t.current) return;
873
873
  const a = {};
874
- Object.entries(r).forEach(([i, o]) => {
874
+ Object.entries(o).forEach(([i, r]) => {
875
875
  const n = e[i];
876
- n && (typeof o == "string" || typeof o == "boolean" ? a[`--tgph-${n.rule}`] = Z({
876
+ n && (typeof r == "string" || typeof r == "boolean" ? a[`--tgph-${n.rule}`] = Z({
877
877
  prop: n,
878
878
  key: i,
879
- value: o,
879
+ value: r,
880
880
  cssVariables: a
881
- }) : $e(o) && _e(o).forEach((l, c) => {
882
- l && (a[`--tgph-${n.rule}-${O[c]}`] = Z({
881
+ }) : $e(r) && je(r).forEach((l, c) => {
882
+ l && (a[`--tgph-${n.rule}-${_[c]}`] = Z({
883
883
  prop: n,
884
884
  key: i,
885
885
  value: l,
@@ -1095,22 +1095,22 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1095
1095
  type: "shadow"
1096
1096
  }
1097
1097
  }, X = ({
1098
- as: r,
1098
+ as: o,
1099
1099
  className: t,
1100
1100
  tgphRef: e,
1101
1101
  ...a
1102
1102
  }) => {
1103
- const i = r || "div", o = p.useRef(null), n = z(e, o), l = p.useMemo(() => {
1103
+ const i = o || "div", r = p.useRef(null), n = B(e, r), l = p.useMemo(() => {
1104
1104
  const c = { borderColor: !0, ...a };
1105
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),
1106
+ (d, s) => (Object.keys(ee).some((b) => b === s) ? d.box[s] = c[s] : d.rest[s] = c[s], d),
1107
1107
  { box: {}, rest: {} }
1108
1108
  );
1109
1109
  }, [a]);
1110
1110
  return p.useLayoutEffect(() => {
1111
1111
  pe({
1112
1112
  props: l.box,
1113
- ref: o,
1113
+ ref: r,
1114
1114
  propsMap: ee
1115
1115
  });
1116
1116
  }, [l.box]), /* @__PURE__ */ u(
@@ -1152,12 +1152,12 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1152
1152
  type: "spacing",
1153
1153
  valueType: "variable"
1154
1154
  }
1155
- }, L = ({
1156
- className: r,
1155
+ }, T = ({
1156
+ className: o,
1157
1157
  tgphRef: t,
1158
1158
  ...e
1159
1159
  }) => {
1160
- const a = p.useRef(null), i = z(t, a), o = p.useMemo(
1160
+ const a = p.useRef(null), i = B(t, a), r = p.useMemo(
1161
1161
  () => Object.keys(e).reduce(
1162
1162
  (n, l) => (Object.keys(te).some((c) => c === l) ? n.stack[l] = e[l] : n.rest[l] = e[l], n),
1163
1163
  { stack: {}, rest: {} }
@@ -1166,19 +1166,19 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1166
1166
  );
1167
1167
  return p.useLayoutEffect(() => {
1168
1168
  pe({
1169
- props: o.stack,
1169
+ props: r.stack,
1170
1170
  ref: a,
1171
1171
  propsMap: te
1172
1172
  });
1173
- }, [o.stack, i]), /* @__PURE__ */ u(
1173
+ }, [r.stack, i]), /* @__PURE__ */ u(
1174
1174
  X,
1175
1175
  {
1176
- className: $("tgph-stack", r),
1176
+ className: $("tgph-stack", o),
1177
1177
  tgphRef: i,
1178
- ...o.rest
1178
+ ...r.rest
1179
1179
  }
1180
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({
1181
+ }, Q = (o) => Array.isArray(o), q = (o) => typeof o == "object" && !Array.isArray(o), Ve = ["ArrowDown", "PageUp", "Home"], Ae = ["ArrowUp", "PageDown", "End"], ue = ["Enter", " "], w = p.createContext({
1182
1182
  onValueChange: () => {
1183
1183
  },
1184
1184
  contentId: "",
@@ -1188,67 +1188,67 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1188
1188
  },
1189
1189
  onOpenToggle: () => {
1190
1190
  }
1191
- }), Ae = ({
1192
- modal: r = !0,
1191
+ }), Qe = ({
1192
+ modal: o = !0,
1193
1193
  closeOnSelect: t = !0,
1194
1194
  open: e,
1195
1195
  onOpenChange: a,
1196
1196
  defaultOpen: i,
1197
- value: o,
1197
+ value: r,
1198
1198
  onValueChange: n,
1199
1199
  errored: l,
1200
1200
  placeholder: c,
1201
1201
  layout: d,
1202
1202
  ...s
1203
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({
1204
+ const b = p.useId(), y = p.useId(), g = p.useRef(null), h = p.useRef(null), v = p.useRef(null), [k, C] = p.useState(""), [L = !1, M] = be({
1205
1205
  prop: e,
1206
1206
  defaultProp: i,
1207
1207
  onChange: a
1208
- }), se = p.useCallback(() => {
1209
- B((de) => !de);
1210
- }, [B]);
1208
+ }), de = p.useCallback(() => {
1209
+ M((ge) => !ge);
1210
+ }, [M]);
1211
1211
  return p.useEffect(() => {
1212
- C || E("");
1213
- }, [C]), /* @__PURE__ */ u(
1212
+ L || C("");
1213
+ }, [L]), /* @__PURE__ */ u(
1214
1214
  w.Provider,
1215
1215
  {
1216
1216
  value: {
1217
- contentId: g,
1218
- triggerId: m,
1219
- value: o,
1217
+ contentId: b,
1218
+ triggerId: y,
1219
+ value: r,
1220
1220
  onValueChange: n,
1221
1221
  placeholder: c,
1222
- open: C,
1223
- setOpen: B,
1224
- onOpenToggle: se,
1222
+ open: L,
1223
+ setOpen: M,
1224
+ onOpenToggle: de,
1225
1225
  closeOnSelect: t,
1226
1226
  searchQuery: k,
1227
- setSearchQuery: E,
1228
- triggerRef: b,
1227
+ setSearchQuery: C,
1228
+ triggerRef: g,
1229
1229
  searchRef: h,
1230
1230
  contentRef: v,
1231
1231
  errored: l,
1232
1232
  layout: d
1233
1233
  },
1234
1234
  children: /* @__PURE__ */ u(
1235
- D.Root,
1235
+ N.Root,
1236
1236
  {
1237
- open: C,
1238
- onOpenChange: B,
1239
- modal: r,
1237
+ open: L,
1238
+ onOpenChange: M,
1239
+ modal: o,
1240
1240
  ...s
1241
1241
  }
1242
1242
  )
1243
1243
  }
1244
1244
  );
1245
- }, Qe = ({ label: r, value: t, ...e }) => {
1245
+ }, De = ({ label: o, value: t, ...e }) => {
1246
1246
  const a = p.useContext(w);
1247
- return /* @__PURE__ */ T(
1248
- P.Root,
1247
+ return /* @__PURE__ */ S(
1248
+ z.Root,
1249
1249
  {
1250
1250
  size: "1",
1251
- as: S.span,
1251
+ as: E.span,
1252
1252
  initial: { opacity: 0, transform: "scale(0.8)" },
1253
1253
  animate: { opacity: 1, transform: "scale(1)" },
1254
1254
  exit: { opacity: 0, transform: "scale(0.5)" },
@@ -1265,16 +1265,14 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1265
1265
  },
1266
1266
  ...e,
1267
1267
  children: [
1268
- /* @__PURE__ */ u(P.Text, { children: r || t }),
1268
+ /* @__PURE__ */ u(z.Text, { children: o || t }),
1269
1269
  /* @__PURE__ */ u(
1270
- P.Button,
1270
+ z.Button,
1271
1271
  {
1272
- as: "span",
1273
- role: "button",
1274
- icon: { icon: _.X, alt: `Remove ${t}` },
1272
+ icon: { icon: j.X, alt: `Remove ${t}` },
1275
1273
  onClick: (i) => {
1276
- const o = a.onValueChange, l = a.value.filter((c) => c.value !== t);
1277
- o(l), i.stopPropagation();
1274
+ const r = a.onValueChange, l = a.value.filter((c) => c.value !== t);
1275
+ r(l), i.stopPropagation(), i.preventDefault();
1278
1276
  }
1279
1277
  }
1280
1278
  )
@@ -1282,14 +1280,14 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1282
1280
  }
1283
1281
  );
1284
1282
  }, Me = ({
1285
- size: r = "1"
1283
+ size: o = "1"
1286
1284
  }) => {
1287
1285
  var a, i;
1288
- const t = p.useContext(w), e = r === "1" ? "6" : r === "2" ? "8" : "10";
1286
+ const t = p.useContext(w), e = o === "1" ? "6" : o === "2" ? "8" : "10";
1289
1287
  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,
1288
+ const r = t.value, n = t.layout || "truncate", l = r.length - 2, c = l.toString().split("");
1289
+ return r.length === 0 ? /* @__PURE__ */ u(T, { h: e, align: "center", my: "1", children: /* @__PURE__ */ u(D.Text, { color: "gray", children: t.placeholder }) }) : /* @__PURE__ */ S(
1290
+ T,
1293
1291
  {
1294
1292
  gap: "1",
1295
1293
  w: "full",
@@ -1301,14 +1299,14 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1301
1299
  flexGrow: 1
1302
1300
  },
1303
1301
  children: [
1304
- /* @__PURE__ */ u(F, { initial: !1, mode: "popLayout", children: o.map((d, s) => {
1302
+ /* @__PURE__ */ u(F, { initial: !1, mode: "popLayout", children: r.map((d, s) => {
1305
1303
  if (n === "truncate" && s <= 1 || n === "wrap")
1306
- return /* @__PURE__ */ u(re, { children: /* @__PURE__ */ u(Qe, { ...d }) }, d.value);
1304
+ return /* @__PURE__ */ u(re, { children: /* @__PURE__ */ u(De, { ...d }) }, d.value);
1307
1305
  }) }),
1308
- /* @__PURE__ */ u(F, { children: n === "truncate" && o.length > 2 && /* @__PURE__ */ u(
1309
- L,
1306
+ /* @__PURE__ */ u(F, { children: n === "truncate" && r.length > 2 && /* @__PURE__ */ u(
1307
+ T,
1310
1308
  {
1311
- as: S.div,
1309
+ as: E.div,
1312
1310
  initial: { opacity: 0 },
1313
1311
  animate: { opacity: 1 },
1314
1312
  exit: { opacity: 0 },
@@ -1323,12 +1321,12 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1323
1321
  right: 0,
1324
1322
  backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
1325
1323
  },
1326
- children: /* @__PURE__ */ T(N, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
1324
+ children: /* @__PURE__ */ S(P, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
1327
1325
  "+",
1328
1326
  /* @__PURE__ */ u(F, { mode: "wait", initial: !1, children: c.map((d) => /* @__PURE__ */ u(
1329
1327
  X,
1330
1328
  {
1331
- as: S.span,
1329
+ as: E.span,
1332
1330
  w: "2",
1333
1331
  display: "inline-block",
1334
1332
  initial: {
@@ -1355,29 +1353,41 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1355
1353
  }
1356
1354
  );
1357
1355
  }
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 }) => {
1356
+ return /* @__PURE__ */ u(T, { h: e, align: "center", my: "1", children: /* @__PURE__ */ u(D.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 }) });
1357
+ }, Pe = ({ size: o = "1", ...t }) => {
1360
1358
  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;
1359
+ var i, r, n;
1360
+ return e.value ? q(e.value) ? ((i = e.value) == null ? void 0 : i.label) || ((r = e.value) == null ? void 0 : r.value) || e.placeholder : ((n = e.value) == null ? void 0 : n.map((l) => l.label).join(", ")) || e.placeholder : e.placeholder;
1363
1361
  }, [e.value, e.placeholder]);
1364
1362
  return /* @__PURE__ */ u(
1365
- D.Anchor,
1363
+ N.Anchor,
1366
1364
  {
1367
1365
  ...t,
1368
1366
  asChild: !0,
1369
1367
  onClick: (i) => {
1370
- var o, n;
1371
- i.preventDefault(), e.onOpenToggle(), (n = (o = e.triggerRef) == null ? void 0 : o.current) == null || n.focus();
1368
+ var r, n;
1369
+ i.preventDefault(), e.onOpenToggle(), (n = (r = e.triggerRef) == null ? void 0 : r.current) == null || n.focus();
1372
1370
  },
1373
1371
  onKeyDown: (i) => {
1374
- i.key === "ArrowDown" && e.onOpenToggle(), (i.key === "Enter" || i.key === " ") && i.preventDefault();
1372
+ if (i.key === "Tab") {
1373
+ i.stopPropagation();
1374
+ return;
1375
+ }
1376
+ if (ue.includes(i.key)) {
1377
+ i.preventDefault();
1378
+ return;
1379
+ }
1380
+ if (i.key === "ArrowDown") {
1381
+ e.onOpenToggle();
1382
+ return;
1383
+ }
1375
1384
  },
1376
1385
  tgphRef: e.triggerRef,
1377
- children: /* @__PURE__ */ u(re, { children: /* @__PURE__ */ T(
1378
- M.Root,
1386
+ children: /* @__PURE__ */ u(re, { children: /* @__PURE__ */ S(
1387
+ D.Root,
1379
1388
  {
1380
1389
  id: e.triggerId,
1390
+ bg: "surface-1",
1381
1391
  variant: "outline",
1382
1392
  w: "full",
1383
1393
  h: "full",
@@ -1391,12 +1401,12 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1391
1401
  "data-tgph-combobox-trigger": !0,
1392
1402
  "data-tgph-comobox-trigger-open": e.open,
1393
1403
  children: [
1394
- /* @__PURE__ */ u(Me, { size: r }),
1404
+ /* @__PURE__ */ u(Me, { size: o }),
1395
1405
  /* @__PURE__ */ u(
1396
- M.Icon,
1406
+ D.Icon,
1397
1407
  {
1398
- as: S.div,
1399
- icon: _.ChevronDown,
1408
+ as: E.div,
1409
+ icon: j.ChevronDown,
1400
1410
  animate: { rotate: e.open ? "180deg" : "0deg" },
1401
1411
  transition: { duration: 0.2, type: "spring", bounce: 0 },
1402
1412
  "aria-hidden": !0
@@ -1407,33 +1417,33 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1407
1417
  ) })
1408
1418
  }
1409
1419
  );
1410
- }, Ne = ({
1411
- tgphRef: r,
1420
+ }, Be = ({
1421
+ tgphRef: o,
1412
1422
  style: t,
1413
1423
  children: e,
1414
1424
  ...a
1415
1425
  }) => {
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);
1426
+ const i = p.useContext(w), r = p.useRef(!1), n = B(o, i.contentRef), l = p.useRef(null), [c, d] = p.useState(0), [s, b] = p.useState(!1), y = p.useCallback(
1427
+ (g) => {
1428
+ const h = g.getBoundingClientRect();
1429
+ h && d(h.height), s || b(!0);
1420
1430
  },
1421
1431
  [s]
1422
1432
  );
1423
1433
  return p.useEffect(() => {
1424
- const b = new ResizeObserver((h) => {
1434
+ const g = new ResizeObserver((h) => {
1425
1435
  for (const v of h) {
1426
1436
  const k = v.target;
1427
- m(k);
1437
+ y(k);
1428
1438
  }
1429
1439
  });
1430
- return l.current && s && b.observe(l.current), () => b.disconnect();
1431
- }, [s, m]), p.useEffect(() => {
1432
- s === !0 && i.open === !1 && g(!1);
1440
+ return l.current && s && g.observe(l.current), () => g.disconnect();
1441
+ }, [s, y]), p.useEffect(() => {
1442
+ s === !0 && i.open === !1 && b(!1);
1433
1443
  }, [i.open, s]), /* @__PURE__ */ u(
1434
- D.Content,
1444
+ N.Content,
1435
1445
  {
1436
- as: S.div,
1446
+ as: E.div,
1437
1447
  mt: "1",
1438
1448
  initial: {
1439
1449
  opacity: 0,
@@ -1445,30 +1455,31 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1445
1455
  scale: 1,
1446
1456
  // Set height based on the internalContentRef so that
1447
1457
  // we get smooth animations when the content changes
1448
- height: c ? `${c}px` : "auto"
1458
+ minHeight: c ? `${c}px` : "0"
1449
1459
  },
1450
1460
  exit: { opacity: 0, scale: 0 },
1451
1461
  transition: { duration: 0.2, type: "spring", bounce: 0 },
1452
1462
  onInteractOutside: () => {
1453
- i.setOpen(!1), o.current = !0;
1463
+ i.setOpen(!1), r.current = !0;
1454
1464
  },
1455
1465
  onAnimationComplete: () => {
1456
1466
  if (!s && l) {
1457
- const b = l.current;
1458
- m(b);
1467
+ const g = l.current;
1468
+ y(g);
1459
1469
  }
1460
1470
  },
1461
- onCloseAutoFocus: (b) => {
1471
+ onCloseAutoFocus: (g) => {
1462
1472
  var h, v;
1463
- o.current || (v = (h = i.triggerRef) == null ? void 0 : h.current) == null || v.focus(), o.current = !1, b.preventDefault();
1473
+ r.current || (v = (h = i.triggerRef) == null ? void 0 : h.current) == null || v.focus(), r.current = !1, g.preventDefault();
1464
1474
  },
1465
- onKeyDown: (b) => {
1466
- var v, k, E, C;
1475
+ onKeyDown: (g) => {
1476
+ var v, k, C, L;
1467
1477
  const h = (k = (v = i.contentRef) == null ? void 0 : v.current) == null ? void 0 : k.querySelectorAll(
1468
1478
  "[data-tgph-combobox-option]"
1469
1479
  );
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);
1480
+ document.activeElement === (h == null ? void 0 : h[0]) && Ae.includes(g.key) && ((L = (C = i.searchRef) == null ? void 0 : C.current) == null || L.focus()), g.key === "Escape" && i.setOpen(!1), g.stopPropagation();
1471
1481
  },
1482
+ bg: "surface-1",
1472
1483
  style: {
1473
1484
  width: "var(--tgph-comobobox-trigger-width)",
1474
1485
  ...t,
@@ -1484,49 +1495,53 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1484
1495
  "data-tgph-combobox-content-open": s,
1485
1496
  role: void 0,
1486
1497
  "aria-orientation": void 0,
1487
- children: /* @__PURE__ */ u(L, { direction: "column", gap: "1", tgphRef: l, children: e })
1498
+ children: /* @__PURE__ */ u(T, { direction: "column", gap: "1", tgphRef: l, children: e })
1488
1499
  }
1489
1500
  );
1490
- }, ze = ({ ...r }) => {
1501
+ }, Ne = ({ ...o }) => {
1491
1502
  const t = p.useContext(w);
1492
1503
  return /* @__PURE__ */ u(
1493
- L,
1504
+ T,
1494
1505
  {
1495
1506
  id: t.contentId,
1496
1507
  direction: "column",
1497
1508
  gap: "1",
1498
1509
  style: {
1499
- overflowY: "auto"
1510
+ overflowY: "auto",
1511
+ // Available Height - Padding from edge of screen
1512
+ maxHeight: "calc(var(--tgph-combobox-content-available-height) - var(--tgph-spacing-12))"
1500
1513
  },
1501
1514
  role: "listbox",
1502
- ...r
1515
+ ...o
1503
1516
  }
1504
1517
  );
1505
- }, ue = ({
1506
- value: r,
1518
+ }, se = ({
1519
+ value: o,
1507
1520
  label: t,
1508
1521
  selected: e,
1509
1522
  onSelect: a,
1510
1523
  ...i
1511
1524
  }) => {
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;
1525
+ const r = p.useContext(w), [n, l] = p.useState(!1), c = r.value ?? [], d = (Q(c), !r.searchQuery || o.toLowerCase().includes(r.searchQuery.toLowerCase())), s = Q(c) ? c.some((y) => y.value === o) : c.value === o, b = (y) => {
1526
+ var g, h;
1527
+ if (ue.includes(y.key)) {
1528
+ if (y.stopPropagation(), y.preventDefault(), r.closeOnSelect === !0 && r.setOpen(!1), a)
1529
+ return a(y);
1530
+ if (Q(c)) {
1531
+ const v = r.onValueChange, k = s ? c.filter((C) => C.value !== o) : [...c, { value: o, label: t }];
1532
+ v(k);
1533
+ } else if (q(c)) {
1534
+ const v = r.onValueChange;
1535
+ v({ value: o, label: t });
1536
+ }
1537
+ (h = (g = r.triggerRef) == null ? void 0 : g.current) == null || h.focus();
1538
+ }
1539
+ };
1513
1540
  if (d)
1514
1541
  return /* @__PURE__ */ u(
1515
- D.Button,
1542
+ N.Button,
1516
1543
  {
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
- },
1544
+ onKeyDown: b,
1530
1545
  selected: e === null ? null : e ?? s,
1531
1546
  onFocus: () => l(!0),
1532
1547
  onBlur: () => l(!1),
@@ -1534,86 +1549,86 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1534
1549
  "aria-selected": s ? "true" : "false",
1535
1550
  "data-tgph-combobox-option": !0,
1536
1551
  "data-tgph-combobox-option-focused": n,
1537
- "data-tgph-combobox-option-value": r,
1552
+ "data-tgph-combobox-option-value": o,
1538
1553
  "data-tgph-combobox-option-label": t,
1539
1554
  ...i,
1540
- children: t || r
1555
+ children: t || o
1541
1556
  }
1542
1557
  );
1543
- }, De = ({
1544
- label: r = "Search",
1558
+ }, ze = ({
1559
+ label: o = "Search",
1545
1560
  placeholder: t = "Search",
1546
1561
  tgphRef: e,
1547
1562
  ...a
1548
1563
  }) => {
1549
1564
  var l;
1550
- const i = p.useId(), o = p.useContext(w), n = z(e, o.searchRef);
1565
+ const i = p.useId(), r = p.useContext(w), n = B(e, r.searchRef);
1551
1566
  return p.useEffect(() => {
1552
1567
  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;
1568
+ const c = (b) => {
1569
+ var y, g;
1570
+ Ve.includes(b.key) && ((g = (y = r.contentRef) == null ? void 0 : y.current) == null || g.focus({ preventScroll: !0 })), b.key === "Escape" && r.setOpen(!1), b.stopPropagation();
1571
+ }, d = (s = r.searchRef) == null ? void 0 : s.current;
1557
1572
  if (d)
1558
1573
  return d.addEventListener("keydown", c), () => {
1559
1574
  d.removeEventListener("keydown", c);
1560
1575
  };
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 }) }),
1576
+ }, [r]), /* @__PURE__ */ S(X, { borderBottom: !0, px: "1", pb: "1", children: [
1577
+ /* @__PURE__ */ u(he.Root, { children: /* @__PURE__ */ u(P, { as: "label", htmlFor: i, children: o }) }),
1563
1578
  /* @__PURE__ */ u(
1564
- ye,
1579
+ fe,
1565
1580
  {
1566
1581
  id: i,
1567
1582
  variant: "ghost",
1568
1583
  placeholder: t,
1569
- value: o.searchQuery,
1584
+ value: r.searchQuery,
1570
1585
  onChange: (c) => {
1571
1586
  var d;
1572
- (d = o == null ? void 0 : o.setSearchQuery) == null || d.call(o, c.target.value);
1587
+ (d = r == null ? void 0 : r.setSearchQuery) == null || d.call(r, c.target.value);
1573
1588
  },
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,
1589
+ LeadingComponent: /* @__PURE__ */ u(K, { icon: j.Search, alt: "Search Icon" }),
1590
+ TrailingComponent: r != null && r.searchQuery && ((l = r == null ? void 0 : r.searchQuery) == null ? void 0 : l.length) > 0 ? /* @__PURE__ */ u(
1591
+ D,
1577
1592
  {
1578
- as: S.button,
1593
+ as: E.button,
1579
1594
  initial: { opacity: 0 },
1580
1595
  animate: { opacity: 1 },
1581
1596
  transition: { duration: 0.2, type: "spring", bounce: 0 },
1582
1597
  variant: "ghost",
1583
1598
  color: "gray",
1584
- icon: { icon: _.X, alt: "Clear Search Query" },
1599
+ icon: { icon: j.X, alt: "Clear Search Query" },
1585
1600
  onClick: () => {
1586
1601
  var c;
1587
- return (c = o.setSearchQuery) == null ? void 0 : c.call(o, "");
1602
+ return (c = r.setSearchQuery) == null ? void 0 : c.call(r, "");
1588
1603
  }
1589
1604
  }
1590
1605
  ) : null,
1591
1606
  autoFocus: !0,
1592
1607
  "data-tgph-combobox-search": !0,
1593
- "aria-controls": o.contentId,
1608
+ "aria-controls": r.contentId,
1594
1609
  ...a,
1595
1610
  tgphRef: n
1596
1611
  }
1597
1612
  )
1598
1613
  ] });
1599
- }, Pe = ({
1600
- icon: r = { icon: _.Search, alt: "Search Icon" },
1614
+ }, Fe = ({
1615
+ icon: o = { icon: j.Search, alt: "Search Icon" },
1601
1616
  message: t = "No results found",
1602
1617
  children: e,
1603
1618
  ...a
1604
1619
  }) => {
1605
- const i = p.useContext(w), [o, n] = p.useState(!1);
1620
+ const i = p.useContext(w), [r, n] = p.useState(!1);
1606
1621
  if (p.useEffect(() => {
1607
1622
  var c, d;
1608
1623
  const l = (d = (c = i.contentRef) == null ? void 0 : c.current) == null ? void 0 : d.querySelectorAll(
1609
1624
  "[data-tgph-combobox-option]"
1610
1625
  );
1611
1626
  (l == null ? void 0 : l.length) === 0 ? n(!0) : n(!1);
1612
- }, [i.searchQuery, i.contentRef, e]), o)
1613
- return /* @__PURE__ */ T(
1614
- L,
1627
+ }, [i.searchQuery, i.contentRef, e]), r)
1628
+ return /* @__PURE__ */ S(
1629
+ T,
1615
1630
  {
1616
- as: S.div,
1631
+ as: E.div,
1617
1632
  initial: { opacity: 0, scale: 0.8 },
1618
1633
  animate: { opacity: 1, scale: 1 },
1619
1634
  transition: { duration: 0.2, type: "spring", bounce: 0 },
@@ -1625,49 +1640,50 @@ const M = ce, O = ["sm", "md", "lg", "xl", "2xl"], _e = (r) => {
1625
1640
  "data-tgph-combobox-empty": !0,
1626
1641
  ...a,
1627
1642
  children: [
1628
- r === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(Y, { ...r }),
1629
- t === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(N, { as: "span", children: t })
1643
+ o === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(K, { ...o }),
1644
+ t === null ? /* @__PURE__ */ u(W, {}) : /* @__PURE__ */ u(P, { as: "span", children: t })
1630
1645
  ]
1631
1646
  }
1632
1647
  );
1633
- }, Fe = ({
1634
- leadingText: r = "Create",
1648
+ }, He = ({
1649
+ leadingText: o = "Create",
1635
1650
  values: t,
1636
1651
  onCreate: e,
1637
1652
  selected: a = null,
1638
1653
  ...i
1639
1654
  }) => {
1640
- const o = p.useContext(w), n = p.useCallback(
1655
+ const r = p.useContext(w), n = p.useCallback(
1641
1656
  (l) => !t || (t == null ? void 0 : t.length) === 0 ? !1 : t.some((c) => c.value === l),
1642
1657
  [t]
1643
1658
  );
1644
- if (o.searchQuery && !n(o.searchQuery))
1659
+ if (r.searchQuery && !n(r.searchQuery))
1645
1660
  return /* @__PURE__ */ u(
1646
- ue,
1661
+ se,
1647
1662
  {
1648
- leadingIcon: { icon: _.Plus, "aria-hidden": !0 },
1663
+ leadingIcon: { icon: j.Plus, "aria-hidden": !0 },
1649
1664
  mx: "1",
1650
- value: o.searchQuery,
1651
- label: `${r} "${o.searchQuery}"`,
1665
+ value: r.searchQuery,
1666
+ label: `${o} "${r.searchQuery}"`,
1652
1667
  selected: a,
1653
1668
  onSelect: () => {
1654
- e && o.value && o.searchQuery && (q(o.value) && e({ value: o.searchQuery }), Q(o.value) && e({ value: o.searchQuery }));
1669
+ var l;
1670
+ e && r.value && r.searchQuery && (q(r.value) && e({ value: r.searchQuery }), Q(r.value) && e({ value: r.searchQuery }), (l = r.setSearchQuery) == null || l.call(r, ""));
1655
1671
  },
1656
1672
  ...i
1657
1673
  }
1658
1674
  );
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
1675
+ }, Ke = {};
1676
+ Object.assign(Ke, {
1677
+ Root: Qe,
1678
+ Trigger: Pe,
1679
+ Content: Be,
1680
+ Options: Ne,
1681
+ Option: se,
1682
+ Search: ze,
1683
+ Empty: Fe,
1684
+ Create: He
1669
1685
  });
1670
1686
  export {
1671
- He as Combobox
1687
+ Ke as Combobox
1672
1688
  };
1673
1689
  //# sourceMappingURL=index.mjs.map