@choc-ui/chakra-autocomplete 6.1.3 → 6.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,84 +1,83 @@
1
- import { jsx as a, jsxs as q, Fragment as pt } from "react/jsx-runtime";
2
- import * as L from "react";
3
- import P, { useMemo as Z, useRef as se, useState as De, useEffect as j, forwardRef as U, useImperativeHandle as dt, memo as mt } from "react";
4
- import { useDisclosure as gt, useControllableState as ht, IconButton as vt, Portal as yt, Popover as N, chakra as bt, Flex as ve, Box as _e, Separator as Xe, Group as Ct, InputElement as Je, Input as wt, Spinner as nt, PopoverAnchor as St, Center as xt, Tag as J } from "@chakra-ui/react";
5
- const [Ot, H] = At();
6
- function At() {
7
- const e = L.createContext(void 0);
1
+ import { jsx as a, jsxs as Y, Fragment as at } from "react/jsx-runtime";
2
+ import * as N from "react";
3
+ import E, { useMemo as U, useRef as te, useState as Le, useEffect as L, forwardRef as B, useImperativeHandle as ct, memo as ft } from "react";
4
+ import { useDisclosure as dt, useControllableState as pt, IconButton as mt, Portal as gt, Popover as P, chakra as ht, Flex as pe, Box as je, Separator as Ve, Group as vt, InputElement as $e, Input as yt, Spinner as Ye, PopoverAnchor as bt, Center as Ct, Tag as Q } from "@chakra-ui/react";
5
+ const [It, W] = wt();
6
+ function wt() {
7
+ const e = N.createContext(void 0);
8
8
  e.displayName = "AutoCompleteContext";
9
9
  function t() {
10
- var o;
11
- const n = L.useContext(e), r = "useAutoCompleteContext: `context` is undefined. Seems you forgot to wrap all autoomplete components within `<AutoComplete />`";
10
+ const n = N.useContext(e), r = "useAutoCompleteContext: `context` is undefined. Seems you forgot to wrap all autoomplete components within `<AutoComplete />`";
12
11
  if (!n) {
13
- const s = new Error(r);
14
- throw s.name = "ContextError", (o = Error.captureStackTrace) == null || o.call(Error, s, t), s;
12
+ const o = new Error(r);
13
+ throw o.name = "ContextError", Error.captureStackTrace?.(o, t), o;
15
14
  }
16
15
  return n;
17
16
  }
18
17
  return [e.Provider, t, e];
19
18
  }
20
- function Et(e) {
21
- return e == null ? void 0 : e[0];
19
+ function xt(e) {
20
+ return e?.[0];
22
21
  }
23
- function Te(e) {
24
- return e != null && e.length ? e[e.length - 1] : void 0;
22
+ function Ne(e) {
23
+ return e?.length ? e[e.length - 1] : void 0;
25
24
  }
26
- function rt(e, t, n = 1, r = !0) {
25
+ function Xe(e, t, n = 1, r = !0) {
27
26
  if (t === 0) return -1;
28
27
  let o = e + n;
29
28
  return e === -1 && (o = n > 0 ? 0 : t - 1), r ? o = (o % t + t) % t : o = Math.max(0, Math.min(o, t - 1)), o;
30
29
  }
31
- function It(e, t, n = !0) {
32
- return rt(e, t, -1, n);
30
+ function St(e, t, n = !0) {
31
+ return Xe(e, t, -1, n);
33
32
  }
34
- function Pt(e, t, n = !0) {
35
- const r = rt(e, t.length, 1, n);
33
+ function Ot(e, t, n = !0) {
34
+ const r = Xe(e, t.length, 1, n);
36
35
  return t[r];
37
36
  }
38
- function Nt(e, t, n = !0) {
39
- const r = It(e, t.length, n);
37
+ function At(e, t, n = !0) {
38
+ const r = St(e, t.length, n);
40
39
  return t[r];
41
40
  }
42
- function Ge(e) {
41
+ function Fe(e) {
43
42
  return Array.isArray(e);
44
43
  }
45
- function Rt(e) {
46
- return Ge(e) && e.length === 0;
44
+ function Et(e) {
45
+ return Fe(e) && e.length === 0;
47
46
  }
48
- function Me(e) {
49
- return e !== null && typeof e == "object" && !Ge(e);
47
+ function De(e) {
48
+ return e !== null && typeof e == "object" && !Fe(e);
50
49
  }
51
- function jt(e) {
52
- return Me(e) && Object.keys(e).length === 0;
50
+ function Pt(e) {
51
+ return De(e) && Object.keys(e).length === 0;
53
52
  }
54
- function We(e) {
55
- return Ge(e) ? Rt(e) : Me(e) ? jt(e) : e == null || e === "";
53
+ function Te(e) {
54
+ return Fe(e) ? Et(e) : De(e) ? Pt(e) : e == null || e === "";
56
55
  }
57
- function me(e) {
56
+ function ce(e) {
58
57
  return typeof e > "u";
59
58
  }
60
- function ot(e) {
59
+ function qe(e) {
61
60
  return typeof e < "u";
62
61
  }
63
- function Lt(e, t) {
62
+ function Rt(e, t) {
64
63
  const n = {};
65
64
  return t.forEach((r) => {
66
65
  r in e && (n[r] = e[r]);
67
66
  }), n;
68
67
  }
69
- function ye(e, t) {
68
+ function me(e, t) {
70
69
  const n = { ...e };
71
70
  return t.forEach((r) => {
72
71
  delete n[r];
73
72
  }), n;
74
73
  }
75
- function Ft(e) {
74
+ function Lt(e) {
76
75
  return typeof e == "function";
77
76
  }
78
- function h(e, ...t) {
79
- return Ft(e) ? e(...t) : e;
77
+ function m(e, ...t) {
78
+ return Lt(e) ? e(...t) : e;
80
79
  }
81
- function Dt(e, t) {
80
+ function Nt(e, t) {
82
81
  if (e != null) {
83
82
  if (typeof e == "function") {
84
83
  e(t);
@@ -91,420 +90,393 @@ function Dt(e, t) {
91
90
  }
92
91
  }
93
92
  }
94
- function Tt(...e) {
93
+ function jt(...e) {
95
94
  return (t) => {
96
95
  e.forEach((n) => {
97
- Dt(n, t);
96
+ Nt(n, t);
98
97
  });
99
98
  };
100
99
  }
101
- function ke(...e) {
102
- return Z(() => Tt(...e), e);
103
- }
104
- var be = function(e, t) {
105
- for (var n, r = L.Children.toArray(e), o = 0, s = r; o < s.length; o++) {
106
- var u = s[o];
107
- if (t(u))
108
- return u;
109
- if (!((n = u.props) === null || n === void 0) && n.children) {
110
- var l = be(u.props.children, t);
111
- if (l)
112
- return l;
100
+ function _e(...e) {
101
+ return U(() => jt(...e), e);
102
+ }
103
+ var ge = function(e, t) {
104
+ for (var n, r = N.Children.toArray(e), o = 0, i = r; o < i.length; o++) {
105
+ var l = i[o];
106
+ if (t(l))
107
+ return l;
108
+ if (!((n = l.props) === null || n === void 0) && n.children) {
109
+ var u = ge(l.props.children, t);
110
+ if (u)
111
+ return u;
113
112
  }
114
113
  }
115
- }, de = function(e, t) {
114
+ }, ae = function(e, t) {
116
115
  for (var n = 0, r = t.length, o = e.length; n < r; n++, o++)
117
116
  e[o] = t[n];
118
117
  return e;
119
- }, st = function(e, t) {
120
- for (var n, r = L.Children.toArray(e), o = [], s = 0, u = r; s < u.length; s++) {
121
- var l = u[s];
122
- t(l) && (o = de(de([], o), [l])), !((n = l.props) === null || n === void 0) && n.children && (o = de(de([], o), st(l.props.children, t)));
118
+ }, Je = function(e, t) {
119
+ for (var n, r = N.Children.toArray(e), o = [], i = 0, l = r; i < l.length; i++) {
120
+ var u = l[i];
121
+ t(u) && (o = ae(ae([], o), [u])), !((n = u.props) === null || n === void 0) && n.children && (o = ae(ae([], o), Je(u.props.children, t)));
123
122
  }
124
123
  return o;
125
124
  };
126
- function Ze(e, t, n = 2) {
127
- function r(d, C) {
128
- d = " ".repeat(C - 1) + d.toLowerCase() + " ".repeat(C - 1);
129
- let E = new Array(d.length - C + 1);
130
- for (let O = 0; O < E.length; O++)
131
- E[O] = d.slice(O, O + C);
132
- return E;
125
+ function He(e, t, n = 2) {
126
+ function r(f, y) {
127
+ f = " ".repeat(y - 1) + f.toLowerCase() + " ".repeat(y - 1);
128
+ let O = new Array(f.length - y + 1);
129
+ for (let w = 0; w < O.length; w++)
130
+ O[w] = f.slice(w, w + y);
131
+ return O;
133
132
  }
134
- if (!(e != null && e.length) || !(t != null && t.length))
133
+ if (!e?.length || !t?.length)
135
134
  return 0;
136
- let o = e.length < t.length ? e : t, s = e.length < t.length ? t : e, u = r(o, n), l = r(s, n), f = new Set(u), v = l.length, y = 0;
137
- for (let d of l)
138
- f.delete(d) && y++;
139
- return y / v;
140
- }
141
- const ze = (e) => {
142
- var t;
143
- return (t = typeof e == "string" || typeof e == "number" ? e : e[Object.keys(e)[0]]) == null ? void 0 : t.toString();
144
- }, _t = (e, t) => typeof e != "string" || We(t) ? e : e.toString().replace(
145
- new RegExp(kt(t), "gi"),
135
+ let o = e.length < t.length ? e : t, i = e.length < t.length ? t : e, l = r(o, n), u = r(i, n), c = new Set(l), g = u.length, h = 0;
136
+ for (let f of u)
137
+ c.delete(f) && h++;
138
+ return h / g;
139
+ }
140
+ const Ge = (e) => (typeof e == "string" || typeof e == "number" ? e : e[Object.keys(e)[0]])?.toString(), Ft = (e, t) => typeof e != "string" || Te(t) ? e : e.toString().replace(
141
+ new RegExp(Gt(t), "gi"),
146
142
  (r) => `<mark>${r}</mark>`
147
- ), Gt = (e) => st(
143
+ ), Dt = (e) => Je(
148
144
  e,
149
- (n) => {
150
- var r;
151
- return ((r = n == null ? void 0 : n.type) == null ? void 0 : r.displayName) === "AutoCompleteItem";
152
- }
145
+ (n) => n?.type?.displayName === "AutoCompleteItem"
153
146
  ).map((n) => {
154
- const r = Lt(n.props, ["value", "label", "fixed", "disabled"]), { getValue: o = ze } = n.props, s = o(r.value);
155
- return { ...ot(r.label) ? r : { ...r, label: s }, value: s, originalValue: r.value };
156
- }), Mt = () => ({
147
+ const r = Rt(n.props, ["value", "label", "fixed", "disabled"]), { getValue: o = Ge } = n.props, i = o(r.value);
148
+ return { ...qe(r.label) ? r : { ...r, label: i }, value: i, originalValue: r.value };
149
+ }), Tt = () => ({
157
150
  bg: "whiteAlpha.100",
158
151
  _light: {
159
152
  bg: "gray.200"
160
153
  }
161
- }), Wt = (e, t, n) => (t == null ? void 0 : t.toLowerCase().indexOf(e == null ? void 0 : e.toLowerCase())) >= 0 || (n == null ? void 0 : n.toLowerCase().indexOf(e == null ? void 0 : e.toLowerCase())) >= 0 || Ze(e, t) >= 0.5 || Ze(e, n) >= 0.5;
162
- function kt(e) {
154
+ }), _t = (e, t, n) => t?.toLowerCase().indexOf(e?.toLowerCase()) >= 0 || n?.toLowerCase().indexOf(e?.toLowerCase()) >= 0 || He(e, t) >= 0.5 || He(e, n) >= 0.5;
155
+ function Gt(e) {
163
156
  return e.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
164
157
  }
165
- const zt = (e, t) => be(
158
+ const Mt = (e, t) => ge(
166
159
  e,
167
- (r) => {
168
- var o;
169
- return ((o = r == null ? void 0 : r.type) == null ? void 0 : o.displayName) === "AutoCompleteItem" && r.props.value === (t == null ? void 0 : t.value);
170
- }
171
- ), Bt = (e, t) => be(
160
+ (r) => r?.type?.displayName === "AutoCompleteItem" && r.props.value === t?.value
161
+ ), Wt = (e, t) => ge(
172
162
  e,
173
- (r) => {
174
- var o;
175
- return ((o = r == null ? void 0 : r.type) == null ? void 0 : o.displayName) === "AutoCompleteItem" && r.props.value === (t == null ? void 0 : t.value);
176
- }
177
- ), $t = (e, t) => ot(
178
- be(e, (n) => {
179
- var o, s;
180
- const r = h(
181
- ((o = n.props) == null ? void 0 : o.getValue) || ze,
182
- ((s = n.props) == null ? void 0 : s.value) || {}
163
+ (r) => r?.type?.displayName === "AutoCompleteItem" && r.props.value === t?.value
164
+ ), kt = (e, t) => qe(
165
+ ge(e, (n) => {
166
+ const r = m(
167
+ n.props?.getValue || Ge,
168
+ n.props?.value || {}
183
169
  );
184
- return t.some((u) => u.value === r);
170
+ return t.some((o) => o.value === r);
185
171
  })
186
172
  );
187
- function Ht(e) {
188
- var Ue;
173
+ function zt(e) {
189
174
  let {
190
175
  prefocusFirstItem: t = !0,
191
176
  closeOnBlur: n = !0,
192
177
  creatable: r,
193
178
  emphasize: o,
194
- emptyState: s = !0,
195
- defaultEmptyStateProps: u = {},
196
- freeSolo: l,
197
- isReadOnly: f,
198
- listAllValuesOnFocus: v,
199
- maxSuggestions: y,
200
- multiple: d,
201
- closeOnSelect: C = !d,
202
- defaultValue: E,
203
- defaultValues: O = E ? [E] : [],
204
- onReady: T,
205
- defaultIsOpen: Ce,
206
- disableFilter: ie,
207
- isLoading: we = !1,
208
- placement: ee = "bottom",
209
- restoreOnBlurIfEmpty: le = !l,
210
- shouldRenderSuggestions: Se = () => !0,
211
- submitKeys: ue = [],
212
- suggestWhenEmpty: xe,
213
- value: K,
214
- values: Oe = K ? typeof K == "string" ? [K] : [...K] : void 0
179
+ emptyState: i = !0,
180
+ defaultEmptyStateProps: l = {},
181
+ freeSolo: u,
182
+ isReadOnly: c,
183
+ listAllValuesOnFocus: g,
184
+ maxSuggestions: h,
185
+ multiple: f,
186
+ closeOnSelect: y = !f,
187
+ defaultValue: O,
188
+ defaultValues: w = O ? [O] : [],
189
+ onReady: V,
190
+ defaultIsOpen: he,
191
+ disableFilter: X,
192
+ isLoading: ve = !1,
193
+ placement: q = "bottom",
194
+ restoreOnBlurIfEmpty: ne = !u,
195
+ shouldRenderSuggestions: ye = () => !0,
196
+ submitKeys: re = [],
197
+ suggestWhenEmpty: be,
198
+ value: k,
199
+ values: Ce = k ? typeof k == "string" ? [k] : [...k] : void 0
215
200
  } = e;
216
- l = l || (d ? !0 : e.freeSolo);
217
- const { open: A, onClose: z, onOpen: V } = gt({ open: Ce }), Ae = Z(
218
- () => h(e.children, {
219
- isOpen: A,
220
- onClose: z,
221
- onOpen: V
201
+ u = u || (f ? !0 : e.freeSolo);
202
+ const { open: x, onClose: G, onOpen: $ } = dt({ open: he }), Ie = U(
203
+ () => m(e.children, {
204
+ isOpen: x,
205
+ onClose: G,
206
+ onOpen: $
222
207
  }),
223
- [e.children, A]
224
- ), S = Z(() => Gt(Ae), [Ae]), F = se(null), Be = se(null), te = se(null), Y = se(null), [$e, ae] = De(!1);
225
- let ce = "";
226
- d ? ce = "" : me(O) ? me(Oe) || (ce = Oe[0]) : ce = O[0];
227
- const [_, ne] = De(ce ?? ""), Ee = Z(
228
- () => ie ? S : S.filter(
229
- (i) => i.fixed || h(
230
- e.filter || Wt,
231
- _,
232
- i.value,
233
- i.label
234
- ) || $e
208
+ [e.children, x]
209
+ ), C = U(() => Dt(Ie), [Ie]), M = te(null), Me = te(null), we = te(null), H = te(null), [We, oe] = Le(!1);
210
+ let ie = "";
211
+ f ? ie = "" : ce(w) ? ce(Ce) || (ie = Ce[0]) : ie = w[0];
212
+ const [j, J] = Le(ie ?? ""), xe = U(
213
+ () => X ? C : C.filter(
214
+ (s) => s.fixed || m(
215
+ e.filter || _t,
216
+ j,
217
+ s.value,
218
+ s.label
219
+ ) || We
235
220
  ).filter(
236
- (i, c) => y ? i.fixed || c < y : !0
221
+ (s, d) => h ? s.fixed || d < h : !0
237
222
  ),
238
- [_, S, $e, y, ie]
239
- ), fe = r ? [{ value: _, noFilter: !0, creatable: !0 }] : [], b = Z(() => [...Ee, ...fe], [Ee, fe]), at = Z(() => [...S, ...fe], [S, fe]), [G, Ie] = ht({
240
- defaultValue: O.map((i) => i == null ? void 0 : i.toString()),
241
- value: Oe,
242
- onChange: (i) => {
243
- const c = b.find((I) => I.value === i.at(-1));
244
- if (!c) return;
245
- const m = i.map(
246
- (I) => at.find((R) => R.value === I)
223
+ [j, C, We, h, X]
224
+ ), se = r ? [{ value: j, noFilter: !0, creatable: !0 }] : [], v = U(() => [...xe, ...se], [xe, se]), nt = U(() => [...C, ...se], [C, se]), [F, Se] = pt({
225
+ defaultValue: w.map((s) => s?.toString()),
226
+ value: Ce,
227
+ onChange: (s) => {
228
+ const d = v.find((S) => S.value === s.at(-1));
229
+ if (!d) return;
230
+ const I = s.map(
231
+ (S) => nt.find((R) => R.value === S)
247
232
  );
248
- h(
233
+ m(
249
234
  e.onChange,
250
- d ? i : i[0],
251
- d ? m : c
235
+ f ? s : s[0],
236
+ f ? I : d
252
237
  );
253
238
  }
254
239
  });
255
- j(() => {
256
- b.length === 0 && !s && A && z();
257
- }, [b.length, s, A]);
258
- const [X, M] = De(
259
- t ? (Ue = S[0]) == null ? void 0 : Ue.value : null
260
- ), ct = e.maxSelections || G.length + 1, Pe = b.findIndex((i) => i.value === X), Ne = Pt(
261
- Pe,
262
- b,
240
+ L(() => {
241
+ v.length === 0 && !i && x && G();
242
+ }, [v.length, i, x]);
243
+ const [K, D] = Le(
244
+ t ? C[0]?.value : null
245
+ ), rt = e.maxSelections || F.length + 1, Oe = v.findIndex((s) => s.value === K), ot = Ot(
246
+ Oe,
247
+ v,
263
248
  !!e.rollNavigation
264
- ), Re = Nt(
265
- Pe,
266
- b,
249
+ ), it = At(
250
+ Oe,
251
+ v,
267
252
  !!e.rollNavigation
268
- ), D = Et(b), je = Te(b), He = !b.some(
269
- (i) => i.value === X
253
+ ), le = xt(v), st = Ne(v), ke = !v.some(
254
+ (s) => s.value === K
270
255
  );
271
- j(() => {
272
- var i;
273
- He && M(t ? (i = S[0]) == null ? void 0 : i.value : null);
274
- }, [He]), j(() => {
275
- t && M(D == null ? void 0 : D.value);
276
- }, [t, M, _, D == null ? void 0 : D.value]), j(() => {
277
- var i;
278
- !A && t && M((i = S[0]) == null ? void 0 : i.value);
279
- }, [A]), j(() => {
280
- A && v && ae(!0);
281
- }, [A, v, ae]), j(() => {
282
- const i = S.find((c) => c.value === X);
283
- h(e.onOptionFocus, {
284
- item: i,
285
- focusMethod: Y.current,
286
- isNewInput: i == null ? void 0 : i.creatable
256
+ L(() => {
257
+ ke && D(t ? C[0]?.value : null);
258
+ }, [ke]), L(() => {
259
+ t && D(le?.value);
260
+ }, [t, D, j, le?.value]), L(() => {
261
+ !x && t && D(C[0]?.value);
262
+ }, [x]), L(() => {
263
+ x && g && oe(!0);
264
+ }, [x, g, oe]), L(() => {
265
+ const s = C.find((d) => d.value === K);
266
+ m(e.onOptionFocus, {
267
+ item: s,
268
+ focusMethod: H.current,
269
+ isNewInput: s?.creatable
287
270
  });
288
- }, [X, e.onOptionFocus]);
289
- const Le = (i) => {
290
- var I, R;
291
- const c = b.find((x) => x.value === i), m = (c == null ? void 0 : c.label) || (c == null ? void 0 : c.value);
292
- ne(() => d ? "" : m ?? ""), !G.includes(i) && G.length < ct && Ie((x) => d ? [...x, i] : [i]), d && ((I = F.current) == null || I.focus()), e.focusInputOnSelect && ((R = F.current) == null || R.focus()), h(e.onSelectOption, {
293
- item: c,
294
- selectMethod: Y.current,
295
- isNewInput: c == null ? void 0 : c.creatable
296
- }), c != null && c.creatable && h(e.onCreateOption, {
297
- item: ye(c, ["noFilter"]),
298
- selectMethod: Y.current
299
- }), C && z();
300
- }, Ke = (i, c) => {
301
- var R;
302
- Ie((x) => {
303
- let B = S.find((W) => W.value === i);
304
- return !B && r === !0 && (B = { label: i, value: i }), B ? (h(e.onTagRemoved, i, B, x), x.filter((W) => W !== i)) : x;
271
+ }, [K, e.onOptionFocus]);
272
+ const Ae = (s) => {
273
+ const d = v.find((S) => S.value === s), I = d?.label || d?.value;
274
+ J(() => f ? "" : I ?? ""), !F.includes(s) && F.length < rt && Se((S) => f ? [...S, s] : [s]), f && M.current?.focus(), e.focusInputOnSelect && M.current?.focus(), m(e.onSelectOption, {
275
+ item: d,
276
+ selectMethod: H.current,
277
+ isNewInput: d?.creatable
278
+ }), d?.creatable && m(e.onCreateOption, {
279
+ item: me(d, ["noFilter"]),
280
+ selectMethod: H.current
281
+ }), y && G();
282
+ }, ze = (s, d) => {
283
+ Se((R) => {
284
+ let T = C.find((z) => z.value === s);
285
+ return !T && r === !0 && (T = { label: s, value: s }), T ? (m(e.onTagRemoved, s, T, R), R.filter((z) => z !== s)) : R;
305
286
  });
306
- const m = S.find((x) => x.value === i), I = (m == null ? void 0 : m.label) || (m == null ? void 0 : m.value);
307
- _ === I && ne(""), c && ((R = F.current) == null || R.focus());
308
- }, ft = (i) => {
309
- var c;
310
- Ie([]), i && ((c = F.current) == null || c.focus());
311
- }, Qe = d ? G.map((i) => {
312
- var c;
313
- return {
314
- label: ((c = S.find((m) => m.value === (i == null ? void 0 : i.toString()))) == null ? void 0 : c.label) || i,
315
- onRemove: () => Ke(i)
316
- };
317
- }) : [];
318
- return j(() => {
319
- h(T, { tags: Qe });
320
- }, [G]), {
287
+ const I = C.find((R) => R.value === s), S = I?.label || I?.value;
288
+ j === S && J(""), d && M.current?.focus();
289
+ }, lt = (s) => {
290
+ Se([]), s && M.current?.focus();
291
+ }, Be = f ? F.map((s) => ({
292
+ label: C.find((d) => d.value === s?.toString())?.label || s,
293
+ onRemove: () => ze(s)
294
+ })) : [];
295
+ return L(() => {
296
+ m(V, { tags: Be });
297
+ }, [F]), {
321
298
  autoCompleteProps: e,
322
- children: Ae,
323
- filteredList: b,
324
- filteredResults: Ee,
325
- focusedValue: X,
326
- defaultEmptyStateProps: u,
327
- getEmptyStateProps: (i) => {
328
- if (b.every((m) => m.noFilter) && s && !r)
329
- return typeof s == "boolean" ? i : h(s, { query: _ });
299
+ children: Ie,
300
+ filteredList: v,
301
+ filteredResults: xe,
302
+ focusedValue: K,
303
+ defaultEmptyStateProps: l,
304
+ getEmptyStateProps: (s) => {
305
+ if (v.every((I) => I.noFilter) && i && !r)
306
+ return typeof i == "boolean" ? s : m(i, { query: j });
330
307
  },
331
- getGroupProps: (i) => {
332
- const c = $t(i.children, b);
308
+ getGroupProps: (s) => {
309
+ const d = kt(s.children, v);
333
310
  return {
334
311
  divider: {
335
- hasFirstChild: zt(i.children, D),
336
- hasLastChild: Bt(
337
- i.children,
338
- Te(b.filter((m) => me(m == null ? void 0 : m.noFilter)))
312
+ hasFirstChild: Mt(s.children, le),
313
+ hasLastChild: Wt(
314
+ s.children,
315
+ Ne(v.filter((I) => ce(I?.noFilter)))
339
316
  )
340
317
  },
341
318
  group: {
342
- display: c ? "initial" : "none"
319
+ display: d ? "initial" : "none"
343
320
  }
344
321
  };
345
322
  },
346
- getInputProps: (i, c) => {
347
- const { onBlur: m, onChange: I, onFocus: R, onKeyDown: x, variant: B, ...W } = i;
323
+ getInputProps: (s, d) => {
324
+ const { onBlur: I, onChange: S, onFocus: R, onKeyDown: T, variant: z, ...Z } = s;
348
325
  return {
349
326
  wrapper: {
350
- ref: Be,
327
+ ref: Me,
351
328
  onClick: () => {
352
- var p;
353
- (p = F == null ? void 0 : F.current) == null || p.focus();
329
+ M?.current?.focus();
354
330
  },
355
331
  //...getMultipleWrapStyles(themeInput, multiple),
356
- ...W
332
+ ...Z
357
333
  },
358
334
  input: {
359
- isReadOnly: f,
335
+ isReadOnly: c,
360
336
  onFocus: (p) => {
361
- h(R, p), e.openOnFocus && !f && V(), e.selectOnFocus && p.target.select(), v && ae(!0);
337
+ m(R, p), e.openOnFocus && !c && $(), e.selectOnFocus && p.target.select(), g && oe(!0);
362
338
  },
363
339
  onBlur: (p) => {
364
- var Q, pe;
365
- h(m, p);
366
- const w = p.relatedTarget === (te == null ? void 0 : te.current) || ((Q = te.current) == null ? void 0 : Q.contains(p.relatedTarget)), g = (pe = Be.current) == null ? void 0 : pe.contains(
340
+ m(I, p);
341
+ const b = p.relatedTarget === we?.current || we.current?.contains(p.relatedTarget), A = Me.current?.contains(
367
342
  p.relatedTarget
368
343
  );
369
- if (!w && !g && (n && z(), !G.includes(p.target.value) && le)) {
370
- const k = Te(G), $ = S.find(
371
- (re) => re.value === k
372
- ), Fe = ($ == null ? void 0 : $.label) || ($ == null ? void 0 : $.value) || "";
373
- ne(Fe);
344
+ if (!b && !A && (n && G(), !F.includes(p.target.value) && ne)) {
345
+ const Ee = Ne(F), ue = C.find(
346
+ (Pe) => Pe.value === Ee
347
+ ), _ = ue?.label || ue?.value || "";
348
+ J(_);
374
349
  }
375
350
  },
376
351
  onChange: (p) => {
377
- const w = p.target.value;
378
- h(I, p), ne(w);
379
- const g = We(w);
380
- h(Se, w) && (!g || xe) ? V() : z(), ae(!1);
352
+ const b = p.target.value;
353
+ m(S, p), J(b);
354
+ const A = Te(b);
355
+ m(ye, b) && (!A || be) ? $() : G(), oe(!1);
381
356
  },
382
357
  onKeyDown: (p) => {
383
- var Q;
384
- h(x, p), Y.current = "keyboard";
385
- const { key: w } = p, g = b[Pe];
386
- if (["Enter", ...ue].includes(w)) {
387
- g && !(g != null && g.disabled) && A ? Le(g == null ? void 0 : g.value) : (Q = F.current) == null || Q.focus(), p.preventDefault();
358
+ m(T, p), H.current = "keyboard";
359
+ const { key: b } = p, A = v[Oe];
360
+ if (["Enter", ...re].includes(b)) {
361
+ A && !A?.disabled && x ? Ae(A?.value) : M.current?.focus(), p.preventDefault();
388
362
  return;
389
363
  }
390
- if (w === "ArrowDown") {
391
- A ? M(Ne == null ? void 0 : Ne.value) : V(), p.preventDefault();
364
+ if (b === "ArrowDown") {
365
+ x ? D(ot?.value) : $(), p.preventDefault();
392
366
  return;
393
367
  }
394
- if (w === "ArrowUp") {
395
- A ? M(Re == null ? void 0 : Re.value) : V(), p.preventDefault();
368
+ if (b === "ArrowUp") {
369
+ x ? D(it?.value) : $(), p.preventDefault();
396
370
  return;
397
371
  }
398
- if (w === "Tab") {
399
- A && g && !(g != null && g.disabled) ? Le(g == null ? void 0 : g.value) : z();
372
+ if (b === "Tab") {
373
+ x && A && !A?.disabled ? Ae(A?.value) : G();
400
374
  return;
401
375
  }
402
- if (w === "Home") {
403
- M(D == null ? void 0 : D.value), p.preventDefault();
376
+ if (b === "Home") {
377
+ D(le?.value), p.preventDefault();
404
378
  return;
405
379
  }
406
- if (w === "End") {
407
- M(je == null ? void 0 : je.value), p.preventDefault();
380
+ if (b === "End") {
381
+ D(st?.value), p.preventDefault();
408
382
  return;
409
383
  }
410
- w === "Escape" && (z(), p.preventDefault());
384
+ b === "Escape" && (G(), p.preventDefault());
411
385
  },
412
- value: _,
386
+ value: j,
413
387
  //variant: multiple ? "unstyled" : variant,
414
- variant: B,
415
- ...W
388
+ variant: z,
389
+ ...Z
416
390
  }
417
391
  };
418
392
  },
419
- getItemProps: (i, c) => {
420
- var Ve;
393
+ getItemProps: (s, d) => {
421
394
  const {
422
- _fixed: m,
423
- _focus: I,
395
+ _fixed: I,
396
+ _focus: S,
424
397
  children: R,
425
- disabled: x,
426
- label: B,
427
- value: W,
398
+ disabled: T,
399
+ label: z,
400
+ value: Z,
428
401
  fixed: p,
429
- getValue: w = ze,
430
- onClick: g,
431
- onMouseOver: Q,
402
+ getValue: b = Ge,
403
+ onClick: A,
404
+ onMouseOver: Ee,
432
405
  //sx,
433
- ...pe
434
- } = i, k = c ? W : (Ve = w(W)) == null ? void 0 : Ve.toString(), $ = k === X, Fe = b.findIndex((oe) => oe.value === k) >= 0, re = R || B || k;
406
+ ...ue
407
+ } = s, _ = d ? Z : b(Z)?.toString(), Pe = _ === K, ut = v.findIndex((ee) => ee.value === _) >= 0, Re = R || z || _;
435
408
  return {
436
409
  item: {
437
- ...typeof re != "string" || !o ? { children: re } : {
410
+ ...typeof Re != "string" || !o ? { children: Re } : {
438
411
  dangerouslySetInnerHTML: {
439
- __html: _t(re, _)
412
+ __html: Ft(Re, j)
440
413
  }
441
414
  },
442
- "aria-selected": G.includes(k),
443
- "aria-disabled": x,
415
+ "aria-selected": F.includes(_),
416
+ "aria-disabled": T,
444
417
  _disabled: { opacity: 0.4, cursor: "not-allowed", userSelect: "none" },
445
- onMouseDown: (oe) => {
446
- var Ye;
447
- h(g, oe), x ? (Ye = F.current) == null || Ye.focus() : Le(k);
418
+ onMouseDown: (ee) => {
419
+ m(A, ee), T ? M.current?.focus() : Ae(_);
448
420
  },
449
- onMouseOver: (oe) => {
450
- h(Q, oe), M(k), Y.current = "mouse";
421
+ onMouseOver: (ee) => {
422
+ m(Ee, ee), D(_), H.current = "mouse";
451
423
  },
452
424
  sx: {
453
425
  //...sx,
454
426
  mark: {
455
427
  color: "inherit",
456
428
  bg: "transparent",
457
- ...Me(o) ? o : {
429
+ ...De(o) ? o : {
458
430
  fontWeight: o ? "extrabold" : "inherit"
459
431
  }
460
432
  }
461
433
  },
462
- ...$ && (I || Mt()),
463
- ...p && m,
464
- ...pe
434
+ ...Pe && (S || Tt()),
435
+ ...p && I,
436
+ ...ue
465
437
  },
466
438
  root: {
467
- isValidSuggestion: Fe,
468
- value: k
439
+ isValidSuggestion: ut,
440
+ value: _
469
441
  }
470
442
  };
471
443
  },
472
- inputRef: F,
473
- interactionRef: Y,
474
- isLoading: we,
475
- isOpen: A,
476
- itemList: S,
477
- listRef: te,
478
- onClose: z,
479
- onOpen: V,
480
- placement: ee,
481
- query: _,
482
- removeItem: Ke,
483
- resetItems: ft,
484
- setQuery: ne,
485
- tags: Qe,
486
- value: K,
487
- values: G
444
+ inputRef: M,
445
+ interactionRef: H,
446
+ isLoading: ve,
447
+ isOpen: x,
448
+ itemList: C,
449
+ listRef: we,
450
+ onClose: G,
451
+ onOpen: $,
452
+ placement: q,
453
+ query: j,
454
+ removeItem: ze,
455
+ resetItems: lt,
456
+ setQuery: J,
457
+ tags: Be,
458
+ value: k,
459
+ values: F
488
460
  };
489
461
  }
490
- var it = {
462
+ var Ze = {
491
463
  color: void 0,
492
464
  size: void 0,
493
465
  className: void 0,
494
466
  style: void 0,
495
467
  attr: void 0
496
- }, qe = P.createContext && /* @__PURE__ */ P.createContext(it), Kt = ["attr", "size", "title"];
497
- function Qt(e, t) {
468
+ }, Ke = E.createContext && /* @__PURE__ */ E.createContext(Ze), Bt = ["attr", "size", "title"];
469
+ function Vt(e, t) {
498
470
  if (e == null) return {};
499
- var n = Ut(e, t), r, o;
471
+ var n = $t(e, t), r, o;
500
472
  if (Object.getOwnPropertySymbols) {
501
- var s = Object.getOwnPropertySymbols(e);
502
- for (o = 0; o < s.length; o++)
503
- r = s[o], !(t.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(e, r) && (n[r] = e[r]);
473
+ var i = Object.getOwnPropertySymbols(e);
474
+ for (o = 0; o < i.length; o++)
475
+ r = i[o], !(t.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(e, r) && (n[r] = e[r]);
504
476
  }
505
477
  return n;
506
478
  }
507
- function Ut(e, t) {
479
+ function $t(e, t) {
508
480
  if (e == null) return {};
509
481
  var n = {};
510
482
  for (var r in e)
@@ -514,17 +486,17 @@ function Ut(e, t) {
514
486
  }
515
487
  return n;
516
488
  }
517
- function ge() {
518
- return ge = Object.assign ? Object.assign.bind() : function(e) {
489
+ function fe() {
490
+ return fe = Object.assign ? Object.assign.bind() : function(e) {
519
491
  for (var t = 1; t < arguments.length; t++) {
520
492
  var n = arguments[t];
521
493
  for (var r in n)
522
494
  Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
523
495
  }
524
496
  return e;
525
- }, ge.apply(this, arguments);
497
+ }, fe.apply(this, arguments);
526
498
  }
527
- function et(e, t) {
499
+ function Qe(e, t) {
528
500
  var n = Object.keys(e);
529
501
  if (Object.getOwnPropertySymbols) {
530
502
  var r = Object.getOwnPropertySymbols(e);
@@ -534,25 +506,25 @@ function et(e, t) {
534
506
  }
535
507
  return n;
536
508
  }
537
- function he(e) {
509
+ function de(e) {
538
510
  for (var t = 1; t < arguments.length; t++) {
539
511
  var n = arguments[t] != null ? arguments[t] : {};
540
- t % 2 ? et(Object(n), !0).forEach(function(r) {
541
- Vt(e, r, n[r]);
542
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : et(Object(n)).forEach(function(r) {
512
+ t % 2 ? Qe(Object(n), !0).forEach(function(r) {
513
+ Ht(e, r, n[r]);
514
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Qe(Object(n)).forEach(function(r) {
543
515
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
544
516
  });
545
517
  }
546
518
  return e;
547
519
  }
548
- function Vt(e, t, n) {
549
- return t = Yt(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
520
+ function Ht(e, t, n) {
521
+ return t = Kt(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
550
522
  }
551
- function Yt(e) {
552
- var t = Xt(e, "string");
523
+ function Kt(e) {
524
+ var t = Qt(e, "string");
553
525
  return typeof t == "symbol" ? t : t + "";
554
526
  }
555
- function Xt(e, t) {
527
+ function Qt(e, t) {
556
528
  if (typeof e != "object" || !e) return e;
557
529
  var n = e[Symbol.toPrimitive];
558
530
  if (n !== void 0) {
@@ -562,54 +534,54 @@ function Xt(e, t) {
562
534
  }
563
535
  return (t === "string" ? String : Number)(e);
564
536
  }
565
- function lt(e) {
566
- return e && e.map((t, n) => /* @__PURE__ */ P.createElement(t.tag, he({
537
+ function et(e) {
538
+ return e && e.map((t, n) => /* @__PURE__ */ E.createElement(t.tag, de({
567
539
  key: n
568
- }, t.attr), lt(t.child)));
540
+ }, t.attr), et(t.child)));
569
541
  }
570
- function Jt(e) {
571
- return (t) => /* @__PURE__ */ P.createElement(Zt, ge({
572
- attr: he({}, e.attr)
573
- }, t), lt(e.child));
542
+ function Ut(e) {
543
+ return (t) => /* @__PURE__ */ E.createElement(Yt, fe({
544
+ attr: de({}, e.attr)
545
+ }, t), et(e.child));
574
546
  }
575
- function Zt(e) {
547
+ function Yt(e) {
576
548
  var t = (n) => {
577
549
  var {
578
550
  attr: r,
579
551
  size: o,
580
- title: s
581
- } = e, u = Qt(e, Kt), l = o || n.size || "1em", f;
582
- return n.className && (f = n.className), e.className && (f = (f ? f + " " : "") + e.className), /* @__PURE__ */ P.createElement("svg", ge({
552
+ title: i
553
+ } = e, l = Vt(e, Bt), u = o || n.size || "1em", c;
554
+ return n.className && (c = n.className), e.className && (c = (c ? c + " " : "") + e.className), /* @__PURE__ */ E.createElement("svg", fe({
583
555
  stroke: "currentColor",
584
556
  fill: "currentColor",
585
557
  strokeWidth: "0"
586
- }, n.attr, r, u, {
587
- className: f,
588
- style: he(he({
558
+ }, n.attr, r, l, {
559
+ className: c,
560
+ style: de(de({
589
561
  color: e.color || n.color
590
562
  }, n.style), e.style),
591
- height: l,
592
- width: l,
563
+ height: u,
564
+ width: u,
593
565
  xmlns: "http://www.w3.org/2000/svg"
594
- }), s && /* @__PURE__ */ P.createElement("title", null, s), e.children);
566
+ }), i && /* @__PURE__ */ E.createElement("title", null, i), e.children);
595
567
  };
596
- return qe !== void 0 ? /* @__PURE__ */ P.createElement(qe.Consumer, null, (n) => t(n)) : t(it);
568
+ return Ke !== void 0 ? /* @__PURE__ */ E.createElement(Ke.Consumer, null, (n) => t(n)) : t(Ze);
597
569
  }
598
- function qt(e) {
599
- return Jt({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M18 6 6 18" }, child: [] }, { tag: "path", attr: { d: "m6 6 12 12" }, child: [] }] })(e);
570
+ function Xt(e) {
571
+ return Ut({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M18 6 6 18" }, child: [] }, { tag: "path", attr: { d: "m6 6 12 12" }, child: [] }] })(e);
600
572
  }
601
- const en = L.forwardRef(function(t, n) {
602
- return /* @__PURE__ */ a(vt, { variant: "ghost", "aria-label": "Close", ref: n, ...t, children: t.children ?? /* @__PURE__ */ a(qt, {}) });
603
- }), tn = L.forwardRef(function(t, n) {
604
- const { portalled: r = !0, portalRef: o, ...s } = t;
605
- return /* @__PURE__ */ a(yt, { disabled: !r, container: o, children: /* @__PURE__ */ a(N.Positioner, { children: /* @__PURE__ */ a(N.Content, { ref: n, ...s }) }) });
573
+ const qt = N.forwardRef(function(t, n) {
574
+ return /* @__PURE__ */ a(mt, { variant: "ghost", "aria-label": "Close", ref: n, ...t, children: t.children ?? /* @__PURE__ */ a(Xt, {}) });
575
+ }), Jt = N.forwardRef(function(t, n) {
576
+ const { portalled: r = !0, portalRef: o, ...i } = t;
577
+ return /* @__PURE__ */ a(gt, { disabled: !r, container: o, children: /* @__PURE__ */ a(P.Positioner, { children: /* @__PURE__ */ a(P.Content, { ref: n, ...i }) }) });
606
578
  });
607
- L.forwardRef(function(t, n) {
608
- return /* @__PURE__ */ a(N.Arrow, { ...t, ref: n, children: /* @__PURE__ */ a(N.ArrowTip, {}) });
579
+ N.forwardRef(function(t, n) {
580
+ return /* @__PURE__ */ a(P.Arrow, { ...t, ref: n, children: /* @__PURE__ */ a(P.ArrowTip, {}) });
609
581
  });
610
- L.forwardRef(function(t, n) {
582
+ N.forwardRef(function(t, n) {
611
583
  return /* @__PURE__ */ a(
612
- N.CloseTrigger,
584
+ P.CloseTrigger,
613
585
  {
614
586
  position: "absolute",
615
587
  top: "1",
@@ -617,257 +589,249 @@ L.forwardRef(function(t, n) {
617
589
  ...t,
618
590
  asChild: !0,
619
591
  ref: n,
620
- children: /* @__PURE__ */ a(en, { size: "sm" })
592
+ children: /* @__PURE__ */ a(qt, { size: "sm" })
621
593
  }
622
594
  );
623
595
  });
624
- N.Title;
625
- N.Description;
626
- N.Footer;
627
- N.Header;
628
- const nn = N.Root, rn = N.Body;
629
- N.Trigger;
630
- const on = U(
596
+ P.Title;
597
+ P.Description;
598
+ P.Footer;
599
+ P.Header;
600
+ const Zt = P.Root, en = P.Body;
601
+ P.Trigger;
602
+ const tn = B(
631
603
  (e, t) => {
632
- const n = Ht(e), {
604
+ const n = zt(e), {
633
605
  children: r,
634
606
  isOpen: o,
635
- onClose: s,
636
- onOpen: u,
637
- placement: l,
638
- resetItems: f,
639
- removeItem: v
607
+ onClose: i,
608
+ onOpen: l,
609
+ placement: u,
610
+ resetItems: c,
611
+ removeItem: g
640
612
  } = n;
641
- dt(t, () => ({
642
- resetItems: f,
643
- removeItem: v
613
+ ct(t, () => ({
614
+ resetItems: c,
615
+ removeItem: g
644
616
  }));
645
- const { matchWidth: y = !0 } = n.autoCompleteProps;
646
- return /* @__PURE__ */ a(Ot, { value: n, children: /* @__PURE__ */ a(
647
- nn,
617
+ const { matchWidth: h = !0 } = n.autoCompleteProps;
618
+ return /* @__PURE__ */ a(It, { value: n, children: /* @__PURE__ */ a(
619
+ Zt,
648
620
  {
649
621
  open: o,
650
622
  autoFocus: !1,
651
- positioning: { placement: l, sameWidth: y },
623
+ positioning: { placement: u, sameWidth: h },
652
624
  present: o,
653
- children: /* @__PURE__ */ a(bt.div, { w: "full", ref: t, children: r })
625
+ children: /* @__PURE__ */ a(ht.div, { w: "full", ref: t, children: r })
654
626
  }
655
627
  ) });
656
628
  }
657
629
  );
658
- on.displayName = "AutoComplete";
659
- const sn = U(
630
+ tn.displayName = "AutoComplete";
631
+ const nn = B(
660
632
  (e, t) => {
661
633
  const {
662
634
  focusedValue: n,
663
635
  getItemProps: r,
664
636
  interactionRef: o
665
- } = H(), s = se(), u = ke(t, s), l = r(e), { isValidSuggestion: f, value: v } = l.root, y = n === v;
666
- j(() => {
667
- var T;
668
- y && o.current === "keyboard" && ((T = s == null ? void 0 : s.current) == null || T.scrollIntoView({
637
+ } = W(), i = te(), l = _e(t, i), u = r(e), { isValidSuggestion: c, value: g } = u.root, h = n === g;
638
+ L(() => {
639
+ h && o.current === "keyboard" && i?.current?.scrollIntoView({
669
640
  behavior: "smooth",
670
641
  block: "nearest"
671
- }));
672
- }, [y, o]), j(() => {
673
- typeof v != "string" && console.warn("wow"), typeof v != "string" && me(e.getValue) && console.error(
642
+ });
643
+ }, [h, o]), L(() => {
644
+ typeof g != "string" && console.warn("wow"), typeof g != "string" && ce(e.getValue) && console.error(
674
645
  "You must define the `getValue` prop, when an Item's value is not a string"
675
646
  );
676
647
  }, []);
677
- const { children: d, dangerouslySetInnerHTML: C, ...E } = l.item, O = ye(E, ["groupId"]);
678
- return f ? /* @__PURE__ */ a(ve, { ref: u, ...ut, ...O, children: d || /* @__PURE__ */ a("span", { dangerouslySetInnerHTML: C }) }) : null;
648
+ const { children: f, dangerouslySetInnerHTML: y, ...O } = u.item, w = me(O, ["groupId"]);
649
+ return c ? /* @__PURE__ */ a(pe, { ref: l, ...tt, ...w, children: f || /* @__PURE__ */ a("span", { dangerouslySetInnerHTML: y }) }) : null;
679
650
  }
680
651
  );
681
- sn.displayName = "AutoCompleteItem";
682
- const ut = {
652
+ nn.displayName = "AutoCompleteItem";
653
+ const tt = {
683
654
  mx: "2",
684
655
  px: "2",
685
656
  py: "2",
686
657
  rounded: "md",
687
658
  cursor: "pointer"
688
659
  };
689
- function ln(e) {
660
+ function rn(e) {
690
661
  const { alwaysDisplay: t, children: n, ...r } = e, {
691
662
  autoCompleteProps: o,
692
- getItemProps: s,
693
- query: u,
694
- filteredResults: l
695
- } = H(), { children: f, ...v } = s(
663
+ getItemProps: i,
664
+ query: l,
665
+ filteredResults: u
666
+ } = W(), { children: c, ...g } = i(
696
667
  {
697
668
  ...e,
698
- value: u,
699
- children: h(n, {
700
- value: u
669
+ value: l,
670
+ children: m(n, {
671
+ value: l
701
672
  })
702
673
  },
703
674
  !0
704
- ).item, y = l.some((E) => E.value === u), d = We(u) ? t : !0;
705
- return o.creatable && d && !y ? /* @__PURE__ */ a(ve, { ...ut, ...v, ...r, children: f || `Add ${u}` }) : null;
675
+ ).item, h = u.some((O) => O.value === l), f = Te(l) ? t : !0;
676
+ return o.creatable && f && !h ? /* @__PURE__ */ a(pe, { ...tt, ...g, ...r, children: c || `Add ${l}` }) : null;
706
677
  }
707
- ln.displayName = "AutoCompleteCreatable";
708
- const un = U(
678
+ rn.displayName = "AutoCompleteCreatable";
679
+ const on = B(
709
680
  (e, t) => {
710
- const { children: n, showDivider: r, ...o } = e, s = ye(o, ["groupSibling"]), { getGroupProps: u } = H(), { group: l } = u(e), f = fn(e);
711
- return /* @__PURE__ */ q(_e, { ref: t, ...l, ...s, children: [
712
- /* @__PURE__ */ a(Xe, { ...f.top }),
681
+ const { children: n, showDivider: r, ...o } = e, i = me(o, ["groupSibling"]), { getGroupProps: l } = W(), { group: u } = l(e), c = un(e);
682
+ return /* @__PURE__ */ Y(je, { ref: t, ...u, ...i, children: [
683
+ /* @__PURE__ */ a(Ve, { ...c.top }),
713
684
  n,
714
- /* @__PURE__ */ a(Xe, { ...f.bottom })
685
+ /* @__PURE__ */ a(Ve, { ...c.bottom })
715
686
  ] });
716
687
  }
717
- ), an = U(
718
- (e, t) => /* @__PURE__ */ a(ve, { ...cn, ...e, ref: t })
688
+ ), sn = B(
689
+ (e, t) => /* @__PURE__ */ a(pe, { ...ln, ...e, ref: t })
719
690
  );
720
- un.displayName = "AutoCompleteGroup";
721
- an.displayName = "AutoCompleteGroupTitle";
722
- const cn = {
691
+ on.displayName = "AutoCompleteGroup";
692
+ sn.displayName = "AutoCompleteGroupTitle";
693
+ const ln = {
723
694
  ml: 5,
724
695
  my: 1,
725
696
  fontSize: "xs",
726
697
  letterSpacing: "wider",
727
698
  fontWeight: "extrabold",
728
699
  textTransform: "uppercase"
729
- }, fn = (e) => {
730
- const { getGroupProps: t } = H(), n = e.groupSibling, {
700
+ }, un = (e) => {
701
+ const { getGroupProps: t } = W(), n = e.groupSibling, {
731
702
  divider: { hasFirstChild: r, hasLastChild: o }
732
- } = t(e), s = {
703
+ } = t(e), i = {
733
704
  my: 2,
734
705
  borderColor: e.dividerColor
735
- }, u = {
736
- ...s,
706
+ }, l = {
707
+ ...i,
737
708
  mb: 4,
738
709
  display: !e.showDivider || r ? "none" : ""
739
- }, l = {
740
- ...s,
710
+ }, u = {
711
+ ...i,
741
712
  display: !e.showDivider || o || n ? "none" : ""
742
713
  };
743
- return { top: u, bottom: l };
744
- }, pn = L.forwardRef(
714
+ return { top: l, bottom: u };
715
+ }, an = N.forwardRef(
745
716
  function(t, n) {
746
717
  const {
747
718
  startElement: r,
748
719
  startElementProps: o,
749
- endElement: s,
750
- endElementProps: u,
751
- children: l,
752
- startOffset: f = "6px",
753
- endOffset: v = "6px",
754
- ...y
720
+ endElement: i,
721
+ endElementProps: l,
722
+ children: u,
723
+ startOffset: c = "6px",
724
+ endOffset: g = "6px",
725
+ ...h
755
726
  } = t;
756
- return /* @__PURE__ */ q(Ct, { ref: n, ...y, children: [
757
- r && /* @__PURE__ */ a(Je, { pointerEvents: "none", ...o, children: r }),
758
- L.cloneElement(l, {
727
+ return /* @__PURE__ */ Y(vt, { ref: n, ...h, children: [
728
+ r && /* @__PURE__ */ a($e, { pointerEvents: "none", ...o, children: r }),
729
+ N.cloneElement(u, {
759
730
  ...r && {
760
- ps: `calc(var(--input-height) - ${f})`
731
+ ps: `calc(var(--input-height) - ${c})`
761
732
  },
762
- ...s && { pe: `calc(var(--input-height) - ${v})` },
763
- ...l.props
733
+ ...i && { pe: `calc(var(--input-height) - ${g})` },
734
+ ...u.props
764
735
  }),
765
- s && /* @__PURE__ */ a(Je, { placement: "end", ...u, children: s })
736
+ i && /* @__PURE__ */ a($e, { placement: "end", ...l, children: i })
766
737
  ] });
767
738
  }
768
- ), dn = U((e, t) => {
769
- const { isLoading: n } = H(), { loadingIcon: r, ...o } = e, s = ye(o, ["children", "wrapStyles", "hidePlaceholder"]), u = /* @__PURE__ */ a(wt, { ...s, ref: t });
770
- return n ? /* @__PURE__ */ a(pn, { endElement: r || /* @__PURE__ */ a(nt, {}), children: u }) : u;
771
- }), mn = U(
739
+ ), cn = B((e, t) => {
740
+ const { isLoading: n } = W(), { loadingIcon: r, ...o } = e, i = me(o, ["children", "wrapStyles", "hidePlaceholder"]), l = /* @__PURE__ */ a(yt, { ...i, ref: t });
741
+ return n ? /* @__PURE__ */ a(an, { w: "full", endElement: r || /* @__PURE__ */ a(Ye, {}), children: l }) : l;
742
+ }), fn = B(
772
743
  (e, t) => {
773
744
  const {
774
745
  autoCompleteProps: n,
775
746
  inputRef: r,
776
747
  getInputProps: o,
777
- tags: s,
778
- setQuery: u,
779
- value: l,
780
- itemList: f
781
- } = H(), {
782
- children: v,
783
- hidePlaceholder: y,
784
- ...d
785
- } = e, { value: C } = d;
786
- j(() => {
787
- if (l !== void 0 && (typeof l == "string" || l instanceof String)) {
788
- const ue = f.find((K) => K.value === l), xe = ue === void 0 ? l : ue.label;
789
- u(xe);
748
+ tags: i,
749
+ setQuery: l,
750
+ value: u,
751
+ itemList: c
752
+ } = W(), {
753
+ children: g,
754
+ hidePlaceholder: h,
755
+ ...f
756
+ } = e, { value: y } = f;
757
+ L(() => {
758
+ if (u !== void 0 && (typeof u == "string" || u instanceof String)) {
759
+ const re = c.find((k) => k.value === u), be = re === void 0 ? u : re.label;
760
+ l(be);
790
761
  }
791
- }, [l]), j(() => {
792
- C !== void 0 && (typeof C == "string" || C instanceof String) && u(C);
793
- }, [C]);
794
- const E = {};
795
- let { wrapper: O, input: T } = o(d, E);
796
- const { ref: Ce, ...ie } = O, we = ke(t, r), ee = h(v, { tags: s });
797
- y && (T = {
798
- ...T,
799
- placeholder: Array.isArray(ee) && ee.length ? void 0 : T.placeholder
762
+ }, [u]), L(() => {
763
+ y !== void 0 && (typeof y == "string" || y instanceof String) && l(y);
764
+ }, [y]);
765
+ const O = {};
766
+ let { wrapper: w, input: V } = o(f, O);
767
+ const { ref: he, ...X } = w, ve = _e(t, r), q = m(g, { tags: i });
768
+ h && (V = {
769
+ ...V,
770
+ placeholder: Array.isArray(q) && q.length ? void 0 : V.placeholder
800
771
  });
801
- const le = /* @__PURE__ */ a(
802
- dn,
772
+ const ne = /* @__PURE__ */ a(
773
+ cn,
803
774
  {
804
- ...T,
805
- ref: we
775
+ ...V,
776
+ ref: ve
806
777
  }
807
- ), Se = /* @__PURE__ */ q(_e, { ...ie, ref: Ce, children: [
808
- ee,
809
- le
778
+ ), ye = /* @__PURE__ */ Y(je, { ...X, ref: he, children: [
779
+ q,
780
+ ne
810
781
  ] });
811
- return /* @__PURE__ */ a(St, { children: n.multiple ? Se : le });
782
+ return /* @__PURE__ */ a(bt, { w: "full", ...X, children: n.multiple ? ye : ne });
812
783
  }
813
784
  );
814
- mn.displayName = "Input";
815
- const gn = (e) => {
816
- const { getEmptyStateProps: t, defaultEmptyStateProps: n } = H(), r = t(
817
- /* @__PURE__ */ a(ve, { ...hn, ...n, children: "No options found!" })
785
+ fn.displayName = "Input";
786
+ const dn = (e) => {
787
+ const { getEmptyStateProps: t, defaultEmptyStateProps: n } = W(), r = t(
788
+ /* @__PURE__ */ a(pe, { ...pn, ...n, children: "No options found!" })
818
789
  );
819
- return /* @__PURE__ */ a(_e, { ...e, children: r });
820
- }, hn = {
790
+ return /* @__PURE__ */ a(je, { ...e, children: r });
791
+ }, pn = {
821
792
  fontSize: "sm",
822
793
  align: "center",
823
794
  justify: "center",
824
795
  fontWeight: "bold",
825
796
  fontStyle: "italic"
826
- }, tt = [
797
+ }, Ue = [
827
798
  "AutoCompleteGroup",
828
799
  "AutoCompleteItem",
829
800
  "AutoCompleteCreatable"
830
- ], vn = (e) => {
831
- const t = P.Children.map(e, (o, s) => {
832
- var u;
833
- if (((u = o == null ? void 0 : o.type) == null ? void 0 : u.displayName) === "AutoCompleteGroup") {
834
- const l = P.Children.toArray(e)[s + 1];
835
- return P.cloneElement(o, {
801
+ ], mn = (e) => {
802
+ const t = E.Children.map(e, (o, i) => {
803
+ if (o?.type?.displayName === "AutoCompleteGroup") {
804
+ const l = E.Children.toArray(e)[i + 1];
805
+ return E.cloneElement(o, {
836
806
  groupSibling: l ? l.type.displayName === "AutoCompleteGroup" : !1
837
807
  });
838
808
  }
839
809
  return o;
840
- }), n = P.Children.toArray(t).filter(
841
- (o) => {
842
- var s;
843
- return !tt.includes(
844
- (s = o == null ? void 0 : o.type) == null ? void 0 : s.displayName
845
- );
846
- }
810
+ }), n = E.Children.toArray(t).filter(
811
+ (o) => !Ue.includes(
812
+ o?.type?.displayName
813
+ )
847
814
  );
848
- return [P.Children.toArray(t).filter(
849
- (o) => {
850
- var s;
851
- return tt.includes(
852
- (s = o == null ? void 0 : o.type) == null ? void 0 : s.displayName
853
- );
854
- }
815
+ return [E.Children.toArray(t).filter(
816
+ (o) => Ue.includes(
817
+ o?.type?.displayName
818
+ )
855
819
  ), n];
856
- }, yn = U(
820
+ }, gn = B(
857
821
  (e, t) => {
858
- const { children: n, loadingState: r, ...o } = e, { listRef: s, isLoading: u } = H(), l = ke(t, s), [f, v] = vn(n);
859
- return /* @__PURE__ */ a(tn, { width: "auto", children: /* @__PURE__ */ q(rn, { ref: l, w: "inherit", ...bn, ...o, children: [
860
- u && /* @__PURE__ */ a(xt, { children: r || /* @__PURE__ */ a(nt, { size: "md" }) }),
861
- !u && /* @__PURE__ */ q(pt, { children: [
862
- f,
863
- /* @__PURE__ */ a(gn, {}),
864
- v
822
+ const { children: n, loadingState: r, ...o } = e, { listRef: i, isLoading: l } = W(), u = _e(t, i), [c, g] = mn(n);
823
+ return /* @__PURE__ */ a(Jt, { width: "auto", children: /* @__PURE__ */ Y(en, { ref: u, w: "inherit", ...hn, ...o, children: [
824
+ l && /* @__PURE__ */ a(Ct, { children: r || /* @__PURE__ */ a(Ye, { size: "md" }) }),
825
+ !l && /* @__PURE__ */ Y(at, { children: [
826
+ c,
827
+ /* @__PURE__ */ a(dn, {}),
828
+ g
865
829
  ] })
866
830
  ] }) });
867
831
  }
868
832
  );
869
- yn.displayName = "AutoCompleteList";
870
- const bn = {
833
+ gn.displayName = "AutoCompleteList";
834
+ const hn = {
871
835
  // py: "4",
872
836
  //opacity: "0",
873
837
  px: "0px",
@@ -884,55 +848,55 @@ const bn = {
884
848
  _focus: {
885
849
  boxShadow: "none"
886
850
  }
887
- }, Cn = L.forwardRef(
851
+ }, vn = N.forwardRef(
888
852
  function(t, n) {
889
853
  const {
890
854
  startElement: r,
891
855
  endElement: o,
892
- onClose: s,
893
- closable: u = !!s,
894
- children: l,
895
- ...f
856
+ onClose: i,
857
+ closable: l = !!i,
858
+ children: u,
859
+ ...c
896
860
  } = t;
897
- return /* @__PURE__ */ q(J.Root, { ref: n, ...f, children: [
898
- r && /* @__PURE__ */ a(J.StartElement, { children: r }),
899
- /* @__PURE__ */ a(J.Label, { children: l }),
900
- o && /* @__PURE__ */ a(J.EndElement, { children: o }),
901
- u && /* @__PURE__ */ a(J.EndElement, { children: /* @__PURE__ */ a(J.CloseTrigger, { onClick: s }) })
861
+ return /* @__PURE__ */ Y(Q.Root, { ref: n, ...c, children: [
862
+ r && /* @__PURE__ */ a(Q.StartElement, { children: r }),
863
+ /* @__PURE__ */ a(Q.Label, { children: u }),
864
+ o && /* @__PURE__ */ a(Q.EndElement, { children: o }),
865
+ l && /* @__PURE__ */ a(Q.EndElement, { children: /* @__PURE__ */ a(Q.CloseTrigger, { onClick: i }) })
902
866
  ] });
903
867
  }
904
- ), Nn = mt((e) => {
868
+ ), An = ft((e) => {
905
869
  const { label: t, onRemove: n, disabled: r, ...o } = e;
906
870
  return /* @__PURE__ */ a(
907
- Cn,
871
+ vn,
908
872
  {
909
873
  borderRadius: "md",
910
874
  fontWeight: "normal",
911
875
  closable: !0,
912
- onClose: () => !r && h(n),
913
- ...r && wn,
876
+ onClose: () => !r && m(n),
877
+ ...r && yn,
914
878
  ...o,
915
879
  children: t
916
880
  }
917
881
  );
918
- }), wn = {
882
+ }), yn = {
919
883
  cursor: "text",
920
884
  userSelect: "none",
921
885
  opacity: 0.4,
922
886
  _focus: { boxShadow: "none" }
923
887
  };
924
888
  export {
925
- on as AutoComplete,
926
- ln as AutoCompleteCreatable,
927
- un as AutoCompleteGroup,
928
- an as AutoCompleteGroupTitle,
929
- mn as AutoCompleteInput,
930
- sn as AutoCompleteItem,
931
- yn as AutoCompleteList,
932
- Ot as AutoCompleteProvider,
933
- Nn as AutoCompleteTag,
934
- ut as baseItemStyles,
935
- At as createContext,
936
- Ht as useAutoComplete,
937
- H as useAutoCompleteContext
889
+ tn as AutoComplete,
890
+ rn as AutoCompleteCreatable,
891
+ on as AutoCompleteGroup,
892
+ sn as AutoCompleteGroupTitle,
893
+ fn as AutoCompleteInput,
894
+ nn as AutoCompleteItem,
895
+ gn as AutoCompleteList,
896
+ It as AutoCompleteProvider,
897
+ An as AutoCompleteTag,
898
+ tt as baseItemStyles,
899
+ wt as createContext,
900
+ zt as useAutoComplete,
901
+ W as useAutoCompleteContext
938
902
  };