@telegraph/combobox 0.0.19 → 0.0.21

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