@choc-ui/chakra-autocomplete 6.1.4 → 6.1.6
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/README.md +1 -0
- package/dist/index.es.js +508 -543
- package/dist/index.js +1 -1
- package/package.json +3 -5
package/dist/index.es.js
CHANGED
|
@@ -1,84 +1,83 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { useDisclosure as
|
|
5
|
-
const [
|
|
6
|
-
function
|
|
7
|
-
const e =
|
|
1
|
+
import { jsx as a, jsxs as Y, Fragment as Ye } 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, PopoverAnchor as bt, Spinner as Xe, 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
|
-
|
|
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
|
|
14
|
-
throw
|
|
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
|
|
21
|
-
return e
|
|
19
|
+
function xt(e) {
|
|
20
|
+
return e?.[0];
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
return e
|
|
22
|
+
function Ne(e) {
|
|
23
|
+
return e?.length ? e[e.length - 1] : void 0;
|
|
25
24
|
}
|
|
26
|
-
function
|
|
25
|
+
function qe(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
|
|
32
|
-
return
|
|
30
|
+
function St(e, t, n = !0) {
|
|
31
|
+
return qe(e, t, -1, n);
|
|
33
32
|
}
|
|
34
|
-
function
|
|
35
|
-
const r =
|
|
33
|
+
function Ot(e, t, n = !0) {
|
|
34
|
+
const r = qe(e, t.length, 1, n);
|
|
36
35
|
return t[r];
|
|
37
36
|
}
|
|
38
|
-
function
|
|
39
|
-
const r =
|
|
37
|
+
function At(e, t, n = !0) {
|
|
38
|
+
const r = St(e, t.length, n);
|
|
40
39
|
return t[r];
|
|
41
40
|
}
|
|
42
|
-
function
|
|
41
|
+
function Fe(e) {
|
|
43
42
|
return Array.isArray(e);
|
|
44
43
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
44
|
+
function Et(e) {
|
|
45
|
+
return Fe(e) && e.length === 0;
|
|
47
46
|
}
|
|
48
|
-
function
|
|
49
|
-
return e !== null && typeof e == "object" && !
|
|
47
|
+
function De(e) {
|
|
48
|
+
return e !== null && typeof e == "object" && !Fe(e);
|
|
50
49
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
50
|
+
function Pt(e) {
|
|
51
|
+
return De(e) && Object.keys(e).length === 0;
|
|
53
52
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
53
|
+
function Te(e) {
|
|
54
|
+
return Fe(e) ? Et(e) : De(e) ? Pt(e) : e == null || e === "";
|
|
56
55
|
}
|
|
57
|
-
function
|
|
56
|
+
function ce(e) {
|
|
58
57
|
return typeof e > "u";
|
|
59
58
|
}
|
|
60
|
-
function
|
|
59
|
+
function Je(e) {
|
|
61
60
|
return typeof e < "u";
|
|
62
61
|
}
|
|
63
|
-
function
|
|
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
|
|
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
|
|
74
|
+
function Lt(e) {
|
|
76
75
|
return typeof e == "function";
|
|
77
76
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
77
|
+
function m(e, ...t) {
|
|
78
|
+
return Lt(e) ? e(...t) : e;
|
|
80
79
|
}
|
|
81
|
-
function
|
|
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
|
|
93
|
+
function jt(...e) {
|
|
95
94
|
return (t) => {
|
|
96
95
|
e.forEach((n) => {
|
|
97
|
-
|
|
96
|
+
Nt(n, t);
|
|
98
97
|
});
|
|
99
98
|
};
|
|
100
99
|
}
|
|
101
|
-
function
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
var
|
|
105
|
-
for (var n, r =
|
|
106
|
-
var
|
|
107
|
-
if (t(
|
|
108
|
-
return
|
|
109
|
-
if (!((n =
|
|
110
|
-
var
|
|
111
|
-
if (
|
|
112
|
-
return
|
|
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
|
-
},
|
|
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
|
-
},
|
|
120
|
-
for (var n, r =
|
|
121
|
-
var
|
|
122
|
-
t(
|
|
118
|
+
}, Ze = 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), Ze(u.props.children, t)));
|
|
123
122
|
}
|
|
124
123
|
return o;
|
|
125
124
|
};
|
|
126
|
-
function
|
|
127
|
-
function r(
|
|
128
|
-
|
|
129
|
-
let
|
|
130
|
-
for (let
|
|
131
|
-
|
|
132
|
-
return
|
|
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 (!
|
|
133
|
+
if (!e?.length || !t?.length)
|
|
135
134
|
return 0;
|
|
136
|
-
let o = e.length < t.length ? e : t,
|
|
137
|
-
for (let
|
|
138
|
-
|
|
139
|
-
return
|
|
140
|
-
}
|
|
141
|
-
const
|
|
142
|
-
|
|
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
|
-
),
|
|
143
|
+
), Dt = (e) => Ze(
|
|
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 =
|
|
155
|
-
return { ...
|
|
156
|
-
}),
|
|
147
|
+
const r = Rt(n.props, ["value", "label", "fixed", "disabled"]), { getValue: o = Ge } = n.props, i = o(r.value);
|
|
148
|
+
return { ...Je(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
|
-
}),
|
|
162
|
-
function
|
|
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
|
|
158
|
+
const Mt = (e, t) => ge(
|
|
166
159
|
e,
|
|
167
|
-
(r) =>
|
|
168
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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) => Je(
|
|
165
|
+
ge(e, (n) => {
|
|
166
|
+
const r = m(
|
|
167
|
+
n.props?.getValue || Ge,
|
|
168
|
+
n.props?.value || {}
|
|
183
169
|
);
|
|
184
|
-
return t.some((
|
|
170
|
+
return t.some((o) => o.value === r);
|
|
185
171
|
})
|
|
186
172
|
);
|
|
187
|
-
function
|
|
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:
|
|
195
|
-
defaultEmptyStateProps:
|
|
196
|
-
freeSolo:
|
|
197
|
-
isReadOnly:
|
|
198
|
-
listAllValuesOnFocus:
|
|
199
|
-
maxSuggestions:
|
|
200
|
-
multiple:
|
|
201
|
-
closeOnSelect:
|
|
202
|
-
defaultValue:
|
|
203
|
-
defaultValues:
|
|
204
|
-
onReady:
|
|
205
|
-
defaultIsOpen:
|
|
206
|
-
disableFilter:
|
|
207
|
-
isLoading:
|
|
208
|
-
placement:
|
|
209
|
-
restoreOnBlurIfEmpty:
|
|
210
|
-
shouldRenderSuggestions:
|
|
211
|
-
submitKeys:
|
|
212
|
-
suggestWhenEmpty:
|
|
213
|
-
value:
|
|
214
|
-
values:
|
|
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
|
-
|
|
217
|
-
const { open:
|
|
218
|
-
() =>
|
|
219
|
-
isOpen:
|
|
220
|
-
onClose:
|
|
221
|
-
onOpen:
|
|
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,
|
|
224
|
-
),
|
|
225
|
-
let
|
|
226
|
-
|
|
227
|
-
const [
|
|
228
|
-
() =>
|
|
229
|
-
(
|
|
230
|
-
e.filter ||
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
) ||
|
|
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
|
-
(
|
|
221
|
+
(s, d) => h ? s.fixed || d < h : !0
|
|
237
222
|
),
|
|
238
|
-
[
|
|
239
|
-
),
|
|
240
|
-
defaultValue:
|
|
241
|
-
value:
|
|
242
|
-
onChange: (
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
const
|
|
246
|
-
(
|
|
223
|
+
[j, C, We, h, X]
|
|
224
|
+
), se = r ? [{ value: j, noFilter: !0, creatable: !0 }] : [], v = U(() => [...xe, ...se], [xe, se]), rt = 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) => rt.find((R) => R.value === S)
|
|
247
232
|
);
|
|
248
|
-
|
|
233
|
+
m(
|
|
249
234
|
e.onChange,
|
|
250
|
-
|
|
251
|
-
|
|
235
|
+
f ? s : s[0],
|
|
236
|
+
f ? I : d
|
|
252
237
|
);
|
|
253
238
|
}
|
|
254
239
|
});
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}, [
|
|
258
|
-
const [
|
|
259
|
-
t ?
|
|
260
|
-
),
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
), ot = e.maxSelections || F.length + 1, Oe = v.findIndex((s) => s.value === K), it = Ot(
|
|
246
|
+
Oe,
|
|
247
|
+
v,
|
|
263
248
|
!!e.rollNavigation
|
|
264
|
-
),
|
|
265
|
-
|
|
266
|
-
|
|
249
|
+
), st = At(
|
|
250
|
+
Oe,
|
|
251
|
+
v,
|
|
267
252
|
!!e.rollNavigation
|
|
268
|
-
),
|
|
269
|
-
(
|
|
253
|
+
), le = xt(v), lt = Ne(v), ke = !v.some(
|
|
254
|
+
(s) => s.value === K
|
|
270
255
|
);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}, [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
focusMethod: Y.current,
|
|
286
|
-
isNewInput: l == null ? void 0 : l.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
|
-
}, [
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
let B = S.find((W) => W.value === l);
|
|
304
|
-
return !B && r === !0 && (B = { label: l, value: l }), B ? (h(e.onTagRemoved, l, B, x), x.filter((W) => W !== l)) : 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 < ot && 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
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
+
}, ut = (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:
|
|
323
|
-
filteredList:
|
|
324
|
-
filteredResults:
|
|
325
|
-
focusedValue:
|
|
326
|
-
defaultEmptyStateProps:
|
|
327
|
-
getEmptyStateProps: (
|
|
328
|
-
if (
|
|
329
|
-
return typeof
|
|
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: (
|
|
332
|
-
const
|
|
308
|
+
getGroupProps: (s) => {
|
|
309
|
+
const d = kt(s.children, v);
|
|
333
310
|
return {
|
|
334
311
|
divider: {
|
|
335
|
-
hasFirstChild:
|
|
336
|
-
hasLastChild:
|
|
337
|
-
|
|
338
|
-
|
|
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:
|
|
319
|
+
display: d ? "initial" : "none"
|
|
343
320
|
}
|
|
344
321
|
};
|
|
345
322
|
},
|
|
346
|
-
getInputProps: (
|
|
347
|
-
const { onBlur:
|
|
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:
|
|
327
|
+
ref: Me,
|
|
351
328
|
onClick: () => {
|
|
352
|
-
|
|
353
|
-
(p = F == null ? void 0 : F.current) == null || p.focus();
|
|
329
|
+
M?.current?.focus();
|
|
354
330
|
},
|
|
355
331
|
//...getMultipleWrapStyles(themeInput, multiple),
|
|
356
|
-
...
|
|
332
|
+
...Z
|
|
357
333
|
},
|
|
358
334
|
input: {
|
|
359
|
-
isReadOnly:
|
|
335
|
+
isReadOnly: c,
|
|
360
336
|
onFocus: (p) => {
|
|
361
|
-
|
|
337
|
+
m(R, p), e.openOnFocus && !c && $(), e.selectOnFocus && p.target.select(), g && oe(!0);
|
|
362
338
|
},
|
|
363
339
|
onBlur: (p) => {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const w = p.relatedTarget === (ne == null ? void 0 : ne.current) || ((Q = ne.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 (!
|
|
370
|
-
const
|
|
371
|
-
(
|
|
372
|
-
),
|
|
373
|
-
|
|
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
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
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
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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 (
|
|
391
|
-
|
|
364
|
+
if (b === "ArrowDown") {
|
|
365
|
+
x ? D(it?.value) : $(), p.preventDefault();
|
|
392
366
|
return;
|
|
393
367
|
}
|
|
394
|
-
if (
|
|
395
|
-
|
|
368
|
+
if (b === "ArrowUp") {
|
|
369
|
+
x ? D(st?.value) : $(), p.preventDefault();
|
|
396
370
|
return;
|
|
397
371
|
}
|
|
398
|
-
if (
|
|
399
|
-
|
|
372
|
+
if (b === "Tab") {
|
|
373
|
+
x && A && !A?.disabled ? Ae(A?.value) : G();
|
|
400
374
|
return;
|
|
401
375
|
}
|
|
402
|
-
if (
|
|
403
|
-
|
|
376
|
+
if (b === "Home") {
|
|
377
|
+
D(le?.value), p.preventDefault();
|
|
404
378
|
return;
|
|
405
379
|
}
|
|
406
|
-
if (
|
|
407
|
-
|
|
380
|
+
if (b === "End") {
|
|
381
|
+
D(lt?.value), p.preventDefault();
|
|
408
382
|
return;
|
|
409
383
|
}
|
|
410
|
-
|
|
384
|
+
b === "Escape" && (G(), p.preventDefault());
|
|
411
385
|
},
|
|
412
|
-
value:
|
|
386
|
+
value: j,
|
|
413
387
|
//variant: multiple ? "unstyled" : variant,
|
|
414
|
-
variant:
|
|
415
|
-
...
|
|
388
|
+
variant: z,
|
|
389
|
+
...Z
|
|
416
390
|
}
|
|
417
391
|
};
|
|
418
392
|
},
|
|
419
|
-
getItemProps: (
|
|
420
|
-
var Ve;
|
|
393
|
+
getItemProps: (s, d) => {
|
|
421
394
|
const {
|
|
422
|
-
_fixed:
|
|
423
|
-
_focus:
|
|
395
|
+
_fixed: I,
|
|
396
|
+
_focus: S,
|
|
424
397
|
children: R,
|
|
425
|
-
disabled:
|
|
426
|
-
label:
|
|
427
|
-
value:
|
|
398
|
+
disabled: T,
|
|
399
|
+
label: z,
|
|
400
|
+
value: Z,
|
|
428
401
|
fixed: p,
|
|
429
|
-
getValue:
|
|
430
|
-
onClick:
|
|
431
|
-
onMouseOver:
|
|
402
|
+
getValue: b = Ge,
|
|
403
|
+
onClick: A,
|
|
404
|
+
onMouseOver: Ee,
|
|
432
405
|
//sx,
|
|
433
|
-
...
|
|
434
|
-
} =
|
|
406
|
+
...ue
|
|
407
|
+
} = s, _ = d ? Z : b(Z)?.toString(), Pe = _ === K, at = v.findIndex((ee) => ee.value === _) >= 0, Re = R || z || _;
|
|
435
408
|
return {
|
|
436
409
|
item: {
|
|
437
|
-
...typeof
|
|
410
|
+
...typeof Re != "string" || !o ? { children: Re } : {
|
|
438
411
|
dangerouslySetInnerHTML: {
|
|
439
|
-
__html:
|
|
412
|
+
__html: Ft(Re, j)
|
|
440
413
|
}
|
|
441
414
|
},
|
|
442
|
-
"aria-selected":
|
|
443
|
-
"aria-disabled":
|
|
415
|
+
"aria-selected": F.includes(_),
|
|
416
|
+
"aria-disabled": T,
|
|
444
417
|
_disabled: { opacity: 0.4, cursor: "not-allowed", userSelect: "none" },
|
|
445
|
-
onMouseDown: (
|
|
446
|
-
|
|
447
|
-
h(g, se), 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: (
|
|
450
|
-
|
|
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
|
-
...
|
|
429
|
+
...De(o) ? o : {
|
|
458
430
|
fontWeight: o ? "extrabold" : "inherit"
|
|
459
431
|
}
|
|
460
432
|
}
|
|
461
433
|
},
|
|
462
|
-
|
|
463
|
-
...p &&
|
|
464
|
-
...
|
|
434
|
+
...Pe && (S || Tt()),
|
|
435
|
+
...p && I,
|
|
436
|
+
...ue
|
|
465
437
|
},
|
|
466
438
|
root: {
|
|
467
|
-
isValidSuggestion:
|
|
468
|
-
value:
|
|
439
|
+
isValidSuggestion: at,
|
|
440
|
+
value: _
|
|
469
441
|
}
|
|
470
442
|
};
|
|
471
443
|
},
|
|
472
|
-
inputRef:
|
|
473
|
-
interactionRef:
|
|
474
|
-
isLoading:
|
|
475
|
-
isOpen:
|
|
476
|
-
itemList:
|
|
477
|
-
listRef:
|
|
478
|
-
onClose:
|
|
479
|
-
onOpen:
|
|
480
|
-
placement:
|
|
481
|
-
query:
|
|
482
|
-
removeItem:
|
|
483
|
-
resetItems:
|
|
484
|
-
setQuery:
|
|
485
|
-
tags:
|
|
486
|
-
value:
|
|
487
|
-
values:
|
|
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: ut,
|
|
456
|
+
setQuery: J,
|
|
457
|
+
tags: Be,
|
|
458
|
+
value: k,
|
|
459
|
+
values: F
|
|
488
460
|
};
|
|
489
461
|
}
|
|
490
|
-
var
|
|
462
|
+
var et = {
|
|
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
|
-
},
|
|
497
|
-
function
|
|
468
|
+
}, Ke = E.createContext && /* @__PURE__ */ E.createContext(et), Bt = ["attr", "size", "title"];
|
|
469
|
+
function Vt(e, t) {
|
|
498
470
|
if (e == null) return {};
|
|
499
|
-
var n =
|
|
471
|
+
var n = $t(e, t), r, o;
|
|
500
472
|
if (Object.getOwnPropertySymbols) {
|
|
501
|
-
var
|
|
502
|
-
for (o = 0; o <
|
|
503
|
-
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
|
|
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
|
|
518
|
-
return
|
|
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
|
-
},
|
|
497
|
+
}, fe.apply(this, arguments);
|
|
526
498
|
}
|
|
527
|
-
function
|
|
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
|
|
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 ?
|
|
541
|
-
|
|
542
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) :
|
|
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
|
|
549
|
-
return t =
|
|
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
|
|
552
|
-
var t =
|
|
523
|
+
function Kt(e) {
|
|
524
|
+
var t = Qt(e, "string");
|
|
553
525
|
return typeof t == "symbol" ? t : t + "";
|
|
554
526
|
}
|
|
555
|
-
function
|
|
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
|
|
566
|
-
return e && e.map((t, n) => /* @__PURE__ */
|
|
537
|
+
function tt(e) {
|
|
538
|
+
return e && e.map((t, n) => /* @__PURE__ */ E.createElement(t.tag, de({
|
|
567
539
|
key: n
|
|
568
|
-
}, t.attr),
|
|
540
|
+
}, t.attr), tt(t.child)));
|
|
569
541
|
}
|
|
570
|
-
function
|
|
571
|
-
return (t) => /* @__PURE__ */
|
|
572
|
-
attr:
|
|
573
|
-
}, t),
|
|
542
|
+
function Ut(e) {
|
|
543
|
+
return (t) => /* @__PURE__ */ E.createElement(Yt, fe({
|
|
544
|
+
attr: de({}, e.attr)
|
|
545
|
+
}, t), tt(e.child));
|
|
574
546
|
}
|
|
575
|
-
function
|
|
547
|
+
function Yt(e) {
|
|
576
548
|
var t = (n) => {
|
|
577
549
|
var {
|
|
578
550
|
attr: r,
|
|
579
551
|
size: o,
|
|
580
|
-
title:
|
|
581
|
-
} = e,
|
|
582
|
-
return n.className && (
|
|
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,
|
|
587
|
-
className:
|
|
588
|
-
style:
|
|
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:
|
|
592
|
-
width:
|
|
563
|
+
height: u,
|
|
564
|
+
width: u,
|
|
593
565
|
xmlns: "http://www.w3.org/2000/svg"
|
|
594
|
-
}),
|
|
566
|
+
}), i && /* @__PURE__ */ E.createElement("title", null, i), e.children);
|
|
595
567
|
};
|
|
596
|
-
return
|
|
568
|
+
return Ke !== void 0 ? /* @__PURE__ */ E.createElement(Ke.Consumer, null, (n) => t(n)) : t(et);
|
|
597
569
|
}
|
|
598
|
-
function
|
|
599
|
-
return
|
|
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
|
|
602
|
-
return /* @__PURE__ */ a(
|
|
603
|
-
}),
|
|
604
|
-
const { portalled: r = !0, portalRef: o, ...
|
|
605
|
-
return /* @__PURE__ */ a(
|
|
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
|
-
|
|
608
|
-
return /* @__PURE__ */ a(
|
|
579
|
+
N.forwardRef(function(t, n) {
|
|
580
|
+
return /* @__PURE__ */ a(P.Arrow, { ...t, ref: n, children: /* @__PURE__ */ a(P.ArrowTip, {}) });
|
|
609
581
|
});
|
|
610
|
-
|
|
582
|
+
N.forwardRef(function(t, n) {
|
|
611
583
|
return /* @__PURE__ */ a(
|
|
612
|
-
|
|
584
|
+
P.CloseTrigger,
|
|
613
585
|
{
|
|
614
586
|
position: "absolute",
|
|
615
587
|
top: "1",
|
|
@@ -617,257 +589,250 @@ L.forwardRef(function(t, n) {
|
|
|
617
589
|
...t,
|
|
618
590
|
asChild: !0,
|
|
619
591
|
ref: n,
|
|
620
|
-
children: /* @__PURE__ */ a(
|
|
592
|
+
children: /* @__PURE__ */ a(qt, { size: "sm" })
|
|
621
593
|
}
|
|
622
594
|
);
|
|
623
595
|
});
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
const
|
|
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 =
|
|
604
|
+
const n = zt(e), {
|
|
633
605
|
children: r,
|
|
634
606
|
isOpen: o,
|
|
635
|
-
onClose:
|
|
636
|
-
onOpen:
|
|
637
|
-
placement:
|
|
638
|
-
resetItems:
|
|
639
|
-
removeItem:
|
|
607
|
+
onClose: i,
|
|
608
|
+
onOpen: l,
|
|
609
|
+
placement: u,
|
|
610
|
+
resetItems: c,
|
|
611
|
+
removeItem: g
|
|
640
612
|
} = n;
|
|
641
|
-
|
|
642
|
-
resetItems:
|
|
643
|
-
removeItem:
|
|
613
|
+
ct(t, () => ({
|
|
614
|
+
resetItems: c,
|
|
615
|
+
removeItem: g
|
|
644
616
|
}));
|
|
645
|
-
const { matchWidth:
|
|
646
|
-
return /* @__PURE__ */ a(
|
|
647
|
-
|
|
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:
|
|
623
|
+
positioning: { placement: u, sameWidth: h },
|
|
652
624
|
present: o,
|
|
653
|
-
children: /* @__PURE__ */ a(
|
|
625
|
+
children: /* @__PURE__ */ a(ht.div, { w: "full", ref: t, children: r })
|
|
654
626
|
}
|
|
655
627
|
) });
|
|
656
628
|
}
|
|
657
629
|
);
|
|
658
|
-
|
|
659
|
-
const
|
|
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
|
-
} =
|
|
666
|
-
|
|
667
|
-
|
|
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
|
-
}, [
|
|
673
|
-
typeof
|
|
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:
|
|
678
|
-
return
|
|
648
|
+
const { children: f, dangerouslySetInnerHTML: y, ...O } = u.item, w = me(O, ["groupId"]);
|
|
649
|
+
return c ? /* @__PURE__ */ a(pe, { ref: l, ...nt, ...w, children: f || /* @__PURE__ */ a("span", { dangerouslySetInnerHTML: y }) }) : null;
|
|
679
650
|
}
|
|
680
651
|
);
|
|
681
|
-
|
|
682
|
-
const
|
|
652
|
+
nn.displayName = "AutoCompleteItem";
|
|
653
|
+
const nt = {
|
|
683
654
|
mx: "2",
|
|
684
655
|
px: "2",
|
|
685
656
|
py: "2",
|
|
686
657
|
rounded: "md",
|
|
687
658
|
cursor: "pointer"
|
|
688
659
|
};
|
|
689
|
-
function
|
|
660
|
+
function rn(e) {
|
|
690
661
|
const { alwaysDisplay: t, children: n, ...r } = e, {
|
|
691
662
|
autoCompleteProps: o,
|
|
692
|
-
getItemProps:
|
|
693
|
-
query:
|
|
694
|
-
filteredResults:
|
|
695
|
-
} =
|
|
663
|
+
getItemProps: i,
|
|
664
|
+
query: l,
|
|
665
|
+
filteredResults: u
|
|
666
|
+
} = W(), { children: c, ...g } = i(
|
|
696
667
|
{
|
|
697
668
|
...e,
|
|
698
|
-
value:
|
|
699
|
-
children:
|
|
700
|
-
value:
|
|
669
|
+
value: l,
|
|
670
|
+
children: m(n, {
|
|
671
|
+
value: l
|
|
701
672
|
})
|
|
702
673
|
},
|
|
703
674
|
!0
|
|
704
|
-
).item,
|
|
705
|
-
return o.creatable &&
|
|
675
|
+
).item, h = u.some((O) => O.value === l), f = Te(l) ? t : !0;
|
|
676
|
+
return o.creatable && f && !h ? /* @__PURE__ */ a(pe, { ...nt, ...g, ...r, children: c || `Add ${l}` }) : null;
|
|
706
677
|
}
|
|
707
|
-
|
|
708
|
-
const
|
|
678
|
+
rn.displayName = "AutoCompleteCreatable";
|
|
679
|
+
const on = B(
|
|
709
680
|
(e, t) => {
|
|
710
|
-
const { children: n, showDivider: r, ...o } = e,
|
|
711
|
-
return /* @__PURE__ */
|
|
712
|
-
/* @__PURE__ */ a(
|
|
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(
|
|
685
|
+
/* @__PURE__ */ a(Ve, { ...c.bottom })
|
|
715
686
|
] });
|
|
716
687
|
}
|
|
717
|
-
),
|
|
718
|
-
(e, t) => /* @__PURE__ */ a(
|
|
688
|
+
), sn = B(
|
|
689
|
+
(e, t) => /* @__PURE__ */ a(pe, { ...ln, ...e, ref: t })
|
|
719
690
|
);
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
const
|
|
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
|
-
},
|
|
730
|
-
const { getGroupProps: t } =
|
|
700
|
+
}, un = (e) => {
|
|
701
|
+
const { getGroupProps: t } = W(), n = e.groupSibling, {
|
|
731
702
|
divider: { hasFirstChild: r, hasLastChild: o }
|
|
732
|
-
} = t(e),
|
|
703
|
+
} = t(e), i = {
|
|
733
704
|
my: 2,
|
|
734
705
|
borderColor: e.dividerColor
|
|
735
|
-
},
|
|
736
|
-
...
|
|
706
|
+
}, l = {
|
|
707
|
+
...i,
|
|
737
708
|
mb: 4,
|
|
738
709
|
display: !e.showDivider || r ? "none" : ""
|
|
739
|
-
},
|
|
740
|
-
...
|
|
710
|
+
}, u = {
|
|
711
|
+
...i,
|
|
741
712
|
display: !e.showDivider || o || n ? "none" : ""
|
|
742
713
|
};
|
|
743
|
-
return { top:
|
|
744
|
-
},
|
|
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:
|
|
750
|
-
endElementProps:
|
|
751
|
-
children:
|
|
752
|
-
startOffset:
|
|
753
|
-
endOffset:
|
|
754
|
-
...
|
|
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__ */
|
|
757
|
-
r && /* @__PURE__ */ a(
|
|
758
|
-
|
|
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) - ${
|
|
731
|
+
ps: `calc(var(--input-height) - ${c})`
|
|
761
732
|
},
|
|
762
|
-
...
|
|
763
|
-
...
|
|
733
|
+
...i && { pe: `calc(var(--input-height) - ${g})` },
|
|
734
|
+
...u.props
|
|
764
735
|
}),
|
|
765
|
-
|
|
736
|
+
i && /* @__PURE__ */ a($e, { placement: "end", ...l, children: i })
|
|
766
737
|
] });
|
|
767
738
|
}
|
|
768
|
-
),
|
|
769
|
-
const { isLoading: n } =
|
|
770
|
-
|
|
771
|
-
}),
|
|
739
|
+
), cn = B((e, t) => {
|
|
740
|
+
const { isLoading: n } = W(), { loadingIcon: r, ...o } = e, i = me(o, ["children", "wrapStyles", "hidePlaceholder"]);
|
|
741
|
+
let l;
|
|
742
|
+
return n && (l = r || /* @__PURE__ */ a(Xe, {})), /* @__PURE__ */ a(an, { w: "full", endElement: /* @__PURE__ */ a(Ye, { children: l }), children: /* @__PURE__ */ a(yt, { ...i, ref: t }) });
|
|
743
|
+
}), fn = B(
|
|
772
744
|
(e, t) => {
|
|
773
745
|
const {
|
|
774
746
|
autoCompleteProps: n,
|
|
775
747
|
inputRef: r,
|
|
776
748
|
getInputProps: o,
|
|
777
|
-
tags:
|
|
778
|
-
setQuery:
|
|
779
|
-
value:
|
|
780
|
-
itemList:
|
|
781
|
-
} =
|
|
782
|
-
children:
|
|
783
|
-
hidePlaceholder:
|
|
784
|
-
...
|
|
785
|
-
} = e, { value:
|
|
786
|
-
|
|
787
|
-
if (
|
|
788
|
-
const
|
|
789
|
-
|
|
749
|
+
tags: i,
|
|
750
|
+
setQuery: l,
|
|
751
|
+
value: u,
|
|
752
|
+
itemList: c
|
|
753
|
+
} = W(), {
|
|
754
|
+
children: g,
|
|
755
|
+
hidePlaceholder: h,
|
|
756
|
+
...f
|
|
757
|
+
} = e, { value: y } = f;
|
|
758
|
+
L(() => {
|
|
759
|
+
if (u !== void 0 && (typeof u == "string" || u instanceof String)) {
|
|
760
|
+
const re = c.find((k) => k.value === u), be = re === void 0 ? u : re.label;
|
|
761
|
+
l(be);
|
|
790
762
|
}
|
|
791
|
-
}, [
|
|
792
|
-
|
|
793
|
-
}, [
|
|
794
|
-
const
|
|
795
|
-
let { wrapper:
|
|
796
|
-
const { ref:
|
|
797
|
-
|
|
798
|
-
...
|
|
799
|
-
placeholder: Array.isArray(
|
|
763
|
+
}, [u]), L(() => {
|
|
764
|
+
y !== void 0 && (typeof y == "string" || y instanceof String) && l(y);
|
|
765
|
+
}, [y]);
|
|
766
|
+
const O = {};
|
|
767
|
+
let { wrapper: w, input: V } = o(f, O);
|
|
768
|
+
const { ref: he, ...X } = w, ve = _e(t, r), q = m(g, { tags: i });
|
|
769
|
+
h && (V = {
|
|
770
|
+
...V,
|
|
771
|
+
placeholder: Array.isArray(q) && q.length ? void 0 : V.placeholder
|
|
800
772
|
});
|
|
801
|
-
const
|
|
802
|
-
|
|
773
|
+
const ne = /* @__PURE__ */ a(
|
|
774
|
+
cn,
|
|
803
775
|
{
|
|
804
|
-
...
|
|
805
|
-
ref:
|
|
776
|
+
...V,
|
|
777
|
+
ref: ve
|
|
806
778
|
}
|
|
807
|
-
),
|
|
808
|
-
|
|
809
|
-
|
|
779
|
+
), ye = /* @__PURE__ */ Y(je, { ...X, ref: he, children: [
|
|
780
|
+
q,
|
|
781
|
+
ne
|
|
810
782
|
] });
|
|
811
|
-
return /* @__PURE__ */ a(
|
|
783
|
+
return /* @__PURE__ */ a(bt, { w: "full", ...X, children: n.multiple ? ye : ne });
|
|
812
784
|
}
|
|
813
785
|
);
|
|
814
|
-
|
|
815
|
-
const
|
|
816
|
-
const { getEmptyStateProps: t, defaultEmptyStateProps: n } =
|
|
817
|
-
/* @__PURE__ */ a(
|
|
786
|
+
fn.displayName = "Input";
|
|
787
|
+
const dn = (e) => {
|
|
788
|
+
const { getEmptyStateProps: t, defaultEmptyStateProps: n } = W(), r = t(
|
|
789
|
+
/* @__PURE__ */ a(pe, { ...pn, ...n, children: "No options found!" })
|
|
818
790
|
);
|
|
819
|
-
return /* @__PURE__ */ a(
|
|
820
|
-
},
|
|
791
|
+
return /* @__PURE__ */ a(je, { ...e, children: r });
|
|
792
|
+
}, pn = {
|
|
821
793
|
fontSize: "sm",
|
|
822
794
|
align: "center",
|
|
823
795
|
justify: "center",
|
|
824
796
|
fontWeight: "bold",
|
|
825
797
|
fontStyle: "italic"
|
|
826
|
-
},
|
|
798
|
+
}, Ue = [
|
|
827
799
|
"AutoCompleteGroup",
|
|
828
800
|
"AutoCompleteItem",
|
|
829
801
|
"AutoCompleteCreatable"
|
|
830
|
-
],
|
|
831
|
-
const t =
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
groupSibling: i ? i.type.displayName === "AutoCompleteGroup" : !1
|
|
802
|
+
], mn = (e) => {
|
|
803
|
+
const t = E.Children.map(e, (o, i) => {
|
|
804
|
+
if (o?.type?.displayName === "AutoCompleteGroup") {
|
|
805
|
+
const l = E.Children.toArray(e)[i + 1];
|
|
806
|
+
return E.cloneElement(o, {
|
|
807
|
+
groupSibling: l ? l.type.displayName === "AutoCompleteGroup" : !1
|
|
837
808
|
});
|
|
838
809
|
}
|
|
839
810
|
return o;
|
|
840
|
-
}), n =
|
|
841
|
-
(o) =>
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
(s = o == null ? void 0 : o.type) == null ? void 0 : s.displayName
|
|
845
|
-
);
|
|
846
|
-
}
|
|
811
|
+
}), n = E.Children.toArray(t).filter(
|
|
812
|
+
(o) => !Ue.includes(
|
|
813
|
+
o?.type?.displayName
|
|
814
|
+
)
|
|
847
815
|
);
|
|
848
|
-
return [
|
|
849
|
-
(o) =>
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
(s = o == null ? void 0 : o.type) == null ? void 0 : s.displayName
|
|
853
|
-
);
|
|
854
|
-
}
|
|
816
|
+
return [E.Children.toArray(t).filter(
|
|
817
|
+
(o) => Ue.includes(
|
|
818
|
+
o?.type?.displayName
|
|
819
|
+
)
|
|
855
820
|
), n];
|
|
856
|
-
},
|
|
821
|
+
}, gn = B(
|
|
857
822
|
(e, t) => {
|
|
858
|
-
const { children: n, loadingState: r, ...o } = e, { listRef:
|
|
859
|
-
return /* @__PURE__ */ a(
|
|
860
|
-
|
|
861
|
-
!
|
|
862
|
-
|
|
863
|
-
/* @__PURE__ */ a(
|
|
864
|
-
|
|
823
|
+
const { children: n, loadingState: r, ...o } = e, { listRef: i, isLoading: l } = W(), u = _e(t, i), [c, g] = mn(n);
|
|
824
|
+
return /* @__PURE__ */ a(Jt, { width: "auto", children: /* @__PURE__ */ Y(en, { ref: u, w: "inherit", ...hn, ...o, children: [
|
|
825
|
+
l && /* @__PURE__ */ a(Ct, { children: r || /* @__PURE__ */ a(Xe, { size: "md" }) }),
|
|
826
|
+
!l && /* @__PURE__ */ Y(Ye, { children: [
|
|
827
|
+
c,
|
|
828
|
+
/* @__PURE__ */ a(dn, {}),
|
|
829
|
+
g
|
|
865
830
|
] })
|
|
866
831
|
] }) });
|
|
867
832
|
}
|
|
868
833
|
);
|
|
869
|
-
|
|
870
|
-
const
|
|
834
|
+
gn.displayName = "AutoCompleteList";
|
|
835
|
+
const hn = {
|
|
871
836
|
// py: "4",
|
|
872
837
|
//opacity: "0",
|
|
873
838
|
px: "0px",
|
|
@@ -884,55 +849,55 @@ const bn = {
|
|
|
884
849
|
_focus: {
|
|
885
850
|
boxShadow: "none"
|
|
886
851
|
}
|
|
887
|
-
},
|
|
852
|
+
}, vn = N.forwardRef(
|
|
888
853
|
function(t, n) {
|
|
889
854
|
const {
|
|
890
855
|
startElement: r,
|
|
891
856
|
endElement: o,
|
|
892
|
-
onClose:
|
|
893
|
-
closable:
|
|
894
|
-
children:
|
|
895
|
-
...
|
|
857
|
+
onClose: i,
|
|
858
|
+
closable: l = !!i,
|
|
859
|
+
children: u,
|
|
860
|
+
...c
|
|
896
861
|
} = t;
|
|
897
|
-
return /* @__PURE__ */
|
|
898
|
-
r && /* @__PURE__ */ a(
|
|
899
|
-
/* @__PURE__ */ a(
|
|
900
|
-
o && /* @__PURE__ */ a(
|
|
901
|
-
|
|
862
|
+
return /* @__PURE__ */ Y(Q.Root, { ref: n, ...c, children: [
|
|
863
|
+
r && /* @__PURE__ */ a(Q.StartElement, { children: r }),
|
|
864
|
+
/* @__PURE__ */ a(Q.Label, { children: u }),
|
|
865
|
+
o && /* @__PURE__ */ a(Q.EndElement, { children: o }),
|
|
866
|
+
l && /* @__PURE__ */ a(Q.EndElement, { children: /* @__PURE__ */ a(Q.CloseTrigger, { onClick: i }) })
|
|
902
867
|
] });
|
|
903
868
|
}
|
|
904
|
-
),
|
|
869
|
+
), An = ft((e) => {
|
|
905
870
|
const { label: t, onRemove: n, disabled: r, ...o } = e;
|
|
906
871
|
return /* @__PURE__ */ a(
|
|
907
|
-
|
|
872
|
+
vn,
|
|
908
873
|
{
|
|
909
874
|
borderRadius: "md",
|
|
910
875
|
fontWeight: "normal",
|
|
911
876
|
closable: !0,
|
|
912
|
-
onClose: () => !r &&
|
|
913
|
-
...r &&
|
|
877
|
+
onClose: () => !r && m(n),
|
|
878
|
+
...r && yn,
|
|
914
879
|
...o,
|
|
915
880
|
children: t
|
|
916
881
|
}
|
|
917
882
|
);
|
|
918
|
-
}),
|
|
883
|
+
}), yn = {
|
|
919
884
|
cursor: "text",
|
|
920
885
|
userSelect: "none",
|
|
921
886
|
opacity: 0.4,
|
|
922
887
|
_focus: { boxShadow: "none" }
|
|
923
888
|
};
|
|
924
889
|
export {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
890
|
+
tn as AutoComplete,
|
|
891
|
+
rn as AutoCompleteCreatable,
|
|
892
|
+
on as AutoCompleteGroup,
|
|
893
|
+
sn as AutoCompleteGroupTitle,
|
|
894
|
+
fn as AutoCompleteInput,
|
|
895
|
+
nn as AutoCompleteItem,
|
|
896
|
+
gn as AutoCompleteList,
|
|
897
|
+
It as AutoCompleteProvider,
|
|
898
|
+
An as AutoCompleteTag,
|
|
899
|
+
nt as baseItemStyles,
|
|
900
|
+
wt as createContext,
|
|
901
|
+
zt as useAutoComplete,
|
|
902
|
+
W as useAutoCompleteContext
|
|
938
903
|
};
|