@himanshu-sorathiya/react-kit 1.0.14 → 1.0.17
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 +163 -76
- package/dist/index.js +579 -324
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,103 +1,92 @@
|
|
|
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/FuzzyHighlighter/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/useModal/ModalContext.tsx
|
|
27
|
+
var f = e(null), p = e(null);
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/ui/useModal/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/useModal/ModalLayout.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 = o(null), x = f === e, S = d && x;
|
|
28
50
|
return r(() => {
|
|
29
51
|
let e = y.current;
|
|
30
|
-
e && (
|
|
31
|
-
}, [
|
|
52
|
+
e && (S && !e.open ? (document.activeElement && (b.current = document.activeElement), v(!1), e.showModal()) : !S && e.open && v(!0));
|
|
53
|
+
}, [S]), typeof document > "u" || !x && !_ ? 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 (_) {
|
|
45
67
|
let e = y.current;
|
|
46
|
-
e && e.close(), v(!1),
|
|
68
|
+
e && e.close(), v(!1), x && g(), b.current &&= (b.current.focus(), null);
|
|
47
69
|
}
|
|
48
70
|
},
|
|
49
71
|
className: `universal-modal ${n}`.trim(),
|
|
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/useFilter/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/useFilter/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/useFuzzySearch/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/useFuzzySearch/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,198 +336,174 @@ 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
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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
|
-
]);
|
|
339
|
+
//#region src/state/useGrouping/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]);
|
|
354
|
+
return {
|
|
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
|
|
364
|
+
};
|
|
407
365
|
}
|
|
408
366
|
//#endregion
|
|
409
|
-
//#region src/
|
|
410
|
-
function
|
|
411
|
-
let
|
|
412
|
-
|
|
413
|
-
let r = new Set(t), i =
|
|
367
|
+
//#region src/state/useMultipleSelection/useMultipleSelection.ts
|
|
368
|
+
function w({ items: e, field: n, initialSelectedIds: r = [] }) {
|
|
369
|
+
let i = o(r), [c, l] = s(() => new Set(r)), u = t((e) => {
|
|
370
|
+
l((t) => {
|
|
371
|
+
let r = new Set(t), i = v(e, n);
|
|
414
372
|
return r.add(i), r;
|
|
415
373
|
});
|
|
416
|
-
}, [n]),
|
|
417
|
-
|
|
418
|
-
let r = new Set(t), i =
|
|
374
|
+
}, [n]), d = t((e) => {
|
|
375
|
+
l((t) => {
|
|
376
|
+
let r = new Set(t), i = v(e, n);
|
|
419
377
|
return r.delete(i), r;
|
|
420
378
|
});
|
|
421
|
-
}, [n]),
|
|
422
|
-
|
|
423
|
-
let r = new Set(t), i =
|
|
379
|
+
}, [n]), f = t((e) => {
|
|
380
|
+
l((t) => {
|
|
381
|
+
let r = new Set(t), i = v(e, n);
|
|
424
382
|
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
425
383
|
});
|
|
426
|
-
}, [n]),
|
|
427
|
-
let t =
|
|
428
|
-
return
|
|
429
|
-
}, [
|
|
430
|
-
let t = e.map((e) =>
|
|
431
|
-
|
|
432
|
-
}, [n]),
|
|
433
|
-
let t = e.map((e) =>
|
|
434
|
-
|
|
435
|
-
}, [e, n]),
|
|
436
|
-
|
|
437
|
-
}, []),
|
|
384
|
+
}, [n]), p = t((e) => {
|
|
385
|
+
let t = v(e, n);
|
|
386
|
+
return c.has(t);
|
|
387
|
+
}, [c, n]), m = t(() => l(new Set(i.current)), []), h = t((e) => {
|
|
388
|
+
let t = e.map((e) => v(e, n));
|
|
389
|
+
l(new Set(t));
|
|
390
|
+
}, [n]), g = t(() => {
|
|
391
|
+
let t = e.map((e) => v(e, n));
|
|
392
|
+
l(new Set(t));
|
|
393
|
+
}, [e, n]), _ = t(() => {
|
|
394
|
+
l(/* @__PURE__ */ new Set());
|
|
395
|
+
}, []), y = t(() => l((t) => {
|
|
438
396
|
if (t.size === e.length) return /* @__PURE__ */ new Set();
|
|
439
|
-
let r = e.map((e) =>
|
|
397
|
+
let r = e.map((e) => v(e, n));
|
|
440
398
|
return new Set(r);
|
|
441
|
-
}), [e, n]),
|
|
399
|
+
}), [e, n]), b = t(() => l((t) => {
|
|
442
400
|
if (t.size === e.length) return /* @__PURE__ */ new Set();
|
|
443
|
-
let r = e.filter((e) => !t.has(
|
|
401
|
+
let r = e.filter((e) => !t.has(v(e, n))).map((e) => v(e, n));
|
|
444
402
|
return new Set(r);
|
|
445
|
-
}), [e, n]),
|
|
446
|
-
|
|
403
|
+
}), [e, n]), x = t((e) => {
|
|
404
|
+
l((t) => {
|
|
447
405
|
let r = new Set(t);
|
|
448
|
-
return e.map((e) =>
|
|
406
|
+
return e.map((e) => v(e, n)).forEach((e) => r.add(e)), r;
|
|
449
407
|
});
|
|
450
|
-
}, [n]),
|
|
451
|
-
|
|
408
|
+
}, [n]), S = t((e) => {
|
|
409
|
+
l((t) => {
|
|
452
410
|
let r = new Set(t);
|
|
453
|
-
return e.map((e) =>
|
|
411
|
+
return e.map((e) => v(e, n)).forEach((e) => r.delete(e)), r;
|
|
454
412
|
});
|
|
455
|
-
}, [n]),
|
|
456
|
-
|
|
413
|
+
}, [n]), C = t((e) => {
|
|
414
|
+
l((t) => {
|
|
457
415
|
let r = /* @__PURE__ */ new Set();
|
|
458
|
-
return e.map((e) =>
|
|
416
|
+
return e.map((e) => v(e, n)).forEach((e) => t.has(e) && r.add(e)), r;
|
|
459
417
|
});
|
|
460
|
-
}, [n]),
|
|
461
|
-
let t =
|
|
462
|
-
return
|
|
418
|
+
}, [n]), w = a(() => e.filter((e) => {
|
|
419
|
+
let t = v(e, n);
|
|
420
|
+
return c.has(t);
|
|
463
421
|
}), [
|
|
464
422
|
e,
|
|
465
423
|
n,
|
|
466
|
-
|
|
424
|
+
c
|
|
467
425
|
]);
|
|
468
426
|
return {
|
|
469
|
-
selectedIds: [...
|
|
470
|
-
selectedCount:
|
|
471
|
-
selectedItems:
|
|
472
|
-
isEmpty:
|
|
473
|
-
select:
|
|
474
|
-
deselect:
|
|
475
|
-
toggle:
|
|
476
|
-
isSelected:
|
|
477
|
-
replaceSelection:
|
|
478
|
-
resetSelection:
|
|
479
|
-
selectAll:
|
|
480
|
-
deselectAll:
|
|
481
|
-
toggleAll:
|
|
482
|
-
invertSelection:
|
|
483
|
-
selectMultiple:
|
|
484
|
-
deselectMultiple:
|
|
485
|
-
retainOnly:
|
|
427
|
+
selectedIds: [...c],
|
|
428
|
+
selectedCount: c.size,
|
|
429
|
+
selectedItems: w,
|
|
430
|
+
isEmpty: c.size === 0,
|
|
431
|
+
select: u,
|
|
432
|
+
deselect: d,
|
|
433
|
+
toggle: f,
|
|
434
|
+
isSelected: p,
|
|
435
|
+
replaceSelection: h,
|
|
436
|
+
resetSelection: m,
|
|
437
|
+
selectAll: g,
|
|
438
|
+
deselectAll: _,
|
|
439
|
+
toggleAll: y,
|
|
440
|
+
invertSelection: b,
|
|
441
|
+
selectMultiple: x,
|
|
442
|
+
deselectMultiple: S,
|
|
443
|
+
retainOnly: C
|
|
486
444
|
};
|
|
487
445
|
}
|
|
488
446
|
//#endregion
|
|
489
|
-
//#region src/
|
|
490
|
-
function
|
|
491
|
-
let n = o(e), [r, i] = s(e)
|
|
447
|
+
//#region src/state/useOrder/useOrder.ts
|
|
448
|
+
function T(e) {
|
|
449
|
+
let n = o(e), [r, i] = s(() => e), a = t((e) => {
|
|
450
|
+
typeof e == "number" && i((t) => {
|
|
451
|
+
if (e <= 0 || e >= t.length) return t;
|
|
452
|
+
let n = [...t];
|
|
453
|
+
return [n[e], n[e - 1]] = [n[e - 1], n[e]], n;
|
|
454
|
+
});
|
|
455
|
+
}, []), c = t((e) => {
|
|
456
|
+
typeof e == "number" && i((t) => {
|
|
457
|
+
if (e < 0 || e >= t.length - 1) return t;
|
|
458
|
+
let n = [...t];
|
|
459
|
+
return [n[e], n[e + 1]] = [n[e + 1], n[e]], n;
|
|
460
|
+
});
|
|
461
|
+
}, []), l = t((e) => e > 0, []), u = t((e) => e < r.length - 1, [r.length]), d = t((e) => {
|
|
462
|
+
typeof e == "number" && i((t) => {
|
|
463
|
+
if (e <= 0 || e >= t.length) return t;
|
|
464
|
+
let n = [...t], [r] = n.splice(e, 1);
|
|
465
|
+
return n.unshift(r), n;
|
|
466
|
+
});
|
|
467
|
+
}, []), f = t((e) => {
|
|
468
|
+
typeof e == "number" && i((t) => {
|
|
469
|
+
if (e < 0 || e >= t.length - 1) return t;
|
|
470
|
+
let n = [...t], [r] = n.splice(e, 1);
|
|
471
|
+
return n.push(r), n;
|
|
472
|
+
});
|
|
473
|
+
}, []), p = t((e, t) => {
|
|
474
|
+
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
475
|
+
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
476
|
+
let r = [...n], [i] = r.splice(e, 1);
|
|
477
|
+
return r.splice(t, 0, i), r;
|
|
478
|
+
});
|
|
479
|
+
}, []), m = t((e, t) => {
|
|
480
|
+
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
481
|
+
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
482
|
+
let r = [...n];
|
|
483
|
+
return [r[e], r[t]] = [r[t], r[e]], r;
|
|
484
|
+
});
|
|
485
|
+
}, []), h = t(() => {
|
|
486
|
+
i(n.current);
|
|
487
|
+
}, []);
|
|
492
488
|
return {
|
|
493
489
|
orderedItems: r,
|
|
494
|
-
moveUp:
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
typeof e == "number" && i((t) => {
|
|
503
|
-
if (e < 0 || e >= t.length - 1) return t;
|
|
504
|
-
let n = [...t];
|
|
505
|
-
return [n[e], n[e + 1]] = [n[e + 1], n[e]], n;
|
|
506
|
-
});
|
|
507
|
-
}, []),
|
|
508
|
-
canMoveUp: t((e) => e > 0, []),
|
|
509
|
-
canMoveDown: t((e) => e < r.length - 1, [r.length]),
|
|
510
|
-
moveToTop: t((e) => {
|
|
511
|
-
typeof e == "number" && i((t) => {
|
|
512
|
-
if (e <= 0 || e >= t.length) return t;
|
|
513
|
-
let n = [...t], [r] = n.splice(e, 1);
|
|
514
|
-
return n.unshift(r), n;
|
|
515
|
-
});
|
|
516
|
-
}, []),
|
|
517
|
-
moveToBottom: t((e) => {
|
|
518
|
-
typeof e == "number" && i((t) => {
|
|
519
|
-
if (e < 0 || e >= t.length - 1) return t;
|
|
520
|
-
let n = [...t], [r] = n.splice(e, 1);
|
|
521
|
-
return n.push(r), n;
|
|
522
|
-
});
|
|
523
|
-
}, []),
|
|
524
|
-
move: t((e, t) => {
|
|
525
|
-
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
526
|
-
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
527
|
-
let r = [...n], [i] = r.splice(e, 1);
|
|
528
|
-
return r.splice(t, 0, i), r;
|
|
529
|
-
});
|
|
530
|
-
}, []),
|
|
531
|
-
swap: t((e, t) => {
|
|
532
|
-
typeof e != "number" || typeof t != "number" || e === t || i((n) => {
|
|
533
|
-
if (e < 0 || e >= n.length || t < 0 || t >= n.length) return n;
|
|
534
|
-
let r = [...n];
|
|
535
|
-
return [r[e], r[t]] = [r[t], r[e]], r;
|
|
536
|
-
});
|
|
537
|
-
}, []),
|
|
490
|
+
moveUp: a,
|
|
491
|
+
moveDown: c,
|
|
492
|
+
canMoveUp: l,
|
|
493
|
+
canMoveDown: u,
|
|
494
|
+
moveToTop: d,
|
|
495
|
+
moveToBottom: f,
|
|
496
|
+
move: p,
|
|
497
|
+
swap: m,
|
|
538
498
|
replaceOrder: t((e) => {
|
|
539
499
|
i(e);
|
|
540
500
|
}, []),
|
|
541
|
-
resetOrder:
|
|
542
|
-
i(n.current);
|
|
543
|
-
}, [])
|
|
501
|
+
resetOrder: h
|
|
544
502
|
};
|
|
545
503
|
}
|
|
546
504
|
//#endregion
|
|
547
|
-
//#region src/
|
|
548
|
-
function
|
|
505
|
+
//#region src/state/usePagination/usePagination.ts
|
|
506
|
+
function E(e, n, r = 0) {
|
|
549
507
|
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);
|
|
550
508
|
return c !== d && l(d), {
|
|
551
509
|
pageItems: a(() => typeof i != "number" || i < 1 ? [] : e.slice(c * i, (c + 1) * i), [
|
|
@@ -600,8 +558,8 @@ function D(e, n, r = 0) {
|
|
|
600
558
|
};
|
|
601
559
|
}
|
|
602
560
|
//#endregion
|
|
603
|
-
//#region src/
|
|
604
|
-
function
|
|
561
|
+
//#region src/state/useSingleSelection/useSingleSelection.ts
|
|
562
|
+
function D(e) {
|
|
605
563
|
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]);
|
|
606
564
|
return {
|
|
607
565
|
selectedId: n,
|
|
@@ -614,27 +572,27 @@ function O(e) {
|
|
|
614
572
|
};
|
|
615
573
|
}
|
|
616
574
|
//#endregion
|
|
617
|
-
//#region src/utils
|
|
618
|
-
function
|
|
619
|
-
let { sortUndefined: r, desc: i = !1 } = n, a =
|
|
575
|
+
//#region src/state/useSort/utils.ts
|
|
576
|
+
function O(e, t, n = {}) {
|
|
577
|
+
let { sortUndefined: r, desc: i = !1 } = n, a = F(e, t, r, i);
|
|
620
578
|
if (a !== null) return a;
|
|
621
579
|
let o = !!e;
|
|
622
580
|
return o === !!t ? 0 : o ? 1 : -1;
|
|
623
581
|
}
|
|
624
|
-
function
|
|
625
|
-
let { sortUndefined: r, desc: i = !1 } = n, a =
|
|
582
|
+
function k(e, t, n = {}) {
|
|
583
|
+
let { sortUndefined: r, desc: i = !1 } = n, a = F(e, t, r, i);
|
|
626
584
|
if (a !== null) return a;
|
|
627
585
|
let o = Number(e), s = Number(t), c = Number.isNaN(o), l = Number.isNaN(s);
|
|
628
|
-
return c || l ?
|
|
586
|
+
return c || l ? F(c ? void 0 : o, l ? void 0 : s, r, i) ?? 0 : o - s;
|
|
629
587
|
}
|
|
630
|
-
function
|
|
631
|
-
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o =
|
|
588
|
+
function A(e, t, n = {}) {
|
|
589
|
+
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o = F(e, t, i, r);
|
|
632
590
|
if (o !== null) return o;
|
|
633
591
|
let s = String(e), c = String(t);
|
|
634
592
|
return s.localeCompare(c, void 0, { sensitivity: a ? "variant" : "base" });
|
|
635
593
|
}
|
|
636
|
-
function
|
|
637
|
-
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o =
|
|
594
|
+
function j(e, t, n = {}) {
|
|
595
|
+
let { desc: r = !1, sortUndefined: i, caseSensitive: a = !1 } = n, o = F(e, t, i, r);
|
|
638
596
|
if (o !== null) return o;
|
|
639
597
|
let s = String(e), c = String(t);
|
|
640
598
|
return s.localeCompare(c, void 0, {
|
|
@@ -642,21 +600,21 @@ function M(e, t, n = {}) {
|
|
|
642
600
|
sensitivity: a ? "variant" : "base"
|
|
643
601
|
});
|
|
644
602
|
}
|
|
645
|
-
function
|
|
646
|
-
let { desc: r = !1, sortUndefined: i } = n, a =
|
|
603
|
+
function M(e, t, n = {}) {
|
|
604
|
+
let { desc: r = !1, sortUndefined: i } = n, a = F(e, t, i, r);
|
|
647
605
|
if (a !== null) return a;
|
|
648
606
|
let o = new Date(e).getTime(), s = new Date(t).getTime(), c = Number.isNaN(o), l = Number.isNaN(s);
|
|
649
|
-
return (c || l) && (a =
|
|
607
|
+
return (c || l) && (a = F(c ? void 0 : o, l ? void 0 : s, i, r), a !== null) ? a : o - s;
|
|
650
608
|
}
|
|
651
|
-
function
|
|
652
|
-
let { desc: r = !1, sortUndefined: i } = n, a =
|
|
609
|
+
function N(e, t, n = {}) {
|
|
610
|
+
let { desc: r = !1, sortUndefined: i } = n, a = F(e, t, i, r);
|
|
653
611
|
return a === null ? e < t ? -1 : +(e > t) : a;
|
|
654
612
|
}
|
|
655
|
-
function
|
|
656
|
-
let { desc: r = !1, sortUndefined: i, compare: a } = n, o =
|
|
613
|
+
function P(e, t, n = {}) {
|
|
614
|
+
let { desc: r = !1, sortUndefined: i, compare: a } = n, o = F(e, t, i, r);
|
|
657
615
|
return o === null ? typeof a == "function" ? a(e, t) : e < t ? -1 : +(e > t) : o;
|
|
658
616
|
}
|
|
659
|
-
function
|
|
617
|
+
function F(e, t, n = "last", r) {
|
|
660
618
|
let i = e == null || e === "", a = t == null || t === "";
|
|
661
619
|
if (i && a) return 0;
|
|
662
620
|
if (!i && !a) return null;
|
|
@@ -673,71 +631,71 @@ function I(e, t, n = "last", r) {
|
|
|
673
631
|
return null;
|
|
674
632
|
}
|
|
675
633
|
//#endregion
|
|
676
|
-
//#region src/
|
|
677
|
-
function
|
|
678
|
-
let
|
|
679
|
-
let t =
|
|
634
|
+
//#region src/state/useSort/useSort.ts
|
|
635
|
+
function I(e, n = []) {
|
|
636
|
+
let r = o(n), [i, c] = s(() => n), l = a(() => {
|
|
637
|
+
let t = i.map((e) => ({
|
|
680
638
|
...e,
|
|
681
639
|
pathArray: (e.field || e.id).split(".")
|
|
682
640
|
}));
|
|
683
641
|
return [...e].sort((e, n) => {
|
|
684
642
|
for (let r of t) {
|
|
685
|
-
let { type: t, id: i, desc: a = !1, invertSorting: o = !1, pathArray: s } = r, c =
|
|
643
|
+
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;
|
|
686
644
|
switch (t) {
|
|
687
645
|
case "numeric":
|
|
688
|
-
u =
|
|
646
|
+
u = k(c, l, r);
|
|
689
647
|
break;
|
|
690
648
|
case "alphabetical":
|
|
691
|
-
u =
|
|
649
|
+
u = A(c, l, r);
|
|
692
650
|
break;
|
|
693
651
|
case "alphanumeric":
|
|
694
|
-
u =
|
|
652
|
+
u = j(c, l, r);
|
|
695
653
|
break;
|
|
696
654
|
case "boolean":
|
|
697
|
-
u =
|
|
655
|
+
u = O(c, l, r);
|
|
698
656
|
break;
|
|
699
657
|
case "date":
|
|
700
|
-
u =
|
|
658
|
+
u = M(c, l, r);
|
|
701
659
|
break;
|
|
702
660
|
case "basic":
|
|
703
|
-
u =
|
|
661
|
+
u = N(c, l, r);
|
|
704
662
|
break;
|
|
705
663
|
case "custom":
|
|
706
|
-
u =
|
|
664
|
+
u = P(c, l, r);
|
|
707
665
|
break;
|
|
708
|
-
default: u =
|
|
666
|
+
default: u = N(c, l, r);
|
|
709
667
|
}
|
|
710
668
|
if (u !== 0) return u * (a === o ? 1 : -1);
|
|
711
669
|
}
|
|
712
670
|
return 0;
|
|
713
671
|
});
|
|
714
|
-
}, [
|
|
715
|
-
|
|
716
|
-
}, []),
|
|
717
|
-
let { multi: r = !1, ...
|
|
718
|
-
|
|
719
|
-
let
|
|
720
|
-
if (!
|
|
721
|
-
let
|
|
672
|
+
}, [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) => {
|
|
673
|
+
c((t) => Array.isArray(e) ? t.filter((t) => !e.includes(t.id)) : t.filter((t) => t.id !== e));
|
|
674
|
+
}, []), f = t(() => c([]), []), p = t(() => c(r.current), []), m = t((e) => c(e), []), h = t((e, t, n) => {
|
|
675
|
+
let { multi: r = !1, ...i } = n || {};
|
|
676
|
+
c((n) => {
|
|
677
|
+
let a = n.find((t) => t.id === e);
|
|
678
|
+
if (!a) {
|
|
679
|
+
let a = {
|
|
722
680
|
id: e,
|
|
723
681
|
type: t,
|
|
724
|
-
...
|
|
682
|
+
...i,
|
|
725
683
|
desc: !1
|
|
726
684
|
};
|
|
727
|
-
return r ? [...n,
|
|
685
|
+
return r ? [...n, a] : [a];
|
|
728
686
|
}
|
|
729
|
-
if (!
|
|
687
|
+
if (!a.desc) {
|
|
730
688
|
let t = {
|
|
731
|
-
...i,
|
|
732
689
|
...a,
|
|
690
|
+
...i,
|
|
733
691
|
desc: !0
|
|
734
692
|
};
|
|
735
693
|
return r ? n.map((n) => n.id === e ? t : n) : [t];
|
|
736
694
|
}
|
|
737
|
-
if (
|
|
695
|
+
if (a.disableSortRemoval || i.disableSortRemoval) {
|
|
738
696
|
let t = {
|
|
739
|
-
...i,
|
|
740
697
|
...a,
|
|
698
|
+
...i,
|
|
741
699
|
desc: !1
|
|
742
700
|
};
|
|
743
701
|
return r ? n.map((n) => n.id === e ? t : n) : [t];
|
|
@@ -746,31 +704,276 @@ function L(e, n = []) {
|
|
|
746
704
|
});
|
|
747
705
|
}, []);
|
|
748
706
|
return {
|
|
749
|
-
sortedItems:
|
|
750
|
-
sorts:
|
|
751
|
-
upsertSorts:
|
|
752
|
-
removeSort:
|
|
753
|
-
clearSorts:
|
|
754
|
-
resetSorts:
|
|
755
|
-
replaceSorts:
|
|
707
|
+
sortedItems: l,
|
|
708
|
+
sorts: i,
|
|
709
|
+
upsertSorts: u,
|
|
710
|
+
removeSort: d,
|
|
711
|
+
clearSorts: f,
|
|
712
|
+
resetSorts: p,
|
|
713
|
+
replaceSorts: m,
|
|
756
714
|
getSortDirection: t((e) => {
|
|
757
|
-
let t =
|
|
715
|
+
let t = i.find((t) => t.id === e);
|
|
758
716
|
return t ? t.desc ? "desc" : "asc" : void 0;
|
|
759
|
-
}, [
|
|
760
|
-
toggleSort:
|
|
717
|
+
}, [i]),
|
|
718
|
+
toggleSort: h,
|
|
761
719
|
getNextSortingOrder: t((e) => {
|
|
762
|
-
let t =
|
|
720
|
+
let t = i.find((t) => t.id === e);
|
|
763
721
|
return t ? t.desc ? t.disableSortRemoval ? "asc" : "none" : "desc" : "asc";
|
|
764
|
-
}, [
|
|
722
|
+
}, [i]),
|
|
765
723
|
getSortIndex: t((e) => {
|
|
766
|
-
let t =
|
|
724
|
+
let t = i.findIndex((t) => t.id === e);
|
|
767
725
|
return t === -1 ? void 0 : t + 1;
|
|
768
|
-
}, [
|
|
726
|
+
}, [i])
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
//#endregion
|
|
730
|
+
//#region src/ui/useExpansion/useExpansion.ts
|
|
731
|
+
function L({ items: e = [], field: n, initialExpandedIds: r = [], multiple: i = !1 } = {}) {
|
|
732
|
+
let c = o(r), [l, u] = s(() => new Set(r)), d = t((e) => {
|
|
733
|
+
let t = v(e, n);
|
|
734
|
+
return l.has(t);
|
|
735
|
+
}, [l, n]), f = t((e) => {
|
|
736
|
+
u((t) => {
|
|
737
|
+
let r = v(e, n);
|
|
738
|
+
if (t.has(r)) return t;
|
|
739
|
+
let a = i ? new Set(t) : /* @__PURE__ */ new Set();
|
|
740
|
+
return a.add(r), a;
|
|
741
|
+
});
|
|
742
|
+
}, [n, i]), p = t((e) => {
|
|
743
|
+
u((t) => {
|
|
744
|
+
let r = v(e, n);
|
|
745
|
+
if (!t.has(r)) return t;
|
|
746
|
+
let i = new Set(t);
|
|
747
|
+
return i.delete(r), i;
|
|
748
|
+
});
|
|
749
|
+
}, [n]), m = t((e) => {
|
|
750
|
+
u((t) => {
|
|
751
|
+
let r = v(e, n), a = i ? new Set(t) : /* @__PURE__ */ new Set();
|
|
752
|
+
return t.has(r) ? i && a.delete(r) : a.add(r), a;
|
|
753
|
+
});
|
|
754
|
+
}, [n, i]), h = t(() => {
|
|
755
|
+
if (!i) return;
|
|
756
|
+
let t = e.map((e) => v(e, n));
|
|
757
|
+
u(new Set(t));
|
|
758
|
+
}, [
|
|
759
|
+
e,
|
|
760
|
+
n,
|
|
761
|
+
i
|
|
762
|
+
]), g = t(() => {
|
|
763
|
+
u(/* @__PURE__ */ new Set());
|
|
764
|
+
}, []), _ = t(() => {
|
|
765
|
+
u(new Set(c.current));
|
|
766
|
+
}, []), y = t((e) => {
|
|
767
|
+
let t = e.map((e) => v(e, n));
|
|
768
|
+
u(new Set(t));
|
|
769
|
+
}, [n]), b = a(() => e.filter((e) => l.has(v(e, n))), [
|
|
770
|
+
e,
|
|
771
|
+
n,
|
|
772
|
+
l
|
|
773
|
+
]);
|
|
774
|
+
return {
|
|
775
|
+
expandedIds: [...l],
|
|
776
|
+
expandedItems: b,
|
|
777
|
+
isExpanded: d,
|
|
778
|
+
expand: f,
|
|
779
|
+
collapse: p,
|
|
780
|
+
toggle: m,
|
|
781
|
+
expandAll: h,
|
|
782
|
+
collapseAll: g,
|
|
783
|
+
resetExpansion: _,
|
|
784
|
+
replaceExpansion: y
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/ui/usePin/usePin.ts
|
|
789
|
+
function R({ items: e, field: n, initialPinnedIds: r = [], maxPins: i = 2 ** 53 - 1 }) {
|
|
790
|
+
let c = o(r), [l, u] = s(() => new Set(r)), d = t((e) => {
|
|
791
|
+
u((t) => {
|
|
792
|
+
if (t.size >= i) return t;
|
|
793
|
+
let r = new Set(t), a = v(e, n);
|
|
794
|
+
return r.add(a), r;
|
|
795
|
+
});
|
|
796
|
+
}, [n, i]), f = t((e) => {
|
|
797
|
+
u((t) => {
|
|
798
|
+
let r = new Set(t), i = v(e, n);
|
|
799
|
+
return r.delete(i), r;
|
|
800
|
+
});
|
|
801
|
+
}, [n]), p = t((e) => {
|
|
802
|
+
u((t) => {
|
|
803
|
+
let r = new Set(t), a = v(e, n);
|
|
804
|
+
if (r.has(a)) r.delete(a);
|
|
805
|
+
else {
|
|
806
|
+
if (r.size >= i) return t;
|
|
807
|
+
r.add(a);
|
|
808
|
+
}
|
|
809
|
+
return r;
|
|
810
|
+
});
|
|
811
|
+
}, [n, i]), m = t((e) => {
|
|
812
|
+
let t = v(e, n);
|
|
813
|
+
return l.has(t);
|
|
814
|
+
}, [l, n]), h = t(() => u(/* @__PURE__ */ new Set()), []), g = t(() => u(new Set(c.current)), [c]), _ = t((e) => {
|
|
815
|
+
let t = e.map((e) => v(e, n));
|
|
816
|
+
u(new Set(t.slice(0, i)));
|
|
817
|
+
}, [n, i]), y = t((e) => {
|
|
818
|
+
u((t) => {
|
|
819
|
+
let r = new Set(t), a = e.map((e) => v(e, n));
|
|
820
|
+
for (let e of a) {
|
|
821
|
+
if (r.size >= i && !r.has(e)) break;
|
|
822
|
+
r.add(e);
|
|
823
|
+
}
|
|
824
|
+
return r;
|
|
825
|
+
});
|
|
826
|
+
}, [n, i]), b = t((e) => {
|
|
827
|
+
u((t) => {
|
|
828
|
+
let r = new Set(t);
|
|
829
|
+
return e.map((e) => v(e, n)).forEach((e) => r.delete(e)), r;
|
|
830
|
+
});
|
|
831
|
+
}, [n]), x = a(() => e.filter((e) => {
|
|
832
|
+
let t = v(e, n);
|
|
833
|
+
return l.has(t);
|
|
834
|
+
}), [
|
|
835
|
+
e,
|
|
836
|
+
n,
|
|
837
|
+
l
|
|
838
|
+
]), S = a(() => e.filter((e) => {
|
|
839
|
+
let t = v(e, n);
|
|
840
|
+
return !l.has(t);
|
|
841
|
+
}), [
|
|
842
|
+
e,
|
|
843
|
+
n,
|
|
844
|
+
l
|
|
845
|
+
]);
|
|
846
|
+
return {
|
|
847
|
+
pinnedIds: [...l],
|
|
848
|
+
pinnedItems: x,
|
|
849
|
+
unpinnedItems: S,
|
|
850
|
+
pinnedCount: l.size,
|
|
851
|
+
hasPins: l.size > 0,
|
|
852
|
+
isAtMaxLimit: l.size >= i,
|
|
853
|
+
pin: d,
|
|
854
|
+
unpin: f,
|
|
855
|
+
togglePin: p,
|
|
856
|
+
isPinned: m,
|
|
857
|
+
clearPins: h,
|
|
858
|
+
resetPins: g,
|
|
859
|
+
replacePins: _,
|
|
860
|
+
pinMultiple: y,
|
|
861
|
+
unpinMultiple: b
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
865
|
+
//#region src/ui/useVisibility/useVisibility.ts
|
|
866
|
+
function z({ items: e, field: n, initialVisibleIds: r = [] }) {
|
|
867
|
+
let i = o(r), [c, l] = s(() => new Set(r)), u = t((e) => {
|
|
868
|
+
let t = v(e, n);
|
|
869
|
+
return c.has(t);
|
|
870
|
+
}, [c, n]), d = t((e) => {
|
|
871
|
+
l((t) => {
|
|
872
|
+
let r = new Set(t), i = v(e, n);
|
|
873
|
+
return r.add(i), r;
|
|
874
|
+
});
|
|
875
|
+
}, [n]), f = t((e) => {
|
|
876
|
+
l((t) => {
|
|
877
|
+
let r = new Set(t), i = v(e, n);
|
|
878
|
+
return r.delete(i), r;
|
|
879
|
+
});
|
|
880
|
+
}, [n]), p = t((e) => {
|
|
881
|
+
l((t) => {
|
|
882
|
+
let r = new Set(t), i = v(e, n);
|
|
883
|
+
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
884
|
+
});
|
|
885
|
+
}, [n]), m = t((t) => {
|
|
886
|
+
l((r) => {
|
|
887
|
+
let i = new Set(r);
|
|
888
|
+
return (t ?? e).forEach((e) => {
|
|
889
|
+
i.add(v(e, n));
|
|
890
|
+
}), i;
|
|
891
|
+
});
|
|
892
|
+
}, [e, n]), h = t((t) => {
|
|
893
|
+
l((r) => {
|
|
894
|
+
let i = new Set(r);
|
|
895
|
+
return (t ?? e).forEach((e) => {
|
|
896
|
+
i.delete(v(e, n));
|
|
897
|
+
}), i;
|
|
898
|
+
});
|
|
899
|
+
}, [e, n]), g = t(() => {
|
|
900
|
+
l(() => new Set(i.current));
|
|
901
|
+
}, []), _ = t((e) => {
|
|
902
|
+
let t = e.map((e) => v(e, n));
|
|
903
|
+
l(() => new Set(t));
|
|
904
|
+
}, [n]), y = a(() => e.filter((e) => {
|
|
905
|
+
let t = v(e, n);
|
|
906
|
+
return c.has(t);
|
|
907
|
+
}), [
|
|
908
|
+
e,
|
|
909
|
+
n,
|
|
910
|
+
c
|
|
911
|
+
]), b = a(() => e.filter((e) => {
|
|
912
|
+
let t = v(e, n);
|
|
913
|
+
return !c.has(t);
|
|
914
|
+
}), [
|
|
915
|
+
e,
|
|
916
|
+
n,
|
|
917
|
+
c
|
|
918
|
+
]);
|
|
919
|
+
return {
|
|
920
|
+
visibleIds: [...c],
|
|
921
|
+
visibleItems: y,
|
|
922
|
+
hiddenItems: b,
|
|
923
|
+
visibleCount: c.size,
|
|
924
|
+
isVisible: u,
|
|
925
|
+
show: d,
|
|
926
|
+
hide: f,
|
|
927
|
+
toggleVisibility: p,
|
|
928
|
+
showAll: m,
|
|
929
|
+
hideAll: h,
|
|
930
|
+
replaceVisibility: _,
|
|
931
|
+
resetVisibility: g
|
|
769
932
|
};
|
|
770
933
|
}
|
|
771
934
|
//#endregion
|
|
772
|
-
//#region src/
|
|
773
|
-
function
|
|
935
|
+
//#region src/performance/useDebounce/useDebounce.ts
|
|
936
|
+
function B(e, n, i = {}) {
|
|
937
|
+
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);
|
|
938
|
+
r(() => {
|
|
939
|
+
f.current = e;
|
|
940
|
+
}, [e]);
|
|
941
|
+
let _ = t(() => {
|
|
942
|
+
p.current &&= (clearTimeout(p.current), null), m.current = -1, h.current = -1, g.current = null, c(!1);
|
|
943
|
+
}, []), v = t(() => {
|
|
944
|
+
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));
|
|
945
|
+
}, []);
|
|
946
|
+
return r(() => () => {
|
|
947
|
+
_();
|
|
948
|
+
}, [_]), {
|
|
949
|
+
debouncedFunc: t((...e) => {
|
|
950
|
+
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(() => {
|
|
951
|
+
h.current !== m.current && d !== !1 && f.current(...e), m.current = -1, c(!1);
|
|
952
|
+
}, n));
|
|
953
|
+
}, [
|
|
954
|
+
n,
|
|
955
|
+
l,
|
|
956
|
+
d,
|
|
957
|
+
u
|
|
958
|
+
]),
|
|
959
|
+
cancel: _,
|
|
960
|
+
flush: v,
|
|
961
|
+
isPending: a
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
//#endregion
|
|
965
|
+
//#region src/performance/useDebounce/useDebouncedValue.ts
|
|
966
|
+
function V(e, t, n = {}) {
|
|
967
|
+
let [i, a] = s(e), { debouncedFunc: o } = B((e) => {
|
|
968
|
+
a(e);
|
|
969
|
+
}, t, n);
|
|
970
|
+
return r(() => {
|
|
971
|
+
o(e);
|
|
972
|
+
}, [e, o]), i;
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/performance/useThrottle/useThrottle.ts
|
|
976
|
+
function H(e, n, i = {}) {
|
|
774
977
|
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);
|
|
775
978
|
r(() => {
|
|
776
979
|
d.current = e;
|
|
@@ -804,4 +1007,56 @@ function R(e, n, i = {}) {
|
|
|
804
1007
|
};
|
|
805
1008
|
}
|
|
806
1009
|
//#endregion
|
|
807
|
-
|
|
1010
|
+
//#region src/events/useKey/constants.ts
|
|
1011
|
+
var U = [
|
|
1012
|
+
"keydown",
|
|
1013
|
+
"keyup",
|
|
1014
|
+
"keypress"
|
|
1015
|
+
];
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/events/useKey/useKey.ts
|
|
1018
|
+
function W(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 } = {}) {
|
|
1019
|
+
let g = o(t), _ = o(n), v = o(!1);
|
|
1020
|
+
i(() => {
|
|
1021
|
+
g.current = t;
|
|
1022
|
+
}, [t]), r(() => {
|
|
1023
|
+
_.current = n;
|
|
1024
|
+
}, [n]), r(() => {
|
|
1025
|
+
let t = h && "current" in h ? h.current : h;
|
|
1026
|
+
if (!t) return;
|
|
1027
|
+
let n = e.toLowerCase(), r = U.includes(c) ? c : "keydown", i = l && r !== "keyup";
|
|
1028
|
+
function o() {
|
|
1029
|
+
v.current = !1;
|
|
1030
|
+
}
|
|
1031
|
+
function y(e) {
|
|
1032
|
+
if (!(e instanceof KeyboardEvent)) return;
|
|
1033
|
+
let t = e.key.toLowerCase();
|
|
1034
|
+
(t === n || d && t === "control" || f && t === "shift" || p && t === "alt" || m && t === "meta") && (v.current = !1);
|
|
1035
|
+
}
|
|
1036
|
+
function b(e) {
|
|
1037
|
+
if (!(e instanceof KeyboardEvent) || !_.current) return;
|
|
1038
|
+
let t = e.target;
|
|
1039
|
+
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()) {
|
|
1040
|
+
if (i && v.current) return;
|
|
1041
|
+
v.current = !0, g.current(e), a && e.preventDefault(), s && e.stopPropagation();
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return t.addEventListener(r, b), i && (t.addEventListener("keyup", y), window.addEventListener("blur", o)), () => {
|
|
1045
|
+
t.removeEventListener(r, b), i && (t.removeEventListener("keyup", y), window.removeEventListener("blur", o));
|
|
1046
|
+
};
|
|
1047
|
+
}, [
|
|
1048
|
+
e,
|
|
1049
|
+
a,
|
|
1050
|
+
s,
|
|
1051
|
+
c,
|
|
1052
|
+
l,
|
|
1053
|
+
u,
|
|
1054
|
+
d,
|
|
1055
|
+
f,
|
|
1056
|
+
p,
|
|
1057
|
+
m,
|
|
1058
|
+
h
|
|
1059
|
+
]);
|
|
1060
|
+
}
|
|
1061
|
+
//#endregion
|
|
1062
|
+
export { d as FuzzyHighlighter, _ as ModalLayout, B as useDebounce, V as useDebouncedValue, L as useExpansion, b as useFilter, S as useFuzzySearch, C as useGrouping, W as useKey, g as useModal, h as useModalActions, m as useModalState, w as useMultipleSelection, T as useOrder, E as usePagination, R as usePin, D as useSingleSelection, I as useSort, H as useThrottle, z as useVisibility };
|