@telegraph/combobox 0.0.30 → 0.0.32

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,24 +1,24 @@
1
- import { jsx as a, jsxs as w, Fragment as P } from "react/jsx-runtime";
1
+ import { jsx as c, jsxs as S, Fragment as V } from "react/jsx-runtime";
2
2
  import { useControllableState as G } from "@radix-ui/react-use-controllable-state";
3
- import * as Y from "@radix-ui/react-visually-hidden";
4
- import { Button as I } from "@telegraph/button";
3
+ import * as M from "@radix-ui/react-visually-hidden";
4
+ import { Button as k } from "@telegraph/button";
5
5
  import { useComposedRefs as F } from "@telegraph/compose-refs";
6
- import { RefToTgphRef as z } from "@telegraph/helpers";
7
- import { Lucide as R, Icon as H } from "@telegraph/icon";
8
- import { Input as M } from "@telegraph/input";
9
- import { Stack as k, Box as K } from "@telegraph/layout";
10
- import { Menu as Q } from "@telegraph/menu";
11
- import { Tag as A } from "@telegraph/tag";
6
+ import { RefToTgphRef as Y } from "@telegraph/helpers";
7
+ import { Lucide as v, Icon as H } from "@telegraph/icon";
8
+ import { Input as z } from "@telegraph/input";
9
+ import { Stack as E, Box as B } from "@telegraph/layout";
10
+ import { Menu as O } from "@telegraph/menu";
11
+ import { Tag as D } from "@telegraph/tag";
12
12
  import { Tooltip as X } from "@telegraph/tooltip";
13
- import { Text as D } from "@telegraph/typography";
14
- import { motion as S, AnimatePresence as O } from "framer-motion";
13
+ import { Text as P } from "@telegraph/typography";
14
+ import { motion as I, AnimatePresence as L } from "framer-motion";
15
15
  import i from "react";
