mimir-ui-kit 1.46.0 → 1.47.0

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.
Files changed (24) hide show
  1. package/dist/assets/CheckboxMimir.css +1 -1
  2. package/dist/assets/SelectSearch.css +1 -1
  3. package/dist/assets/useNestedSelection.css +1 -1
  4. package/dist/components/CheckboxMimir/CheckboxMimir.d.ts +2 -0
  5. package/dist/components/CheckboxMimir/CheckboxMimir.js +42 -41
  6. package/dist/components/MultiSelectSearch/MultiSelectSearch.d.ts +3 -0
  7. package/dist/components/MultiSelectSearch/MultiSelectSearch.js +260 -245
  8. package/dist/components/MultiSelectSearch/hooks/useChips.js +79 -57
  9. package/dist/components/MultiSelectSearch/hooks/useNestedSelection.d.ts +5 -2
  10. package/dist/components/MultiSelectSearch/hooks/useNestedSelection.js +3 -2
  11. package/dist/components/MultiSelectSearch/hooks/useRenderVirtualizedList.d.ts +5 -2
  12. package/dist/components/MultiSelectSearch/hooks/useRenderVirtualizedList.js +151 -136
  13. package/dist/components/MultiSelectSearch/hooks/useSearch.d.ts +4 -1
  14. package/dist/components/MultiSelectSearch/hooks/useSearch.js +54 -30
  15. package/dist/components/MultiSelectSearch/hooks/useVirtualization.d.ts +0 -1
  16. package/dist/components/MultiSelectSearch/hooks/useVirtualization.js +25 -46
  17. package/dist/components/MultiSelectSearch/types.d.ts +15 -0
  18. package/dist/components/SelectSearch/SelectSearch.d.ts +1 -0
  19. package/dist/components/SelectSearch/SelectSearch.js +304 -324
  20. package/dist/components/SelectSearch/types.d.ts +5 -0
  21. package/dist/components/SelectSearch/utils.js +18 -17
  22. package/dist/useNestedSelection-bo9wXvE-.js +181 -0
  23. package/package.json +1 -1
  24. package/dist/useNestedSelection-DnuUbEqM.js +0 -119
@@ -109,4 +109,9 @@ export type TSelectSearchProps = Pick<TInputProps, 'withClearButton' | 'variant'
109
109
  * @default false
110
110
  */
111
111
  highlightMatches?: boolean;
112
+ /**
113
+ * Включить поиск по хедерам группы вложенных элементов в режиме группировки
114
+ * @default false
115
+ */
116
+ searchInHeaderGroupItems?: boolean;
112
117
  };
@@ -1,5 +1,5 @@
1
1
  import { createElement as u, Fragment as l, isValidElement as g, cloneElement as m } from "react";
2
- import { ESelectSearchSize as s, MOBILE_MENU_HEIGHT as w, DESKTOP_MENU_HEIGHT as f } from "./constants.js";
2
+ import { ESelectSearchSize as s, MOBILE_MENU_HEIGHT as h, DESKTOP_MENU_HEIGHT as w } from "./constants.js";
3
3
  import "../../Input-IzZ6B9kw.js";
4
4
  import { EInputSize as c } from "../Input/constants.js";
5
5
  const A = (r) => {
@@ -15,33 +15,34 @@ const A = (r) => {
15
15
  }
16
16
  }, H = (r, t) => r ? t === s.L ? "DropdownArrowUp24px" : "DropdownArrowUp16px" : t === s.L ? "DropdownArrowDown24px" : "DropdownArrowBottom16px", M = (r, t, n) => {
17
17
  if (!r.length || !t) return r;
18
- const e = [], i = /* @__PURE__ */ new Set();
18
+ const e = [], p = /* @__PURE__ */ new Set();
19
19
  for (const o of r) {
20
- const p = String(o[t] || "Без группы");
21
- i.has(p) || (i.add(p), e.push({
22
- id: `group-header-${p}`,
23
- name: n(p),
20
+ const i = String(o[t] || "Без группы");
21
+ p.has(i) || (p.add(i), e.push({
22
+ id: `group-header-${i}`,
23
+ name: n(i),
24
24
  isGroupHeader: !0,
25
- originalValue: p
25
+ originalValue: i
26
26
  })), e.push(o);
27
27
  }
28
28
  return e;
29
29
  }, D = (r, t) => {
30
30
  if (!r.current) return !1;
31
- const n = r.current.getBoundingClientRect(), e = window.innerHeight, i = t === s.M || t === s.S ? w : f, o = e - n.bottom, p = n.top;
32
- return o >= i ? !1 : p > o;
33
- }, h = (r, t, n) => {
31
+ const n = r.current.getBoundingClientRect(), e = window.innerHeight, p = t === s.M || t === s.S ? h : w, o = e - n.bottom, i = n.top;
32
+ return o >= p ? !1 : i > o;
33
+ }, f = (r, t, n) => {
34
34
  if (!t.trim())
35
35
  return [r];
36
36
  const e = new RegExp(
37
37
  `(${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`,
38
38
  "gi"
39
39
  );
40
- return r.split(e).map((o, p) => e.test(o) ? u(
40
+ return r.split(e).map((o, i) => e.test(o) ? u(
41
41
  "span",
42
42
  {
43
- key: p,
44
- className: n
43
+ key: i,
44
+ className: n,
45
+ "data-testid": "highlighted-match"
45
46
  },
46
47
  o
47
48
  ) : o);
@@ -49,7 +50,7 @@ const A = (r) => {
49
50
  if (!t.trim())
50
51
  return r;
51
52
  if (typeof r == "string") {
52
- const e = h(
53
+ const e = f(
53
54
  r,
54
55
  t,
55
56
  n
@@ -61,9 +62,9 @@ const A = (r) => {
61
62
  );
62
63
  }
63
64
  return Array.isArray(r) ? r.map(
64
- (e, i) => u(
65
+ (e, p) => u(
65
66
  l,
66
- { key: i },
67
+ { key: p },
67
68
  a(e, t, n)
68
69
  )
69
70
  ) : g(r) ? m(r, {
@@ -78,7 +79,7 @@ const A = (r) => {
78
79
  export {
79
80
  H as getDropdownArrowIcon,
80
81
  a as highlightReactNode,
81
- h as highlightText,
82
+ f as highlightText,
82
83
  A as mapSizeToInputSize,
83
84
  M as prepareGroupedItems,
84
85
  D as shouldShowMenuOnTop
@@ -0,0 +1,181 @@
1
+ import { jsxs as C, jsx as r } from "react/jsx-runtime";
2
+ import { c as w } from "./index-DIxK0V-G.js";
3
+ import { useEffect as j } from "react";
4
+ import { Icon as k } from "./icons/Icon.js";
5
+ import { CheckboxMimir as q } from "./components/CheckboxMimir/CheckboxMimir.js";
6
+ import { EMultiSelectSearchSize as M } from "./components/MultiSelectSearch/constants.js";
7
+ import { getAllChildrenIds as F } from "./components/MultiSelectSearch/utils.js";
8
+ import { W as P } from "./combobox-fIVOzEhl.js";
9
+ import './assets/useNestedSelection.css';const W = "_disabled_1l3p8_5", B = "_container_1l3p8_9", L = "_l_1l3p8_36", T = "_loader_1l3p8_40", V = "_full_1l3p8_50", $ = "_button_1l3p8_62", y = "_options_1l3p8_32", G = "_visible_1l3p8_89", H = "_top_1l3p8_92", J = "_bottom_1l3p8_97", K = "_m_1l3p8_2", R = "_focused_1l3p8_157", U = "_option_1l3p8_32", X = "_chip_1l3p8_186", Y = "_clear_1l3p8_211", s = {
10
+ "multi-select-search": "_multi-select-search_1l3p8_2",
11
+ disabled: W,
12
+ container: B,
13
+ "container-open": "_container-open_1l3p8_18",
14
+ "group-header": "_group-header_1l3p8_22",
15
+ "options-container": "_options-container_1l3p8_32",
16
+ l: L,
17
+ loader: T,
18
+ "input-container": "_input-container_1l3p8_45",
19
+ full: V,
20
+ "selected-icon": "_selected-icon_1l3p8_54",
21
+ "selector-icon-open": "_selector-icon-open_1l3p8_58",
22
+ button: $,
23
+ "selector-icon": "_selector-icon_1l3p8_58",
24
+ options: y,
25
+ visible: G,
26
+ top: H,
27
+ bottom: J,
28
+ "no-options": "_no-options_1l3p8_118",
29
+ m: K,
30
+ "multi-select-input-disabled": "_multi-select-input-disabled_1l3p8_154",
31
+ "multi-select-input": "_multi-select-input_1l3p8_154",
32
+ focused: R,
33
+ option: U,
34
+ "option-active": "_option-active_1l3p8_176",
35
+ "option-inner": "_option-inner_1l3p8_179",
36
+ chip: X,
37
+ "chip-container": "_chip-container_1l3p8_191",
38
+ "chip-root": "_chip-root_1l3p8_197",
39
+ "right-slot": "_right-slot_1l3p8_201",
40
+ "required-mark": "_required-mark_1l3p8_206",
41
+ clear: Y,
42
+ "icon-button": "_icon-button_1l3p8_220",
43
+ "highlighted-text": "_highlighted-text_1l3p8_224",
44
+ "highlighted-text-wrapper": "_highlighted-text-wrapper_1l3p8_229",
45
+ "nested-option": "_nested-option_1l3p8_233",
46
+ "expand-button": "_expand-button_1l3p8_241",
47
+ "expand-icon": "_expand-icon_1l3p8_253",
48
+ "expand-icon-expanded": "_expand-icon-expanded_1l3p8_256"
49
+ }, cn = ({
50
+ filteredItems: p,
51
+ selectedItems: v,
52
+ expandedOptions: S,
53
+ setExpandedOptions: a,
54
+ size: _,
55
+ classNameOption: N,
56
+ items: h,
57
+ enableNestedSelection: u,
58
+ searchInNestedItems: f = !1,
59
+ internalSearchQuery: g,
60
+ renderOptionContent: D,
61
+ groupBy: E,
62
+ useIconInsteadOfCheckbox: A = !1
63
+ }) => {
64
+ const b = (t) => {
65
+ a((i) => {
66
+ const e = new Set(i);
67
+ return e.has(t) ? e.delete(t) : e.add(t), e;
68
+ });
69
+ };
70
+ j(() => {
71
+ if (u && f && g) {
72
+ const t = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), e = (c) => {
73
+ c.forEach((n) => {
74
+ i.has(n.id) || (i.add(n.id), n.children && n.children.length > 0 && (n.children.some(
75
+ (l) => p.some((o) => o.id === l.id)
76
+ ) && t.add(n.id), e(n.children)));
77
+ });
78
+ };
79
+ e(h), a((c) => /* @__PURE__ */ new Set([...c, ...t]));
80
+ }
81
+ }, [
82
+ p,
83
+ u,
84
+ f,
85
+ g,
86
+ h,
87
+ a
88
+ ]);
89
+ const I = (t) => {
90
+ const i = v.map((o) => o.id);
91
+ if (!t.children || t.children.length === 0)
92
+ return {
93
+ checked: i.includes(t.id),
94
+ isMinusIcon: !1
95
+ };
96
+ const e = t.children.flatMap((o) => [
97
+ o.id,
98
+ ...F(o)
99
+ ]), c = e.filter(
100
+ (o) => i.includes(o)
101
+ ).length, n = e.length, d = c > 0;
102
+ return {
103
+ checked: d,
104
+ isMinusIcon: d && !(c === n)
105
+ };
106
+ }, m = (t, i = 0) => {
107
+ const e = /* @__PURE__ */ new Map(), c = (n) => {
108
+ if (e.has(n.id))
109
+ return e.get(n.id);
110
+ if (p.some((l) => l.id === n.id))
111
+ return e.set(n.id, !0), !0;
112
+ if (n.children && n.children.length > 0) {
113
+ const l = n.children.some(
114
+ (o) => c(o)
115
+ );
116
+ return e.set(n.id, l), l;
117
+ }
118
+ return e.set(n.id, !1), !1;
119
+ };
120
+ return t.filter((n) => i === 0 ? c(n) && h.some((d) => d.id === n.id) : f ? c(n) : !n.children).map((n) => {
121
+ const d = S.has(n.id), l = n.children && n.children.length > 0, o = I(n);
122
+ return /* @__PURE__ */ C("div", { children: [
123
+ /* @__PURE__ */ C(
124
+ P,
125
+ {
126
+ value: n,
127
+ className: ({ focus: x }) => w(s.option, N, _ && s[_], {
128
+ [s["option-active"]]: x && !E && !u,
129
+ [s["nested-option"]]: i > 0
130
+ }),
131
+ children: [
132
+ A ? o.checked && /* @__PURE__ */ r(
133
+ k,
134
+ {
135
+ iconName: _ === M.L ? "Done24px" : "Done16px",
136
+ className: s["selected-icon"]
137
+ }
138
+ ) : /* @__PURE__ */ r(
139
+ q,
140
+ {
141
+ isInteractive: !1,
142
+ checked: o.checked,
143
+ isMinusIcon: o.isMinusIcon
144
+ }
145
+ ),
146
+ /* @__PURE__ */ r("div", { className: s["option-inner"], children: D(n) }),
147
+ l && /* @__PURE__ */ r(
148
+ "div",
149
+ {
150
+ className: s["expand-button"],
151
+ "data-testid": `expand-button-${n.id}`,
152
+ onMouseDown: (x) => {
153
+ x.stopPropagation(), b(n.id);
154
+ },
155
+ children: /* @__PURE__ */ r(
156
+ k,
157
+ {
158
+ iconName: _ === M.M ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
159
+ className: w(s["expand-icon"], {
160
+ [s["expand-icon-expanded"]]: d
161
+ })
162
+ }
163
+ )
164
+ }
165
+ )
166
+ ]
167
+ }
168
+ ),
169
+ l && d && /* @__PURE__ */ r("div", { className: s["nested-children"], children: m(n.children, i + 1) })
170
+ ] }, n.id);
171
+ });
172
+ };
173
+ return {
174
+ toggleExpanded: b,
175
+ renderNestedOptions: m
176
+ };
177
+ };
178
+ export {
179
+ s as c,
180
+ cn as u
181
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.46.0",
4
+ "version": "1.47.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -1,119 +0,0 @@
1
- import { jsxs as r, jsx as _ } from "react/jsx-runtime";
2
- import { c as a } from "./index-DIxK0V-G.js";
3
- import { Icon as w } from "./icons/Icon.js";
4
- import { CheckboxMimir as k } from "./components/CheckboxMimir/CheckboxMimir.js";
5
- import { EMultiSelectSearchSize as N } from "./components/MultiSelectSearch/constants.js";
6
- import { isOptionSelected as S } from "./components/MultiSelectSearch/utils.js";
7
- import { W as y } from "./combobox-fIVOzEhl.js";
8
- import './assets/useNestedSelection.css';const D = "_disabled_dbl8p_5", M = "_container_dbl8p_9", E = "_sticky_dbl8p_33", j = "_hidden_dbl8p_41", q = "_l_dbl8p_49", A = "_loader_dbl8p_53", C = "_full_dbl8p_63", O = "_button_dbl8p_75", W = "_options_dbl8p_45", B = "_visible_dbl8p_102", F = "_top_dbl8p_105", P = "_bottom_dbl8p_110", $ = "_m_dbl8p_2", G = "_focused_dbl8p_170", H = "_option_dbl8p_45", I = "_chip_dbl8p_199", J = "_clear_dbl8p_224", e = {
9
- "multi-select-search": "_multi-select-search_dbl8p_2",
10
- disabled: D,
11
- container: M,
12
- "container-open": "_container-open_dbl8p_18",
13
- "group-header": "_group-header_dbl8p_22",
14
- "sticky-active": "_sticky-active_dbl8p_33",
15
- sticky: E,
16
- hidden: j,
17
- "options-container": "_options-container_dbl8p_45",
18
- l: q,
19
- loader: A,
20
- "input-container": "_input-container_dbl8p_58",
21
- full: C,
22
- "selected-icon": "_selected-icon_dbl8p_67",
23
- "selector-icon-open": "_selector-icon-open_dbl8p_71",
24
- button: O,
25
- "selector-icon": "_selector-icon_dbl8p_71",
26
- options: W,
27
- visible: B,
28
- top: F,
29
- bottom: P,
30
- "no-options": "_no-options_dbl8p_131",
31
- m: $,
32
- "multi-select-input-disabled": "_multi-select-input-disabled_dbl8p_167",
33
- "multi-select-input": "_multi-select-input_dbl8p_167",
34
- focused: G,
35
- option: H,
36
- "option-active": "_option-active_dbl8p_189",
37
- "option-inner": "_option-inner_dbl8p_192",
38
- chip: I,
39
- "chip-container": "_chip-container_dbl8p_204",
40
- "chip-root": "_chip-root_dbl8p_210",
41
- "right-slot": "_right-slot_dbl8p_214",
42
- "required-mark": "_required-mark_dbl8p_219",
43
- clear: J,
44
- "icon-button": "_icon-button_dbl8p_233",
45
- "highlighted-text": "_highlighted-text_dbl8p_237",
46
- "highlighted-text-wrapper": "_highlighted-text-wrapper_dbl8p_242",
47
- "nested-option": "_nested-option_dbl8p_246",
48
- "expand-button": "_expand-button_dbl8p_254",
49
- "expand-icon": "_expand-icon_dbl8p_266",
50
- "expand-icon-expanded": "_expand-icon-expanded_dbl8p_269"
51
- }, X = ({
52
- filteredItems: b,
53
- selectedItems: h,
54
- expandedOptions: u,
55
- setExpandedOptions: m,
56
- size: c,
57
- classNameOption: x,
58
- items: f,
59
- renderOptionContent: g
60
- }) => {
61
- const l = (n) => {
62
- m((i) => {
63
- const o = new Set(i);
64
- return o.has(n) ? o.delete(n) : o.add(n), o;
65
- });
66
- }, s = (n, i = 0) => n.filter((o) => {
67
- const p = b.some((t) => t.id === o.id);
68
- return i === 0 ? p && f.some((t) => t.id === o.id) : !o.children;
69
- }).map((o) => {
70
- const p = u.has(o.id), t = o.children && o.children.length > 0, v = S(
71
- o,
72
- h.map((d) => d.id)
73
- );
74
- return /* @__PURE__ */ r("div", { children: [
75
- /* @__PURE__ */ r(
76
- y,
77
- {
78
- value: o,
79
- className: ({ focus: d }) => a(e.option, x, c && e[c], {
80
- [e["option-active"]]: d,
81
- [e["nested-option"]]: i > 0
82
- }),
83
- children: [
84
- /* @__PURE__ */ _(k, { isInteractive: !1, checked: v }),
85
- /* @__PURE__ */ _("div", { className: e["option-inner"], children: g(o) }),
86
- t && /* @__PURE__ */ _(
87
- "div",
88
- {
89
- className: e["expand-button"],
90
- "data-testid": `expand-button-${o.id}`,
91
- onMouseDown: (d) => {
92
- d.stopPropagation(), l(o.id);
93
- },
94
- children: /* @__PURE__ */ _(
95
- w,
96
- {
97
- iconName: c === N.M ? "DropdownArrowBottom16px" : "DropdownArrowDown24px",
98
- className: a(e["expand-icon"], {
99
- [e["expand-icon-expanded"]]: p
100
- })
101
- }
102
- )
103
- }
104
- )
105
- ]
106
- }
107
- ),
108
- t && p && /* @__PURE__ */ _("div", { className: e["nested-children"], children: s(o.children, i + 1) })
109
- ] }, o.id);
110
- });
111
- return {
112
- toggleExpanded: l,
113
- renderNestedOptions: s
114
- };
115
- };
116
- export {
117
- e as c,
118
- X as u
119
- };