@aiquants/virtualscroll 0.2.1 → 0.2.2
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.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +387 -386
- package/dist/index.js.map +1 -1
- package/dist/src/VirtualScroll.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ge, { useState as X, useRef as Y, useEffect as B, forwardRef as de, useReducer as be, useMemo as ne, useCallback as L, useLayoutEffect as oe, useImperativeHandle as he, useId as ve } from "react";
|
|
2
2
|
import { twMerge as ae } from "tailwind-merge";
|
|
3
|
-
var re = { exports: {} },
|
|
3
|
+
var re = { exports: {} }, ee = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* react-jsx-runtime.production.js
|
|
@@ -12,10 +12,10 @@ var re = { exports: {} }, K = {};
|
|
|
12
12
|
*/
|
|
13
13
|
var ie;
|
|
14
14
|
function xe() {
|
|
15
|
-
if (ie) return
|
|
15
|
+
if (ie) return ee;
|
|
16
16
|
ie = 1;
|
|
17
|
-
var
|
|
18
|
-
function
|
|
17
|
+
var l = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
18
|
+
function r(t, s, a) {
|
|
19
19
|
var o = null;
|
|
20
20
|
if (a !== void 0 && (o = "" + a), s.key !== void 0 && (o = "" + s.key), "key" in s) {
|
|
21
21
|
a = {};
|
|
@@ -23,16 +23,16 @@ function xe() {
|
|
|
23
23
|
d !== "key" && (a[d] = s[d]);
|
|
24
24
|
} else a = s;
|
|
25
25
|
return s = a.ref, {
|
|
26
|
-
$$typeof:
|
|
26
|
+
$$typeof: l,
|
|
27
27
|
type: t,
|
|
28
28
|
key: o,
|
|
29
29
|
ref: s !== void 0 ? s : null,
|
|
30
30
|
props: a
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return ee.Fragment = e, ee.jsx = r, ee.jsxs = r, ee;
|
|
34
34
|
}
|
|
35
|
-
var
|
|
35
|
+
var te = {};
|
|
36
36
|
/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-jsx-runtime.development.js
|
|
@@ -43,295 +43,295 @@ var ee = {};
|
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
44
|
*/
|
|
45
45
|
var le;
|
|
46
|
-
function
|
|
46
|
+
function pe() {
|
|
47
47
|
return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
50
|
-
if (typeof
|
|
51
|
-
return
|
|
52
|
-
if (typeof
|
|
53
|
-
switch (
|
|
54
|
-
case
|
|
48
|
+
function l(n) {
|
|
49
|
+
if (n == null) return null;
|
|
50
|
+
if (typeof n == "function")
|
|
51
|
+
return n.$$typeof === H ? null : n.displayName || n.name || null;
|
|
52
|
+
if (typeof n == "string") return n;
|
|
53
|
+
switch (n) {
|
|
54
|
+
case j:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case I:
|
|
57
57
|
return "Profiler";
|
|
58
58
|
case b:
|
|
59
59
|
return "StrictMode";
|
|
60
|
-
case
|
|
60
|
+
case V:
|
|
61
61
|
return "Suspense";
|
|
62
|
-
case
|
|
62
|
+
case C:
|
|
63
63
|
return "SuspenseList";
|
|
64
|
-
case
|
|
64
|
+
case J:
|
|
65
65
|
return "Activity";
|
|
66
66
|
}
|
|
67
|
-
if (typeof
|
|
68
|
-
switch (typeof
|
|
67
|
+
if (typeof n == "object")
|
|
68
|
+
switch (typeof n.tag == "number" && console.error(
|
|
69
69
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
-
),
|
|
70
|
+
), n.$$typeof) {
|
|
71
71
|
case S:
|
|
72
72
|
return "Portal";
|
|
73
73
|
case f:
|
|
74
|
-
return (
|
|
74
|
+
return (n.displayName || "Context") + ".Provider";
|
|
75
75
|
case k:
|
|
76
|
-
return (
|
|
76
|
+
return (n._context.displayName || "Context") + ".Consumer";
|
|
77
77
|
case P:
|
|
78
|
-
var
|
|
79
|
-
return
|
|
80
|
-
case
|
|
81
|
-
return
|
|
78
|
+
var u = n.render;
|
|
79
|
+
return n = n.displayName, n || (n = u.displayName || u.name || "", n = n !== "" ? "ForwardRef(" + n + ")" : "ForwardRef"), n;
|
|
80
|
+
case $:
|
|
81
|
+
return u = n.displayName || null, u !== null ? u : l(n.type) || "Memo";
|
|
82
82
|
case w:
|
|
83
|
-
|
|
83
|
+
u = n._payload, n = n._init;
|
|
84
84
|
try {
|
|
85
|
-
return
|
|
85
|
+
return l(n(u));
|
|
86
86
|
} catch {
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
-
function e(
|
|
92
|
-
return "" +
|
|
91
|
+
function e(n) {
|
|
92
|
+
return "" + n;
|
|
93
93
|
}
|
|
94
|
-
function n
|
|
94
|
+
function r(n) {
|
|
95
95
|
try {
|
|
96
|
-
e(
|
|
97
|
-
var
|
|
96
|
+
e(n);
|
|
97
|
+
var u = !1;
|
|
98
98
|
} catch {
|
|
99
|
-
|
|
99
|
+
u = !0;
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
var h =
|
|
101
|
+
if (u) {
|
|
102
|
+
u = console;
|
|
103
|
+
var h = u.error, x = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
|
|
104
104
|
return h.call(
|
|
105
|
-
|
|
105
|
+
u,
|
|
106
106
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
107
|
-
|
|
108
|
-
), e(
|
|
107
|
+
x
|
|
108
|
+
), e(n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function t(
|
|
112
|
-
if (
|
|
113
|
-
if (typeof
|
|
111
|
+
function t(n) {
|
|
112
|
+
if (n === j) return "<>";
|
|
113
|
+
if (typeof n == "object" && n !== null && n.$$typeof === w)
|
|
114
114
|
return "<...>";
|
|
115
115
|
try {
|
|
116
|
-
var
|
|
117
|
-
return
|
|
116
|
+
var u = l(n);
|
|
117
|
+
return u ? "<" + u + ">" : "<...>";
|
|
118
118
|
} catch {
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function s() {
|
|
123
|
-
var
|
|
124
|
-
return
|
|
123
|
+
var n = U.A;
|
|
124
|
+
return n === null ? null : n.getOwner();
|
|
125
125
|
}
|
|
126
126
|
function a() {
|
|
127
127
|
return Error("react-stack-top-frame");
|
|
128
128
|
}
|
|
129
|
-
function o(
|
|
130
|
-
if (Z.call(
|
|
131
|
-
var
|
|
132
|
-
if (
|
|
129
|
+
function o(n) {
|
|
130
|
+
if (Z.call(n, "key")) {
|
|
131
|
+
var u = Object.getOwnPropertyDescriptor(n, "key").get;
|
|
132
|
+
if (u && u.isReactWarning) return !1;
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return n.key !== void 0;
|
|
135
135
|
}
|
|
136
|
-
function d(
|
|
136
|
+
function d(n, u) {
|
|
137
137
|
function h() {
|
|
138
|
-
|
|
138
|
+
g || (g = !0, console.error(
|
|
139
139
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
140
|
-
|
|
140
|
+
u
|
|
141
141
|
));
|
|
142
142
|
}
|
|
143
|
-
h.isReactWarning = !0, Object.defineProperty(
|
|
143
|
+
h.isReactWarning = !0, Object.defineProperty(n, "key", {
|
|
144
144
|
get: h,
|
|
145
145
|
configurable: !0
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
var
|
|
150
|
-
return
|
|
148
|
+
function i() {
|
|
149
|
+
var n = l(this.type);
|
|
150
|
+
return E[n] || (E[n] = !0, console.error(
|
|
151
151
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
152
|
-
)),
|
|
152
|
+
)), n = this.props.ref, n !== void 0 ? n : null;
|
|
153
153
|
}
|
|
154
|
-
function c(
|
|
155
|
-
return h = T.ref,
|
|
156
|
-
$$typeof:
|
|
157
|
-
type:
|
|
158
|
-
key:
|
|
154
|
+
function c(n, u, h, x, z, T, q, G) {
|
|
155
|
+
return h = T.ref, n = {
|
|
156
|
+
$$typeof: p,
|
|
157
|
+
type: n,
|
|
158
|
+
key: u,
|
|
159
159
|
props: T,
|
|
160
|
-
_owner:
|
|
161
|
-
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(
|
|
160
|
+
_owner: z
|
|
161
|
+
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(n, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
|
-
get:
|
|
164
|
-
}) : Object.defineProperty(
|
|
163
|
+
get: i
|
|
164
|
+
}) : Object.defineProperty(n, "ref", { enumerable: !1, value: null }), n._store = {}, Object.defineProperty(n._store, "validated", {
|
|
165
165
|
configurable: !1,
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
writable: !0,
|
|
168
168
|
value: 0
|
|
169
|
-
}), Object.defineProperty(
|
|
169
|
+
}), Object.defineProperty(n, "_debugInfo", {
|
|
170
170
|
configurable: !1,
|
|
171
171
|
enumerable: !1,
|
|
172
172
|
writable: !0,
|
|
173
173
|
value: null
|
|
174
|
-
}), Object.defineProperty(
|
|
174
|
+
}), Object.defineProperty(n, "_debugStack", {
|
|
175
175
|
configurable: !1,
|
|
176
176
|
enumerable: !1,
|
|
177
177
|
writable: !0,
|
|
178
|
-
value:
|
|
179
|
-
}), Object.defineProperty(
|
|
178
|
+
value: q
|
|
179
|
+
}), Object.defineProperty(n, "_debugTask", {
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
184
|
-
}), Object.freeze && (Object.freeze(
|
|
183
|
+
value: G
|
|
184
|
+
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
185
185
|
}
|
|
186
|
-
function m(
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
186
|
+
function m(n, u, h, x, z, T, q, G) {
|
|
187
|
+
var R = u.children;
|
|
188
|
+
if (R !== void 0)
|
|
189
|
+
if (x)
|
|
190
|
+
if (F(R)) {
|
|
191
|
+
for (x = 0; x < R.length; x++)
|
|
192
|
+
v(R[x]);
|
|
193
|
+
Object.freeze && Object.freeze(R);
|
|
194
194
|
} else
|
|
195
195
|
console.error(
|
|
196
196
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
197
|
);
|
|
198
|
-
else
|
|
199
|
-
if (Z.call(
|
|
200
|
-
|
|
201
|
-
var
|
|
198
|
+
else v(R);
|
|
199
|
+
if (Z.call(u, "key")) {
|
|
200
|
+
R = l(n);
|
|
201
|
+
var W = Object.keys(u).filter(function(se) {
|
|
202
202
|
return se !== "key";
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
x = 0 < W.length ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}", M[R + x] || (W = 0 < W.length ? "{" + W.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
205
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
206
|
let props = %s;
|
|
207
207
|
<%s {...props} />
|
|
208
208
|
React keys must be passed directly to JSX without using spread:
|
|
209
209
|
let props = %s;
|
|
210
210
|
<%s key={someKey} {...props} />`,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
),
|
|
211
|
+
x,
|
|
212
|
+
R,
|
|
213
|
+
W,
|
|
214
|
+
R
|
|
215
|
+
), M[R + x] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (R = null, h !== void 0 && (r(h), R = "" + h), o(u) && (r(u.key), R = "" + u.key), "key" in u) {
|
|
218
218
|
h = {};
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
} else h =
|
|
222
|
-
return
|
|
219
|
+
for (var K in u)
|
|
220
|
+
K !== "key" && (h[K] = u[K]);
|
|
221
|
+
} else h = u;
|
|
222
|
+
return R && d(
|
|
223
223
|
h,
|
|
224
|
-
typeof
|
|
224
|
+
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
225
225
|
), c(
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
n,
|
|
227
|
+
R,
|
|
228
228
|
T,
|
|
229
|
-
|
|
229
|
+
z,
|
|
230
230
|
s(),
|
|
231
231
|
h,
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
q,
|
|
233
|
+
G
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
typeof
|
|
236
|
+
function v(n) {
|
|
237
|
+
typeof n == "object" && n !== null && n.$$typeof === p && n._store && (n._store.validated = 1);
|
|
238
238
|
}
|
|
239
|
-
var _ =
|
|
239
|
+
var _ = ge, p = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), j = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), I = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), f = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), V = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), J = Symbol.for("react.activity"), H = Symbol.for("react.client.reference"), U = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, F = Array.isArray, Q = console.createTask ? console.createTask : function() {
|
|
240
240
|
return null;
|
|
241
241
|
};
|
|
242
242
|
_ = {
|
|
243
|
-
react_stack_bottom_frame: function(
|
|
244
|
-
return
|
|
243
|
+
react_stack_bottom_frame: function(n) {
|
|
244
|
+
return n();
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
|
-
var
|
|
247
|
+
var g, E = {}, y = _.react_stack_bottom_frame.bind(
|
|
248
248
|
_,
|
|
249
249
|
a
|
|
250
|
-
)(),
|
|
251
|
-
|
|
252
|
-
var T = 1e4 >
|
|
250
|
+
)(), O = Q(t(a)), M = {};
|
|
251
|
+
te.Fragment = j, te.jsx = function(n, u, h, x, z) {
|
|
252
|
+
var T = 1e4 > U.recentlyCreatedOwnerStacks++;
|
|
253
253
|
return m(
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
n,
|
|
255
|
+
u,
|
|
256
256
|
h,
|
|
257
257
|
!1,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
T ? Error("react-stack-top-frame") :
|
|
261
|
-
T ?
|
|
258
|
+
x,
|
|
259
|
+
z,
|
|
260
|
+
T ? Error("react-stack-top-frame") : y,
|
|
261
|
+
T ? Q(t(n)) : O
|
|
262
262
|
);
|
|
263
|
-
},
|
|
264
|
-
var T = 1e4 >
|
|
263
|
+
}, te.jsxs = function(n, u, h, x, z) {
|
|
264
|
+
var T = 1e4 > U.recentlyCreatedOwnerStacks++;
|
|
265
265
|
return m(
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
n,
|
|
267
|
+
u,
|
|
268
268
|
h,
|
|
269
269
|
!0,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
T ? Error("react-stack-top-frame") :
|
|
273
|
-
T ?
|
|
270
|
+
x,
|
|
271
|
+
z,
|
|
272
|
+
T ? Error("react-stack-top-frame") : y,
|
|
273
|
+
T ? Q(t(n)) : O
|
|
274
274
|
);
|
|
275
275
|
};
|
|
276
|
-
})()),
|
|
276
|
+
})()), te;
|
|
277
277
|
}
|
|
278
278
|
var ue;
|
|
279
|
-
function
|
|
280
|
-
return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports =
|
|
279
|
+
function Te() {
|
|
280
|
+
return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = pe()), re.exports;
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
const
|
|
284
|
-
debug(
|
|
285
|
-
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${
|
|
282
|
+
var D = Te();
|
|
283
|
+
const N = {
|
|
284
|
+
debug(l, ...e) {
|
|
285
|
+
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${l}`, ...e);
|
|
286
286
|
},
|
|
287
|
-
warn(
|
|
288
|
-
console.warn(`[VirtualScroll] ${
|
|
287
|
+
warn(l, ...e) {
|
|
288
|
+
console.warn(`[VirtualScroll] ${l}`, ...e);
|
|
289
289
|
},
|
|
290
|
-
error(
|
|
291
|
-
console.error(`[VirtualScroll] ${
|
|
290
|
+
error(l, ...e) {
|
|
291
|
+
console.error(`[VirtualScroll] ${l}`, ...e);
|
|
292
292
|
}
|
|
293
|
-
},
|
|
294
|
-
const t = "touches" in
|
|
293
|
+
}, A = (l, e, r) => Math.min(r, Math.max(e, l)), ce = (l, e, r) => {
|
|
294
|
+
const t = "touches" in l.nativeEvent, s = t ? l.nativeEvent.touches[0] : l.nativeEvent, a = (d) => {
|
|
295
295
|
t && d.cancelable && d.preventDefault();
|
|
296
|
-
const
|
|
296
|
+
const i = "touches" in d ? d.touches[0] : d;
|
|
297
297
|
e({
|
|
298
|
-
deltaX:
|
|
299
|
-
deltaY:
|
|
298
|
+
deltaX: i.clientX - s.clientX,
|
|
299
|
+
deltaY: i.clientY - s.clientY
|
|
300
300
|
});
|
|
301
301
|
}, o = () => {
|
|
302
|
-
t ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)),
|
|
302
|
+
t ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)), r?.();
|
|
303
303
|
};
|
|
304
304
|
t ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
|
|
305
|
-
},
|
|
306
|
-
const [
|
|
305
|
+
}, Ee = 20, _e = ({ contentSize: l, viewportSize: e, scrollPosition: r, onScroll: t, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
|
|
306
|
+
const [i, c] = X(!1), m = Y(null), v = e / l, _ = Math.max(Ee, v * e), p = l - e, S = r / p * (e - _), j = l > e;
|
|
307
307
|
B(() => {
|
|
308
|
-
m.current && (
|
|
309
|
-
}, [
|
|
310
|
-
const b = (f) =>
|
|
311
|
-
if (!
|
|
308
|
+
m.current && (i ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
|
|
309
|
+
}, [i]);
|
|
310
|
+
const b = (f) => A(f / (e - _) * p, 0, p), I = (f) => {
|
|
311
|
+
if (!j || "button" in f && f.button !== 0 || f.ctrlKey)
|
|
312
312
|
return;
|
|
313
313
|
f.stopPropagation();
|
|
314
314
|
const P = S;
|
|
315
315
|
c(!0), ce(
|
|
316
316
|
f,
|
|
317
|
-
({ deltaX:
|
|
318
|
-
t?.(b(P + (s ?
|
|
317
|
+
({ deltaX: V, deltaY: C }) => {
|
|
318
|
+
t?.(b(P + (s ? V : C)), S);
|
|
319
319
|
},
|
|
320
320
|
() => {
|
|
321
321
|
c(!1);
|
|
322
322
|
}
|
|
323
323
|
);
|
|
324
324
|
}, k = (f) => {
|
|
325
|
-
if (!
|
|
325
|
+
if (!j || "button" in f && f.button !== 0 || f.ctrlKey)
|
|
326
326
|
return;
|
|
327
|
-
const
|
|
328
|
-
t?.(b(
|
|
329
|
-
t?.(b(
|
|
327
|
+
const V = "touches" in f.nativeEvent ? f.nativeEvent.touches[0] : f.nativeEvent, C = s ? V.clientX : V.clientY, $ = f.currentTarget.getBoundingClientRect(), J = (s ? C - $.left : C - $.top) - _ / 2;
|
|
328
|
+
t?.(b(J), S), ce(f, ({ deltaX: H, deltaY: U }) => {
|
|
329
|
+
t?.(b(J + (s ? H : U)), S);
|
|
330
330
|
});
|
|
331
331
|
};
|
|
332
332
|
return (
|
|
333
333
|
// スクロールバーのコンテナ
|
|
334
|
-
/* @__PURE__ */
|
|
334
|
+
/* @__PURE__ */ D.jsx(
|
|
335
335
|
"div",
|
|
336
336
|
{
|
|
337
337
|
className: ae("group relative cursor-default select-none", o),
|
|
@@ -346,12 +346,12 @@ const j = {
|
|
|
346
346
|
role: "scrollbar",
|
|
347
347
|
tabIndex: -1,
|
|
348
348
|
"aria-controls": d,
|
|
349
|
-
"aria-valuenow":
|
|
349
|
+
"aria-valuenow": r,
|
|
350
350
|
"aria-valuemin": 0,
|
|
351
|
-
"aria-valuemax":
|
|
351
|
+
"aria-valuemax": p,
|
|
352
352
|
"aria-orientation": s ? "horizontal" : "vertical",
|
|
353
|
-
children:
|
|
354
|
-
/* @__PURE__ */
|
|
353
|
+
children: l > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
|
|
354
|
+
/* @__PURE__ */ D.jsx(
|
|
355
355
|
"div",
|
|
356
356
|
{
|
|
357
357
|
className: "group absolute",
|
|
@@ -361,21 +361,21 @@ const j = {
|
|
|
361
361
|
// 当たり判定を上下または左右に広げる
|
|
362
362
|
...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
363
363
|
},
|
|
364
|
-
onMouseDown:
|
|
365
|
-
onTouchStart:
|
|
364
|
+
onMouseDown: I,
|
|
365
|
+
onTouchStart: I,
|
|
366
366
|
role: "slider",
|
|
367
367
|
"aria-orientation": s ? "horizontal" : "vertical",
|
|
368
|
-
"aria-valuenow":
|
|
368
|
+
"aria-valuenow": r,
|
|
369
369
|
"aria-valuemin": 0,
|
|
370
|
-
"aria-valuemax":
|
|
370
|
+
"aria-valuemax": p,
|
|
371
371
|
tabIndex: 0,
|
|
372
|
-
children: /* @__PURE__ */
|
|
372
|
+
children: /* @__PURE__ */ D.jsx(
|
|
373
373
|
"div",
|
|
374
374
|
{
|
|
375
375
|
ref: m,
|
|
376
376
|
className: ae(
|
|
377
377
|
"absolute",
|
|
378
|
-
s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${
|
|
378
|
+
s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${i ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${i ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
|
|
379
379
|
),
|
|
380
380
|
style: {
|
|
381
381
|
backgroundColor: "#7F7F7F",
|
|
@@ -384,20 +384,20 @@ const j = {
|
|
|
384
384
|
...s ? {
|
|
385
385
|
left: 0,
|
|
386
386
|
right: 0,
|
|
387
|
-
top:
|
|
388
|
-
bottom:
|
|
387
|
+
top: i ? -2 : 1.5,
|
|
388
|
+
bottom: i ? -2 : 1.5
|
|
389
389
|
} : {
|
|
390
390
|
top: 0,
|
|
391
391
|
bottom: 0,
|
|
392
|
-
left:
|
|
393
|
-
right:
|
|
392
|
+
left: i ? -2 : 1.5,
|
|
393
|
+
right: i ? -2 : 1.5
|
|
394
394
|
}
|
|
395
395
|
},
|
|
396
396
|
onMouseEnter: (f) => {
|
|
397
|
-
s ? (f.currentTarget.style.top = "-0.5px", f.currentTarget.style.bottom = "-0.5px") : (f.currentTarget.style.left = "-0.5px", f.currentTarget.style.right = "-0.5px"),
|
|
397
|
+
s ? (f.currentTarget.style.top = "-0.5px", f.currentTarget.style.bottom = "-0.5px") : (f.currentTarget.style.left = "-0.5px", f.currentTarget.style.right = "-0.5px"), i || (f.currentTarget.style.backgroundColor = "#5F5F5F");
|
|
398
398
|
},
|
|
399
399
|
onMouseLeave: (f) => {
|
|
400
|
-
s ? (f.currentTarget.style.top =
|
|
400
|
+
s ? (f.currentTarget.style.top = i ? "-2px" : "1.5px", f.currentTarget.style.bottom = i ? "-2px" : "1.5px") : (f.currentTarget.style.left = i ? "-2px" : "1.5px", f.currentTarget.style.right = i ? "-2px" : "1.5px"), i || (f.currentTarget.style.backgroundColor = "#7F7F7F");
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
)
|
|
@@ -406,59 +406,59 @@ const j = {
|
|
|
406
406
|
}
|
|
407
407
|
)
|
|
408
408
|
);
|
|
409
|
-
}, Ie = de(({ children:
|
|
410
|
-
const c =
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
(
|
|
414
|
-
const k = e >
|
|
415
|
-
if (
|
|
409
|
+
}, Ie = de(({ children: l, contentSize: e, viewportSize: r, scrollBarWidth: t = 12, onScroll: s, className: a, style: o, background: d }, i) => {
|
|
410
|
+
const c = Y(0), [m, v] = be((I) => I + 1, 0), _ = Y(null);
|
|
411
|
+
N.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: r, scrollBarWidth: t, className: a, style: o });
|
|
412
|
+
const p = ne(() => e > r, [e, r]), S = L(
|
|
413
|
+
(I) => {
|
|
414
|
+
const k = e > r, f = c.current;
|
|
415
|
+
if (N.debug("[ScrollPane] scrollTo called", { newPosition: I, contentSize: e, viewportSize: r, currentIsScrollable: k, prevPosition: f }), !k) {
|
|
416
416
|
c.current !== 0 && (c.current = 0, s?.(0, f));
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
const P = typeof
|
|
420
|
-
c.current !==
|
|
419
|
+
const P = typeof I == "function" ? I(c.current) : I, V = A(P, 0, e - r);
|
|
420
|
+
c.current !== V && (c.current = V, s?.(V, f));
|
|
421
421
|
},
|
|
422
|
-
[s, e,
|
|
422
|
+
[s, e, r]
|
|
423
423
|
);
|
|
424
424
|
oe(() => {
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
c.current >
|
|
425
|
+
if (p) {
|
|
426
|
+
N.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: r, scrollPosition: c.current });
|
|
427
|
+
const I = A(e - r, 0, e);
|
|
428
|
+
c.current > I && S(I);
|
|
429
429
|
} else
|
|
430
430
|
S(0);
|
|
431
|
-
}, [
|
|
432
|
-
const
|
|
433
|
-
if (!
|
|
431
|
+
}, [p, S, e, r]), B(() => {
|
|
432
|
+
const I = (f) => {
|
|
433
|
+
if (!p)
|
|
434
434
|
return;
|
|
435
435
|
f.preventDefault();
|
|
436
436
|
let P = f.deltaY;
|
|
437
|
-
f.deltaMode === 1 ? P *= 16 : f.deltaMode === 2 && (P *=
|
|
437
|
+
f.deltaMode === 1 ? P *= 16 : f.deltaMode === 2 && (P *= r), N.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: c.current }), S((V) => V + P);
|
|
438
438
|
}, k = _.current;
|
|
439
|
-
return k && k.addEventListener("wheel",
|
|
440
|
-
k && k.removeEventListener("wheel",
|
|
439
|
+
return k && k.addEventListener("wheel", I, { passive: !1 }), () => {
|
|
440
|
+
k && k.removeEventListener("wheel", I);
|
|
441
441
|
};
|
|
442
|
-
}, [
|
|
443
|
-
|
|
442
|
+
}, [p, S, r]), he(
|
|
443
|
+
i,
|
|
444
444
|
() => ({
|
|
445
445
|
scrollTo: S,
|
|
446
446
|
getScrollPosition: () => c.current,
|
|
447
447
|
getContentSize: () => e,
|
|
448
|
-
getViewportSize: () =>
|
|
448
|
+
getViewportSize: () => r
|
|
449
449
|
}),
|
|
450
|
-
[S, e,
|
|
450
|
+
[S, e, r]
|
|
451
451
|
);
|
|
452
|
-
const
|
|
453
|
-
return ne(() => /* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
452
|
+
const j = ve();
|
|
453
|
+
return ne(() => /* @__PURE__ */ D.jsxs("div", { ref: _, className: ae("flex", a), style: o, children: [
|
|
454
|
+
/* @__PURE__ */ D.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: r }, id: j, children: [
|
|
455
455
|
d,
|
|
456
|
-
|
|
456
|
+
l(c.current)
|
|
457
457
|
] }),
|
|
458
|
-
|
|
459
|
-
] }), [
|
|
458
|
+
p && /* @__PURE__ */ D.jsx(_e, { contentSize: e, viewportSize: r, scrollPosition: c.current, onScroll: S, scrollBarWidth: t, ariaControls: j })
|
|
459
|
+
] }), [l, e, r, t, a, o, p, S, j, d]);
|
|
460
460
|
});
|
|
461
|
-
class
|
|
461
|
+
class Re {
|
|
462
462
|
/**
|
|
463
463
|
* @private
|
|
464
464
|
* @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
|
|
@@ -498,8 +498,8 @@ class Se {
|
|
|
498
498
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
499
499
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
500
500
|
*/
|
|
501
|
-
constructor(e,
|
|
502
|
-
this.reset(e,
|
|
501
|
+
constructor(e, r, t) {
|
|
502
|
+
this.reset(e, r, t);
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* @method reset
|
|
@@ -509,26 +509,26 @@ class Se {
|
|
|
509
509
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
510
510
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
511
511
|
*/
|
|
512
|
-
reset(e,
|
|
513
|
-
if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof
|
|
514
|
-
if (this.valueFn =
|
|
512
|
+
reset(e, r, t) {
|
|
513
|
+
if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof r == "function") {
|
|
514
|
+
if (this.valueFn = r, this.size > 0) {
|
|
515
515
|
const a = t?.sampleRange ?? {
|
|
516
516
|
from: 0,
|
|
517
517
|
to: Math.min(99, this.size - 1)
|
|
518
518
|
}, { mode: o, materializedValues: d } = this._calculateMode(a.from, a.to);
|
|
519
519
|
if (this.baseValue = o, t?.materialize)
|
|
520
|
-
for (let
|
|
521
|
-
const c = d[
|
|
520
|
+
for (let i = 0; i < d.length; i++) {
|
|
521
|
+
const c = d[i], m = a.from + i;
|
|
522
522
|
if (m >= this.size)
|
|
523
523
|
break;
|
|
524
|
-
const
|
|
525
|
-
this.deltas.set(m,
|
|
524
|
+
const v = c - this.baseValue;
|
|
525
|
+
this.deltas.set(m, v), this._updateTree(m, v);
|
|
526
526
|
}
|
|
527
527
|
} else
|
|
528
528
|
this.baseValue = 0;
|
|
529
529
|
this.total = this.getTotal();
|
|
530
530
|
} else
|
|
531
|
-
this.valueFn = void 0, this.baseValue =
|
|
531
|
+
this.valueFn = void 0, this.baseValue = r, this.total = this.baseValue * this.size;
|
|
532
532
|
}
|
|
533
533
|
/**
|
|
534
534
|
* @method setValueFn
|
|
@@ -548,11 +548,11 @@ class Se {
|
|
|
548
548
|
* @param {number} to - The ending index of the range (inclusive).
|
|
549
549
|
* @returns {{ mode: number; materializedValues: number[] }} An object containing the calculated mode and the array of generated values.
|
|
550
550
|
*/
|
|
551
|
-
_calculateMode(e,
|
|
551
|
+
_calculateMode(e, r) {
|
|
552
552
|
if (!this.valueFn)
|
|
553
553
|
return { mode: 0, materializedValues: [] };
|
|
554
554
|
const t = [];
|
|
555
|
-
for (let c = e; c <=
|
|
555
|
+
for (let c = e; c <= r && !(c >= this.size); c++)
|
|
556
556
|
t.push(this.valueFn(c));
|
|
557
557
|
const s = [...t];
|
|
558
558
|
if (t.length === 0)
|
|
@@ -562,16 +562,16 @@ class Se {
|
|
|
562
562
|
let o;
|
|
563
563
|
t.length % 2 === 0 ? o = Math.floor((t[a - 1] + t[a]) / 2) : o = t[a];
|
|
564
564
|
const d = /* @__PURE__ */ new Map();
|
|
565
|
-
let
|
|
565
|
+
let i = 0;
|
|
566
566
|
for (const c of t) {
|
|
567
567
|
const m = (d.get(c) ?? 0) + 1;
|
|
568
|
-
d.set(c, m), m >
|
|
568
|
+
d.set(c, m), m > i && (i = m);
|
|
569
569
|
}
|
|
570
|
-
if (
|
|
570
|
+
if (i > 1) {
|
|
571
571
|
const c = [];
|
|
572
|
-
for (const [
|
|
573
|
-
_ ===
|
|
574
|
-
const m = c.reduce((
|
|
572
|
+
for (const [v, _] of d.entries())
|
|
573
|
+
_ === i && c.push(v);
|
|
574
|
+
const m = c.reduce((v, _) => v + _, 0);
|
|
575
575
|
o = Math.floor(m / c.length);
|
|
576
576
|
}
|
|
577
577
|
return { mode: o, materializedValues: s };
|
|
@@ -583,8 +583,8 @@ class Se {
|
|
|
583
583
|
* @param {number} index - The 0-based index to update.
|
|
584
584
|
* @param {number} value - The new value.
|
|
585
585
|
*/
|
|
586
|
-
update(e,
|
|
587
|
-
return this.updates([{ index: e, value:
|
|
586
|
+
update(e, r) {
|
|
587
|
+
return this.updates([{ index: e, value: r }]);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* @method updates
|
|
@@ -593,7 +593,7 @@ class Se {
|
|
|
593
593
|
* @param {{ index: number; value: number }[]} updates - An array of updates, each with an index and the new value.
|
|
594
594
|
*/
|
|
595
595
|
updates(e) {
|
|
596
|
-
const
|
|
596
|
+
const r = e.map(({ index: t, value: s }) => {
|
|
597
597
|
if (t < 0 || t >= this.size)
|
|
598
598
|
throw new Error(`Index ${t} out of bounds`);
|
|
599
599
|
if (s < 0)
|
|
@@ -601,7 +601,7 @@ class Se {
|
|
|
601
601
|
const a = this.deltas.has(t) ? (this.deltas.get(t) ?? 0) + this.baseValue : this.baseValue, o = s - a;
|
|
602
602
|
return { index: t, change: o };
|
|
603
603
|
}).filter((t) => t.change !== 0);
|
|
604
|
-
return
|
|
604
|
+
return r.length > 0 ? this.updateDeltas(r) : this.total;
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
607
|
* @method updateDelta
|
|
@@ -610,8 +610,8 @@ class Se {
|
|
|
610
610
|
* @param {number} index - The 0-based index to update.
|
|
611
611
|
* @param {number} change - The value to add to the delta at the given index.
|
|
612
612
|
*/
|
|
613
|
-
updateDelta(e,
|
|
614
|
-
return this.updateDeltas([{ index: e, change:
|
|
613
|
+
updateDelta(e, r) {
|
|
614
|
+
return this.updateDeltas([{ index: e, change: r }]);
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* @method updateDeltas
|
|
@@ -620,11 +620,11 @@ class Se {
|
|
|
620
620
|
* @param {{ index: number; change: number }[]} updates - An array of updates, each with an index and the change to apply.
|
|
621
621
|
*/
|
|
622
622
|
updateDeltas(e) {
|
|
623
|
-
for (const { index:
|
|
624
|
-
if (
|
|
625
|
-
throw new Error(`Index ${
|
|
626
|
-
const s = this.deltas.get(
|
|
627
|
-
this.deltas.set(
|
|
623
|
+
for (const { index: r, change: t } of e) {
|
|
624
|
+
if (r < 0 || r >= this.size)
|
|
625
|
+
throw new Error(`Index ${r} out of bounds`);
|
|
626
|
+
const s = this.deltas.get(r) ?? 0;
|
|
627
|
+
this.deltas.set(r, s + t), this._updateTree(r, t);
|
|
628
628
|
}
|
|
629
629
|
return this.total;
|
|
630
630
|
}
|
|
@@ -636,13 +636,13 @@ class Se {
|
|
|
636
636
|
* @param {number} index - The 0-based index that changed.
|
|
637
637
|
* @param {number} change - The change in value.
|
|
638
638
|
*/
|
|
639
|
-
_updateTree(e,
|
|
640
|
-
if (
|
|
639
|
+
_updateTree(e, r) {
|
|
640
|
+
if (r === 0)
|
|
641
641
|
return;
|
|
642
642
|
let t = e + 1;
|
|
643
643
|
for (; t <= this.size; )
|
|
644
|
-
this.tree.set(t, (this.tree.get(t) ?? 0) +
|
|
645
|
-
this.total !== void 0 && (this.total +=
|
|
644
|
+
this.tree.set(t, (this.tree.get(t) ?? 0) + r), t += t & -t;
|
|
645
|
+
this.total !== void 0 && (this.total += r);
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
648
648
|
* @private
|
|
@@ -652,10 +652,10 @@ class Se {
|
|
|
652
652
|
* @param {number} index - The 0-based index to materialize.
|
|
653
653
|
* @param {boolean} [updateTree=true] - Whether to update the Fenwick tree after materialization.
|
|
654
654
|
*/
|
|
655
|
-
_materialize(e,
|
|
655
|
+
_materialize(e, r = !0) {
|
|
656
656
|
if (this.valueFn) {
|
|
657
657
|
const t = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
|
|
658
|
-
if (a !== t && (this.deltas.set(e, a),
|
|
658
|
+
if (a !== t && (this.deltas.set(e, a), r)) {
|
|
659
659
|
const o = a - t;
|
|
660
660
|
this._updateTree(e, o);
|
|
661
661
|
}
|
|
@@ -674,23 +674,23 @@ class Se {
|
|
|
674
674
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
675
675
|
* @returns {{ cumulative: number; total: number | undefined; currentValue: number; safeIndex: number }} The cumulative sum of values from index 0 to the given index, the total sum, and the value at the given index.
|
|
676
676
|
*/
|
|
677
|
-
prefixSum(e,
|
|
677
|
+
prefixSum(e, r) {
|
|
678
678
|
if (e < 0)
|
|
679
679
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
680
|
-
const t =
|
|
680
|
+
const t = A(e, 0, this.size - 1), s = r?.materializeOption;
|
|
681
681
|
if (s?.materialize && this.valueFn) {
|
|
682
682
|
if (s.ranges)
|
|
683
|
-
for (const
|
|
684
|
-
const c =
|
|
685
|
-
for (let
|
|
686
|
-
this._materialize(
|
|
683
|
+
for (const i of s.ranges) {
|
|
684
|
+
const c = i.from, m = Math.min(i.to, this.size - 1);
|
|
685
|
+
for (let v = c; v <= m; v++)
|
|
686
|
+
this._materialize(v);
|
|
687
687
|
}
|
|
688
688
|
this._materialize(t);
|
|
689
689
|
}
|
|
690
690
|
let a = 0, o = t + 1;
|
|
691
691
|
for (; o > 0; ) {
|
|
692
|
-
const
|
|
693
|
-
a +=
|
|
692
|
+
const i = this.tree.get(o) ?? 0;
|
|
693
|
+
a += i, o -= o & -o;
|
|
694
694
|
}
|
|
695
695
|
const d = s?.materialize ? this.get(t) : (this.deltas.get(t) || 0) + this.baseValue;
|
|
696
696
|
return { cumulative: a + this.baseValue * (t + 1), total: this.total, currentValue: d, safeIndex: t };
|
|
@@ -708,10 +708,10 @@ class Se {
|
|
|
708
708
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
709
709
|
* @returns {number} The value at the given index.
|
|
710
710
|
*/
|
|
711
|
-
get(e,
|
|
711
|
+
get(e, r) {
|
|
712
712
|
if (e < 0 || e >= this.size)
|
|
713
713
|
throw new Error("Index out of bounds");
|
|
714
|
-
const t =
|
|
714
|
+
const t = r?.materializeOption;
|
|
715
715
|
if (t?.materialize && this.valueFn)
|
|
716
716
|
if (t.ranges) {
|
|
717
717
|
for (const s of t.ranges) {
|
|
@@ -737,9 +737,9 @@ class Se {
|
|
|
737
737
|
* @returns {number} The total sum of all values.
|
|
738
738
|
*/
|
|
739
739
|
getTotal(e) {
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
for (const t of
|
|
740
|
+
const r = e?.materializeOption;
|
|
741
|
+
if (r?.materialize && this.valueFn && r.ranges)
|
|
742
|
+
for (const t of r.ranges) {
|
|
743
743
|
const s = t.from, a = Math.min(t.to, this.size - 1);
|
|
744
744
|
for (let o = s; o <= a; o++)
|
|
745
745
|
this._materialize(o);
|
|
@@ -768,16 +768,16 @@ class Se {
|
|
|
768
768
|
this.reset(this.size, (a) => s(a), { materialize: !0 });
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
|
-
const
|
|
771
|
+
const r = /* @__PURE__ */ new Map();
|
|
772
772
|
let t = this.baseValue * this.size;
|
|
773
773
|
for (const [s, a] of this.deltas.entries()) {
|
|
774
774
|
if (t += a, a === 0)
|
|
775
775
|
continue;
|
|
776
776
|
let o = s + 1;
|
|
777
777
|
for (; o <= this.size; )
|
|
778
|
-
|
|
778
|
+
r.set(o, (r.get(o) ?? 0) + a), o += o & -o;
|
|
779
779
|
}
|
|
780
|
-
this.tree =
|
|
780
|
+
this.tree = r, this.total = t;
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
783
783
|
* @method calculateAccumulatedError
|
|
@@ -789,8 +789,8 @@ class Se {
|
|
|
789
789
|
if (this.total === void 0)
|
|
790
790
|
return 0;
|
|
791
791
|
let e = this.baseValue * this.size;
|
|
792
|
-
for (const
|
|
793
|
-
e +=
|
|
792
|
+
for (const r of this.deltas.values())
|
|
793
|
+
e += r;
|
|
794
794
|
return this.total - e;
|
|
795
795
|
}
|
|
796
796
|
/**
|
|
@@ -800,9 +800,9 @@ class Se {
|
|
|
800
800
|
* @param {number} newSize - The new size of the tree.
|
|
801
801
|
*/
|
|
802
802
|
changeSize(e) {
|
|
803
|
-
const
|
|
804
|
-
if (e !==
|
|
805
|
-
if (e <
|
|
803
|
+
const r = this.size;
|
|
804
|
+
if (e !== r) {
|
|
805
|
+
if (e < r)
|
|
806
806
|
for (const t of this.deltas.keys())
|
|
807
807
|
t >= e && this.deltas.delete(t);
|
|
808
808
|
this.size = e, this.rebuildTree(), console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
|
|
@@ -830,13 +830,13 @@ class Se {
|
|
|
830
830
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
831
831
|
* @returns {{ index: number, total: number | undefined, cumulative: number | undefined, currentValue: number | undefined, safeIndex: number | undefined }} The 0-based index and the total sum, or -1 if not found.
|
|
832
832
|
*/
|
|
833
|
-
findIndexAtOrAfter(e,
|
|
833
|
+
findIndexAtOrAfter(e, r) {
|
|
834
834
|
if (this.size === 0)
|
|
835
835
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
836
836
|
let t = 0, s = this.size - 1, a = -1, o, d = this.total;
|
|
837
837
|
for (; t <= s; ) {
|
|
838
|
-
const
|
|
839
|
-
o = this.prefixSum(
|
|
838
|
+
const i = Math.floor((t + s) / 2);
|
|
839
|
+
o = this.prefixSum(i, r), d = o.total, o.cumulative >= e ? (a = i, s = i - 1) : t = i + 1;
|
|
840
840
|
}
|
|
841
841
|
return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
|
|
842
842
|
}
|
|
@@ -853,157 +853,158 @@ class Se {
|
|
|
853
853
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
854
854
|
* @returns {{ index: number, total: number | undefined, cumulative: number | undefined, currentValue: number | undefined, safeIndex: number | undefined }} The 0-based index and the total sum, or -1 if not found.
|
|
855
855
|
*/
|
|
856
|
-
findIndexAtOrBefore(e,
|
|
856
|
+
findIndexAtOrBefore(e, r) {
|
|
857
857
|
if (this.size === 0)
|
|
858
858
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
859
859
|
let t = 0, s = this.size - 1, a = -1, o, d = this.total;
|
|
860
860
|
for (; t <= s; ) {
|
|
861
|
-
const
|
|
862
|
-
o = this.prefixSum(
|
|
861
|
+
const i = Math.floor((t + s) / 2);
|
|
862
|
+
o = this.prefixSum(i, r), d = o.total, o.cumulative <= e ? (a = i, t = i + 1) : s = i - 1;
|
|
863
863
|
}
|
|
864
864
|
return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
|
-
const
|
|
868
|
-
const t = Math.max(0,
|
|
867
|
+
const Se = (l, e, r) => {
|
|
868
|
+
const t = Math.max(0, l), s = Y(null), a = ne(() => new Re(t, e, r), [t, e, r]);
|
|
869
869
|
return Object.is(s.current, a) || console.warn("[useFenwickMapTree] instance changed"), s.current = a, a;
|
|
870
870
|
};
|
|
871
|
-
function
|
|
872
|
-
const
|
|
871
|
+
function ke({ itemCount: l, getItem: e, getItemHeight: r, viewportSize: t, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: i, background: c, initialScrollIndex: m, initialScrollOffset: v }, _) {
|
|
872
|
+
const p = Y(null), S = Y(!1);
|
|
873
873
|
B(() => (S.current = !0, () => {
|
|
874
874
|
S.current = !1;
|
|
875
875
|
}), []);
|
|
876
|
-
const
|
|
877
|
-
let g = 0,
|
|
876
|
+
const j = Y({ size: l, valueOrFn: r, options: { sampleRange: { from: 0, to: 100 } } }), b = Se(j.current.size, j.current.valueOrFn, j.current.options), [I] = X(() => {
|
|
877
|
+
let g = 0, E = 0;
|
|
878
878
|
if (typeof m == "number") {
|
|
879
|
-
const
|
|
880
|
-
g =
|
|
881
|
-
} else typeof
|
|
882
|
-
return { position: g, total:
|
|
883
|
-
}), [k, f] =
|
|
879
|
+
const y = A(m, 0, l - 1), O = A(y - s * 2, 0, l - 1), M = A(y + s * 2, 0, l - 1), n = m > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: O, to: M }] } } : void 0, { cumulative: u, total: h, currentValue: x } = b.prefixSum(m, n);
|
|
880
|
+
g = u - x, E = h ?? b.getTotal();
|
|
881
|
+
} else typeof v == "number" && (g = v), E = b.getTotal();
|
|
882
|
+
return { position: g, total: E };
|
|
883
|
+
}), [k, f] = X(I.position), [P, V] = X(I.total), [C, $] = X(I.position), [w, J] = X(l);
|
|
884
884
|
oe(() => {
|
|
885
|
-
b.setValueFn(
|
|
885
|
+
b.setValueFn(r), w !== l && (b.changeSize(l), J(l));
|
|
886
886
|
const g = b.getTotal();
|
|
887
|
-
P !== g &&
|
|
888
|
-
}, [b, w,
|
|
889
|
-
|
|
890
|
-
}, [
|
|
891
|
-
const
|
|
887
|
+
P !== g && V(g);
|
|
888
|
+
}, [b, w, l, P, r]), oe(() => {
|
|
889
|
+
C !== null && p.current && (N.debug("[VirtualScroll] Scrolling to position:", C), p.current.scrollTo(C), $(null));
|
|
890
|
+
}, [C]);
|
|
891
|
+
const H = L(
|
|
892
892
|
(g) => {
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
const
|
|
896
|
-
|
|
893
|
+
if (p.current) {
|
|
894
|
+
N.debug("[VirtualScroll] Scrolling to index:", g);
|
|
895
|
+
const E = A(g, 0, w - 1), y = A(E - s * 2, 0, w - 1), O = A(E + s * 2, 0, w - 1), { cumulative: M, total: n, currentValue: u } = b.prefixSum(E, { materializeOption: { materialize: !0, ranges: [{ from: y, to: O }] } });
|
|
896
|
+
N.debug("[VirtualScroll] Scrolling to index:", g, "Offset:", M, "Total height:", n, "Current value:", u, "safeIndex:", E, "safeIndexFrom:", y, "safeIndexTo:", O), n && (V(n), $(M - u)), N.debug("[VirtualScroll] Setting scroll position to:", M - u);
|
|
897
897
|
}
|
|
898
898
|
},
|
|
899
899
|
[b, s, w]
|
|
900
|
-
),
|
|
900
|
+
), U = L(
|
|
901
901
|
(g) => {
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
|
|
902
|
+
if (p.current) {
|
|
903
|
+
const E = b.getTotal(), y = A(Math.floor(g), 0, E), O = b.findIndexAtOrAfter(y, { materializeOption: { materialize: !1 } }).index;
|
|
904
|
+
H(O);
|
|
905
905
|
}
|
|
906
906
|
},
|
|
907
|
-
[b,
|
|
908
|
-
), Z =
|
|
909
|
-
(g,
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
o?.(g,
|
|
907
|
+
[b, H]
|
|
908
|
+
), Z = L(
|
|
909
|
+
(g, E) => {
|
|
910
|
+
N.debug("[VirtualScroll] Scroll position changed:", g), f(g);
|
|
911
|
+
const y = b.getTotal();
|
|
912
|
+
o?.(g, y);
|
|
913
913
|
},
|
|
914
914
|
[b, o]
|
|
915
|
-
),
|
|
915
|
+
), F = ne(() => {
|
|
916
916
|
if (w === 0)
|
|
917
917
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
918
|
-
const { index: g, cumulative:
|
|
919
|
-
let
|
|
920
|
-
g === -1 ?
|
|
921
|
-
const
|
|
922
|
-
let
|
|
923
|
-
for (;
|
|
924
|
-
const
|
|
925
|
-
|
|
918
|
+
const { index: g, cumulative: E, currentValue: y } = b.findIndexAtOrAfter(k, { materializeOption: { materialize: !1 } });
|
|
919
|
+
let O = 0;
|
|
920
|
+
g === -1 ? O = 0 : (E ?? 0) < k + (y ?? 0) ? O = 1 : O = 0;
|
|
921
|
+
const M = g === -1 ? 0 : g + O, n = A(M - s, 0, w - 1);
|
|
922
|
+
let u = 0, h = g === -1 ? 0 : g + O;
|
|
923
|
+
for (; h < w && u < t; ) {
|
|
924
|
+
const z = r(h);
|
|
925
|
+
u += z, h++;
|
|
926
926
|
}
|
|
927
|
-
|
|
928
|
-
const
|
|
929
|
-
return
|
|
930
|
-
renderingStartIndex:
|
|
931
|
-
renderingEndIndex:
|
|
932
|
-
visibleStartIndex:
|
|
933
|
-
visibleEndIndex:
|
|
927
|
+
h -= 1;
|
|
928
|
+
const x = A(h + s, 0, w - 1);
|
|
929
|
+
return N.debug("[VirtualScroll] Calculated rendering range:", {
|
|
930
|
+
renderingStartIndex: n,
|
|
931
|
+
renderingEndIndex: x,
|
|
932
|
+
visibleStartIndex: M,
|
|
933
|
+
visibleEndIndex: h,
|
|
934
934
|
scrollPosition: k,
|
|
935
935
|
renderingContentSize: b.getTotal(),
|
|
936
936
|
overscanCount: s,
|
|
937
937
|
viewportSize: t
|
|
938
|
-
}), { renderingStartIndex:
|
|
939
|
-
}, [k, s, t,
|
|
938
|
+
}), { renderingStartIndex: n, renderingEndIndex: x, visibleStartIndex: M, visibleEndIndex: h };
|
|
939
|
+
}, [k, s, t, r, b, w]);
|
|
940
940
|
B(() => {
|
|
941
|
-
const g =
|
|
942
|
-
|
|
943
|
-
renderingStartIndex:
|
|
944
|
-
renderingEndIndex:
|
|
945
|
-
visibleStartIndex:
|
|
946
|
-
visibleEndIndex:
|
|
941
|
+
const g = p.current?.getScrollPosition() ?? 0;
|
|
942
|
+
N.debug("[VirtualScroll] Range change effect triggered", {
|
|
943
|
+
renderingStartIndex: F.renderingStartIndex,
|
|
944
|
+
renderingEndIndex: F.renderingEndIndex,
|
|
945
|
+
visibleStartIndex: F.visibleStartIndex,
|
|
946
|
+
visibleEndIndex: F.visibleEndIndex,
|
|
947
947
|
scrollPosition: k,
|
|
948
948
|
contentSize: P,
|
|
949
949
|
scrollPaneScrollPosition: g
|
|
950
|
-
}), d?.(
|
|
951
|
-
}, [
|
|
952
|
-
const
|
|
950
|
+
}), d?.(F.renderingStartIndex, F.renderingEndIndex, F.visibleStartIndex, F.visibleEndIndex, k, P);
|
|
951
|
+
}, [F.renderingStartIndex, F.renderingEndIndex, F.visibleStartIndex, F.visibleEndIndex, d, k, P]);
|
|
952
|
+
const Q = L(
|
|
953
953
|
(g) => {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
954
|
+
const { renderingStartIndex: E, renderingEndIndex: y } = F;
|
|
955
|
+
if (N.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: E, renderingEndIndex: y, fenwickSize: w, viewportSize: t }), w === 0)
|
|
956
|
+
return /* @__PURE__ */ D.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ D.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
|
|
957
|
+
const O = A(E, 0, w - 1), { cumulative: M, currentValue: n } = b.prefixSum(O, { materializeOption: { materialize: !1 } }), u = M - n, h = [], x = [];
|
|
958
|
+
for (let T = E; T <= y; T++) {
|
|
959
|
+
const q = r(T);
|
|
960
|
+
h.push({ item: e(T), height: q }), b.get(T) !== q && x.push({ index: T, value: q });
|
|
960
961
|
}
|
|
961
|
-
|
|
962
|
-
const
|
|
963
|
-
|
|
962
|
+
x.length > 0 && Promise.resolve().then(() => {
|
|
963
|
+
const T = b.updates(x);
|
|
964
|
+
T && (V(T), N.debug("[VirtualScroll] Updated heights for items", x, "New total height:", T));
|
|
964
965
|
});
|
|
965
|
-
const
|
|
966
|
-
return
|
|
967
|
-
const
|
|
968
|
-
return /* @__PURE__ */
|
|
966
|
+
const z = P < t ? 0 : u - g;
|
|
967
|
+
return N.debug("[VirtualScroll] Rendering items", { visibleItems: h, containerTop: z }), /* @__PURE__ */ D.jsx("div", { className: "absolute w-full", style: { top: z }, children: h.map(({ item: T, height: q }, G) => {
|
|
968
|
+
const R = E + G, W = A(R, 0, w - 1), { cumulative: K, currentValue: se } = b.prefixSum(W, { materializeOption: { materialize: !1 } }), me = K - se;
|
|
969
|
+
return /* @__PURE__ */ D.jsx(
|
|
969
970
|
"div",
|
|
970
971
|
{
|
|
971
|
-
"data-index":
|
|
972
|
+
"data-index": R,
|
|
972
973
|
style: {
|
|
973
974
|
position: "absolute",
|
|
974
|
-
top:
|
|
975
|
+
top: me - u,
|
|
975
976
|
width: "100%"
|
|
976
977
|
},
|
|
977
|
-
children:
|
|
978
|
+
children: i(T, R)
|
|
978
979
|
},
|
|
979
|
-
|
|
980
|
+
R
|
|
980
981
|
);
|
|
981
982
|
}) });
|
|
982
983
|
},
|
|
983
|
-
[e,
|
|
984
|
+
[e, i, P, t, F, b, w, r]
|
|
984
985
|
);
|
|
985
986
|
return he(
|
|
986
987
|
_,
|
|
987
988
|
() => ({
|
|
988
|
-
getScrollPosition: () =>
|
|
989
|
-
getContentSize: () =>
|
|
990
|
-
getViewportSize: () =>
|
|
991
|
-
scrollTo: (g) =>
|
|
992
|
-
scrollToIndex: (g) =>
|
|
989
|
+
getScrollPosition: () => p.current?.getScrollPosition() ?? -1,
|
|
990
|
+
getContentSize: () => p.current?.getContentSize() ?? -1,
|
|
991
|
+
getViewportSize: () => p.current?.getViewportSize() ?? -1,
|
|
992
|
+
scrollTo: (g) => U(g),
|
|
993
|
+
scrollToIndex: (g) => H(g),
|
|
993
994
|
getFenwickTreeTotalHeight: () => b.getTotal(),
|
|
994
995
|
getFenwickSize: () => b.getSize()
|
|
995
996
|
}),
|
|
996
|
-
[
|
|
997
|
-
), /* @__PURE__ */
|
|
997
|
+
[H, b, U]
|
|
998
|
+
), /* @__PURE__ */ D.jsx(Ie, { ref: p, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: Q });
|
|
998
999
|
}
|
|
999
|
-
const
|
|
1000
|
-
class
|
|
1000
|
+
const Fe = de(ke);
|
|
1001
|
+
class Pe {
|
|
1001
1002
|
key;
|
|
1002
1003
|
value;
|
|
1003
1004
|
prev = null;
|
|
1004
1005
|
next = null;
|
|
1005
|
-
constructor(e,
|
|
1006
|
-
this.key = e, this.value =
|
|
1006
|
+
constructor(e, r) {
|
|
1007
|
+
this.key = e, this.value = r;
|
|
1007
1008
|
}
|
|
1008
1009
|
}
|
|
1009
1010
|
class fe {
|
|
@@ -1047,54 +1048,54 @@ class fe {
|
|
|
1047
1048
|
this.remove(e), this.addToTail(e);
|
|
1048
1049
|
}
|
|
1049
1050
|
}
|
|
1050
|
-
function
|
|
1051
|
-
const e =
|
|
1051
|
+
function we(l) {
|
|
1052
|
+
const e = Y(/* @__PURE__ */ new Map()), r = Y(new fe());
|
|
1052
1053
|
B(() => {
|
|
1053
|
-
for (; e.current.size >
|
|
1054
|
-
const c =
|
|
1054
|
+
for (; e.current.size > l; ) {
|
|
1055
|
+
const c = r.current.removeHead();
|
|
1055
1056
|
if (c)
|
|
1056
1057
|
e.current.delete(c.key);
|
|
1057
1058
|
else
|
|
1058
1059
|
break;
|
|
1059
1060
|
}
|
|
1060
|
-
}, [
|
|
1061
|
-
const t =
|
|
1061
|
+
}, [l]);
|
|
1062
|
+
const t = L((c) => {
|
|
1062
1063
|
const m = e.current.get(c);
|
|
1063
1064
|
if (m)
|
|
1064
|
-
return
|
|
1065
|
-
}, []), s =
|
|
1065
|
+
return r.current.moveToTail(m), m.value;
|
|
1066
|
+
}, []), s = L(
|
|
1066
1067
|
(c, m) => {
|
|
1067
|
-
if (
|
|
1068
|
+
if (l <= 0)
|
|
1068
1069
|
return;
|
|
1069
|
-
let
|
|
1070
|
-
if (
|
|
1071
|
-
|
|
1070
|
+
let v = e.current.get(c);
|
|
1071
|
+
if (v)
|
|
1072
|
+
v.value = m, r.current.moveToTail(v);
|
|
1072
1073
|
else {
|
|
1073
|
-
if (e.current.size >=
|
|
1074
|
-
const _ =
|
|
1074
|
+
if (e.current.size >= l) {
|
|
1075
|
+
const _ = r.current.removeHead();
|
|
1075
1076
|
_ && e.current.delete(_.key);
|
|
1076
1077
|
}
|
|
1077
|
-
|
|
1078
|
+
v = new Pe(c, m), e.current.set(c, v), r.current.addToTail(v);
|
|
1078
1079
|
}
|
|
1079
1080
|
},
|
|
1080
|
-
[
|
|
1081
|
-
), a =
|
|
1082
|
-
e.current.clear(),
|
|
1083
|
-
}, []), [d,
|
|
1084
|
-
return B(() =>
|
|
1081
|
+
[l]
|
|
1082
|
+
), a = L((c) => e.current.has(c), []), o = L(() => {
|
|
1083
|
+
e.current.clear(), r.current = new fe();
|
|
1084
|
+
}, []), [d, i] = X(() => ({ get: t, set: s, has: a, clear: o }));
|
|
1085
|
+
return B(() => i({ get: t, set: s, has: a, clear: o }), [t, s, a, o]), d;
|
|
1085
1086
|
}
|
|
1086
|
-
const
|
|
1087
|
-
const { get:
|
|
1088
|
-
return { get:
|
|
1087
|
+
const Ve = 1e4, Ae = () => {
|
|
1088
|
+
const { get: l, set: e, has: r, clear: t } = we(Ve);
|
|
1089
|
+
return { get: l, set: e, has: r, clear: t };
|
|
1089
1090
|
};
|
|
1090
1091
|
export {
|
|
1091
|
-
|
|
1092
|
-
|
|
1092
|
+
Re as FenwickMapTree,
|
|
1093
|
+
_e as ScrollBar,
|
|
1093
1094
|
Ie as ScrollPane,
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1095
|
+
Fe as VirtualScroll,
|
|
1096
|
+
A as minmax,
|
|
1097
|
+
Se as useFenwickMapTree,
|
|
1098
|
+
Ae as useHeightCache,
|
|
1099
|
+
we as useLruCache
|
|
1099
1100
|
};
|
|
1100
1101
|
//# sourceMappingURL=index.js.map
|