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,44 +1,68 @@
1
- import { useCallback as i, useMemo as c } from "react";
2
- import { flattenOptions as p } from "../utils.js";
3
- const L = ({
4
- filterOnSearch: s,
5
- items: r,
6
- internalSearchQuery: u,
7
- selectedItems: n,
8
- enableNestedSelection: f,
9
- displayValue: l
1
+ import { useCallback as M, useMemo as S } from "react";
2
+ import { flattenOptions as V } from "../utils.js";
3
+ const v = ({
4
+ filterOnSearch: h,
5
+ items: a,
6
+ internalSearchQuery: i,
7
+ selectedItems: l,
8
+ enableNestedSelection: u,
9
+ searchInNestedItems: d = !1,
10
+ displayValue: g,
11
+ groupBy: t,
12
+ searchInHeaderGroupItems: w = !1
10
13
  }) => {
11
- const e = i(
12
- (o) => {
13
- const t = o[l];
14
- return typeof t == "string" ? t : String(t || "");
14
+ const f = M(
15
+ (e) => {
16
+ const r = e[g];
17
+ return typeof r == "string" ? r : String(r || "");
15
18
  },
16
- [l]
19
+ [g]
17
20
  );
18
21
  return {
19
- filteredItems: c(() => {
20
- if (!s) return r;
21
- const o = u.toLowerCase();
22
- if (n.length > 0) {
23
- const t = n[n.length - 1];
24
- if (e(t).toLowerCase() === o)
25
- return r;
22
+ filteredItems: S(() => {
23
+ if (!h) return a;
24
+ const e = i.toLowerCase();
25
+ if (l.length > 0) {
26
+ const r = l[l.length - 1];
27
+ if (f(r).toLowerCase() === e)
28
+ return a;
26
29
  }
27
- return f ? p(r).filter(
28
- (a) => e(a).toLowerCase().includes(o)
29
- ) : r.filter(
30
- (t) => e(t).toLowerCase().includes(o)
30
+ if (u && d) {
31
+ const C = V(a).filter(
32
+ (o) => f(o).toLowerCase().includes(e)
33
+ ), n = new Set(C), c = (o) => {
34
+ o.forEach((s) => {
35
+ s.children && s.children.length > 0 && (s.children.some(
36
+ (L) => n.has(L)
37
+ ) && n.add(s), c(s.children));
38
+ });
39
+ };
40
+ return c(a), Array.from(n);
41
+ }
42
+ if (t && w) {
43
+ const r = /* @__PURE__ */ new Set();
44
+ return a.forEach((n) => {
45
+ t && n[t] && String(n[t]).toLowerCase().includes(e) && r.add(n), n.children && n.children.length > 0 && n.children.forEach((c) => {
46
+ t && c[t] && String(c[t]).toLowerCase().includes(e) && (r.add(c), r.add(n));
47
+ });
48
+ }), Array.from(r);
49
+ }
50
+ return a.filter(
51
+ (r) => f(r).toLowerCase().includes(e)
31
52
  );
32
53
  }, [
33
- s,
34
- r,
54
+ h,
55
+ a,
56
+ i,
57
+ l,
35
58
  u,
36
- n,
59
+ d,
37
60
  f,
38
- e
61
+ t,
62
+ w
39
63
  ])
40
64
  };
41
65
  };
42
66
  export {
43
- L as useSearch
67
+ v as useSearch
44
68
  };
@@ -14,6 +14,5 @@ export type TUseVirtualizationReturn = {
14
14
  virtualItems: TMultiSelectOption[];
15
15
  stickyIndices: number[];
16
16
  virtualizer: ReturnType<typeof useVirtualizer>;
17
- activeSticky: number | null;
18
17
  };
19
18
  export declare const useVirtualization: ({ filteredItems, groupBy, getGroupTitle, size, parentRef }: TUseVirtualizationProps) => TUseVirtualizationReturn;
@@ -1,59 +1,38 @@
1
- import { u as h } from "../../../index-D5H8gPPn.js";
2
- import { useState as p, useMemo as I, useEffect as z } from "react";
3
- import { EMultiSelectSearchSize as M } from "../constants.js";
4
- import { prepareGroupedItems as O } from "../utils.js";
5
- const T = 10, S = {
1
+ import { u as E } from "../../../index-D5H8gPPn.js";
2
+ import { useMemo as n } from "react";
3
+ import { EMultiSelectSearchSize as S } from "../constants.js";
4
+ import { prepareGroupedItems as f } from "../utils.js";
5
+ const z = 10, s = {
6
6
  M: 49,
7
7
  L: 65
8
- }, b = ({
9
- filteredItems: u,
10
- groupBy: e,
11
- getGroupTitle: f,
12
- size: x,
13
- parentRef: a
8
+ }, h = ({
9
+ filteredItems: e,
10
+ groupBy: o,
11
+ getGroupTitle: i,
12
+ size: c,
13
+ parentRef: u
14
14
  }) => {
15
- const [k, L] = p(null), r = I(() => e ? O(
16
- u,
15
+ const r = n(() => o ? f(
17
16
  e,
18
- f || ((t) => t)
19
- ) : u, [u, e, f]), n = I(() => {
17
+ o,
18
+ i || ((t) => t)
19
+ ) : e, [e, o, i]), a = n(() => {
20
20
  const t = [];
21
- return r.forEach((c, i) => {
22
- c.isGroupHeader && t.push(i);
21
+ return r.forEach((l, p) => {
22
+ l.isGroupHeader && t.push(p);
23
23
  }), t;
24
- }, [r]), s = h({
24
+ }, [r]), m = E({
25
25
  count: r.length,
26
- getScrollElement: () => a.current,
27
- estimateSize: () => x === M.L ? S.L : S.M,
28
- overscan: T
26
+ getScrollElement: () => u.current,
27
+ estimateSize: () => c === S.L ? s.L : s.M,
28
+ overscan: z
29
29
  });
30
- return z(() => {
31
- const t = a.current;
32
- if (!t || !e) return;
33
- const c = () => {
34
- var d, v;
35
- const i = t.scrollTop;
36
- let m = null;
37
- for (let o = 0; o < n.length; o++) {
38
- const E = n[o];
39
- if ((((d = s.getVirtualItems().find((l) => l.index === E)) == null ? void 0 : d.start) || 0) <= i) {
40
- m = E;
41
- const l = n[o + 1];
42
- if (l !== void 0 && (((v = s.getVirtualItems().find((V) => V.index === l)) == null ? void 0 : v.start) || 0) <= i)
43
- continue;
44
- } else
45
- break;
46
- }
47
- L(m);
48
- };
49
- return t.addEventListener("scroll", c), () => t.removeEventListener("scroll", c);
50
- }, [s, n, e, a.current]), {
30
+ return {
51
31
  virtualItems: r,
52
- stickyIndices: n,
53
- virtualizer: s,
54
- activeSticky: k
32
+ stickyIndices: a,
33
+ virtualizer: m
55
34
  };
56
35
  };
57
36
  export {
58
- b as useVirtualization
37
+ h as useVirtualization
59
38
  };
@@ -117,4 +117,19 @@ export type TMultiSelectSearchProps = Pick<TInputProps, 'withClearButton' | 'var
117
117
  * @default false
118
118
  */
119
119
  enableNestedSelection?: boolean;
120
+ /**
121
+ * Включить поиск во вложенных айтемах при enableNestedSelection = true
122
+ * @default false
123
+ */
124
+ searchInNestedItems?: boolean;
125
+ /**
126
+ * Использовать иконку вместо чекбокса для выбранных элементов
127
+ * @default false
128
+ */
129
+ useIconInsteadOfCheckbox?: boolean;
130
+ /**
131
+ * Включить поиск по хедерам группы вложенных элементов в режиме группировки
132
+ * @default false
133
+ */
134
+ searchInHeaderGroupItems?: boolean;
120
135
  };
@@ -32,4 +32,5 @@ export declare const SelectSearch: import('react').ForwardRefExoticComponent<Pic
32
32
  autoPlacement?: boolean;
33
33
  borderRadius?: ESelectSearchBorderRadius | `${ESelectSearchBorderRadius}`;
34
34
  highlightMatches?: boolean;
35
+ searchInHeaderGroupItems?: boolean;
35
36
  } & import('react').RefAttributes<HTMLElement>>;