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.
- package/dist/assets/CheckboxMimir.css +1 -1
 - package/dist/assets/SelectSearch.css +1 -1
 - package/dist/assets/useNestedSelection.css +1 -1
 - package/dist/components/CheckboxMimir/CheckboxMimir.d.ts +2 -0
 - package/dist/components/CheckboxMimir/CheckboxMimir.js +42 -41
 - package/dist/components/MultiSelectSearch/MultiSelectSearch.d.ts +3 -0
 - package/dist/components/MultiSelectSearch/MultiSelectSearch.js +260 -245
 - package/dist/components/MultiSelectSearch/hooks/useChips.js +79 -57
 - package/dist/components/MultiSelectSearch/hooks/useNestedSelection.d.ts +5 -2
 - package/dist/components/MultiSelectSearch/hooks/useNestedSelection.js +3 -2
 - package/dist/components/MultiSelectSearch/hooks/useRenderVirtualizedList.d.ts +5 -2
 - package/dist/components/MultiSelectSearch/hooks/useRenderVirtualizedList.js +151 -136
 - package/dist/components/MultiSelectSearch/hooks/useSearch.d.ts +4 -1
 - package/dist/components/MultiSelectSearch/hooks/useSearch.js +54 -30
 - package/dist/components/MultiSelectSearch/hooks/useVirtualization.d.ts +0 -1
 - package/dist/components/MultiSelectSearch/hooks/useVirtualization.js +25 -46
 - package/dist/components/MultiSelectSearch/types.d.ts +15 -0
 - package/dist/components/SelectSearch/SelectSearch.d.ts +1 -0
 - package/dist/components/SelectSearch/SelectSearch.js +304 -324
 - package/dist/components/SelectSearch/types.d.ts +5 -0
 - package/dist/components/SelectSearch/utils.js +18 -17
 - package/dist/useNestedSelection-bo9wXvE-.js +181 -0
 - package/package.json +1 -1
 - package/dist/useNestedSelection-DnuUbEqM.js +0 -119
 
