@himanshu-sorathiya/react-kit 1.0.13 → 1.0.16
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/index.d.ts +176 -74
- package/dist/index.js +561 -270
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import React$1 from 'react';
|
|
3
4
|
import { CSSProperties, RefObject } from 'react';
|
|
4
5
|
|
|
6
|
+
export interface FuzzyHighlighterProps {
|
|
7
|
+
text: string;
|
|
8
|
+
query: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
caseSensitive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function FuzzyHighlighter({ text, query, className, caseSensitive, }: FuzzyHighlighterProps): React$1.JSX.Element;
|
|
5
13
|
export interface ModalLayoutProps {
|
|
6
14
|
modalId: string;
|
|
7
|
-
children: React.ReactNode;
|
|
15
|
+
children: React$1.ReactNode;
|
|
8
16
|
wrapperClassName?: string;
|
|
9
|
-
wrapperStyle?: CSSProperties;
|
|
17
|
+
wrapperStyle?: React$1.CSSProperties;
|
|
10
18
|
containerClassName?: string;
|
|
11
|
-
containerStyle?: CSSProperties;
|
|
19
|
+
containerStyle?: React$1.CSSProperties;
|
|
12
20
|
}
|
|
13
21
|
export declare function ModalLayout({ modalId, children, wrapperClassName, wrapperStyle, containerClassName, containerStyle, }: ModalLayoutProps): import("react").ReactPortal | null;
|
|
14
|
-
export interface DebounceOptions {
|
|
15
|
-
maxWait?: number;
|
|
16
|
-
leading?: boolean;
|
|
17
|
-
trailing?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface UseDebounceReturn<Args extends any[]> {
|
|
20
|
-
debouncedFunc: (...args: Args) => void;
|
|
21
|
-
cancel: () => void;
|
|
22
|
-
flush: () => void;
|
|
23
|
-
isPending: boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare function useDebounce<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: DebounceOptions): UseDebounceReturn<Args>;
|
|
26
|
-
export interface DebouncedValueOptions {
|
|
27
|
-
maxWait?: number;
|
|
28
|
-
leading?: boolean;
|
|
29
|
-
trailing?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export type UseDebouncedValueReturn<T> = T;
|
|
32
|
-
export declare function useDebouncedValue<T>(value: T, delay: number, options?: DebouncedValueOptions): UseDebouncedValueReturn<T>;
|
|
33
22
|
export type FilterType = "text" | "number" | "boolean" | "date" | "select" | "multiselect" | "custom";
|
|
34
23
|
export type TextOperator = "contains" | "equals" | "startsWith" | "endsWith" | "notContains";
|
|
35
24
|
export type NumberOperator = "equals" | "greaterThan" | "lessThan" | "greaterThanOrEqual" | "lessThanOrEqual" | "between";
|
|
@@ -133,60 +122,25 @@ export type UseFuzzySearchFields<T> = {
|
|
|
133
122
|
}[];
|
|
134
123
|
export type UseFuzzySearchReturn<T> = T[];
|
|
135
124
|
export declare function useFuzzySearch<T>(data: T[], query: string, fields: UseFuzzySearchFields<T>, options?: FuzzySearchOptions): UseFuzzySearchReturn<T>;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"keypress"
|
|
140
|
-
];
|
|
141
|
-
export type KeyEventType = (typeof validKeyEventTypes)[number];
|
|
142
|
-
export interface BaseKeyOptions {
|
|
143
|
-
enabled?: boolean;
|
|
144
|
-
target?: RefObject<HTMLElement | null> | Window;
|
|
145
|
-
preventDefault?: boolean;
|
|
146
|
-
stopPropagation?: boolean;
|
|
147
|
-
ignoreWhenFocusedInInputs?: boolean;
|
|
148
|
-
ctrlKey?: boolean;
|
|
149
|
-
shiftKey?: boolean;
|
|
150
|
-
altKey?: boolean;
|
|
151
|
-
metaKey?: boolean;
|
|
152
|
-
}
|
|
153
|
-
export type KeyOptions = BaseKeyOptions & ({
|
|
154
|
-
eventType?: "keydown" | "keypress";
|
|
155
|
-
preventRepeat?: boolean;
|
|
156
|
-
} | {
|
|
157
|
-
eventType: "keyup";
|
|
158
|
-
preventRepeat?: never;
|
|
159
|
-
});
|
|
160
|
-
export type UseKeyReturn = void;
|
|
161
|
-
export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
|
|
162
|
-
export interface UseModalStateReturn<TData> {
|
|
163
|
-
isOpen: boolean;
|
|
164
|
-
id: string | null;
|
|
165
|
-
data: TData | undefined;
|
|
166
|
-
}
|
|
167
|
-
export interface UseModalActionsReturn {
|
|
168
|
-
openModal: <T = unknown>(id: string, data?: T) => void;
|
|
169
|
-
closeModal: () => void;
|
|
170
|
-
clearModal: () => void;
|
|
125
|
+
export interface Group<T> {
|
|
126
|
+
key: string;
|
|
127
|
+
items: T[];
|
|
171
128
|
}
|
|
172
|
-
export
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
moveToTop: (index: number) => void;
|
|
183
|
-
moveToBottom: (index: number) => void;
|
|
184
|
-
move: (fromIndex: number, toIndex: number) => void;
|
|
185
|
-
swap: (indexA: number, indexB: number) => void;
|
|
186
|
-
replaceOrder: (newOrderedItems: T[]) => void;
|
|
187
|
-
resetOrder: () => void;
|
|
129
|
+
export interface UseGroupingReturn<T> {
|
|
130
|
+
groupedRecord: Record<string, T[]>;
|
|
131
|
+
groupedArray: Group<T>[];
|
|
132
|
+
groupKeys: string[];
|
|
133
|
+
totalGroups: number;
|
|
134
|
+
activeGroupBy: string | undefined;
|
|
135
|
+
changeGroupBy: (newField: string) => void;
|
|
136
|
+
clearGrouping: () => void;
|
|
137
|
+
resetGrouping: () => void;
|
|
138
|
+
getGroupItems: (groupKey: string) => T[];
|
|
188
139
|
}
|
|
189
|
-
export declare function
|
|
140
|
+
export declare function useGrouping<T = unknown>({ items, initialGroupBy, }: {
|
|
141
|
+
items: T[];
|
|
142
|
+
initialGroupBy?: string;
|
|
143
|
+
}): UseGroupingReturn<T>;
|
|
190
144
|
export interface UsePaginationReturn<T> {
|
|
191
145
|
pageItems: T[];
|
|
192
146
|
pageSize: number;
|
|
@@ -205,6 +159,80 @@ export interface UsePaginationReturn<T> {
|
|
|
205
159
|
resetPagination: () => void;
|
|
206
160
|
}
|
|
207
161
|
export declare function usePagination<T>(data: T[], initialPageSize: number, initialPageIndex?: number): UsePaginationReturn<T>;
|
|
162
|
+
export type SelectionId = string | number;
|
|
163
|
+
export interface UseMultipleSelectionReturn<T> {
|
|
164
|
+
selectedIds: SelectionId[];
|
|
165
|
+
selectedCount: number;
|
|
166
|
+
selectedItems: T[];
|
|
167
|
+
isEmpty: boolean;
|
|
168
|
+
select: (item: SelectionId | T) => void;
|
|
169
|
+
deselect: (item: SelectionId | T) => void;
|
|
170
|
+
toggle: (item: SelectionId | T) => void;
|
|
171
|
+
isSelected: (item: SelectionId | T) => boolean;
|
|
172
|
+
resetSelection: () => void;
|
|
173
|
+
replaceSelection: (newSelectedItems: SelectionId[] | T[]) => void;
|
|
174
|
+
selectAll: () => void;
|
|
175
|
+
deselectAll: () => void;
|
|
176
|
+
toggleAll: () => void;
|
|
177
|
+
invertSelection: () => void;
|
|
178
|
+
selectMultiple: (newItems: SelectionId[] | T[]) => void;
|
|
179
|
+
deselectMultiple: (itemsToRemove: SelectionId[] | T[]) => void;
|
|
180
|
+
retainOnly: (itemsToRetain: SelectionId[] | T[]) => void;
|
|
181
|
+
}
|
|
182
|
+
export declare function useMultipleSelection<T = unknown>({ items, field, initialSelectedIds, }: {
|
|
183
|
+
items: T[];
|
|
184
|
+
field?: string;
|
|
185
|
+
initialSelectedIds?: SelectionId[];
|
|
186
|
+
}): UseMultipleSelectionReturn<T>;
|
|
187
|
+
type SelectionId$1 = string | number;
|
|
188
|
+
export interface UseSingleSelectionReturn {
|
|
189
|
+
selectedId: SelectionId$1 | undefined;
|
|
190
|
+
hasSelection: boolean;
|
|
191
|
+
select: (id: SelectionId$1) => void;
|
|
192
|
+
deselect: () => void;
|
|
193
|
+
toggle: (id: SelectionId$1) => void;
|
|
194
|
+
isSelected: (id: SelectionId$1) => boolean;
|
|
195
|
+
resetSelection: () => void;
|
|
196
|
+
}
|
|
197
|
+
export declare function useSingleSelection(initialSelectedId?: SelectionId$1): UseSingleSelectionReturn;
|
|
198
|
+
export interface UseOrderReturn<T> {
|
|
199
|
+
orderedItems: T[];
|
|
200
|
+
moveUp: (index: number) => void;
|
|
201
|
+
moveDown: (index: number) => void;
|
|
202
|
+
canMoveUp: (index: number) => boolean;
|
|
203
|
+
canMoveDown: (index: number) => boolean;
|
|
204
|
+
moveToTop: (index: number) => void;
|
|
205
|
+
moveToBottom: (index: number) => void;
|
|
206
|
+
move: (fromIndex: number, toIndex: number) => void;
|
|
207
|
+
swap: (indexA: number, indexB: number) => void;
|
|
208
|
+
resetOrder: () => void;
|
|
209
|
+
replaceOrder: (newOrderedItems: T[]) => void;
|
|
210
|
+
}
|
|
211
|
+
export declare function useOrder<T>(initialItems: T[]): UseOrderReturn<T>;
|
|
212
|
+
export type PinId = string | number;
|
|
213
|
+
export interface UsePinReturn<T> {
|
|
214
|
+
pinnedIds: PinId[];
|
|
215
|
+
pinnedItems: T[];
|
|
216
|
+
unpinnedItems: T[];
|
|
217
|
+
pinnedCount: number;
|
|
218
|
+
hasPins: boolean;
|
|
219
|
+
isAtMaxLimit: boolean;
|
|
220
|
+
pin: (itemOrId: PinId | T) => void;
|
|
221
|
+
unpin: (itemOrId: PinId | T) => void;
|
|
222
|
+
togglePin: (itemOrId: PinId | T) => void;
|
|
223
|
+
isPinned: (itemOrId: PinId | T) => boolean;
|
|
224
|
+
clearPins: () => void;
|
|
225
|
+
resetPins: () => void;
|
|
226
|
+
replacePins: (newPinnedItems: PinId[] | T[]) => void;
|
|
227
|
+
pinMultiple: (newItems: PinId[] | T[]) => void;
|
|
228
|
+
unpinMultiple: (itemsToRemove: PinId[] | T[]) => void;
|
|
229
|
+
}
|
|
230
|
+
export declare function usePin<T = unknown>({ items, field, initialPinnedIds, maxPins, }: {
|
|
231
|
+
items: T[];
|
|
232
|
+
field?: string;
|
|
233
|
+
initialPinnedIds?: PinId[];
|
|
234
|
+
maxPins?: number;
|
|
235
|
+
}): UsePinReturn<T>;
|
|
208
236
|
export type SortType = "numeric" | "alphabetical" | "alphanumeric" | "boolean" | "date" | "basic" | "custom";
|
|
209
237
|
export interface BaseSortOptions {
|
|
210
238
|
desc?: boolean;
|
|
@@ -246,6 +274,54 @@ export interface UseSortReturn<T> {
|
|
|
246
274
|
getSortIndex: (id: string) => number | undefined;
|
|
247
275
|
}
|
|
248
276
|
export declare function useSort<T>(data: T[], initialSorts?: SortState): UseSortReturn<T>;
|
|
277
|
+
export interface UseModalStateReturn<TData> {
|
|
278
|
+
isOpen: boolean;
|
|
279
|
+
id: string | null;
|
|
280
|
+
data: TData | undefined;
|
|
281
|
+
}
|
|
282
|
+
export interface UseModalActionsReturn {
|
|
283
|
+
openModal: <T = unknown>(id: string, data?: T) => void;
|
|
284
|
+
closeModal: () => void;
|
|
285
|
+
clearModal: () => void;
|
|
286
|
+
}
|
|
287
|
+
export type UseModalReturn<TData> = UseModalStateReturn<TData> & UseModalActionsReturn;
|
|
288
|
+
export declare function useModalState<TData = unknown>(): UseModalStateReturn<TData>;
|
|
289
|
+
export declare function useModalActions(): UseModalActionsReturn;
|
|
290
|
+
export declare function useModal<TData = unknown>(): UseModalReturn<TData>;
|
|
291
|
+
export type VisibilityId = number | string;
|
|
292
|
+
export interface UseVisibilityReturn<T> {
|
|
293
|
+
visibleIds: VisibilityId[];
|
|
294
|
+
visibleItems: T[];
|
|
295
|
+
hiddenItems: T[];
|
|
296
|
+
visibleCount: number;
|
|
297
|
+
isVisible: (itemOrId: VisibilityId | T) => boolean;
|
|
298
|
+
show: (itemOrId: VisibilityId | T) => void;
|
|
299
|
+
hide: (itemOrId: VisibilityId | T) => void;
|
|
300
|
+
toggleVisibility: (itemOrId: VisibilityId | T) => void;
|
|
301
|
+
showAll: (itemsArray?: VisibilityId[] | T[]) => void;
|
|
302
|
+
hideAll: (itemsArray?: VisibilityId[] | T[]) => void;
|
|
303
|
+
resetVisibility: () => void;
|
|
304
|
+
replaceVisibility: (newItems: VisibilityId[] | T[]) => void;
|
|
305
|
+
}
|
|
306
|
+
export declare function useVisibility<T = unknown>({ items, field, initialVisibleIds, }: {
|
|
307
|
+
items: T[];
|
|
308
|
+
field?: string;
|
|
309
|
+
initialVisibleIds?: VisibilityId[];
|
|
310
|
+
}): UseVisibilityReturn<T>;
|
|
311
|
+
export interface DebounceOptions {
|
|
312
|
+
maxWait?: number;
|
|
313
|
+
leading?: boolean;
|
|
314
|
+
trailing?: boolean;
|
|
315
|
+
}
|
|
316
|
+
export interface UseDebounceReturn<Args extends any[]> {
|
|
317
|
+
debouncedFunc: (...args: Args) => void;
|
|
318
|
+
cancel: () => void;
|
|
319
|
+
flush: () => void;
|
|
320
|
+
isPending: boolean;
|
|
321
|
+
}
|
|
322
|
+
export declare function useDebounce<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: DebounceOptions): UseDebounceReturn<Args>;
|
|
323
|
+
export type UseDebouncedValueReturn<T> = T;
|
|
324
|
+
export declare function useDebouncedValue<T>(value: T, delay: number, options?: DebounceOptions): UseDebouncedValueReturn<T>;
|
|
249
325
|
export interface ThrottleOptions {
|
|
250
326
|
leading?: boolean;
|
|
251
327
|
trailing?: boolean;
|
|
@@ -257,5 +333,31 @@ export interface UseThrottleReturn<Args extends any[]> {
|
|
|
257
333
|
isPending: boolean;
|
|
258
334
|
}
|
|
259
335
|
export declare function useThrottle<Args extends any[]>(func: (...args: Args) => void, delay: number, options?: ThrottleOptions): UseThrottleReturn<Args>;
|
|
336
|
+
declare const validKeyEventTypes: readonly [
|
|
337
|
+
"keydown",
|
|
338
|
+
"keyup",
|
|
339
|
+
"keypress"
|
|
340
|
+
];
|
|
341
|
+
export type KeyEventType = (typeof validKeyEventTypes)[number];
|
|
342
|
+
export interface BaseKeyOptions {
|
|
343
|
+
enabled?: boolean;
|
|
344
|
+
target?: React$1.RefObject<HTMLElement | null> | Window;
|
|
345
|
+
preventDefault?: boolean;
|
|
346
|
+
stopPropagation?: boolean;
|
|
347
|
+
ignoreWhenFocusedInInputs?: boolean;
|
|
348
|
+
ctrlKey?: boolean;
|
|
349
|
+
shiftKey?: boolean;
|
|
350
|
+
altKey?: boolean;
|
|
351
|
+
metaKey?: boolean;
|
|
352
|
+
}
|
|
353
|
+
export type KeyOptions = BaseKeyOptions & ({
|
|
354
|
+
eventType?: "keydown" | "keypress";
|
|
355
|
+
preventRepeat?: boolean;
|
|
356
|
+
} | {
|
|
357
|
+
eventType: "keyup";
|
|
358
|
+
preventRepeat?: never;
|
|
359
|
+
});
|
|
360
|
+
export type UseKeyReturn = void;
|
|
361
|
+
export declare function useKey(key: string, handler: (e: KeyboardEvent) => void, { enabled, preventDefault, stopPropagation, eventType, preventRepeat, ignoreWhenFocusedInInputs, ctrlKey, shiftKey, altKey, metaKey, target, }?: KeyOptions): UseKeyReturn;
|
|
260
362
|
|
|
261
363
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,66 @@
|
|
|
1
1
|
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useLayoutEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
//#region src/
|
|
5
|
-
|
|
2
|
+
import { Fragment as c, jsx as l } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal as u } from "react-dom";
|
|
4
|
+
//#region src/ui/highlight/FuzzyHighlighter.tsx
|
|
5
|
+
function d({ text: e, query: t, className: n = "", caseSensitive: r = !1 }) {
|
|
6
|
+
let i = t.trim();
|
|
7
|
+
if (!i || !e) return /* @__PURE__ */ l(c, { children: e });
|
|
8
|
+
let a = i.split(/\s+/).filter((e) => e.length > 0);
|
|
9
|
+
if (a.length === 0) return /* @__PURE__ */ l(c, { children: e });
|
|
10
|
+
let o = `fuzzy-highlight ${n}`.trim(), s = [...a].sort((e, t) => t.length - e.length).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")), u = [...s];
|
|
11
|
+
if (s.length > 1) {
|
|
12
|
+
let e = a.map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+");
|
|
13
|
+
u.unshift(e);
|
|
14
|
+
}
|
|
15
|
+
if (i.length > 1 && i === i.toUpperCase() && /^[A-Z]+$/.test(i)) {
|
|
16
|
+
let e = i.split("").map((e) => `\\b${e}`).join("[^a-z0-9]*");
|
|
17
|
+
u.unshift(e);
|
|
18
|
+
}
|
|
19
|
+
let d = `(${u.join("|")})`, f = new RegExp(d, r ? "g" : "gi");
|
|
20
|
+
return /* @__PURE__ */ l(c, { children: e.split(f).map((e, t) => f.test(e) ? /* @__PURE__ */ l("strong", {
|
|
21
|
+
className: o,
|
|
22
|
+
children: e
|
|
23
|
+
}, t) : e) });
|
|
24
|
+
}
|
|
6
25
|
//#endregion
|
|
7
|
-
//#region src/
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
//#region src/ui/modal/ModalContext.tsx
|
|
27
|
+
var f = e(null), p = e(null);
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/ui/modal/useModal.ts
|
|
30
|
+
function m() {
|
|
31
|
+
let e = n(f);
|
|
10
32
|
if (!e) throw Error("useModalState must be used within a ModalProvider");
|
|
11
33
|
return e;
|
|
12
34
|
}
|
|
13
|
-
function
|
|
14
|
-
let e = n(
|
|
35
|
+
function h() {
|
|
36
|
+
let e = n(p);
|
|
15
37
|
if (!e) throw Error("useModalActions must be used within a ModalProvider");
|
|
16
38
|
return e;
|
|
17
39
|
}
|
|
18
|
-
function
|
|
40
|
+
function g() {
|
|
19
41
|
return {
|
|
20
|
-
...
|
|
21
|
-
...
|
|
42
|
+
...m(),
|
|
43
|
+
...h()
|
|
22
44
|
};
|
|
23
45
|
}
|
|
24
46
|
//#endregion
|
|
25
|
-
//#region src/
|
|
26
|
-
function
|
|
27
|
-
let { isOpen: d, id:
|
|
47
|
+
//#region src/ui/modal/Modal.tsx
|
|
48
|
+
function _({ modalId: e, children: t, wrapperClassName: n = "", wrapperStyle: i, containerClassName: a = "", containerStyle: c }) {
|
|
49
|
+
let { isOpen: d, id: f } = m(), { closeModal: p, clearModal: g } = h(), [_, v] = s(!1), y = o(null), b = f === e, x = d && b;
|
|
28
50
|
return r(() => {
|
|
29
51
|
let e = y.current;
|
|
30
52
|
e && (x && !e.open ? (v(!1), e.showModal()) : !x && e.open && v(!0));
|
|
31
|
-
}, [x]), typeof document > "u" || !b && !_ ? null :
|
|
53
|
+
}, [x]), typeof document > "u" || !b && !_ ? null : u(/* @__PURE__ */ l("dialog", {
|
|
32
54
|
ref: y,
|
|
33
55
|
onCancel: (e) => {
|
|
34
|
-
e.preventDefault(),
|
|
56
|
+
e.preventDefault(), p();
|
|
35
57
|
},
|
|
36
|
-
onClose:
|
|
58
|
+
onClose: p,
|
|
37
59
|
onClick: (e) => {
|
|
38
60
|
let t = y.current;
|
|
39
61
|
if (!t) return;
|
|
40
62
|
let n = t.getBoundingClientRect();
|
|
41
|
-
(e.clientX < n.x || e.clientX > n.x + n.width || e.clientY < n.y || e.clientY > n.y + n.height) &&
|
|
63
|
+
(e.clientX < n.x || e.clientX > n.x + n.width || e.clientY < n.y || e.clientY > n.y + n.height) && p();
|
|
42
64
|
},
|
|
43
65
|
onAnimationEnd: () => {
|
|
44
66
|
if (_) {
|
|
@@ -50,54 +72,21 @@ function h({ modalId: e, children: t, wrapperClassName: n = "", wrapperStyle: i,
|
|
|
50
72
|
style: i,
|
|
51
73
|
children: /* @__PURE__ */ l("div", {
|
|
52
74
|
className: `modal-container ${a}`.trim(),
|
|
53
|
-
style:
|
|
75
|
+
style: c,
|
|
54
76
|
children: t
|
|
55
77
|
})
|
|
56
78
|
}), document.body);
|
|
57
79
|
}
|
|
58
80
|
//#endregion
|
|
59
|
-
//#region src/
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
r
|
|
63
|
-
|
|
64
|
-
}, [e]);
|
|
65
|
-
let _ = t(() => {
|
|
66
|
-
p.current &&= (clearTimeout(p.current), null), m.current = -1, h.current = -1, g.current = null, c(!1);
|
|
67
|
-
}, []), v = t(() => {
|
|
68
|
-
p.current && g.current && (clearTimeout(p.current), p.current = null, f.current(...g.current), m.current = Date.now(), h.current = -1, g.current = null, c(!1));
|
|
69
|
-
}, []);
|
|
70
|
-
return r(() => () => {
|
|
71
|
-
_();
|
|
72
|
-
}, [_]), {
|
|
73
|
-
debouncedFunc: t((...e) => {
|
|
74
|
-
c(!0), h.current = Date.now(), g.current = e, m.current === -1 && (m.current = Date.now(), u === !0 && f.current(...e)), l !== void 0 && Date.now() - m.current >= l ? (p.current && clearTimeout(p.current), f.current(...e), m.current = -1, c(!1)) : (p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
75
|
-
h.current !== m.current && d !== !1 && f.current(...e), m.current = -1, c(!1);
|
|
76
|
-
}, n));
|
|
77
|
-
}, [
|
|
78
|
-
n,
|
|
79
|
-
l,
|
|
80
|
-
d,
|
|
81
|
-
u
|
|
82
|
-
]),
|
|
83
|
-
cancel: _,
|
|
84
|
-
flush: v,
|
|
85
|
-
isPending: a
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/hooks/useDebouncedValue.ts
|
|
90
|
-
function _(e, t, n = {}) {
|
|
91
|
-
let [i, a] = s(e), { debouncedFunc: o } = g((e) => {
|
|
92
|
-
a(e);
|
|
93
|
-
}, t, n);
|
|
94
|
-
return r(() => {
|
|
95
|
-
o(e);
|
|
96
|
-
}, [e, o]), i;
|
|
81
|
+
//#region src/shared/utils.ts
|
|
82
|
+
function v(e, t, n) {
|
|
83
|
+
if (typeof e != "object" || !e) return e;
|
|
84
|
+
let r = t ?? n ?? "";
|
|
85
|
+
return Array.isArray(r) ? r.reduce((e, t) => e?.[t], e) : r.includes(".") ? r.split(".").reduce((e, t) => e?.[t], e) : e?.[r];
|
|
97
86
|
}
|
|
98
87
|
//#endregion
|
|
99
|
-
//#region src/utils
|
|
100
|
-
var
|
|
88
|
+
//#region src/state/filter/utils.ts
|
|
89
|
+
var y = {
|
|
101
90
|
text: {
|
|
102
91
|
contains: (e, t, n) => e == null ? !1 : n?.caseSensitive ? String(e).includes(String(t)) : String(e).toLowerCase().includes(String(t).toLowerCase()),
|
|
103
92
|
equals: (e, t, n) => e == null ? !1 : n?.caseSensitive ? String(e) === String(t) : String(e).toLowerCase() === String(t).toLowerCase(),
|
|
@@ -153,48 +142,41 @@ var v = {
|
|
|
153
142
|
}
|
|
154
143
|
};
|
|
155
144
|
//#endregion
|
|
156
|
-
//#region src/
|
|
157
|
-
function y(e, t, n) {
|
|
158
|
-
if (typeof e != "object" || !e) return e;
|
|
159
|
-
let r = t ?? n ?? "";
|
|
160
|
-
return Array.isArray(r) ? r.reduce((e, t) => e?.[t], e) : r.includes(".") ? r.split(".").reduce((e, t) => e?.[t], e) : e?.[r];
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/hooks/useFilter.ts
|
|
145
|
+
//#region src/state/filter/useFilter.ts
|
|
164
146
|
function b(e, n = []) {
|
|
165
|
-
let
|
|
166
|
-
let t =
|
|
147
|
+
let r = o(n), [i, c] = s(() => n), l = a(() => {
|
|
148
|
+
let t = i.filter((e) => e.isActive !== !1).map((e) => ({
|
|
167
149
|
...e,
|
|
168
150
|
pathArray: (e.field || e.id).split(".")
|
|
169
151
|
}));
|
|
170
152
|
return e.filter((e) => t.every((t) => {
|
|
171
|
-
let { id: n, type: r, operator: i, value: a, compare: o, pathArray: s } = t, c =
|
|
172
|
-
if (r === "custom") return o
|
|
173
|
-
let l =
|
|
153
|
+
let { id: n, type: r, operator: i, value: a, compare: o, pathArray: s } = t, c = v(e, s, n);
|
|
154
|
+
if (r === "custom") return !o || o(c, a, e);
|
|
155
|
+
let l = y[r];
|
|
174
156
|
if (!l) return !0;
|
|
175
157
|
let u = l[i];
|
|
176
|
-
return u
|
|
158
|
+
return !u || u(c, a, t);
|
|
177
159
|
}));
|
|
178
|
-
}, [e,
|
|
179
|
-
|
|
180
|
-
}, []),
|
|
181
|
-
|
|
182
|
-
}, []),
|
|
183
|
-
|
|
184
|
-
}, []),
|
|
185
|
-
|
|
186
|
-
}, [
|
|
187
|
-
|
|
160
|
+
}, [e, i]), u = t((e) => {
|
|
161
|
+
c((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? e : t) : [...t, e]);
|
|
162
|
+
}, []), d = t((e) => {
|
|
163
|
+
c((t) => Array.isArray(e) ? t.filter((t) => !e.includes(t.id)) : t.filter((t) => t.id !== e));
|
|
164
|
+
}, []), f = t(() => {
|
|
165
|
+
c([]);
|
|
166
|
+
}, []), p = t(() => {
|
|
167
|
+
c(r.current);
|
|
168
|
+
}, []), m = t((e) => {
|
|
169
|
+
c(e);
|
|
188
170
|
}, []);
|
|
189
171
|
return {
|
|
190
|
-
filteredItems:
|
|
191
|
-
filters:
|
|
192
|
-
upsertFilter:
|
|
193
|
-
removeFilter:
|
|
194
|
-
clearFilters:
|
|
195
|
-
resetFilters:
|
|
172
|
+
filteredItems: l,
|
|
173
|
+
filters: i,
|
|
174
|
+
upsertFilter: u,
|
|
175
|
+
removeFilter: d,
|
|
176
|
+
clearFilters: f,
|
|
177
|
+
resetFilters: p,
|
|
196
178
|
toggleFilter: t((e) => {
|
|
197
|
-
|
|
179
|
+
c((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? {
|
|
198
180
|
...t,
|
|
199
181
|
isActive: t.isActive === !1
|
|
200
182
|
} : t) : [...t, {
|
|
@@ -203,27 +185,27 @@ function b(e, n = []) {
|
|
|
203
185
|
}]);
|
|
204
186
|
}, []),
|
|
205
187
|
updateFilterConfig: t((e, t) => {
|
|
206
|
-
|
|
188
|
+
c((n) => n.map((n) => n.id === e ? {
|
|
207
189
|
...n,
|
|
208
190
|
...t
|
|
209
191
|
} : n));
|
|
210
192
|
}, []),
|
|
211
|
-
replaceFilters:
|
|
212
|
-
getFilterValue: t((e) =>
|
|
193
|
+
replaceFilters: m,
|
|
194
|
+
getFilterValue: t((e) => i.find((t) => t.id === e)?.value, [i]),
|
|
213
195
|
updateFilterValue: t((e, t) => {
|
|
214
|
-
|
|
196
|
+
c((n) => n.map((n) => n.id === e ? {
|
|
215
197
|
...n,
|
|
216
198
|
value: t
|
|
217
199
|
} : n));
|
|
218
200
|
}, []),
|
|
219
201
|
isFilterActive: t((e) => {
|
|
220
|
-
let t =
|
|
202
|
+
let t = i.find((t) => t.id === e);
|
|
221
203
|
return t ? t.isActive !== !1 : !1;
|
|
222
|
-
}, [
|
|
204
|
+
}, [i])
|
|
223
205
|
};
|
|
224
206
|
}
|
|
225
207
|
//#endregion
|
|
226
|
-
//#region src/utils
|
|
208
|
+
//#region src/state/fuzzy-search/utils.ts
|
|
227
209
|
function x(e, t, n = !1) {
|
|
228
210
|
let r = e.trim(), i = t.trim(), a = r.length > 1 && r === r.toUpperCase() && /^[A-Z]+$/.test(r);
|
|
229
211
|
if (n || (r = r.toLowerCase(), i = i.toLowerCase()), r === i) return 1;
|
|
@@ -272,12 +254,12 @@ function x(e, t, n = !1) {
|
|
|
272
254
|
return Math.max(0, _ * .45);
|
|
273
255
|
}
|
|
274
256
|
//#endregion
|
|
275
|
-
//#region src/
|
|
257
|
+
//#region src/state/fuzzy-search/useFuzzySearch.ts
|
|
276
258
|
function S(e, t, n, r = {}) {
|
|
277
259
|
let i = r.threshold ?? .01, o = r.caseSensitive ?? !1, s = r.matchStrategy ?? "any", c = r.exactPhraseBonus ?? !0, l = a(() => n.length === 0 || e.length === 0 ? [] : e.map((e, t) => {
|
|
278
260
|
let r = [], i = [];
|
|
279
261
|
for (let { field: t, weight: a } of n) {
|
|
280
|
-
let n =
|
|
262
|
+
let n = v(e, t);
|
|
281
263
|
if (Array.isArray(n)) {
|
|
282
264
|
for (let e of n) if (e != null && e !== "" && typeof e != "object") {
|
|
283
265
|
let t = String(e);
|
|
@@ -354,118 +336,36 @@ function S(e, t, n, r = {}) {
|
|
|
354
336
|
]);
|
|
355
337
|
}
|
|
356
338
|
//#endregion
|
|
357
|
-
//#region src/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
]
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}, [
|
|
370
|
-
|
|
371
|
-
}, [n]),
|
|
372
|
-
let t = h && "current" in h ? h.current : h;
|
|
373
|
-
if (!t) return;
|
|
374
|
-
let n = e.toLowerCase(), r = C.includes(c) ? c : "keydown", i = l && r !== "keyup";
|
|
375
|
-
function o() {
|
|
376
|
-
v.current = !1;
|
|
377
|
-
}
|
|
378
|
-
function y(e) {
|
|
379
|
-
if (!(e instanceof KeyboardEvent)) return;
|
|
380
|
-
let t = e.key.toLowerCase();
|
|
381
|
-
(t === n || d && t === "control" || f && t === "shift" || p && t === "alt" || m && t === "meta") && (v.current = !1);
|
|
382
|
-
}
|
|
383
|
-
function b(e) {
|
|
384
|
-
if (!(e instanceof KeyboardEvent) || !_.current) return;
|
|
385
|
-
let t = e.target;
|
|
386
|
-
if (!(u && t instanceof HTMLElement && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement || t.isContentEditable)) && e.ctrlKey === d && e.shiftKey === f && e.altKey === p && e.metaKey === m && n === e.key.toLowerCase()) {
|
|
387
|
-
if (i && v.current) return;
|
|
388
|
-
v.current = !0, g.current(e), a && e.preventDefault(), s && e.stopPropagation();
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return t.addEventListener(r, b), i && (t.addEventListener("keyup", y), window.addEventListener("blur", o)), () => {
|
|
392
|
-
t.removeEventListener(r, b), i && (t.removeEventListener("keyup", y), window.removeEventListener("blur", o));
|
|
393
|
-
};
|
|
394
|
-
}, [
|
|
395
|
-
e,
|
|
396
|
-
a,
|
|
397
|
-
s,
|
|
398
|
-
c,
|
|
399
|
-
l,
|
|
400
|
-
u,
|
|
401
|
-
d,
|
|
402
|
-
f,
|
|
403
|
-
p,
|
|
404
|
-
m,
|
|
405
|
-
h
|
|
406
|
-
]);
|
|
407
|
-
}
|
|
408
|
-
//#endregion
|
|
409
|
-
//#region src/hooks/useOrder.ts
|
|
410
|
-
function T(e) {
|
|
411
|
-
let n = o(e), [r, i] = s(e);
|
|
339
|
+
//#region src/state/grouping/useGrouping.ts
|
|
340
|
+
function C({ items: e, initialGroupBy: n }) {
|
|
341
|
+
let [r, i] = s(n), o = a(() => r ? e.reduce((e, t) => {
|
|
342
|
+
let n = v(t, r), i = n == null ? "Unknown" : String(n);
|
|
343
|
+
return e[i] || (e[i] = []), e[i].push(t), e;
|
|
344
|
+
}, {}) : { Ungrouped: e }, [e, r]), c = a(() => Object.keys(o).map((e) => ({
|
|
345
|
+
key: e,
|
|
346
|
+
items: o[e]
|
|
347
|
+
})), [o]), l = a(() => Object.keys(o), [o]), u = t((e) => {
|
|
348
|
+
i(e);
|
|
349
|
+
}, []), d = t(() => {
|
|
350
|
+
i(void 0);
|
|
351
|
+
}, []), f = t(() => {
|
|
352
|
+
i(n);
|
|
353
|
+
}, [n]), p = t((e) => o[e] || [], [o]);
|
|
412
354
|
return {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
typeof e == "number" && i((t) => {
|
|
423
|
-
if (e < 0 || e >= t.length - 1) return t;
|
|
424
|
-
let n = [...t];
|
|
425
|
-
return [n[e], n[e + 1]] = [n[e + 1], n[e]], n;
|
|
426
|
-
});
|
|
427
|
-
}, []),
|
|
428
|
-
canMoveUp: t((e) => e > 0, []),
|
|
429
|
-
canMoveDown: t((e) => e < r.length - 1, [r.length]),
|
|
430
|
-
moveToTop: t((e) => {
|
|
431
|
-
typeof e == "number" && i((t) => {
|
|
432
|
-
if (e <= 0 || e >= t.length) return t;
|
|
433
|
-
let n = [...t], [r] = n.splice(e, 1);
|
|
434
|
-
return n.unshift(r), n;
|
|
435
|
-
});
|
|
436
|
-
}, []),
|
|
437
|
-
moveToBottom: t((e) => {
|
|
438
|
-
typeof e == "number" && i((t) => {
|
|
439
|
-
if (e < 0 || e >= t.length - 1) return t;
|
|
440
|
-
let n = [...t], [r] = n.splice(e, 1);
|
|
441
|
-
return n.push(r), n;
|
|
442
|
-
});
|
|
443
|
-
}, []),
|
|
444
|
-
move: t((e, t) => {
|
|
445
|
-
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
446
|
-
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
447
|
-
let r = [...n], [i] = r.splice(e, 1);
|
|
448
|
-
return r.splice(t, 0, i), r;
|
|
449
|
-
});
|
|
450
|
-
}, []),
|
|
451
|
-
swap: t((e, t) => {
|
|
452
|
-
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
453
|
-
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
454
|
-
let r = [...n];
|
|
455
|
-
return [r[e], r[t]] = [r[t], r[e]], r;
|
|
456
|
-
});
|
|
457
|
-
}, []),
|
|
458
|
-
replaceOrder: t((e) => {
|
|
459
|
-
i(e);
|
|
460
|
-
}, []),
|
|
461
|
-
resetOrder: t(() => {
|
|
462
|
-
i(n.current);
|
|
463
|
-
}, [])
|
|
355
|
+
groupedRecord: o,
|
|
356
|
+
groupedArray: c,
|
|
357
|
+
groupKeys: l,
|
|
358
|
+
totalGroups: l.length,
|
|
359
|
+
activeGroupBy: r,
|
|
360
|
+
changeGroupBy: u,
|
|
361
|
+
clearGrouping: d,
|
|
362
|
+
resetGrouping: f,
|
|
363
|
+
getGroupItems: p
|
|
464
364
|
};
|
|
465
365
|
}
|
|
466
366
|
//#endregion
|
|
467
|
-
//#region src/
|
|
468
|
-
function
|
|
367
|
+
//#region src/state/pagination/usePagination.ts
|
|
368
|
+
function w(e, n, r = 0) {
|
|
469
369
|
let [i, o] = s(n), [c, l] = s(r), u = Math.max(1, Math.ceil(e.length / Math.max(1, i))), d = Math.min(Math.max(0, c), u - 1);
|
|
470
370
|
return c !== d && l(d), {
|
|
471
371
|
pageItems: a(() => typeof i != "number" || i < 1 ? [] : e.slice(c * i, (c + 1) * i), [
|
|
@@ -520,27 +420,256 @@ function E(e, n, r = 0) {
|
|
|
520
420
|
};
|
|
521
421
|
}
|
|
522
422
|
//#endregion
|
|
523
|
-
//#region src/
|
|
524
|
-
function
|
|
525
|
-
let
|
|
423
|
+
//#region src/state/selection/useMultipleSelection.ts
|
|
424
|
+
function T({ items: e, field: n, initialSelectedIds: r = [] }) {
|
|
425
|
+
let i = o(r), [c, l] = s(() => new Set(r)), u = t((e) => {
|
|
426
|
+
l((t) => {
|
|
427
|
+
let r = new Set(t), i = v(e, n);
|
|
428
|
+
return r.add(i), r;
|
|
429
|
+
});
|
|
430
|
+
}, [n]), d = t((e) => {
|
|
431
|
+
l((t) => {
|
|
432
|
+
let r = new Set(t), i = v(e, n);
|
|
433
|
+
return r.delete(i), r;
|
|
434
|
+
});
|
|
435
|
+
}, [n]), f = t((e) => {
|
|
436
|
+
l((t) => {
|
|
437
|
+
let r = new Set(t), i = v(e, n);
|
|
438
|
+
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
439
|
+
});
|
|
440
|
+
}, [n]), p = t((e) => {
|
|
441
|
+
let t = v(e, n);
|
|
442
|
+
return c.has(t);
|
|
443
|
+
}, [c, n]), m = t(() => l(new Set(i.current)), []), h = t((e) => {
|
|
444
|
+
let t = e.map((e) => v(e, n));
|
|
445
|
+
l(new Set(t));
|
|
446
|
+
}, [n]), g = t(() => {
|
|
447
|
+
let t = e.map((e) => v(e, n));
|
|
448
|
+
l(new Set(t));
|
|
449
|
+
}, [e, n]), _ = t(() => {
|
|
450
|
+
l(/* @__PURE__ */ new Set());
|
|
451
|
+
}, []), y = t(() => l((t) => {
|
|
452
|
+
if (t.size === e.length) return /* @__PURE__ */ new Set();
|
|
453
|
+
let r = e.map((e) => v(e, n));
|
|
454
|
+
return new Set(r);
|
|
455
|
+
}), [e, n]), b = t(() => l((t) => {
|
|
456
|
+
if (t.size === e.length) return /* @__PURE__ */ new Set();
|
|
457
|
+
let r = e.filter((e) => !t.has(v(e, n))).map((e) => v(e, n));
|
|
458
|
+
return new Set(r);
|
|
459
|
+
}), [e, n]), x = t((e) => {
|
|
460
|
+
l((t) => {
|
|
461
|
+
let r = new Set(t);
|
|
462
|
+
return e.map((e) => v(e, n)).forEach((e) => r.add(e)), r;
|
|
463
|
+
});
|
|
464
|
+
}, [n]), S = t((e) => {
|
|
465
|
+
l((t) => {
|
|
466
|
+
let r = new Set(t);
|
|
467
|
+
return e.map((e) => v(e, n)).forEach((e) => r.delete(e)), r;
|
|
468
|
+
});
|
|
469
|
+
}, [n]), C = t((e) => {
|
|
470
|
+
l((t) => {
|
|
471
|
+
let r = /* @__PURE__ */ new Set();
|
|
472
|
+
return e.map((e) => v(e, n)).forEach((e) => t.has(e) && r.add(e)), r;
|
|
473
|
+
});
|
|
474
|
+
}, [n]), w = a(() => e.filter((e) => {
|
|
475
|
+
let t = v(e, n);
|
|
476
|
+
return c.has(t);
|
|
477
|
+
}), [
|
|
478
|
+
e,
|
|
479
|
+
n,
|
|
480
|
+
c
|
|
481
|
+
]);
|
|
482
|
+
return {
|
|
483
|
+
selectedIds: [...c],
|
|
484
|
+
selectedCount: c.size,
|
|
485
|
+
selectedItems: w,
|
|
486
|
+
isEmpty: c.size === 0,
|
|
487
|
+
select: u,
|
|
488
|
+
deselect: d,
|
|
489
|
+
toggle: f,
|
|
490
|
+
isSelected: p,
|
|
491
|
+
replaceSelection: h,
|
|
492
|
+
resetSelection: m,
|
|
493
|
+
selectAll: g,
|
|
494
|
+
deselectAll: _,
|
|
495
|
+
toggleAll: y,
|
|
496
|
+
invertSelection: b,
|
|
497
|
+
selectMultiple: x,
|
|
498
|
+
deselectMultiple: S,
|
|
499
|
+
retainOnly: C
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/state/selection/useSingleSelection.ts
|
|
504
|
+
function E(e) {
|
|
505
|
+
let [n, r] = s(e), i = t((e) => r(e), []), a = t(() => r(void 0), []), o = t((e) => r((t) => t === e ? void 0 : e), []), c = t((e) => n === e, [n]), l = t(() => r(e), [e]);
|
|
506
|
+
return {
|
|
507
|
+
selectedId: n,
|
|
508
|
+
hasSelection: !!n,
|
|
509
|
+
select: i,
|
|
510
|
+
deselect: a,
|
|
511
|
+
toggle: o,
|
|
512
|
+
isSelected: c,
|
|
513
|
+
resetSelection: l
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/state/sort/useOrder.ts
|
|
518
|
+
function D(e) {
|
|
519
|
+
let n = o(e), [r, i] = s(() => e), a = t((e) => {
|
|
520
|
+
typeof e == "number" && i((t) => {
|
|
521
|
+
if (e <= 0 || e >= t.length) return t;
|
|
522
|
+
let n = [...t];
|
|
523
|
+
return [n[e], n[e - 1]] = [n[e - 1], n[e]], n;
|
|
524
|
+
});
|
|
525
|
+
}, []), c = t((e) => {
|
|
526
|
+
typeof e == "number" && i((t) => {
|
|
527
|
+
if (e < 0 || e >= t.length - 1) return t;
|
|
528
|
+
let n = [...t];
|
|
529
|
+
return [n[e], n[e + 1]] = [n[e + 1], n[e]], n;
|
|
530
|
+
});
|
|
531
|
+
}, []), l = t((e) => e > 0, []), u = t((e) => e < r.length - 1, [r.length]), d = t((e) => {
|
|
532
|
+
typeof e == "number" && i((t) => {
|
|
533
|
+
if (e <= 0 || e >= t.length) return t;
|
|
534
|
+
let n = [...t], [r] = n.splice(e, 1);
|
|
535
|
+
return n.unshift(r), n;
|
|
536
|
+
});
|
|
537
|
+
}, []), f = t((e) => {
|
|
538
|
+
typeof e == "number" && i((t) => {
|
|
539
|
+
if (e < 0 || e >= t.length - 1) return t;
|
|
540
|
+
let n = [...t], [r] = n.splice(e, 1);
|
|
541
|
+
return n.push(r), n;
|
|
542
|
+
});
|
|
543
|
+
}, []), p = t((e, t) => {
|
|
544
|
+
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
545
|
+
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
546
|
+
let r = [...n], [i] = r.splice(e, 1);
|
|
547
|
+
return r.splice(t, 0, i), r;
|
|
548
|
+
});
|
|
549
|
+
}, []), m = t((e, t) => {
|
|
550
|
+
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
551
|
+
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
552
|
+
let r = [...n];
|
|
553
|
+
return [r[e], r[t]] = [r[t], r[e]], r;
|
|
554
|
+
});
|
|
555
|
+
}, []), h = t(() => {
|
|
556
|
+
i(n.current);
|
|
557
|
+
}, []);
|
|
558
|
+
return {
|
|
559
|
+
orderedItems: r,
|
|
560
|
+
moveUp: a,
|
|
561
|
+
moveDown: c,
|
|
562
|
+
canMoveUp: l,
|
|
563
|
+
canMoveDown: u,
|
|
564
|
+
moveToTop: d,
|
|
565
|
+
moveToBottom: f,
|
|
566
|
+
move: p,
|
|
567
|
+
swap: m,
|
|
568
|
+
replaceOrder: t((e) => {
|
|
569
|
+
i(e);
|
|
570
|
+
}, []),
|
|
571
|
+
resetOrder: h
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/state/sort/usePin.ts
|
|
576
|
+
function O({ items: e, field: n, initialPinnedIds: r = [], maxPins: i = 2 ** 53 - 1 }) {
|
|
577
|
+
let c = o(r), [l, u] = s(() => new Set(r)), d = t((e) => {
|
|
578
|
+
u((t) => {
|
|
579
|
+
if (t.size >= i) return t;
|
|
580
|
+
let r = new Set(t), a = v(e, n);
|
|
581
|
+
return r.add(a), r;
|
|
582
|
+
});
|
|
583
|
+
}, [n, i]), f = t((e) => {
|
|
584
|
+
u((t) => {
|
|
585
|
+
let r = new Set(t), i = v(e, n);
|
|
586
|
+
return r.delete(i), r;
|
|
587
|
+
});
|
|
588
|
+
}, [n]), p = t((e) => {
|
|
589
|
+
u((t) => {
|
|
590
|
+
let r = new Set(t), a = v(e, n);
|
|
591
|
+
if (r.has(a)) r.delete(a);
|
|
592
|
+
else {
|
|
593
|
+
if (r.size >= i) return t;
|
|
594
|
+
r.add(a);
|
|
595
|
+
}
|
|
596
|
+
return r;
|
|
597
|
+
});
|
|
598
|
+
}, [n, i]), m = t((e) => {
|
|
599
|
+
let t = v(e, n);
|
|
600
|
+
return l.has(t);
|
|
601
|
+
}, [l, n]), h = t(() => u(/* @__PURE__ */ new Set()), []), g = t(() => u(new Set(c.current)), [c]), _ = t((e) => {
|
|
602
|
+
let t = e.map((e) => v(e, n));
|
|
603
|
+
u(new Set(t.slice(0, i)));
|
|
604
|
+
}, [n, i]), y = t((e) => {
|
|
605
|
+
u((t) => {
|
|
606
|
+
let r = new Set(t), a = e.map((e) => v(e, n));
|
|
607
|
+
for (let e of a) {
|
|
608
|
+
if (r.size >= i && !r.has(e)) break;
|
|
609
|
+
r.add(e);
|
|
610
|
+
}
|
|
611
|
+
return r;
|
|
612
|
+
});
|
|
613
|
+
}, [n, i]), b = t((e) => {
|
|
614
|
+
u((t) => {
|
|
615
|
+
let r = new Set(t);
|
|
616
|
+
return e.map((e) => v(e, n)).forEach((e) => r.delete(e)), r;
|
|
617
|
+
});
|
|
618
|
+
}, [n]), x = a(() => e.filter((e) => {
|
|
619
|
+
let t = v(e, n);
|
|
620
|
+
return l.has(t);
|
|
621
|
+
}), [
|
|
622
|
+
e,
|
|
623
|
+
n,
|
|
624
|
+
l
|
|
625
|
+
]), S = a(() => e.filter((e) => {
|
|
626
|
+
let t = v(e, n);
|
|
627
|
+
return !l.has(t);
|
|
628
|
+
}), [
|
|
629
|
+
e,
|
|
630
|
+
n,
|
|
631
|
+
l
|
|
632
|
+
]);
|
|
633
|
+
return {
|
|
634
|
+
pinnedIds: [...l],
|
|
635
|
+
pinnedItems: x,
|
|
636
|
+
unpinnedItems: S,
|
|
637
|
+
pinnedCount: l.size,
|
|
638
|
+
hasPins: l.size > 0,
|
|
639
|
+
isAtMaxLimit: l.size >= i,
|
|
640
|
+
pin: d,
|
|
641
|
+
unpin: f,
|
|
642
|
+
togglePin: p,
|
|
643
|
+
isPinned: m,
|
|
644
|
+
clearPins: h,
|
|
645
|
+
resetPins: g,
|
|
646
|
+
replacePins: _,
|
|
647
|
+
pinMultiple: y,
|
|
648
|
+
unpinMultiple: b
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/state/sort/utils.ts
|
|
653
|
+
function k(e, t, n = {}) {
|
|
654
|
+
let { sortUndefined: r, desc: i = !1 } = n, a = I(e, t, r, i);
|
|
526
655
|
if (a !== null) return a;
|
|
527
656
|
let o = !!e;
|
|
528
657
|
return o === !!t ? 0 : o ? 1 : -1;
|
|
529
658
|
}
|
|
530
|
-
function
|
|
531
|
-
let { sortUndefined: r, desc: i = !1 } = n, a =
|
|
659
|
+
function A(e, t, n = {}) {
|
|
660
|
+
let { sortUndefined: r, desc: i = !1 } = n, a = I(e, t, r, i);
|
|
532
661
|
if (a !== null) return a;
|
|
533
662
|
let o = Number(e), s = Number(t), c = Number.isNaN(o), l = Number.isNaN(s);
|
|
534
|
-
return c || l ?
|
|
663
|
+
return c || l ? I(c ? void 0 : o, l ? void 0 : s, r, i) ?? 0 : o - s;
|
|
535
664
|
}
|
|
536
|
-
function
|
|
537
|
-
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o =
|
|
665
|
+
function j(e, t, n = {}) {
|
|
666
|
+
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o = I(e, t, i, r);
|
|
538
667
|
if (o !== null) return o;
|
|
539
668
|
let s = String(e), c = String(t);
|
|
540
669
|
return s.localeCompare(c, void 0, { sensitivity: a ? "variant" : "base" });
|
|
541
670
|
}
|
|
542
|
-
function
|
|
543
|
-
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o =
|
|
671
|
+
function M(e, t, n = {}) {
|
|
672
|
+
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o = I(e, t, i, r);
|
|
544
673
|
if (o !== null) return o;
|
|
545
674
|
let s = String(e), c = String(t);
|
|
546
675
|
return s.localeCompare(c, void 0, {
|
|
@@ -548,21 +677,21 @@ function A(e, t, n = {}) {
|
|
|
548
677
|
sensitivity: a ? "variant" : "base"
|
|
549
678
|
});
|
|
550
679
|
}
|
|
551
|
-
function
|
|
552
|
-
let { desc: r = !1, sortUndefined: i } = n, a =
|
|
680
|
+
function N(e, t, n = {}) {
|
|
681
|
+
let { desc: r = !1, sortUndefined: i } = n, a = I(e, t, i, r);
|
|
553
682
|
if (a !== null) return a;
|
|
554
683
|
let o = new Date(e).getTime(), s = new Date(t).getTime(), c = Number.isNaN(o), l = Number.isNaN(s);
|
|
555
|
-
return (c || l) && (a =
|
|
684
|
+
return (c || l) && (a = I(c ? void 0 : o, l ? void 0 : s, i, r), a !== null) ? a : o - s;
|
|
556
685
|
}
|
|
557
|
-
function
|
|
558
|
-
let { desc: r = !1, sortUndefined: i } = n, a =
|
|
686
|
+
function P(e, t, n = {}) {
|
|
687
|
+
let { desc: r = !1, sortUndefined: i } = n, a = I(e, t, i, r);
|
|
559
688
|
return a === null ? e < t ? -1 : +(e > t) : a;
|
|
560
689
|
}
|
|
561
|
-
function
|
|
562
|
-
let { desc: r = !1, sortUndefined: i, compare: a } = n, o =
|
|
690
|
+
function F(e, t, n = {}) {
|
|
691
|
+
let { desc: r = !1, sortUndefined: i, compare: a } = n, o = I(e, t, i, r);
|
|
563
692
|
return o === null ? typeof a == "function" ? a(e, t) : e < t ? -1 : +(e > t) : o;
|
|
564
693
|
}
|
|
565
|
-
function
|
|
694
|
+
function I(e, t, n = "last", r) {
|
|
566
695
|
let i = e == null || e === "", a = t == null || t === "";
|
|
567
696
|
if (i && a) return 0;
|
|
568
697
|
if (!i && !a) return null;
|
|
@@ -579,71 +708,71 @@ function P(e, t, n = "last", r) {
|
|
|
579
708
|
return null;
|
|
580
709
|
}
|
|
581
710
|
//#endregion
|
|
582
|
-
//#region src/
|
|
583
|
-
function
|
|
584
|
-
let
|
|
585
|
-
let t =
|
|
711
|
+
//#region src/state/sort/useSort.ts
|
|
712
|
+
function L(e, n = []) {
|
|
713
|
+
let r = o(n), [i, c] = s(() => n), l = a(() => {
|
|
714
|
+
let t = i.map((e) => ({
|
|
586
715
|
...e,
|
|
587
716
|
pathArray: (e.field || e.id).split(".")
|
|
588
717
|
}));
|
|
589
718
|
return [...e].sort((e, n) => {
|
|
590
719
|
for (let r of t) {
|
|
591
|
-
let { type: t, id: i, desc: a = !1, invertSorting: o = !1, pathArray: s } = r, c =
|
|
720
|
+
let { type: t, id: i, desc: a = !1, invertSorting: o = !1, pathArray: s } = r, c = v(e, s, i), l = v(n, s, i), u;
|
|
592
721
|
switch (t) {
|
|
593
722
|
case "numeric":
|
|
594
|
-
u =
|
|
723
|
+
u = A(c, l, r);
|
|
595
724
|
break;
|
|
596
725
|
case "alphabetical":
|
|
597
|
-
u =
|
|
726
|
+
u = j(c, l, r);
|
|
598
727
|
break;
|
|
599
728
|
case "alphanumeric":
|
|
600
|
-
u =
|
|
729
|
+
u = M(c, l, r);
|
|
601
730
|
break;
|
|
602
731
|
case "boolean":
|
|
603
|
-
u =
|
|
732
|
+
u = k(c, l, r);
|
|
604
733
|
break;
|
|
605
734
|
case "date":
|
|
606
|
-
u =
|
|
735
|
+
u = N(c, l, r);
|
|
607
736
|
break;
|
|
608
737
|
case "basic":
|
|
609
|
-
u =
|
|
738
|
+
u = P(c, l, r);
|
|
610
739
|
break;
|
|
611
740
|
case "custom":
|
|
612
|
-
u =
|
|
741
|
+
u = F(c, l, r);
|
|
613
742
|
break;
|
|
614
|
-
default: u =
|
|
743
|
+
default: u = P(c, l, r);
|
|
615
744
|
}
|
|
616
745
|
if (u !== 0) return u * (a === o ? 1 : -1);
|
|
617
746
|
}
|
|
618
747
|
return 0;
|
|
619
748
|
});
|
|
620
|
-
}, [
|
|
621
|
-
|
|
622
|
-
}, []),
|
|
623
|
-
let { multi: r = !1, ...
|
|
624
|
-
|
|
625
|
-
let
|
|
626
|
-
if (!
|
|
627
|
-
let
|
|
749
|
+
}, [i, e]), u = t((e) => c((t) => t.some((t) => t.id === e.id) ? t.map((t) => t.id === e.id ? e : t) : [...t, e]), []), d = t((e) => {
|
|
750
|
+
c((t) => Array.isArray(e) ? t.filter((t) => !e.includes(t.id)) : t.filter((t) => t.id !== e));
|
|
751
|
+
}, []), f = t(() => c([]), []), p = t(() => c(r.current), []), m = t((e) => c(e), []), h = t((e, t, n) => {
|
|
752
|
+
let { multi: r = !1, ...i } = n || {};
|
|
753
|
+
c((n) => {
|
|
754
|
+
let a = n.find((t) => t.id === e);
|
|
755
|
+
if (!a) {
|
|
756
|
+
let a = {
|
|
628
757
|
id: e,
|
|
629
758
|
type: t,
|
|
630
|
-
...
|
|
759
|
+
...i,
|
|
631
760
|
desc: !1
|
|
632
761
|
};
|
|
633
|
-
return r ? [...n,
|
|
762
|
+
return r ? [...n, a] : [a];
|
|
634
763
|
}
|
|
635
|
-
if (!
|
|
764
|
+
if (!a.desc) {
|
|
636
765
|
let t = {
|
|
637
|
-
...i,
|
|
638
766
|
...a,
|
|
767
|
+
...i,
|
|
639
768
|
desc: !0
|
|
640
769
|
};
|
|
641
770
|
return r ? n.map((n) => n.id === e ? t : n) : [t];
|
|
642
771
|
}
|
|
643
|
-
if (
|
|
772
|
+
if (a.disableSortRemoval || i.disableSortRemoval) {
|
|
644
773
|
let t = {
|
|
645
|
-
...i,
|
|
646
774
|
...a,
|
|
775
|
+
...i,
|
|
647
776
|
desc: !1
|
|
648
777
|
};
|
|
649
778
|
return r ? n.map((n) => n.id === e ? t : n) : [t];
|
|
@@ -652,31 +781,141 @@ function F(e, n = []) {
|
|
|
652
781
|
});
|
|
653
782
|
}, []);
|
|
654
783
|
return {
|
|
655
|
-
sortedItems:
|
|
656
|
-
sorts:
|
|
657
|
-
upsertSorts:
|
|
658
|
-
removeSort:
|
|
659
|
-
clearSorts:
|
|
660
|
-
resetSorts:
|
|
661
|
-
replaceSorts:
|
|
784
|
+
sortedItems: l,
|
|
785
|
+
sorts: i,
|
|
786
|
+
upsertSorts: u,
|
|
787
|
+
removeSort: d,
|
|
788
|
+
clearSorts: f,
|
|
789
|
+
resetSorts: p,
|
|
790
|
+
replaceSorts: m,
|
|
662
791
|
getSortDirection: t((e) => {
|
|
663
|
-
let t =
|
|
792
|
+
let t = i.find((t) => t.id === e);
|
|
664
793
|
return t ? t.desc ? "desc" : "asc" : void 0;
|
|
665
|
-
}, [
|
|
666
|
-
toggleSort:
|
|
794
|
+
}, [i]),
|
|
795
|
+
toggleSort: h,
|
|
667
796
|
getNextSortingOrder: t((e) => {
|
|
668
|
-
let t =
|
|
797
|
+
let t = i.find((t) => t.id === e);
|
|
669
798
|
return t ? t.desc ? t.disableSortRemoval ? "asc" : "none" : "desc" : "asc";
|
|
670
|
-
}, [
|
|
799
|
+
}, [i]),
|
|
671
800
|
getSortIndex: t((e) => {
|
|
672
|
-
let t =
|
|
801
|
+
let t = i.findIndex((t) => t.id === e);
|
|
673
802
|
return t === -1 ? void 0 : t + 1;
|
|
674
|
-
}, [
|
|
803
|
+
}, [i])
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/ui/visibility/useVisibility.ts
|
|
808
|
+
function R({ items: e, field: n, initialVisibleIds: r = [] }) {
|
|
809
|
+
let i = o(r), [c, l] = s(() => new Set(r)), u = t((e) => {
|
|
810
|
+
let t = v(e, n);
|
|
811
|
+
return c.has(t);
|
|
812
|
+
}, [c, n]), d = t((e) => {
|
|
813
|
+
l((t) => {
|
|
814
|
+
let r = new Set(t), i = v(e, n);
|
|
815
|
+
return r.add(i), r;
|
|
816
|
+
});
|
|
817
|
+
}, [n]), f = t((e) => {
|
|
818
|
+
l((t) => {
|
|
819
|
+
let r = new Set(t), i = v(e, n);
|
|
820
|
+
return r.delete(i), r;
|
|
821
|
+
});
|
|
822
|
+
}, [n]), p = t((e) => {
|
|
823
|
+
l((t) => {
|
|
824
|
+
let r = new Set(t), i = v(e, n);
|
|
825
|
+
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
826
|
+
});
|
|
827
|
+
}, [n]), m = t((t) => {
|
|
828
|
+
l((r) => {
|
|
829
|
+
let i = new Set(r);
|
|
830
|
+
return (t ?? e).forEach((e) => {
|
|
831
|
+
i.add(v(e, n));
|
|
832
|
+
}), i;
|
|
833
|
+
});
|
|
834
|
+
}, [e, n]), h = t((t) => {
|
|
835
|
+
l((r) => {
|
|
836
|
+
let i = new Set(r);
|
|
837
|
+
return (t ?? e).forEach((e) => {
|
|
838
|
+
i.delete(v(e, n));
|
|
839
|
+
}), i;
|
|
840
|
+
});
|
|
841
|
+
}, [e, n]), g = t(() => {
|
|
842
|
+
l(() => new Set(i.current));
|
|
843
|
+
}, []), _ = t((e) => {
|
|
844
|
+
let t = e.map((e) => v(e, n));
|
|
845
|
+
l(() => new Set(t));
|
|
846
|
+
}, [n]), y = a(() => e.filter((e) => {
|
|
847
|
+
let t = v(e, n);
|
|
848
|
+
return c.has(t);
|
|
849
|
+
}), [
|
|
850
|
+
e,
|
|
851
|
+
n,
|
|
852
|
+
c
|
|
853
|
+
]), b = a(() => e.filter((e) => {
|
|
854
|
+
let t = v(e, n);
|
|
855
|
+
return !c.has(t);
|
|
856
|
+
}), [
|
|
857
|
+
e,
|
|
858
|
+
n,
|
|
859
|
+
c
|
|
860
|
+
]);
|
|
861
|
+
return {
|
|
862
|
+
visibleIds: [...c],
|
|
863
|
+
visibleItems: y,
|
|
864
|
+
hiddenItems: b,
|
|
865
|
+
visibleCount: c.size,
|
|
866
|
+
isVisible: u,
|
|
867
|
+
show: d,
|
|
868
|
+
hide: f,
|
|
869
|
+
toggleVisibility: p,
|
|
870
|
+
showAll: m,
|
|
871
|
+
hideAll: h,
|
|
872
|
+
replaceVisibility: _,
|
|
873
|
+
resetVisibility: g
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/performance/debounce/useDebounce.ts
|
|
878
|
+
function z(e, n, i = {}) {
|
|
879
|
+
let [a, c] = s(!1), l = i.maxWait, u = !!i.leading, d = !u && i.trailing === !1 ? !0 : i.trailing ?? !u, f = o(e), p = o(null), m = o(-1), h = o(-1), g = o(null);
|
|
880
|
+
r(() => {
|
|
881
|
+
f.current = e;
|
|
882
|
+
}, [e]);
|
|
883
|
+
let _ = t(() => {
|
|
884
|
+
p.current &&= (clearTimeout(p.current), null), m.current = -1, h.current = -1, g.current = null, c(!1);
|
|
885
|
+
}, []), v = t(() => {
|
|
886
|
+
p.current && g.current && (clearTimeout(p.current), p.current = null, f.current(...g.current), m.current = Date.now(), h.current = -1, g.current = null, c(!1));
|
|
887
|
+
}, []);
|
|
888
|
+
return r(() => () => {
|
|
889
|
+
_();
|
|
890
|
+
}, [_]), {
|
|
891
|
+
debouncedFunc: t((...e) => {
|
|
892
|
+
c(!0), h.current = Date.now(), g.current = e, m.current === -1 && (m.current = Date.now(), u === !0 && f.current(...e)), l !== void 0 && Date.now() - m.current >= l ? (p.current && clearTimeout(p.current), f.current(...e), m.current = -1, c(!1)) : (p.current && clearTimeout(p.current), p.current = setTimeout(() => {
|
|
893
|
+
h.current !== m.current && d !== !1 && f.current(...e), m.current = -1, c(!1);
|
|
894
|
+
}, n));
|
|
895
|
+
}, [
|
|
896
|
+
n,
|
|
897
|
+
l,
|
|
898
|
+
d,
|
|
899
|
+
u
|
|
900
|
+
]),
|
|
901
|
+
cancel: _,
|
|
902
|
+
flush: v,
|
|
903
|
+
isPending: a
|
|
675
904
|
};
|
|
676
905
|
}
|
|
677
906
|
//#endregion
|
|
678
|
-
//#region src/
|
|
679
|
-
function
|
|
907
|
+
//#region src/performance/debounce/useDebouncedValue.ts
|
|
908
|
+
function B(e, t, n = {}) {
|
|
909
|
+
let [i, a] = s(e), { debouncedFunc: o } = z((e) => {
|
|
910
|
+
a(e);
|
|
911
|
+
}, t, n);
|
|
912
|
+
return r(() => {
|
|
913
|
+
o(e);
|
|
914
|
+
}, [e, o]), i;
|
|
915
|
+
}
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/performance/throttle/useThrottle.ts
|
|
918
|
+
function V(e, n, i = {}) {
|
|
680
919
|
let [a, c] = s(!1), l = i.leading ?? !0, u = i.trailing ?? !0, d = o(e), f = o(null), p = o(-1), m = o(null);
|
|
681
920
|
r(() => {
|
|
682
921
|
d.current = e;
|
|
@@ -710,4 +949,56 @@ function I(e, n, i = {}) {
|
|
|
710
949
|
};
|
|
711
950
|
}
|
|
712
951
|
//#endregion
|
|
713
|
-
|
|
952
|
+
//#region src/events/key/constants.ts
|
|
953
|
+
var H = [
|
|
954
|
+
"keydown",
|
|
955
|
+
"keyup",
|
|
956
|
+
"keypress"
|
|
957
|
+
];
|
|
958
|
+
//#endregion
|
|
959
|
+
//#region src/events/key/useKey.ts
|
|
960
|
+
function U(e, t, { enabled: n = !0, preventDefault: a = !0, stopPropagation: s = !0, eventType: c = "keydown", preventRepeat: l = !1, ignoreWhenFocusedInInputs: u = !0, ctrlKey: d = !1, shiftKey: f = !1, altKey: p = !1, metaKey: m = !1, target: h = window } = {}) {
|
|
961
|
+
let g = o(t), _ = o(n), v = o(!1);
|
|
962
|
+
i(() => {
|
|
963
|
+
g.current = t;
|
|
964
|
+
}, [t]), r(() => {
|
|
965
|
+
_.current = n;
|
|
966
|
+
}, [n]), r(() => {
|
|
967
|
+
let t = h && "current" in h ? h.current : h;
|
|
968
|
+
if (!t) return;
|
|
969
|
+
let n = e.toLowerCase(), r = H.includes(c) ? c : "keydown", i = l && r !== "keyup";
|
|
970
|
+
function o() {
|
|
971
|
+
v.current = !1;
|
|
972
|
+
}
|
|
973
|
+
function y(e) {
|
|
974
|
+
if (!(e instanceof KeyboardEvent)) return;
|
|
975
|
+
let t = e.key.toLowerCase();
|
|
976
|
+
(t === n || d && t === "control" || f && t === "shift" || p && t === "alt" || m && t === "meta") && (v.current = !1);
|
|
977
|
+
}
|
|
978
|
+
function b(e) {
|
|
979
|
+
if (!(e instanceof KeyboardEvent) || !_.current) return;
|
|
980
|
+
let t = e.target;
|
|
981
|
+
if (!(u && t instanceof HTMLElement && (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement || t.isContentEditable)) && e.ctrlKey === d && e.shiftKey === f && e.altKey === p && e.metaKey === m && n === e.key.toLowerCase()) {
|
|
982
|
+
if (i && v.current) return;
|
|
983
|
+
v.current = !0, g.current(e), a && e.preventDefault(), s && e.stopPropagation();
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return t.addEventListener(r, b), i && (t.addEventListener("keyup", y), window.addEventListener("blur", o)), () => {
|
|
987
|
+
t.removeEventListener(r, b), i && (t.removeEventListener("keyup", y), window.removeEventListener("blur", o));
|
|
988
|
+
};
|
|
989
|
+
}, [
|
|
990
|
+
e,
|
|
991
|
+
a,
|
|
992
|
+
s,
|
|
993
|
+
c,
|
|
994
|
+
l,
|
|
995
|
+
u,
|
|
996
|
+
d,
|
|
997
|
+
f,
|
|
998
|
+
p,
|
|
999
|
+
m,
|
|
1000
|
+
h
|
|
1001
|
+
]);
|
|
1002
|
+
}
|
|
1003
|
+
//#endregion
|
|
1004
|
+
export { d as FuzzyHighlighter, _ as ModalLayout, z as useDebounce, B as useDebouncedValue, b as useFilter, S as useFuzzySearch, C as useGrouping, U as useKey, g as useModal, h as useModalActions, m as useModalState, T as useMultipleSelection, D as useOrder, w as usePagination, O as usePin, E as useSingleSelection, L as useSort, V as useThrottle, R as useVisibility };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@himanshu-sorathiya/react-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "An opinionated collection of react hooks, and reusable UI components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"react-dom": "^19.2.6",
|
|
43
43
|
"typescript": "~6.0.2",
|
|
44
44
|
"typescript-eslint": "^8.59.2",
|
|
45
|
-
"vite": "^8.
|
|
45
|
+
"vite": "^8.1.4"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": [
|
|
48
48
|
"**/*.css"
|