mimir-ui-kit 1.54.2 → 1.54.4
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { forwardRef as tt, useId as nt, useRef as L, useState as
|
|
4
|
-
import { EMultiSelectSearchSize as
|
|
5
|
-
import { useChips as
|
|
1
|
+
import { jsxs as v, jsx as c, Fragment as se } from "react/jsx-runtime";
|
|
2
|
+
import { c as C } from "../../index-DIxK0V-G.js";
|
|
3
|
+
import { forwardRef as tt, useId as nt, useRef as L, useState as at, useEffect as ie } from "react";
|
|
4
|
+
import { EMultiSelectSearchSize as re, ELoadingIndicatorPlacement as D } from "./constants.js";
|
|
5
|
+
import { useChips as ot } from "./hooks/useChips.js";
|
|
6
6
|
import { useDataLoading as st } from "./hooks/useDataLoading.js";
|
|
7
7
|
import { useEventHandling as it } from "./hooks/useEventHandling.js";
|
|
8
8
|
import { useMenuPlacement as rt } from "./hooks/useMenuPlacement.js";
|
|
@@ -11,198 +11,196 @@ import { u as ct, c as t } from "../../useNestedSelection-bo9wXvE-.js";
|
|
|
11
11
|
import { useRenderVirtualizedList as dt } from "./hooks/useRenderVirtualizedList.js";
|
|
12
12
|
import { useSearch as ut } from "./hooks/useSearch.js";
|
|
13
13
|
import { useVirtualization as mt } from "./hooks/useVirtualization.js";
|
|
14
|
-
import { normalizeDataForNestedSelection as pt, flattenOptions as ft, updateInputValueAfterChange as
|
|
14
|
+
import { normalizeDataForNestedSelection as pt, flattenOptions as ft, updateInputValueAfterChange as le, getInitialInputValue as ht, mapSizeToInputSize as ce, getDropdownArrowIcon as gt, processNestedSelectionChange as de, flattenSelectedItems as It, dispatchMultiselectOpen as R, highlightReactNode as St } from "./utils.js";
|
|
15
15
|
import { Icon as Nt } from "../../icons/Icon.js";
|
|
16
16
|
import { Button as zt } from "../Button/Button.js";
|
|
17
|
-
import { I as
|
|
17
|
+
import { I as ue } from "../../Input-DgWOCNwP.js";
|
|
18
18
|
import { EInputVariant as wt } from "../Input/constants.js";
|
|
19
|
-
import { Loader as
|
|
20
|
-
import { H as vt, U as
|
|
21
|
-
const
|
|
22
|
-
(
|
|
19
|
+
import { Loader as me } from "../Loader/Loader.js";
|
|
20
|
+
import { H as vt, U as pe, G as fe } from "../../combobox-fIVOzEhl.js";
|
|
21
|
+
const jt = tt(
|
|
22
|
+
(he, ge) => {
|
|
23
23
|
const {
|
|
24
|
-
placeholder:
|
|
25
|
-
size:
|
|
26
|
-
value:
|
|
24
|
+
placeholder: Q,
|
|
25
|
+
size: d = re.L,
|
|
26
|
+
value: I,
|
|
27
27
|
onChange: s,
|
|
28
|
-
full:
|
|
29
|
-
showArrow:
|
|
28
|
+
full: Ie,
|
|
29
|
+
showArrow: Se = !0,
|
|
30
30
|
items: i = [],
|
|
31
31
|
classNameOption: j,
|
|
32
|
-
displayValue:
|
|
33
|
-
filterOnSearch:
|
|
32
|
+
displayValue: p = "name",
|
|
33
|
+
filterOnSearch: Ne = !0,
|
|
34
34
|
onSearch: B,
|
|
35
35
|
variant: J = wt.DefaultGray,
|
|
36
|
-
menuPlacement:
|
|
37
|
-
disabled:
|
|
38
|
-
searchProps:
|
|
36
|
+
menuPlacement: ze = "bottom",
|
|
37
|
+
disabled: u = !1,
|
|
38
|
+
searchProps: U,
|
|
39
39
|
withClearButton: P = !1,
|
|
40
|
-
withChip:
|
|
41
|
-
chipVariant:
|
|
40
|
+
withChip: we = !1,
|
|
41
|
+
chipVariant: ve = "sapphire",
|
|
42
42
|
disableInput: b = !1,
|
|
43
|
-
autocomplete:
|
|
44
|
-
id:
|
|
45
|
-
autoPlacement:
|
|
43
|
+
autocomplete: $ = "on",
|
|
44
|
+
id: Ce,
|
|
45
|
+
autoPlacement: be = !1,
|
|
46
46
|
onIsOpen: M,
|
|
47
|
-
noOptionsText:
|
|
48
|
-
noMatchText:
|
|
49
|
-
loadOnOpen:
|
|
50
|
-
loading:
|
|
47
|
+
noOptionsText: ye = "Нет данных",
|
|
48
|
+
noMatchText: Oe = "Ничего не найдено",
|
|
49
|
+
loadOnOpen: De,
|
|
50
|
+
loading: Me,
|
|
51
51
|
loadingIndicatorPlacement: x = D.Both,
|
|
52
|
-
groupBy:
|
|
53
|
-
getGroupTitle:
|
|
52
|
+
groupBy: S,
|
|
53
|
+
getGroupTitle: xe = (e) => e,
|
|
54
54
|
highlightMatches: k = !1,
|
|
55
55
|
enableNestedSelection: n = !1,
|
|
56
|
-
searchInNestedItems:
|
|
57
|
-
useIconInsteadOfCheckbox:
|
|
56
|
+
searchInNestedItems: W = !1,
|
|
57
|
+
useIconInsteadOfCheckbox: K = !1,
|
|
58
58
|
searchInHeaderGroupItems: A = !1
|
|
59
|
-
} =
|
|
60
|
-
isOpen:
|
|
59
|
+
} = he, Ve = nt(), y = Ce || `multiselect-${Ve}`, V = L(null), N = L(null), Te = L(!1), X = L(null), [a, Y] = at(null), Le = lt({ value: I, displayValue: p }), {
|
|
60
|
+
isOpen: f,
|
|
61
61
|
setIsOpen: O,
|
|
62
|
-
inputValue:
|
|
63
|
-
setInputValue:
|
|
64
|
-
selectedItems:
|
|
62
|
+
inputValue: E,
|
|
63
|
+
setInputValue: z,
|
|
64
|
+
selectedItems: m,
|
|
65
65
|
setSelectedItems: g,
|
|
66
|
-
expandedOptions:
|
|
67
|
-
setExpandedOptions:
|
|
68
|
-
internalSearchQuery:
|
|
69
|
-
setInternalSearchQuery:
|
|
70
|
-
} =
|
|
71
|
-
autoPlacement:
|
|
72
|
-
menuPlacement:
|
|
73
|
-
size:
|
|
74
|
-
selectSearchRef:
|
|
75
|
-
isOpen:
|
|
76
|
-
}), { actualMenuPlacement:
|
|
77
|
-
filterOnSearch:
|
|
78
|
-
items: n &&
|
|
79
|
-
internalSearchQuery:
|
|
80
|
-
selectedItems:
|
|
66
|
+
expandedOptions: Re,
|
|
67
|
+
setExpandedOptions: Be,
|
|
68
|
+
internalSearchQuery: w,
|
|
69
|
+
setInternalSearchQuery: F
|
|
70
|
+
} = Le, Pe = rt({
|
|
71
|
+
autoPlacement: be,
|
|
72
|
+
menuPlacement: ze,
|
|
73
|
+
size: d,
|
|
74
|
+
selectSearchRef: V,
|
|
75
|
+
isOpen: f
|
|
76
|
+
}), { actualMenuPlacement: ke, isVisible: Ae, isMenuReady: Ee, updateMenuPlacement: Z } = Pe, Fe = st({ loadOnOpen: De, loading: Me }), { isLoading: _, handleDataLoading: q } = Fe, qe = ut({
|
|
77
|
+
filterOnSearch: Ne,
|
|
78
|
+
items: n && a ? a.normalizedItems : i,
|
|
79
|
+
internalSearchQuery: w,
|
|
80
|
+
selectedItems: m,
|
|
81
81
|
enableNestedSelection: n,
|
|
82
|
-
searchInNestedItems:
|
|
83
|
-
displayValue:
|
|
84
|
-
groupBy:
|
|
82
|
+
searchInNestedItems: W,
|
|
83
|
+
displayValue: p,
|
|
84
|
+
groupBy: S,
|
|
85
85
|
searchInHeaderGroupItems: A
|
|
86
|
-
}), { filteredItems:
|
|
87
|
-
filteredItems:
|
|
88
|
-
groupBy:
|
|
89
|
-
getGroupTitle:
|
|
90
|
-
size:
|
|
91
|
-
parentRef:
|
|
92
|
-
}), { virtualItems:
|
|
93
|
-
|
|
86
|
+
}), { filteredItems: T } = qe, Ge = mt({
|
|
87
|
+
filteredItems: T,
|
|
88
|
+
groupBy: S,
|
|
89
|
+
getGroupTitle: xe,
|
|
90
|
+
size: d,
|
|
91
|
+
parentRef: X
|
|
92
|
+
}), { virtualItems: He, virtualizer: Qe } = Ge;
|
|
93
|
+
ie(() => {
|
|
94
94
|
if (n && i.length > 0) {
|
|
95
95
|
const e = pt(i);
|
|
96
|
-
|
|
96
|
+
Y(e);
|
|
97
97
|
} else
|
|
98
|
-
|
|
99
|
-
}, [i, n]),
|
|
100
|
-
if (
|
|
101
|
-
let e =
|
|
102
|
-
n &&
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const a = n ? ce(
|
|
98
|
+
Y(null);
|
|
99
|
+
}, [i, n]), ie(() => {
|
|
100
|
+
if (I) {
|
|
101
|
+
let e = I;
|
|
102
|
+
n && a && (e = I.map((r) => ft(
|
|
103
|
+
a.normalizedItems
|
|
104
|
+
).find(
|
|
105
|
+
(l) => l.id === r.id || l.originalId === (r.originalId || r.id) && l.name === r.name
|
|
106
|
+
)).filter(Boolean)), g(e);
|
|
107
|
+
const o = n ? le(
|
|
109
108
|
e,
|
|
110
109
|
n,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
) : ht(e,
|
|
114
|
-
|
|
115
|
-
} else
|
|
116
|
-
|
|
117
|
-
}, [C, f, n, o, i]);
|
|
110
|
+
a ? a.normalizedItems : i,
|
|
111
|
+
p
|
|
112
|
+
) : ht(e, p);
|
|
113
|
+
z(o);
|
|
114
|
+
} else I === null && (g([]), z(""));
|
|
115
|
+
}, [I, p, n, a, i]);
|
|
118
116
|
const je = (e) => {
|
|
119
|
-
let
|
|
120
|
-
if (n &&
|
|
121
|
-
const { normalizedItems:
|
|
122
|
-
|
|
117
|
+
let o = e;
|
|
118
|
+
if (n && a) {
|
|
119
|
+
const { normalizedItems: l } = a;
|
|
120
|
+
o = de(
|
|
123
121
|
e,
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
m,
|
|
123
|
+
l
|
|
126
124
|
);
|
|
127
|
-
} else n && (
|
|
125
|
+
} else n && (o = de(
|
|
128
126
|
e,
|
|
129
|
-
|
|
127
|
+
m,
|
|
130
128
|
i
|
|
131
129
|
));
|
|
132
130
|
const r = It(
|
|
133
|
-
|
|
134
|
-
n &&
|
|
131
|
+
o,
|
|
132
|
+
n && a ? a.normalizedItems : i
|
|
135
133
|
);
|
|
136
|
-
g(
|
|
137
|
-
const
|
|
134
|
+
g(o), s == null || s(r);
|
|
135
|
+
const h = le(
|
|
138
136
|
r,
|
|
139
137
|
n,
|
|
140
|
-
n &&
|
|
141
|
-
|
|
138
|
+
n && a ? a.normalizedItems : i,
|
|
139
|
+
p
|
|
142
140
|
);
|
|
143
|
-
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
141
|
+
z(h), F(""), O(!0), R(y), setTimeout(() => {
|
|
142
|
+
if (N.current) {
|
|
143
|
+
N.current.focus(), N.current.scrollLeft = N.current.scrollWidth;
|
|
144
|
+
const l = h.length;
|
|
145
|
+
N.current.setSelectionRange(l, l);
|
|
148
146
|
}
|
|
149
147
|
}, 0);
|
|
150
|
-
},
|
|
151
|
-
var
|
|
148
|
+
}, ee = async (e) => {
|
|
149
|
+
var h, l;
|
|
152
150
|
if (b) return;
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
151
|
+
const o = e.target.value;
|
|
152
|
+
if (z(o), F(((h = o.split(",").pop()) == null ? void 0 : h.trim()) || ""), B == null || B(o), n)
|
|
153
|
+
o === "" && m.length > 0 && (g([]), s == null || s([]));
|
|
156
154
|
else {
|
|
157
|
-
const
|
|
158
|
-
(
|
|
155
|
+
const et = o.split(",").map((H) => H.trim()).filter(Boolean), G = i.filter(
|
|
156
|
+
(H) => et.includes(H[p])
|
|
159
157
|
);
|
|
160
|
-
JSON.stringify(
|
|
158
|
+
JSON.stringify(G) !== JSON.stringify(m) && (g(G), s == null || s(G));
|
|
161
159
|
}
|
|
162
|
-
|
|
163
|
-
const r = (
|
|
160
|
+
f || (O(!0), R(y), await q());
|
|
161
|
+
const r = (l = V.current) == null ? void 0 : l.querySelector(
|
|
164
162
|
`.${t.options}`
|
|
165
163
|
);
|
|
166
164
|
r && typeof r.scrollTo == "function" && r.scrollTo({ top: 0, behavior: "smooth" });
|
|
167
165
|
}, Je = (e) => {
|
|
168
166
|
e.preventDefault(), e.currentTarget.focus();
|
|
169
|
-
const
|
|
170
|
-
e.currentTarget.setSelectionRange(
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
e.stopPropagation(),
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
},
|
|
167
|
+
const o = e.currentTarget.value.length;
|
|
168
|
+
e.currentTarget.setSelectionRange(o, o);
|
|
169
|
+
}, Ue = () => {
|
|
170
|
+
z(""), F(""), g([]), s == null || s([]);
|
|
171
|
+
}, $e = (e) => {
|
|
172
|
+
e.stopPropagation(), Ue();
|
|
173
|
+
}, te = async () => {
|
|
174
|
+
Z(), O(!0), R(y), await q();
|
|
175
|
+
}, We = async (e) => {
|
|
178
176
|
if (b) {
|
|
179
177
|
e.target.blur();
|
|
180
178
|
return;
|
|
181
179
|
}
|
|
182
|
-
await
|
|
183
|
-
},
|
|
184
|
-
const e = !
|
|
185
|
-
e && (
|
|
186
|
-
},
|
|
187
|
-
if (
|
|
180
|
+
await te();
|
|
181
|
+
}, ne = async () => {
|
|
182
|
+
const e = !f;
|
|
183
|
+
e && (Z(), R(y), await q()), O(e), M == null || M(e);
|
|
184
|
+
}, Ke = () => {
|
|
185
|
+
if (Se)
|
|
188
186
|
return {
|
|
189
187
|
addonType: "react-node",
|
|
190
|
-
addonContent: /* @__PURE__ */
|
|
191
|
-
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
188
|
+
addonContent: /* @__PURE__ */ v(se, { children: [
|
|
189
|
+
_ && (x === D.Input || x === D.Both) && /* @__PURE__ */ c(me, { size: "s" }),
|
|
190
|
+
/* @__PURE__ */ c(
|
|
191
|
+
pe,
|
|
194
192
|
{
|
|
195
|
-
className:
|
|
196
|
-
[t.disabled]:
|
|
193
|
+
className: C(t.button, {
|
|
194
|
+
[t.disabled]: u
|
|
197
195
|
}),
|
|
198
|
-
disabled:
|
|
199
|
-
onMouseDown:
|
|
200
|
-
children: /* @__PURE__ */
|
|
196
|
+
disabled: u,
|
|
197
|
+
onMouseDown: ne,
|
|
198
|
+
children: /* @__PURE__ */ c(
|
|
201
199
|
Nt,
|
|
202
200
|
{
|
|
203
|
-
iconName:
|
|
204
|
-
className:
|
|
205
|
-
[t["selector-icon-open"]]:
|
|
201
|
+
iconName: d == re.M ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
|
|
202
|
+
className: C(t["selector-icon"], {
|
|
203
|
+
[t["selector-icon-open"]]: f
|
|
206
204
|
})
|
|
207
205
|
}
|
|
208
206
|
)
|
|
@@ -210,189 +208,189 @@ const Ut = tt(
|
|
|
210
208
|
)
|
|
211
209
|
] })
|
|
212
210
|
};
|
|
213
|
-
},
|
|
214
|
-
/* @__PURE__ */
|
|
211
|
+
}, Xe = () => _ && (x === D.Dropdown || x === D.Both) ? /* @__PURE__ */ v("div", { className: t.loader, children: [
|
|
212
|
+
/* @__PURE__ */ c(me, { size: "s" }),
|
|
215
213
|
"Загрузка..."
|
|
216
|
-
] }) :
|
|
217
|
-
let
|
|
218
|
-
const r = e.bottom && /* @__PURE__ */
|
|
219
|
-
if (k &&
|
|
220
|
-
const
|
|
221
|
-
(typeof e.name == "string" ? e.name : String(e.name || "")).toLowerCase().includes(
|
|
214
|
+
] }) : ye, ae = (e) => {
|
|
215
|
+
let o = e.name;
|
|
216
|
+
const r = e.bottom && /* @__PURE__ */ c("div", { children: e.bottom });
|
|
217
|
+
if (k && w && !(S && A)) {
|
|
218
|
+
const h = w.toLowerCase();
|
|
219
|
+
(typeof e.name == "string" ? e.name : String(e.name || "")).toLowerCase().includes(h) && (o = St(
|
|
222
220
|
e.name,
|
|
223
|
-
|
|
221
|
+
w,
|
|
224
222
|
t["highlighted-text"]
|
|
225
223
|
));
|
|
226
224
|
}
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
|
|
225
|
+
return /* @__PURE__ */ v(se, { children: [
|
|
226
|
+
o,
|
|
229
227
|
r
|
|
230
228
|
] });
|
|
231
|
-
},
|
|
232
|
-
filteredItems:
|
|
233
|
-
selectedItems:
|
|
234
|
-
expandedOptions:
|
|
235
|
-
setExpandedOptions:
|
|
236
|
-
size:
|
|
229
|
+
}, Ye = ct({
|
|
230
|
+
filteredItems: T,
|
|
231
|
+
selectedItems: m,
|
|
232
|
+
expandedOptions: Re,
|
|
233
|
+
setExpandedOptions: Be,
|
|
234
|
+
size: d,
|
|
237
235
|
classNameOption: j,
|
|
238
|
-
items: n &&
|
|
236
|
+
items: n && a ? a.normalizedItems : i,
|
|
239
237
|
enableNestedSelection: n,
|
|
240
|
-
searchInNestedItems:
|
|
241
|
-
internalSearchQuery:
|
|
238
|
+
searchInNestedItems: W,
|
|
239
|
+
internalSearchQuery: w,
|
|
242
240
|
renderOptionContent: ae,
|
|
243
|
-
groupBy:
|
|
244
|
-
useIconInsteadOfCheckbox:
|
|
241
|
+
groupBy: S,
|
|
242
|
+
useIconInsteadOfCheckbox: K,
|
|
245
243
|
highlightMatches: k
|
|
246
|
-
}), { renderNestedOptions:
|
|
247
|
-
selectedItems:
|
|
244
|
+
}), { renderNestedOptions: Ze } = Ye, oe = ot({
|
|
245
|
+
selectedItems: m,
|
|
248
246
|
enableNestedSelection: n,
|
|
249
|
-
size:
|
|
250
|
-
chipVariant:
|
|
251
|
-
items: n &&
|
|
252
|
-
displayValue:
|
|
247
|
+
size: d,
|
|
248
|
+
chipVariant: ve,
|
|
249
|
+
items: n && a ? a.normalizedItems : i,
|
|
250
|
+
displayValue: p,
|
|
253
251
|
setSelectedItems: g,
|
|
254
252
|
onChange: s,
|
|
255
|
-
setInputValue:
|
|
253
|
+
setInputValue: z
|
|
256
254
|
});
|
|
257
255
|
it({
|
|
258
|
-
isOpen:
|
|
256
|
+
isOpen: f,
|
|
259
257
|
setIsOpen: O,
|
|
260
258
|
onIsOpen: M,
|
|
261
259
|
id: y,
|
|
262
|
-
selectSearchRef:
|
|
263
|
-
isHandlingRef:
|
|
260
|
+
selectSearchRef: V,
|
|
261
|
+
isHandlingRef: Te
|
|
264
262
|
});
|
|
265
|
-
const
|
|
266
|
-
items: n &&
|
|
267
|
-
filteredItems:
|
|
268
|
-
size:
|
|
269
|
-
actualMenuPlacement:
|
|
270
|
-
isVisible:
|
|
271
|
-
noOptionsText:
|
|
272
|
-
noMatchText:
|
|
263
|
+
const _e = dt({
|
|
264
|
+
items: n && a ? a.normalizedItems : i,
|
|
265
|
+
filteredItems: T,
|
|
266
|
+
size: d,
|
|
267
|
+
actualMenuPlacement: ke,
|
|
268
|
+
isVisible: Ae,
|
|
269
|
+
noOptionsText: Xe(),
|
|
270
|
+
noMatchText: Oe,
|
|
273
271
|
enableNestedSelection: n,
|
|
274
|
-
renderNestedOptions:
|
|
275
|
-
groupBy:
|
|
276
|
-
parentRef:
|
|
277
|
-
virtualItems:
|
|
278
|
-
virtualizer:
|
|
272
|
+
renderNestedOptions: Ze,
|
|
273
|
+
groupBy: S,
|
|
274
|
+
parentRef: X,
|
|
275
|
+
virtualItems: He,
|
|
276
|
+
virtualizer: Qe,
|
|
279
277
|
classNameOption: j,
|
|
280
|
-
selectedItems:
|
|
278
|
+
selectedItems: m,
|
|
281
279
|
renderOptionContent: ae,
|
|
282
280
|
cls: t,
|
|
283
|
-
useIconInsteadOfCheckbox:
|
|
281
|
+
useIconInsteadOfCheckbox: K,
|
|
284
282
|
highlightMatches: k,
|
|
285
|
-
internalSearchQuery:
|
|
283
|
+
internalSearchQuery: w,
|
|
286
284
|
searchInHeaderGroupItems: A
|
|
287
285
|
});
|
|
288
|
-
return /* @__PURE__ */
|
|
289
|
-
/* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ v("div", { ref: V, children: [
|
|
287
|
+
/* @__PURE__ */ c(
|
|
290
288
|
vt,
|
|
291
289
|
{
|
|
292
290
|
multiple: !0,
|
|
293
291
|
as: "div",
|
|
294
|
-
value:
|
|
295
|
-
className:
|
|
296
|
-
[t.full]:
|
|
297
|
-
[t.disabled]:
|
|
292
|
+
value: m,
|
|
293
|
+
className: C(t["multi-select-search"], {
|
|
294
|
+
[t.full]: Ie,
|
|
295
|
+
[t.disabled]: u
|
|
298
296
|
}),
|
|
299
297
|
onChange: je,
|
|
300
|
-
ref:
|
|
301
|
-
disabled:
|
|
302
|
-
virtual:
|
|
303
|
-
children: /* @__PURE__ */
|
|
298
|
+
ref: ge,
|
|
299
|
+
disabled: u,
|
|
300
|
+
virtual: S ? void 0 : { options: T },
|
|
301
|
+
children: /* @__PURE__ */ v(
|
|
304
302
|
"div",
|
|
305
303
|
{
|
|
306
|
-
className:
|
|
307
|
-
[t["container-open"]]:
|
|
304
|
+
className: C(t.container, t[d], {
|
|
305
|
+
[t["container-open"]]: f
|
|
308
306
|
}),
|
|
309
307
|
children: [
|
|
310
|
-
b && /* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
308
|
+
b && /* @__PURE__ */ v("div", { className: t["input-container"], children: [
|
|
309
|
+
/* @__PURE__ */ c(
|
|
310
|
+
pe,
|
|
313
311
|
{
|
|
314
|
-
disabled:
|
|
312
|
+
disabled: u,
|
|
315
313
|
style: { width: "100%" },
|
|
316
|
-
onClick:
|
|
317
|
-
children: /* @__PURE__ */
|
|
318
|
-
|
|
314
|
+
onClick: ne,
|
|
315
|
+
children: /* @__PURE__ */ c(
|
|
316
|
+
fe,
|
|
319
317
|
{
|
|
320
|
-
as:
|
|
321
|
-
label:
|
|
322
|
-
size:
|
|
323
|
-
className:
|
|
318
|
+
as: ue,
|
|
319
|
+
label: Q,
|
|
320
|
+
size: ce(d),
|
|
321
|
+
className: C(t["multi-select-input"], {
|
|
324
322
|
[t["multi-select-input-disabled"]]: b && P
|
|
325
323
|
}),
|
|
326
|
-
onChange:
|
|
327
|
-
value:
|
|
328
|
-
disabled:
|
|
324
|
+
onChange: ee,
|
|
325
|
+
value: E,
|
|
326
|
+
disabled: u,
|
|
329
327
|
variant: J,
|
|
330
328
|
rightSlotClassName: t["right-slot"],
|
|
331
329
|
requiredMarkClassName: t["required-mark"],
|
|
332
330
|
"data-testid": "select-search-input",
|
|
333
|
-
onFocus:
|
|
331
|
+
onFocus: We,
|
|
334
332
|
rightAddon: {
|
|
335
333
|
addonType: "icon",
|
|
336
|
-
addonContent: gt(
|
|
334
|
+
addonContent: gt(f, d)
|
|
337
335
|
},
|
|
338
|
-
autocomplete:
|
|
339
|
-
|
|
336
|
+
autocomplete: $,
|
|
337
|
+
...U
|
|
340
338
|
}
|
|
341
339
|
)
|
|
342
340
|
}
|
|
343
341
|
),
|
|
344
|
-
P &&
|
|
342
|
+
P && E && /* @__PURE__ */ c(
|
|
345
343
|
zt,
|
|
346
344
|
{
|
|
347
345
|
tabIndex: -1,
|
|
348
|
-
className:
|
|
349
|
-
[t.disabled]:
|
|
346
|
+
className: C(t.clear, {
|
|
347
|
+
[t.disabled]: u
|
|
350
348
|
}),
|
|
351
349
|
iconButtonClassName: t["icon-button"],
|
|
352
350
|
isIconButton: !0,
|
|
353
351
|
iconName: "Close16px",
|
|
354
352
|
size: "m-s",
|
|
355
353
|
clear: !0,
|
|
356
|
-
disabled:
|
|
354
|
+
disabled: u,
|
|
357
355
|
variant: "secondary-gray",
|
|
358
|
-
onClick:
|
|
356
|
+
onClick: $e,
|
|
359
357
|
"data-testid": "clear-button"
|
|
360
358
|
}
|
|
361
359
|
)
|
|
362
360
|
] }),
|
|
363
|
-
!b && /* @__PURE__ */
|
|
364
|
-
|
|
361
|
+
!b && /* @__PURE__ */ c(
|
|
362
|
+
fe,
|
|
365
363
|
{
|
|
366
|
-
as:
|
|
367
|
-
label:
|
|
368
|
-
size:
|
|
364
|
+
as: ue,
|
|
365
|
+
label: Q,
|
|
366
|
+
size: ce(d),
|
|
369
367
|
className: t["multi-select-input"],
|
|
370
368
|
rightSlotClassName: t["right-slot"],
|
|
371
369
|
requiredMarkClassName: t["required-mark"],
|
|
372
|
-
value:
|
|
373
|
-
disabled:
|
|
370
|
+
value: E,
|
|
371
|
+
disabled: u,
|
|
374
372
|
variant: J,
|
|
375
373
|
withClearButton: P,
|
|
376
|
-
onFocus:
|
|
374
|
+
onFocus: te,
|
|
377
375
|
onMouseDown: Je,
|
|
378
|
-
onChange:
|
|
379
|
-
ref:
|
|
380
|
-
rightAddon:
|
|
376
|
+
onChange: ee,
|
|
377
|
+
ref: N,
|
|
378
|
+
rightAddon: Ke(),
|
|
381
379
|
"data-testid": "select-search-input",
|
|
382
|
-
autocomplete:
|
|
383
|
-
|
|
380
|
+
autocomplete: $,
|
|
381
|
+
...U
|
|
384
382
|
}
|
|
385
383
|
),
|
|
386
|
-
|
|
384
|
+
f && Ee && _e()
|
|
387
385
|
]
|
|
388
386
|
}
|
|
389
387
|
)
|
|
390
388
|
}
|
|
391
389
|
),
|
|
392
|
-
|
|
390
|
+
we && oe && /* @__PURE__ */ c("div", { className: t["chip-container"], children: oe })
|
|
393
391
|
] });
|
|
394
392
|
}
|
|
395
393
|
);
|
|
396
394
|
export {
|
|
397
|
-
|
|
395
|
+
jt as MultiSelectSearch
|
|
398
396
|
};
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { createElement as
|
|
2
|
-
import { EMultiSelectSearchSize as
|
|
1
|
+
import { createElement as g, Fragment as S, isValidElement as w, cloneElement as E } from "react";
|
|
2
|
+
import { EMultiSelectSearchSize as a, MOBILE_MENU_HEIGHT as M, DESKTOP_MENU_HEIGHT as T } from "./constants.js";
|
|
3
3
|
import "../../Input-DgWOCNwP.js";
|
|
4
|
-
import { EInputSize as
|
|
5
|
-
const j = (
|
|
6
|
-
switch (
|
|
7
|
-
case
|
|
8
|
-
return
|
|
9
|
-
case
|
|
10
|
-
return
|
|
4
|
+
import { EInputSize as f } from "../Input/constants.js";
|
|
5
|
+
const j = (n) => {
|
|
6
|
+
switch (n) {
|
|
7
|
+
case a.M:
|
|
8
|
+
return f.M;
|
|
9
|
+
case a.L:
|
|
10
|
+
return f.L;
|
|
11
11
|
default:
|
|
12
|
-
return
|
|
12
|
+
return f.M;
|
|
13
13
|
}
|
|
14
|
-
}, _ = (
|
|
15
|
-
window.dispatchEvent(new CustomEvent(C, { detail:
|
|
16
|
-
}, G = (
|
|
17
|
-
if (!
|
|
18
|
-
const r =
|
|
14
|
+
}, _ = (n, t) => n ? t === a.L ? "DropdownArrowUp24px" : "DropdownArrowUp16px" : t === a.L ? "DropdownArrowDown24px" : "DropdownArrowBottom16px", b = (n, t) => n && n.length > 0 ? n.map((r) => r[t]).join(", ") : "", A = (n, t) => n.map((r) => r[t]).join(", "), C = "multiselectOpen", y = (n) => {
|
|
15
|
+
window.dispatchEvent(new CustomEvent(C, { detail: n }));
|
|
16
|
+
}, G = (n, t) => {
|
|
17
|
+
if (!n.current) return !1;
|
|
18
|
+
const r = n.current.getBoundingClientRect(), e = window.innerHeight, i = t === a.M ? M : T, s = e - r.bottom, o = r.top;
|
|
19
19
|
return s >= i ? !1 : o > s;
|
|
20
|
-
},
|
|
21
|
-
if (!
|
|
22
|
-
const
|
|
23
|
-
for (const s of
|
|
20
|
+
}, k = (n, t, r) => {
|
|
21
|
+
if (!n.length || !t) return n;
|
|
22
|
+
const e = [], i = /* @__PURE__ */ new Set();
|
|
23
|
+
for (const s of n) {
|
|
24
24
|
const o = String(s[t] || "Без группы");
|
|
25
|
-
i.has(o) || (i.add(o),
|
|
25
|
+
i.has(o) || (i.add(o), e.push({
|
|
26
26
|
id: `group-header-${o}`,
|
|
27
27
|
name: r(o),
|
|
28
28
|
isGroupHeader: !0,
|
|
29
29
|
originalValue: o
|
|
30
|
-
})),
|
|
30
|
+
})), e.push(s);
|
|
31
31
|
}
|
|
32
|
-
return
|
|
33
|
-
},
|
|
32
|
+
return e;
|
|
33
|
+
}, m = (n, t, r) => {
|
|
34
34
|
if (!t.trim())
|
|
35
|
-
return
|
|
36
|
-
if (typeof
|
|
37
|
-
const
|
|
38
|
-
|
|
35
|
+
return n;
|
|
36
|
+
if (typeof n == "string") {
|
|
37
|
+
const e = O(
|
|
38
|
+
n,
|
|
39
39
|
t,
|
|
40
40
|
r
|
|
41
41
|
);
|
|
42
|
-
return
|
|
42
|
+
return g(
|
|
43
43
|
"span",
|
|
44
44
|
{ className: "highlighted-text-wrapper" },
|
|
45
|
-
|
|
45
|
+
e
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
|
-
return Array.isArray(
|
|
49
|
-
(
|
|
48
|
+
return Array.isArray(n) ? n.map(
|
|
49
|
+
(e, i) => g(
|
|
50
50
|
S,
|
|
51
51
|
{ key: i },
|
|
52
|
-
|
|
52
|
+
m(e, t, r)
|
|
53
53
|
)
|
|
54
|
-
) : w(
|
|
55
|
-
...
|
|
56
|
-
children:
|
|
57
|
-
|
|
54
|
+
) : w(n) ? E(n, {
|
|
55
|
+
...n.props,
|
|
56
|
+
children: m(
|
|
57
|
+
n.props.children,
|
|
58
58
|
t,
|
|
59
59
|
r
|
|
60
60
|
)
|
|
61
|
-
}) :
|
|
62
|
-
}, O = (
|
|
61
|
+
}) : n;
|
|
62
|
+
}, O = (n, t, r) => {
|
|
63
63
|
if (!t.trim())
|
|
64
|
-
return [
|
|
65
|
-
const
|
|
64
|
+
return [n];
|
|
65
|
+
const e = new RegExp(
|
|
66
66
|
`(${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
|
|
67
67
|
"gi"
|
|
68
68
|
);
|
|
69
|
-
return
|
|
69
|
+
return n.split(e).map((s, o) => e.test(s) ? g(
|
|
70
70
|
"span",
|
|
71
71
|
{
|
|
72
72
|
key: o,
|
|
@@ -75,52 +75,60 @@ const j = (e) => {
|
|
|
75
75
|
},
|
|
76
76
|
s
|
|
77
77
|
) : s);
|
|
78
|
-
},
|
|
78
|
+
}, h = (n, t) => {
|
|
79
79
|
const r = [];
|
|
80
|
-
if (
|
|
81
|
-
for (const
|
|
82
|
-
r.push(
|
|
80
|
+
if (n.children)
|
|
81
|
+
for (const e of n.children)
|
|
82
|
+
r.push(e.id), r.push(...h(e));
|
|
83
83
|
return r;
|
|
84
|
-
}, N = (
|
|
85
|
-
const t = [], r = (
|
|
86
|
-
for (const i of
|
|
84
|
+
}, N = (n) => {
|
|
85
|
+
const t = [], r = (e) => {
|
|
86
|
+
for (const i of e)
|
|
87
87
|
t.push(i), i.children && r(i.children);
|
|
88
88
|
};
|
|
89
|
-
return r(
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
return i === 0 ? String(
|
|
93
|
-
},
|
|
94
|
-
let
|
|
95
|
-
const i =
|
|
89
|
+
return r(n), t;
|
|
90
|
+
}, K = (n, t) => t.includes(n.id) ? !0 : h(n).some((e) => t.includes(e)), q = (n, t) => h(n).filter((e) => t.includes(e)).length, $ = (n) => h(n).length, v = (n, t, r) => {
|
|
91
|
+
const e = q(n, t), i = $(n);
|
|
92
|
+
return i === 0 ? String(n[r] || "") : `${n[r]} (${e} из ${i})`;
|
|
93
|
+
}, P = (n, t, r) => {
|
|
94
|
+
let e = n;
|
|
95
|
+
const i = n.filter(
|
|
96
96
|
(o) => !t.some((c) => c.id === o.id)
|
|
97
97
|
), s = t.filter(
|
|
98
|
-
(o) => !
|
|
98
|
+
(o) => !n.some((c) => c.id === o.id)
|
|
99
99
|
);
|
|
100
100
|
for (const o of i)
|
|
101
101
|
if (o.children && o.children.length > 0) {
|
|
102
|
-
const c =
|
|
103
|
-
(
|
|
102
|
+
const c = h(o), d = N(r).filter(
|
|
103
|
+
(u) => c.includes(u.id)
|
|
104
104
|
);
|
|
105
105
|
d.every(
|
|
106
|
-
(
|
|
107
|
-
) ?
|
|
108
|
-
(
|
|
109
|
-
) :
|
|
106
|
+
(u) => t.some((p) => p.id === u.id)
|
|
107
|
+
) ? e = e.filter(
|
|
108
|
+
(u) => !d.some((p) => p.id === u.id)
|
|
109
|
+
) : e = [...e, ...d];
|
|
110
110
|
}
|
|
111
111
|
for (const o of s) {
|
|
112
|
-
const c =
|
|
113
|
-
|
|
112
|
+
const c = [], d = [o];
|
|
113
|
+
for (; d.length > 0; ) {
|
|
114
|
+
const l = d.pop();
|
|
115
|
+
if (l.children)
|
|
116
|
+
for (const u of l.children)
|
|
117
|
+
c.push(u.id), d.push(u);
|
|
118
|
+
}
|
|
119
|
+
e = e.filter(
|
|
120
|
+
(l) => !c.includes(l.id)
|
|
121
|
+
);
|
|
114
122
|
}
|
|
115
|
-
return
|
|
123
|
+
return e = e.filter(
|
|
116
124
|
(o, c, d) => c === d.findIndex((l) => l.id === o.id)
|
|
117
|
-
),
|
|
125
|
+
), e = e.filter(
|
|
118
126
|
(o) => !o.children || o.children.length === 0
|
|
119
|
-
),
|
|
120
|
-
}, B = (
|
|
127
|
+
), e;
|
|
128
|
+
}, B = (n, t, r, e) => {
|
|
121
129
|
if (t) {
|
|
122
130
|
const i = /* @__PURE__ */ new Set();
|
|
123
|
-
for (const s of
|
|
131
|
+
for (const s of n)
|
|
124
132
|
if (s.children && s.children.length > 0)
|
|
125
133
|
i.add(s);
|
|
126
134
|
else {
|
|
@@ -135,54 +143,54 @@ const j = (e) => {
|
|
|
135
143
|
return Array.from(i).map(
|
|
136
144
|
(s) => v(
|
|
137
145
|
s,
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
n.map((o) => o.id),
|
|
147
|
+
e
|
|
140
148
|
)
|
|
141
149
|
).join(", ");
|
|
142
150
|
}
|
|
143
|
-
return A(
|
|
144
|
-
}, x = (
|
|
145
|
-
t.push(
|
|
146
|
-
const i = x(
|
|
147
|
-
...
|
|
151
|
+
return A(n, e);
|
|
152
|
+
}, x = (n, t, r) => `unique-${t.join("-")}-${n}-${r.value++}`, I = (n, t = [], r = { value: 0 }) => n.map((e) => {
|
|
153
|
+
t.push(e.id);
|
|
154
|
+
const i = x(e.id, t, r), s = {
|
|
155
|
+
...e,
|
|
148
156
|
id: i,
|
|
149
|
-
originalId:
|
|
157
|
+
originalId: e.id,
|
|
150
158
|
path: [...t]
|
|
151
159
|
};
|
|
152
|
-
return
|
|
153
|
-
|
|
160
|
+
return e.children && e.children.length > 0 && (s.children = I(
|
|
161
|
+
e.children,
|
|
154
162
|
t,
|
|
155
163
|
r
|
|
156
164
|
)), t.pop(), s;
|
|
157
|
-
}), U = (
|
|
158
|
-
const t = {}, r = [...
|
|
165
|
+
}), U = (n) => {
|
|
166
|
+
const t = {}, r = [...n];
|
|
159
167
|
for (; r.length > 0; ) {
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const i = String(
|
|
163
|
-
t[i] = t[i] || [], t[i].push(
|
|
168
|
+
const e = r.pop();
|
|
169
|
+
if (e.originalId) {
|
|
170
|
+
const i = String(e.originalId);
|
|
171
|
+
t[i] = t[i] || [], t[i].push(e.id);
|
|
164
172
|
}
|
|
165
|
-
if (
|
|
166
|
-
for (let i =
|
|
167
|
-
r.push(
|
|
173
|
+
if (e.children)
|
|
174
|
+
for (let i = e.children.length - 1; i >= 0; i--)
|
|
175
|
+
r.push(e.children[i]);
|
|
168
176
|
}
|
|
169
177
|
return t;
|
|
170
|
-
}, R = (
|
|
171
|
-
const r =
|
|
172
|
-
for (const [c, d] of Object.entries(
|
|
178
|
+
}, R = (n) => {
|
|
179
|
+
const r = I(n, [], { value: 0 }), e = U(r), i = {};
|
|
180
|
+
for (const [c, d] of Object.entries(e))
|
|
173
181
|
for (const l of d)
|
|
174
182
|
i[String(l)] = isNaN(Number(c)) ? c : Number(c);
|
|
175
183
|
return {
|
|
176
184
|
normalizedItems: r,
|
|
177
|
-
idMapping:
|
|
185
|
+
idMapping: e,
|
|
178
186
|
originalToUniqueId: (c) => {
|
|
179
|
-
const d = String(c), l =
|
|
187
|
+
const d = String(c), l = e[d];
|
|
180
188
|
return l && l.length > 0 ? l[0] : c;
|
|
181
189
|
},
|
|
182
190
|
uniqueToOriginalId: (c) => i[String(c)] || c
|
|
183
191
|
};
|
|
184
|
-
}, F = (
|
|
185
|
-
const r = [],
|
|
192
|
+
}, F = (n, t) => {
|
|
193
|
+
const r = [], e = /* @__PURE__ */ new Set(), i = (s) => {
|
|
186
194
|
const o = t.find(
|
|
187
195
|
(c) => {
|
|
188
196
|
var d;
|
|
@@ -194,13 +202,13 @@ const j = (e) => {
|
|
|
194
202
|
regionName: o.name
|
|
195
203
|
} : {};
|
|
196
204
|
};
|
|
197
|
-
for (const s of
|
|
198
|
-
if (!
|
|
205
|
+
for (const s of n)
|
|
206
|
+
if (!e.has(s.id) && (!s.children || s.children.length === 0)) {
|
|
199
207
|
const o = i(s), c = {
|
|
200
208
|
...s,
|
|
201
209
|
...o
|
|
202
210
|
};
|
|
203
|
-
r.push(c),
|
|
211
|
+
r.push(c), e.add(s.id);
|
|
204
212
|
}
|
|
205
213
|
return r;
|
|
206
214
|
};
|
|
@@ -210,19 +218,19 @@ export {
|
|
|
210
218
|
N as flattenOptions,
|
|
211
219
|
F as flattenSelectedItems,
|
|
212
220
|
v as formatOptionWithCount,
|
|
213
|
-
|
|
221
|
+
h as getAllChildrenIds,
|
|
214
222
|
_ as getDropdownArrowIcon,
|
|
215
223
|
b as getInitialInputValue,
|
|
216
224
|
q as getSelectedChildrenCount,
|
|
217
225
|
$ as getTotalChildrenCount,
|
|
218
|
-
|
|
226
|
+
m as highlightReactNode,
|
|
219
227
|
O as highlightText,
|
|
220
|
-
|
|
228
|
+
K as isOptionSelected,
|
|
221
229
|
A as joinSelectedItems,
|
|
222
230
|
j as mapSizeToInputSize,
|
|
223
231
|
R as normalizeDataForNestedSelection,
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
k as prepareGroupedItems,
|
|
233
|
+
P as processNestedSelectionChange,
|
|
226
234
|
G as shouldShowMenuOnTop,
|
|
227
235
|
B as updateInputValueAfterChange
|
|
228
236
|
};
|