mimir-ui-kit 1.38.18 → 1.38.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,4 +22,5 @@ export declare const MultiSelectSearch: import('react').ForwardRefExoticComponen
22
22
  autocomplete?: "on" | "off";
23
23
  id?: string;
24
24
  autoPlacement?: boolean;
25
+ onIsOpen?: (value: boolean) => void;
25
26
  } & import('react').RefAttributes<HTMLElement>>;
@@ -1,228 +1,229 @@
1
- import { jsxs as M, jsx as n, Fragment as $ } from "react/jsx-runtime";
1
+ import { jsxs as E, jsx as n, Fragment as Q } from "react/jsx-runtime";
2
2
  import { c as l } from "../../index-DIxK0V-G.js";
3
- import { forwardRef as Ie, useId as ge, useRef as Q, useState as b, useEffect as L, useMemo as Ne, useCallback as Se } from "react";
4
- import { EMultiSelectSearchSize as x } from "./constants.js";
5
- import { getInitialInputValue as X, shouldShowMenuOnTop as Ce, MULTISELECT_OPEN_EVENT as Y, mapSizeToInputSize as Z, getDropdownArrowIcon as Me, dispatchMultiselectOpen as E, joinSelectedItems as ee } from "./utils.js";
6
- import { Icon as Ee } from "../../icons/Icon.js";
7
- import { Button as Le } from "../Button/Button.js";
8
- import { CheckboxMimir as Te } from "../CheckboxMimir/CheckboxMimir.js";
9
- import { Chip as ke } from "../Chip/Chip.js";
10
- import { I as te } from "../../Input-BYrIS5GU.js";
11
- import { EInputVariant as ye } from "../Input/constants.js";
12
- import { H as Oe, U as oe, G as ne, K as ze, W as Ae } from "../../combobox-CVtJDVoZ.js";
13
- import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe = "_container_io0c8_9", De = "_full_io0c8_27", Pe = "_button_io0c8_39", qe = "_options_io0c8_53", Re = "_visible_io0c8_66", Be = "_top_io0c8_69", Fe = "_bottom_io0c8_74", je = "_m_io0c8_2", Ge = "_l_io0c8_116", Ue = "_focused_io0c8_134", We = "_option_io0c8_53", He = "_chip_io0c8_163", Je = "_clear_io0c8_188", t = {
3
+ import { forwardRef as Ie, useId as Ne, useRef as X, useState as w, useEffect as T, useMemo as Se, useCallback as Ce } from "react";
4
+ import { EMultiSelectSearchSize as D } from "./constants.js";
5
+ import { getInitialInputValue as Y, shouldShowMenuOnTop as Me, MULTISELECT_OPEN_EVENT as Z, mapSizeToInputSize as ee, getDropdownArrowIcon as Ee, dispatchMultiselectOpen as L, joinSelectedItems as te } from "./utils.js";
6
+ import { Icon as Le } from "../../icons/Icon.js";
7
+ import { Button as Te } from "../Button/Button.js";
8
+ import { CheckboxMimir as ke } from "../CheckboxMimir/CheckboxMimir.js";
9
+ import { Chip as ye } from "../Chip/Chip.js";
10
+ import { I as oe } from "../../Input-BYrIS5GU.js";
11
+ import { EInputVariant as ze } from "../Input/constants.js";
12
+ import { H as Ae, U as ne, G as ie, K as Oe, W as Ve } from "../../combobox-CVtJDVoZ.js";
13
+ import '../../assets/MultiSelectSearch.css';const xe = "_disabled_io0c8_5", De = "_container_io0c8_9", Pe = "_full_io0c8_27", qe = "_button_io0c8_39", Re = "_options_io0c8_53", Be = "_visible_io0c8_66", Fe = "_top_io0c8_69", je = "_bottom_io0c8_74", Ge = "_m_io0c8_2", Ue = "_l_io0c8_116", We = "_focused_io0c8_134", He = "_option_io0c8_53", Je = "_chip_io0c8_163", Ke = "_clear_io0c8_188", t = {
14
14
  "multi-select-search": "_multi-select-search_io0c8_2",
15
- disabled: Ve,
16
- container: xe,
15
+ disabled: xe,
16
+ container: De,
17
17
  "container-open": "_container-open_io0c8_18",
18
18
  "input-container": "_input-container_io0c8_22",
19
- full: De,
19
+ full: Pe,
20
20
  "selected-icon": "_selected-icon_io0c8_31",
21
21
  "selector-icon-open": "_selector-icon-open_io0c8_35",
22
- button: Pe,
22
+ button: qe,
23
23
  "selector-icon": "_selector-icon_io0c8_35",
24
- options: qe,
25
- visible: Re,
26
- top: Be,
27
- bottom: Fe,
24
+ options: Re,
25
+ visible: Be,
26
+ top: Fe,
27
+ bottom: je,
28
28
  "no-options": "_no-options_io0c8_95",
29
- m: je,
30
- l: Ge,
29
+ m: Ge,
30
+ l: Ue,
31
31
  "multi-select-input-disabled": "_multi-select-input-disabled_io0c8_131",
32
32
  "multi-select-input": "_multi-select-input_io0c8_131",
33
- focused: Ue,
34
- option: We,
33
+ focused: We,
34
+ option: He,
35
35
  "option-active": "_option-active_io0c8_153",
36
36
  "option-inner": "_option-inner_io0c8_156",
37
- chip: He,
37
+ chip: Je,
38
38
  "chip-container": "_chip-container_io0c8_168",
39
39
  "chip-root": "_chip-root_io0c8_174",
40
40
  "right-slot": "_right-slot_io0c8_178",
41
41
  "required-mark": "_required-mark_io0c8_183",
42
- clear: Je,
42
+ clear: Ke,
43
43
  "icon-button": "_icon-button_io0c8_197"
44
- }, ct = Ie(
45
- (ie, se) => {
44
+ }, lt = Ie(
45
+ (se, ce) => {
46
46
  const {
47
- placeholder: D,
48
- size: i = x.L,
47
+ placeholder: P,
48
+ size: i = D.L,
49
49
  value: d,
50
50
  onChange: s,
51
- full: ce,
52
- showArrow: le = !0,
51
+ full: le,
52
+ showArrow: re = !0,
53
53
  items: h = [],
54
- classNameOption: re,
54
+ classNameOption: ae,
55
55
  displayValue: f = "name",
56
- filterOnSearch: P = !0,
57
- onSearch: T,
58
- variant: q = ye.DefaultGray,
59
- menuPlacement: w = "bottom",
56
+ filterOnSearch: q = !0,
57
+ onSearch: k,
58
+ variant: R = ze.DefaultGray,
59
+ menuPlacement: g = "bottom",
60
60
  disabled: r = !1,
61
- searchProps: R,
62
- withClearButton: k = !1,
63
- withChip: ae = !1,
64
- chipVariant: ue = "sapphire",
61
+ searchProps: B,
62
+ withClearButton: y = !1,
63
+ withChip: ue = !1,
64
+ chipVariant: de = "sapphire",
65
65
  disableInput: I = !1,
66
- autocomplete: B = "on",
67
- id: de,
68
- autoPlacement: y = !1
69
- } = ie, pe = ge(), p = de || `multiselect-${pe}`, g = Q(null), v = Q(null), [m, _] = b(!1), [N, S] = b(
70
- () => X(d, f)
71
- ), [c, C] = b(
66
+ autocomplete: F = "on",
67
+ id: pe,
68
+ autoPlacement: z = !1,
69
+ onIsOpen: v
70
+ } = se, me = Ne(), p = pe || `multiselect-${me}`, N = X(null), b = X(null), [m, _] = w(!1), [S, C] = w(
71
+ () => Y(d, f)
72
+ ), [c, M] = w(
72
73
  d || []
73
- ), [O, F] = b(w), [z, j] = b(!1), [me, G] = b(!1);
74
- L(() => {
75
- d && (C(d), JSON.stringify(d) !== JSON.stringify(c) && S(X(d, f)));
74
+ ), [A, j] = w(g), [O, G] = w(!1), [_e, U] = w(!1);
75
+ T(() => {
76
+ d && (M(d), JSON.stringify(d) !== JSON.stringify(c) && C(Y(d, f)));
76
77
  }, [d, f, c]);
77
- const U = Ne(() => {
78
+ const W = Se(() => {
78
79
  var o;
79
- if (!P) return h;
80
- const e = ((o = N.split(",").pop()) == null ? void 0 : o.trim().toLowerCase()) ?? "";
80
+ if (!q) return h;
81
+ const e = ((o = S.split(",").pop()) == null ? void 0 : o.trim().toLowerCase()) ?? "";
81
82
  return c.length > 0 && c[c.length - 1].name.toLowerCase() === e ? h : h.filter(
82
83
  (a) => a.name.toLowerCase().includes(e)
83
84
  );
84
- }, [P, h, N, c]), _e = (e) => {
85
- C(e), s == null || s(e);
86
- const o = ee(e, f);
87
- S(o), _(!0), E(p), setTimeout(() => {
88
- if (v.current) {
89
- v.current.focus(), v.current.scrollLeft = v.current.scrollWidth;
85
+ }, [q, h, S, c]), he = (e) => {
86
+ M(e), s == null || s(e);
87
+ const o = te(e, f);
88
+ C(o), _(!0), L(p), setTimeout(() => {
89
+ if (b.current) {
90
+ b.current.focus(), b.current.scrollLeft = b.current.scrollWidth;
90
91
  const a = o.length;
91
- v.current.setSelectionRange(a, a);
92
+ b.current.setSelectionRange(a, a);
92
93
  }
93
94
  }, 0);
94
- }, W = (e) => {
95
- var K;
95
+ }, H = (e) => {
96
+ var $;
96
97
  if (I) return;
97
98
  const o = e.target.value;
98
- S(o), T == null || T(o);
99
- const a = o.split(",").map((V) => V.trim()).filter(Boolean), J = h.filter(
100
- (V) => a.includes(V[f])
99
+ C(o), k == null || k(o);
100
+ const a = o.split(",").map((x) => x.trim()).filter(Boolean), K = h.filter(
101
+ (x) => a.includes(x[f])
101
102
  );
102
- C(J), s == null || s(J), _(!0), E(p);
103
- const A = (K = g.current) == null ? void 0 : K.querySelector(
103
+ M(K), s == null || s(K), _(!0), L(p);
104
+ const V = ($ = N.current) == null ? void 0 : $.querySelector(
104
105
  `.${t.options}`
105
106
  );
106
- A && typeof A.scrollTo == "function" && A.scrollTo({ top: 0, behavior: "smooth" });
107
- }, he = (e) => {
107
+ V && typeof V.scrollTo == "function" && V.scrollTo({ top: 0, behavior: "smooth" });
108
+ }, fe = (e) => {
108
109
  const o = c.filter(
109
110
  (a) => a.id !== e.id
110
111
  );
111
- C(o), s == null || s(o), S(ee(o, f));
112
- }, u = Se(() => {
113
- if (!y) {
114
- F(w);
112
+ M(o), s == null || s(o), C(te(o, f));
113
+ }, u = Ce(() => {
114
+ if (!z) {
115
+ j(g);
115
116
  return;
116
117
  }
117
- const e = Ce(g, i);
118
- F(e ? "top" : w);
119
- }, [y, w, i]), H = () => {
118
+ const e = Me(N, i);
119
+ j(e ? "top" : g);
120
+ }, [z, g, i]), J = () => {
120
121
  const e = !m;
121
- e && (u(), E(p)), _(e);
122
- }, fe = (e) => {
122
+ e && (u(), L(p)), _(e), v == null || v(e);
123
+ }, ve = (e) => {
123
124
  e.preventDefault(), e.currentTarget.focus();
124
125
  const o = e.currentTarget.value.length;
125
126
  e.currentTarget.setSelectionRange(o, o);
126
- }, ve = () => {
127
- S(""), C([]), s == null || s([]);
128
- }, be = (e) => {
129
- e.stopPropagation(), ve();
127
+ }, be = () => {
128
+ C(""), M([]), s == null || s([]);
130
129
  }, we = (e) => {
130
+ e.stopPropagation(), be();
131
+ }, ge = (e) => {
131
132
  if (I) {
132
133
  e.target.blur();
133
134
  return;
134
135
  }
135
- u(), _(!0), E(p);
136
+ u(), _(!0), L(p);
136
137
  };
137
- return L(() => {
138
+ return T(() => {
138
139
  const e = (o) => {
139
- g.current && !g.current.contains(o.target) && !o.defaultPrevented && _(!1);
140
+ N.current && !N.current.contains(o.target) && !o.defaultPrevented && (_(!1), v == null || v(!1));
140
141
  };
141
142
  return document.addEventListener("mousedown", e), () => {
142
143
  document.removeEventListener("mousedown", e);
143
144
  };
144
- }, []), L(() => {
145
+ }, []), T(() => {
145
146
  const e = (o) => {
146
147
  o.detail !== p && _(!1);
147
148
  };
148
149
  return window.addEventListener(
149
- Y,
150
+ Z,
150
151
  e
151
152
  ), () => {
152
153
  window.removeEventListener(
153
- Y,
154
+ Z,
154
155
  e
155
156
  );
156
157
  };
157
- }, [p]), L(() => {
158
+ }, [p]), T(() => {
158
159
  if (m) {
159
160
  u(), window.addEventListener("scroll", u), window.addEventListener("resize", u);
160
161
  const e = requestAnimationFrame(() => {
161
- G(!0), j(!0);
162
+ U(!0), G(!0);
162
163
  });
163
164
  return () => {
164
165
  window.removeEventListener("scroll", u), window.removeEventListener("resize", u), cancelAnimationFrame(e);
165
166
  };
166
167
  } else
167
- j(!1), G(!1);
168
- }, [m, w, y, i, u]), /* @__PURE__ */ M("div", { ref: g, children: [
168
+ G(!1), U(!1);
169
+ }, [m, g, z, i, u]), /* @__PURE__ */ E("div", { ref: N, children: [
169
170
  /* @__PURE__ */ n(
170
- Oe,
171
+ Ae,
171
172
  {
172
173
  multiple: !0,
173
174
  as: "div",
174
175
  value: c,
175
176
  className: l(t["multi-select-search"], {
176
- [t.full]: ce,
177
+ [t.full]: le,
177
178
  [t.disabled]: r
178
179
  }),
179
- onChange: _e,
180
- ref: se,
180
+ onChange: he,
181
+ ref: ce,
181
182
  disabled: r,
182
- virtual: { options: U },
183
- children: /* @__PURE__ */ M(
183
+ virtual: { options: W },
184
+ children: /* @__PURE__ */ E(
184
185
  "div",
185
186
  {
186
187
  className: l(t.container, t[i], {
187
188
  [t["container-open"]]: m
188
189
  }),
189
190
  children: [
190
- I && /* @__PURE__ */ M("div", { className: t["input-container"], children: [
191
+ I && /* @__PURE__ */ E("div", { className: t["input-container"], children: [
191
192
  /* @__PURE__ */ n(
192
- oe,
193
+ ne,
193
194
  {
194
195
  disabled: r,
195
196
  style: { width: "100%" },
196
- onClick: H,
197
+ onClick: J,
197
198
  children: /* @__PURE__ */ n(
198
- ne,
199
+ ie,
199
200
  {
200
- as: te,
201
- label: D,
202
- size: Z(i),
201
+ as: oe,
202
+ label: P,
203
+ size: ee(i),
203
204
  className: l(t["multi-select-input"], {
204
- [t["multi-select-input-disabled"]]: I && k
205
+ [t["multi-select-input-disabled"]]: I && y
205
206
  }),
206
- onChange: W,
207
- value: N,
207
+ onChange: H,
208
+ value: S,
208
209
  disabled: r,
209
- variant: q,
210
+ variant: R,
210
211
  rightSlotClassName: t["right-slot"],
211
212
  requiredMarkClassName: t["required-mark"],
212
213
  "data-testid": "select-search-input",
213
- onFocus: we,
214
+ onFocus: ge,
214
215
  rightAddon: {
215
216
  addonType: "icon",
216
- addonContent: Me(m, i)
217
+ addonContent: Ee(m, i)
217
218
  },
218
- autocomplete: B,
219
- ...R
219
+ autocomplete: F,
220
+ ...B
220
221
  }
221
222
  )
222
223
  }
223
224
  ),
224
- k && N && /* @__PURE__ */ n(
225
- Le,
225
+ y && S && /* @__PURE__ */ n(
226
+ Te,
226
227
  {
227
228
  tabIndex: -1,
228
229
  className: l(t.clear, {
@@ -235,44 +236,44 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
235
236
  clear: !0,
236
237
  disabled: r,
237
238
  variant: "secondary-gray",
238
- onClick: be,
239
+ onClick: we,
239
240
  "data-testid": "clear-button"
240
241
  }
241
242
  )
242
243
  ] }),
243
244
  !I && /* @__PURE__ */ n(
244
- ne,
245
+ ie,
245
246
  {
246
- as: te,
247
- label: D,
248
- size: Z(i),
247
+ as: oe,
248
+ label: P,
249
+ size: ee(i),
249
250
  className: t["multi-select-input"],
250
251
  rightSlotClassName: t["right-slot"],
251
252
  requiredMarkClassName: t["required-mark"],
252
- value: N,
253
+ value: S,
253
254
  disabled: r,
254
- variant: q,
255
- withClearButton: k,
255
+ variant: R,
256
+ withClearButton: y,
256
257
  onFocus: () => {
257
- _(!0), E(p);
258
+ _(!0), L(p);
258
259
  },
259
- onMouseDown: fe,
260
- onChange: W,
261
- ref: v,
260
+ onMouseDown: ve,
261
+ onChange: H,
262
+ ref: b,
262
263
  rightAddon: {
263
264
  addonType: "react-node",
264
- addonContent: le && /* @__PURE__ */ n(
265
- oe,
265
+ addonContent: re && /* @__PURE__ */ n(
266
+ ne,
266
267
  {
267
268
  className: l(t.button, {
268
269
  [t.disabled]: r
269
270
  }),
270
271
  disabled: r,
271
- onMouseDown: H,
272
+ onMouseDown: J,
272
273
  children: /* @__PURE__ */ n(
273
- Ee,
274
+ Le,
274
275
  {
275
- iconName: i == x.M ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
276
+ iconName: i == D.M ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
276
277
  className: l(t["selector-icon"], {
277
278
  [t["selector-icon-open"]]: m
278
279
  })
@@ -282,40 +283,40 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
282
283
  )
283
284
  },
284
285
  "data-testid": "select-search-input",
285
- autocomplete: B,
286
- ...R
286
+ autocomplete: F,
287
+ ...B
287
288
  }
288
289
  ),
289
- m && me && /* @__PURE__ */ n($, { children: h.length ? U.length ? /* @__PURE__ */ n(
290
- ze,
290
+ m && _e && /* @__PURE__ */ n(Q, { children: h.length ? W.length ? /* @__PURE__ */ n(
291
+ Oe,
291
292
  {
292
293
  className: l(
293
294
  t.options,
294
295
  t[i],
295
- t[O],
296
- { [t.visible]: z }
296
+ t[A],
297
+ { [t.visible]: O }
297
298
  ),
298
299
  modal: !1,
299
300
  static: !0,
300
301
  children: ({ option: e }) => /* @__PURE__ */ n(
301
- Ae,
302
+ Ve,
302
303
  {
303
304
  value: e,
304
305
  className: ({ focus: o }) => l(
305
306
  t.option,
306
- re,
307
+ ae,
307
308
  i && t[i],
308
309
  {
309
310
  [t["option-active"]]: o
310
311
  }
311
312
  ),
312
- children: /* @__PURE__ */ M($, { children: [
313
- /* @__PURE__ */ M("div", { className: t["option-inner"], children: [
313
+ children: /* @__PURE__ */ E(Q, { children: [
314
+ /* @__PURE__ */ E("div", { className: t["option-inner"], children: [
314
315
  e.name,
315
316
  e.bottom && /* @__PURE__ */ n("div", { children: e.bottom })
316
317
  ] }),
317
318
  /* @__PURE__ */ n(
318
- Te,
319
+ ke,
319
320
  {
320
321
  isInteractive: !1,
321
322
  checked: c.some(
@@ -335,8 +336,8 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
335
336
  t.options,
336
337
  t[i],
337
338
  t["no-options"],
338
- t[O],
339
- { [t.visible]: z }
339
+ t[A],
340
+ { [t.visible]: O }
340
341
  ),
341
342
  children: "Ничего не найдено"
342
343
  }
@@ -347,8 +348,8 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
347
348
  t.options,
348
349
  t[i],
349
350
  t["no-options"],
350
- t[O],
351
- { [t.visible]: z }
351
+ t[A],
352
+ { [t.visible]: O }
352
353
  ),
353
354
  children: "Нет данных"
354
355
  }
@@ -358,14 +359,14 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
358
359
  )
359
360
  }
360
361
  ),
361
- ae && c.length > 0 && /* @__PURE__ */ n("div", { className: t["chip-container"], children: c.map((e) => /* @__PURE__ */ n(
362
- ke,
362
+ ue && c.length > 0 && /* @__PURE__ */ n("div", { className: t["chip-container"], children: c.map((e) => /* @__PURE__ */ n(
363
+ ye,
363
364
  {
364
- size: i === x.L ? "s" : "xs",
365
- variant: ue,
365
+ size: i === D.L ? "s" : "xs",
366
+ variant: de,
366
367
  className: t["chip-root"],
367
368
  withAction: !0,
368
- onClose: () => he(e),
369
+ onClose: () => fe(e),
369
370
  children: /* @__PURE__ */ n("span", { className: t.chip, children: e.name })
370
371
  },
371
372
  e.id
@@ -374,5 +375,5 @@ import '../../assets/MultiSelectSearch.css';const Ve = "_disabled_io0c8_5", xe =
374
375
  }
375
376
  );
376
377
  export {
377
- ct as MultiSelectSearch
378
+ lt as MultiSelectSearch
378
379
  };
@@ -67,4 +67,6 @@ export type TMultiSelectSearchProps = Pick<TInputProps, 'withClearButton' | 'var
67
67
  * Автоматическое определение положения выпадающего меню
68
68
  */
69
69
  autoPlacement?: boolean;
70
+ /** Функция обратного вызова, срабатывающая при открытии и закрытии выпадающего списка */
71
+ onIsOpen?: (value: boolean) => void;
70
72
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.38.18",
4
+ "version": "1.38.20",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {