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
@@ -1,79 +1,101 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { Chip as M } from "../../Chip/Chip.js";
3
- import { EChipSize as u } from "../../Chip/constants.js";
4
- import { EMultiSelectSearchSize as N } from "../constants.js";
5
- import { getSelectedChildrenCount as O, getAllChildrenIds as C, formatOptionWithCount as S, joinSelectedItems as R } from "../utils.js";
6
- const D = ({
7
- selectedItems: d,
8
- enableNestedSelection: e,
9
- size: m,
10
- chipVariant: E,
11
- items: j,
12
- displayValue: c,
13
- setSelectedItems: h,
14
- onChange: t,
15
- setInputValue: z
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { Chip as N } from "../../Chip/Chip.js";
3
+ import { EChipSize as E } from "../../Chip/constants.js";
4
+ import { EMultiSelectSearchSize as O } from "../constants.js";
5
+ import { getSelectedChildrenCount as R, getAllChildrenIds as j, formatOptionWithCount as w, joinSelectedItems as W } from "../utils.js";
6
+ const F = ({
7
+ selectedItems: c,
8
+ enableNestedSelection: l,
9
+ size: z,
10
+ chipVariant: A,
11
+ items: h,
12
+ displayValue: t,
13
+ setSelectedItems: p,
14
+ onChange: s,
15
+ setInputValue: a
16
16
  }) => {
17
- const P = (r, i) => r.children && r.children.length > 0 ? S(r, i, c) : r[c], l = (r) => {
18
- const i = r.map((n) => n.id), o = e ? r.map((n) => P(n, i)).join(", ") : R(r, c);
19
- z(o);
20
- }, v = (r) => {
21
- const i = d.filter(
22
- (o) => o.id !== r.id
17
+ const f = (r) => {
18
+ if (l) {
19
+ const o = /* @__PURE__ */ new Set();
20
+ for (const n of r)
21
+ if (n.children && n.children.length > 0)
22
+ o.add(n);
23
+ else {
24
+ const d = h.find(
25
+ (e) => {
26
+ var S;
27
+ return (S = e.children) == null ? void 0 : S.some((M) => M.id === n.id);
28
+ }
29
+ );
30
+ d ? o.add(d) : o.add(n);
31
+ }
32
+ const i = Array.from(o).map(
33
+ (n) => w(
34
+ n,
35
+ r.map((d) => d.id),
36
+ t
37
+ )
38
+ ).join(", ");
39
+ a(i);
40
+ } else
41
+ a(W(r, t));
42
+ }, P = (r) => {
43
+ const o = c.filter(
44
+ (i) => i.id !== r.id
23
45
  );
24
- h(i), t == null || t(i), l(i);
25
- }, w = (r) => {
26
- const i = C(r), o = [r.id, ...i], n = d.filter((s) => !o.includes(s.id));
27
- h(n), t == null || t(n), l(n);
46
+ p(o), s == null || s(o), f(o);
47
+ }, v = (r) => {
48
+ const o = j(r), i = [r.id, ...o], n = c.filter((d) => !i.includes(d.id));
49
+ p(n), s == null || s(n), f(n);
28
50
  }, x = (r) => ({
29
51
  id: r.id,
30
- name: S(
52
+ name: w(
31
53
  r,
32
- d.map((i) => i.id),
33
- c
54
+ c.map((o) => o.id),
55
+ t
34
56
  ),
35
- onClose: () => w(r)
36
- }), p = (r) => ({
37
- id: r.id,
38
- name: String(r[c] || ""),
39
57
  onClose: () => v(r)
40
- }), A = (r) => j.some(
41
- (i) => {
42
- var o;
43
- return (o = i.children) == null ? void 0 : o.some((n) => n.id === r.id);
58
+ }), u = (r) => ({
59
+ id: r.id,
60
+ name: String(r[t] || ""),
61
+ onClose: () => P(r)
62
+ }), L = (r) => h.some(
63
+ (o) => {
64
+ var i;
65
+ return (i = o.children) == null ? void 0 : i.some((n) => n.id === r.id);
44
66
  }
45
- ), a = (r) => /* @__PURE__ */ f(
46
- M,
67
+ ), C = (r) => /* @__PURE__ */ m(
68
+ N,
47
69
  {
48
- size: m === N.L ? u.S : u.XS,
49
- variant: E,
70
+ size: z === O.L ? E.S : E.XS,
71
+ variant: A,
50
72
  className: "chip-root",
51
73
  withAction: !0,
52
74
  onClose: r.onClose,
53
- children: /* @__PURE__ */ f("span", { className: "chip", children: r.name })
75
+ children: /* @__PURE__ */ m("span", { className: "chip", children: r.name })
54
76
  },
55
77
  r.id
56
78
  );
57
- if (!d.length)
79
+ if (!c.length)
58
80
  return null;
59
- if (e) {
60
- const r = /* @__PURE__ */ new Set(), i = [];
61
- return d.forEach((o) => {
62
- if (!r.has(o.id))
63
- if (o.children && o.children.length > 0) {
64
- if (O(
65
- o,
66
- d.map((s) => s.id)
81
+ if (l) {
82
+ const r = /* @__PURE__ */ new Set(), o = [];
83
+ return c.forEach((i) => {
84
+ if (!r.has(i.id))
85
+ if (i.children && i.children.length > 0) {
86
+ if (R(
87
+ i,
88
+ c.map((d) => d.id)
67
89
  ) > 0) {
68
- i.push(x(o));
69
- const s = C(o);
70
- r.add(o.id), s.forEach((L) => r.add(L));
90
+ o.push(x(i));
91
+ const d = j(i);
92
+ r.add(i.id), d.forEach((e) => r.add(e));
71
93
  }
72
- } else A(o) || (i.push(p(o)), r.add(o.id));
73
- }), i.map(a);
94
+ } else L(i) || (o.push(u(i)), r.add(i.id));
95
+ }), o.map(C);
74
96
  }
75
- return d.map((r) => a(p(r)));
97
+ return c.map((r) => C(u(r)));
76
98
  };
77
99
  export {
78
- D as useChips
100
+ F as useChips
79
101
  };
@@ -11,13 +11,16 @@ type TUseNestedSelectionProps = {
11
11
  classNameOption?: string;
12
12
  items: TMultiSelectOption[];
13
13
  enableNestedSelection: boolean;
14
- highlightMatches: boolean;
14
+ searchInNestedItems?: boolean;
15
15
  internalSearchQuery: string;
16
+ highlightMatches: boolean;
16
17
  renderOptionContent: (item: TMultiSelectOption) => ReactNode;
18
+ groupBy?: string;
19
+ useIconInsteadOfCheckbox?: boolean;
17
20
  };
18
21
  type TUseNestedSelectionReturn = {
19
22
  toggleExpanded: (optionId: string | number) => void;
20
23
  renderNestedOptions: (options: TMultiSelectOption[], level?: number) => ReactNode[];
21
24
  };
22
- export declare const useNestedSelection: ({ filteredItems, selectedItems, expandedOptions, setExpandedOptions, size, classNameOption, items, renderOptionContent }: TUseNestedSelectionProps) => TUseNestedSelectionReturn;
25
+ export declare const useNestedSelection: ({ filteredItems, selectedItems, expandedOptions, setExpandedOptions, size, classNameOption, items, enableNestedSelection, searchInNestedItems, internalSearchQuery, renderOptionContent, groupBy, useIconInsteadOfCheckbox }: TUseNestedSelectionProps) => TUseNestedSelectionReturn;
23
26
  export {};
@@ -1,11 +1,12 @@
1
1
  import "react/jsx-runtime";
2
2
  import "../../../index-DIxK0V-G.js";
3
+ import "react";
3
4
  import "../../../icons/Icon.js";
4
5
  import "../../CheckboxMimir/CheckboxMimir.js";
5
6
  import "../constants.js";
6
- import { u as a } from "../../../useNestedSelection-DnuUbEqM.js";
7
+ import { u as c } from "../../../useNestedSelection-bo9wXvE-.js";
7
8
  import "../utils.js";
8
9
  import "../../../combobox-fIVOzEhl.js";
9
10
  export {
10
- a as useNestedSelection
11
+ c as useNestedSelection
11
12
  };
@@ -15,13 +15,16 @@ type TUseRenderVirtualizedListProps = {
15
15
  renderNestedOptions: (items: TMultiSelectOption[]) => ReactNode;
16
16
  groupBy?: string;
17
17
  parentRef: RefObject<HTMLDivElement>;
18
- activeSticky: number | null;
19
18
  virtualItems: TMultiSelectOption[];
20
19
  virtualizer: ReturnType<typeof useVirtualizer>;
21
20
  classNameOption?: string;
22
21
  selectedItems: TMultiSelectOption[];
23
22
  renderOptionContent: (item: TMultiSelectOption) => ReactNode;
24
23
  cls: Record<string, string>;
24
+ useIconInsteadOfCheckbox?: boolean;
25
+ highlightMatches?: boolean;
26
+ internalSearchQuery?: string;
27
+ searchInHeaderGroupItems?: boolean;
25
28
  };
26
- export declare const useRenderVirtualizedList: ({ items, filteredItems, size, actualMenuPlacement, isVisible, noOptionsText, noMatchText, enableNestedSelection, renderNestedOptions, groupBy, parentRef, activeSticky, virtualItems, virtualizer, classNameOption, selectedItems, renderOptionContent, cls }: TUseRenderVirtualizedListProps) => () => ReactNode;
29
+ export declare const useRenderVirtualizedList: ({ items, filteredItems, size, actualMenuPlacement, isVisible, noOptionsText, noMatchText, enableNestedSelection, renderNestedOptions, groupBy, parentRef, virtualItems, virtualizer, classNameOption, selectedItems, renderOptionContent, cls, useIconInsteadOfCheckbox, highlightMatches, internalSearchQuery, searchInHeaderGroupItems }: TUseRenderVirtualizedListProps) => () => ReactNode;
27
30
  export {};
@@ -1,106 +1,108 @@
1
- import { jsx as t, jsxs as u, Fragment as j } from "react/jsx-runtime";
2
- import { c as m } from "../../../index-DIxK0V-G.js";
3
- import { CheckboxMimir as k } from "../../CheckboxMimir/CheckboxMimir.js";
4
- import { W as G, K } from "../../../combobox-fIVOzEhl.js";
5
- const W = (n, a, r, d, e) => /* @__PURE__ */ t(
1
+ import { jsx as n, jsxs as $, Fragment as D } from "react/jsx-runtime";
2
+ import { c } from "../../../index-DIxK0V-G.js";
3
+ import { Icon as k } from "../../../icons/Icon.js";
4
+ import { CheckboxMimir as b } from "../../CheckboxMimir/CheckboxMimir.js";
5
+ import { EMultiSelectSearchSize as j } from "../constants.js";
6
+ import { highlightReactNode as I } from "../utils.js";
7
+ import { W as E, K } from "../../../combobox-fIVOzEhl.js";
8
+ const W = (i, a, o, r, e) => /* @__PURE__ */ n(
6
9
  "div",
7
10
  {
8
- className: m(
11
+ className: c(
9
12
  e.options,
10
- e[n],
13
+ e[i],
11
14
  e["no-options"],
12
15
  e[a],
13
- { [e.visible]: r }
16
+ { [e.visible]: o }
14
17
  ),
15
- children: d
18
+ children: r
16
19
  }
17
- ), y = (n, a, r, d, e) => /* @__PURE__ */ t(
20
+ ), w = (i, a, o, r, e) => /* @__PURE__ */ n(
18
21
  "div",
19
22
  {
20
- className: m(
23
+ className: c(
21
24
  e.options,
22
- e[n],
25
+ e[i],
23
26
  e["no-options"],
24
27
  e[a],
25
- { [e.visible]: r }
28
+ { [e.visible]: o }
26
29
  ),
27
- children: d
30
+ children: r
28
31
  }
29
- ), E = (n, a, r, d, e, p) => /* @__PURE__ */ t(
32
+ ), F = (i, a, o, r, e, p) => /* @__PURE__ */ n(
30
33
  "div",
31
34
  {
32
- className: m(p.options, p[n], p[a], {
33
- [p.visible]: r
35
+ className: c(p.options, p[i], p[a], {
36
+ [p.visible]: o
34
37
  }),
35
- children: e(d)
38
+ children: e(r)
36
39
  }
37
- ), F = (n, a, r, d, e, p, o, s, f, x, i) => /* @__PURE__ */ u(
38
- "div",
39
- {
40
- ref: d,
41
- className: m(
42
- i.options,
43
- i[n],
44
- i[a],
45
- i["options-container"],
46
- { [i.visible]: r }
47
- ),
48
- children: [
49
- e !== null && /* @__PURE__ */ t(
50
- "div",
51
- {
52
- className: m(i["group-header"], i.sticky),
53
- "data-testid": `group-header-${p[e].name}`,
54
- children: p[e].name
55
- }
40
+ ), H = (i, a, o, r, e, p, d, N, v, t, m, f, x, g, l) => {
41
+ const u = new Set(N.map((s) => s.id));
42
+ return /* @__PURE__ */ n(
43
+ "div",
44
+ {
45
+ ref: r,
46
+ className: c(
47
+ t.options,
48
+ t[i],
49
+ t[a],
50
+ t["options-container"],
51
+ { [t.visible]: o }
56
52
  ),
57
- /* @__PURE__ */ t(
53
+ children: /* @__PURE__ */ n(
58
54
  "div",
59
55
  {
60
56
  style: {
61
- height: `${o.getTotalSize()}px`,
57
+ height: `${p.getTotalSize()}px`,
62
58
  width: "100%"
63
59
  },
64
- children: o.getVirtualItems().map((N) => {
65
- const h = p[N.index];
66
- return /* @__PURE__ */ t(
60
+ children: p.getVirtualItems().map((s) => {
61
+ const h = e[s.index], S = u.has(h.id);
62
+ return /* @__PURE__ */ n(
67
63
  "div",
68
64
  {
69
- "data-index": N.index,
70
- ref: o.measureElement,
65
+ "data-index": s.index,
66
+ ref: p.measureElement,
71
67
  style: {
72
68
  position: "absolute",
73
69
  top: 0,
74
70
  left: 0,
75
71
  width: "100%",
76
- transform: `translateY(${N.start}px)`
72
+ transform: `translateY(${s.start}px)`
77
73
  },
78
- children: h.isGroupHeader ? /* @__PURE__ */ t(
74
+ children: h.isGroupHeader ? /* @__PURE__ */ n(
79
75
  "div",
80
76
  {
81
- className: m(i["group-header"], {
82
- [i.hidden]: e === N.index
83
- }),
77
+ className: t["group-header"],
84
78
  "data-testid": `group-header-${h.name}`,
85
- children: h.name
79
+ children: x && g && l ? I(
80
+ h.name,
81
+ g,
82
+ t["highlighted-text"]
83
+ ) : h.name
86
84
  }
87
- ) : /* @__PURE__ */ t(
88
- G,
85
+ ) : /* @__PURE__ */ n(
86
+ E,
89
87
  {
90
88
  value: h,
91
- className: ({ focus: g }) => m(i.option, s, n && i[n], {
92
- [i["option-active"]]: g
89
+ className: ({ focus: L }) => c(t.option, d, i && t[i], {
90
+ [t["option-active"]]: L && !m
93
91
  }),
94
92
  "data-testid": `option-${h.id}`,
95
- children: /* @__PURE__ */ u(j, { children: [
96
- /* @__PURE__ */ t("div", { className: i["option-inner"], children: x(h) }),
97
- /* @__PURE__ */ t(
93
+ children: /* @__PURE__ */ $(D, { children: [
94
+ /* @__PURE__ */ n("div", { className: t["option-inner"], children: v(h) }),
95
+ f ? S && /* @__PURE__ */ n(
98
96
  k,
97
+ {
98
+ iconName: i === j.L ? "Done24px" : "Done16px",
99
+ className: t["selected-icon"]
100
+ }
101
+ ) : /* @__PURE__ */ n(
102
+ b,
99
103
  {
100
104
  isInteractive: !1,
101
- checked: f.some(
102
- (g) => g.id === h.id
103
- )
105
+ checked: S
104
106
  }
105
107
  )
106
108
  ] })
@@ -108,104 +110,117 @@ const W = (n, a, r, d, e) => /* @__PURE__ */ t(
108
110
  h.id
109
111
  )
110
112
  },
111
- N.key
113
+ s.key
112
114
  );
113
115
  })
114
116
  }
115
117
  )
116
- ]
117
- }
118
- ), H = (n, a, r, d, e, p, o) => /* @__PURE__ */ t(
119
- K,
120
- {
121
- className: m(o.options, o[n], o[a], {
122
- [o.visible]: r
123
- }),
124
- modal: !1,
125
- static: !0,
126
- children: ({ option: s }) => /* @__PURE__ */ t(
127
- G,
128
- {
129
- value: s,
130
- className: ({ focus: f }) => m(o.option, d, n && o[n], {
131
- [o["option-active"]]: f
132
- }),
133
- "data-testid": `option-${s.id}`,
134
- children: /* @__PURE__ */ u(j, { children: [
135
- /* @__PURE__ */ t("div", { className: o["option-inner"], children: p(s) }),
136
- /* @__PURE__ */ t(
137
- k,
138
- {
139
- isInteractive: !1,
140
- checked: e.some(
141
- (f) => f.id === s.id
142
- )
143
- }
144
- )
145
- ] })
146
- },
147
- s.id
148
- )
149
- }
150
- ), C = ({
151
- items: n,
118
+ }
119
+ );
120
+ }, T = (i, a, o, r, e, p, d, N, v) => {
121
+ const t = new Set(e.map((m) => m.id));
122
+ return /* @__PURE__ */ n(
123
+ K,
124
+ {
125
+ className: c(d.options, d[i], d[a], {
126
+ [d.visible]: o
127
+ }),
128
+ modal: !1,
129
+ static: !0,
130
+ children: ({ option: m }) => {
131
+ const f = t.has(m.id);
132
+ return /* @__PURE__ */ n(
133
+ E,
134
+ {
135
+ value: m,
136
+ className: ({ focus: x }) => c(d.option, r, i && d[i], {
137
+ [d["option-active"]]: x && !N
138
+ }),
139
+ "data-testid": `option-${m.id}`,
140
+ children: /* @__PURE__ */ $(D, { children: [
141
+ /* @__PURE__ */ n("div", { className: d["option-inner"], children: p(m) }),
142
+ v ? f && /* @__PURE__ */ n(
143
+ k,
144
+ {
145
+ iconName: i === j.L ? "Done24px" : "Done16px",
146
+ className: d["selected-icon"]
147
+ }
148
+ ) : /* @__PURE__ */ n(b, { isInteractive: !1, checked: f })
149
+ ] })
150
+ },
151
+ m.id
152
+ );
153
+ }
154
+ }
155
+ );
156
+ }, Z = ({
157
+ items: i,
152
158
  filteredItems: a,
153
- size: r,
154
- actualMenuPlacement: d,
159
+ size: o,
160
+ actualMenuPlacement: r,
155
161
  isVisible: e,
156
162
  noOptionsText: p,
157
- noMatchText: o,
158
- enableNestedSelection: s,
159
- renderNestedOptions: f,
160
- groupBy: x,
161
- parentRef: i,
162
- activeSticky: N,
163
- virtualItems: h,
164
- virtualizer: g,
165
- classNameOption: $,
166
- selectedItems: b,
167
- renderOptionContent: L,
168
- cls: v
169
- }) => () => n.length ? a.length ? s ? E(
163
+ noMatchText: d,
164
+ enableNestedSelection: N,
165
+ renderNestedOptions: v,
166
+ groupBy: t,
167
+ parentRef: m,
168
+ virtualItems: f,
169
+ virtualizer: x,
170
+ classNameOption: g,
171
+ selectedItems: l,
172
+ renderOptionContent: u,
173
+ cls: s,
174
+ useIconInsteadOfCheckbox: h = !1,
175
+ highlightMatches: S = !1,
176
+ internalSearchQuery: L,
177
+ searchInHeaderGroupItems: G = !1
178
+ }) => () => i.length ? a.length ? N ? F(
179
+ o,
170
180
  r,
171
- d,
172
181
  e,
173
182
  a,
174
- f,
175
- v
176
- ) : x ? F(
183
+ v,
184
+ s
185
+ ) : t ? H(
186
+ o,
177
187
  r,
178
- d,
179
188
  e,
180
- i,
181
- N,
182
- h,
189
+ m,
190
+ f,
191
+ x,
183
192
  g,
184
- $,
185
- b,
193
+ l,
194
+ u,
195
+ s,
196
+ t,
197
+ h,
198
+ S,
186
199
  L,
187
- v
188
- ) : H(
200
+ G
201
+ ) : T(
202
+ o,
189
203
  r,
190
- d,
191
204
  e,
192
- $,
193
- b,
194
- L,
195
- v
196
- ) : y(
205
+ g,
206
+ l,
207
+ u,
208
+ s,
209
+ t,
210
+ h
211
+ ) : w(
212
+ o,
197
213
  r,
198
- d,
199
214
  e,
200
- o,
201
- v
215
+ d,
216
+ s
202
217
  ) : W(
218
+ o,
203
219
  r,
204
- d,
205
220
  e,
206
221
  p,
207
- v
222
+ s
208
223
  );
209
224
  export {
210
- C as useRenderVirtualizedList
225
+ Z as useRenderVirtualizedList
211
226
  };
@@ -6,9 +6,12 @@ export type TUseSearchProps = {
6
6
  internalSearchQuery: string;
7
7
  selectedItems: TMultiSelectOption[];
8
8
  enableNestedSelection: boolean;
9
+ searchInNestedItems?: boolean;
9
10
  displayValue: string;
11
+ groupBy?: string;
12
+ searchInHeaderGroupItems?: boolean;
10
13
  };
11
14
  export type TUseSearchReturn = {
12
15
  filteredItems: TMultiSelectOption[];
13
16
  };
14
- export declare const useSearch: ({ filterOnSearch, items, internalSearchQuery, selectedItems, enableNestedSelection, displayValue }: TUseSearchProps) => TUseSearchReturn;
17
+ export declare const useSearch: ({ filterOnSearch, items, internalSearchQuery, selectedItems, enableNestedSelection, searchInNestedItems, displayValue, groupBy, searchInHeaderGroupItems }: TUseSearchProps) => TUseSearchReturn;