| 
         @@ -1,44 +1,68 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import { useCallback as  
     | 
| 
       2 
     | 
    
         
            -
            import { flattenOptions as  
     | 
| 
       3 
     | 
    
         
            -
            const  
     | 
| 
       4 
     | 
    
         
            -
              filterOnSearch:  
     | 
| 
       5 
     | 
    
         
            -
              items:  
     | 
| 
       6 
     | 
    
         
            -
              internalSearchQuery:  
     | 
| 
       7 
     | 
    
         
            -
              selectedItems:  
     | 
| 
       8 
     | 
    
         
            -
              enableNestedSelection:  
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
      
 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  
     | 
| 
       12 
     | 
    
         
            -
                ( 
     | 
| 
       13 
     | 
    
         
            -
                  const  
     | 
| 
       14 
     | 
    
         
            -
                  return typeof  
     | 
| 
      
 14 
     | 
    
         
            +
              const f = M(
         
     | 
| 
      
 15 
     | 
    
         
            +
                (e) => {
         
     | 
| 
      
 16 
     | 
    
         
            +
                  const r = e[g];
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return typeof r == "string" ? r : String(r || "");
         
     | 
| 
       15 
18 
     | 
    
         
             
                },
         
     | 
| 
       16 
     | 
    
         
            -
                [ 
     | 
| 
      
 19 
     | 
    
         
            +
                [g]
         
     | 
| 
       17 
20 
     | 
    
         
             
              );
         
     | 
| 
       18 
21 
     | 
    
         
             
              return {
         
     | 
| 
       19 
     | 
    
         
            -
                filteredItems:  
     | 
| 
       20 
     | 
    
         
            -
                  if (! 
     | 
| 
       21 
     | 
    
         
            -
                  const  
     | 
| 
       22 
     | 
    
         
            -
                  if ( 
     | 
| 
       23 
     | 
    
         
            -
                    const  
     | 
| 
       24 
     | 
    
         
            -
                    if ( 
     | 
| 
       25 
     | 
    
         
            -
                      return  
     | 
| 
      
 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 
     | 
    
         
            -
                   
     | 
| 
       28 
     | 
    
         
            -
                     
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                     
     | 
| 
      
 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 
     | 
    
         
            -
                   
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
      
 54 
     | 
    
         
            +
                  h,
         
     | 
| 
      
 55 
     | 
    
         
            +
                  a,
         
     | 
| 
      
 56 
     | 
    
         
            +
                  i,
         
     | 
| 
      
 57 
     | 
    
         
            +
                  l,
         
     | 
| 
       35 
58 
     | 
    
         
             
                  u,
         
     | 
| 
       36 
     | 
    
         
            -
                   
     | 
| 
      
 59 
     | 
    
         
            +
                  d,
         
     | 
| 
       37 
60 
     | 
    
         
             
                  f,
         
     | 
| 
       38 
     | 
    
         
            -
                   
     | 
| 
      
 61 
     | 
    
         
            +
                  t,
         
     | 
| 
      
 62 
     | 
    
         
            +
                  w
         
     | 
| 
       39 
63 
     | 
    
         
             
                ])
         
     | 
| 
       40 
64 
     | 
    
         
             
              };
         
     | 
| 
       41 
65 
     | 
    
         
             
            };
         
     | 
| 
       42 
66 
     | 
    
         
             
            export {
         
     | 
| 
       43 
     | 
    
         
            -
               
     | 
| 
      
 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  
     | 
| 
       2 
     | 
    
         
            -
            import {  
     | 
| 
       3 
     | 
    
         
            -
            import { EMultiSelectSearchSize as  
     | 
| 
       4 
     | 
    
         
            -
            import { prepareGroupedItems as  
     | 
| 
       5 
     | 
    
         
            -
            const  
     | 
| 
      
 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 
     | 
    
         
            -
            },  
     | 
| 
       9 
     | 
    
         
            -
              filteredItems:  
     | 
| 
       10 
     | 
    
         
            -
              groupBy:  
     | 
| 
       11 
     | 
    
         
            -
              getGroupTitle:  
     | 
| 
       12 
     | 
    
         
            -
              size:  
     | 
| 
       13 
     | 
    
         
            -
              parentRef:  
     | 
| 
      
 8 
     | 
    
         
            +
            }, h = ({
         
     | 
| 
      
 9 
     | 
    
         
            +
              filteredItems: e,
         
     | 
| 
      
 10 
     | 
    
         
            +
              groupBy: o,
         
     | 
| 
      
 11 
     | 
    
         
            +
              getGroupTitle: i,
         
     | 
| 
      
 12 
     | 
    
         
            +
              size: c,
         
     | 
| 
      
 13 
     | 
    
         
            +
              parentRef: u
         
     | 
| 
       14 
14 
     | 
    
         
             
            }) => {
         
     | 
| 
       15 
     | 
    
         
            -
              const  
     | 
| 
       16 
     | 
    
         
            -
                u,
         
     | 
| 
      
 15 
     | 
    
         
            +
              const r = n(() => o ? f(
         
     | 
| 
       17 
16 
     | 
    
         
             
                e,
         
     | 
| 
       18 
     | 
    
         
            -
                 
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
                o,
         
     | 
| 
      
 18 
     | 
    
         
            +
                i || ((t) => t)
         
     | 
| 
      
 19 
     | 
    
         
            +
              ) : e, [e, o, i]), a = n(() => {
         
     | 
| 
       20 
20 
     | 
    
         
             
                const t = [];
         
     | 
| 
       21 
     | 
    
         
            -
                return r.forEach(( 
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
      
 21 
     | 
    
         
            +
                return r.forEach((l, p) => {
         
     | 
| 
      
 22 
     | 
    
         
            +
                  l.isGroupHeader && t.push(p);
         
     | 
| 
       23 
23 
     | 
    
         
             
                }), t;
         
     | 
| 
       24 
     | 
    
         
            -
              }, [r]),  
     | 
| 
      
 24 
     | 
    
         
            +
              }, [r]), m = E({
         
     | 
| 
       25 
25 
     | 
    
         
             
                count: r.length,
         
     | 
| 
       26 
     | 
    
         
            -
                getScrollElement: () =>  
     | 
| 
       27 
     | 
    
         
            -
                estimateSize: () =>  
     | 
| 
       28 
     | 
    
         
            -
                overscan:  
     | 
| 
      
 26 
     | 
    
         
            +
                getScrollElement: () => u.current,
         
     | 
| 
      
 27 
     | 
    
         
            +
                estimateSize: () => c === S.L ? s.L : s.M,
         
     | 
| 
      
 28 
     | 
    
         
            +
                overscan: z
         
     | 
| 
       29 
29 
     | 
    
         
             
              });
         
     | 
| 
       30 
     | 
    
         
            -
              return  
     | 
| 
       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:  
     | 
| 
       53 
     | 
    
         
            -
                virtualizer:  
     | 
| 
       54 
     | 
    
         
            -
                activeSticky: k
         
     | 
| 
      
 32 
     | 
    
         
            +
                stickyIndices: a,
         
     | 
| 
      
 33 
     | 
    
         
            +
                virtualizer: m
         
     | 
| 
       55 
34 
     | 
    
         
             
              };
         
     | 
| 
       56 
35 
     | 
    
         
             
            };
         
     | 
| 
       57 
36 
     | 
    
         
             
            export {
         
     | 
| 
       58 
     | 
    
         
            -
               
     | 
| 
      
 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>>;
         
     |