16
16
  const q = {
17
17
  0: "5",
18
18
  1: "6",
19
19
  2: "8",
20
20
  3: "10"
21
- }, E = (n) => Array.isArray(n), L = (n) => typeof n == "object" && !Array.isArray(n), N = ["ArrowDown", "PageUp", "Home"], U = ["ArrowUp", "PageDown", "End"], j = ["Enter", " "], C = i.createContext({
21
+ }, R = (t) => Array.isArray(t), T = (t) => typeof t == "object" && !Array.isArray(t) || !t, N = ["ArrowDown", "PageUp", "Home"], U = ["ArrowUp", "PageDown", "End"], K = ["Enter", " "], x = i.createContext({
22
22
  onValueChange: () => {
23
23
  },
24
24
  contentId: "",
@@ -30,68 +30,68 @@ const q = {
30
30
  },
31
31
  clearable: !1
32
32
  }), J = ({
33
- modal: n = !0,
34
- closeOnSelect: c = !0,
33
+ modal: t = !0,
34
+ closeOnSelect: l = !0,
35
35
  clearable: e = !1,
36
- open: s,
37
- onOpenChange: r,
38
- defaultOpen: t,
39
- value: u,
36
+ open: u,
37
+ onOpenChange: s,
38
+ defaultOpen: r,
39
+ value: n,
40
40
  onValueChange: o,
41
- errored: l,
42
- placeholder: y,
43
- layout: f,
44
- ...b
41
+ errored: a,
42
+ placeholder: b,
43
+ layout: d,
44
+ ...y
45
45
  }) => {
46
- const g = i.useId(), p = i.useId(), h = i.useRef(null), d = i.useRef(null), m = i.useRef(null), [x, v] = i.useState(""), [T = !1, V] = G({
47
- prop: s,
48
- defaultProp: t,
49
- onChange: r
46
+ const p = i.useId(), g = i.useId(), h = i.useRef(null), m = i.useRef(null), f = i.useRef(null), [C, w] = i.useState(""), [Q = !1, A] = G({
47
+ prop: u,
48
+ defaultProp: r,
49
+ onChange: s
50
50
  }), _ = i.useCallback(() => {
51
- V(($) => !$);
52
- }, [V]);
51
+ A(($) => !$);
52
+ }, [A]);
53
53
  return i.useEffect(() => {
54
- T || v("");
55
- }, [T]), /* @__PURE__ */ a(
56
- C.Provider,
54
+ Q || w("");
55
+ }, [Q]), /* @__PURE__ */ c(
56
+ x.Provider,
57
57
  {
58
58
  value: {
59
- contentId: g,
60
- triggerId: p,
61
- value: u,
59
+ contentId: p,
60
+ triggerId: g,
61
+ value: n,
62
62
  onValueChange: o,
63
- placeholder: y,
64
- open: T,
65
- setOpen: V,
63
+ placeholder: b,
64
+ open: Q,
65
+ setOpen: A,
66
66
  onOpenToggle: _,
67
- closeOnSelect: c,
67
+ closeOnSelect: l,
68
68
  clearable: e,
69
- searchQuery: x,
70
- setSearchQuery: v,
69
+ searchQuery: C,
70
+ setSearchQuery: w,
71
71
  triggerRef: h,
72
- searchRef: d,
73
- contentRef: m,
74
- errored: l,
75
- layout: f
72
+ searchRef: m,
73
+ contentRef: f,
74
+ errored: a,
75
+ layout: d
76
76
  },
77
- children: /* @__PURE__ */ a(
78
- Q.Root,
77
+ children: /* @__PURE__ */ c(
78
+ O.Root,
79
79
  {
80
- open: T,
81
- onOpenChange: V,
82
- modal: n,
83
- ...b
80
+ open: Q,
81
+ onOpenChange: A,
82
+ modal: t,
83
+ ...y
84
84
  }
85
85
  )
86
86
  }
87
87
  );
88
- }, W = ({ label: n, value: c, ...e }) => {
89
- const s = i.useContext(C);
90
- return /* @__PURE__ */ w(
91
- A.Root,
88
+ }, W = ({ label: t, value: l, ...e }) => {
89
+ const u = i.useContext(x);
90
+ return /* @__PURE__ */ S(
91
+ D.Root,
92
92
  {
93
93
  size: "1",
94
- as: S.span,
94
+ as: I.span,
95
95
  initial: { opacity: 0, transform: "scale(0.8)" },
96
96
  animate: { opacity: 1, transform: "scale(1)" },
97
97
  exit: { opacity: 0, transform: "scale(0.5)" },
@@ -108,14 +108,15 @@ const q = {
108
108
  },
109
109
  ...e,
110
110
  children: [
111
- /* @__PURE__ */ a(A.Text, { children: n || c }),
112
- /* @__PURE__ */ a(
113
- A.Button,
111
+ /* @__PURE__ */ c(D.Text, { children: t || l }),
112
+ /* @__PURE__ */ c(
113
+ D.Button,
114
114
  {
115
- icon: { icon: R.X, alt: `Remove ${c}` },
116
- onClick: (r) => {
117
- const t = s.onValueChange, o = s.value.filter((l) => l.value !== c);
118
- t(o), r.stopPropagation(), r.preventDefault();
115
+ icon: { icon: v.X, alt: `Remove ${l}` },
116
+ onClick: (s) => {
117
+ if (!u.onValueChange) return;
118
+ const r = u.onValueChange, o = u.value.filter((a) => (a == null ? void 0 : a.value) !== l);
119
+ r == null || r(o), s.stopPropagation(), s.preventDefault();
119
120
  }
120
121
  }
121
122
  )
@@ -123,30 +124,30 @@ const q = {
123
124
  }
124
125
  );
125
126
  }, Z = () => {
126
- var c, e;
127
- const n = i.useContext(C);
128
- if (n.value && E(n.value)) {
129
- const s = n.value, r = n.layout || "truncate", t = s.length - 2, u = t.toString().split("");
130
- return s.length === 0 ? /* @__PURE__ */ a(I.Text, { color: "gray", children: n.placeholder }) : /* @__PURE__ */ w(
131
- k,
127
+ var l, e;
128
+ const t = i.useContext(x);
129
+ if (t.value && R(t.value)) {
130
+ const u = t.layout || "truncate", s = t.value.length - 2, r = s.toString().split("");
131
+ return t.value.length === 0 ? /* @__PURE__ */ c(k.Text, { color: "gray", children: t.placeholder }) : /* @__PURE__ */ S(
132
+ E,
132
133
  {
133
134
  gap: "1",
134
135
  w: "full",
135
- wrap: r === "wrap" ? "wrap" : "nowrap",
136
+ wrap: u === "wrap" ? "wrap" : "nowrap",
136
137
  align: "center",
137
138
  style: {
138
139
  position: "relative",
139
140
  flexGrow: 1
140
141
  },
141
142
  children: [
142
- /* @__PURE__ */ a(O, { initial: !1, mode: "popLayout", children: s.map((o, l) => {
143
- if (r === "truncate" && l <= 1 || r === "wrap")
144
- return /* @__PURE__ */ a(z, { children: /* @__PURE__ */ a(W, { ...o }) }, o.value);
143
+ /* @__PURE__ */ c(L, { initial: !1, mode: "popLayout", children: t.value.map((n, o) => {
144
+ if (n != null && n.value && (u === "truncate" && o <= 1 || u === "wrap"))
145
+ return /* @__PURE__ */ c(Y, { children: /* @__PURE__ */ c(W, { ...n }) }, n.value);
145
146
  }) }),
146
- /* @__PURE__ */ a(O, { children: r === "truncate" && s.length > 2 && /* @__PURE__ */ a(
147
- k,
147
+ /* @__PURE__ */ c(L, { children: u === "truncate" && t.value.length > 2 && /* @__PURE__ */ c(
148
+ E,
148
149
  {
149
- as: S.div,
150
+ as: I.div,
150
151
  initial: { opacity: 0 },
151
152
  animate: { opacity: 1 },
152
153
  exit: { opacity: 0 },
@@ -155,18 +156,18 @@ const q = {
155
156
  pr: "1",
156
157
  pl: "8",
157
158
  align: "center",
158
- "aria-label": `${t} more selected`,
159
+ "aria-label": `${s} more selected`,
159
160
  style: {
160
161
  position: "absolute",
161
162
  right: 0,
162
163
  backgroundImage: "linear-gradient(to left, var(--tgph-surface-1) 0 60%, transparent 90% 100%)"
163
164
  },
164
- children: /* @__PURE__ */ w(D, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
165
+ children: /* @__PURE__ */ S(P, { as: "span", size: "1", style: { whiteSpace: "nowrap" }, children: [
165
166
  "+",
166
- /* @__PURE__ */ a(O, { mode: "wait", initial: !1, children: u.map((o) => /* @__PURE__ */ a(
167
- K,
167
+ /* @__PURE__ */ c(L, { mode: "wait", initial: !1, children: r.map((n) => /* @__PURE__ */ c(
168
+ B,
168
169
  {
169
- as: S.span,
170
+ as: I.span,
170
171
  w: "2",
171
172
  display: "inline-block",
172
173
  initial: {
@@ -179,9 +180,9 @@ const q = {
179
180
  opacity: 0.5
180
181
  },
181
182
  transition: { duration: 0.1, type: "spring", bounce: 0 },
182
- children: o
183
+ children: n
183
184
  },
184
- o
185
+ n
185
186
  )) }),
186
187
  " ",
187
188
  "more"
@@ -193,83 +194,104 @@ const q = {
193
194
  }
194
195
  );
195
196
  }
196
- return /* @__PURE__ */ a(I.Text, { color: n.value ? "default" : "gray", children: ((c = n == null ? void 0 : n.value) == null ? void 0 : c.label) || ((e = n == null ? void 0 : n.value) == null ? void 0 : e.value) || n.placeholder });
197
- }, ee = ({ size: n = "2", ...c }) => {
198
- const e = i.useContext(C), s = i.useCallback(() => {
199
- var r, t, u;
200
- return e.value ? L(e.value) ? ((r = e.value) == null ? void 0 : r.label) || ((t = e.value) == null ? void 0 : t.value) || e.placeholder : ((u = e.value) == null ? void 0 : u.map((o) => o.label).join(", ")) || e.placeholder : e.placeholder;
201
- }, [e.value, e.placeholder]);
202
- return /* @__PURE__ */ a(
203
- Q.Trigger,
197
+ return /* @__PURE__ */ c(k.Text, { color: t.value ? "default" : "gray", children: ((l = t == null ? void 0 : t.value) == null ? void 0 : l.label) || ((e = t == null ? void 0 : t.value) == null ? void 0 : e.value) || t.placeholder });
198
+ }, ee = ({ size: t = "2", ...l }) => {
199
+ const e = i.useContext(x), u = i.useCallback(() => {
200
+ var n, o, a;
201
+ return e.value ? T(e.value) ? ((n = e.value) == null ? void 0 : n.label) || ((o = e.value) == null ? void 0 : o.value) || e.placeholder : ((a = e.value) == null ? void 0 : a.map((b) => b == null ? void 0 : b.label).join(", ")) || e.placeholder : e.placeholder;
202
+ }, [e.value, e.placeholder]), s = i.useMemo(() => {
203
+ var n;
204
+ if (R(e.value))
205
+ return e.clearable && ((n = e.value) == null ? void 0 : n.length) > 0;
206
+ if (T(e.value))
207
+ return e.clearable && e.value;
208
+ }, [e.clearable, e.value]), r = () => {
209
+ var n, o;
210
+ if (R(e.value)) {
211
+ const a = e.onValueChange;
212
+ a == null || a([]);
213
+ }
214
+ if (T(e.value)) {
215
+ const a = e.onValueChange;
216
+ a == null || a(void 0);
217
+ }
218
+ (o = (n = e.triggerRef) == null ? void 0 : n.current) == null || o.focus();
219
+ };
220
+ return /* @__PURE__ */ c(
221
+ O.Trigger,
204
222
  {
205
- ...c,
223
+ ...l,
206
224
  asChild: !0,
207
- onClick: (r) => {
208
- var t, u;
209
- r.preventDefault(), e.onOpenToggle(), (u = (t = e.triggerRef) == null ? void 0 : t.current) == null || u.focus();
225
+ onClick: (n) => {
226
+ var o, a;
227
+ n.preventDefault(), e.onOpenToggle(), (a = (o = e.triggerRef) == null ? void 0 : o.current) == null || a.focus();
210
228
  },
211
- onKeyDown: (r) => {
212
- if (r.key === "Tab") {
213
- r.stopPropagation();
229
+ onKeyDown: (n) => {
230
+ if (n.key === "Tab") {
231
+ n.stopPropagation();
214
232
  return;
215
233
  }
216
- if (j.includes(r.key)) {
217
- r.preventDefault();
234
+ if (K.includes(n.key)) {
235
+ n.preventDefault();
218
236
  return;
219
237
  }
220
- if (r.key === "ArrowDown") {
238
+ if (n.key === "ArrowDown") {
221
239
  e.onOpenToggle();
222
240
  return;
223
241
  }
224
242
  },
225
243
  tgphRef: e.triggerRef,
226
- children: /* @__PURE__ */ w(
227
- I.Root,
244
+ children: /* @__PURE__ */ S(
245
+ k.Root,
228
246
  {
229
247
  id: e.triggerId,
230
248
  bg: "surface-1",
231
249
  variant: "outline",
232
250
  align: "center",
233
- minH: q[n],
251
+ minH: q[t],
234
252
  h: "full",
235
253
  w: "full",
236
254
  py: "1",
237
- size: n,
255
+ size: t,
238
256
  color: e.errored ? "red" : "gray",
239
257
  justify: "space-between",
240
258
  role: "combobox",
241
- "aria-label": s(),
259
+ "aria-label": u(),
242
260
  "aria-controls": e.contentId,
243
261
  "aria-expanded": e.open,
244
262
  "aria-haspopup": "listbox",
245
263
  "data-tgph-combobox-trigger": !0,
246
264
  "data-tgph-comobox-trigger-open": e.open,
247
265
  children: [
248
- /* @__PURE__ */ a(Z, {}),
249
- /* @__PURE__ */ w(k, { align: "center", gap: "1", children: [
250
- e.clearable && e.value && /* @__PURE__ */ a(X, { label: "Clear field", children: /* @__PURE__ */ a(
251
- I,
266
+ /* @__PURE__ */ c(Z, {}),
267
+ /* @__PURE__ */ S(E, { align: "center", gap: "1", children: [
268
+ s && /* @__PURE__ */ c(X, { label: "Clear field", children: /* @__PURE__ */ c(
269
+ k,
252
270
  {
253
271
  type: "button",
254
- icon: { icon: R.X, alt: "Clear field" },
272
+ icon: { icon: v.X, alt: "Clear field" },
255
273
  size: "1",
256
274
  variant: "ghost",
257
- onClick: (r) => {
258
- var t;
259
- e.value && (r.stopPropagation(), (t = e == null ? void 0 : e.onValueChange) == null || t.call(e, void 0));
275
+ onClick: (n) => {
276
+ e.value && (n.stopPropagation(), r());
260
277
  },
261
- onKeyDown: (r) => {
262
- var t;
263
- (r.key === "Enter" || r.key === " ") && (r.stopPropagation(), (t = e == null ? void 0 : e.onValueChange) == null || t.call(e, void 0));
278
+ onKeyDown: (n) => {
279
+ (n.key === "Enter" || n.key === " ") && (n.stopPropagation(), r());
264
280
  },
265
- "data-tgph-combobox-clear": !0
281
+ "data-tgph-combobox-clear": !0,
282
+ style: {
283
+ // Remove margin to make the clear button flush
284
+ // with the trigger button
285
+ marginTop: "calc(-1 * var(--tgph-spacing-1)",
286
+ marginBottom: "calc(-1 * var(--tgph-spacing-1)"
287
+ }
266
288
  }
267
289
  ) }),
268
- /* @__PURE__ */ a(
269
- I.Icon,
290
+ /* @__PURE__ */ c(
291
+ k.Icon,
270
292
  {
271
- as: S.div,
272
- icon: R.ChevronDown,
293
+ as: I.div,
294
+ icon: v.ChevronDown,
273
295
  animate: { rotate: e.open ? "180deg" : "0deg" },
274
296
  transition: { duration: 0.2, type: "spring", bounce: 0 },
275
297
  "aria-hidden": !0
@@ -282,32 +304,32 @@ const q = {
282
304
  }
283
305
  );
284
306
  }, te = ({
285
- tgphRef: n,
286
- style: c,
307
+ tgphRef: t,
308
+ style: l,
287
309
  children: e,
288
- ...s
310
+ ...u
289
311
  }) => {
290
- const r = i.useContext(C), t = i.useRef(!1), u = F(n, r.contentRef), o = i.useRef(null), [l, y] = i.useState(0), [f, b] = i.useState(!1), g = i.useCallback(
291
- (p) => {
292
- const h = p.getBoundingClientRect();
293
- h && y(h.height), f || b(!0);
312
+ const s = i.useContext(x), r = i.useRef(!1), n = F(t, s.contentRef), o = i.useRef(null), [a, b] = i.useState(0), [d, y] = i.useState(!1), p = i.useCallback(
313
+ (g) => {
314
+ const h = g.getBoundingClientRect();
315
+ h && b(h.height), d || y(!0);
294
316
  },
295
- [f]
317
+ [d]
296
318
  );
297
319
  return i.useEffect(() => {
298
- const p = new ResizeObserver((h) => {
299
- for (const d of h) {
300
- const m = d.target;
301
- g(m);
320
+ const g = new ResizeObserver((h) => {
321
+ for (const m of h) {
322
+ const f = m.target;
323
+ p(f);
302
324
  }
303
325
  });
304
- return o.current && f && p.observe(o.current), () => p.disconnect();
305
- }, [f, g]), i.useEffect(() => {
306
- f === !0 && r.open === !1 && b(!1);
307
- }, [r.open, f]), /* @__PURE__ */ a(
308
- Q.Content,
326
+ return o.current && d && g.observe(o.current), () => g.disconnect();
327
+ }, [d, p]), i.useEffect(() => {
328
+ d === !0 && s.open === !1 && y(!1);
329
+ }, [s.open, d]), /* @__PURE__ */ c(
330
+ O.Content,
309
331
  {
310
- as: S.div,
332
+ as: I.div,
311
333
  mt: "1",
312
334
  initial: {
313
335
  opacity: 0,
@@ -319,52 +341,52 @@ const q = {
319
341
  scale: 1,
320
342
  // Set height based on the internalContentRef so that
321
343
  // we get smooth animations when the content changes
322
- minHeight: l ? `${l}px` : "0"
344
+ minHeight: a ? `${a}px` : "0"
323
345
  },
324
346
  exit: { opacity: 0, scale: 0 },
325
347
  transition: { duration: 0.2, type: "spring", bounce: 0 },
326
348
  onAnimationComplete: () => {
327
- if (!f && o) {
328
- const p = o.current;
329
- g(p);
349
+ if (!d && o) {
350
+ const g = o.current;
351
+ p(g);
330
352
  }
331
353
  },
332
- onCloseAutoFocus: (p) => {
333
- var h, d;
334
- t.current || (d = (h = r.triggerRef) == null ? void 0 : h.current) == null || d.focus(), t.current = !1, p.preventDefault();
354
+ onCloseAutoFocus: (g) => {
355
+ var h, m;
356
+ r.current || (m = (h = s.triggerRef) == null ? void 0 : h.current) == null || m.focus(), r.current = !1, g.preventDefault();
335
357
  },
336
- onKeyDown: (p) => {
337
- var d, m, x, v;
338
- const h = (m = (d = r.contentRef) == null ? void 0 : d.current) == null ? void 0 : m.querySelectorAll(
358
+ onKeyDown: (g) => {
359
+ var m, f, C, w;
360
+ const h = (f = (m = s.contentRef) == null ? void 0 : m.current) == null ? void 0 : f.querySelectorAll(
339
361
  "[data-tgph-combobox-option]"
340
362
  );
341
- document.activeElement === (h == null ? void 0 : h[0]) && U.includes(p.key) && ((v = (x = r.searchRef) == null ? void 0 : x.current) == null || v.focus()), p.key === "Escape" && r.setOpen(!1), p.stopPropagation();
363
+ document.activeElement === (h == null ? void 0 : h[0]) && U.includes(g.key) && ((w = (C = s.searchRef) == null ? void 0 : C.current) == null || w.focus()), g.key === "Escape" && s.setOpen(!1), g.stopPropagation();
342
364
  },
343
365
  bg: "surface-1",
344
366
  style: {
345
367
  width: "var(--tgph-comobobox-trigger-width)",
346
- ...c,
368
+ ...l,
347
369
  "--tgph-comobobox-content-transform-origin": "var(--radix-popper-transform-origin)",
348
370
  "--tgph-combobox-content-available-width": "var(--radix-popper-available-width)",
349
371
  "--tgph-combobox-content-available-height": "calc(var(--radix-popper-available-height) - var(--tgph-spacing-8))",
350
372
  "--tgph-comobobox-trigger-width": "var(--radix-popper-anchor-width)",
351
373
  "--tgph-combobox-trigger-height": "var(--radix-popper-anchor-height)"
352
374
  },
353
- ...s,
354
- tgphRef: u,
375
+ ...u,
376
+ tgphRef: n,
355
377
  "data-tgph-combobox-content": !0,
356
- "data-tgph-combobox-content-open": f,
378
+ "data-tgph-combobox-content-open": d,
357
379
  role: void 0,
358
380
  "aria-orientation": void 0,
359
- children: /* @__PURE__ */ a(k, { direction: "column", gap: "1", tgphRef: o, children: e })
381
+ children: /* @__PURE__ */ c(E, { direction: "column", gap: "1", tgphRef: o, children: e })
360
382
  }
361
383
  );
362
- }, oe = ({ ...n }) => {
363
- const c = i.useContext(C);
364
- return /* @__PURE__ */ a(
365
- k,
384
+ }, oe = ({ ...t }) => {
385
+ const l = i.useContext(x);
386
+ return /* @__PURE__ */ c(
387
+ E,
366
388
  {
367
- id: c.contentId,
389
+ id: l.contentId,
368
390
  direction: "column",
369
391
  gap: "1",
370
392
  style: {
@@ -373,127 +395,127 @@ const q = {
373
395
  maxHeight: "calc(var(--tgph-combobox-content-available-height) - var(--tgph-spacing-12))"
374
396
  },
375
397
  role: "listbox",
376
- ...n
398
+ ...t
377
399
  }
378
400
  );
379
- }, B = ({
380
- value: n,
381
- label: c,
401
+ }, j = ({
402
+ value: t,
403
+ label: l,
382
404
  selected: e,
383
- onSelect: s,
384
- ...r
405
+ onSelect: u,
406
+ ...s
385
407
  }) => {
386
- const t = i.useContext(C), [u, o] = i.useState(!1), l = t.value ?? [], y = (E(l), !t.searchQuery || n.toLowerCase().includes(t.searchQuery.toLowerCase())), f = E(l) ? l.some((g) => g.value === n) : l.value === n, b = (g) => {
387
- var h, d;
388
- const p = g;
389
- if (!(p.key && !j.includes(p.key))) {
390
- if (g.stopPropagation(), g.preventDefault(), t.closeOnSelect === !0 && t.setOpen(!1), s)
391
- return s(g);
392
- if (E(l)) {
393
- const m = t.onValueChange, x = f ? l.filter((v) => v.value !== n) : [...l, { value: n, label: c }];
394
- m(x);
395
- } else if (L(l)) {
396
- const m = t.onValueChange;
397
- m({ value: n, label: c });
408
+ const r = i.useContext(x), [n, o] = i.useState(!1), a = r.value, b = (R(a), !r.searchQuery || t.toLowerCase().includes(r.searchQuery.toLowerCase())), d = R(a) ? a.some((p) => (p == null ? void 0 : p.value) === t) : (a == null ? void 0 : a.value) === t, y = (p) => {
409
+ var h, m;
410
+ const g = p;
411
+ if (!(g.key && !K.includes(g.key))) {
412
+ if (p.stopPropagation(), p.preventDefault(), r.closeOnSelect === !0 && r.setOpen(!1), u)
413
+ return u(p);
414
+ if (T(a)) {
415
+ const f = r.onValueChange;
416
+ f == null || f({ value: t, label: l });
417
+ } else if (R(a)) {
418
+ const f = r.onValueChange, C = d ? a.filter((w) => (w == null ? void 0 : w.value) !== t) : [...a, { value: t, label: l }];
419
+ f == null || f(C);
398
420
  }
399
- (d = (h = t.triggerRef) == null ? void 0 : h.current) == null || d.focus();
421
+ (m = (h = r.triggerRef) == null ? void 0 : h.current) == null || m.focus();
400
422
  }
401
423
  };
402
- if (y)
403
- return /* @__PURE__ */ a(
404
- Q.Button,
424
+ if (b)
425
+ return /* @__PURE__ */ c(
426
+ O.Button,
405
427
  {
406
428
  type: "button",
407
- onSelect: b,
408
- onKeyDown: b,
409
- selected: e === null ? null : e ?? f,
429
+ onSelect: y,
430
+ onKeyDown: y,
431
+ selected: e === null ? null : e ?? d,
410
432
  onFocus: () => o(!0),
411
433
  onBlur: () => o(!1),
412
434
  role: "option",
413
- "aria-selected": f ? "true" : "false",
435
+ "aria-selected": d ? "true" : "false",
414
436
  "data-tgph-combobox-option": !0,
415
- "data-tgph-combobox-option-focused": u,
416
- "data-tgph-combobox-option-value": n,
417
- "data-tgph-combobox-option-label": c,
418
- ...r,
419
- children: c || n
437
+ "data-tgph-combobox-option-focused": n,
438
+ "data-tgph-combobox-option-value": t,
439
+ "data-tgph-combobox-option-label": l,
440
+ ...s,
441
+ children: l || t
420
442
  }
421
443
  );
422
444
  }, ne = ({
423
- label: n = "Search",
424
- placeholder: c = "Search",
445
+ label: t = "Search",
446
+ placeholder: l = "Search",
425
447
  tgphRef: e,
426
- value: s,
427
- onValueChange: r,
428
- ...t
448
+ value: u,
449
+ onValueChange: s,
450
+ ...r
429
451
  }) => {
430
- var b;
431
- const u = i.useId(), o = i.useContext(C), l = F(e, o.searchRef), y = s ?? o.searchQuery, f = r ?? o.setSearchQuery;
452
+ var y;
453
+ const n = i.useId(), o = i.useContext(x), a = F(e, o.searchRef), b = u ?? o.searchQuery, d = s ?? o.setSearchQuery;
432
454
  return i.useEffect(() => {
433
455
  var h;
434
- const g = (d) => {
435
- var m, x;
436
- N.includes(d.key) && ((x = (m = o.contentRef) == null ? void 0 : m.current) == null || x.focus({ preventScroll: !0 })), d.key === "Escape" && o.setOpen(!1), d.stopPropagation();
437
- }, p = (h = o.searchRef) == null ? void 0 : h.current;
438
- if (p)
439
- return p.addEventListener("keydown", g), () => {
440
- p.removeEventListener("keydown", g);
456
+ const p = (m) => {
457
+ var f, C;
458
+ N.includes(m.key) && ((C = (f = o.contentRef) == null ? void 0 : f.current) == null || C.focus({ preventScroll: !0 })), m.key === "Escape" && o.setOpen(!1), m.stopPropagation();
459
+ }, g = (h = o.searchRef) == null ? void 0 : h.current;
460
+ if (g)
461
+ return g.addEventListener("keydown", p), () => {
462
+ g.removeEventListener("keydown", p);
441
463
  };
442
- }, [o]), /* @__PURE__ */ w(K, { borderBottom: "px", px: "1", pb: "1", children: [
443
- /* @__PURE__ */ a(Y.Root, { children: /* @__PURE__ */ a(D, { as: "label", htmlFor: u, children: n }) }),
444
- /* @__PURE__ */ a(
445
- M,
464
+ }, [o]), /* @__PURE__ */ S(B, { borderBottom: "px", px: "1", pb: "1", children: [
465
+ /* @__PURE__ */ c(M.Root, { children: /* @__PURE__ */ c(P, { as: "label", htmlFor: n, children: t }) }),
466
+ /* @__PURE__ */ c(
467
+ z,
446
468
  {
447
- id: u,
469
+ id: n,
448
470
  variant: "ghost",
449
- placeholder: c,
450
- value: y,
451
- onChange: (g) => {
452
- f(g.target.value);
471
+ placeholder: l,
472
+ value: b,
473
+ onChange: (p) => {
474
+ d(p.target.value);
453
475
  },
454
- LeadingComponent: /* @__PURE__ */ a(H, { icon: R.Search, alt: "Search Icon" }),
455
- TrailingComponent: o != null && o.searchQuery && ((b = o == null ? void 0 : o.searchQuery) == null ? void 0 : b.length) > 0 ? /* @__PURE__ */ a(
456
- I,
476
+ LeadingComponent: /* @__PURE__ */ c(H, { icon: v.Search, alt: "Search Icon" }),
477
+ TrailingComponent: o != null && o.searchQuery && ((y = o == null ? void 0 : o.searchQuery) == null ? void 0 : y.length) > 0 ? /* @__PURE__ */ c(
478
+ k,
457
479
  {
458
- as: S.button,
480
+ as: I.button,
459
481
  initial: { opacity: 0 },
460
482
  animate: { opacity: 1 },
461
483
  transition: { duration: 0.2, type: "spring", bounce: 0 },
462
484
  variant: "ghost",
463
485
  color: "gray",
464
- icon: { icon: R.X, alt: "Clear Search Query" },
486
+ icon: { icon: v.X, alt: "Clear Search Query" },
465
487
  onClick: () => {
466
- var g;
467
- return (g = o.setSearchQuery) == null ? void 0 : g.call(o, "");
488
+ var p;
489
+ return (p = o.setSearchQuery) == null ? void 0 : p.call(o, "");
468
490
  }
469
491
  }
470
492
  ) : null,
471
493
  autoFocus: !0,
472
494
  "data-tgph-combobox-search": !0,
473
495
  "aria-controls": o.contentId,
474
- ...t,
475
- tgphRef: l
496
+ ...r,
497
+ tgphRef: a
476
498
  }
477
499
  )
478
500
  ] });
479
501
  }, re = ({
480
- icon: n = { icon: R.Search, alt: "Search Icon" },
481
- message: c = "No results found",
502
+ icon: t = { icon: v.Search, alt: "Search Icon" },
503
+ message: l = "No results found",
482
504
  children: e,
483
- ...s
505
+ ...u
484
506
  }) => {
485
- const r = i.useContext(C), [t, u] = i.useState(!1);
507
+ const s = i.useContext(x), [r, n] = i.useState(!1);
486
508
  if (i.useEffect(() => {
487
- var l, y;
488
- const o = (y = (l = r.contentRef) == null ? void 0 : l.current) == null ? void 0 : y.querySelectorAll(
509
+ var a, b;
510
+ const o = (b = (a = s.contentRef) == null ? void 0 : a.current) == null ? void 0 : b.querySelectorAll(
489
511
  "[data-tgph-combobox-option]"
490
512
  );
491
- (o == null ? void 0 : o.length) === 0 ? u(!0) : u(!1);
492
- }, [r.searchQuery, r.contentRef, e]), t)
493
- return /* @__PURE__ */ w(
494
- k,
513
+ (o == null ? void 0 : o.length) === 0 ? n(!0) : n(!1);
514
+ }, [s.searchQuery, s.contentRef, e]), r)
515
+ return /* @__PURE__ */ S(
516
+ E,
495
517
  {
496
- as: S.div,
518
+ as: I.div,
497
519
  initial: { opacity: 0, scale: 0.8 },
498
520
  animate: { opacity: 1, scale: 1 },
499
521
  transition: { duration: 0.2, type: "spring", bounce: 0 },
@@ -503,38 +525,38 @@ const q = {
503
525
  w: "full",
504
526
  my: "8",
505
527
  "data-tgph-combobox-empty": !0,
506
- ...s,
528
+ ...u,
507
529
  children: [
508
- n === null ? /* @__PURE__ */ a(P, {}) : /* @__PURE__ */ a(H, { ...n }),
509
- c === null ? /* @__PURE__ */ a(P, {}) : /* @__PURE__ */ a(D, { as: "span", children: c })
530
+ t === null ? /* @__PURE__ */ c(V, {}) : /* @__PURE__ */ c(H, { ...t }),
531
+ l === null ? /* @__PURE__ */ c(V, {}) : /* @__PURE__ */ c(P, { as: "span", children: l })
510
532
  ]
511
533
  }
512
534
  );
513
535
  }, ae = ({
514
- leadingText: n = "Create",
515
- values: c,
536
+ leadingText: t = "Create",
537
+ values: l,
516
538
  onCreate: e,
517
- selected: s = null,
518
- ...r
539
+ selected: u = null,
540
+ ...s
519
541
  }) => {
520
- const t = i.useContext(C), u = i.useCallback(
521
- (o) => !c || (c == null ? void 0 : c.length) === 0 ? !1 : c.some((l) => l.value === o),
522
- [c]
542
+ const r = i.useContext(x), n = i.useCallback(
543
+ (o) => !l || (l == null ? void 0 : l.length) === 0 ? !1 : l.some((a) => (a == null ? void 0 : a.value) === o),
544
+ [l]
523
545
  );
524
- if (t.searchQuery && !u(t.searchQuery))
525
- return /* @__PURE__ */ a(
526
- B,
546
+ if (r.searchQuery && !n(r.searchQuery))
547
+ return /* @__PURE__ */ c(
548
+ j,
527
549
  {
528
- leadingIcon: { icon: R.Plus, "aria-hidden": !0 },
550
+ leadingIcon: { icon: v.Plus, "aria-hidden": !0 },
529
551
  mx: "1",
530
- value: t.searchQuery,
531
- label: `${n} "${t.searchQuery}"`,
532
- selected: s,
552
+ value: r.searchQuery,
553
+ label: `${t} "${r.searchQuery}"`,
554
+ selected: u,
533
555
  onSelect: () => {
534
556
  var o;
535
- e && t.value && t.searchQuery && (L(t.value) && e({ value: t.searchQuery }), E(t.value) && e({ value: t.searchQuery }), (o = t.setSearchQuery) == null || o.call(t, ""));
557
+ e && r.value && r.searchQuery && (T(r.value) && e({ value: r.searchQuery }), R(r.value) && e({ value: r.searchQuery }), (o = r.setSearchQuery) == null || o.call(r, ""));
536
558
  },
537
- ...r
559
+ ...s
538
560
  }
539
561
  );
540
562
  }, ie = {};
@@ -543,7 +565,7 @@ Object.assign(ie, {
543
565
  Trigger: ee,
544
566
  Content: te,
545
567
  Options: oe,
546
- Option: B,
568
+ Option: j,
547
569
  Search: ne,
548
570
  Empty: re,
549
571
  Create: ae