@himanshu-sorathiya/react-kit 1.0.20 → 1.0.21
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/events2.js +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/performance2.js +55 -55
- package/dist/state.d.ts +8 -8
- package/dist/state2.js +193 -191
- package/dist/ui.d.ts +5 -5
- package/dist/ui2.js +177 -177
- package/package.json +1 -1
package/dist/events2.js
CHANGED
|
@@ -16,7 +16,7 @@ function i(i, a, { enabled: o = !0, preventDefault: s = !0, stopPropagation: c =
|
|
|
16
16
|
}, [o]), e(() => {
|
|
17
17
|
let e = g && "current" in g ? g.current : g;
|
|
18
18
|
if (!e) return;
|
|
19
|
-
let t = i.toLowerCase(), n = r.includes(l) ? l : "keydown", a = u && n !== "keyup";
|
|
19
|
+
let t = String(i || "").toLowerCase(), n = r.includes(l) ? l : "keydown", a = u && n !== "keyup";
|
|
20
20
|
function o() {
|
|
21
21
|
y.current = !1;
|
|
22
22
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -361,7 +361,7 @@ export interface UseFilterReturn<T> {
|
|
|
361
361
|
updateFilterValue: (id: string, value: unknown) => void;
|
|
362
362
|
isFilterActive: (id: string) => boolean;
|
|
363
363
|
}
|
|
364
|
-
export declare function useFilter<T>(data
|
|
364
|
+
export declare function useFilter<T>(data?: T[], initialFilters?: FilterState<T>): UseFilterReturn<T>;
|
|
365
365
|
export interface FuzzySearchOptions {
|
|
366
366
|
threshold?: number;
|
|
367
367
|
caseSensitive?: boolean;
|
|
@@ -404,8 +404,8 @@ export interface UseGroupingReturn<T> {
|
|
|
404
404
|
resetGrouping: () => void;
|
|
405
405
|
getGroupItems: (groupKey: string) => T[];
|
|
406
406
|
}
|
|
407
|
-
export declare function useGrouping<T = unknown>(
|
|
408
|
-
items
|
|
407
|
+
export declare function useGrouping<T = unknown>(options?: {
|
|
408
|
+
items?: T[];
|
|
409
409
|
initialGroupBy?: string;
|
|
410
410
|
}): UseGroupingReturn<T>;
|
|
411
411
|
export type SelectionId = string | number;
|
|
@@ -428,8 +428,8 @@ export interface UseMultipleSelectionReturn<T> {
|
|
|
428
428
|
deselectMultiple: (itemsToRemove: SelectionId[] | T[]) => void;
|
|
429
429
|
retainOnly: (itemsToRetain: SelectionId[] | T[]) => void;
|
|
430
430
|
}
|
|
431
|
-
export declare function useMultipleSelection<T = unknown>(
|
|
432
|
-
items
|
|
431
|
+
export declare function useMultipleSelection<T = unknown>(options?: {
|
|
432
|
+
items?: T[];
|
|
433
433
|
field?: string;
|
|
434
434
|
initialSelectedIds?: SelectionId[];
|
|
435
435
|
}): UseMultipleSelectionReturn<T>;
|
|
@@ -446,7 +446,7 @@ export interface UseOrderReturn<T> {
|
|
|
446
446
|
resetOrder: () => void;
|
|
447
447
|
replaceOrder: (newOrderedItems: T[]) => void;
|
|
448
448
|
}
|
|
449
|
-
export declare function useOrder<T>(initialItems
|
|
449
|
+
export declare function useOrder<T>(initialItems?: T[]): UseOrderReturn<T>;
|
|
450
450
|
export interface UsePaginationReturn<T> {
|
|
451
451
|
pageItems: T[];
|
|
452
452
|
pageSize: number;
|
|
@@ -464,7 +464,7 @@ export interface UsePaginationReturn<T> {
|
|
|
464
464
|
resetPageSize: () => void;
|
|
465
465
|
resetPagination: () => void;
|
|
466
466
|
}
|
|
467
|
-
export declare function usePagination<T>(data: T[], initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
|
|
467
|
+
export declare function usePagination<T>(data: T[] | undefined, initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
|
|
468
468
|
type SelectionId$1 = string | number;
|
|
469
469
|
export interface UseSingleSelectionReturn {
|
|
470
470
|
selectedId: SelectionId$1 | undefined;
|
|
@@ -516,7 +516,7 @@ export interface UseSortReturn<T> {
|
|
|
516
516
|
getNextSortingOrder: (id: string) => "asc" | "desc" | "none";
|
|
517
517
|
getSortIndex: (id: string) => number | undefined;
|
|
518
518
|
}
|
|
519
|
-
export declare function useSort<T>(data
|
|
519
|
+
export declare function useSort<T>(data?: T[], initialSorts?: SortState): UseSortReturn<T>;
|
|
520
520
|
export interface FuzzyHighlighterProps {
|
|
521
521
|
text: string;
|
|
522
522
|
query: string;
|
|
@@ -546,7 +546,7 @@ export interface UseExpansionReturn<T> {
|
|
|
546
546
|
resetExpansion: () => void;
|
|
547
547
|
replaceExpansion: (newExpandedItems: ExpansionId[] | T[]) => void;
|
|
548
548
|
}
|
|
549
|
-
export declare function useExpansion<T = unknown>(
|
|
549
|
+
export declare function useExpansion<T = unknown>(options?: {
|
|
550
550
|
items?: T[];
|
|
551
551
|
field?: string;
|
|
552
552
|
initialExpandedIds?: ExpansionId[];
|
|
@@ -584,8 +584,8 @@ export interface UsePinReturn<T> {
|
|
|
584
584
|
pinMultiple: (newItems: PinId[] | T[]) => void;
|
|
585
585
|
unpinMultiple: (itemsToRemove: PinId[] | T[]) => void;
|
|
586
586
|
}
|
|
587
|
-
export declare function usePin<T = unknown>(
|
|
588
|
-
items
|
|
587
|
+
export declare function usePin<T = unknown>(options?: {
|
|
588
|
+
items?: T[];
|
|
589
589
|
field?: string;
|
|
590
590
|
initialPinnedIds?: PinId[];
|
|
591
591
|
maxPins?: number;
|
|
@@ -605,8 +605,8 @@ export interface UseVisibilityReturn<T> {
|
|
|
605
605
|
resetVisibility: () => void;
|
|
606
606
|
replaceVisibility: (newVisibleItems: VisibilityId[] | T[]) => void;
|
|
607
607
|
}
|
|
608
|
-
export declare function useVisibility<T = unknown>(
|
|
609
|
-
items
|
|
608
|
+
export declare function useVisibility<T = unknown>(options?: {
|
|
609
|
+
items?: T[];
|
|
610
610
|
field?: string;
|
|
611
611
|
initialVisibleIds?: VisibilityId[];
|
|
612
612
|
}): UseVisibilityReturn<T>;
|
package/dist/performance2.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
2
2
|
//#region src/performance/useDebounce/useDebounce.ts
|
|
3
3
|
function i(i, a = {}) {
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
}, []),
|
|
7
|
-
|
|
4
|
+
let o = Math.max(0, Number(i) || 0), [s, c] = r(!1), l = a?.maxWait, u = !!a?.leading, d = !u && a?.trailing === !1 ? !0 : a?.trailing ?? !u, f = n(null), p = n(null), m = n(null), h = n(-1), g = n(-1), _ = e(() => {
|
|
5
|
+
m.current &&= (clearTimeout(m.current), null), h.current = -1, g.current = -1, p.current = null, f.current = null, c(!1);
|
|
6
|
+
}, []), v = e(() => {
|
|
7
|
+
m.current && f.current && p.current && (clearTimeout(m.current), m.current = null, f.current(...p.current), h.current = Date.now(), g.current = -1, p.current = null, f.current = null, c(!1));
|
|
8
8
|
}, []);
|
|
9
9
|
return t(() => () => {
|
|
10
|
-
|
|
11
|
-
}, [
|
|
10
|
+
_();
|
|
11
|
+
}, [_]), {
|
|
12
12
|
run: e((e, ...t) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
13
|
+
c(!0), g.current = Date.now(), p.current = t, f.current = e, h.current === -1 && (h.current = Date.now(), u === !0 && f.current(...t)), l !== void 0 && Date.now() - h.current >= l ? (m.current && clearTimeout(m.current), f.current && f.current(...t), h.current = -1, c(!1)) : (m.current && clearTimeout(m.current), m.current = setTimeout(() => {
|
|
14
|
+
g.current !== h.current && d !== !1 && f.current && p.current && f.current(...p.current), h.current = -1, c(!1);
|
|
15
|
+
}, o));
|
|
16
16
|
}, [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
o,
|
|
18
|
+
l,
|
|
19
|
+
d,
|
|
20
|
+
u
|
|
21
21
|
]),
|
|
22
|
-
cancel:
|
|
23
|
-
flush:
|
|
24
|
-
isPending:
|
|
22
|
+
cancel: _,
|
|
23
|
+
flush: v,
|
|
24
|
+
isPending: s
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
@@ -71,34 +71,34 @@ function s(e, n, i = {}) {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/performance/useRateLimit/useRateLimit.ts
|
|
73
73
|
function c(i, a, o) {
|
|
74
|
-
let
|
|
74
|
+
let s = Math.max(1, Number(i) || 1), c = Math.max(0, Number(a) || 0), [l, u] = r(s), d = o?.refillStrategy ?? "burst", f = n(o?.onRateLimitReached);
|
|
75
75
|
t(() => {
|
|
76
|
-
|
|
76
|
+
f.current = o?.onRateLimitReached;
|
|
77
77
|
}, [o?.onRateLimitReached]);
|
|
78
|
-
let
|
|
78
|
+
let p = n(s), [m] = r(() => Date.now()), h = n(m), g = n(null);
|
|
79
79
|
return t(() => () => {
|
|
80
|
-
|
|
80
|
+
g.current && clearTimeout(g.current);
|
|
81
81
|
}, []), {
|
|
82
82
|
run: e((e, ...t) => {
|
|
83
|
-
let n = Date.now(), r = n -
|
|
84
|
-
if (
|
|
83
|
+
let n = Date.now(), r = n - h.current;
|
|
84
|
+
if (d === "burst") r >= c && (p.current = s, h.current = n);
|
|
85
85
|
else {
|
|
86
|
-
let e =
|
|
87
|
-
t > 0 && (
|
|
86
|
+
let e = c / s, t = Math.floor(r / e);
|
|
87
|
+
t > 0 && (p.current = Math.min(s, p.current + t), h.current += t * e);
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
let e =
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
if (p.current > 0 ? (--p.current, u(p.current), e(...t)) : f.current && f.current(), g.current && clearTimeout(g.current), p.current < s) {
|
|
90
|
+
let e = c / s, t = d === "burst" ? c - (Date.now() - h.current) : e - (Date.now() - h.current);
|
|
91
|
+
g.current = setTimeout(() => {
|
|
92
|
+
u((e) => Math.min(s, e + 1)), h.current = Date.now(), p.current = Math.min(s, p.current + 1);
|
|
93
93
|
}, Math.max(0, t));
|
|
94
94
|
}
|
|
95
95
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
s,
|
|
97
|
+
c,
|
|
98
|
+
d
|
|
99
99
|
]),
|
|
100
|
-
remaining:
|
|
101
|
-
isRateLimited:
|
|
100
|
+
remaining: l,
|
|
101
|
+
isRateLimited: l === 0
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
@@ -120,34 +120,34 @@ function l(r, i, a, o) {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/performance/useThrottle/useThrottle.ts
|
|
122
122
|
function u(i, a = {}) {
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
}, []),
|
|
128
|
-
|
|
129
|
-
}, [
|
|
123
|
+
let o = Math.max(0, Number(i) || 0), [s, c] = r(!1), l = a?.leading ?? !0, u = a?.trailing ?? !0;
|
|
124
|
+
l === !1 && u === !1 && (l = !0, u = !0);
|
|
125
|
+
let d = n(null), f = n(null), p = n(null), m = n(-1), h = e(() => {
|
|
126
|
+
p.current &&= (clearTimeout(p.current), null), m.current = -1, f.current = null, d.current = null, c(!1);
|
|
127
|
+
}, []), g = e(() => {
|
|
128
|
+
f.current && d.current && (p.current &&= (clearTimeout(p.current), null), d.current(...f.current), m.current = l ? Date.now() : -1, f.current = null, d.current = null, c(!1));
|
|
129
|
+
}, [l]);
|
|
130
130
|
return t(() => () => {
|
|
131
|
-
|
|
132
|
-
}, [
|
|
131
|
+
h();
|
|
132
|
+
}, [h]), {
|
|
133
133
|
run: e((e, ...t) => {
|
|
134
|
-
|
|
134
|
+
c(!0);
|
|
135
135
|
let n = Date.now();
|
|
136
|
-
if (
|
|
137
|
-
else if (!
|
|
138
|
-
let e =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
},
|
|
136
|
+
if (f.current = t, d.current = e, m.current === -1 ? l : n - m.current >= o) p.current &&= (clearTimeout(p.current), null), d.current(...t), m.current = n, f.current = null, c(!1);
|
|
137
|
+
else if (!p.current) {
|
|
138
|
+
let e = m.current === -1 ? 0 : n - m.current, t = o - e;
|
|
139
|
+
p.current = setTimeout(() => {
|
|
140
|
+
u && f.current && d.current ? (d.current(...f.current), m.current = l ? Date.now() : -1) : m.current = -1, f.current = null, d.current = null, p.current = null, c(!1);
|
|
141
|
+
}, t);
|
|
142
142
|
}
|
|
143
143
|
}, [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
o,
|
|
145
|
+
l,
|
|
146
|
+
u
|
|
147
147
|
]),
|
|
148
|
-
cancel:
|
|
149
|
-
flush:
|
|
150
|
-
isPending:
|
|
148
|
+
cancel: h,
|
|
149
|
+
flush: g,
|
|
150
|
+
isPending: s
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
//#endregion
|
package/dist/state.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export interface UseFilterReturn<T> {
|
|
|
75
75
|
updateFilterValue: (id: string, value: unknown) => void;
|
|
76
76
|
isFilterActive: (id: string) => boolean;
|
|
77
77
|
}
|
|
78
|
-
export declare function useFilter<T>(data
|
|
78
|
+
export declare function useFilter<T>(data?: T[], initialFilters?: FilterState<T>): UseFilterReturn<T>;
|
|
79
79
|
export interface FuzzySearchOptions {
|
|
80
80
|
threshold?: number;
|
|
81
81
|
caseSensitive?: boolean;
|
|
@@ -118,8 +118,8 @@ export interface UseGroupingReturn<T> {
|
|
|
118
118
|
resetGrouping: () => void;
|
|
119
119
|
getGroupItems: (groupKey: string) => T[];
|
|
120
120
|
}
|
|
121
|
-
export declare function useGrouping<T = unknown>(
|
|
122
|
-
items
|
|
121
|
+
export declare function useGrouping<T = unknown>(options?: {
|
|
122
|
+
items?: T[];
|
|
123
123
|
initialGroupBy?: string;
|
|
124
124
|
}): UseGroupingReturn<T>;
|
|
125
125
|
export type SelectionId = string | number;
|
|
@@ -142,8 +142,8 @@ export interface UseMultipleSelectionReturn<T> {
|
|
|
142
142
|
deselectMultiple: (itemsToRemove: SelectionId[] | T[]) => void;
|
|
143
143
|
retainOnly: (itemsToRetain: SelectionId[] | T[]) => void;
|
|
144
144
|
}
|
|
145
|
-
export declare function useMultipleSelection<T = unknown>(
|
|
146
|
-
items
|
|
145
|
+
export declare function useMultipleSelection<T = unknown>(options?: {
|
|
146
|
+
items?: T[];
|
|
147
147
|
field?: string;
|
|
148
148
|
initialSelectedIds?: SelectionId[];
|
|
149
149
|
}): UseMultipleSelectionReturn<T>;
|
|
@@ -160,7 +160,7 @@ export interface UseOrderReturn<T> {
|
|
|
160
160
|
resetOrder: () => void;
|
|
161
161
|
replaceOrder: (newOrderedItems: T[]) => void;
|
|
162
162
|
}
|
|
163
|
-
export declare function useOrder<T>(initialItems
|
|
163
|
+
export declare function useOrder<T>(initialItems?: T[]): UseOrderReturn<T>;
|
|
164
164
|
export interface UsePaginationReturn<T> {
|
|
165
165
|
pageItems: T[];
|
|
166
166
|
pageSize: number;
|
|
@@ -178,7 +178,7 @@ export interface UsePaginationReturn<T> {
|
|
|
178
178
|
resetPageSize: () => void;
|
|
179
179
|
resetPagination: () => void;
|
|
180
180
|
}
|
|
181
|
-
export declare function usePagination<T>(data: T[], initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
|
|
181
|
+
export declare function usePagination<T>(data: T[] | undefined, initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
|
|
182
182
|
type SelectionId$1 = string | number;
|
|
183
183
|
export interface UseSingleSelectionReturn {
|
|
184
184
|
selectedId: SelectionId$1 | undefined;
|
|
@@ -230,6 +230,6 @@ export interface UseSortReturn<T> {
|
|
|
230
230
|
getNextSortingOrder: (id: string) => "asc" | "desc" | "none";
|
|
231
231
|
getSortIndex: (id: string) => number | undefined;
|
|
232
232
|
}
|
|
233
|
-
export declare function useSort<T>(data
|
|
233
|
+
export declare function useSort<T>(data?: T[], initialSorts?: SortState): UseSortReturn<T>;
|
|
234
234
|
|
|
235
235
|
export {};
|
package/dist/state2.js
CHANGED
|
@@ -58,13 +58,13 @@ var a = {
|
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
60
|
//#region src/state/useFilter/useFilter.ts
|
|
61
|
-
function o(o, s = []) {
|
|
62
|
-
let c =
|
|
63
|
-
let t =
|
|
61
|
+
function o(o = [], s = []) {
|
|
62
|
+
let c = n(() => Array.isArray(o) ? o : [], [o]), l = n(() => Array.isArray(s) ? s : [], [s]), u = r(l), [d, f] = i(() => l), p = n(() => {
|
|
63
|
+
let t = d.filter((e) => e.isActive !== !1).map((e) => ({
|
|
64
64
|
...e,
|
|
65
65
|
pathArray: (e.field || e.id).split(".")
|
|
66
66
|
}));
|
|
67
|
-
return
|
|
67
|
+
return c.filter((n) => t.every((t) => {
|
|
68
68
|
let { id: r, type: i, operator: o, value: s, compare: c, pathArray: l } = t, u = e(n, l, r);
|
|
69
69
|
if (i === "custom") return !c || c(u, s, n);
|
|
70
70
|
let d = a[i];
|
|
@@ -72,26 +72,26 @@ function o(o, s = []) {
|
|
|
72
72
|
let f = d[o];
|
|
73
73
|
return !f || f(u, s, t);
|
|
74
74
|
}));
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
}, []),
|
|
78
|
-
|
|
79
|
-
}, []),
|
|
80
|
-
|
|
81
|
-
}, []),
|
|
82
|
-
u
|
|
83
|
-
}, []),
|
|
84
|
-
|
|
75
|
+
}, [c, d]), m = t((e) => {
|
|
76
|
+
f((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? e : t) : [...t, e]);
|
|
77
|
+
}, []), h = t((e) => {
|
|
78
|
+
f((t) => Array.isArray(e) ? t.filter((t) => !e.includes(t.id)) : t.filter((t) => t.id !== e));
|
|
79
|
+
}, []), g = t(() => {
|
|
80
|
+
f([]);
|
|
81
|
+
}, []), _ = t(() => {
|
|
82
|
+
f(u.current);
|
|
83
|
+
}, []), v = t((e) => {
|
|
84
|
+
f(Array.isArray(e) ? e : []);
|
|
85
85
|
}, []);
|
|
86
86
|
return {
|
|
87
|
-
filteredItems:
|
|
88
|
-
filters:
|
|
89
|
-
upsertFilter:
|
|
90
|
-
removeFilter:
|
|
91
|
-
clearFilters:
|
|
92
|
-
resetFilters:
|
|
87
|
+
filteredItems: p,
|
|
88
|
+
filters: d,
|
|
89
|
+
upsertFilter: m,
|
|
90
|
+
removeFilter: h,
|
|
91
|
+
clearFilters: g,
|
|
92
|
+
resetFilters: _,
|
|
93
93
|
toggleFilter: t((e) => {
|
|
94
|
-
|
|
94
|
+
f((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? {
|
|
95
95
|
...t,
|
|
96
96
|
isActive: t.isActive === !1
|
|
97
97
|
} : t) : [...t, {
|
|
@@ -100,23 +100,23 @@ function o(o, s = []) {
|
|
|
100
100
|
}]);
|
|
101
101
|
}, []),
|
|
102
102
|
updateFilterConfig: t((e, t) => {
|
|
103
|
-
|
|
103
|
+
f((n) => n.map((n) => n.id === e ? {
|
|
104
104
|
...n,
|
|
105
105
|
...t
|
|
106
106
|
} : n));
|
|
107
107
|
}, []),
|
|
108
|
-
replaceFilters:
|
|
109
|
-
getFilterValue: t((e) =>
|
|
108
|
+
replaceFilters: v,
|
|
109
|
+
getFilterValue: t((e) => d.find((t) => t.id === e)?.value, [d]),
|
|
110
110
|
updateFilterValue: t((e, t) => {
|
|
111
|
-
|
|
111
|
+
f((n) => n.map((n) => n.id === e ? {
|
|
112
112
|
...n,
|
|
113
113
|
value: t
|
|
114
114
|
} : n));
|
|
115
115
|
}, []),
|
|
116
116
|
isFilterActive: t((e) => {
|
|
117
|
-
let t =
|
|
117
|
+
let t = d.find((t) => t.id === e);
|
|
118
118
|
return t ? t.isActive !== !1 : !1;
|
|
119
|
-
}, [
|
|
119
|
+
}, [d])
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
@@ -252,223 +252,223 @@ function c(t, r, i, a = {}) {
|
|
|
252
252
|
}
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/state/useGrouping/useGrouping.ts
|
|
255
|
-
function l(
|
|
256
|
-
let [
|
|
257
|
-
let r = e(n,
|
|
255
|
+
function l(r = {}) {
|
|
256
|
+
let a = r || {}, o = n(() => Array.isArray(a.items) ? a.items : [], [a.items]), s = a.initialGroupBy, [c, l] = i(s), u = n(() => c ? o.reduce((t, n) => {
|
|
257
|
+
let r = e(n, c), i = r == null ? "Unknown" : String(r);
|
|
258
258
|
return t[i] || (t[i] = []), t[i].push(n), t;
|
|
259
|
-
}, {}) : { Ungrouped:
|
|
259
|
+
}, {}) : { Ungrouped: o }, [o, c]), d = n(() => Object.keys(u).map((e) => ({
|
|
260
260
|
key: e,
|
|
261
|
-
items:
|
|
262
|
-
})), [
|
|
263
|
-
|
|
264
|
-
}, []),
|
|
265
|
-
|
|
266
|
-
}, []),
|
|
267
|
-
s
|
|
268
|
-
}, [
|
|
261
|
+
items: u[e]
|
|
262
|
+
})), [u]), f = n(() => Object.keys(u), [u]), p = t((e) => {
|
|
263
|
+
l(e);
|
|
264
|
+
}, []), m = t(() => {
|
|
265
|
+
l(void 0);
|
|
266
|
+
}, []), h = t(() => {
|
|
267
|
+
l(s);
|
|
268
|
+
}, [s]), g = t((e) => u[e] || [], [u]);
|
|
269
269
|
return {
|
|
270
|
-
groupedRecord:
|
|
271
|
-
groupedArray:
|
|
272
|
-
groupKeys:
|
|
273
|
-
totalGroups:
|
|
274
|
-
activeGroupBy:
|
|
275
|
-
changeGroupBy:
|
|
276
|
-
clearGrouping:
|
|
277
|
-
resetGrouping:
|
|
278
|
-
getGroupItems:
|
|
270
|
+
groupedRecord: u,
|
|
271
|
+
groupedArray: d,
|
|
272
|
+
groupKeys: f,
|
|
273
|
+
totalGroups: f.length,
|
|
274
|
+
activeGroupBy: c,
|
|
275
|
+
changeGroupBy: p,
|
|
276
|
+
clearGrouping: m,
|
|
277
|
+
resetGrouping: h,
|
|
278
|
+
getGroupItems: g
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/state/useMultipleSelection/useMultipleSelection.ts
|
|
283
|
-
function u(
|
|
284
|
-
let c = r(
|
|
285
|
-
|
|
286
|
-
let r = new Set(n), i = e(t,
|
|
283
|
+
function u(a = {}) {
|
|
284
|
+
let o = a || {}, s = n(() => Array.isArray(o.items) ? o.items : [], [o.items]), c = Array.isArray(o.initialSelectedIds) ? o.initialSelectedIds : [], l = o.field, u = r(c), [d, f] = i(() => new Set(c)), p = t((t) => {
|
|
285
|
+
f((n) => {
|
|
286
|
+
let r = new Set(n), i = e(t, l);
|
|
287
287
|
return r.add(i), r;
|
|
288
288
|
});
|
|
289
|
-
}, [
|
|
290
|
-
|
|
291
|
-
let r = new Set(n), i = e(t,
|
|
289
|
+
}, [l]), m = t((t) => {
|
|
290
|
+
f((n) => {
|
|
291
|
+
let r = new Set(n), i = e(t, l);
|
|
292
292
|
return r.delete(i), r;
|
|
293
293
|
});
|
|
294
|
-
}, [
|
|
295
|
-
|
|
296
|
-
let r = new Set(n), i = e(t,
|
|
294
|
+
}, [l]), h = t((t) => {
|
|
295
|
+
f((n) => {
|
|
296
|
+
let r = new Set(n), i = e(t, l);
|
|
297
297
|
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
298
298
|
});
|
|
299
|
-
}, [
|
|
300
|
-
let n = e(t,
|
|
301
|
-
return
|
|
302
|
-
}, [
|
|
303
|
-
let n = t.map((t) => e(t,
|
|
304
|
-
|
|
305
|
-
}, [
|
|
306
|
-
let t =
|
|
307
|
-
|
|
308
|
-
}, [
|
|
309
|
-
|
|
310
|
-
}, []),
|
|
311
|
-
if (t.size ===
|
|
312
|
-
let n =
|
|
299
|
+
}, [l]), g = t((t) => {
|
|
300
|
+
let n = e(t, l);
|
|
301
|
+
return d.has(n);
|
|
302
|
+
}, [d, l]), _ = t(() => f(new Set(u.current)), []), v = t((t) => {
|
|
303
|
+
let n = (Array.isArray(t) ? t : []).map((t) => e(t, l));
|
|
304
|
+
f(new Set(n));
|
|
305
|
+
}, [l]), y = t(() => {
|
|
306
|
+
let t = s.map((t) => e(t, l));
|
|
307
|
+
f(new Set(t));
|
|
308
|
+
}, [s, l]), b = t(() => {
|
|
309
|
+
f(/* @__PURE__ */ new Set());
|
|
310
|
+
}, []), x = t(() => f((t) => {
|
|
311
|
+
if (t.size === s.length) return /* @__PURE__ */ new Set();
|
|
312
|
+
let n = s.map((t) => e(t, l));
|
|
313
313
|
return new Set(n);
|
|
314
|
-
}), [
|
|
315
|
-
if (t.size ===
|
|
316
|
-
let n =
|
|
314
|
+
}), [s, l]), S = t(() => f((t) => {
|
|
315
|
+
if (t.size === s.length) return /* @__PURE__ */ new Set();
|
|
316
|
+
let n = s.filter((n) => !t.has(e(n, l))).map((t) => e(t, l));
|
|
317
317
|
return new Set(n);
|
|
318
|
-
}), [
|
|
319
|
-
|
|
318
|
+
}), [s, l]), C = t((t) => {
|
|
319
|
+
f((n) => {
|
|
320
320
|
let r = new Set(n);
|
|
321
|
-
return t.map((t) => e(t,
|
|
321
|
+
return (Array.isArray(t) ? t : []).map((t) => e(t, l)).forEach((e) => r.add(e)), r;
|
|
322
322
|
});
|
|
323
|
-
}, [
|
|
324
|
-
|
|
323
|
+
}, [l]), w = t((t) => {
|
|
324
|
+
f((n) => {
|
|
325
325
|
let r = new Set(n);
|
|
326
|
-
return t.map((t) => e(t,
|
|
326
|
+
return (Array.isArray(t) ? t : []).map((t) => e(t, l)).forEach((e) => r.delete(e)), r;
|
|
327
327
|
});
|
|
328
|
-
}, [
|
|
329
|
-
|
|
328
|
+
}, [l]), T = t((t) => {
|
|
329
|
+
f((n) => {
|
|
330
330
|
let r = /* @__PURE__ */ new Set();
|
|
331
|
-
return t.map((t) => e(t,
|
|
331
|
+
return (Array.isArray(t) ? t : []).map((t) => e(t, l)).forEach((e) => n.has(e) && r.add(e)), r;
|
|
332
332
|
});
|
|
333
|
-
}, [
|
|
334
|
-
let n = e(t,
|
|
335
|
-
return
|
|
333
|
+
}, [l]), E = n(() => s.filter((t) => {
|
|
334
|
+
let n = e(t, l);
|
|
335
|
+
return d.has(n);
|
|
336
336
|
}), [
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
337
|
+
s,
|
|
338
|
+
l,
|
|
339
|
+
d
|
|
340
340
|
]);
|
|
341
341
|
return {
|
|
342
|
-
selectedIds: [...
|
|
343
|
-
selectedCount:
|
|
344
|
-
selectedItems:
|
|
345
|
-
isEmpty:
|
|
346
|
-
select:
|
|
347
|
-
deselect:
|
|
348
|
-
toggle:
|
|
349
|
-
isSelected:
|
|
350
|
-
replaceSelection:
|
|
351
|
-
resetSelection:
|
|
352
|
-
selectAll:
|
|
353
|
-
deselectAll:
|
|
354
|
-
toggleAll:
|
|
355
|
-
invertSelection:
|
|
356
|
-
selectMultiple:
|
|
357
|
-
deselectMultiple:
|
|
358
|
-
retainOnly:
|
|
342
|
+
selectedIds: [...d],
|
|
343
|
+
selectedCount: d.size,
|
|
344
|
+
selectedItems: E,
|
|
345
|
+
isEmpty: d.size === 0,
|
|
346
|
+
select: p,
|
|
347
|
+
deselect: m,
|
|
348
|
+
toggle: h,
|
|
349
|
+
isSelected: g,
|
|
350
|
+
replaceSelection: v,
|
|
351
|
+
resetSelection: _,
|
|
352
|
+
selectAll: y,
|
|
353
|
+
deselectAll: b,
|
|
354
|
+
toggleAll: x,
|
|
355
|
+
invertSelection: S,
|
|
356
|
+
selectMultiple: C,
|
|
357
|
+
deselectMultiple: w,
|
|
358
|
+
retainOnly: T
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
361
|
//#endregion
|
|
362
362
|
//#region src/state/useOrder/useOrder.ts
|
|
363
|
-
function d(e) {
|
|
364
|
-
let
|
|
365
|
-
typeof e == "number" &&
|
|
363
|
+
function d(e = []) {
|
|
364
|
+
let a = n(() => Array.isArray(e) ? e : [], [e]), o = r(a), [s, c] = i(() => a), l = t((e) => {
|
|
365
|
+
typeof e == "number" && c((t) => {
|
|
366
366
|
if (e <= 0 || e >= t.length) return t;
|
|
367
367
|
let n = [...t];
|
|
368
368
|
return [n[e], n[e - 1]] = [n[e - 1], n[e]], n;
|
|
369
369
|
});
|
|
370
|
-
}, []),
|
|
371
|
-
typeof e == "number" &&
|
|
370
|
+
}, []), u = t((e) => {
|
|
371
|
+
typeof e == "number" && c((t) => {
|
|
372
372
|
if (e < 0 || e >= t.length - 1) return t;
|
|
373
373
|
let n = [...t];
|
|
374
374
|
return [n[e], n[e + 1]] = [n[e + 1], n[e]], n;
|
|
375
375
|
});
|
|
376
|
-
}, []),
|
|
377
|
-
typeof e == "number" &&
|
|
376
|
+
}, []), d = t((e) => e > 0, []), f = t((e) => e < s.length - 1, [s.length]), p = t((e) => {
|
|
377
|
+
typeof e == "number" && c((t) => {
|
|
378
378
|
if (e <= 0 || e >= t.length) return t;
|
|
379
379
|
let n = [...t], [r] = n.splice(e, 1);
|
|
380
380
|
return n.unshift(r), n;
|
|
381
381
|
});
|
|
382
|
-
}, []),
|
|
383
|
-
typeof e == "number" &&
|
|
382
|
+
}, []), m = t((e) => {
|
|
383
|
+
typeof e == "number" && c((t) => {
|
|
384
384
|
if (e < 0 || e >= t.length - 1) return t;
|
|
385
385
|
let n = [...t], [r] = n.splice(e, 1);
|
|
386
386
|
return n.push(r), n;
|
|
387
387
|
});
|
|
388
|
-
}, []),
|
|
389
|
-
typeof e != "number" || typeof t != "number" || e === t ||
|
|
388
|
+
}, []), h = t((e, t) => {
|
|
389
|
+
typeof e != "number" || typeof t != "number" || e === t || c((n) => {
|
|
390
390
|
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
391
391
|
let r = [...n], [i] = r.splice(e, 1);
|
|
392
392
|
return r.splice(t, 0, i), r;
|
|
393
393
|
});
|
|
394
|
-
}, []),
|
|
395
|
-
typeof e != "number" || typeof t != "number" || e === t ||
|
|
394
|
+
}, []), g = t((e, t) => {
|
|
395
|
+
typeof e != "number" || typeof t != "number" || e === t || c((n) => {
|
|
396
396
|
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
397
397
|
let r = [...n];
|
|
398
398
|
return [r[e], r[t]] = [r[t], r[e]], r;
|
|
399
399
|
});
|
|
400
|
-
}, []),
|
|
401
|
-
o
|
|
400
|
+
}, []), _ = t(() => {
|
|
401
|
+
c(o.current);
|
|
402
402
|
}, []);
|
|
403
403
|
return {
|
|
404
|
-
orderedItems:
|
|
405
|
-
moveUp:
|
|
406
|
-
moveDown:
|
|
407
|
-
canMoveUp:
|
|
408
|
-
canMoveDown:
|
|
409
|
-
moveToTop:
|
|
410
|
-
moveToBottom:
|
|
411
|
-
move:
|
|
412
|
-
swap:
|
|
404
|
+
orderedItems: s,
|
|
405
|
+
moveUp: l,
|
|
406
|
+
moveDown: u,
|
|
407
|
+
canMoveUp: d,
|
|
408
|
+
canMoveDown: f,
|
|
409
|
+
moveToTop: p,
|
|
410
|
+
moveToBottom: m,
|
|
411
|
+
move: h,
|
|
412
|
+
swap: g,
|
|
413
413
|
replaceOrder: t((e) => {
|
|
414
|
-
|
|
414
|
+
c(Array.isArray(e) ? e : []);
|
|
415
415
|
}, []),
|
|
416
|
-
resetOrder:
|
|
416
|
+
resetOrder: _
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
419
|
//#endregion
|
|
420
420
|
//#region src/state/usePagination/usePagination.ts
|
|
421
|
-
function f(e, r, a = 0) {
|
|
422
|
-
let [
|
|
423
|
-
return
|
|
424
|
-
pageItems: n(() => typeof
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
421
|
+
function f(e = [], r, a = 0) {
|
|
422
|
+
let o = n(() => Array.isArray(e) ? e : [], [e]), [s, c] = i(r), [l, u] = i(a), d = Math.max(1, Math.ceil(o.length / Math.max(1, s))), f = Math.min(Math.max(0, l), d - 1);
|
|
423
|
+
return l !== f && u(f), {
|
|
424
|
+
pageItems: n(() => typeof s != "number" || s < 1 ? [] : o.slice(l * s, (l + 1) * s), [
|
|
425
|
+
l,
|
|
426
|
+
s,
|
|
427
|
+
o
|
|
428
428
|
]),
|
|
429
|
-
pageSize:
|
|
430
|
-
pageIndex:
|
|
431
|
-
totalPages:
|
|
432
|
-
canPrevious:
|
|
433
|
-
canNext:
|
|
429
|
+
pageSize: s,
|
|
430
|
+
pageIndex: l,
|
|
431
|
+
totalPages: d,
|
|
432
|
+
canPrevious: l > 0,
|
|
433
|
+
canNext: l < d - 1,
|
|
434
434
|
nextPage: t(() => {
|
|
435
|
-
|
|
436
|
-
}, [
|
|
435
|
+
u((e) => e < d - 1 ? e + 1 : e);
|
|
436
|
+
}, [d]),
|
|
437
437
|
previousPage: t(() => {
|
|
438
|
-
|
|
438
|
+
u((e) => e > 0 ? e - 1 : e);
|
|
439
439
|
}, []),
|
|
440
440
|
goToFirstPage: t(() => {
|
|
441
|
-
|
|
441
|
+
u(0);
|
|
442
442
|
}, []),
|
|
443
443
|
goToLastPage: t(() => {
|
|
444
|
-
|
|
445
|
-
}, [
|
|
444
|
+
u(d - 1);
|
|
445
|
+
}, [d]),
|
|
446
446
|
goToPage: t((e) => {
|
|
447
|
-
typeof e == "number" && e >= 0 && e <=
|
|
448
|
-
}, [
|
|
449
|
-
changePageSize: t((
|
|
450
|
-
if (typeof
|
|
451
|
-
|
|
452
|
-
let
|
|
453
|
-
|
|
447
|
+
typeof e == "number" && e >= 0 && e <= d - 1 && u(e);
|
|
448
|
+
}, [d]),
|
|
449
|
+
changePageSize: t((e) => {
|
|
450
|
+
if (typeof e == "number" && e > 0) {
|
|
451
|
+
c(e);
|
|
452
|
+
let t = Math.max(1, Math.ceil(o.length / Math.max(1, e)));
|
|
453
|
+
u((e) => Math.min(Math.max(0, e), t - 1));
|
|
454
454
|
}
|
|
455
|
-
}, [
|
|
455
|
+
}, [o.length]),
|
|
456
456
|
resetPageIndex: t(() => {
|
|
457
|
-
|
|
458
|
-
}, [a,
|
|
457
|
+
u(Math.min(Math.max(0, a), d - 1));
|
|
458
|
+
}, [a, d]),
|
|
459
459
|
resetPageSize: t(() => {
|
|
460
|
-
|
|
461
|
-
let
|
|
462
|
-
|
|
463
|
-
}, [r,
|
|
460
|
+
c(Math.max(1, r));
|
|
461
|
+
let e = Math.max(1, Math.ceil(o.length / Math.max(1, r)));
|
|
462
|
+
u((t) => Math.min(Math.max(0, t), e - 1));
|
|
463
|
+
}, [r, o.length]),
|
|
464
464
|
resetPagination: t(() => {
|
|
465
|
-
|
|
466
|
-
let
|
|
467
|
-
|
|
465
|
+
c(Math.max(1, r));
|
|
466
|
+
let e = Math.max(1, Math.ceil(o.length / Math.max(1, r)));
|
|
467
|
+
u(Math.min(Math.max(0, a), e - 1));
|
|
468
468
|
}, [
|
|
469
469
|
r,
|
|
470
470
|
a,
|
|
471
|
-
|
|
471
|
+
o.length
|
|
472
472
|
])
|
|
473
473
|
};
|
|
474
474
|
}
|
|
@@ -547,13 +547,13 @@ function x(e, t, n = "last", r) {
|
|
|
547
547
|
}
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region src/state/useSort/useSort.ts
|
|
550
|
-
function S(a, o = []) {
|
|
551
|
-
let s =
|
|
552
|
-
let t =
|
|
550
|
+
function S(a = [], o = []) {
|
|
551
|
+
let s = n(() => Array.isArray(a) ? a : [], [a]), c = n(() => Array.isArray(o) ? o : [], [o]), l = r(c), [u, d] = i(() => c), f = n(() => {
|
|
552
|
+
let t = u.map((e) => ({
|
|
553
553
|
...e,
|
|
554
554
|
pathArray: (e.field || e.id).split(".")
|
|
555
555
|
}));
|
|
556
|
-
return [...
|
|
556
|
+
return [...s].sort((n, r) => {
|
|
557
557
|
for (let i of t) {
|
|
558
558
|
let { type: t, id: a, desc: o = !1, invertSorting: s = !1, pathArray: c } = i, l = e(n, c, a), u = e(r, c, a), d;
|
|
559
559
|
switch (t) {
|
|
@@ -584,11 +584,13 @@ function S(a, o = []) {
|
|
|
584
584
|
}
|
|
585
585
|
return 0;
|
|
586
586
|
});
|
|
587
|
-
}, [
|
|
588
|
-
|
|
589
|
-
}, []),
|
|
587
|
+
}, [u, s]), p = t((e) => d((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? e : t) : [...t, e]), []), x = t((e) => {
|
|
588
|
+
d((t) => Array.isArray(e) ? t.filter((t) => !e.includes(t.id)) : t.filter((t) => t.id !== e));
|
|
589
|
+
}, []), S = t(() => d([]), []), C = t(() => d(l.current), []), w = t((e) => {
|
|
590
|
+
d(Array.isArray(e) ? e : []);
|
|
591
|
+
}, []), T = t((e, t, n) => {
|
|
590
592
|
let { multi: r = !1, ...i } = n || {};
|
|
591
|
-
|
|
593
|
+
d((n) => {
|
|
592
594
|
let a = n.find((t) => t.id === e);
|
|
593
595
|
if (!a) {
|
|
594
596
|
let a = {
|
|
@@ -619,26 +621,26 @@ function S(a, o = []) {
|
|
|
619
621
|
});
|
|
620
622
|
}, []);
|
|
621
623
|
return {
|
|
622
|
-
sortedItems:
|
|
623
|
-
sorts:
|
|
624
|
-
upsertSorts:
|
|
625
|
-
removeSort:
|
|
626
|
-
clearSorts:
|
|
627
|
-
resetSorts:
|
|
628
|
-
replaceSorts:
|
|
624
|
+
sortedItems: f,
|
|
625
|
+
sorts: u,
|
|
626
|
+
upsertSorts: p,
|
|
627
|
+
removeSort: x,
|
|
628
|
+
clearSorts: S,
|
|
629
|
+
resetSorts: C,
|
|
630
|
+
replaceSorts: w,
|
|
629
631
|
getSortDirection: t((e) => {
|
|
630
|
-
let t =
|
|
632
|
+
let t = u.find((t) => t.id === e);
|
|
631
633
|
return t ? t.desc ? "desc" : "asc" : void 0;
|
|
632
|
-
}, [
|
|
633
|
-
toggleSort:
|
|
634
|
+
}, [u]),
|
|
635
|
+
toggleSort: T,
|
|
634
636
|
getNextSortingOrder: t((e) => {
|
|
635
|
-
let t =
|
|
637
|
+
let t = u.find((t) => t.id === e);
|
|
636
638
|
return t ? t.desc ? t.disableSortRemoval ? "asc" : "none" : "desc" : "asc";
|
|
637
|
-
}, [
|
|
639
|
+
}, [u]),
|
|
638
640
|
getSortIndex: t((e) => {
|
|
639
|
-
let t =
|
|
641
|
+
let t = u.findIndex((t) => t.id === e);
|
|
640
642
|
return t === -1 ? void 0 : t + 1;
|
|
641
|
-
}, [
|
|
643
|
+
}, [u])
|
|
642
644
|
};
|
|
643
645
|
}
|
|
644
646
|
//#endregion
|
package/dist/ui.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface UseExpansionReturn<T> {
|
|
|
32
32
|
resetExpansion: () => void;
|
|
33
33
|
replaceExpansion: (newExpandedItems: ExpansionId[] | T[]) => void;
|
|
34
34
|
}
|
|
35
|
-
export declare function useExpansion<T = unknown>(
|
|
35
|
+
export declare function useExpansion<T = unknown>(options?: {
|
|
36
36
|
items?: T[];
|
|
37
37
|
field?: string;
|
|
38
38
|
initialExpandedIds?: ExpansionId[];
|
|
@@ -70,8 +70,8 @@ export interface UsePinReturn<T> {
|
|
|
70
70
|
pinMultiple: (newItems: PinId[] | T[]) => void;
|
|
71
71
|
unpinMultiple: (itemsToRemove: PinId[] | T[]) => void;
|
|
72
72
|
}
|
|
73
|
-
export declare function usePin<T = unknown>(
|
|
74
|
-
items
|
|
73
|
+
export declare function usePin<T = unknown>(options?: {
|
|
74
|
+
items?: T[];
|
|
75
75
|
field?: string;
|
|
76
76
|
initialPinnedIds?: PinId[];
|
|
77
77
|
maxPins?: number;
|
|
@@ -91,8 +91,8 @@ export interface UseVisibilityReturn<T> {
|
|
|
91
91
|
resetVisibility: () => void;
|
|
92
92
|
replaceVisibility: (newVisibleItems: VisibilityId[] | T[]) => void;
|
|
93
93
|
}
|
|
94
|
-
export declare function useVisibility<T = unknown>(
|
|
95
|
-
items
|
|
94
|
+
export declare function useVisibility<T = unknown>(options?: {
|
|
95
|
+
items?: T[];
|
|
96
96
|
field?: string;
|
|
97
97
|
initialVisibleIds?: VisibilityId[];
|
|
98
98
|
}): UseVisibilityReturn<T>;
|
package/dist/ui2.js
CHANGED
|
@@ -4,22 +4,22 @@ import { Fragment as c, jsx as l } from "react/jsx-runtime";
|
|
|
4
4
|
import { createPortal as u } from "react-dom";
|
|
5
5
|
//#region src/ui/FuzzyHighlighter/FuzzyHighlighter.tsx
|
|
6
6
|
function d({ text: e, query: t, className: n = "", caseSensitive: r = !1 }) {
|
|
7
|
-
let i = t.trim();
|
|
8
|
-
if (!i || !
|
|
9
|
-
let
|
|
10
|
-
if (
|
|
11
|
-
let
|
|
12
|
-
if (
|
|
13
|
-
let e =
|
|
14
|
-
|
|
7
|
+
let i = String(t || "").trim(), a = String(e || "");
|
|
8
|
+
if (!i || !a) return /* @__PURE__ */ l(c, { children: a });
|
|
9
|
+
let o = i.split(/\s+/).filter((e) => e.length > 0);
|
|
10
|
+
if (o.length === 0) return /* @__PURE__ */ l(c, { children: a });
|
|
11
|
+
let s = `fuzzy-highlight ${n}`.trim(), u = [...o].sort((e, t) => t.length - e.length).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")), d = [...u];
|
|
12
|
+
if (u.length > 1) {
|
|
13
|
+
let e = o.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+");
|
|
14
|
+
d.unshift(e);
|
|
15
15
|
}
|
|
16
16
|
if (i.length > 1 && i === i.toUpperCase() && /^[A-Z]+$/.test(i)) {
|
|
17
17
|
let e = i.split("").map((e) => `\\b${e}`).join("[^a-z0-9]*");
|
|
18
|
-
|
|
18
|
+
d.unshift(e);
|
|
19
19
|
}
|
|
20
|
-
let
|
|
21
|
-
return /* @__PURE__ */ l(c, { children:
|
|
22
|
-
className:
|
|
20
|
+
let f = `(${d.join("|")})`, p = new RegExp(f, r ? "g" : "gi");
|
|
21
|
+
return /* @__PURE__ */ l(c, { children: a.split(p).map((e, t) => p.test(e) ? /* @__PURE__ */ l("strong", {
|
|
22
|
+
className: s,
|
|
23
23
|
children: e
|
|
24
24
|
}, t) : e) });
|
|
25
25
|
}
|
|
@@ -80,207 +80,207 @@ function _({ modalId: e, children: t, wrapperClassName: n = "", wrapperStyle: r,
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/ui/useExpansion/useExpansion.ts
|
|
83
|
-
function v(
|
|
84
|
-
let l = o(
|
|
85
|
-
let n = e(t,
|
|
86
|
-
return
|
|
87
|
-
}, [
|
|
88
|
-
|
|
89
|
-
let
|
|
90
|
-
if (n.has(
|
|
91
|
-
let
|
|
92
|
-
return
|
|
83
|
+
function v(t = {}) {
|
|
84
|
+
let r = t || {}, i = a(() => Array.isArray(r.items) ? r.items : [], [r.items]), c = Array.isArray(r.initialExpandedIds) ? r.initialExpandedIds : [], l = r.field, u = !!r.multiple, d = o(c), [f, p] = s(() => new Set(c)), m = n((t) => {
|
|
85
|
+
let n = e(t, l);
|
|
86
|
+
return f.has(n);
|
|
87
|
+
}, [f, l]), h = n((t) => {
|
|
88
|
+
p((n) => {
|
|
89
|
+
let r = e(t, l);
|
|
90
|
+
if (n.has(r)) return n;
|
|
91
|
+
let i = u ? new Set(n) : /* @__PURE__ */ new Set();
|
|
92
|
+
return i.add(r), i;
|
|
93
93
|
});
|
|
94
|
-
}, [
|
|
95
|
-
|
|
96
|
-
let
|
|
97
|
-
if (!n.has(
|
|
98
|
-
let
|
|
99
|
-
return
|
|
94
|
+
}, [l, u]), g = n((t) => {
|
|
95
|
+
p((n) => {
|
|
96
|
+
let r = e(t, l);
|
|
97
|
+
if (!n.has(r)) return n;
|
|
98
|
+
let i = new Set(n);
|
|
99
|
+
return i.delete(r), i;
|
|
100
100
|
});
|
|
101
|
-
}, [
|
|
102
|
-
|
|
103
|
-
let
|
|
104
|
-
return n.has(
|
|
101
|
+
}, [l]), _ = n((t) => {
|
|
102
|
+
p((n) => {
|
|
103
|
+
let r = e(t, l), i = u ? new Set(n) : /* @__PURE__ */ new Set();
|
|
104
|
+
return n.has(r) ? u && i.delete(r) : i.add(r), i;
|
|
105
105
|
});
|
|
106
|
-
}, [
|
|
107
|
-
if (!
|
|
108
|
-
let
|
|
109
|
-
|
|
106
|
+
}, [l, u]), v = n(() => {
|
|
107
|
+
if (!u) return;
|
|
108
|
+
let t = (Array.isArray(i) ? i : []).map((t) => e(t, l));
|
|
109
|
+
p(new Set(t));
|
|
110
110
|
}, [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
c
|
|
114
|
-
]), _ = n(() => {
|
|
115
|
-
d(/* @__PURE__ */ new Set());
|
|
116
|
-
}, []), v = n(() => {
|
|
117
|
-
d(new Set(l.current));
|
|
118
|
-
}, []), y = n((t) => {
|
|
119
|
-
let n = t.map((t) => e(t, r));
|
|
120
|
-
d(new Set(n));
|
|
121
|
-
}, [r]), b = a(() => t.filter((t) => u.has(e(t, r))), [
|
|
122
|
-
t,
|
|
123
|
-
r,
|
|
111
|
+
i,
|
|
112
|
+
l,
|
|
124
113
|
u
|
|
114
|
+
]), y = n(() => {
|
|
115
|
+
p(/* @__PURE__ */ new Set());
|
|
116
|
+
}, []), b = n(() => {
|
|
117
|
+
p(new Set(d.current));
|
|
118
|
+
}, []), x = n((t) => {
|
|
119
|
+
let n = (Array.isArray(t) ? t : []).map((t) => e(t, l));
|
|
120
|
+
p(new Set(n));
|
|
121
|
+
}, [l]), S = a(() => (Array.isArray(i) ? i : []).filter((t) => f.has(e(t, l))), [
|
|
122
|
+
i,
|
|
123
|
+
l,
|
|
124
|
+
f
|
|
125
125
|
]);
|
|
126
126
|
return {
|
|
127
|
-
expandedIds: [...
|
|
128
|
-
expandedItems:
|
|
129
|
-
isExpanded:
|
|
130
|
-
expand:
|
|
131
|
-
collapse:
|
|
132
|
-
toggle:
|
|
133
|
-
expandAll:
|
|
134
|
-
collapseAll:
|
|
135
|
-
resetExpansion:
|
|
136
|
-
replaceExpansion:
|
|
127
|
+
expandedIds: [...f],
|
|
128
|
+
expandedItems: S,
|
|
129
|
+
isExpanded: m,
|
|
130
|
+
expand: h,
|
|
131
|
+
collapse: g,
|
|
132
|
+
toggle: _,
|
|
133
|
+
expandAll: v,
|
|
134
|
+
collapseAll: y,
|
|
135
|
+
resetExpansion: b,
|
|
136
|
+
replaceExpansion: x
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
//#endregion
|
|
140
140
|
//#region src/ui/usePin/usePin.ts
|
|
141
|
-
function y(
|
|
142
|
-
let l = o(
|
|
143
|
-
|
|
144
|
-
if (n.size >=
|
|
145
|
-
let
|
|
146
|
-
return
|
|
141
|
+
function y(t = {}) {
|
|
142
|
+
let r = t || {}, i = a(() => Array.isArray(r.items) ? r.items : [], [r.items]), c = Array.isArray(r.initialPinnedIds) ? r.initialPinnedIds : [], l = r.field, u = typeof r.maxPins == "number" && !isNaN(r.maxPins) ? Math.max(1, r.maxPins) : 2 ** 53 - 1, d = o(c), [f, p] = s(() => new Set(c)), m = n((t) => {
|
|
143
|
+
p((n) => {
|
|
144
|
+
if (n.size >= u) return n;
|
|
145
|
+
let r = new Set(n), i = e(t, l);
|
|
146
|
+
return r.add(i), r;
|
|
147
147
|
});
|
|
148
|
-
}, [
|
|
149
|
-
|
|
150
|
-
let
|
|
151
|
-
return
|
|
148
|
+
}, [l, u]), h = n((t) => {
|
|
149
|
+
p((n) => {
|
|
150
|
+
let r = new Set(n), i = e(t, l);
|
|
151
|
+
return r.delete(i), r;
|
|
152
152
|
});
|
|
153
|
-
}, [
|
|
154
|
-
|
|
155
|
-
let
|
|
156
|
-
if (
|
|
153
|
+
}, [l]), g = n((t) => {
|
|
154
|
+
p((n) => {
|
|
155
|
+
let r = new Set(n), i = e(t, l);
|
|
156
|
+
if (r.has(i)) r.delete(i);
|
|
157
157
|
else {
|
|
158
|
-
if (
|
|
159
|
-
|
|
158
|
+
if (r.size >= u) return n;
|
|
159
|
+
r.add(i);
|
|
160
160
|
}
|
|
161
|
-
return
|
|
161
|
+
return r;
|
|
162
162
|
});
|
|
163
|
-
}, [
|
|
164
|
-
let n = e(t,
|
|
165
|
-
return
|
|
166
|
-
}, [
|
|
167
|
-
let n = t.map((t) => e(t,
|
|
168
|
-
|
|
169
|
-
}, [
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
for (let e of
|
|
173
|
-
if (
|
|
174
|
-
|
|
163
|
+
}, [l, u]), _ = n((t) => {
|
|
164
|
+
let n = e(t, l);
|
|
165
|
+
return f.has(n);
|
|
166
|
+
}, [f, l]), v = n(() => p(/* @__PURE__ */ new Set()), []), y = n(() => p(new Set(d.current)), [d]), b = n((t) => {
|
|
167
|
+
let n = (Array.isArray(t) ? t : []).map((t) => e(t, l));
|
|
168
|
+
p(new Set(n.slice(0, u)));
|
|
169
|
+
}, [l, u]), x = n((t) => {
|
|
170
|
+
p((n) => {
|
|
171
|
+
let r = new Set(n), i = (Array.isArray(t) ? t : []).map((t) => e(t, l));
|
|
172
|
+
for (let e of i) {
|
|
173
|
+
if (r.size >= u && !r.has(e)) break;
|
|
174
|
+
r.add(e);
|
|
175
175
|
}
|
|
176
|
-
return
|
|
176
|
+
return r;
|
|
177
177
|
});
|
|
178
|
-
}, [
|
|
179
|
-
|
|
180
|
-
let
|
|
181
|
-
return t.map((t) => e(t,
|
|
178
|
+
}, [l, u]), S = n((t) => {
|
|
179
|
+
p((n) => {
|
|
180
|
+
let r = new Set(n);
|
|
181
|
+
return (Array.isArray(t) ? t : []).map((t) => e(t, l)).forEach((e) => r.delete(e)), r;
|
|
182
182
|
});
|
|
183
|
-
}, [
|
|
184
|
-
let n = e(t,
|
|
185
|
-
return
|
|
183
|
+
}, [l]), C = a(() => (Array.isArray(i) ? i : []).filter((t) => {
|
|
184
|
+
let n = e(t, l);
|
|
185
|
+
return f.has(n);
|
|
186
186
|
}), [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
]),
|
|
191
|
-
let n = e(t,
|
|
192
|
-
return !
|
|
187
|
+
i,
|
|
188
|
+
l,
|
|
189
|
+
f
|
|
190
|
+
]), w = a(() => (Array.isArray(i) ? i : []).filter((t) => {
|
|
191
|
+
let n = e(t, l);
|
|
192
|
+
return !f.has(n);
|
|
193
193
|
}), [
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
i,
|
|
195
|
+
l,
|
|
196
|
+
f
|
|
197
197
|
]);
|
|
198
198
|
return {
|
|
199
|
-
pinnedIds: [...
|
|
200
|
-
pinnedItems:
|
|
201
|
-
unpinnedItems:
|
|
202
|
-
pinnedCount:
|
|
203
|
-
hasPins:
|
|
204
|
-
isAtMaxLimit:
|
|
205
|
-
pin:
|
|
206
|
-
unpin:
|
|
207
|
-
togglePin:
|
|
208
|
-
isPinned:
|
|
209
|
-
clearPins:
|
|
210
|
-
resetPins:
|
|
211
|
-
replacePins:
|
|
212
|
-
pinMultiple:
|
|
213
|
-
unpinMultiple:
|
|
199
|
+
pinnedIds: [...f],
|
|
200
|
+
pinnedItems: C,
|
|
201
|
+
unpinnedItems: w,
|
|
202
|
+
pinnedCount: f.size,
|
|
203
|
+
hasPins: f.size > 0,
|
|
204
|
+
isAtMaxLimit: f.size >= u,
|
|
205
|
+
pin: m,
|
|
206
|
+
unpin: h,
|
|
207
|
+
togglePin: g,
|
|
208
|
+
isPinned: _,
|
|
209
|
+
clearPins: v,
|
|
210
|
+
resetPins: y,
|
|
211
|
+
replacePins: b,
|
|
212
|
+
pinMultiple: x,
|
|
213
|
+
unpinMultiple: S
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
216
|
//#endregion
|
|
217
217
|
//#region src/ui/useVisibility/useVisibility.ts
|
|
218
|
-
function b(
|
|
219
|
-
let c = o(
|
|
220
|
-
let n = e(t,
|
|
221
|
-
return
|
|
222
|
-
}, [
|
|
223
|
-
|
|
224
|
-
let
|
|
225
|
-
return
|
|
218
|
+
function b(t = {}) {
|
|
219
|
+
let r = t || {}, i = a(() => Array.isArray(r.items) ? r.items : [], [r.items]), c = Array.isArray(r.initialVisibleIds) ? r.initialVisibleIds : [], l = r.field, u = o(c), [d, f] = s(() => new Set(c)), p = n((t) => {
|
|
220
|
+
let n = e(t, l);
|
|
221
|
+
return d.has(n);
|
|
222
|
+
}, [d, l]), m = n((t) => {
|
|
223
|
+
f((n) => {
|
|
224
|
+
let r = new Set(n), i = e(t, l);
|
|
225
|
+
return r.add(i), r;
|
|
226
226
|
});
|
|
227
|
-
}, [
|
|
228
|
-
|
|
229
|
-
let
|
|
230
|
-
return
|
|
227
|
+
}, [l]), h = n((t) => {
|
|
228
|
+
f((n) => {
|
|
229
|
+
let r = new Set(n), i = e(t, l);
|
|
230
|
+
return r.delete(i), r;
|
|
231
231
|
});
|
|
232
|
-
}, [
|
|
233
|
-
|
|
234
|
-
let
|
|
235
|
-
return
|
|
232
|
+
}, [l]), g = n((t) => {
|
|
233
|
+
f((n) => {
|
|
234
|
+
let r = new Set(n), i = e(t, l);
|
|
235
|
+
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
236
236
|
});
|
|
237
|
-
}, [
|
|
238
|
-
|
|
239
|
-
let
|
|
240
|
-
return (
|
|
241
|
-
|
|
242
|
-
}),
|
|
237
|
+
}, [l]), _ = n((t) => {
|
|
238
|
+
f((n) => {
|
|
239
|
+
let r = new Set(n);
|
|
240
|
+
return (Array.isArray(t) ? t : Array.isArray(i) ? i : []).forEach((t) => {
|
|
241
|
+
r.add(e(t, l));
|
|
242
|
+
}), r;
|
|
243
243
|
});
|
|
244
|
-
}, [
|
|
245
|
-
|
|
246
|
-
let
|
|
247
|
-
return (
|
|
248
|
-
|
|
249
|
-
}),
|
|
244
|
+
}, [i, l]), v = n((t) => {
|
|
245
|
+
f((n) => {
|
|
246
|
+
let r = new Set(n);
|
|
247
|
+
return (Array.isArray(t) ? t : Array.isArray(i) ? i : []).forEach((t) => {
|
|
248
|
+
r.delete(e(t, l));
|
|
249
|
+
}), r;
|
|
250
250
|
});
|
|
251
|
-
}, [
|
|
252
|
-
|
|
253
|
-
}, []),
|
|
254
|
-
let n = t.map((t) => e(t,
|
|
255
|
-
|
|
256
|
-
}, [
|
|
257
|
-
let n = e(t,
|
|
258
|
-
return
|
|
251
|
+
}, [i, l]), y = n(() => {
|
|
252
|
+
f(() => new Set(u.current));
|
|
253
|
+
}, []), b = n((t) => {
|
|
254
|
+
let n = (Array.isArray(t) ? t : []).map((t) => e(t, l));
|
|
255
|
+
f(() => new Set(n));
|
|
256
|
+
}, [l]), x = a(() => (Array.isArray(i) ? i : []).filter((t) => {
|
|
257
|
+
let n = e(t, l);
|
|
258
|
+
return d.has(n);
|
|
259
259
|
}), [
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
]),
|
|
264
|
-
let n = e(t,
|
|
265
|
-
return !
|
|
260
|
+
i,
|
|
261
|
+
l,
|
|
262
|
+
d
|
|
263
|
+
]), S = a(() => (Array.isArray(i) ? i : []).filter((t) => {
|
|
264
|
+
let n = e(t, l);
|
|
265
|
+
return !d.has(n);
|
|
266
266
|
}), [
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
i,
|
|
268
|
+
l,
|
|
269
|
+
d
|
|
270
270
|
]);
|
|
271
271
|
return {
|
|
272
|
-
visibleIds: [...
|
|
273
|
-
visibleItems:
|
|
274
|
-
hiddenItems:
|
|
275
|
-
visibleCount:
|
|
276
|
-
isVisible:
|
|
277
|
-
show:
|
|
278
|
-
hide:
|
|
279
|
-
toggleVisibility:
|
|
280
|
-
showAll:
|
|
281
|
-
hideAll:
|
|
282
|
-
replaceVisibility:
|
|
283
|
-
resetVisibility:
|
|
272
|
+
visibleIds: [...d],
|
|
273
|
+
visibleItems: x,
|
|
274
|
+
hiddenItems: S,
|
|
275
|
+
visibleCount: d.size,
|
|
276
|
+
isVisible: p,
|
|
277
|
+
show: m,
|
|
278
|
+
hide: h,
|
|
279
|
+
toggleVisibility: g,
|
|
280
|
+
showAll: _,
|
|
281
|
+
hideAll: v,
|
|
282
|
+
replaceVisibility: b,
|
|
283
|
+
resetVisibility: y
|
|
284
284
|
};
|
|
285
285
|
}
|
|
286
286
|
//#endregion
|