@himanshu-sorathiya/react-kit 1.0.26 → 1.0.28
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 +1153 -43
- package/dist/index.js +5 -5
- package/dist/performance.d.ts +883 -30
- package/dist/performance.js +2 -2
- package/dist/performance2.js +358 -224
- package/dist/storage.d.ts +270 -13
- package/dist/storage2.js +150 -213
- package/package.json +7 -4
package/dist/performance2.js
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import { t as e } from "./useEventListener.js";
|
|
2
2
|
import { t } from "./utils.js";
|
|
3
3
|
import { useCallback as n, useEffect as r, useLayoutEffect as i, useMemo as a, useRef as o, useState as s } from "react";
|
|
4
|
-
//#region src/performance/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
//#region src/performance/useDebouncer/useDebouncer.ts
|
|
5
|
+
var c = globalThis.process?.env?.NODE_ENV !== "production";
|
|
6
|
+
function l(e, t = {}) {
|
|
7
|
+
let i = Math.max(0, Number(e) || 0);
|
|
8
|
+
c && (typeof e != "number" || !Number.isFinite(e) || e < 0) && console.warn(`[useDebouncer] Received an invalid \`delay\` (${String(e)}) — falling back to ${i}ms.`);
|
|
9
|
+
let [a, l] = s(!1), u = t?.maxWait, d = !!t?.leading, f = t?.trailing ?? !0;
|
|
10
|
+
c && !d && !f && console.warn("[useDebouncer] Both `leading` and `trailing` are false — the debounced function will never be invoked."), c && u !== void 0 && u < i && console.warn(`[useDebouncer] \`maxWait\` (${u}ms) is smaller than \`delay\` (${i}ms) — the function will fire on almost every call.`);
|
|
11
|
+
let p = o(null), m = o(null), h = o(null), g = o(-1), _ = n(() => {
|
|
12
|
+
h.current !== null && (clearTimeout(h.current), h.current = null), g.current = -1, m.current = null, p.current = null, l(!1);
|
|
8
13
|
}, []), v = n(() => {
|
|
9
|
-
|
|
14
|
+
let e = p.current, t = m.current;
|
|
15
|
+
h.current === null || e === null || t === null || (clearTimeout(h.current), h.current = null, g.current = -1, m.current = null, p.current = null, l(!1), e(...t));
|
|
10
16
|
}, []);
|
|
11
|
-
return r(() =>
|
|
12
|
-
_();
|
|
13
|
-
}, [_]), {
|
|
17
|
+
return r(() => _, [_]), {
|
|
14
18
|
run: n((e, ...t) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
let n = Date.now();
|
|
20
|
+
if (p.current = e, m.current = t, g.current === -1 && (g.current = n, d)) {
|
|
21
|
+
let e = p.current, t = m.current;
|
|
22
|
+
m.current = null, e(...t);
|
|
23
|
+
}
|
|
24
|
+
let r = p.current, a = m.current;
|
|
25
|
+
if (u !== void 0 && r !== null && a !== null && n - g.current >= u) {
|
|
26
|
+
h.current !== null && (clearTimeout(h.current), h.current = null), g.current = -1, m.current = null, p.current = null, l(!1), r(...a);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
h.current !== null && clearTimeout(h.current), h.current = setTimeout(() => {
|
|
30
|
+
h.current = null;
|
|
31
|
+
let e = p.current, t = m.current;
|
|
32
|
+
g.current = -1, m.current = null, p.current = null, l(!1), f && e !== null && t !== null && e(...t);
|
|
33
|
+
}, i), l(f);
|
|
18
34
|
}, [
|
|
19
35
|
i,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
u,
|
|
37
|
+
f,
|
|
38
|
+
d
|
|
23
39
|
]),
|
|
24
40
|
cancel: _,
|
|
25
41
|
flush: v,
|
|
@@ -27,121 +43,219 @@ function c(e, t = {}) {
|
|
|
27
43
|
};
|
|
28
44
|
}
|
|
29
45
|
//#endregion
|
|
30
|
-
//#region src/performance/
|
|
31
|
-
|
|
46
|
+
//#region src/performance/useDebouncer/useDebouncedCallback.ts
|
|
47
|
+
var u = globalThis.process?.env?.NODE_ENV !== "production";
|
|
48
|
+
function d(e, t, i = {}) {
|
|
49
|
+
u && typeof e != "function" && console.warn(`[useDebouncedCallback] Expected \`func\` to be a function, received ${typeof e}.`);
|
|
32
50
|
let a = o(e);
|
|
33
51
|
r(() => {
|
|
34
52
|
a.current = e;
|
|
35
53
|
}, [e]);
|
|
36
|
-
let { run: s, cancel:
|
|
54
|
+
let { run: s, cancel: c, flush: d, isPending: f } = l(t, i);
|
|
37
55
|
return {
|
|
38
56
|
debouncedFunc: n((...e) => {
|
|
39
57
|
s(a.current, ...e);
|
|
40
58
|
}, [s]),
|
|
41
|
-
cancel:
|
|
42
|
-
flush:
|
|
43
|
-
isPending:
|
|
59
|
+
cancel: c,
|
|
60
|
+
flush: d,
|
|
61
|
+
isPending: f
|
|
44
62
|
};
|
|
45
63
|
}
|
|
46
64
|
//#endregion
|
|
47
|
-
//#region src/
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
//#region src/shared/rateControlShared/utils.ts
|
|
66
|
+
function f(e) {
|
|
67
|
+
return typeof e == "function";
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/performance/useDebouncer/useDebouncedState.ts
|
|
71
|
+
var p = globalThis.process?.env?.NODE_ENV !== "production";
|
|
72
|
+
function m(e, t, r = {}) {
|
|
73
|
+
p && r.equalityFn !== void 0 && typeof r.equalityFn != "function" && console.warn("[useDebouncedState] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
74
|
+
let i = typeof r.equalityFn == "function" ? r.equalityFn : Object.is, [a, c] = s(e), l = o(a), { debouncedFunc: u, cancel: m, flush: h, isPending: g } = d(n((e) => {
|
|
75
|
+
c((t) => i(t, e) ? t : e);
|
|
76
|
+
}, [i]), t, r);
|
|
52
77
|
return [
|
|
53
|
-
r,
|
|
54
78
|
a,
|
|
79
|
+
n((e) => {
|
|
80
|
+
let t = f(e) ? e(l.current) : e;
|
|
81
|
+
l.current = t, u(t);
|
|
82
|
+
}, [u]),
|
|
55
83
|
{
|
|
56
|
-
isPending:
|
|
57
|
-
cancel:
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
isPending: g,
|
|
85
|
+
cancel: n(() => {
|
|
86
|
+
m(), c((e) => (l.current = e, e));
|
|
87
|
+
}, [m]),
|
|
88
|
+
flush: h,
|
|
89
|
+
forceSetValue: n((e) => {
|
|
90
|
+
m(), c((t) => {
|
|
91
|
+
let n = f(e) ? e(t) : e;
|
|
92
|
+
return l.current = n, n;
|
|
93
|
+
});
|
|
94
|
+
}, [m])
|
|
60
95
|
}
|
|
61
96
|
];
|
|
62
97
|
}
|
|
63
98
|
//#endregion
|
|
64
|
-
//#region src/performance/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
//#region src/performance/useDebouncer/useDebouncedValue.ts
|
|
100
|
+
var h = globalThis.process?.env?.NODE_ENV !== "production";
|
|
101
|
+
function g(e, t, n = {}) {
|
|
102
|
+
h && n.equalityFn !== void 0 && typeof n.equalityFn != "function" && console.warn("[useDebouncedValue] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
103
|
+
let i = typeof n.equalityFn == "function" ? n.equalityFn : Object.is, [a, o] = s(e), { debouncedFunc: c, cancel: l, flush: u, isPending: f } = d((e) => {
|
|
104
|
+
o((t) => i(t, e) ? t : e);
|
|
68
105
|
}, t, n);
|
|
69
106
|
return r(() => {
|
|
70
|
-
|
|
71
|
-
}, [e,
|
|
107
|
+
c(e);
|
|
108
|
+
}, [e, c]), [a, {
|
|
109
|
+
isPending: f,
|
|
110
|
+
cancel: l,
|
|
111
|
+
flush: u
|
|
112
|
+
}];
|
|
72
113
|
}
|
|
73
114
|
//#endregion
|
|
74
|
-
//#region src/performance/
|
|
75
|
-
|
|
76
|
-
|
|
115
|
+
//#region src/performance/useRateLimiter/useRateLimiter.ts
|
|
116
|
+
var _ = globalThis.process?.env?.NODE_ENV !== "production";
|
|
117
|
+
function v(e, t, i) {
|
|
118
|
+
let a = Math.max(1, Math.floor(Number(e) || 1)), c = Math.max(0, Number(t) || 0);
|
|
119
|
+
_ && (typeof e != "number" || !Number.isFinite(e) || e < 1) && console.warn(`[useRateLimiter] Received an invalid \`limit\` (${String(e)}) — falling back to ${a}.`), _ && (typeof t != "number" || !Number.isFinite(t) || t < 0) && console.warn(`[useRateLimiter] Received an invalid \`windowMs\` (${String(t)}) — falling back to ${c}ms.`), _ && c === 0 && console.warn("[useRateLimiter] `windowMs` is 0 — rate limiting is effectively disabled; every call will be allowed."), _ && i?.refillStrategy !== void 0 && i.refillStrategy !== "burst" && i.refillStrategy !== "gradual" && console.warn(`[useRateLimiter] \`refillStrategy\` must be "burst" or "gradual", received "${String(i.refillStrategy)}" — falling back to "burst".`), _ && i?.onRateLimitReached !== void 0 && typeof i.onRateLimitReached != "function" && console.warn("[useRateLimiter] `onRateLimitReached` must be a function — ignoring the provided value.");
|
|
120
|
+
let [l, u] = s(a), d = i?.refillStrategy === "gradual" ? "gradual" : "burst", f = o(typeof i?.onRateLimitReached == "function" ? i.onRateLimitReached : void 0);
|
|
77
121
|
r(() => {
|
|
78
|
-
f.current = i?.onRateLimitReached;
|
|
122
|
+
f.current = typeof i?.onRateLimitReached == "function" ? i.onRateLimitReached : void 0;
|
|
79
123
|
}, [i?.onRateLimitReached]);
|
|
80
|
-
let p = o(a),
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}, [])
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
124
|
+
let p = o(a), m = o(Date.now()), h = o(null);
|
|
125
|
+
r(() => () => {
|
|
126
|
+
h.current !== null && clearTimeout(h.current);
|
|
127
|
+
}, []);
|
|
128
|
+
let g = n(() => {
|
|
129
|
+
if (c === 0) {
|
|
130
|
+
p.current !== a && (p.current = a, u(a));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
let e = Date.now(), t = e - m.current;
|
|
134
|
+
if (d === "burst") {
|
|
135
|
+
t >= c && p.current !== a && (p.current = a, m.current = e, u(a));
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
let n = c / a, r = Math.floor(t / n);
|
|
139
|
+
r > 0 && (p.current = Math.min(a, p.current + r), m.current += r * n, u(p.current));
|
|
140
|
+
}, [
|
|
141
|
+
d,
|
|
142
|
+
c,
|
|
143
|
+
a
|
|
144
|
+
]), v = n(function e() {
|
|
145
|
+
if (h.current !== null && (clearTimeout(h.current), h.current = null), p.current >= a || c === 0) return;
|
|
146
|
+
let t = c / a, n = Date.now() - m.current, r = d === "burst" ? c - n : t - n;
|
|
147
|
+
h.current = setTimeout(() => {
|
|
148
|
+
h.current = null, g(), e();
|
|
149
|
+
}, Math.max(0, r));
|
|
150
|
+
}, [
|
|
151
|
+
a,
|
|
152
|
+
c,
|
|
153
|
+
d,
|
|
154
|
+
g
|
|
155
|
+
]), y = n(() => {
|
|
156
|
+
h.current !== null && (clearTimeout(h.current), h.current = null), p.current = a, m.current = Date.now(), u(a);
|
|
157
|
+
}, [a]);
|
|
158
|
+
return {
|
|
159
|
+
run: n((e, ...t) => (g(), p.current > 0 ? (--p.current, u(p.current), v(), e(...t), !0) : (f.current?.(), v(), !1)), [g, v]),
|
|
160
|
+
reset: y,
|
|
102
161
|
remaining: l,
|
|
103
162
|
isRateLimited: l === 0
|
|
104
163
|
};
|
|
105
164
|
}
|
|
106
165
|
//#endregion
|
|
107
|
-
//#region src/performance/
|
|
108
|
-
|
|
166
|
+
//#region src/performance/useRateLimiter/useRateLimitedCallback.ts
|
|
167
|
+
var y = globalThis.process?.env?.NODE_ENV !== "production";
|
|
168
|
+
function b(e, t, i, a) {
|
|
169
|
+
y && typeof e != "function" && console.warn(`[useRateLimitedCallback] Expected \`func\` to be a function, received ${typeof e}.`);
|
|
109
170
|
let s = o(e);
|
|
110
171
|
r(() => {
|
|
111
172
|
s.current = e;
|
|
112
173
|
}, [e]);
|
|
113
|
-
let { run: c,
|
|
174
|
+
let { run: c, reset: l, remaining: u, isRateLimited: d } = v(t, i, a);
|
|
114
175
|
return {
|
|
115
|
-
rateLimitedFunc: n((...e) =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
isRateLimited: u
|
|
176
|
+
rateLimitedFunc: n((...e) => c(s.current, ...e), [c]),
|
|
177
|
+
reset: l,
|
|
178
|
+
remaining: u,
|
|
179
|
+
isRateLimited: d
|
|
120
180
|
};
|
|
121
181
|
}
|
|
122
182
|
//#endregion
|
|
123
|
-
//#region src/performance/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
183
|
+
//#region src/performance/useRateLimiter/useRateLimitedState.ts
|
|
184
|
+
var x = globalThis.process?.env?.NODE_ENV !== "production";
|
|
185
|
+
function S(e, t, r, i = {}) {
|
|
186
|
+
x && i.equalityFn !== void 0 && typeof i.equalityFn != "function" && console.warn("[useRateLimitedState] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
187
|
+
let a = typeof i.equalityFn == "function" ? i.equalityFn : Object.is, [o, c] = s(e), l = n((e) => {
|
|
188
|
+
c((t) => {
|
|
189
|
+
let n = f(e) ? e(t) : e;
|
|
190
|
+
return a(t, n) ? t : n;
|
|
191
|
+
});
|
|
192
|
+
}, [a]), { rateLimitedFunc: u, reset: d, remaining: p, isRateLimited: m } = b(l, t, r, i);
|
|
193
|
+
return [
|
|
194
|
+
o,
|
|
195
|
+
n((e) => u(e), [u]),
|
|
196
|
+
{
|
|
197
|
+
remaining: p,
|
|
198
|
+
isRateLimited: m,
|
|
199
|
+
reset: d,
|
|
200
|
+
forceSetValue: n((e) => {
|
|
201
|
+
l(e);
|
|
202
|
+
}, [l])
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/performance/useRateLimiter/useRateLimitedValue.ts
|
|
208
|
+
var C = globalThis.process?.env?.NODE_ENV !== "production";
|
|
209
|
+
function w(e, t, n, i = {}) {
|
|
210
|
+
C && i.equalityFn !== void 0 && typeof i.equalityFn != "function" && console.warn("[useRateLimitedValue] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
211
|
+
let a = typeof i.equalityFn == "function" ? i.equalityFn : Object.is, [c, l] = s(e), { rateLimitedFunc: u, reset: d, remaining: f, isRateLimited: p } = b((e) => {
|
|
212
|
+
l((t) => a(t, e) ? t : e);
|
|
213
|
+
}, t, n, i), m = o(!0);
|
|
214
|
+
return r(() => {
|
|
215
|
+
if (m.current) {
|
|
216
|
+
m.current = !1;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
u(e);
|
|
220
|
+
}, [e, u]), [c, {
|
|
221
|
+
remaining: f,
|
|
222
|
+
isRateLimited: p,
|
|
223
|
+
reset: d
|
|
224
|
+
}];
|
|
225
|
+
}
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/performance/useThrottler/useThrottler.ts
|
|
228
|
+
var T = globalThis.process?.env?.NODE_ENV !== "production";
|
|
229
|
+
function E(e, t = {}) {
|
|
230
|
+
let i = Math.max(0, Number(e) || 0);
|
|
231
|
+
T && (typeof e != "number" || !Number.isFinite(e) || e < 0) && console.warn(`[useThrottler] Received an invalid \`delay\` (${String(e)}) — falling back to ${i}ms.`);
|
|
232
|
+
let [a, c] = s(!1), l = t?.leading ?? !0, u = t?.trailing ?? !0;
|
|
233
|
+
T && !l && !u && console.warn("[useThrottler] Both `leading` and `trailing` are false — the throttled function will never be invoked.");
|
|
127
234
|
let d = o(null), f = o(null), p = o(null), m = o(-1), h = n(() => {
|
|
128
|
-
p.current
|
|
235
|
+
p.current !== null && (clearTimeout(p.current), p.current = null), m.current = -1, f.current = null, d.current = null, c(!1);
|
|
129
236
|
}, []), g = n(() => {
|
|
130
|
-
|
|
237
|
+
let e = d.current, t = f.current;
|
|
238
|
+
e === null || t === null || (p.current !== null && (clearTimeout(p.current), p.current = null), m.current = l ? Date.now() : -1, f.current = null, d.current = null, c(!1), e(...t));
|
|
131
239
|
}, [l]);
|
|
132
|
-
return r(() =>
|
|
133
|
-
h();
|
|
134
|
-
}, [h]), {
|
|
240
|
+
return r(() => h, [h]), {
|
|
135
241
|
run: n((e, ...t) => {
|
|
136
|
-
|
|
242
|
+
if (!l && !u) return;
|
|
137
243
|
let n = Date.now();
|
|
138
|
-
if (f.current = t, d.current = e, m.current === -1 ? l : n - m.current >= i)
|
|
139
|
-
|
|
244
|
+
if (f.current = t, d.current = e, m.current === -1 ? l : n - m.current >= i) {
|
|
245
|
+
p.current !== null && (clearTimeout(p.current), p.current = null);
|
|
246
|
+
let e = d.current, t = f.current;
|
|
247
|
+
m.current = n, f.current = null, c(!1), e(...t);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (p.current === null) {
|
|
140
251
|
let e = m.current === -1 ? 0 : n - m.current, t = i - e;
|
|
141
252
|
p.current = setTimeout(() => {
|
|
142
|
-
|
|
143
|
-
|
|
253
|
+
p.current = null;
|
|
254
|
+
let e = d.current, t = f.current;
|
|
255
|
+
f.current = null, d.current = null, c(!1), u && e !== null && t !== null ? (m.current = l ? Date.now() : -1, e(...t)) : m.current = -1;
|
|
256
|
+
}, Math.max(0, t));
|
|
144
257
|
}
|
|
258
|
+
c(u);
|
|
145
259
|
}, [
|
|
146
260
|
i,
|
|
147
261
|
l,
|
|
@@ -153,13 +267,15 @@ function m(e, t = {}) {
|
|
|
153
267
|
};
|
|
154
268
|
}
|
|
155
269
|
//#endregion
|
|
156
|
-
//#region src/performance/
|
|
157
|
-
|
|
270
|
+
//#region src/performance/useThrottler/useThrottledCallback.ts
|
|
271
|
+
var D = globalThis.process?.env?.NODE_ENV !== "production";
|
|
272
|
+
function O(e, t, i = {}) {
|
|
273
|
+
D && typeof e != "function" && console.warn(`[useThrottledCallback] Expected \`func\` to be a function, received ${typeof e}.`);
|
|
158
274
|
let a = o(e);
|
|
159
275
|
r(() => {
|
|
160
276
|
a.current = e;
|
|
161
277
|
}, [e]);
|
|
162
|
-
let { run: s, cancel: c, flush: l, isPending: u } =
|
|
278
|
+
let { run: s, cancel: c, flush: l, isPending: u } = E(t, i);
|
|
163
279
|
return {
|
|
164
280
|
throttledFunc: n((...e) => {
|
|
165
281
|
s(a.current, ...e);
|
|
@@ -170,35 +286,53 @@ function h(e, t, i = {}) {
|
|
|
170
286
|
};
|
|
171
287
|
}
|
|
172
288
|
//#endregion
|
|
173
|
-
//#region src/performance/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
289
|
+
//#region src/performance/useThrottler/useThrottledState.ts
|
|
290
|
+
var k = globalThis.process?.env?.NODE_ENV !== "production";
|
|
291
|
+
function A(e, t, r = {}) {
|
|
292
|
+
k && r.equalityFn !== void 0 && typeof r.equalityFn != "function" && console.warn("[useThrottledState] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
293
|
+
let i = typeof r.equalityFn == "function" ? r.equalityFn : Object.is, [a, c] = s(e), l = o(a), { throttledFunc: u, cancel: d, flush: p, isPending: m } = O(n((e) => {
|
|
294
|
+
c((t) => i(t, e) ? t : e);
|
|
295
|
+
}, [i]), t, r);
|
|
178
296
|
return [
|
|
179
|
-
r,
|
|
180
297
|
a,
|
|
298
|
+
n((e) => {
|
|
299
|
+
let t = f(e) ? e(l.current) : e;
|
|
300
|
+
l.current = t, u(t);
|
|
301
|
+
}, [u]),
|
|
181
302
|
{
|
|
182
|
-
isPending:
|
|
183
|
-
cancel:
|
|
184
|
-
|
|
185
|
-
|
|
303
|
+
isPending: m,
|
|
304
|
+
cancel: n(() => {
|
|
305
|
+
d(), c((e) => (l.current = e, e));
|
|
306
|
+
}, [d]),
|
|
307
|
+
flush: p,
|
|
308
|
+
forceSetValue: n((e) => {
|
|
309
|
+
d(), c((t) => {
|
|
310
|
+
let n = f(e) ? e(t) : e;
|
|
311
|
+
return l.current = n, n;
|
|
312
|
+
});
|
|
313
|
+
}, [d])
|
|
186
314
|
}
|
|
187
315
|
];
|
|
188
316
|
}
|
|
189
317
|
//#endregion
|
|
190
|
-
//#region src/performance/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
318
|
+
//#region src/performance/useThrottler/useThrottledValue.ts
|
|
319
|
+
var j = globalThis.process?.env?.NODE_ENV !== "production";
|
|
320
|
+
function M(e, t, n = {}) {
|
|
321
|
+
j && n.equalityFn !== void 0 && typeof n.equalityFn != "function" && console.warn("[useThrottledValue] `equalityFn` must be a function — falling back to `Object.is`.");
|
|
322
|
+
let i = typeof n.equalityFn == "function" ? n.equalityFn : Object.is, [a, o] = s(e), { throttledFunc: c, cancel: l, flush: u, isPending: d } = O((e) => {
|
|
323
|
+
o((t) => i(t, e) ? t : e);
|
|
194
324
|
}, t, n);
|
|
195
325
|
return r(() => {
|
|
196
|
-
|
|
197
|
-
}, [e,
|
|
326
|
+
c(e);
|
|
327
|
+
}, [e, c]), [a, {
|
|
328
|
+
isPending: d,
|
|
329
|
+
cancel: l,
|
|
330
|
+
flush: u
|
|
331
|
+
}];
|
|
198
332
|
}
|
|
199
333
|
//#endregion
|
|
200
334
|
//#region src/shared/virtualShared/offsetCache.ts
|
|
201
|
-
var
|
|
335
|
+
var N = class {
|
|
202
336
|
_offsets = /* @__PURE__ */ new Float64Array();
|
|
203
337
|
_count = 0;
|
|
204
338
|
initializeOffsets(e, t) {
|
|
@@ -267,42 +401,42 @@ var v = class {
|
|
|
267
401
|
};
|
|
268
402
|
//#endregion
|
|
269
403
|
//#region src/shared/virtualShared/utils.ts
|
|
270
|
-
function
|
|
404
|
+
function P(e, t) {
|
|
271
405
|
let n = typeof t == "function" ? t(e) : t, r = Number(n);
|
|
272
406
|
return Number.isFinite(r) && r >= 0 ? r : 0;
|
|
273
407
|
}
|
|
274
|
-
function
|
|
408
|
+
function F(e, t, n) {
|
|
275
409
|
if (e <= 0) return 0;
|
|
276
410
|
if (typeof t == "number") return e * Math.max(0, t);
|
|
277
411
|
if (n) return n.getItemStartOffset(e);
|
|
278
412
|
let r = 0;
|
|
279
|
-
for (let n = 0; n < e; n++) r +=
|
|
413
|
+
for (let n = 0; n < e; n++) r += P(n, t);
|
|
280
414
|
return r;
|
|
281
415
|
}
|
|
282
|
-
function
|
|
416
|
+
function I(e, t, n) {
|
|
283
417
|
if (e <= 0) return 0;
|
|
284
418
|
if (typeof t == "number") return e * Math.max(0, t);
|
|
285
419
|
if (n) return n.getTotalSize();
|
|
286
420
|
let r = 0;
|
|
287
|
-
for (let n = 0; n < e; n++) r +=
|
|
421
|
+
for (let n = 0; n < e; n++) r += P(n, t);
|
|
288
422
|
return r;
|
|
289
423
|
}
|
|
290
|
-
function
|
|
424
|
+
function L(e, t) {
|
|
291
425
|
if (!e) return 0;
|
|
292
426
|
let n = t === "vertical";
|
|
293
427
|
return e instanceof Window ? n ? document.documentElement.clientHeight : document.documentElement.clientWidth : e instanceof Document ? n ? e.documentElement.clientHeight : e.documentElement.clientWidth : n ? e.clientHeight : e.clientWidth;
|
|
294
428
|
}
|
|
295
|
-
function
|
|
429
|
+
function R(e, t) {
|
|
296
430
|
if (!e) return 0;
|
|
297
431
|
let n = t === "vertical";
|
|
298
432
|
return e instanceof Window ? n ? e.scrollY : e.scrollX : e instanceof Document ? n ? e.documentElement.scrollTop : e.documentElement.scrollLeft : n ? e.scrollTop : e.scrollLeft;
|
|
299
433
|
}
|
|
300
|
-
function
|
|
434
|
+
function z(e) {
|
|
301
435
|
return e ? e instanceof Window ? document.documentElement : e instanceof Document ? e.scrollingElement ?? e.documentElement : e : null;
|
|
302
436
|
}
|
|
303
437
|
//#endregion
|
|
304
438
|
//#region src/performance/useVirtualGrid/utils.ts
|
|
305
|
-
function
|
|
439
|
+
function B(e, t, n, r, i, a) {
|
|
306
440
|
if (n <= 0 || t <= 0) return {
|
|
307
441
|
startIndex: 0,
|
|
308
442
|
endIndex: -1
|
|
@@ -318,7 +452,7 @@ function T(e, t, n, r, i, a) {
|
|
|
318
452
|
o = 0, s = -1;
|
|
319
453
|
let i = 0, a = !1;
|
|
320
454
|
for (let c = 0; c < n; c++) {
|
|
321
|
-
let n =
|
|
455
|
+
let n = P(c, r), l = i + n;
|
|
322
456
|
if (!a && l > e && (o = c, a = !0), a) if (i < e + t) s = c;
|
|
323
457
|
else break;
|
|
324
458
|
i += n;
|
|
@@ -330,8 +464,8 @@ function T(e, t, n, r, i, a) {
|
|
|
330
464
|
endIndex: s
|
|
331
465
|
};
|
|
332
466
|
}
|
|
333
|
-
function
|
|
334
|
-
let s = o ? o.getItemSize(e) :
|
|
467
|
+
function V(e, t, n, r, i, a, o) {
|
|
468
|
+
let s = o ? o.getItemSize(e) : P(e, a), c = F(e, a, o), l = c + s, u = Math.max(0, r - n), d;
|
|
335
469
|
switch (t) {
|
|
336
470
|
case "start":
|
|
337
471
|
d = c;
|
|
@@ -351,47 +485,47 @@ function E(e, t, n, r, i, a, o) {
|
|
|
351
485
|
}
|
|
352
486
|
//#endregion
|
|
353
487
|
//#region src/performance/useVirtualGrid/useVirtualGrid.ts
|
|
354
|
-
function
|
|
355
|
-
let { rowCount: c, colCount:
|
|
488
|
+
function H(t) {
|
|
489
|
+
let { rowCount: c, colCount: l, estimateRowHeight: u, estimateColumnWidth: f, getScrollElement: p, overscanRows: m = 3, overscanCols: h = 3, scrollingDelay: g = 150, initialViewportHeight: _ = 0, initialViewportWidth: v = 0, initialScrollTop: y, initialScrollLeft: b, initialScrollRow: x, initialScrollCol: S, itemKey: C } = t, w = Math.max(0, Math.trunc(Number(c)) || 0), T = Math.max(0, Math.trunc(Number(l)) || 0), E = Math.max(0, Math.trunc(Number(m)) || 0), D = Math.max(0, Math.trunc(Number(h)) || 0), O = o(t);
|
|
356
490
|
i(() => {
|
|
357
|
-
|
|
491
|
+
O.current = t;
|
|
358
492
|
});
|
|
359
|
-
let
|
|
360
|
-
if (typeof
|
|
361
|
-
let e = new
|
|
362
|
-
return e.initializeOffsets(
|
|
363
|
-
}, [
|
|
493
|
+
let k = a(() => {
|
|
494
|
+
if (typeof u != "function") return;
|
|
495
|
+
let e = new N();
|
|
496
|
+
return e.initializeOffsets(w, u), e;
|
|
497
|
+
}, [w, u]), A = a(() => {
|
|
364
498
|
if (typeof f != "function") return;
|
|
365
|
-
let e = new
|
|
366
|
-
return e.initializeOffsets(
|
|
367
|
-
}, [
|
|
499
|
+
let e = new N();
|
|
500
|
+
return e.initializeOffsets(T, f), e;
|
|
501
|
+
}, [T, f]), j = o(k), M = o(A);
|
|
368
502
|
i(() => {
|
|
369
|
-
|
|
370
|
-
}, [
|
|
371
|
-
|
|
372
|
-
}, [
|
|
503
|
+
j.current = k;
|
|
504
|
+
}, [k]), i(() => {
|
|
505
|
+
M.current = A;
|
|
506
|
+
}, [A]);
|
|
373
507
|
let [H, U] = s(() => {
|
|
374
|
-
if (typeof
|
|
375
|
-
if (typeof
|
|
376
|
-
let e = Math.max(0, Math.min(Math.trunc(Number(
|
|
377
|
-
return
|
|
508
|
+
if (typeof y == "number") return Math.max(0, y);
|
|
509
|
+
if (typeof x == "number" && w > 0) {
|
|
510
|
+
let e = Math.max(0, Math.min(Math.trunc(Number(x)) || 0, w - 1));
|
|
511
|
+
return k ? k.getItemStartOffset(e) : F(e, u);
|
|
378
512
|
}
|
|
379
513
|
return 0;
|
|
380
514
|
}), [W, G] = s(() => {
|
|
381
|
-
if (typeof
|
|
382
|
-
if (typeof
|
|
383
|
-
let e = Math.max(0, Math.min(Math.trunc(Number(
|
|
384
|
-
return
|
|
515
|
+
if (typeof b == "number") return Math.max(0, b);
|
|
516
|
+
if (typeof S == "number" && T > 0) {
|
|
517
|
+
let e = Math.max(0, Math.min(Math.trunc(Number(S)) || 0, T - 1));
|
|
518
|
+
return A ? A.getItemStartOffset(e) : F(e, f);
|
|
385
519
|
}
|
|
386
520
|
return 0;
|
|
387
|
-
}), [K, q] = s(!1), [, J] = s({}), Y = o(!1), { debouncedFunc: X } =
|
|
521
|
+
}), [K, q] = s(!1), [, J] = s({}), Y = o(!1), { debouncedFunc: X } = d(() => q(!1), g), Z = p();
|
|
388
522
|
r(() => {
|
|
389
523
|
if (!Z) return;
|
|
390
524
|
if (!Y.current) {
|
|
391
525
|
Y.current = !0;
|
|
392
|
-
let e = typeof
|
|
526
|
+
let e = typeof y == "number" || typeof x == "number", t = typeof b == "number" || typeof S == "number";
|
|
393
527
|
if (e || t) {
|
|
394
|
-
let n =
|
|
528
|
+
let n = z(Z);
|
|
395
529
|
n && n.scrollTo({
|
|
396
530
|
...e && { top: H },
|
|
397
531
|
...t && { left: W },
|
|
@@ -400,21 +534,21 @@ function D(t) {
|
|
|
400
534
|
return;
|
|
401
535
|
}
|
|
402
536
|
}
|
|
403
|
-
let e =
|
|
537
|
+
let e = R(Z, "vertical"), t = R(Z, "horizontal");
|
|
404
538
|
U((t) => t === e ? t : e), G((e) => e === t ? e : t);
|
|
405
539
|
}, [
|
|
406
540
|
Z,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
541
|
+
y,
|
|
542
|
+
b,
|
|
543
|
+
x,
|
|
544
|
+
S,
|
|
411
545
|
H,
|
|
412
546
|
W
|
|
413
547
|
]);
|
|
414
548
|
function ee() {
|
|
415
|
-
let { getScrollElement: e, scrollingDelay: t } =
|
|
549
|
+
let { getScrollElement: e, scrollingDelay: t } = O.current, n = e();
|
|
416
550
|
if (!n) return;
|
|
417
|
-
let r =
|
|
551
|
+
let r = R(n, "vertical"), i = R(n, "horizontal");
|
|
418
552
|
U(r), G(i), (t ?? 150) > 0 && (q(!0), X());
|
|
419
553
|
}
|
|
420
554
|
e("scroll", ee, {
|
|
@@ -427,13 +561,13 @@ function D(t) {
|
|
|
427
561
|
let t = new ResizeObserver(e), n = Z instanceof Document ? Z.documentElement : Z;
|
|
428
562
|
return t.observe(n), () => t.disconnect();
|
|
429
563
|
}, [Z]);
|
|
430
|
-
let te =
|
|
564
|
+
let te = L(Z, "vertical") || _, ne = L(Z, "horizontal") || v, re = I(w, u, k), ie = I(T, f, A), { startIndex: Q, endIndex: ae } = B(H, te, w, u, E, k), { startIndex: $, endIndex: oe } = B(W, ne, T, f, D, A), se = [];
|
|
431
565
|
if (Q <= ae && $ <= oe) {
|
|
432
|
-
let e =
|
|
566
|
+
let e = k ? k.getItemStartOffset(Q) : F(Q, u);
|
|
433
567
|
for (let t = Q; t <= ae; t++) {
|
|
434
|
-
let n =
|
|
568
|
+
let n = k ? k.getItemSize(t) : P(t, u), r = A ? A.getItemStartOffset($) : F($, f);
|
|
435
569
|
for (let i = $; i <= oe; i++) {
|
|
436
|
-
let a =
|
|
570
|
+
let a = A ? A.getItemSize(i) : P(i, f), o = C ? C(t, i) : `${t}:${i}`;
|
|
437
571
|
se.push({
|
|
438
572
|
key: o,
|
|
439
573
|
rowIndex: t,
|
|
@@ -453,9 +587,9 @@ function D(t) {
|
|
|
453
587
|
totalWidth: ie,
|
|
454
588
|
isScrolling: K,
|
|
455
589
|
scrollToOffset: n((e, t) => {
|
|
456
|
-
let { getScrollElement: n, initialViewportHeight: r, initialViewportWidth: i } =
|
|
590
|
+
let { getScrollElement: n, initialViewportHeight: r, initialViewportWidth: i } = O.current, a = n();
|
|
457
591
|
if (!a) return;
|
|
458
|
-
let { rowCount: o, colCount: s, estimateRowHeight: c, estimateColumnWidth: l } =
|
|
592
|
+
let { rowCount: o, colCount: s, estimateRowHeight: c, estimateColumnWidth: l } = O.current, u = Math.max(0, Math.trunc(Number(o)) || 0), d = Math.max(0, Math.trunc(Number(s)) || 0), f = I(u, c, j.current), p = I(d, l, M.current), m = L(a, "vertical") || r || 0, h = L(a, "horizontal") || i || 0, g = Math.max(0, Math.min(e.top, Math.max(0, f - m))), _ = Math.max(0, Math.min(e.left, Math.max(0, p - h))), v = z(a);
|
|
459
593
|
v && v.scrollTo({
|
|
460
594
|
top: g,
|
|
461
595
|
left: _,
|
|
@@ -463,36 +597,36 @@ function D(t) {
|
|
|
463
597
|
});
|
|
464
598
|
}, []),
|
|
465
599
|
scrollToRow: n((e, t) => {
|
|
466
|
-
let { getScrollElement: n, rowCount: r, estimateRowHeight: i, initialViewportHeight: a } =
|
|
600
|
+
let { getScrollElement: n, rowCount: r, estimateRowHeight: i, initialViewportHeight: a } = O.current, o = n();
|
|
467
601
|
if (!o) return;
|
|
468
602
|
let s = Math.max(0, Math.trunc(Number(r)) || 0);
|
|
469
603
|
if (s === 0) return;
|
|
470
|
-
let c = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, s - 1)), l =
|
|
604
|
+
let c = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, s - 1)), l = L(o, "vertical") || a || 0, u = I(s, i, j.current), d = R(o, "vertical"), f = V(c, t?.align ?? "auto", l, u, d, i, j.current), p = z(o);
|
|
471
605
|
p && p.scrollTo({
|
|
472
606
|
top: f,
|
|
473
607
|
behavior: t?.smooth === !0 ? "smooth" : "auto"
|
|
474
608
|
});
|
|
475
609
|
}, []),
|
|
476
610
|
scrollToColumn: n((e, t) => {
|
|
477
|
-
let { getScrollElement: n, colCount: r, estimateColumnWidth: i, initialViewportWidth: a } =
|
|
611
|
+
let { getScrollElement: n, colCount: r, estimateColumnWidth: i, initialViewportWidth: a } = O.current, o = n();
|
|
478
612
|
if (!o) return;
|
|
479
613
|
let s = Math.max(0, Math.trunc(Number(r)) || 0);
|
|
480
614
|
if (s === 0) return;
|
|
481
|
-
let c = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, s - 1)), l =
|
|
615
|
+
let c = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, s - 1)), l = L(o, "horizontal") || a || 0, u = I(s, i, M.current), d = R(o, "horizontal"), f = V(c, t?.align ?? "auto", l, u, d, i, M.current), p = z(o);
|
|
482
616
|
p && p.scrollTo({
|
|
483
617
|
left: f,
|
|
484
618
|
behavior: t?.smooth === !0 ? "smooth" : "auto"
|
|
485
619
|
});
|
|
486
620
|
}, []),
|
|
487
621
|
scrollToCell: n((e, t, n) => {
|
|
488
|
-
let { getScrollElement: r, rowCount: i, colCount: a, estimateRowHeight: o, estimateColumnWidth: s, initialViewportHeight: c, initialViewportWidth: l } =
|
|
622
|
+
let { getScrollElement: r, rowCount: i, colCount: a, estimateRowHeight: o, estimateColumnWidth: s, initialViewportHeight: c, initialViewportWidth: l } = O.current, u = r();
|
|
489
623
|
if (!u) return;
|
|
490
624
|
let d = Math.max(0, Math.trunc(Number(i)) || 0), f = Math.max(0, Math.trunc(Number(a)) || 0);
|
|
491
625
|
if (d === 0 || f === 0) return;
|
|
492
|
-
let p = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, d - 1)), m = Math.max(0, Math.min(Math.trunc(Number(t)) || 0, f - 1)), h =
|
|
493
|
-
|
|
494
|
-
top:
|
|
495
|
-
left:
|
|
626
|
+
let p = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, d - 1)), m = Math.max(0, Math.min(Math.trunc(Number(t)) || 0, f - 1)), h = L(u, "vertical") || c || 0, g = L(u, "horizontal") || l || 0, _ = I(d, o, j.current), v = I(f, s, M.current), y = R(u, "vertical"), b = R(u, "horizontal"), x = V(p, n?.rowAlign ?? "auto", h, _, y, o, j.current), S = V(m, n?.colAlign ?? "auto", g, v, b, s, M.current), C = z(u);
|
|
627
|
+
C && C.scrollTo({
|
|
628
|
+
top: x,
|
|
629
|
+
left: S,
|
|
496
630
|
behavior: n?.smooth === !0 ? "smooth" : "auto"
|
|
497
631
|
});
|
|
498
632
|
}, [])
|
|
@@ -500,13 +634,13 @@ function D(t) {
|
|
|
500
634
|
}
|
|
501
635
|
//#endregion
|
|
502
636
|
//#region src/performance/useVirtualList/utils.ts
|
|
503
|
-
function
|
|
504
|
-
return
|
|
637
|
+
function U(e, t) {
|
|
638
|
+
return L(e, t ? "horizontal" : "vertical");
|
|
505
639
|
}
|
|
506
|
-
function
|
|
507
|
-
return
|
|
640
|
+
function W(e, t) {
|
|
641
|
+
return R(e, t ? "horizontal" : "vertical");
|
|
508
642
|
}
|
|
509
|
-
function
|
|
643
|
+
function G(e, t, n, r, i, a, o, s) {
|
|
510
644
|
if (r <= 0 || t <= 0) return {
|
|
511
645
|
startIndex: 0,
|
|
512
646
|
endIndex: -1
|
|
@@ -526,7 +660,7 @@ function A(e, t, n, r, i, a, o, s) {
|
|
|
526
660
|
c = r, l = -1;
|
|
527
661
|
let a = 0;
|
|
528
662
|
for (let o = 0; o < r; o++) {
|
|
529
|
-
let r =
|
|
663
|
+
let r = P(o, i), s = n - a - r;
|
|
530
664
|
if (n - a <= e) break;
|
|
531
665
|
s < e + t && (o < c && (c = o), l = o), a += r;
|
|
532
666
|
}
|
|
@@ -535,7 +669,7 @@ function A(e, t, n, r, i, a, o, s) {
|
|
|
535
669
|
c = 0, l = -1;
|
|
536
670
|
let n = 0, a = !1;
|
|
537
671
|
for (let o = 0; o < r; o++) {
|
|
538
|
-
let r =
|
|
672
|
+
let r = P(o, i), s = n + r;
|
|
539
673
|
if (!a && s > e && (c = o, a = !0), a) if (n < e + t) l = o;
|
|
540
674
|
else break;
|
|
541
675
|
n += r;
|
|
@@ -547,8 +681,8 @@ function A(e, t, n, r, i, a, o, s) {
|
|
|
547
681
|
endIndex: l
|
|
548
682
|
};
|
|
549
683
|
}
|
|
550
|
-
function
|
|
551
|
-
let c = s ? s.getItemSize(e) :
|
|
684
|
+
function K(e, t, n, r, i, a, o, s) {
|
|
685
|
+
let c = s ? s.getItemSize(e) : P(e, a), l = F(e, a, s), u = o ? r - l - c : l, d = u + c, f = Math.max(0, r - n), p;
|
|
552
686
|
switch (t) {
|
|
553
687
|
case "start":
|
|
554
688
|
p = o ? Math.max(0, d - n) : u;
|
|
@@ -568,75 +702,75 @@ function j(e, t, n, r, i, a, o, s) {
|
|
|
568
702
|
}
|
|
569
703
|
//#endregion
|
|
570
704
|
//#region src/performance/useVirtualList/useVirtualList.ts
|
|
571
|
-
function
|
|
572
|
-
let { count:
|
|
705
|
+
function q(c) {
|
|
706
|
+
let { count: l, estimateSize: u, getScrollElement: f, overscan: p = 3, horizontal: m = !1, reverse: h = !1, scrollingDelay: g = 150, initialViewportSize: _ = 0, data: v, itemKey: y, initialOffset: b, initialScrollIndex: x } = c, S = Math.max(0, Math.trunc(Number(l)) || 0), C = Math.max(0, Math.trunc(Number(p)) || 0), w = o(c);
|
|
573
707
|
i(() => {
|
|
574
|
-
|
|
708
|
+
w.current = c;
|
|
575
709
|
});
|
|
576
|
-
let
|
|
577
|
-
if (typeof
|
|
578
|
-
let e = new
|
|
579
|
-
return e.initializeOffsets(
|
|
580
|
-
}, [
|
|
710
|
+
let T = a(() => {
|
|
711
|
+
if (typeof u != "function") return;
|
|
712
|
+
let e = new N();
|
|
713
|
+
return e.initializeOffsets(S, u), e;
|
|
714
|
+
}, [S, u]), E = o(T);
|
|
581
715
|
i(() => {
|
|
582
|
-
|
|
583
|
-
}, [
|
|
584
|
-
let [
|
|
585
|
-
if (typeof
|
|
586
|
-
if (typeof
|
|
587
|
-
let e = Math.max(0, Math.min(Math.trunc(Number(
|
|
716
|
+
E.current = T;
|
|
717
|
+
}, [T]);
|
|
718
|
+
let [D, O] = s(() => {
|
|
719
|
+
if (typeof b == "number") return Math.max(0, b);
|
|
720
|
+
if (typeof x == "number" && S > 0) {
|
|
721
|
+
let e = Math.max(0, Math.min(Math.trunc(Number(x)) || 0, S - 1)), t = T ? T.getItemStartOffset(e) : F(e, u);
|
|
588
722
|
if (h) {
|
|
589
|
-
let n =
|
|
723
|
+
let n = T ? T.getItemSize(e) : P(e, u), r = I(S, u, T);
|
|
590
724
|
return Math.max(0, r - t - n);
|
|
591
725
|
}
|
|
592
726
|
return t;
|
|
593
727
|
}
|
|
594
728
|
return 0;
|
|
595
|
-
}), [
|
|
729
|
+
}), [k, A] = s(!1), [, j] = s({}), M = o(!1), { debouncedFunc: L } = d(() => A(!1), g), R = f();
|
|
596
730
|
r(() => {
|
|
597
|
-
if (!
|
|
598
|
-
if (!
|
|
599
|
-
let e =
|
|
731
|
+
if (!R) return;
|
|
732
|
+
if (!M.current && (M.current = !0, typeof b == "number" || typeof x == "number")) {
|
|
733
|
+
let e = z(R);
|
|
600
734
|
e && e.scrollTo({
|
|
601
|
-
[m ? "left" : "top"]:
|
|
735
|
+
[m ? "left" : "top"]: D,
|
|
602
736
|
behavior: "auto"
|
|
603
737
|
});
|
|
604
738
|
return;
|
|
605
739
|
}
|
|
606
|
-
let e =
|
|
607
|
-
|
|
740
|
+
let e = W(R, m);
|
|
741
|
+
O((t) => t === e ? t : e);
|
|
608
742
|
}, [
|
|
609
|
-
|
|
743
|
+
R,
|
|
610
744
|
m,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
745
|
+
b,
|
|
746
|
+
x,
|
|
747
|
+
D
|
|
614
748
|
]);
|
|
615
|
-
function
|
|
616
|
-
let { getScrollElement: e, horizontal: t } =
|
|
749
|
+
function B() {
|
|
750
|
+
let { getScrollElement: e, horizontal: t } = w.current, n = e();
|
|
617
751
|
if (!n) return;
|
|
618
|
-
let r =
|
|
619
|
-
|
|
752
|
+
let r = W(n, t ?? !1);
|
|
753
|
+
O(r), (w.current.scrollingDelay ?? 150) > 0 && (A(!0), L());
|
|
620
754
|
}
|
|
621
|
-
e("scroll",
|
|
622
|
-
target:
|
|
755
|
+
e("scroll", B, {
|
|
756
|
+
target: R,
|
|
623
757
|
passive: !0
|
|
624
758
|
}), r(() => {
|
|
625
|
-
if (!
|
|
626
|
-
let e = () =>
|
|
627
|
-
if (
|
|
628
|
-
let t = new ResizeObserver(e), n =
|
|
759
|
+
if (!R) return;
|
|
760
|
+
let e = () => j({});
|
|
761
|
+
if (R instanceof Window) return R.addEventListener("resize", e), () => R.removeEventListener("resize", e);
|
|
762
|
+
let t = new ResizeObserver(e), n = R instanceof Document ? R.documentElement : R;
|
|
629
763
|
return t.observe(n), () => t.disconnect();
|
|
630
|
-
}, [
|
|
631
|
-
let
|
|
764
|
+
}, [R]);
|
|
765
|
+
let V = U(R, m) || _, H = I(S, u, T), { startIndex: q, endIndex: J } = G(D, V, H, S, u, C, h, T), Y = [];
|
|
632
766
|
if (q <= J) {
|
|
633
|
-
let e =
|
|
767
|
+
let e = T ? T.getItemStartOffset(q) : F(q, u);
|
|
634
768
|
for (let n = q; n <= J; n++) {
|
|
635
|
-
let r =
|
|
636
|
-
if (
|
|
637
|
-
if (typeof
|
|
638
|
-
else if (
|
|
639
|
-
let e = t(
|
|
769
|
+
let r = T ? T.getItemSize(n) : P(n, u), i = h ? H - e - r : e, a = n;
|
|
770
|
+
if (y) {
|
|
771
|
+
if (typeof y == "function") a = y(n, v?.[n]);
|
|
772
|
+
else if (v && v[n] !== void 0 && v[n] !== null) {
|
|
773
|
+
let e = t(v[n], y);
|
|
640
774
|
(typeof e == "string" || typeof e == "number") && (a = e);
|
|
641
775
|
}
|
|
642
776
|
}
|
|
@@ -649,23 +783,23 @@ function M(c) {
|
|
|
649
783
|
}
|
|
650
784
|
}
|
|
651
785
|
let X = n((e, t) => {
|
|
652
|
-
let { getScrollElement: n, horizontal: r, count: i, estimateSize: a } =
|
|
786
|
+
let { getScrollElement: n, horizontal: r, count: i, estimateSize: a } = w.current, o = n();
|
|
653
787
|
if (!o) return;
|
|
654
|
-
let s = r ?? !1, c =
|
|
788
|
+
let s = r ?? !1, c = U(o, s) || w.current.initialViewportSize || 0, l = E.current, u = I(Math.max(0, Math.trunc(Number(i)) || 0), a, l), d = Math.max(0, Math.min(e, Math.max(0, u - c))), f = z(o);
|
|
655
789
|
if (!f) return;
|
|
656
790
|
let p = { behavior: t?.smooth === !0 ? "smooth" : "auto" };
|
|
657
791
|
s ? p.left = d : p.top = d, f.scrollTo(p);
|
|
658
792
|
}, []);
|
|
659
793
|
return {
|
|
660
794
|
virtualItems: Y,
|
|
661
|
-
totalSize:
|
|
662
|
-
isScrolling:
|
|
795
|
+
totalSize: H,
|
|
796
|
+
isScrolling: k,
|
|
663
797
|
scrollToIndex: n((e, t) => {
|
|
664
|
-
let { getScrollElement: n, count: r, estimateSize: i, horizontal: a, reverse: o } =
|
|
798
|
+
let { getScrollElement: n, count: r, estimateSize: i, horizontal: a, reverse: o } = w.current, s = n();
|
|
665
799
|
if (!s) return;
|
|
666
800
|
let c = Math.max(0, Math.trunc(Number(r)) || 0);
|
|
667
801
|
if (c === 0) return;
|
|
668
|
-
let l = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, c - 1)), u = t?.align ?? "auto", d = a ?? !1, f = o ?? !1, p =
|
|
802
|
+
let l = Math.max(0, Math.min(Math.trunc(Number(e)) || 0, c - 1)), u = t?.align ?? "auto", d = a ?? !1, f = o ?? !1, p = E.current, m = K(l, u, U(s, d) || w.current.initialViewportSize || 0, I(c, i, p), W(s, d), i, f, p), h = z(s);
|
|
669
803
|
if (!h) return;
|
|
670
804
|
let g = { behavior: t?.smooth === !0 ? "smooth" : "auto" };
|
|
671
805
|
d ? g.left = m : g.top = m, h.scrollTo(g);
|
|
@@ -674,4 +808,4 @@ function M(c) {
|
|
|
674
808
|
};
|
|
675
809
|
}
|
|
676
810
|
//#endregion
|
|
677
|
-
export {
|
|
811
|
+
export { O as a, S as c, g as d, m as f, A as i, b as l, l as m, H as n, E as o, d as p, M as r, w as s, q as t, v as u };
|