@aiquants/virtualscroll 0.2.0 → 0.2.1
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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +382 -387
- 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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import be, { useState as W, useRef as $, useEffect as B, forwardRef as de, useReducer as ve, useMemo as ne, useCallback as Y, useLayoutEffect as oe, useImperativeHandle as he, useId as pe } from "react";
|
|
2
2
|
import { twMerge as ae } from "tailwind-merge";
|
|
3
3
|
var re = { exports: {} }, K = {};
|
|
4
4
|
/**
|
|
@@ -11,11 +11,11 @@ var re = { exports: {} }, K = {};
|
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
13
|
var ie;
|
|
14
|
-
function
|
|
14
|
+
function xe() {
|
|
15
15
|
if (ie) return K;
|
|
16
16
|
ie = 1;
|
|
17
17
|
var u = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
18
|
-
function n(
|
|
18
|
+
function n(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 = {};
|
|
@@ -24,7 +24,7 @@ function ve() {
|
|
|
24
24
|
} else a = s;
|
|
25
25
|
return s = a.ref, {
|
|
26
26
|
$$typeof: u,
|
|
27
|
-
type:
|
|
27
|
+
type: t,
|
|
28
28
|
key: o,
|
|
29
29
|
ref: s !== void 0 ? s : null,
|
|
30
30
|
props: a
|
|
@@ -43,244 +43,244 @@ var ee = {};
|
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
44
|
*/
|
|
45
45
|
var le;
|
|
46
|
-
function
|
|
46
|
+
function Te() {
|
|
47
47
|
return le || (le = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
48
|
-
function u(
|
|
49
|
-
if (
|
|
50
|
-
if (typeof
|
|
51
|
-
return
|
|
52
|
-
if (typeof
|
|
53
|
-
switch (
|
|
54
|
-
case
|
|
48
|
+
function u(r) {
|
|
49
|
+
if (r == null) return null;
|
|
50
|
+
if (typeof r == "function")
|
|
51
|
+
return r.$$typeof === U ? null : r.displayName || r.name || null;
|
|
52
|
+
if (typeof r == "string") return r;
|
|
53
|
+
switch (r) {
|
|
54
|
+
case A:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case R:
|
|
57
57
|
return "Profiler";
|
|
58
58
|
case b:
|
|
59
59
|
return "StrictMode";
|
|
60
|
-
case
|
|
60
|
+
case O:
|
|
61
61
|
return "Suspense";
|
|
62
|
-
case
|
|
62
|
+
case M:
|
|
63
63
|
return "SuspenseList";
|
|
64
|
-
case
|
|
64
|
+
case X:
|
|
65
65
|
return "Activity";
|
|
66
66
|
}
|
|
67
|
-
if (typeof
|
|
68
|
-
switch (typeof
|
|
67
|
+
if (typeof r == "object")
|
|
68
|
+
switch (typeof r.tag == "number" && console.error(
|
|
69
69
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
70
|
-
),
|
|
71
|
-
case
|
|
70
|
+
), r.$$typeof) {
|
|
71
|
+
case S:
|
|
72
72
|
return "Portal";
|
|
73
73
|
case f:
|
|
74
|
-
return (
|
|
75
|
-
case
|
|
76
|
-
return (
|
|
74
|
+
return (r.displayName || "Context") + ".Provider";
|
|
75
|
+
case k:
|
|
76
|
+
return (r._context.displayName || "Context") + ".Consumer";
|
|
77
|
+
case P:
|
|
78
|
+
var i = r.render;
|
|
79
|
+
return r = r.displayName, r || (r = i.displayName || i.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
80
|
+
case H:
|
|
81
|
+
return i = r.displayName || null, i !== null ? i : u(r.type) || "Memo";
|
|
77
82
|
case w:
|
|
78
|
-
|
|
79
|
-
return t = t.displayName, t || (t = i.displayName || i.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
80
|
-
case $:
|
|
81
|
-
return i = t.displayName || null, i !== null ? i : u(t.type) || "Memo";
|
|
82
|
-
case _:
|
|
83
|
-
i = t._payload, t = t._init;
|
|
83
|
+
i = r._payload, r = r._init;
|
|
84
84
|
try {
|
|
85
|
-
return u(
|
|
85
|
+
return u(r(i));
|
|
86
86
|
} catch {
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
-
function e(
|
|
92
|
-
return "" +
|
|
91
|
+
function e(r) {
|
|
92
|
+
return "" + r;
|
|
93
93
|
}
|
|
94
|
-
function n(
|
|
94
|
+
function n(r) {
|
|
95
95
|
try {
|
|
96
|
-
e(
|
|
96
|
+
e(r);
|
|
97
97
|
var i = !1;
|
|
98
98
|
} catch {
|
|
99
99
|
i = !0;
|
|
100
100
|
}
|
|
101
101
|
if (i) {
|
|
102
102
|
i = console;
|
|
103
|
-
var
|
|
104
|
-
return
|
|
103
|
+
var h = i.error, v = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
|
|
104
|
+
return h.call(
|
|
105
105
|
i,
|
|
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
|
+
v
|
|
108
|
+
), e(r);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function r
|
|
112
|
-
if (
|
|
113
|
-
if (typeof
|
|
111
|
+
function t(r) {
|
|
112
|
+
if (r === A) return "<>";
|
|
113
|
+
if (typeof r == "object" && r !== null && r.$$typeof === w)
|
|
114
114
|
return "<...>";
|
|
115
115
|
try {
|
|
116
|
-
var i = u(
|
|
116
|
+
var i = u(r);
|
|
117
117
|
return i ? "<" + i + ">" : "<...>";
|
|
118
118
|
} catch {
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function s() {
|
|
123
|
-
var
|
|
124
|
-
return
|
|
123
|
+
var r = q.A;
|
|
124
|
+
return r === null ? null : r.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 i = Object.getOwnPropertyDescriptor(
|
|
129
|
+
function o(r) {
|
|
130
|
+
if (Z.call(r, "key")) {
|
|
131
|
+
var i = Object.getOwnPropertyDescriptor(r, "key").get;
|
|
132
132
|
if (i && i.isReactWarning) return !1;
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return r.key !== void 0;
|
|
135
135
|
}
|
|
136
|
-
function d(
|
|
137
|
-
function
|
|
138
|
-
|
|
136
|
+
function d(r, i) {
|
|
137
|
+
function h() {
|
|
138
|
+
J || (J = !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
|
i
|
|
141
141
|
));
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
get:
|
|
143
|
+
h.isReactWarning = !0, Object.defineProperty(r, "key", {
|
|
144
|
+
get: h,
|
|
145
145
|
configurable: !0
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
function l() {
|
|
149
|
-
var
|
|
150
|
-
return
|
|
149
|
+
var r = u(this.type);
|
|
150
|
+
return G[r] || (G[r] = !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
|
+
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
153
153
|
}
|
|
154
|
-
function c(
|
|
155
|
-
return
|
|
156
|
-
$$typeof:
|
|
157
|
-
type:
|
|
154
|
+
function c(r, i, h, v, E, T, I, L) {
|
|
155
|
+
return h = T.ref, r = {
|
|
156
|
+
$$typeof: x,
|
|
157
|
+
type: r,
|
|
158
158
|
key: i,
|
|
159
159
|
props: T,
|
|
160
|
-
_owner:
|
|
161
|
-
}, (
|
|
160
|
+
_owner: E
|
|
161
|
+
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(r, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
163
|
get: l
|
|
164
|
-
}) : Object.defineProperty(
|
|
164
|
+
}) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
|
|
165
165
|
configurable: !1,
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
writable: !0,
|
|
168
168
|
value: 0
|
|
169
|
-
}), Object.defineProperty(
|
|
169
|
+
}), Object.defineProperty(r, "_debugInfo", {
|
|
170
170
|
configurable: !1,
|
|
171
171
|
enumerable: !1,
|
|
172
172
|
writable: !0,
|
|
173
173
|
value: null
|
|
174
|
-
}), Object.defineProperty(
|
|
174
|
+
}), Object.defineProperty(r, "_debugStack", {
|
|
175
175
|
configurable: !1,
|
|
176
176
|
enumerable: !1,
|
|
177
177
|
writable: !0,
|
|
178
|
-
value:
|
|
179
|
-
}), Object.defineProperty(
|
|
178
|
+
value: I
|
|
179
|
+
}), Object.defineProperty(r, "_debugTask", {
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
184
|
-
}), Object.freeze && (Object.freeze(
|
|
183
|
+
value: L
|
|
184
|
+
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
186
|
+
function m(r, i, h, v, E, T, I, L) {
|
|
187
|
+
var y = i.children;
|
|
188
|
+
if (y !== void 0)
|
|
189
|
+
if (v)
|
|
190
|
+
if (C(y)) {
|
|
191
|
+
for (v = 0; v < y.length; v++)
|
|
192
|
+
p(y[v]);
|
|
193
|
+
Object.freeze && Object.freeze(y);
|
|
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
|
|
198
|
+
else p(y);
|
|
199
199
|
if (Z.call(i, "key")) {
|
|
200
|
-
|
|
201
|
-
var
|
|
200
|
+
y = u(r);
|
|
201
|
+
var N = Object.keys(i).filter(function(se) {
|
|
202
202
|
return se !== "key";
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
v = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", V[y + v] || (N = 0 < N.length ? "{" + N.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
|
+
v,
|
|
212
|
+
y,
|
|
213
|
+
N,
|
|
214
|
+
y
|
|
215
|
+
), V[y + v] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
217
|
+
if (y = null, h !== void 0 && (n(h), y = "" + h), o(i) && (n(i.key), y = "" + i.key), "key" in i) {
|
|
218
|
+
h = {};
|
|
219
219
|
for (var Q in i)
|
|
220
|
-
Q !== "key" && (
|
|
221
|
-
} else
|
|
222
|
-
return
|
|
223
|
-
|
|
224
|
-
typeof
|
|
220
|
+
Q !== "key" && (h[Q] = i[Q]);
|
|
221
|
+
} else h = i;
|
|
222
|
+
return y && d(
|
|
223
|
+
h,
|
|
224
|
+
typeof r == "function" ? r.displayName || r.name || "Unknown" : r
|
|
225
225
|
), c(
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
r,
|
|
227
|
+
y,
|
|
228
228
|
T,
|
|
229
|
-
|
|
229
|
+
E,
|
|
230
230
|
s(),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
h,
|
|
232
|
+
I,
|
|
233
|
+
L
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
typeof
|
|
236
|
+
function p(r) {
|
|
237
|
+
typeof r == "object" && r !== null && r.$$typeof === x && r._store && (r._store.validated = 1);
|
|
238
238
|
}
|
|
239
|
-
var
|
|
239
|
+
var _ = be, x = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), b = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), k = Symbol.for("react.consumer"), f = Symbol.for("react.context"), P = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), M = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), X = Symbol.for("react.activity"), U = Symbol.for("react.client.reference"), q = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, C = Array.isArray, D = console.createTask ? console.createTask : function() {
|
|
240
240
|
return null;
|
|
241
241
|
};
|
|
242
|
-
|
|
243
|
-
react_stack_bottom_frame: function(
|
|
244
|
-
return
|
|
242
|
+
_ = {
|
|
243
|
+
react_stack_bottom_frame: function(r) {
|
|
244
|
+
return r();
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
|
-
var
|
|
248
|
-
|
|
247
|
+
var J, G = {}, te = _.react_stack_bottom_frame.bind(
|
|
248
|
+
_,
|
|
249
249
|
a
|
|
250
|
-
)(),
|
|
251
|
-
ee.Fragment =
|
|
252
|
-
var T = 1e4 >
|
|
253
|
-
return
|
|
254
|
-
|
|
250
|
+
)(), g = D(t(a)), V = {};
|
|
251
|
+
ee.Fragment = A, ee.jsx = function(r, i, h, v, E) {
|
|
252
|
+
var T = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return m(
|
|
254
|
+
r,
|
|
255
255
|
i,
|
|
256
|
-
|
|
256
|
+
h,
|
|
257
257
|
!1,
|
|
258
|
-
|
|
259
|
-
|
|
258
|
+
v,
|
|
259
|
+
E,
|
|
260
260
|
T ? Error("react-stack-top-frame") : te,
|
|
261
|
-
T ?
|
|
261
|
+
T ? D(t(r)) : g
|
|
262
262
|
);
|
|
263
|
-
}, ee.jsxs = function(
|
|
264
|
-
var T = 1e4 >
|
|
265
|
-
return
|
|
266
|
-
|
|
263
|
+
}, ee.jsxs = function(r, i, h, v, E) {
|
|
264
|
+
var T = 1e4 > q.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return m(
|
|
266
|
+
r,
|
|
267
267
|
i,
|
|
268
|
-
|
|
268
|
+
h,
|
|
269
269
|
!0,
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
v,
|
|
271
|
+
E,
|
|
272
272
|
T ? Error("react-stack-top-frame") : te,
|
|
273
|
-
T ?
|
|
273
|
+
T ? D(t(r)) : g
|
|
274
274
|
);
|
|
275
275
|
};
|
|
276
276
|
})()), ee;
|
|
277
277
|
}
|
|
278
278
|
var ue;
|
|
279
|
-
function
|
|
280
|
-
return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports =
|
|
279
|
+
function Ee() {
|
|
280
|
+
return ue || (ue = 1, process.env.NODE_ENV === "production" ? re.exports = xe() : re.exports = Te()), re.exports;
|
|
281
281
|
}
|
|
282
|
-
var z =
|
|
283
|
-
const
|
|
282
|
+
var z = Ee();
|
|
283
|
+
const j = {
|
|
284
284
|
debug(u, ...e) {
|
|
285
285
|
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${u}`, ...e);
|
|
286
286
|
},
|
|
@@ -290,43 +290,43 @@ const A = {
|
|
|
290
290
|
error(u, ...e) {
|
|
291
291
|
console.error(`[VirtualScroll] ${u}`, ...e);
|
|
292
292
|
}
|
|
293
|
-
},
|
|
294
|
-
const
|
|
295
|
-
|
|
293
|
+
}, F = (u, e, n) => Math.min(n, Math.max(e, u)), ce = (u, e, n) => {
|
|
294
|
+
const t = "touches" in u.nativeEvent, s = t ? u.nativeEvent.touches[0] : u.nativeEvent, a = (d) => {
|
|
295
|
+
t && d.cancelable && d.preventDefault();
|
|
296
296
|
const l = "touches" in d ? d.touches[0] : d;
|
|
297
297
|
e({
|
|
298
298
|
deltaX: l.clientX - s.clientX,
|
|
299
299
|
deltaY: l.clientY - s.clientY
|
|
300
300
|
});
|
|
301
301
|
}, o = () => {
|
|
302
|
-
|
|
302
|
+
t ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", o)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", o)), n?.();
|
|
303
303
|
};
|
|
304
|
-
|
|
305
|
-
},
|
|
306
|
-
const [l, c] = W(!1),
|
|
307
|
-
|
|
308
|
-
|
|
304
|
+
t ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", o)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", o));
|
|
305
|
+
}, _e = 20, Re = ({ contentSize: u, viewportSize: e, scrollPosition: n, onScroll: t, horizontal: s = !1, scrollBarWidth: a = 12, className: o, ariaControls: d }) => {
|
|
306
|
+
const [l, c] = W(!1), m = $(null), p = e / u, _ = Math.max(_e, p * e), x = u - e, S = n / x * (e - _), A = u > e;
|
|
307
|
+
B(() => {
|
|
308
|
+
m.current && (l ? m.current.style.backgroundColor = "#4F4F4F" : m.current.style.backgroundColor = "#7F7F7F");
|
|
309
309
|
}, [l]);
|
|
310
|
-
const b = (f) =>
|
|
311
|
-
if (!
|
|
310
|
+
const b = (f) => F(f / (e - _) * x, 0, x), R = (f) => {
|
|
311
|
+
if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
|
|
312
312
|
return;
|
|
313
313
|
f.stopPropagation();
|
|
314
|
-
const
|
|
314
|
+
const P = S;
|
|
315
315
|
c(!0), ce(
|
|
316
316
|
f,
|
|
317
|
-
({ deltaX:
|
|
318
|
-
|
|
317
|
+
({ deltaX: O, deltaY: M }) => {
|
|
318
|
+
t?.(b(P + (s ? O : M)), S);
|
|
319
319
|
},
|
|
320
320
|
() => {
|
|
321
321
|
c(!1);
|
|
322
322
|
}
|
|
323
323
|
);
|
|
324
|
-
},
|
|
325
|
-
if (!
|
|
324
|
+
}, k = (f) => {
|
|
325
|
+
if (!A || "button" in f && f.button !== 0 || f.ctrlKey)
|
|
326
326
|
return;
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
const O = "touches" in f.nativeEvent ? f.nativeEvent.touches[0] : f.nativeEvent, M = s ? O.clientX : O.clientY, H = f.currentTarget.getBoundingClientRect(), X = (s ? M - H.left : M - H.top) - _ / 2;
|
|
328
|
+
t?.(b(X), S), ce(f, ({ deltaX: U, deltaY: q }) => {
|
|
329
|
+
t?.(b(X + (s ? U : q)), S);
|
|
330
330
|
});
|
|
331
331
|
};
|
|
332
332
|
return (
|
|
@@ -341,14 +341,14 @@ const A = {
|
|
|
341
341
|
backgroundColor: "white",
|
|
342
342
|
userSelect: "none"
|
|
343
343
|
},
|
|
344
|
-
onMouseDown:
|
|
345
|
-
onTouchStart:
|
|
344
|
+
onMouseDown: k,
|
|
345
|
+
onTouchStart: k,
|
|
346
346
|
role: "scrollbar",
|
|
347
347
|
tabIndex: -1,
|
|
348
348
|
"aria-controls": d,
|
|
349
349
|
"aria-valuenow": n,
|
|
350
350
|
"aria-valuemin": 0,
|
|
351
|
-
"aria-valuemax":
|
|
351
|
+
"aria-valuemax": x,
|
|
352
352
|
"aria-orientation": s ? "horizontal" : "vertical",
|
|
353
353
|
children: u > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
|
|
354
354
|
/* @__PURE__ */ z.jsx(
|
|
@@ -356,23 +356,23 @@ const A = {
|
|
|
356
356
|
{
|
|
357
357
|
className: "group absolute",
|
|
358
358
|
style: {
|
|
359
|
-
[s ? "width" : "height"]:
|
|
360
|
-
[s ? "left" : "top"]:
|
|
359
|
+
[s ? "width" : "height"]: _,
|
|
360
|
+
[s ? "left" : "top"]: S,
|
|
361
361
|
// 当たり判定を上下または左右に広げる
|
|
362
362
|
...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
363
363
|
},
|
|
364
|
-
onMouseDown:
|
|
365
|
-
onTouchStart:
|
|
364
|
+
onMouseDown: R,
|
|
365
|
+
onTouchStart: R,
|
|
366
366
|
role: "slider",
|
|
367
367
|
"aria-orientation": s ? "horizontal" : "vertical",
|
|
368
368
|
"aria-valuenow": n,
|
|
369
369
|
"aria-valuemin": 0,
|
|
370
|
-
"aria-valuemax":
|
|
370
|
+
"aria-valuemax": x,
|
|
371
371
|
tabIndex: 0,
|
|
372
372
|
children: /* @__PURE__ */ z.jsx(
|
|
373
373
|
"div",
|
|
374
374
|
{
|
|
375
|
-
ref:
|
|
375
|
+
ref: m,
|
|
376
376
|
className: ae(
|
|
377
377
|
"absolute",
|
|
378
378
|
s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${l ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${l ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
|
|
@@ -406,59 +406,59 @@ const A = {
|
|
|
406
406
|
}
|
|
407
407
|
)
|
|
408
408
|
);
|
|
409
|
-
},
|
|
410
|
-
const c =
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
(
|
|
414
|
-
const
|
|
415
|
-
if (
|
|
409
|
+
}, Ie = de(({ children: u, contentSize: e, viewportSize: n, scrollBarWidth: t = 12, onScroll: s, className: a, style: o, background: d }, l) => {
|
|
410
|
+
const c = $(0), [m, p] = ve((R) => R + 1, 0), _ = $(null);
|
|
411
|
+
j.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: t, className: a, style: o });
|
|
412
|
+
const x = ne(() => e > n, [e, n]), S = Y(
|
|
413
|
+
(R) => {
|
|
414
|
+
const k = e > n, f = c.current;
|
|
415
|
+
if (j.debug("[ScrollPane] scrollTo called", { newPosition: R, contentSize: e, viewportSize: n, currentIsScrollable: k, prevPosition: f }), !k) {
|
|
416
416
|
c.current !== 0 && (c.current = 0, s?.(0, f));
|
|
417
417
|
return;
|
|
418
418
|
}
|
|
419
|
-
const
|
|
420
|
-
c.current !==
|
|
419
|
+
const P = typeof R == "function" ? R(c.current) : R, O = F(P, 0, e - n);
|
|
420
|
+
c.current !== O && (c.current = O, s?.(O, f));
|
|
421
421
|
},
|
|
422
422
|
[s, e, n]
|
|
423
423
|
);
|
|
424
424
|
oe(() => {
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
c.current >
|
|
425
|
+
if (x) {
|
|
426
|
+
j.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: n, scrollPosition: c.current });
|
|
427
|
+
const R = F(e - n, 0, e);
|
|
428
|
+
c.current > R && S(R);
|
|
429
429
|
} else
|
|
430
|
-
|
|
431
|
-
}, [
|
|
432
|
-
const
|
|
433
|
-
if (!
|
|
430
|
+
S(0);
|
|
431
|
+
}, [x, S, e, n]), B(() => {
|
|
432
|
+
const R = (f) => {
|
|
433
|
+
if (!x)
|
|
434
434
|
return;
|
|
435
435
|
f.preventDefault();
|
|
436
|
-
let
|
|
437
|
-
f.deltaMode === 1 ?
|
|
438
|
-
},
|
|
439
|
-
return
|
|
440
|
-
|
|
436
|
+
let P = f.deltaY;
|
|
437
|
+
f.deltaMode === 1 ? P *= 16 : f.deltaMode === 2 && (P *= n), j.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: c.current }), S((O) => O + P);
|
|
438
|
+
}, k = _.current;
|
|
439
|
+
return k && k.addEventListener("wheel", R, { passive: !1 }), () => {
|
|
440
|
+
k && k.removeEventListener("wheel", R);
|
|
441
441
|
};
|
|
442
|
-
}, [
|
|
442
|
+
}, [x, S, n]), he(
|
|
443
443
|
l,
|
|
444
444
|
() => ({
|
|
445
|
-
scrollTo:
|
|
445
|
+
scrollTo: S,
|
|
446
446
|
getScrollPosition: () => c.current,
|
|
447
447
|
getContentSize: () => e,
|
|
448
448
|
getViewportSize: () => n
|
|
449
449
|
}),
|
|
450
|
-
[
|
|
450
|
+
[S, e, n]
|
|
451
451
|
);
|
|
452
|
-
const
|
|
453
|
-
return ne(() => /* @__PURE__ */ z.jsxs("div", { ref:
|
|
454
|
-
/* @__PURE__ */ z.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: n }, id:
|
|
452
|
+
const A = pe();
|
|
453
|
+
return ne(() => /* @__PURE__ */ z.jsxs("div", { ref: _, className: ae("flex", a), style: o, children: [
|
|
454
|
+
/* @__PURE__ */ z.jsxs("div", { className: "relative h-full flex-1 overflow-hidden", style: { height: n }, id: A, children: [
|
|
455
455
|
d,
|
|
456
456
|
u(c.current)
|
|
457
457
|
] }),
|
|
458
|
-
|
|
459
|
-
] }), [u, e, n,
|
|
458
|
+
x && /* @__PURE__ */ z.jsx(Re, { contentSize: e, viewportSize: n, scrollPosition: c.current, onScroll: S, scrollBarWidth: t, ariaControls: A })
|
|
459
|
+
] }), [u, e, n, t, a, o, x, S, A, d]);
|
|
460
460
|
});
|
|
461
|
-
class
|
|
461
|
+
class Se {
|
|
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 Re {
|
|
|
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, n,
|
|
502
|
-
this.reset(e, n,
|
|
501
|
+
constructor(e, n, t) {
|
|
502
|
+
this.reset(e, n, t);
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* @method reset
|
|
@@ -509,20 +509,20 @@ class Re {
|
|
|
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, n,
|
|
512
|
+
reset(e, n, t) {
|
|
513
513
|
if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof n == "function") {
|
|
514
514
|
if (this.valueFn = n, this.size > 0) {
|
|
515
|
-
const a =
|
|
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
|
-
if (this.baseValue = o,
|
|
519
|
+
if (this.baseValue = o, t?.materialize)
|
|
520
520
|
for (let l = 0; l < d.length; l++) {
|
|
521
|
-
const c = d[l],
|
|
522
|
-
if (
|
|
521
|
+
const c = d[l], m = a.from + l;
|
|
522
|
+
if (m >= this.size)
|
|
523
523
|
break;
|
|
524
|
-
const
|
|
525
|
-
this.deltas.set(
|
|
524
|
+
const p = c - this.baseValue;
|
|
525
|
+
this.deltas.set(m, p), this._updateTree(m, p);
|
|
526
526
|
}
|
|
527
527
|
} else
|
|
528
528
|
this.baseValue = 0;
|
|
@@ -551,28 +551,28 @@ class Re {
|
|
|
551
551
|
_calculateMode(e, n) {
|
|
552
552
|
if (!this.valueFn)
|
|
553
553
|
return { mode: 0, materializedValues: [] };
|
|
554
|
-
const
|
|
554
|
+
const t = [];
|
|
555
555
|
for (let c = e; c <= n && !(c >= this.size); c++)
|
|
556
|
-
|
|
557
|
-
const s = [...
|
|
558
|
-
if (
|
|
556
|
+
t.push(this.valueFn(c));
|
|
557
|
+
const s = [...t];
|
|
558
|
+
if (t.length === 0)
|
|
559
559
|
return { mode: 0, materializedValues: [] };
|
|
560
|
-
|
|
561
|
-
const a = Math.floor(
|
|
560
|
+
t.sort((c, m) => c - m);
|
|
561
|
+
const a = Math.floor(t.length / 2);
|
|
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
565
|
let l = 0;
|
|
566
|
-
for (const c of
|
|
567
|
-
const
|
|
568
|
-
d.set(c,
|
|
566
|
+
for (const c of t) {
|
|
567
|
+
const m = (d.get(c) ?? 0) + 1;
|
|
568
|
+
d.set(c, m), m > l && (l = m);
|
|
569
569
|
}
|
|
570
570
|
if (l > 1) {
|
|
571
571
|
const c = [];
|
|
572
|
-
for (const [
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
o = Math.floor(
|
|
572
|
+
for (const [p, _] of d.entries())
|
|
573
|
+
_ === l && c.push(p);
|
|
574
|
+
const m = c.reduce((p, _) => p + _, 0);
|
|
575
|
+
o = Math.floor(m / c.length);
|
|
576
576
|
}
|
|
577
577
|
return { mode: o, materializedValues: s };
|
|
578
578
|
}
|
|
@@ -593,14 +593,14 @@ class Re {
|
|
|
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 n = e.map(({ index:
|
|
597
|
-
if (
|
|
598
|
-
throw new Error(`Index ${
|
|
596
|
+
const n = e.map(({ index: t, value: s }) => {
|
|
597
|
+
if (t < 0 || t >= this.size)
|
|
598
|
+
throw new Error(`Index ${t} out of bounds`);
|
|
599
599
|
if (s < 0)
|
|
600
600
|
throw new Error("Value cannot be negative.");
|
|
601
|
-
const a = this.deltas.has(
|
|
602
|
-
return { index:
|
|
603
|
-
}).filter((
|
|
601
|
+
const a = this.deltas.has(t) ? (this.deltas.get(t) ?? 0) + this.baseValue : this.baseValue, o = s - a;
|
|
602
|
+
return { index: t, change: o };
|
|
603
|
+
}).filter((t) => t.change !== 0);
|
|
604
604
|
return n.length > 0 ? this.updateDeltas(n) : this.total;
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
@@ -620,11 +620,11 @@ class Re {
|
|
|
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: n, change:
|
|
623
|
+
for (const { index: n, change: t } of e) {
|
|
624
624
|
if (n < 0 || n >= this.size)
|
|
625
625
|
throw new Error(`Index ${n} out of bounds`);
|
|
626
626
|
const s = this.deltas.get(n) ?? 0;
|
|
627
|
-
this.deltas.set(n, s +
|
|
627
|
+
this.deltas.set(n, s + t), this._updateTree(n, t);
|
|
628
628
|
}
|
|
629
629
|
return this.total;
|
|
630
630
|
}
|
|
@@ -639,9 +639,9 @@ class Re {
|
|
|
639
639
|
_updateTree(e, n) {
|
|
640
640
|
if (n === 0)
|
|
641
641
|
return;
|
|
642
|
-
let
|
|
643
|
-
for (;
|
|
644
|
-
this.tree.set(
|
|
642
|
+
let t = e + 1;
|
|
643
|
+
for (; t <= this.size; )
|
|
644
|
+
this.tree.set(t, (this.tree.get(t) ?? 0) + n), t += t & -t;
|
|
645
645
|
this.total !== void 0 && (this.total += n);
|
|
646
646
|
}
|
|
647
647
|
/**
|
|
@@ -654,9 +654,9 @@ class Re {
|
|
|
654
654
|
*/
|
|
655
655
|
_materialize(e, n = !0) {
|
|
656
656
|
if (this.valueFn) {
|
|
657
|
-
const
|
|
658
|
-
if (a !==
|
|
659
|
-
const o = a -
|
|
657
|
+
const t = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
|
|
658
|
+
if (a !== t && (this.deltas.set(e, a), n)) {
|
|
659
|
+
const o = a - t;
|
|
660
660
|
this._updateTree(e, o);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
@@ -677,23 +677,23 @@ class Re {
|
|
|
677
677
|
prefixSum(e, n) {
|
|
678
678
|
if (e < 0)
|
|
679
679
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
680
|
-
const
|
|
680
|
+
const t = F(e, 0, this.size - 1), s = n?.materializeOption;
|
|
681
681
|
if (s?.materialize && this.valueFn) {
|
|
682
682
|
if (s.ranges)
|
|
683
683
|
for (const l of s.ranges) {
|
|
684
|
-
const c = l.from,
|
|
685
|
-
for (let
|
|
686
|
-
this._materialize(
|
|
684
|
+
const c = l.from, m = Math.min(l.to, this.size - 1);
|
|
685
|
+
for (let p = c; p <= m; p++)
|
|
686
|
+
this._materialize(p);
|
|
687
687
|
}
|
|
688
|
-
this._materialize(
|
|
688
|
+
this._materialize(t);
|
|
689
689
|
}
|
|
690
|
-
let a = 0, o =
|
|
690
|
+
let a = 0, o = t + 1;
|
|
691
691
|
for (; o > 0; ) {
|
|
692
692
|
const l = this.tree.get(o) ?? 0;
|
|
693
693
|
a += l, o -= o & -o;
|
|
694
694
|
}
|
|
695
|
-
const d = s?.materialize ? this.get(
|
|
696
|
-
return { cumulative: a + this.baseValue * (
|
|
695
|
+
const d = s?.materialize ? this.get(t) : (this.deltas.get(t) || 0) + this.baseValue;
|
|
696
|
+
return { cumulative: a + this.baseValue * (t + 1), total: this.total, currentValue: d, safeIndex: t };
|
|
697
697
|
}
|
|
698
698
|
/**
|
|
699
699
|
* @method get
|
|
@@ -711,15 +711,15 @@ class Re {
|
|
|
711
711
|
get(e, n) {
|
|
712
712
|
if (e < 0 || e >= this.size)
|
|
713
713
|
throw new Error("Index out of bounds");
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
if (
|
|
717
|
-
for (const s of
|
|
714
|
+
const t = n?.materializeOption;
|
|
715
|
+
if (t?.materialize && this.valueFn)
|
|
716
|
+
if (t.ranges) {
|
|
717
|
+
for (const s of t.ranges) {
|
|
718
718
|
const a = s.from, o = Math.min(s.to, this.size - 1);
|
|
719
719
|
for (let d = a; d <= o; d++)
|
|
720
720
|
this._materialize(d);
|
|
721
721
|
}
|
|
722
|
-
e >=
|
|
722
|
+
e >= t.ranges[0].from && e <= t.ranges[t.ranges.length - 1].to && this._materialize(e);
|
|
723
723
|
} else
|
|
724
724
|
this._materialize(e);
|
|
725
725
|
return (this.deltas.get(e) ?? 0) + this.baseValue;
|
|
@@ -739,8 +739,8 @@ class Re {
|
|
|
739
739
|
getTotal(e) {
|
|
740
740
|
const n = e?.materializeOption;
|
|
741
741
|
if (n?.materialize && this.valueFn && n.ranges)
|
|
742
|
-
for (const
|
|
743
|
-
const s =
|
|
742
|
+
for (const t of n.ranges) {
|
|
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);
|
|
746
746
|
}
|
|
@@ -748,10 +748,10 @@ class Re {
|
|
|
748
748
|
if (this.size === 0)
|
|
749
749
|
this.total = 0;
|
|
750
750
|
else {
|
|
751
|
-
let
|
|
751
|
+
let t = this.baseValue * this.size;
|
|
752
752
|
for (const s of this.deltas.values())
|
|
753
|
-
|
|
754
|
-
this.total =
|
|
753
|
+
t += s;
|
|
754
|
+
this.total = t, console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
|
|
755
755
|
}
|
|
756
756
|
return this.total;
|
|
757
757
|
}
|
|
@@ -769,15 +769,15 @@ class Re {
|
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
771
|
const n = /* @__PURE__ */ new Map();
|
|
772
|
-
let
|
|
772
|
+
let t = this.baseValue * this.size;
|
|
773
773
|
for (const [s, a] of this.deltas.entries()) {
|
|
774
|
-
if (
|
|
774
|
+
if (t += a, a === 0)
|
|
775
775
|
continue;
|
|
776
776
|
let o = s + 1;
|
|
777
777
|
for (; o <= this.size; )
|
|
778
778
|
n.set(o, (n.get(o) ?? 0) + a), o += o & -o;
|
|
779
779
|
}
|
|
780
|
-
this.tree = n, this.total =
|
|
780
|
+
this.tree = n, this.total = t;
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
783
783
|
* @method calculateAccumulatedError
|
|
@@ -803,8 +803,8 @@ class Re {
|
|
|
803
803
|
const n = this.size;
|
|
804
804
|
if (e !== n) {
|
|
805
805
|
if (e < n)
|
|
806
|
-
for (const
|
|
807
|
-
|
|
806
|
+
for (const t of this.deltas.keys())
|
|
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");
|
|
809
809
|
}
|
|
810
810
|
}
|
|
@@ -833,10 +833,10 @@ class Re {
|
|
|
833
833
|
findIndexAtOrAfter(e, n) {
|
|
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
|
-
let
|
|
837
|
-
for (;
|
|
838
|
-
const l = Math.floor((
|
|
839
|
-
o = this.prefixSum(l, n), d = o.total, o.cumulative >= e ? (a = l, s = l - 1) :
|
|
836
|
+
let t = 0, s = this.size - 1, a = -1, o, d = this.total;
|
|
837
|
+
for (; t <= s; ) {
|
|
838
|
+
const l = Math.floor((t + s) / 2);
|
|
839
|
+
o = this.prefixSum(l, n), d = o.total, o.cumulative >= e ? (a = l, s = l - 1) : t = l + 1;
|
|
840
840
|
}
|
|
841
841
|
return { index: a, total: d, cumulative: o?.cumulative, currentValue: o?.currentValue, safeIndex: o?.safeIndex };
|
|
842
842
|
}
|
|
@@ -856,153 +856,148 @@ class Re {
|
|
|
856
856
|
findIndexAtOrBefore(e, n) {
|
|
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
|
-
let
|
|
860
|
-
for (;
|
|
861
|
-
const l = Math.floor((
|
|
862
|
-
o = this.prefixSum(l, n), d = o.total, o.cumulative <= e ? (a = l,
|
|
859
|
+
let t = 0, s = this.size - 1, a = -1, o, d = this.total;
|
|
860
|
+
for (; t <= s; ) {
|
|
861
|
+
const l = Math.floor((t + s) / 2);
|
|
862
|
+
o = this.prefixSum(l, n), d = o.total, o.cumulative <= e ? (a = l, t = l + 1) : s = l - 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
|
|
867
|
+
const ke = (u, e, n) => {
|
|
868
|
+
const t = Math.max(0, u), s = $(null), a = ne(() => new Se(t, e, n), [t, e, n]);
|
|
869
869
|
return Object.is(s.current, a) || console.warn("[useFenwickMapTree] instance changed"), s.current = a, a;
|
|
870
870
|
};
|
|
871
|
-
function
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
871
|
+
function Pe({ itemCount: u, getItem: e, getItemHeight: n, viewportSize: t, overscanCount: s = 5, className: a, onScroll: o, onRangeChange: d, children: l, background: c, initialScrollIndex: m, initialScrollOffset: p }, _) {
|
|
872
|
+
const x = $(null), S = $(!1);
|
|
873
|
+
B(() => (S.current = !0, () => {
|
|
874
|
+
S.current = !1;
|
|
875
875
|
}), []);
|
|
876
|
-
const
|
|
877
|
-
let
|
|
878
|
-
if (typeof
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
} else typeof
|
|
882
|
-
return { position:
|
|
883
|
-
}), [
|
|
876
|
+
const A = $({ size: u, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), b = ke(A.current.size, A.current.valueOrFn, A.current.options), [R] = W(() => {
|
|
877
|
+
let g = 0, V = 0;
|
|
878
|
+
if (typeof m == "number") {
|
|
879
|
+
const r = F(m, 0, u - 1), i = F(r - s * 2, 0, u - 1), h = F(r + s * 2, 0, u - 1), v = m > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: i, to: h }] } } : void 0, { cumulative: E, total: T, currentValue: I } = b.prefixSum(m, v);
|
|
880
|
+
g = E - I, V = T ?? b.getTotal();
|
|
881
|
+
} else typeof p == "number" && (g = p), V = b.getTotal();
|
|
882
|
+
return { position: g, total: V };
|
|
883
|
+
}), [k, f] = W(R.position), [P, O] = W(R.total), [M, H] = W(R.position), [w, X] = W(u);
|
|
884
884
|
oe(() => {
|
|
885
|
-
b.setValueFn(n),
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
}, [b,
|
|
889
|
-
|
|
890
|
-
}, [
|
|
891
|
-
const
|
|
892
|
-
(
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
const
|
|
896
|
-
|
|
885
|
+
b.setValueFn(n), w !== u && (b.changeSize(u), X(u));
|
|
886
|
+
const g = b.getTotal();
|
|
887
|
+
P !== g && O(g);
|
|
888
|
+
}, [b, w, u, P, n]), oe(() => {
|
|
889
|
+
M !== null && x.current && (j.debug("[VirtualScroll] Scrolling to position:", M), x.current.scrollTo(M), H(null));
|
|
890
|
+
}, [M]);
|
|
891
|
+
const U = Y(
|
|
892
|
+
(g) => {
|
|
893
|
+
if (x.current) {
|
|
894
|
+
j.debug("[VirtualScroll] Scrolling to index:", g);
|
|
895
|
+
const V = F(g, 0, w - 1), r = F(V - s * 2, 0, w - 1), i = F(V + s * 2, 0, w - 1), { cumulative: h, total: v, currentValue: E } = b.prefixSum(V, { materializeOption: { materialize: !0, ranges: [{ from: r, to: i }] } });
|
|
896
|
+
j.debug("[VirtualScroll] Scrolling to index:", g, "Offset:", h, "Total height:", v, "Current value:", E, "safeIndex:", V, "safeIndexFrom:", r, "safeIndexTo:", i), v && (O(v), H(h - E)), j.debug("[VirtualScroll] Setting scroll position to:", h - E);
|
|
897
897
|
}
|
|
898
898
|
},
|
|
899
|
-
[b, s,
|
|
900
|
-
),
|
|
901
|
-
(
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
|
|
899
|
+
[b, s, w]
|
|
900
|
+
), q = Y(
|
|
901
|
+
(g) => {
|
|
902
|
+
if (x.current) {
|
|
903
|
+
const V = b.getTotal(), r = F(Math.floor(g), 0, V), i = b.findIndexAtOrAfter(r, { materializeOption: { materialize: !1 } }).index;
|
|
904
|
+
U(i);
|
|
905
905
|
}
|
|
906
906
|
},
|
|
907
|
-
[b,
|
|
908
|
-
), Z =
|
|
909
|
-
(
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
o?.(
|
|
907
|
+
[b, U]
|
|
908
|
+
), Z = Y(
|
|
909
|
+
(g, V) => {
|
|
910
|
+
j.debug("[VirtualScroll] Scroll position changed:", g), f(g);
|
|
911
|
+
const r = b.getTotal();
|
|
912
|
+
o?.(g, r);
|
|
913
913
|
},
|
|
914
914
|
[b, o]
|
|
915
|
-
), { renderingStartIndex:
|
|
916
|
-
if (
|
|
915
|
+
), { renderingStartIndex: C, renderingEndIndex: D, visibleStartIndex: J, visibleEndIndex: G } = ne(() => {
|
|
916
|
+
if (w === 0)
|
|
917
917
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
918
|
-
const { index:
|
|
918
|
+
const { index: g, cumulative: V, currentValue: r } = b.findIndexAtOrAfter(k, { materializeOption: { materialize: !1 } });
|
|
919
919
|
let i = 0;
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
let
|
|
923
|
-
for (; T <
|
|
924
|
-
const
|
|
925
|
-
|
|
920
|
+
g === -1 ? i = 0 : (V ?? 0) < k + (r ?? 0) ? i = 1 : i = 0;
|
|
921
|
+
const h = g === -1 ? 0 : g + i, v = F(h - s, 0, w - 1);
|
|
922
|
+
let E = 0, T = g === -1 ? 0 : g + i;
|
|
923
|
+
for (; T < w && E < t; ) {
|
|
924
|
+
const L = n(T);
|
|
925
|
+
E += L, T++;
|
|
926
926
|
}
|
|
927
927
|
T -= 1;
|
|
928
|
-
const
|
|
929
|
-
return
|
|
930
|
-
renderingStartIndex:
|
|
931
|
-
renderingEndIndex:
|
|
932
|
-
visibleStartIndex:
|
|
928
|
+
const I = F(T + s, 0, w - 1);
|
|
929
|
+
return j.debug("[VirtualScroll] Calculated rendering range:", {
|
|
930
|
+
renderingStartIndex: v,
|
|
931
|
+
renderingEndIndex: I,
|
|
932
|
+
visibleStartIndex: h,
|
|
933
933
|
visibleEndIndex: T,
|
|
934
|
-
scrollPosition:
|
|
934
|
+
scrollPosition: k,
|
|
935
935
|
renderingContentSize: b.getTotal(),
|
|
936
936
|
overscanCount: s,
|
|
937
|
-
viewportSize:
|
|
938
|
-
}), { renderingStartIndex:
|
|
939
|
-
}, [
|
|
940
|
-
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
renderingStartIndex:
|
|
944
|
-
renderingEndIndex:
|
|
945
|
-
visibleStartIndex:
|
|
946
|
-
visibleEndIndex:
|
|
947
|
-
scrollPosition:
|
|
948
|
-
contentSize:
|
|
949
|
-
scrollPaneScrollPosition:
|
|
950
|
-
}), d?.(
|
|
951
|
-
}, [
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
const t = n(v);
|
|
956
|
-
b.get(v) !== t && h.push({ index: v, value: t });
|
|
957
|
-
}
|
|
958
|
-
if (h.length > 0) {
|
|
959
|
-
const v = b.updates(h);
|
|
960
|
-
v && y((t) => v !== t && I.current ? (A.debug("[VirtualScroll] Updated heights for items", h, "New total height:", v), v) : t);
|
|
961
|
-
}
|
|
962
|
-
}, [j, M, n, b, _]);
|
|
963
|
-
const te = L(
|
|
964
|
-
(h) => {
|
|
965
|
-
if (A.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: h, renderingStartIndex: j, renderingEndIndex: M, fenwickSize: _, viewportSize: r }), _ === 0)
|
|
937
|
+
viewportSize: t
|
|
938
|
+
}), { renderingStartIndex: v, renderingEndIndex: I, visibleStartIndex: h, visibleEndIndex: T };
|
|
939
|
+
}, [k, s, t, n, b, w]);
|
|
940
|
+
B(() => {
|
|
941
|
+
const g = x.current?.getScrollPosition() ?? 0;
|
|
942
|
+
j.debug("[VirtualScroll] Range change effect triggered", {
|
|
943
|
+
renderingStartIndex: C,
|
|
944
|
+
renderingEndIndex: D,
|
|
945
|
+
visibleStartIndex: J,
|
|
946
|
+
visibleEndIndex: G,
|
|
947
|
+
scrollPosition: k,
|
|
948
|
+
contentSize: P,
|
|
949
|
+
scrollPaneScrollPosition: g
|
|
950
|
+
}), d?.(C, D, J, G, k, P);
|
|
951
|
+
}, [C, D, J, G, d, k, P]);
|
|
952
|
+
const te = Y(
|
|
953
|
+
(g) => {
|
|
954
|
+
if (j.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: g, renderingStartIndex: C, renderingEndIndex: D, fenwickSize: w, viewportSize: t }), w === 0)
|
|
966
955
|
return /* @__PURE__ */ z.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ z.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
|
|
967
|
-
const
|
|
968
|
-
for (let
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
956
|
+
const V = F(C, 0, w - 1), { cumulative: r, currentValue: i } = b.prefixSum(V, { materializeOption: { materialize: !1 } }), h = r - i, v = [], E = [];
|
|
957
|
+
for (let I = C; I <= D; I++) {
|
|
958
|
+
const L = n(I);
|
|
959
|
+
v.push({ item: e(I), height: L }), b.get(I) !== L && E.push({ index: I, value: L });
|
|
960
|
+
}
|
|
961
|
+
E.length > 0 && Promise.resolve().then(() => {
|
|
962
|
+
const I = b.updates(E);
|
|
963
|
+
I && (O(I), j.debug("[VirtualScroll] Updated heights for items", E, "New total height:", I));
|
|
964
|
+
});
|
|
965
|
+
const T = P < t ? 0 : h - g;
|
|
966
|
+
return j.debug("[VirtualScroll] Rendering items", { visibleItems: v, containerTop: T }), /* @__PURE__ */ z.jsx("div", { className: "absolute w-full", style: { top: T }, children: v.map(({ item: I, height: L }, y) => {
|
|
967
|
+
const N = C + y, Q = F(N, 0, w - 1), { cumulative: se, currentValue: me } = b.prefixSum(Q, { materializeOption: { materialize: !1 } }), ge = se - me;
|
|
973
968
|
return /* @__PURE__ */ z.jsx(
|
|
974
969
|
"div",
|
|
975
970
|
{
|
|
976
|
-
"data-index":
|
|
971
|
+
"data-index": N,
|
|
977
972
|
style: {
|
|
978
973
|
position: "absolute",
|
|
979
|
-
top:
|
|
974
|
+
top: ge - h,
|
|
980
975
|
width: "100%"
|
|
981
976
|
},
|
|
982
|
-
children: l(
|
|
977
|
+
children: l(I, N)
|
|
983
978
|
},
|
|
984
|
-
|
|
979
|
+
N
|
|
985
980
|
);
|
|
986
981
|
}) });
|
|
987
982
|
},
|
|
988
|
-
[e, l,
|
|
983
|
+
[e, l, P, t, C, D, b, w, n]
|
|
989
984
|
);
|
|
990
985
|
return he(
|
|
991
|
-
|
|
986
|
+
_,
|
|
992
987
|
() => ({
|
|
993
|
-
getScrollPosition: () =>
|
|
994
|
-
getContentSize: () =>
|
|
995
|
-
getViewportSize: () =>
|
|
996
|
-
scrollTo: (
|
|
997
|
-
scrollToIndex: (
|
|
988
|
+
getScrollPosition: () => x.current?.getScrollPosition() ?? -1,
|
|
989
|
+
getContentSize: () => x.current?.getContentSize() ?? -1,
|
|
990
|
+
getViewportSize: () => x.current?.getViewportSize() ?? -1,
|
|
991
|
+
scrollTo: (g) => q(g),
|
|
992
|
+
scrollToIndex: (g) => U(g),
|
|
998
993
|
getFenwickTreeTotalHeight: () => b.getTotal(),
|
|
999
994
|
getFenwickSize: () => b.getSize()
|
|
1000
995
|
}),
|
|
1001
|
-
[
|
|
1002
|
-
), /* @__PURE__ */ z.jsx(
|
|
996
|
+
[U, b, q]
|
|
997
|
+
), /* @__PURE__ */ z.jsx(Ie, { ref: x, contentSize: P, viewportSize: t, className: a, onScroll: Z, background: c, children: te });
|
|
1003
998
|
}
|
|
1004
|
-
const
|
|
1005
|
-
class
|
|
999
|
+
const Ae = de(Pe);
|
|
1000
|
+
class we {
|
|
1006
1001
|
key;
|
|
1007
1002
|
value;
|
|
1008
1003
|
prev = null;
|
|
@@ -1052,9 +1047,9 @@ class fe {
|
|
|
1052
1047
|
this.remove(e), this.addToTail(e);
|
|
1053
1048
|
}
|
|
1054
1049
|
}
|
|
1055
|
-
function
|
|
1056
|
-
const e =
|
|
1057
|
-
|
|
1050
|
+
function Ve(u) {
|
|
1051
|
+
const e = $(/* @__PURE__ */ new Map()), n = $(new fe());
|
|
1052
|
+
B(() => {
|
|
1058
1053
|
for (; e.current.size > u; ) {
|
|
1059
1054
|
const c = n.current.removeHead();
|
|
1060
1055
|
if (c)
|
|
@@ -1063,43 +1058,43 @@ function we(u) {
|
|
|
1063
1058
|
break;
|
|
1064
1059
|
}
|
|
1065
1060
|
}, [u]);
|
|
1066
|
-
const
|
|
1067
|
-
const
|
|
1068
|
-
if (
|
|
1069
|
-
return n.current.moveToTail(
|
|
1070
|
-
}, []), s =
|
|
1071
|
-
(c,
|
|
1061
|
+
const t = Y((c) => {
|
|
1062
|
+
const m = e.current.get(c);
|
|
1063
|
+
if (m)
|
|
1064
|
+
return n.current.moveToTail(m), m.value;
|
|
1065
|
+
}, []), s = Y(
|
|
1066
|
+
(c, m) => {
|
|
1072
1067
|
if (u <= 0)
|
|
1073
1068
|
return;
|
|
1074
|
-
let
|
|
1075
|
-
if (
|
|
1076
|
-
|
|
1069
|
+
let p = e.current.get(c);
|
|
1070
|
+
if (p)
|
|
1071
|
+
p.value = m, n.current.moveToTail(p);
|
|
1077
1072
|
else {
|
|
1078
1073
|
if (e.current.size >= u) {
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1074
|
+
const _ = n.current.removeHead();
|
|
1075
|
+
_ && e.current.delete(_.key);
|
|
1081
1076
|
}
|
|
1082
|
-
|
|
1077
|
+
p = new we(c, m), e.current.set(c, p), n.current.addToTail(p);
|
|
1083
1078
|
}
|
|
1084
1079
|
},
|
|
1085
1080
|
[u]
|
|
1086
|
-
), a =
|
|
1081
|
+
), a = Y((c) => e.current.has(c), []), o = Y(() => {
|
|
1087
1082
|
e.current.clear(), n.current = new fe();
|
|
1088
|
-
}, []), [d, l] = W(() => ({ get:
|
|
1089
|
-
return
|
|
1083
|
+
}, []), [d, l] = W(() => ({ get: t, set: s, has: a, clear: o }));
|
|
1084
|
+
return B(() => l({ get: t, set: s, has: a, clear: o }), [t, s, a, o]), d;
|
|
1090
1085
|
}
|
|
1091
|
-
const
|
|
1092
|
-
const { get: u, set: e, has: n, clear:
|
|
1093
|
-
return { get: u, set: e, has: n, clear:
|
|
1086
|
+
const ye = 1e4, je = () => {
|
|
1087
|
+
const { get: u, set: e, has: n, clear: t } = Ve(ye);
|
|
1088
|
+
return { get: u, set: e, has: n, clear: t };
|
|
1094
1089
|
};
|
|
1095
1090
|
export {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1091
|
+
Se as FenwickMapTree,
|
|
1092
|
+
Re as ScrollBar,
|
|
1093
|
+
Ie as ScrollPane,
|
|
1094
|
+
Ae as VirtualScroll,
|
|
1095
|
+
F as minmax,
|
|
1096
|
+
ke as useFenwickMapTree,
|
|
1097
|
+
je as useHeightCache,
|
|
1098
|
+
Ve as useLruCache
|
|
1104
1099
|
};
|
|
1105
1100
|
//# sourceMappingURL=index.js.map
|