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