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