@choc-ui/chakra-autocomplete 5.8.0 → 6.0.0

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