ics-ui-kit 0.1.0-alpha.16 → 0.1.0-alpha.17
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/SearchSelectTag-9aMVvXqp.js +95 -0
- package/dist/SearchSelectTag-9aMVvXqp.js.map +1 -0
- package/dist/components/search-select/index.d.ts +2 -0
- package/dist/components/search-select.js +352 -260
- package/dist/components/search-select.js.map +1 -1
- package/dist/components/tag-input.js +110 -186
- package/dist/components/tag-input.js.map +1 -1
- package/package.json +1 -1
- package/dist/useControllableState-B3ZaoXSG.js +0 -15
- package/dist/useControllableState-B3ZaoXSG.js.map +0 -1
|
@@ -1,160 +1,160 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var de = Object.defineProperty, he = Object.defineProperties;
|
|
2
|
+
var fe = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var k = Object.getOwnPropertySymbols;
|
|
4
|
+
var X = Object.prototype.hasOwnProperty, Y = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var U = (e, r, t) => r in e ? de(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, L = (e, r) => {
|
|
6
6
|
for (var t in r || (r = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
X.call(r, t) && U(e, t, r[t]);
|
|
8
|
+
if (k)
|
|
9
|
+
for (var t of k(r))
|
|
10
|
+
Y.call(r, t) && U(e, t, r[t]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, P = (e, r) => he(e, fe(r));
|
|
13
|
+
var E = (e, r) => {
|
|
14
14
|
var t = {};
|
|
15
15
|
for (var n in e)
|
|
16
|
-
|
|
17
|
-
if (e != null &&
|
|
18
|
-
for (var n of
|
|
19
|
-
r.indexOf(n) < 0 &&
|
|
16
|
+
X.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
|
|
17
|
+
if (e != null && k)
|
|
18
|
+
for (var n of k(e))
|
|
19
|
+
r.indexOf(n) < 0 && Y.call(e, n) && (t[n] = e[n]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var
|
|
23
|
-
var
|
|
22
|
+
var Z = (e, r, t) => new Promise((n, s) => {
|
|
23
|
+
var i = (o) => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
25
|
+
c(t.next(o));
|
|
26
26
|
} catch (u) {
|
|
27
27
|
s(u);
|
|
28
28
|
}
|
|
29
|
-
}, m = (
|
|
29
|
+
}, m = (o) => {
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
c(t.throw(o));
|
|
32
32
|
} catch (u) {
|
|
33
33
|
s(u);
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
|
|
35
|
+
}, c = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(i, m);
|
|
36
|
+
c((t = t.apply(e, r)).next());
|
|
37
37
|
});
|
|
38
|
-
import { jsx as
|
|
39
|
-
import
|
|
40
|
-
import { c as
|
|
41
|
-
import { u as
|
|
42
|
-
import { b as
|
|
43
|
-
import { I as
|
|
44
|
-
import { b as
|
|
45
|
-
import { C as
|
|
46
|
-
import { C as
|
|
47
|
-
import { L as
|
|
48
|
-
import { u as
|
|
49
|
-
import { E as
|
|
50
|
-
import { E as
|
|
51
|
-
import { H as
|
|
52
|
-
const
|
|
38
|
+
import { jsx as l, jsxs as M, Fragment as W } from "react/jsx-runtime";
|
|
39
|
+
import A, { useState as O, useCallback as N, useEffect as z, useMemo as D, useRef as K } from "react";
|
|
40
|
+
import { c as F } from "../index-CR-odn5-.js";
|
|
41
|
+
import { u as j, a as me, S as pe } from "../SearchSelectTag-9aMVvXqp.js";
|
|
42
|
+
import { b as Se, f as ee, C as re, c as te, d as ge, h as ye } from "../Command-F3OlI1TA.js";
|
|
43
|
+
import { I as B } from "../Icon-CSPBHL_x.js";
|
|
44
|
+
import { b as ve, P as _, a as $ } from "../Popover-B3jOhCY-.js";
|
|
45
|
+
import { C as be, s as Ce } from "../Select-C9hKZk4J.js";
|
|
46
|
+
import { C as ne } from "../check-C-TqZgvb.js";
|
|
47
|
+
import { L as ae } from "../Loader-DCJ9-3Mw.js";
|
|
48
|
+
import { u as Ne } from "../useDebounce-BRah78CF.js";
|
|
49
|
+
import { E as xe } from "../EmptyState-_sREQZFi.js";
|
|
50
|
+
import { E as Le } from "../ErrorState-E8i5zWYq.js";
|
|
51
|
+
import { H as Oe } from "../HintState-BRHKrilH.js";
|
|
52
|
+
const we = ({
|
|
53
53
|
options: e,
|
|
54
54
|
value: r,
|
|
55
55
|
defaultValue: t,
|
|
56
56
|
onChange: n
|
|
57
57
|
}) => {
|
|
58
|
-
const [s,
|
|
59
|
-
(
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
|
|
58
|
+
const [s, i] = O(void 0), m = N(
|
|
59
|
+
(h) => {
|
|
60
|
+
if (h !== void 0) {
|
|
61
|
+
const f = e.find((g) => g.value === h) || s;
|
|
62
|
+
f && f.value === h && (i(f), n == null || n(h, f));
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
[n, e, s]
|
|
66
|
-
), [
|
|
66
|
+
), [c, o] = j({
|
|
67
67
|
value: r,
|
|
68
68
|
defaultValue: t,
|
|
69
69
|
onChange: m
|
|
70
70
|
});
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
if (s && s.value ===
|
|
71
|
+
z(() => {
|
|
72
|
+
if (c !== void 0) {
|
|
73
|
+
if (s && s.value === c)
|
|
74
74
|
return;
|
|
75
|
-
const
|
|
76
|
-
|
|
75
|
+
const h = e.find((f) => f.value === c);
|
|
76
|
+
h && i(h);
|
|
77
77
|
} else
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
const u =
|
|
81
|
-
(
|
|
82
|
-
const
|
|
83
|
-
|
|
78
|
+
i(void 0);
|
|
79
|
+
}, [c, e, s]);
|
|
80
|
+
const u = N(
|
|
81
|
+
(h) => {
|
|
82
|
+
const f = e.find((g) => g.label === h);
|
|
83
|
+
f && o(f.value);
|
|
84
84
|
},
|
|
85
|
-
[
|
|
85
|
+
[o, e]
|
|
86
86
|
);
|
|
87
87
|
return {
|
|
88
|
-
selectedValue:
|
|
88
|
+
selectedValue: c,
|
|
89
89
|
selectedOption: s,
|
|
90
90
|
setSelectedByLabel: u,
|
|
91
|
-
setSelectedValue:
|
|
91
|
+
setSelectedValue: o
|
|
92
92
|
};
|
|
93
|
-
},
|
|
93
|
+
}, Te = F({
|
|
94
94
|
base: "self-center pl-1.5"
|
|
95
|
-
}),
|
|
95
|
+
}), le = ({ children: e, className: r }) => /* @__PURE__ */ l("span", { className: Te({ className: r }), children: e }), Ie = F({
|
|
96
96
|
base: "pointer-events-none self-center pl-1.5 text-muted"
|
|
97
|
-
}),
|
|
98
|
-
extend:
|
|
97
|
+
}), Pe = ({ children: e, className: r }) => /* @__PURE__ */ l("span", { className: Ie({ className: r }), children: e }), Me = F({
|
|
98
|
+
extend: Ce,
|
|
99
99
|
base: "group/search-select-trigger h-auto items-start py-1.5 pl-1.5 pr-3 lg:h-auto lg:py-1.5 lg:pl-1.5 lg:pr-2.5",
|
|
100
100
|
slots: {
|
|
101
101
|
iconWrapper: "py-1.5 lg:py-1"
|
|
102
102
|
}
|
|
103
|
-
}),
|
|
104
|
-
(
|
|
105
|
-
var u =
|
|
106
|
-
const
|
|
107
|
-
return /* @__PURE__ */
|
|
103
|
+
}), q = A.forwardRef(
|
|
104
|
+
(o, c) => {
|
|
105
|
+
var u = o, { className: e, children: r, disabled: t, open: n, invalid: s, placeholder: i } = u, m = E(u, ["className", "children", "disabled", "open", "invalid", "placeholder"]);
|
|
106
|
+
const h = Me({ disabled: t, invalid: s });
|
|
107
|
+
return /* @__PURE__ */ M(
|
|
108
108
|
"button",
|
|
109
|
-
|
|
109
|
+
P(L({}, m), {
|
|
110
110
|
disabled: t,
|
|
111
|
-
className:
|
|
112
|
-
ref:
|
|
111
|
+
className: h.base({ className: e }),
|
|
112
|
+
ref: c,
|
|
113
113
|
role: "combobox",
|
|
114
114
|
"aria-expanded": n,
|
|
115
115
|
"aria-invalid": s,
|
|
116
116
|
"aria-haspopup": "listbox",
|
|
117
117
|
children: [
|
|
118
|
-
r !== void 0 ? r : /* @__PURE__ */
|
|
119
|
-
!t && /* @__PURE__ */
|
|
118
|
+
r !== void 0 ? r : /* @__PURE__ */ l(Pe, { children: i }),
|
|
119
|
+
!t && /* @__PURE__ */ l("div", { className: h.iconWrapper(), children: /* @__PURE__ */ l(B, { icon: be, className: h.icon() }) })
|
|
120
120
|
]
|
|
121
121
|
})
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
);
|
|
125
|
-
|
|
126
|
-
const
|
|
125
|
+
q.displayName = "SearchSelectTrigger";
|
|
126
|
+
const Re = F({
|
|
127
127
|
base: "w-full min-w-[var(--radix-popper-anchor-width)] border-secondary-border p-0"
|
|
128
|
-
}),
|
|
128
|
+
}), H = A.forwardRef(
|
|
129
129
|
(s, n) => {
|
|
130
|
-
var
|
|
131
|
-
return /* @__PURE__ */
|
|
130
|
+
var i = s, { className: e, children: r } = i, t = E(i, ["className", "children"]);
|
|
131
|
+
return /* @__PURE__ */ l(ve, P(L({ ref: n, className: Re({ className: e }), align: "start" }, t), { children: r }));
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
var s = n, { placeholder: e = "Find" } = s, r =
|
|
137
|
-
return /* @__PURE__ */
|
|
134
|
+
H.displayName = "SearchSelectContent";
|
|
135
|
+
const G = A.forwardRef((n, t) => {
|
|
136
|
+
var s = n, { placeholder: e = "Find" } = s, r = E(s, ["placeholder"]);
|
|
137
|
+
return /* @__PURE__ */ l(Se, L({ ref: t, placeholder: e }, r));
|
|
138
138
|
});
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
const
|
|
139
|
+
G.displayName = "SearchSelectInput";
|
|
140
|
+
const Ee = F({ base: "" }), Ve = (e) => {
|
|
141
|
+
const J = e, {
|
|
142
142
|
className: r,
|
|
143
143
|
options: t,
|
|
144
144
|
renderOption: n,
|
|
145
145
|
placeholder: s = "Выберите значение",
|
|
146
|
-
value:
|
|
146
|
+
value: i,
|
|
147
147
|
defaultValue: m,
|
|
148
|
-
onChange:
|
|
149
|
-
disabled:
|
|
148
|
+
onChange: c,
|
|
149
|
+
disabled: o,
|
|
150
150
|
invalid: u,
|
|
151
|
-
searchPlaceholder:
|
|
152
|
-
emptyText:
|
|
153
|
-
shouldFilter:
|
|
151
|
+
searchPlaceholder: h = "Найти",
|
|
152
|
+
emptyText: f = "Результатов не найдено",
|
|
153
|
+
shouldFilter: g = !0,
|
|
154
154
|
footerContent: v,
|
|
155
|
-
onSearchChange:
|
|
156
|
-
onOpenChange:
|
|
157
|
-
} =
|
|
155
|
+
onSearchChange: a,
|
|
156
|
+
onOpenChange: d
|
|
157
|
+
} = J, y = E(J, [
|
|
158
158
|
"className",
|
|
159
159
|
"options",
|
|
160
160
|
"renderOption",
|
|
@@ -170,235 +170,235 @@ const Pe = E({ base: "" }), Re = (e) => {
|
|
|
170
170
|
"footerContent",
|
|
171
171
|
"onSearchChange",
|
|
172
172
|
"onOpenChange"
|
|
173
|
-
]), [
|
|
173
|
+
]), [b, C] = O(!1), [w, V] = O(""), { selectedValue: R, selectedOption: I, setSelectedByLabel: p } = we({
|
|
174
174
|
options: t,
|
|
175
|
-
value:
|
|
175
|
+
value: i,
|
|
176
176
|
defaultValue: m,
|
|
177
|
-
onChange:
|
|
178
|
-
}),
|
|
179
|
-
(
|
|
180
|
-
|
|
177
|
+
onChange: c
|
|
178
|
+
}), T = N(
|
|
179
|
+
(x) => {
|
|
180
|
+
p(x), C(!1);
|
|
181
181
|
},
|
|
182
|
-
[
|
|
183
|
-
),
|
|
184
|
-
(
|
|
185
|
-
|
|
182
|
+
[p, C]
|
|
183
|
+
), S = N(
|
|
184
|
+
(x) => {
|
|
185
|
+
V(x), a == null || a(x);
|
|
186
186
|
},
|
|
187
|
-
[
|
|
188
|
-
),
|
|
189
|
-
(
|
|
190
|
-
|
|
187
|
+
[a]
|
|
188
|
+
), Q = N(
|
|
189
|
+
(x) => {
|
|
190
|
+
C(x), d == null || d(x);
|
|
191
191
|
},
|
|
192
|
-
[
|
|
193
|
-
),
|
|
192
|
+
[d]
|
|
193
|
+
), oe = D(() => {
|
|
194
194
|
if (I)
|
|
195
|
-
return n ? n({ option: I, type: "trigger" }) : /* @__PURE__ */
|
|
196
|
-
}, [I, n]),
|
|
197
|
-
option:
|
|
195
|
+
return n ? n({ option: I, type: "trigger" }) : /* @__PURE__ */ l(le, { children: I.label });
|
|
196
|
+
}, [I, n]), ie = D(() => t.map((x, ue) => /* @__PURE__ */ l(ee, { value: x.label, onSelect: T, children: n ? n({
|
|
197
|
+
option: x,
|
|
198
198
|
type: "list",
|
|
199
|
-
isSelected:
|
|
200
|
-
searchQuery:
|
|
201
|
-
index:
|
|
202
|
-
}) : /* @__PURE__ */
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
] }) },
|
|
206
|
-
return /* @__PURE__ */
|
|
207
|
-
/* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
|
|
212
|
-
/* @__PURE__ */
|
|
199
|
+
isSelected: R === x.value,
|
|
200
|
+
searchQuery: w,
|
|
201
|
+
index: ue
|
|
202
|
+
}) : /* @__PURE__ */ M(W, { children: [
|
|
203
|
+
x.label,
|
|
204
|
+
R === x.value && /* @__PURE__ */ l(B, { icon: ne, className: "ml-auto" })
|
|
205
|
+
] }) }, x.value)), [t, n, R, w, T]);
|
|
206
|
+
return /* @__PURE__ */ l(_, P(L({}, y), { open: b, onOpenChange: Q, children: /* @__PURE__ */ M("div", { className: Ee({ className: r }), children: [
|
|
207
|
+
/* @__PURE__ */ l($, { asChild: !0, children: /* @__PURE__ */ l(q, { disabled: o, invalid: u, open: b, placeholder: s, children: oe }) }),
|
|
208
|
+
/* @__PURE__ */ l(H, { children: /* @__PURE__ */ M(re, { shouldFilter: g, children: [
|
|
209
|
+
/* @__PURE__ */ l(G, { placeholder: h, onValueChange: S }),
|
|
210
|
+
/* @__PURE__ */ M(te, { children: [
|
|
211
|
+
ie,
|
|
212
|
+
/* @__PURE__ */ l(ge, { className: "border-b border-secondary-border py-6", children: f }),
|
|
213
213
|
v
|
|
214
|
-
] }, `list-${
|
|
214
|
+
] }, `list-${w}`)
|
|
215
215
|
] }) })
|
|
216
216
|
] }) }));
|
|
217
|
-
},
|
|
217
|
+
}, De = F({
|
|
218
218
|
base: "py-2 text-center text-sm text-muted-foreground"
|
|
219
|
-
}), se =
|
|
219
|
+
}), se = A.forwardRef(
|
|
220
220
|
({ onLoad: e, hasMore: r, loadingText: t = "Загрузка...", className: n }, s) => {
|
|
221
|
-
const
|
|
222
|
-
return
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
const
|
|
221
|
+
const i = K(null), m = De({ className: n });
|
|
222
|
+
return A.useImperativeHandle(s, () => i.current), z(() => {
|
|
223
|
+
const c = i.current;
|
|
224
|
+
if (!c || !r) return;
|
|
225
|
+
const o = new IntersectionObserver(
|
|
226
226
|
([u]) => {
|
|
227
227
|
u.isIntersecting && e();
|
|
228
228
|
},
|
|
229
229
|
{ rootMargin: "50px" }
|
|
230
230
|
);
|
|
231
|
-
return
|
|
232
|
-
|
|
231
|
+
return o.observe(c), () => {
|
|
232
|
+
o.disconnect();
|
|
233
233
|
};
|
|
234
|
-
}, [e, r]), r ? /* @__PURE__ */
|
|
234
|
+
}, [e, r]), r ? /* @__PURE__ */ l("div", { ref: i, className: m, children: /* @__PURE__ */ l(ae, { className: "flex-row", children: t }) }) : null;
|
|
235
235
|
}
|
|
236
236
|
);
|
|
237
237
|
se.displayName = "LoadMoreTrigger";
|
|
238
|
-
const
|
|
238
|
+
const Fe = (e, r) => {
|
|
239
239
|
if (!r.trim()) return 1;
|
|
240
240
|
const t = e.toLowerCase().trim(), n = r.toLowerCase().trim();
|
|
241
241
|
if (t.startsWith(n)) return 3;
|
|
242
242
|
if (t.includes(n)) return 2;
|
|
243
243
|
let s = 0;
|
|
244
|
-
for (let
|
|
245
|
-
t[
|
|
244
|
+
for (let i = 0; i < t.length && s < n.length; i++)
|
|
245
|
+
t[i] === n[s] && s++;
|
|
246
246
|
return s === n.length ? 1 : 0;
|
|
247
|
-
},
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
const { visibleOptions: u, hasMoreItems:
|
|
251
|
-
const
|
|
252
|
-
option:
|
|
253
|
-
score: n(
|
|
254
|
-
})).filter(({ score:
|
|
247
|
+
}, Ae = (e) => {
|
|
248
|
+
const a = e, { options: r, pageSize: t = 50, filter: n = Fe } = a, s = E(a, ["options", "pageSize", "filter"]), [i, m] = O(t), [c, o] = O("");
|
|
249
|
+
z(() => m(t), [c, t]);
|
|
250
|
+
const { visibleOptions: u, hasMoreItems: h } = D(() => {
|
|
251
|
+
const d = c ? r.map((C) => ({
|
|
252
|
+
option: C,
|
|
253
|
+
score: n(C.label, c)
|
|
254
|
+
})).filter(({ score: C }) => C > 0).sort((C, w) => w.score - C.score).map(({ option: C }) => C) : r, y = d.slice(0, i), b = i < d.length;
|
|
255
255
|
return {
|
|
256
|
-
visibleOptions:
|
|
257
|
-
hasMoreItems:
|
|
256
|
+
visibleOptions: y,
|
|
257
|
+
hasMoreItems: b
|
|
258
258
|
};
|
|
259
|
-
}, [r,
|
|
260
|
-
m((
|
|
261
|
-
}, [t]),
|
|
262
|
-
|
|
263
|
-
}, []), v =
|
|
264
|
-
(
|
|
265
|
-
|
|
259
|
+
}, [r, c, i, n]), f = N(() => {
|
|
260
|
+
m((d) => d + t);
|
|
261
|
+
}, [t]), g = N((d) => {
|
|
262
|
+
o(d);
|
|
263
|
+
}, []), v = N(
|
|
264
|
+
(d) => {
|
|
265
|
+
d && c && o("");
|
|
266
266
|
},
|
|
267
|
-
[
|
|
267
|
+
[c, o]
|
|
268
268
|
);
|
|
269
|
-
return /* @__PURE__ */
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
return /* @__PURE__ */ l(
|
|
270
|
+
Ve,
|
|
271
|
+
P(L({}, s), {
|
|
272
272
|
options: u,
|
|
273
273
|
shouldFilter: !1,
|
|
274
|
-
footerContent: /* @__PURE__ */
|
|
275
|
-
onSearchChange:
|
|
274
|
+
footerContent: /* @__PURE__ */ l(se, { onLoad: f, hasMore: h }),
|
|
275
|
+
onSearchChange: g,
|
|
276
276
|
onOpenChange: v
|
|
277
277
|
})
|
|
278
278
|
);
|
|
279
279
|
};
|
|
280
|
-
|
|
281
|
-
const Qe =
|
|
280
|
+
Ae.displayName = "LazySearchSelect";
|
|
281
|
+
const Qe = A.forwardRef((e, r) => /* @__PURE__ */ l(ye, L({ ref: r }, e)));
|
|
282
282
|
Qe.displayName = "SearchSelectSeparator";
|
|
283
|
-
const
|
|
284
|
-
const [r, t] =
|
|
285
|
-
|
|
286
|
-
}, []),
|
|
287
|
-
(
|
|
283
|
+
const ze = ({ loadOptions: e }) => {
|
|
284
|
+
const [r, t] = O([]), [n, s] = O("idle"), [i, m] = O(null), c = K(null), o = K(0), u = N(() => {
|
|
285
|
+
c.current && c.current.abort();
|
|
286
|
+
}, []), h = N(
|
|
287
|
+
(f) => Z(void 0, null, function* () {
|
|
288
288
|
u();
|
|
289
|
-
const
|
|
290
|
-
|
|
289
|
+
const g = ++o.current, v = new AbortController();
|
|
290
|
+
c.current = v, s("loading"), m(null);
|
|
291
291
|
try {
|
|
292
|
-
const
|
|
293
|
-
searchQuery:
|
|
292
|
+
const a = yield e({
|
|
293
|
+
searchQuery: f,
|
|
294
294
|
signal: v.signal
|
|
295
295
|
});
|
|
296
|
-
if (
|
|
297
|
-
t(
|
|
298
|
-
} catch (
|
|
299
|
-
if (
|
|
300
|
-
m(
|
|
296
|
+
if (g !== o.current) return;
|
|
297
|
+
t(a.options), s("success");
|
|
298
|
+
} catch (a) {
|
|
299
|
+
if (a instanceof Error && a.name === "AbortError" || g !== o.current) return;
|
|
300
|
+
m(a instanceof Error ? a.message : "Неизвестная ошибка"), s("error");
|
|
301
301
|
}
|
|
302
302
|
}),
|
|
303
303
|
[e, u]
|
|
304
304
|
);
|
|
305
|
-
return
|
|
305
|
+
return z(() => () => u(), [u]), {
|
|
306
306
|
options: r,
|
|
307
307
|
loadingState: n,
|
|
308
|
-
error:
|
|
309
|
-
loadData:
|
|
308
|
+
error: i,
|
|
309
|
+
loadData: h,
|
|
310
310
|
cancelRequests: u
|
|
311
311
|
};
|
|
312
|
-
},
|
|
312
|
+
}, ke = ({
|
|
313
313
|
options: e,
|
|
314
314
|
loadingState: r,
|
|
315
315
|
error: t,
|
|
316
316
|
isSelected: n,
|
|
317
317
|
searchQuery: s,
|
|
318
|
-
loadMode:
|
|
318
|
+
loadMode: i,
|
|
319
319
|
minInputLength: m,
|
|
320
|
-
onSelect:
|
|
321
|
-
renderOption:
|
|
320
|
+
onSelect: c,
|
|
321
|
+
renderOption: o,
|
|
322
322
|
loadingText: u,
|
|
323
|
-
errorText:
|
|
324
|
-
inputHintText:
|
|
325
|
-
emptyText:
|
|
323
|
+
errorText: h,
|
|
324
|
+
inputHintText: f,
|
|
325
|
+
emptyText: g
|
|
326
326
|
}) => {
|
|
327
|
-
const v =
|
|
328
|
-
var
|
|
327
|
+
const v = D(() => e.map((a, d) => {
|
|
328
|
+
var y;
|
|
329
329
|
return {
|
|
330
|
-
option:
|
|
331
|
-
index:
|
|
332
|
-
isSelected: (
|
|
330
|
+
option: a,
|
|
331
|
+
index: d,
|
|
332
|
+
isSelected: (y = n == null ? void 0 : n(a)) != null ? y : !1
|
|
333
333
|
};
|
|
334
334
|
}), [e, n]);
|
|
335
|
-
return r === "error" ? /* @__PURE__ */
|
|
336
|
-
option:
|
|
335
|
+
return r === "error" ? /* @__PURE__ */ l(Le, { className: "py-6", children: t || h }) : r === "loading" ? /* @__PURE__ */ l(ae, { className: "py-6", children: u }) : i === "input" && s.length < m ? /* @__PURE__ */ l(Oe, { className: "py-6", children: f }) : e.length === 0 && r === "success" ? /* @__PURE__ */ l(xe, { className: "py-6", children: g }) : /* @__PURE__ */ l(W, { children: v.map(({ option: a, index: d, isSelected: y }) => /* @__PURE__ */ l(ee, { value: a.label, onSelect: c, children: o ? o({
|
|
336
|
+
option: a,
|
|
337
337
|
type: "list",
|
|
338
|
-
isSelected:
|
|
338
|
+
isSelected: y,
|
|
339
339
|
searchQuery: s,
|
|
340
|
-
index:
|
|
341
|
-
}) : /* @__PURE__ */
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
] }) },
|
|
345
|
-
},
|
|
340
|
+
index: d
|
|
341
|
+
}) : /* @__PURE__ */ M(W, { children: [
|
|
342
|
+
a.label,
|
|
343
|
+
y && /* @__PURE__ */ l(B, { icon: ne, className: "ml-auto" })
|
|
344
|
+
] }) }, a.value)) });
|
|
345
|
+
}, ce = (e) => {
|
|
346
346
|
const {
|
|
347
347
|
loadOptions: r,
|
|
348
348
|
loadMode: t = "auto",
|
|
349
349
|
minInputLength: n = 3,
|
|
350
350
|
debounceMs: s = 300,
|
|
351
|
-
searchPlaceholder:
|
|
351
|
+
searchPlaceholder: i = "Найти",
|
|
352
352
|
loadingText: m = "Загружаем...",
|
|
353
|
-
errorText:
|
|
354
|
-
inputHintText:
|
|
353
|
+
errorText: c = "Ошибка загрузки",
|
|
354
|
+
inputHintText: o = "Введите текст для поиска",
|
|
355
355
|
emptyText: u = "Результатов не найдено",
|
|
356
|
-
renderOption:
|
|
357
|
-
onSelect:
|
|
358
|
-
isSelected:
|
|
359
|
-
} = e, [v,
|
|
356
|
+
renderOption: h,
|
|
357
|
+
onSelect: f,
|
|
358
|
+
isSelected: g
|
|
359
|
+
} = e, [v, a] = O(""), d = Ne(v, s), { options: y, loadingState: b, error: C, loadData: w } = ze({
|
|
360
360
|
loadOptions: r
|
|
361
|
-
}),
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}, [
|
|
365
|
-
const
|
|
361
|
+
}), V = D(() => t === "auto" ? !0 : t === "input" ? d.length >= n : !1, [t, d, n]);
|
|
362
|
+
z(() => {
|
|
363
|
+
V && w(d);
|
|
364
|
+
}, [V, d, w]);
|
|
365
|
+
const R = N(
|
|
366
366
|
(I) => {
|
|
367
|
-
|
|
367
|
+
f(y.find((p) => p.label === I) || null);
|
|
368
368
|
},
|
|
369
|
-
[
|
|
369
|
+
[f, y]
|
|
370
370
|
);
|
|
371
|
-
return /* @__PURE__ */
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
-
|
|
371
|
+
return /* @__PURE__ */ M(re, { shouldFilter: !1, children: [
|
|
372
|
+
/* @__PURE__ */ l(G, { placeholder: i, onValueChange: a }),
|
|
373
|
+
/* @__PURE__ */ l(te, { children: /* @__PURE__ */ l(
|
|
374
|
+
ke,
|
|
375
375
|
{
|
|
376
|
-
options:
|
|
377
|
-
loadingState:
|
|
378
|
-
error:
|
|
379
|
-
isSelected:
|
|
380
|
-
searchQuery:
|
|
376
|
+
options: y,
|
|
377
|
+
loadingState: b,
|
|
378
|
+
error: C,
|
|
379
|
+
isSelected: g,
|
|
380
|
+
searchQuery: d,
|
|
381
381
|
loadMode: t,
|
|
382
382
|
minInputLength: n,
|
|
383
|
-
onSelect:
|
|
384
|
-
renderOption:
|
|
383
|
+
onSelect: R,
|
|
384
|
+
renderOption: h,
|
|
385
385
|
loadingText: m,
|
|
386
|
-
errorText:
|
|
387
|
-
inputHintText:
|
|
386
|
+
errorText: c,
|
|
387
|
+
inputHintText: o,
|
|
388
388
|
emptyText: u
|
|
389
389
|
}
|
|
390
|
-
) }, `list-${
|
|
390
|
+
) }, `list-${d}`)
|
|
391
391
|
] });
|
|
392
|
-
},
|
|
393
|
-
const
|
|
392
|
+
}, nr = (e) => {
|
|
393
|
+
const y = e, {
|
|
394
394
|
renderOption: r,
|
|
395
395
|
placeholder: t = "Выберите значение",
|
|
396
396
|
value: n,
|
|
397
397
|
defaultValue: s,
|
|
398
|
-
disabled:
|
|
398
|
+
disabled: i,
|
|
399
399
|
invalid: m,
|
|
400
|
-
onChange:
|
|
401
|
-
} =
|
|
400
|
+
onChange: c
|
|
401
|
+
} = y, o = E(y, [
|
|
402
402
|
"renderOption",
|
|
403
403
|
"placeholder",
|
|
404
404
|
"value",
|
|
@@ -406,39 +406,131 @@ const Ae = ({ loadOptions: e }) => {
|
|
|
406
406
|
"disabled",
|
|
407
407
|
"invalid",
|
|
408
408
|
"onChange"
|
|
409
|
-
]), [u,
|
|
409
|
+
]), [u, h] = O(!1), [f, g] = j({
|
|
410
410
|
value: n,
|
|
411
411
|
defaultValue: s,
|
|
412
|
-
onChange:
|
|
413
|
-
}), v =
|
|
414
|
-
if (
|
|
415
|
-
return r ? r({ option:
|
|
416
|
-
}, [
|
|
417
|
-
(
|
|
418
|
-
|
|
412
|
+
onChange: c
|
|
413
|
+
}), v = D(() => {
|
|
414
|
+
if (f)
|
|
415
|
+
return r ? r({ option: f, type: "trigger" }) : /* @__PURE__ */ l(le, { children: f.label });
|
|
416
|
+
}, [f, r]), a = N(
|
|
417
|
+
(b) => {
|
|
418
|
+
b && g(b), h(!1);
|
|
419
419
|
},
|
|
420
|
-
[
|
|
421
|
-
),
|
|
422
|
-
(
|
|
423
|
-
[
|
|
420
|
+
[g, h]
|
|
421
|
+
), d = N(
|
|
422
|
+
(b) => (f == null ? void 0 : f.value) === b.value,
|
|
423
|
+
[f]
|
|
424
424
|
);
|
|
425
|
-
return /* @__PURE__ */
|
|
426
|
-
/* @__PURE__ */
|
|
427
|
-
/* @__PURE__ */
|
|
425
|
+
return /* @__PURE__ */ M(_, P(L({}, o), { open: u, onOpenChange: h, children: [
|
|
426
|
+
/* @__PURE__ */ l($, { asChild: !0, children: /* @__PURE__ */ l(q, { placeholder: t, disabled: i, invalid: m, open: u, children: v }) }),
|
|
427
|
+
/* @__PURE__ */ l(H, { children: /* @__PURE__ */ l(ce, P(L({}, e), { onSelect: a, isSelected: d })) })
|
|
428
428
|
] }));
|
|
429
|
+
}, qe = F({
|
|
430
|
+
base: ""
|
|
431
|
+
}), He = (e) => {
|
|
432
|
+
const I = e, {
|
|
433
|
+
className: r,
|
|
434
|
+
placeholder: t = "Выберите значение",
|
|
435
|
+
value: n,
|
|
436
|
+
defaultValue: s,
|
|
437
|
+
onChange: i,
|
|
438
|
+
disabled: m,
|
|
439
|
+
invalid: c,
|
|
440
|
+
keepOpenOnSelect: o = !0,
|
|
441
|
+
onLabelClick: u,
|
|
442
|
+
renderOption: h
|
|
443
|
+
} = I, f = E(I, [
|
|
444
|
+
"className",
|
|
445
|
+
"placeholder",
|
|
446
|
+
"value",
|
|
447
|
+
"defaultValue",
|
|
448
|
+
"onChange",
|
|
449
|
+
"disabled",
|
|
450
|
+
"invalid",
|
|
451
|
+
"keepOpenOnSelect",
|
|
452
|
+
"onLabelClick",
|
|
453
|
+
"renderOption"
|
|
454
|
+
]), [g, v] = O(!1), [a, d] = j({
|
|
455
|
+
value: n,
|
|
456
|
+
defaultValue: s,
|
|
457
|
+
onChange: i
|
|
458
|
+
}), y = N(
|
|
459
|
+
(p) => {
|
|
460
|
+
if (p) {
|
|
461
|
+
const T = a == null ? void 0 : a.find((S) => S.value === p.value);
|
|
462
|
+
d(T ? (S) => (S == null ? void 0 : S.filter((Q) => Q.value !== p.value)) || [] : (S) => [...S || [], p]);
|
|
463
|
+
}
|
|
464
|
+
o || v(!1);
|
|
465
|
+
},
|
|
466
|
+
[a, o, d, v]
|
|
467
|
+
), b = N(
|
|
468
|
+
(p) => {
|
|
469
|
+
(a == null ? void 0 : a.find((S) => S.value === p.value)) && d((S) => (S == null ? void 0 : S.filter((Q) => Q.value !== p.value)) || []);
|
|
470
|
+
},
|
|
471
|
+
[a, d]
|
|
472
|
+
), C = N(
|
|
473
|
+
(p) => {
|
|
474
|
+
var T;
|
|
475
|
+
return (T = a == null ? void 0 : a.some((S) => S.value === p.value)) != null ? T : !1;
|
|
476
|
+
},
|
|
477
|
+
[a]
|
|
478
|
+
), { handleKeyDown: w, isFocused: V } = me({
|
|
479
|
+
items: a || [],
|
|
480
|
+
onEnter: u,
|
|
481
|
+
onDelete: b
|
|
482
|
+
}), R = D(() => {
|
|
483
|
+
if (!(!a || a.length === 0))
|
|
484
|
+
return h ? a.map((p) => h({
|
|
485
|
+
option: p,
|
|
486
|
+
type: "trigger",
|
|
487
|
+
onClose: () => {
|
|
488
|
+
b(p);
|
|
489
|
+
}
|
|
490
|
+
})) : a.map((p, T) => /* @__PURE__ */ l(
|
|
491
|
+
pe,
|
|
492
|
+
{
|
|
493
|
+
onLabelClick: (S) => {
|
|
494
|
+
S.preventDefault(), u == null || u(p);
|
|
495
|
+
},
|
|
496
|
+
onClose: (S) => {
|
|
497
|
+
S.preventDefault(), b(p);
|
|
498
|
+
},
|
|
499
|
+
isFocused: V(T),
|
|
500
|
+
children: p.label
|
|
501
|
+
},
|
|
502
|
+
p.value
|
|
503
|
+
));
|
|
504
|
+
}, [a, h, b, u, V]);
|
|
505
|
+
return /* @__PURE__ */ l("div", { className: qe({ className: r }), children: /* @__PURE__ */ M(_, P(L({ open: g, onOpenChange: v }, f), { children: [
|
|
506
|
+
/* @__PURE__ */ l($, { asChild: !0, children: /* @__PURE__ */ l(
|
|
507
|
+
q,
|
|
508
|
+
{
|
|
509
|
+
onKeyDown: w,
|
|
510
|
+
disabled: m,
|
|
511
|
+
open: g,
|
|
512
|
+
placeholder: t,
|
|
513
|
+
invalid: c,
|
|
514
|
+
children: R && /* @__PURE__ */ l("div", { className: "flex flex-wrap gap-1.5 lg:gap-1", children: R })
|
|
515
|
+
}
|
|
516
|
+
) }),
|
|
517
|
+
/* @__PURE__ */ l(H, { children: /* @__PURE__ */ l(ce, P(L({}, e), { onSelect: y, isSelected: C })) })
|
|
518
|
+
] })) });
|
|
429
519
|
};
|
|
520
|
+
He.displayName = "MultiSelect";
|
|
430
521
|
export {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
522
|
+
nr as AsyncSearchSelect,
|
|
523
|
+
ke as AsyncSearchSelectContent,
|
|
524
|
+
Ae as LazySearchSelect,
|
|
434
525
|
se as LoadMoreTrigger,
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
526
|
+
He as MultiSelect,
|
|
527
|
+
Ve as SearchSelect,
|
|
528
|
+
H as SearchSelectContent,
|
|
529
|
+
G as SearchSelectInput,
|
|
438
530
|
Qe as SearchSelectSeparator,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
531
|
+
q as SearchSelectTrigger,
|
|
532
|
+
Fe as defaultFuzzyFilter,
|
|
533
|
+
ze as useAsyncDataLoader,
|
|
534
|
+
we as useSearchSelect
|
|
443
535
|
};
|
|
444
536
|
//# sourceMappingURL=search-select.js.map
|