@aiquants/virtualscroll 0.2.2 → 0.4.0
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/README.md +41 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1037 -572
- package/dist/index.js.map +1 -1
- package/dist/src/ScrollBar.d.ts +30 -1
- package/dist/src/ScrollBar.d.ts.map +1 -1
- package/dist/src/ScrollPane.d.ts +19 -0
- package/dist/src/ScrollPane.d.ts.map +1 -1
- package/dist/src/TapScrollCircle.d.ts +45 -0
- package/dist/src/TapScrollCircle.d.ts.map +1 -0
- package/dist/src/VirtualScroll.d.ts +3 -1
- package/dist/src/VirtualScroll.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/virtualscroll.css +1 -0
- package/dist/vite.config.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { twMerge as
|
|
3
|
-
var
|
|
1
|
+
import He, { forwardRef as Re, useState as le, useRef as H, useCallback as $, useImperativeHandle as Ae, useMemo as U, useEffect as ae, useReducer as $e, useLayoutEffect as be, useId as Ue } from "react";
|
|
2
|
+
import { twMerge as pe } from "tailwind-merge";
|
|
3
|
+
var Te = { exports: {} }, fe = {};
|
|
4
4
|
/**
|
|
5
5
|
* @license React
|
|
6
6
|
* react-jsx-runtime.production.js
|
|
@@ -10,29 +10,29 @@ var re = { exports: {} }, ee = {};
|
|
|
10
10
|
* This source code is licensed under the MIT license found in the
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
14
|
-
function
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
function r
|
|
19
|
-
var
|
|
20
|
-
if (a !== void 0 && (
|
|
13
|
+
var Ve;
|
|
14
|
+
function qe() {
|
|
15
|
+
if (Ve) return fe;
|
|
16
|
+
Ve = 1;
|
|
17
|
+
var c = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
18
|
+
function n(r, s, a) {
|
|
19
|
+
var i = null;
|
|
20
|
+
if (a !== void 0 && (i = "" + a), s.key !== void 0 && (i = "" + s.key), "key" in s) {
|
|
21
21
|
a = {};
|
|
22
|
-
for (var
|
|
23
|
-
|
|
22
|
+
for (var f in s)
|
|
23
|
+
f !== "key" && (a[f] = s[f]);
|
|
24
24
|
} else a = s;
|
|
25
25
|
return s = a.ref, {
|
|
26
|
-
$$typeof:
|
|
27
|
-
type:
|
|
28
|
-
key:
|
|
26
|
+
$$typeof: c,
|
|
27
|
+
type: r,
|
|
28
|
+
key: i,
|
|
29
29
|
ref: s !== void 0 ? s : null,
|
|
30
30
|
props: a
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return fe.Fragment = e, fe.jsx = n, fe.jsxs = n, fe;
|
|
34
34
|
}
|
|
35
|
-
var
|
|
35
|
+
var me = {};
|
|
36
36
|
/**
|
|
37
37
|
* @license React
|
|
38
38
|
* react-jsx-runtime.development.js
|
|
@@ -42,423 +42,874 @@ var te = {};
|
|
|
42
42
|
* This source code is licensed under the MIT license found in the
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
44
|
*/
|
|
45
|
-
var
|
|
46
|
-
function
|
|
47
|
-
return
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
50
|
-
if (typeof
|
|
51
|
-
return
|
|
52
|
-
if (typeof
|
|
53
|
-
switch (
|
|
54
|
-
case
|
|
45
|
+
var ke;
|
|
46
|
+
function Xe() {
|
|
47
|
+
return ke || (ke = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
48
|
+
function c(t) {
|
|
49
|
+
if (t == null) return null;
|
|
50
|
+
if (typeof t == "function")
|
|
51
|
+
return t.$$typeof === l ? null : t.displayName || t.name || null;
|
|
52
|
+
if (typeof t == "string") return t;
|
|
53
|
+
switch (t) {
|
|
54
|
+
case N:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case F:
|
|
57
57
|
return "Profiler";
|
|
58
|
-
case
|
|
58
|
+
case K:
|
|
59
59
|
return "StrictMode";
|
|
60
|
-
case
|
|
60
|
+
case k:
|
|
61
61
|
return "Suspense";
|
|
62
62
|
case C:
|
|
63
63
|
return "SuspenseList";
|
|
64
|
-
case
|
|
64
|
+
case se:
|
|
65
65
|
return "Activity";
|
|
66
66
|
}
|
|
67
|
-
if (typeof
|
|
68
|
-
switch (typeof
|
|
67
|
+
if (typeof t == "object")
|
|
68
|
+
switch (typeof t.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
|
+
), t.$$typeof) {
|
|
71
|
+
case ie:
|
|
72
72
|
return "Portal";
|
|
73
|
-
case
|
|
74
|
-
return (
|
|
75
|
-
case
|
|
76
|
-
return (
|
|
77
|
-
case
|
|
78
|
-
var
|
|
79
|
-
return
|
|
80
|
-
case
|
|
81
|
-
return
|
|
82
|
-
case
|
|
83
|
-
|
|
73
|
+
case Z:
|
|
74
|
+
return (t.displayName || "Context") + ".Provider";
|
|
75
|
+
case m:
|
|
76
|
+
return (t._context.displayName || "Context") + ".Consumer";
|
|
77
|
+
case A:
|
|
78
|
+
var o = t.render;
|
|
79
|
+
return t = t.displayName, t || (t = o.displayName || o.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
80
|
+
case B:
|
|
81
|
+
return o = t.displayName || null, o !== null ? o : c(t.type) || "Memo";
|
|
82
|
+
case X:
|
|
83
|
+
o = t._payload, t = t._init;
|
|
84
84
|
try {
|
|
85
|
-
return
|
|
85
|
+
return c(t(o));
|
|
86
86
|
} catch {
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
|
-
function e(
|
|
92
|
-
return "" +
|
|
91
|
+
function e(t) {
|
|
92
|
+
return "" + t;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function n(t) {
|
|
95
95
|
try {
|
|
96
|
-
e(
|
|
97
|
-
var
|
|
96
|
+
e(t);
|
|
97
|
+
var o = !1;
|
|
98
98
|
} catch {
|
|
99
|
-
|
|
99
|
+
o = !0;
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
var
|
|
104
|
-
return
|
|
105
|
-
|
|
101
|
+
if (o) {
|
|
102
|
+
o = console;
|
|
103
|
+
var T = o.error, y = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
104
|
+
return T.call(
|
|
105
|
+
o,
|
|
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
|
+
y
|
|
108
|
+
), e(t);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
function t
|
|
112
|
-
if (
|
|
113
|
-
if (typeof
|
|
111
|
+
function r(t) {
|
|
112
|
+
if (t === N) return "<>";
|
|
113
|
+
if (typeof t == "object" && t !== null && t.$$typeof === X)
|
|
114
114
|
return "<...>";
|
|
115
115
|
try {
|
|
116
|
-
var
|
|
117
|
-
return
|
|
116
|
+
var o = c(t);
|
|
117
|
+
return o ? "<" + o + ">" : "<...>";
|
|
118
118
|
} catch {
|
|
119
119
|
return "<...>";
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function s() {
|
|
123
|
-
var
|
|
124
|
-
return
|
|
123
|
+
var t = Y.A;
|
|
124
|
+
return t === null ? null : t.getOwner();
|
|
125
125
|
}
|
|
126
126
|
function a() {
|
|
127
127
|
return Error("react-stack-top-frame");
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
if (
|
|
131
|
-
var
|
|
132
|
-
if (
|
|
129
|
+
function i(t) {
|
|
130
|
+
if (j.call(t, "key")) {
|
|
131
|
+
var o = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
132
|
+
if (o && o.isReactWarning) return !1;
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return t.key !== void 0;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
function
|
|
138
|
-
|
|
136
|
+
function f(t, o) {
|
|
137
|
+
function T() {
|
|
138
|
+
E || (E = !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
|
+
o
|
|
141
141
|
));
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
get:
|
|
143
|
+
T.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
144
|
+
get: T,
|
|
145
145
|
configurable: !0
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
var
|
|
150
|
-
return
|
|
148
|
+
function p() {
|
|
149
|
+
var t = c(this.type);
|
|
150
|
+
return M[t] || (M[t] = !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
|
+
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
156
|
-
$$typeof:
|
|
157
|
-
type:
|
|
158
|
-
key:
|
|
159
|
-
props:
|
|
160
|
-
_owner:
|
|
161
|
-
}, (
|
|
154
|
+
function g(t, o, T, y, w, V, D, _) {
|
|
155
|
+
return T = V.ref, t = {
|
|
156
|
+
$$typeof: ne,
|
|
157
|
+
type: t,
|
|
158
|
+
key: o,
|
|
159
|
+
props: V,
|
|
160
|
+
_owner: w
|
|
161
|
+
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(t, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
|
-
get:
|
|
164
|
-
}) : Object.defineProperty(
|
|
163
|
+
get: p
|
|
164
|
+
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
165
165
|
configurable: !1,
|
|
166
166
|
enumerable: !1,
|
|
167
167
|
writable: !0,
|
|
168
168
|
value: 0
|
|
169
|
-
}), Object.defineProperty(
|
|
169
|
+
}), Object.defineProperty(t, "_debugInfo", {
|
|
170
170
|
configurable: !1,
|
|
171
171
|
enumerable: !1,
|
|
172
172
|
writable: !0,
|
|
173
173
|
value: null
|
|
174
|
-
}), Object.defineProperty(
|
|
174
|
+
}), Object.defineProperty(t, "_debugStack", {
|
|
175
175
|
configurable: !1,
|
|
176
176
|
enumerable: !1,
|
|
177
177
|
writable: !0,
|
|
178
|
-
value:
|
|
179
|
-
}), Object.defineProperty(
|
|
178
|
+
value: D
|
|
179
|
+
}), Object.defineProperty(t, "_debugTask", {
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
184
|
-
}), Object.freeze && (Object.freeze(
|
|
183
|
+
value: _
|
|
184
|
+
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
var R =
|
|
186
|
+
function x(t, o, T, y, w, V, D, _) {
|
|
187
|
+
var R = o.children;
|
|
188
188
|
if (R !== void 0)
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
|
|
189
|
+
if (y)
|
|
190
|
+
if (L(R)) {
|
|
191
|
+
for (y = 0; y < R.length; y++)
|
|
192
|
+
P(R[y]);
|
|
193
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 (
|
|
200
|
-
R =
|
|
201
|
-
var
|
|
202
|
-
return
|
|
198
|
+
else P(R);
|
|
199
|
+
if (j.call(o, "key")) {
|
|
200
|
+
R = c(t);
|
|
201
|
+
var G = Object.keys(o).filter(function(u) {
|
|
202
|
+
return u !== "key";
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
y = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", I[R + y] || (G = 0 < G.length ? "{" + G.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
|
-
|
|
211
|
+
y,
|
|
212
212
|
R,
|
|
213
|
-
|
|
213
|
+
G,
|
|
214
214
|
R
|
|
215
|
-
),
|
|
215
|
+
), I[R + y] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (R = null,
|
|
218
|
-
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
} else
|
|
222
|
-
return R &&
|
|
223
|
-
h,
|
|
224
|
-
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
225
|
-
), c(
|
|
226
|
-
n,
|
|
227
|
-
R,
|
|
217
|
+
if (R = null, T !== void 0 && (n(T), R = "" + T), i(o) && (n(o.key), R = "" + o.key), "key" in o) {
|
|
218
|
+
T = {};
|
|
219
|
+
for (var J in o)
|
|
220
|
+
J !== "key" && (T[J] = o[J]);
|
|
221
|
+
} else T = o;
|
|
222
|
+
return R && f(
|
|
228
223
|
T,
|
|
229
|
-
|
|
224
|
+
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
225
|
+
), g(
|
|
226
|
+
t,
|
|
227
|
+
R,
|
|
228
|
+
V,
|
|
229
|
+
w,
|
|
230
230
|
s(),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
T,
|
|
232
|
+
D,
|
|
233
|
+
_
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
237
|
-
typeof
|
|
236
|
+
function P(t) {
|
|
237
|
+
typeof t == "object" && t !== null && t.$$typeof === ne && t._store && (t._store.validated = 1);
|
|
238
238
|
}
|
|
239
|
-
var
|
|
239
|
+
var S = He, ne = Symbol.for("react.transitional.element"), ie = Symbol.for("react.portal"), N = Symbol.for("react.fragment"), K = Symbol.for("react.strict_mode"), F = Symbol.for("react.profiler"), m = Symbol.for("react.consumer"), Z = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), k = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), B = Symbol.for("react.memo"), X = Symbol.for("react.lazy"), se = Symbol.for("react.activity"), l = Symbol.for("react.client.reference"), Y = S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, L = Array.isArray, b = console.createTask ? console.createTask : function() {
|
|
240
240
|
return null;
|
|
241
241
|
};
|
|
242
|
-
|
|
243
|
-
react_stack_bottom_frame: function(
|
|
244
|
-
return
|
|
242
|
+
S = {
|
|
243
|
+
react_stack_bottom_frame: function(t) {
|
|
244
|
+
return t();
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
|
-
var
|
|
248
|
-
|
|
247
|
+
var E, M = {}, h = S.react_stack_bottom_frame.bind(
|
|
248
|
+
S,
|
|
249
249
|
a
|
|
250
|
-
)(),
|
|
251
|
-
|
|
252
|
-
var
|
|
253
|
-
return
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
250
|
+
)(), v = b(r(a)), I = {};
|
|
251
|
+
me.Fragment = N, me.jsx = function(t, o, T, y, w) {
|
|
252
|
+
var V = 1e4 > Y.recentlyCreatedOwnerStacks++;
|
|
253
|
+
return x(
|
|
254
|
+
t,
|
|
255
|
+
o,
|
|
256
|
+
T,
|
|
257
257
|
!1,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
y,
|
|
259
|
+
w,
|
|
260
|
+
V ? Error("react-stack-top-frame") : h,
|
|
261
|
+
V ? b(r(t)) : v
|
|
262
262
|
);
|
|
263
|
-
},
|
|
264
|
-
var
|
|
265
|
-
return
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
}, me.jsxs = function(t, o, T, y, w) {
|
|
264
|
+
var V = 1e4 > Y.recentlyCreatedOwnerStacks++;
|
|
265
|
+
return x(
|
|
266
|
+
t,
|
|
267
|
+
o,
|
|
268
|
+
T,
|
|
269
269
|
!0,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
y,
|
|
271
|
+
w,
|
|
272
|
+
V ? Error("react-stack-top-frame") : h,
|
|
273
|
+
V ? b(r(t)) : v
|
|
274
274
|
);
|
|
275
275
|
};
|
|
276
|
-
})()),
|
|
276
|
+
})()), me;
|
|
277
277
|
}
|
|
278
|
-
var
|
|
279
|
-
function
|
|
280
|
-
return
|
|
278
|
+
var Le;
|
|
279
|
+
function We() {
|
|
280
|
+
return Le || (Le = 1, process.env.NODE_ENV === "production" ? Te.exports = qe() : Te.exports = Xe()), Te.exports;
|
|
281
281
|
}
|
|
282
|
-
var
|
|
283
|
-
const
|
|
284
|
-
debug(
|
|
285
|
-
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${
|
|
282
|
+
var q = We();
|
|
283
|
+
const re = {
|
|
284
|
+
debug(c, ...e) {
|
|
285
|
+
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${c}`, ...e);
|
|
286
286
|
},
|
|
287
|
-
warn(
|
|
288
|
-
console.warn(`[VirtualScroll] ${
|
|
287
|
+
warn(c, ...e) {
|
|
288
|
+
console.warn(`[VirtualScroll] ${c}`, ...e);
|
|
289
289
|
},
|
|
290
|
-
error(
|
|
291
|
-
console.error(`[VirtualScroll] ${
|
|
290
|
+
error(c, ...e) {
|
|
291
|
+
console.error(`[VirtualScroll] ${c}`, ...e);
|
|
292
292
|
}
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
}, z = (c, e, n) => Math.min(n, Math.max(e, c)), Ie = {
|
|
294
|
+
active: !1,
|
|
295
|
+
offsetY: 0,
|
|
296
|
+
distance: 0,
|
|
297
|
+
direction: 0
|
|
298
|
+
}, Oe = 6, je = Re(({ onDragChange: c, className: e, maxVisualDistance: n = 160, size: r = 64, style: s, opacity: a = 1 }, i) => {
|
|
299
|
+
const [f, p] = le(Ie), g = H(null), x = H({ x: 0, y: 0 }), P = H(null), S = $(
|
|
300
|
+
(b, E = !1) => {
|
|
301
|
+
const { y: M } = x.current, h = b - M, v = Math.abs(h), I = v < Oe ? 0 : h < 0 ? -1 : 1, t = {
|
|
302
|
+
active: E || v >= Oe,
|
|
303
|
+
offsetY: h,
|
|
304
|
+
distance: v,
|
|
305
|
+
direction: I
|
|
306
|
+
};
|
|
307
|
+
p(t), c(t);
|
|
308
|
+
},
|
|
309
|
+
[c]
|
|
310
|
+
), ne = $(
|
|
311
|
+
(b = !1) => {
|
|
312
|
+
if (b && g.current !== null) {
|
|
313
|
+
const E = P.current;
|
|
314
|
+
E?.hasPointerCapture(g.current) && E.releasePointerCapture(g.current);
|
|
315
|
+
}
|
|
316
|
+
g.current = null, p(Ie), c(Ie);
|
|
317
|
+
},
|
|
318
|
+
[c]
|
|
319
|
+
), ie = $(
|
|
320
|
+
(b) => {
|
|
321
|
+
b.preventDefault(), b.stopPropagation();
|
|
322
|
+
const E = P.current ?? b.currentTarget, M = E.getBoundingClientRect();
|
|
323
|
+
x.current = {
|
|
324
|
+
x: M.left + M.width / 2,
|
|
325
|
+
y: M.top + M.height / 2
|
|
326
|
+
}, g.current = b.pointerId, E.setPointerCapture(b.pointerId), S(b.clientY, !0);
|
|
327
|
+
},
|
|
328
|
+
[S]
|
|
329
|
+
), N = $(
|
|
330
|
+
(b) => {
|
|
331
|
+
g.current === b.pointerId && (b.preventDefault(), S(b.clientY));
|
|
332
|
+
},
|
|
333
|
+
[S]
|
|
334
|
+
), K = $(
|
|
335
|
+
(b) => {
|
|
336
|
+
g.current === b.pointerId && (b.preventDefault(), b.stopPropagation(), ne(!0));
|
|
337
|
+
},
|
|
338
|
+
[ne]
|
|
339
|
+
);
|
|
340
|
+
Ae(
|
|
341
|
+
i,
|
|
342
|
+
() => ({
|
|
343
|
+
reset: () => {
|
|
344
|
+
ne(!0);
|
|
345
|
+
},
|
|
346
|
+
getElement: () => P.current
|
|
347
|
+
}),
|
|
348
|
+
[ne]
|
|
349
|
+
);
|
|
350
|
+
const F = U(() => Math.min(f.distance, n) / n, [f.distance, n]), m = U(() => r / 64, [r]), Z = U(() => 1 + F * 0.4, [F]), A = U(() => f.direction * F * 10 * m, [f.direction, F, m]), k = U(() => f.direction * F * 26 * m, [f.direction, F, m]), C = U(() => 22 * m, [m]), B = U(() => Math.max(2.5, 3 * m), [m]), X = U(() => 6 * m, [m]), se = U(() => 3 * m, [m]), l = U(() => Math.min(Math.max(a, 0), 1), [a]), Y = U(() => {
|
|
351
|
+
const b = {
|
|
352
|
+
...s,
|
|
353
|
+
width: r,
|
|
354
|
+
height: r,
|
|
355
|
+
transform: `translateY(${A}px)`
|
|
356
|
+
};
|
|
357
|
+
return b.opacity = l, b;
|
|
358
|
+
}, [l, A, r, s]), j = U(() => Math.abs(k) + X, [X, k]), L = U(() => k > 0 ? se : -Math.abs(k) - se, [se, k]);
|
|
359
|
+
return /* @__PURE__ */ q.jsxs(
|
|
360
|
+
"div",
|
|
361
|
+
{
|
|
362
|
+
ref: P,
|
|
363
|
+
className: pe(
|
|
364
|
+
"relative flex items-center justify-center touch-none select-none",
|
|
365
|
+
"transition-transform duration-100 ease-out",
|
|
366
|
+
e
|
|
367
|
+
),
|
|
368
|
+
style: Y,
|
|
369
|
+
onPointerDown: ie,
|
|
370
|
+
onPointerMove: N,
|
|
371
|
+
onPointerUp: K,
|
|
372
|
+
onPointerCancel: K,
|
|
373
|
+
role: "presentation",
|
|
374
|
+
children: [
|
|
375
|
+
/* @__PURE__ */ q.jsx(
|
|
376
|
+
"div",
|
|
377
|
+
{
|
|
378
|
+
className: "absolute inset-0 rounded-full border border-white/40 bg-gradient-to-br from-[#1d4ed8]/60 via-[#60a5fa]/55 to-[#bfdbfe]/40 shadow-md",
|
|
379
|
+
style: {
|
|
380
|
+
transform: `scaleY(${Z})`,
|
|
381
|
+
transition: f.active ? "transform 40ms ease-out" : "transform 200ms ease"
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ q.jsx(
|
|
386
|
+
"div",
|
|
387
|
+
{
|
|
388
|
+
className: "absolute left-1/2 top-1/2 h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/50 bg-white/85",
|
|
389
|
+
style: {
|
|
390
|
+
width: C,
|
|
391
|
+
height: C,
|
|
392
|
+
transform: `translate(-50%, calc(-50% + ${k * 0.3}px)) scale(${1 + F * 0.2})`,
|
|
393
|
+
transition: f.active ? "transform 40ms ease-out" : "transform 200ms ease"
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
),
|
|
397
|
+
/* @__PURE__ */ q.jsx(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
className: "absolute left-1/2 top-1/2 w-1 rounded-full bg-white/50",
|
|
401
|
+
style: {
|
|
402
|
+
width: B,
|
|
403
|
+
height: j,
|
|
404
|
+
transform: `translate(-50%, ${L}px)`,
|
|
405
|
+
opacity: F,
|
|
406
|
+
transition: f.active ? "height 40ms ease-out, opacity 60ms" : "height 200ms ease, opacity 120ms"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
});
|
|
414
|
+
je.displayName = "TapScrollCircle";
|
|
415
|
+
const De = (c, e, n) => {
|
|
416
|
+
const r = "touches" in c.nativeEvent, s = r ? c.nativeEvent.touches[0] : c.nativeEvent, a = (f) => {
|
|
417
|
+
r && f.cancelable && f.preventDefault();
|
|
418
|
+
const p = "touches" in f ? f.touches[0] : f;
|
|
297
419
|
e({
|
|
298
|
-
deltaX:
|
|
299
|
-
deltaY:
|
|
420
|
+
deltaX: p.clientX - s.clientX,
|
|
421
|
+
deltaY: p.clientY - s.clientY
|
|
300
422
|
});
|
|
301
|
-
},
|
|
302
|
-
|
|
423
|
+
}, i = () => {
|
|
424
|
+
r ? (document.removeEventListener("touchmove", a), document.removeEventListener("touchend", i)) : (document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", i)), n?.();
|
|
303
425
|
};
|
|
304
|
-
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
426
|
+
r ? (document.addEventListener("touchmove", a, { passive: !1 }), document.addEventListener("touchend", i)) : (document.addEventListener("mousemove", a), document.addEventListener("mouseup", i));
|
|
427
|
+
}, Pe = "virtualscroll:tap-scroll-cancel", Fe = 20, Ge = 250, Je = 60, Be = 20, Ke = 20, Ze = 220, Ne = { active: !1, offsetY: 0, distance: 0, direction: 0 }, _e = 2.2, Qe = 8, et = 120, ce = {
|
|
428
|
+
enabled: !0,
|
|
429
|
+
size: 64,
|
|
430
|
+
offsetX: -80,
|
|
431
|
+
offsetY: 0,
|
|
432
|
+
className: void 0,
|
|
433
|
+
maxVisualDistance: Ze,
|
|
434
|
+
opacity: 1
|
|
435
|
+
}, tt = (c) => {
|
|
436
|
+
if (!c || c <= 0)
|
|
437
|
+
return _e;
|
|
438
|
+
const e = Math.max(1, c), n = Math.log10(e), r = _e + n * Qe;
|
|
439
|
+
return z(r, _e, et);
|
|
440
|
+
}, rt = ({ contentSize: c, viewportSize: e, scrollPosition: n, onScroll: r, horizontal: s = !1, scrollBarWidth: a = 12, className: i, ariaControls: f, tapScrollCircleOptions: p, itemCount: g }) => {
|
|
441
|
+
const [x, P] = le(!1), [S, ne] = le(!1), ie = H(null), N = H(n), K = H(null), F = H(null), m = H(Ne), Z = H(null), A = H(null), k = H(null), C = U(() => {
|
|
442
|
+
const d = p?.maxSpeedMultiplier, O = typeof d == "number" ? d : tt(g);
|
|
443
|
+
return {
|
|
444
|
+
enabled: p?.enabled ?? ce.enabled,
|
|
445
|
+
size: p?.size ?? ce.size,
|
|
446
|
+
offsetX: p?.offsetX ?? ce.offsetX,
|
|
447
|
+
offsetY: p?.offsetY ?? ce.offsetY,
|
|
448
|
+
className: p?.className ?? ce.className,
|
|
449
|
+
maxVisualDistance: p?.maxVisualDistance ?? ce.maxVisualDistance,
|
|
450
|
+
maxSpeedMultiplier: O,
|
|
451
|
+
opacity: z(p?.opacity ?? ce.opacity, 0, 1)
|
|
452
|
+
};
|
|
453
|
+
}, [g, p]), {
|
|
454
|
+
enabled: B,
|
|
455
|
+
size: X,
|
|
456
|
+
offsetX: se,
|
|
457
|
+
offsetY: l,
|
|
458
|
+
className: Y,
|
|
459
|
+
maxVisualDistance: j,
|
|
460
|
+
maxSpeedMultiplier: L,
|
|
461
|
+
opacity: b
|
|
462
|
+
} = C, E = Math.max(j, 1), M = e / c, h = a, v = Math.max(e - h * 2, 0), I = M * v, t = Math.min(Math.max(Fe, I || 0), v || Fe), o = c - e, T = Math.max(v - t, 0), y = o <= 0 || T <= 0 ? 0 : n / o * T, w = c > e;
|
|
463
|
+
ae(() => {
|
|
464
|
+
N.current = n;
|
|
465
|
+
}, [n]), ae(() => {
|
|
466
|
+
ie.current && (x ? ie.current.style.backgroundColor = "#4F4F4F" : ie.current.style.backgroundColor = "#7F7F7F");
|
|
467
|
+
}, [x]);
|
|
468
|
+
const V = $(() => {
|
|
469
|
+
K.current !== null && (window.clearInterval(K.current), K.current = null), F.current !== null && (window.clearTimeout(F.current), F.current = null);
|
|
470
|
+
}, []), D = $(() => {
|
|
471
|
+
A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), k.current = null;
|
|
472
|
+
}, []), _ = $(() => {
|
|
473
|
+
m.current = { ...Ne }, ne(!1), Z.current?.reset(), D();
|
|
474
|
+
}, [D]), R = $(
|
|
475
|
+
(d) => {
|
|
476
|
+
const O = m.current;
|
|
477
|
+
if (!O.active || O.direction === 0) {
|
|
478
|
+
D();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (!w || o <= 0) {
|
|
482
|
+
D();
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const te = k.current ?? d, Q = Math.max((d - te) / 1e3, 0);
|
|
486
|
+
if (k.current = d, Q <= 0) {
|
|
487
|
+
A.current = window.requestAnimationFrame(R);
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
const Ee = (Math.min(O.distance, E) / E) ** 1.1, de = Math.max(e * 0.2, 40), we = Math.max(e * L, 1200), Se = de + (we - de) * Ee, xe = N.current, ye = z(xe + O.direction * Se * Q, 0, o);
|
|
491
|
+
if (ye === xe) {
|
|
492
|
+
D();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
N.current = ye, r?.(ye, xe), A.current = window.requestAnimationFrame(R);
|
|
496
|
+
},
|
|
497
|
+
[E, o, r, w, D, L, e]
|
|
498
|
+
), G = $(() => {
|
|
499
|
+
A.current === null && (k.current = null, A.current = window.requestAnimationFrame(R));
|
|
500
|
+
}, [R]);
|
|
501
|
+
ae(() => () => {
|
|
502
|
+
V(), D();
|
|
503
|
+
}, [V, D]);
|
|
504
|
+
const J = $(
|
|
505
|
+
(d) => {
|
|
506
|
+
m.current = d, ne(d.active), d.active && d.direction !== 0 ? G() : D();
|
|
507
|
+
},
|
|
508
|
+
[G, D]
|
|
509
|
+
);
|
|
510
|
+
ae(() => {
|
|
511
|
+
B || _();
|
|
512
|
+
}, [_, B]), ae(() => {
|
|
513
|
+
const d = (O) => {
|
|
514
|
+
const Q = O.detail?.paneId;
|
|
515
|
+
Q && f && Q !== f || _();
|
|
516
|
+
};
|
|
517
|
+
return window.addEventListener(Pe, d), () => {
|
|
518
|
+
window.removeEventListener(Pe, d);
|
|
519
|
+
};
|
|
520
|
+
}, [f, _]), ae(() => {
|
|
521
|
+
if (!B)
|
|
312
522
|
return;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
(
|
|
318
|
-
|
|
523
|
+
const d = (O) => {
|
|
524
|
+
if (!m.current.active)
|
|
525
|
+
return;
|
|
526
|
+
const te = O.target;
|
|
527
|
+
if (!(te instanceof Node)) {
|
|
528
|
+
_();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
Z.current?.getElement()?.contains(te) || _();
|
|
532
|
+
};
|
|
533
|
+
return document.addEventListener("pointerdown", d, !0), () => {
|
|
534
|
+
document.removeEventListener("pointerdown", d, !0);
|
|
535
|
+
};
|
|
536
|
+
}, [_, B]);
|
|
537
|
+
const u = (d) => {
|
|
538
|
+
if (!w || T <= 0 || o <= 0)
|
|
539
|
+
return 0;
|
|
540
|
+
const O = z(d, 0, T);
|
|
541
|
+
return z(O / T * o, 0, o);
|
|
542
|
+
}, ee = (d) => {
|
|
543
|
+
if (!w || o <= 0)
|
|
544
|
+
return;
|
|
545
|
+
const O = Math.max(Math.round(e / Ke), Be), te = N.current, Q = z(te + d * O, 0, o);
|
|
546
|
+
Q !== te && (N.current = Q, r?.(Q, te));
|
|
547
|
+
}, W = () => {
|
|
548
|
+
V();
|
|
549
|
+
}, oe = (d) => (O) => {
|
|
550
|
+
w && (O.preventDefault(), O.stopPropagation(), _(), V(), ee(d), F.current = window.setTimeout(() => {
|
|
551
|
+
K.current = window.setInterval(() => {
|
|
552
|
+
ee(d);
|
|
553
|
+
}, Je);
|
|
554
|
+
}, Ge));
|
|
555
|
+
}, ue = (d) => (O) => {
|
|
556
|
+
(O.key === "Enter" || O.key === " " || O.key === "Spacebar") && (O.preventDefault(), ee(d));
|
|
557
|
+
}, ge = (d) => {
|
|
558
|
+
if (!w || "button" in d && d.button !== 0 || d.ctrlKey)
|
|
559
|
+
return;
|
|
560
|
+
d.stopPropagation(), _();
|
|
561
|
+
const O = y;
|
|
562
|
+
P(!0), De(
|
|
563
|
+
d,
|
|
564
|
+
({ deltaX: te, deltaY: Q }) => {
|
|
565
|
+
r?.(u(O + (s ? te : Q)), y);
|
|
319
566
|
},
|
|
320
567
|
() => {
|
|
321
|
-
|
|
568
|
+
P(!1);
|
|
322
569
|
}
|
|
323
570
|
);
|
|
324
|
-
},
|
|
325
|
-
if (!
|
|
571
|
+
}, Me = (d) => {
|
|
572
|
+
if (!w || "button" in d && d.button !== 0 || d.ctrlKey)
|
|
326
573
|
return;
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
574
|
+
const te = "touches" in d.nativeEvent ? d.nativeEvent.touches[0] : d.nativeEvent, Q = s ? te.clientX : te.clientY, ve = d.currentTarget.getBoundingClientRect(), Ee = s ? Q - ve.left : Q - ve.top;
|
|
575
|
+
_();
|
|
576
|
+
const de = Ee - t / 2;
|
|
577
|
+
r?.(u(de), y), De(d, ({ deltaX: we, deltaY: Se }) => {
|
|
578
|
+
r?.(u(de + (s ? we : Se)), y);
|
|
330
579
|
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
"
|
|
349
|
-
"
|
|
350
|
-
"
|
|
351
|
-
"
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
580
|
+
}, Ye = U(() => z((S ? 1 : 0.8) * b, 0, 1), [S, b]), ze = U(() => {
|
|
581
|
+
const O = `calc(50% - ${X / 2}px + ${l}px)`;
|
|
582
|
+
return {
|
|
583
|
+
left: se,
|
|
584
|
+
top: O
|
|
585
|
+
};
|
|
586
|
+
}, [se, l, X]);
|
|
587
|
+
return /* @__PURE__ */ q.jsxs(
|
|
588
|
+
"div",
|
|
589
|
+
{
|
|
590
|
+
className: pe(
|
|
591
|
+
"group relative cursor-default select-none",
|
|
592
|
+
s ? "flex flex-row items-stretch" : "flex flex-col items-stretch",
|
|
593
|
+
i
|
|
594
|
+
),
|
|
595
|
+
style: {
|
|
596
|
+
[s ? "width" : "height"]: e,
|
|
597
|
+
[s ? "height" : "width"]: a,
|
|
598
|
+
backgroundColor: "white",
|
|
599
|
+
userSelect: "none",
|
|
600
|
+
position: "relative"
|
|
601
|
+
},
|
|
602
|
+
role: "scrollbar",
|
|
603
|
+
tabIndex: -1,
|
|
604
|
+
"aria-controls": f,
|
|
605
|
+
"aria-valuenow": n,
|
|
606
|
+
"aria-valuemin": 0,
|
|
607
|
+
"aria-valuemax": o,
|
|
608
|
+
"aria-orientation": s ? "horizontal" : "vertical",
|
|
609
|
+
children: [
|
|
610
|
+
!s && w && B && /* @__PURE__ */ q.jsx(
|
|
611
|
+
je,
|
|
612
|
+
{
|
|
613
|
+
ref: Z,
|
|
614
|
+
className: pe(
|
|
615
|
+
"pointer-events-auto absolute transition-opacity duration-150",
|
|
616
|
+
Y
|
|
617
|
+
),
|
|
618
|
+
size: X,
|
|
619
|
+
maxVisualDistance: E,
|
|
620
|
+
style: ze,
|
|
621
|
+
opacity: Ye,
|
|
622
|
+
onDragChange: J
|
|
623
|
+
}
|
|
624
|
+
),
|
|
625
|
+
/* @__PURE__ */ q.jsx(
|
|
626
|
+
"button",
|
|
627
|
+
{
|
|
628
|
+
type: "button",
|
|
629
|
+
className: "flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
630
|
+
style: {
|
|
631
|
+
[s ? "width" : "height"]: h,
|
|
632
|
+
[s ? "height" : "width"]: a,
|
|
633
|
+
backgroundColor: "#E0E0E0"
|
|
634
|
+
},
|
|
635
|
+
"aria-label": s ? "Scroll left" : "Scroll up",
|
|
636
|
+
onMouseDown: oe(-1),
|
|
637
|
+
onTouchStart: oe(-1),
|
|
638
|
+
onMouseUp: W,
|
|
639
|
+
onMouseLeave: W,
|
|
640
|
+
onTouchEnd: W,
|
|
641
|
+
onTouchCancel: W,
|
|
642
|
+
onKeyDown: ue(-1),
|
|
643
|
+
disabled: !w,
|
|
644
|
+
children: /* @__PURE__ */ q.jsx("span", { "aria-hidden": "true", children: s ? "◀" : "▲" })
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
/* @__PURE__ */ q.jsx(
|
|
355
648
|
"div",
|
|
356
649
|
{
|
|
357
|
-
className: "
|
|
650
|
+
className: "relative flex-1",
|
|
358
651
|
style: {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// 当たり判定を上下または左右に広げる
|
|
362
|
-
...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
652
|
+
backgroundColor: "#F5F5F5",
|
|
653
|
+
borderRadius: a / 2
|
|
363
654
|
},
|
|
364
|
-
onMouseDown:
|
|
365
|
-
onTouchStart:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"aria-valuenow": r,
|
|
369
|
-
"aria-valuemin": 0,
|
|
370
|
-
"aria-valuemax": p,
|
|
371
|
-
tabIndex: 0,
|
|
372
|
-
children: /* @__PURE__ */ D.jsx(
|
|
655
|
+
onMouseDown: Me,
|
|
656
|
+
onTouchStart: Me,
|
|
657
|
+
children: c > e && // スクロールバーのつまみの当たり判定を広げるためのラッパー
|
|
658
|
+
/* @__PURE__ */ q.jsx(
|
|
373
659
|
"div",
|
|
374
660
|
{
|
|
375
|
-
|
|
376
|
-
className: ae(
|
|
377
|
-
"absolute",
|
|
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
|
-
),
|
|
661
|
+
className: "group absolute",
|
|
380
662
|
style: {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
...s ? {
|
|
385
|
-
left: 0,
|
|
386
|
-
right: 0,
|
|
387
|
-
top: i ? -2 : 1.5,
|
|
388
|
-
bottom: i ? -2 : 1.5
|
|
389
|
-
} : {
|
|
390
|
-
top: 0,
|
|
391
|
-
bottom: 0,
|
|
392
|
-
left: i ? -2 : 1.5,
|
|
393
|
-
right: i ? -2 : 1.5
|
|
394
|
-
}
|
|
663
|
+
[s ? "width" : "height"]: t,
|
|
664
|
+
[s ? "left" : "top"]: y,
|
|
665
|
+
...s ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
395
666
|
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
667
|
+
onMouseDown: ge,
|
|
668
|
+
onTouchStart: ge,
|
|
669
|
+
role: "slider",
|
|
670
|
+
"aria-orientation": s ? "horizontal" : "vertical",
|
|
671
|
+
"aria-valuenow": n,
|
|
672
|
+
"aria-valuemin": 0,
|
|
673
|
+
"aria-valuemax": o,
|
|
674
|
+
tabIndex: 0,
|
|
675
|
+
children: /* @__PURE__ */ q.jsx(
|
|
676
|
+
"div",
|
|
677
|
+
{
|
|
678
|
+
ref: ie,
|
|
679
|
+
className: pe(
|
|
680
|
+
"absolute",
|
|
681
|
+
s ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${x ? "inset-y-[-2px]" : "group-active:inset-y-[-2px]"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${x ? "inset-x-[-2px]" : "group-active:inset-x-[-2px]"}`
|
|
682
|
+
),
|
|
683
|
+
style: {
|
|
684
|
+
backgroundColor: "#7F7F7F",
|
|
685
|
+
borderRadius: a - 1,
|
|
686
|
+
...s ? {
|
|
687
|
+
left: 0,
|
|
688
|
+
right: 0,
|
|
689
|
+
top: x ? -2 : 1.5,
|
|
690
|
+
bottom: x ? -2 : 1.5
|
|
691
|
+
} : {
|
|
692
|
+
top: 0,
|
|
693
|
+
bottom: 0,
|
|
694
|
+
left: x ? -2 : 1.5,
|
|
695
|
+
right: x ? -2 : 1.5
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
onMouseEnter: (d) => {
|
|
699
|
+
s ? (d.currentTarget.style.top = "-0.5px", d.currentTarget.style.bottom = "-0.5px") : (d.currentTarget.style.left = "-0.5px", d.currentTarget.style.right = "-0.5px"), x || (d.currentTarget.style.backgroundColor = "#5F5F5F");
|
|
700
|
+
},
|
|
701
|
+
onMouseLeave: (d) => {
|
|
702
|
+
s ? (d.currentTarget.style.top = x ? "-2px" : "1.5px", d.currentTarget.style.bottom = x ? "-2px" : "1.5px") : (d.currentTarget.style.left = x ? "-2px" : "1.5px", d.currentTarget.style.right = x ? "-2px" : "1.5px"), x || (d.currentTarget.style.backgroundColor = "#7F7F7F");
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
)
|
|
402
706
|
}
|
|
403
707
|
)
|
|
404
708
|
}
|
|
709
|
+
),
|
|
710
|
+
/* @__PURE__ */ q.jsx(
|
|
711
|
+
"button",
|
|
712
|
+
{
|
|
713
|
+
type: "button",
|
|
714
|
+
className: "flex items-center justify-center text-xs text-[#313131] transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
715
|
+
style: {
|
|
716
|
+
[s ? "width" : "height"]: h,
|
|
717
|
+
[s ? "height" : "width"]: a,
|
|
718
|
+
backgroundColor: "#E0E0E0"
|
|
719
|
+
},
|
|
720
|
+
"aria-label": s ? "Scroll right" : "Scroll down",
|
|
721
|
+
onMouseDown: oe(1),
|
|
722
|
+
onTouchStart: oe(1),
|
|
723
|
+
onMouseUp: W,
|
|
724
|
+
onMouseLeave: W,
|
|
725
|
+
onTouchEnd: W,
|
|
726
|
+
onTouchCancel: W,
|
|
727
|
+
onKeyDown: ue(1),
|
|
728
|
+
disabled: !w,
|
|
729
|
+
children: /* @__PURE__ */ q.jsx("span", { "aria-hidden": "true", children: s ? "▶" : "▼" })
|
|
730
|
+
}
|
|
405
731
|
)
|
|
406
|
-
|
|
407
|
-
|
|
732
|
+
]
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
}, he = {
|
|
736
|
+
maxVelocity: 6,
|
|
737
|
+
minVelocity: 0.02,
|
|
738
|
+
deceleration: 25e-4,
|
|
739
|
+
velocitySampleWindow: 90,
|
|
740
|
+
startVelocityThreshold: 0.04
|
|
741
|
+
}, nt = Re(({ children: c, contentSize: e, viewportSize: n, scrollBarWidth: r = 12, onScroll: s, className: a, style: i, background: f, tapScrollCircleOptions: p, inertiaOptions: g, itemCount: x }, P) => {
|
|
742
|
+
const S = H(0), [ne, ie] = $e((l) => l + 1, 0), N = H(null), K = H(null), F = H({
|
|
743
|
+
frame: null,
|
|
744
|
+
velocity: 0,
|
|
745
|
+
lastTimestamp: null
|
|
746
|
+
}), m = U(
|
|
747
|
+
() => ({
|
|
748
|
+
maxVelocity: g?.maxVelocity ?? he.maxVelocity,
|
|
749
|
+
minVelocity: g?.minVelocity ?? he.minVelocity,
|
|
750
|
+
deceleration: g?.deceleration ?? he.deceleration,
|
|
751
|
+
velocitySampleWindow: g?.velocitySampleWindow ?? he.velocitySampleWindow,
|
|
752
|
+
startVelocityThreshold: g?.startVelocityThreshold ?? he.startVelocityThreshold
|
|
753
|
+
}),
|
|
754
|
+
[g]
|
|
408
755
|
);
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (N.debug("[ScrollPane] scrollTo called", { newPosition: I, contentSize: e, viewportSize: r, currentIsScrollable: k, prevPosition: f }), !k) {
|
|
416
|
-
c.current !== 0 && (c.current = 0, s?.(0, f));
|
|
756
|
+
re.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: n, scrollBarWidth: r, className: a, style: i, tapScrollCircleOptions: p, inertiaOptions: g });
|
|
757
|
+
const Z = H({ contentSize: e, viewportSize: n }), A = U(() => e > n, [e, n]), k = $(
|
|
758
|
+
(l) => {
|
|
759
|
+
const { contentSize: Y, viewportSize: j } = Z.current, L = Y > j, b = S.current;
|
|
760
|
+
if (re.debug("[ScrollPane] scrollTo called", { newPosition: l, contentSize: Y, viewportSize: j, currentIsScrollable: L, prevPosition: b }), !L) {
|
|
761
|
+
S.current !== 0 && (S.current = 0, s?.(0, b));
|
|
417
762
|
return;
|
|
418
763
|
}
|
|
419
|
-
const
|
|
420
|
-
|
|
764
|
+
const E = typeof l == "function" ? l(S.current) : l, M = z(E, 0, Y - j);
|
|
765
|
+
S.current !== M && (S.current = M, s?.(M, b));
|
|
421
766
|
},
|
|
422
|
-
[s
|
|
767
|
+
[s]
|
|
768
|
+
), C = $(() => {
|
|
769
|
+
const l = F.current;
|
|
770
|
+
l.frame !== null && cancelAnimationFrame(l.frame), l.frame = null, l.velocity = 0, l.lastTimestamp = null;
|
|
771
|
+
}, []), B = $(
|
|
772
|
+
(l) => {
|
|
773
|
+
if (!A)
|
|
774
|
+
return;
|
|
775
|
+
const { maxVelocity: Y, minVelocity: j, deceleration: L, startVelocityThreshold: b } = m, E = z(l, -Y, Y);
|
|
776
|
+
if (Math.abs(E) < b)
|
|
777
|
+
return;
|
|
778
|
+
C(), F.current.velocity = E, F.current.lastTimestamp = null;
|
|
779
|
+
const M = (h) => {
|
|
780
|
+
const v = F.current;
|
|
781
|
+
if (v.lastTimestamp === null) {
|
|
782
|
+
v.lastTimestamp = h, v.frame = requestAnimationFrame(M);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const I = h - v.lastTimestamp;
|
|
786
|
+
if (v.lastTimestamp = h, I <= 0) {
|
|
787
|
+
v.frame = requestAnimationFrame(M);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
const t = v.velocity;
|
|
791
|
+
let o = t;
|
|
792
|
+
const T = L * I;
|
|
793
|
+
t > 0 ? o = Math.max(0, t - T) : t < 0 && (o = Math.min(0, t + T));
|
|
794
|
+
const w = (t + o) / 2 * I, V = S.current;
|
|
795
|
+
w !== 0 && k((u) => u + w);
|
|
796
|
+
const D = S.current, { contentSize: _, viewportSize: R } = Z.current, G = Math.max(_ - R, 0);
|
|
797
|
+
v.velocity = o;
|
|
798
|
+
const J = D === V || D <= 0 && o <= 0 || D >= G && o >= 0;
|
|
799
|
+
if (Math.abs(o) < j || J) {
|
|
800
|
+
C();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
v.frame = requestAnimationFrame(M);
|
|
804
|
+
};
|
|
805
|
+
F.current.frame = requestAnimationFrame(M);
|
|
806
|
+
},
|
|
807
|
+
[A, m, k, C]
|
|
423
808
|
);
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
809
|
+
be(() => {
|
|
810
|
+
Z.current = { contentSize: e, viewportSize: n };
|
|
811
|
+
}, [e, n]), be(() => {
|
|
812
|
+
if (A) {
|
|
813
|
+
re.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: n, scrollPosition: S.current });
|
|
814
|
+
const l = z(e - n, 0, e);
|
|
815
|
+
S.current > l && k(l);
|
|
429
816
|
} else
|
|
430
|
-
|
|
431
|
-
}, [
|
|
432
|
-
const
|
|
433
|
-
if (!
|
|
817
|
+
k(0);
|
|
818
|
+
}, [A, k, e, n]), ae(() => {
|
|
819
|
+
const l = (j) => {
|
|
820
|
+
if (!A)
|
|
434
821
|
return;
|
|
435
|
-
|
|
436
|
-
let
|
|
437
|
-
|
|
438
|
-
},
|
|
439
|
-
return
|
|
440
|
-
|
|
822
|
+
j.preventDefault(), C();
|
|
823
|
+
let L = j.deltaY;
|
|
824
|
+
j.deltaMode === 1 ? L *= 16 : j.deltaMode === 2 && (L *= n), re.debug("[ScrollPane] wheel event", { deltaY: L, scrollPosition: S.current }), k((b) => b + L);
|
|
825
|
+
}, Y = N.current;
|
|
826
|
+
return Y && Y.addEventListener("wheel", l, { passive: !1 }), () => {
|
|
827
|
+
Y && Y.removeEventListener("wheel", l);
|
|
441
828
|
};
|
|
442
|
-
}, [
|
|
443
|
-
|
|
829
|
+
}, [A, k, C, n]), Ae(
|
|
830
|
+
P,
|
|
444
831
|
() => ({
|
|
445
|
-
scrollTo:
|
|
446
|
-
getScrollPosition: () =>
|
|
832
|
+
scrollTo: k,
|
|
833
|
+
getScrollPosition: () => S.current,
|
|
447
834
|
getContentSize: () => e,
|
|
448
|
-
getViewportSize: () =>
|
|
835
|
+
getViewportSize: () => n
|
|
449
836
|
}),
|
|
450
|
-
[
|
|
837
|
+
[k, e, n]
|
|
451
838
|
);
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
l(c.current)
|
|
839
|
+
const X = Ue(), se = U(() => /* @__PURE__ */ q.jsxs("div", { ref: N, className: pe("flex", a), style: i, children: [
|
|
840
|
+
/* @__PURE__ */ q.jsxs("div", { ref: K, className: "relative h-full flex-1 overflow-hidden", style: { height: n, touchAction: "none" }, id: X, children: [
|
|
841
|
+
f,
|
|
842
|
+
c(S.current)
|
|
457
843
|
] }),
|
|
458
|
-
|
|
459
|
-
|
|
844
|
+
A && /* @__PURE__ */ q.jsx(
|
|
845
|
+
rt,
|
|
846
|
+
{
|
|
847
|
+
contentSize: e,
|
|
848
|
+
viewportSize: n,
|
|
849
|
+
scrollPosition: S.current,
|
|
850
|
+
onScroll: k,
|
|
851
|
+
scrollBarWidth: r,
|
|
852
|
+
ariaControls: X,
|
|
853
|
+
tapScrollCircleOptions: p,
|
|
854
|
+
itemCount: x
|
|
855
|
+
}
|
|
856
|
+
)
|
|
857
|
+
] }), [c, e, n, r, a, i, A, k, X, f, p, x]);
|
|
858
|
+
return ae(() => {
|
|
859
|
+
const l = K.current;
|
|
860
|
+
if (!l)
|
|
861
|
+
return;
|
|
862
|
+
const Y = 6, j = "input, textarea, select, button, a[href], [role='button']";
|
|
863
|
+
let L = null, b = 0, E = 0, M = !1, h = !1, v = !1, I = null, t = [];
|
|
864
|
+
const o = () => {
|
|
865
|
+
L = null, b = 0, E = 0, M = !1, h = !1, t = [];
|
|
866
|
+
}, T = (u) => {
|
|
867
|
+
const ee = performance.now();
|
|
868
|
+
t.push({ clientY: u, time: ee }), t = t.filter((W) => ee - W.time <= m.velocitySampleWindow);
|
|
869
|
+
}, y = (u) => u instanceof HTMLElement ? u.closest("[data-scrollpane-ignore-drag='true']") !== null : !1, w = (u) => u instanceof HTMLElement ? u.closest(j) !== null : !1, V = (u) => {
|
|
870
|
+
v && (u.preventDefault(), u.stopPropagation(), v = !1);
|
|
871
|
+
}, D = (u) => {
|
|
872
|
+
M || (M = !0, h = !1, v = !0, l.hasPointerCapture(u.pointerId) || l.setPointerCapture(u.pointerId), T(u.clientY));
|
|
873
|
+
}, _ = (u) => {
|
|
874
|
+
if (L !== u.pointerId)
|
|
875
|
+
return;
|
|
876
|
+
if (!M) {
|
|
877
|
+
const oe = Math.abs(u.clientY - b);
|
|
878
|
+
if (h && oe < Y)
|
|
879
|
+
return;
|
|
880
|
+
D(u);
|
|
881
|
+
}
|
|
882
|
+
if (!M)
|
|
883
|
+
return;
|
|
884
|
+
T(u.clientY);
|
|
885
|
+
const ee = u.clientY - b, W = E - ee;
|
|
886
|
+
k(W), u.cancelable && u.preventDefault();
|
|
887
|
+
}, R = (u) => {
|
|
888
|
+
if (L !== u.pointerId)
|
|
889
|
+
return;
|
|
890
|
+
M && v && u.cancelable && (u.preventDefault(), u.stopPropagation()), l.hasPointerCapture(u.pointerId) && l.releasePointerCapture(u.pointerId);
|
|
891
|
+
let ee = 0;
|
|
892
|
+
if (M && t.length >= 2) {
|
|
893
|
+
const W = t[t.length - 1], oe = t.find((ue) => W.time - ue.time <= m.velocitySampleWindow) ?? t[0];
|
|
894
|
+
if (W && oe && W.time !== oe.time) {
|
|
895
|
+
const ue = W.clientY - oe.clientY, ge = W.time - oe.time;
|
|
896
|
+
ee = -(ue / ge);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
o(), I !== null && window.clearTimeout(I), v && (I = window.setTimeout(() => {
|
|
900
|
+
v = !1, I = null;
|
|
901
|
+
}, 0)), Math.abs(ee) >= m.startVelocityThreshold && B(ee);
|
|
902
|
+
}, G = (u) => {
|
|
903
|
+
A && (u.button !== 0 && u.pointerType === "mouse" || u.ctrlKey || u.metaKey || u.altKey || y(u.target) || (window.dispatchEvent(new CustomEvent(Pe, { detail: { paneId: X } })), C(), L = u.pointerId, b = u.clientY, E = S.current, h = w(u.target), M = !1, v = !1, t = [], h || (v = !0, D(u), T(u.clientY), u.cancelable && u.preventDefault())));
|
|
904
|
+
}, J = (u) => {
|
|
905
|
+
L === u.pointerId && (v = !1, l.hasPointerCapture(u.pointerId) && l.releasePointerCapture(u.pointerId), I !== null && (window.clearTimeout(I), I = null), o());
|
|
906
|
+
};
|
|
907
|
+
return l.addEventListener("click", V, !0), l.addEventListener("pointerdown", G, { passive: !1 }), l.addEventListener("pointermove", _, { passive: !1 }), l.addEventListener("pointerup", R), l.addEventListener("pointercancel", J), window.addEventListener("pointermove", _, { passive: !1 }), window.addEventListener("pointerup", R), window.addEventListener("pointercancel", J), () => {
|
|
908
|
+
l.removeEventListener("click", V, !0), l.removeEventListener("pointerdown", G), l.removeEventListener("pointermove", _), l.removeEventListener("pointerup", R), l.removeEventListener("pointercancel", J), window.removeEventListener("pointermove", _), window.removeEventListener("pointerup", R), window.removeEventListener("pointercancel", J), L !== null && l.hasPointerCapture(L) && l.releasePointerCapture(L), I !== null && window.clearTimeout(I), C();
|
|
909
|
+
};
|
|
910
|
+
}, [X, A, m, k, B, C]), se;
|
|
460
911
|
});
|
|
461
|
-
class
|
|
912
|
+
class st {
|
|
462
913
|
/**
|
|
463
914
|
* @private
|
|
464
915
|
* @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
|
|
@@ -498,8 +949,8 @@ class Re {
|
|
|
498
949
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
499
950
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
500
951
|
*/
|
|
501
|
-
constructor(e,
|
|
502
|
-
this.reset(e,
|
|
952
|
+
constructor(e, n, r) {
|
|
953
|
+
this.reset(e, n, r);
|
|
503
954
|
}
|
|
504
955
|
/**
|
|
505
956
|
* @method reset
|
|
@@ -509,26 +960,26 @@ class Re {
|
|
|
509
960
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
510
961
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
511
962
|
*/
|
|
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 =
|
|
515
|
-
const a =
|
|
963
|
+
reset(e, n, r) {
|
|
964
|
+
if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof n == "function") {
|
|
965
|
+
if (this.valueFn = n, this.size > 0) {
|
|
966
|
+
const a = r?.sampleRange ?? {
|
|
516
967
|
from: 0,
|
|
517
968
|
to: Math.min(99, this.size - 1)
|
|
518
|
-
}, { mode:
|
|
519
|
-
if (this.baseValue =
|
|
520
|
-
for (let
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
969
|
+
}, { mode: i, materializedValues: f } = this._calculateMode(a.from, a.to);
|
|
970
|
+
if (this.baseValue = i, r?.materialize)
|
|
971
|
+
for (let p = 0; p < f.length; p++) {
|
|
972
|
+
const g = f[p], x = a.from + p;
|
|
973
|
+
if (x >= this.size)
|
|
523
974
|
break;
|
|
524
|
-
const
|
|
525
|
-
this.deltas.set(
|
|
975
|
+
const P = g - this.baseValue;
|
|
976
|
+
this.deltas.set(x, P), this._updateTree(x, P);
|
|
526
977
|
}
|
|
527
978
|
} else
|
|
528
979
|
this.baseValue = 0;
|
|
529
980
|
this.total = this.getTotal();
|
|
530
981
|
} else
|
|
531
|
-
this.valueFn = void 0, this.baseValue =
|
|
982
|
+
this.valueFn = void 0, this.baseValue = n, this.total = this.baseValue * this.size;
|
|
532
983
|
}
|
|
533
984
|
/**
|
|
534
985
|
* @method setValueFn
|
|
@@ -548,33 +999,33 @@ class Re {
|
|
|
548
999
|
* @param {number} to - The ending index of the range (inclusive).
|
|
549
1000
|
* @returns {{ mode: number; materializedValues: number[] }} An object containing the calculated mode and the array of generated values.
|
|
550
1001
|
*/
|
|
551
|
-
_calculateMode(e,
|
|
1002
|
+
_calculateMode(e, n) {
|
|
552
1003
|
if (!this.valueFn)
|
|
553
1004
|
return { mode: 0, materializedValues: [] };
|
|
554
|
-
const
|
|
555
|
-
for (let
|
|
556
|
-
|
|
557
|
-
const s = [...
|
|
558
|
-
if (
|
|
1005
|
+
const r = [];
|
|
1006
|
+
for (let g = e; g <= n && !(g >= this.size); g++)
|
|
1007
|
+
r.push(this.valueFn(g));
|
|
1008
|
+
const s = [...r];
|
|
1009
|
+
if (r.length === 0)
|
|
559
1010
|
return { mode: 0, materializedValues: [] };
|
|
560
|
-
|
|
561
|
-
const a = Math.floor(
|
|
562
|
-
let
|
|
563
|
-
|
|
564
|
-
const
|
|
565
|
-
let
|
|
566
|
-
for (const
|
|
567
|
-
const
|
|
568
|
-
|
|
1011
|
+
r.sort((g, x) => g - x);
|
|
1012
|
+
const a = Math.floor(r.length / 2);
|
|
1013
|
+
let i;
|
|
1014
|
+
r.length % 2 === 0 ? i = Math.floor((r[a - 1] + r[a]) / 2) : i = r[a];
|
|
1015
|
+
const f = /* @__PURE__ */ new Map();
|
|
1016
|
+
let p = 0;
|
|
1017
|
+
for (const g of r) {
|
|
1018
|
+
const x = (f.get(g) ?? 0) + 1;
|
|
1019
|
+
f.set(g, x), x > p && (p = x);
|
|
569
1020
|
}
|
|
570
|
-
if (
|
|
571
|
-
const
|
|
572
|
-
for (const [
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
|
|
1021
|
+
if (p > 1) {
|
|
1022
|
+
const g = [];
|
|
1023
|
+
for (const [P, S] of f.entries())
|
|
1024
|
+
S === p && g.push(P);
|
|
1025
|
+
const x = g.reduce((P, S) => P + S, 0);
|
|
1026
|
+
i = Math.floor(x / g.length);
|
|
576
1027
|
}
|
|
577
|
-
return { mode:
|
|
1028
|
+
return { mode: i, materializedValues: s };
|
|
578
1029
|
}
|
|
579
1030
|
/**
|
|
580
1031
|
* @method update
|
|
@@ -583,8 +1034,8 @@ class Re {
|
|
|
583
1034
|
* @param {number} index - The 0-based index to update.
|
|
584
1035
|
* @param {number} value - The new value.
|
|
585
1036
|
*/
|
|
586
|
-
update(e,
|
|
587
|
-
return this.updates([{ index: e, value:
|
|
1037
|
+
update(e, n) {
|
|
1038
|
+
return this.updates([{ index: e, value: n }]);
|
|
588
1039
|
}
|
|
589
1040
|
/**
|
|
590
1041
|
* @method updates
|
|
@@ -593,15 +1044,15 @@ class Re {
|
|
|
593
1044
|
* @param {{ index: number; value: number }[]} updates - An array of updates, each with an index and the new value.
|
|
594
1045
|
*/
|
|
595
1046
|
updates(e) {
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
throw new Error(`Index ${
|
|
1047
|
+
const n = e.map(({ index: r, value: s }) => {
|
|
1048
|
+
if (r < 0 || r >= this.size)
|
|
1049
|
+
throw new Error(`Index ${r} out of bounds`);
|
|
599
1050
|
if (s < 0)
|
|
600
1051
|
throw new Error("Value cannot be negative.");
|
|
601
|
-
const a = this.deltas.has(
|
|
602
|
-
return { index:
|
|
603
|
-
}).filter((
|
|
604
|
-
return
|
|
1052
|
+
const a = this.deltas.has(r) ? (this.deltas.get(r) ?? 0) + this.baseValue : this.baseValue, i = s - a;
|
|
1053
|
+
return { index: r, change: i };
|
|
1054
|
+
}).filter((r) => r.change !== 0);
|
|
1055
|
+
return n.length > 0 ? this.updateDeltas(n) : this.total;
|
|
605
1056
|
}
|
|
606
1057
|
/**
|
|
607
1058
|
* @method updateDelta
|
|
@@ -610,8 +1061,8 @@ class Re {
|
|
|
610
1061
|
* @param {number} index - The 0-based index to update.
|
|
611
1062
|
* @param {number} change - The value to add to the delta at the given index.
|
|
612
1063
|
*/
|
|
613
|
-
updateDelta(e,
|
|
614
|
-
return this.updateDeltas([{ index: e, change:
|
|
1064
|
+
updateDelta(e, n) {
|
|
1065
|
+
return this.updateDeltas([{ index: e, change: n }]);
|
|
615
1066
|
}
|
|
616
1067
|
/**
|
|
617
1068
|
* @method updateDeltas
|
|
@@ -620,11 +1071,11 @@ class Re {
|
|
|
620
1071
|
* @param {{ index: number; change: number }[]} updates - An array of updates, each with an index and the change to apply.
|
|
621
1072
|
*/
|
|
622
1073
|
updateDeltas(e) {
|
|
623
|
-
for (const { index:
|
|
624
|
-
if (
|
|
625
|
-
throw new Error(`Index ${
|
|
626
|
-
const s = this.deltas.get(
|
|
627
|
-
this.deltas.set(
|
|
1074
|
+
for (const { index: n, change: r } of e) {
|
|
1075
|
+
if (n < 0 || n >= this.size)
|
|
1076
|
+
throw new Error(`Index ${n} out of bounds`);
|
|
1077
|
+
const s = this.deltas.get(n) ?? 0;
|
|
1078
|
+
this.deltas.set(n, s + r), this._updateTree(n, r);
|
|
628
1079
|
}
|
|
629
1080
|
return this.total;
|
|
630
1081
|
}
|
|
@@ -636,13 +1087,13 @@ class Re {
|
|
|
636
1087
|
* @param {number} index - The 0-based index that changed.
|
|
637
1088
|
* @param {number} change - The change in value.
|
|
638
1089
|
*/
|
|
639
|
-
_updateTree(e,
|
|
640
|
-
if (
|
|
1090
|
+
_updateTree(e, n) {
|
|
1091
|
+
if (n === 0)
|
|
641
1092
|
return;
|
|
642
|
-
let
|
|
643
|
-
for (;
|
|
644
|
-
this.tree.set(
|
|
645
|
-
this.total !== void 0 && (this.total +=
|
|
1093
|
+
let r = e + 1;
|
|
1094
|
+
for (; r <= this.size; )
|
|
1095
|
+
this.tree.set(r, (this.tree.get(r) ?? 0) + n), r += r & -r;
|
|
1096
|
+
this.total !== void 0 && (this.total += n);
|
|
646
1097
|
}
|
|
647
1098
|
/**
|
|
648
1099
|
* @private
|
|
@@ -652,12 +1103,12 @@ class Re {
|
|
|
652
1103
|
* @param {number} index - The 0-based index to materialize.
|
|
653
1104
|
* @param {boolean} [updateTree=true] - Whether to update the Fenwick tree after materialization.
|
|
654
1105
|
*/
|
|
655
|
-
_materialize(e,
|
|
1106
|
+
_materialize(e, n = !0) {
|
|
656
1107
|
if (this.valueFn) {
|
|
657
|
-
const
|
|
658
|
-
if (a !==
|
|
659
|
-
const
|
|
660
|
-
this._updateTree(e,
|
|
1108
|
+
const r = this.deltas.get(e) ?? 0, a = this.valueFn(e) - this.baseValue;
|
|
1109
|
+
if (a !== r && (this.deltas.set(e, a), n)) {
|
|
1110
|
+
const i = a - r;
|
|
1111
|
+
this._updateTree(e, i);
|
|
661
1112
|
}
|
|
662
1113
|
}
|
|
663
1114
|
}
|
|
@@ -674,26 +1125,26 @@ class Re {
|
|
|
674
1125
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
675
1126
|
* @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
1127
|
*/
|
|
677
|
-
prefixSum(e,
|
|
1128
|
+
prefixSum(e, n) {
|
|
678
1129
|
if (e < 0)
|
|
679
1130
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
680
|
-
const
|
|
1131
|
+
const r = z(e, 0, this.size - 1), s = n?.materializeOption;
|
|
681
1132
|
if (s?.materialize && this.valueFn) {
|
|
682
1133
|
if (s.ranges)
|
|
683
|
-
for (const
|
|
684
|
-
const
|
|
685
|
-
for (let
|
|
686
|
-
this._materialize(
|
|
1134
|
+
for (const p of s.ranges) {
|
|
1135
|
+
const g = p.from, x = Math.min(p.to, this.size - 1);
|
|
1136
|
+
for (let P = g; P <= x; P++)
|
|
1137
|
+
this._materialize(P);
|
|
687
1138
|
}
|
|
688
|
-
this._materialize(
|
|
1139
|
+
this._materialize(r);
|
|
689
1140
|
}
|
|
690
|
-
let a = 0,
|
|
691
|
-
for (;
|
|
692
|
-
const
|
|
693
|
-
a +=
|
|
1141
|
+
let a = 0, i = r + 1;
|
|
1142
|
+
for (; i > 0; ) {
|
|
1143
|
+
const p = this.tree.get(i) ?? 0;
|
|
1144
|
+
a += p, i -= i & -i;
|
|
694
1145
|
}
|
|
695
|
-
const
|
|
696
|
-
return { cumulative: a + this.baseValue * (
|
|
1146
|
+
const f = s?.materialize ? this.get(r) : (this.deltas.get(r) || 0) + this.baseValue;
|
|
1147
|
+
return { cumulative: a + this.baseValue * (r + 1), total: this.total, currentValue: f, safeIndex: r };
|
|
697
1148
|
}
|
|
698
1149
|
/**
|
|
699
1150
|
* @method get
|
|
@@ -708,18 +1159,18 @@ class Re {
|
|
|
708
1159
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
709
1160
|
* @returns {number} The value at the given index.
|
|
710
1161
|
*/
|
|
711
|
-
get(e,
|
|
1162
|
+
get(e, n) {
|
|
712
1163
|
if (e < 0 || e >= this.size)
|
|
713
1164
|
throw new Error("Index out of bounds");
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
if (
|
|
717
|
-
for (const s of
|
|
718
|
-
const a = s.from,
|
|
719
|
-
for (let
|
|
720
|
-
this._materialize(
|
|
1165
|
+
const r = n?.materializeOption;
|
|
1166
|
+
if (r?.materialize && this.valueFn)
|
|
1167
|
+
if (r.ranges) {
|
|
1168
|
+
for (const s of r.ranges) {
|
|
1169
|
+
const a = s.from, i = Math.min(s.to, this.size - 1);
|
|
1170
|
+
for (let f = a; f <= i; f++)
|
|
1171
|
+
this._materialize(f);
|
|
721
1172
|
}
|
|
722
|
-
e >=
|
|
1173
|
+
e >= r.ranges[0].from && e <= r.ranges[r.ranges.length - 1].to && this._materialize(e);
|
|
723
1174
|
} else
|
|
724
1175
|
this._materialize(e);
|
|
725
1176
|
return (this.deltas.get(e) ?? 0) + this.baseValue;
|
|
@@ -737,21 +1188,21 @@ class Re {
|
|
|
737
1188
|
* @returns {number} The total sum of all values.
|
|
738
1189
|
*/
|
|
739
1190
|
getTotal(e) {
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
for (const
|
|
743
|
-
const s =
|
|
744
|
-
for (let
|
|
745
|
-
this._materialize(
|
|
1191
|
+
const n = e?.materializeOption;
|
|
1192
|
+
if (n?.materialize && this.valueFn && n.ranges)
|
|
1193
|
+
for (const r of n.ranges) {
|
|
1194
|
+
const s = r.from, a = Math.min(r.to, this.size - 1);
|
|
1195
|
+
for (let i = s; i <= a; i++)
|
|
1196
|
+
this._materialize(i);
|
|
746
1197
|
}
|
|
747
1198
|
if (this.total === void 0)
|
|
748
1199
|
if (this.size === 0)
|
|
749
1200
|
this.total = 0;
|
|
750
1201
|
else {
|
|
751
|
-
let
|
|
1202
|
+
let r = this.baseValue * this.size;
|
|
752
1203
|
for (const s of this.deltas.values())
|
|
753
|
-
|
|
754
|
-
this.total =
|
|
1204
|
+
r += s;
|
|
1205
|
+
this.total = r, console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
|
|
755
1206
|
}
|
|
756
1207
|
return this.total;
|
|
757
1208
|
}
|
|
@@ -768,16 +1219,16 @@ class Re {
|
|
|
768
1219
|
this.reset(this.size, (a) => s(a), { materialize: !0 });
|
|
769
1220
|
return;
|
|
770
1221
|
}
|
|
771
|
-
const
|
|
772
|
-
let
|
|
1222
|
+
const n = /* @__PURE__ */ new Map();
|
|
1223
|
+
let r = this.baseValue * this.size;
|
|
773
1224
|
for (const [s, a] of this.deltas.entries()) {
|
|
774
|
-
if (
|
|
1225
|
+
if (r += a, a === 0)
|
|
775
1226
|
continue;
|
|
776
|
-
let
|
|
777
|
-
for (;
|
|
778
|
-
|
|
1227
|
+
let i = s + 1;
|
|
1228
|
+
for (; i <= this.size; )
|
|
1229
|
+
n.set(i, (n.get(i) ?? 0) + a), i += i & -i;
|
|
779
1230
|
}
|
|
780
|
-
this.tree =
|
|
1231
|
+
this.tree = n, this.total = r;
|
|
781
1232
|
}
|
|
782
1233
|
/**
|
|
783
1234
|
* @method calculateAccumulatedError
|
|
@@ -789,8 +1240,8 @@ class Re {
|
|
|
789
1240
|
if (this.total === void 0)
|
|
790
1241
|
return 0;
|
|
791
1242
|
let e = this.baseValue * this.size;
|
|
792
|
-
for (const
|
|
793
|
-
e +=
|
|
1243
|
+
for (const n of this.deltas.values())
|
|
1244
|
+
e += n;
|
|
794
1245
|
return this.total - e;
|
|
795
1246
|
}
|
|
796
1247
|
/**
|
|
@@ -800,11 +1251,11 @@ class Re {
|
|
|
800
1251
|
* @param {number} newSize - The new size of the tree.
|
|
801
1252
|
*/
|
|
802
1253
|
changeSize(e) {
|
|
803
|
-
const
|
|
804
|
-
if (e !==
|
|
805
|
-
if (e <
|
|
806
|
-
for (const
|
|
807
|
-
|
|
1254
|
+
const n = this.size;
|
|
1255
|
+
if (e !== n) {
|
|
1256
|
+
if (e < n)
|
|
1257
|
+
for (const r of this.deltas.keys())
|
|
1258
|
+
r >= e && this.deltas.delete(r);
|
|
808
1259
|
this.size = e, this.rebuildTree(), console.assert(this.prefixSum(this.getSize() - 1).cumulative === this.prefixSum(this.getSize() - 1).total, "Inconsistent Fenwick Tree state");
|
|
809
1260
|
}
|
|
810
1261
|
}
|
|
@@ -830,15 +1281,15 @@ class Re {
|
|
|
830
1281
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
831
1282
|
* @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
1283
|
*/
|
|
833
|
-
findIndexAtOrAfter(e,
|
|
1284
|
+
findIndexAtOrAfter(e, n) {
|
|
834
1285
|
if (this.size === 0)
|
|
835
1286
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
836
|
-
let
|
|
837
|
-
for (;
|
|
838
|
-
const
|
|
839
|
-
|
|
1287
|
+
let r = 0, s = this.size - 1, a = -1, i, f = this.total;
|
|
1288
|
+
for (; r <= s; ) {
|
|
1289
|
+
const p = Math.floor((r + s) / 2);
|
|
1290
|
+
i = this.prefixSum(p, n), f = i.total, i.cumulative >= e ? (a = p, s = p - 1) : r = p + 1;
|
|
840
1291
|
}
|
|
841
|
-
return { index: a, total:
|
|
1292
|
+
return { index: a, total: f, cumulative: i?.cumulative, currentValue: i?.currentValue, safeIndex: i?.safeIndex };
|
|
842
1293
|
}
|
|
843
1294
|
/**
|
|
844
1295
|
* @method findIndexAtOrBefore
|
|
@@ -853,161 +1304,175 @@ class Re {
|
|
|
853
1304
|
* @param {number} options.materializeOption.ranges.to - The ending index of the range.
|
|
854
1305
|
* @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
1306
|
*/
|
|
856
|
-
findIndexAtOrBefore(e,
|
|
1307
|
+
findIndexAtOrBefore(e, n) {
|
|
857
1308
|
if (this.size === 0)
|
|
858
1309
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
859
|
-
let
|
|
860
|
-
for (;
|
|
861
|
-
const
|
|
862
|
-
|
|
1310
|
+
let r = 0, s = this.size - 1, a = -1, i, f = this.total;
|
|
1311
|
+
for (; r <= s; ) {
|
|
1312
|
+
const p = Math.floor((r + s) / 2);
|
|
1313
|
+
i = this.prefixSum(p, n), f = i.total, i.cumulative <= e ? (a = p, r = p + 1) : s = p - 1;
|
|
863
1314
|
}
|
|
864
|
-
return { index: a, total:
|
|
1315
|
+
return { index: a, total: f, cumulative: i?.cumulative, currentValue: i?.currentValue, safeIndex: i?.safeIndex };
|
|
865
1316
|
}
|
|
866
1317
|
}
|
|
867
|
-
const
|
|
868
|
-
const
|
|
1318
|
+
const ot = (c, e, n) => {
|
|
1319
|
+
const r = Math.max(0, c), s = H(null), a = U(() => new st(r, e, n), [r, e, n]);
|
|
869
1320
|
return Object.is(s.current, a) || console.warn("[useFenwickMapTree] instance changed"), s.current = a, a;
|
|
870
1321
|
};
|
|
871
|
-
function
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
1322
|
+
function at({ itemCount: c, getItem: e, getItemHeight: n, viewportSize: r, overscanCount: s = 5, className: a, onScroll: i, onRangeChange: f, children: p, background: g, initialScrollIndex: x, initialScrollOffset: P, tapScrollCircleOptions: S, inertiaOptions: ne }, ie) {
|
|
1323
|
+
const N = H(null), K = H(!1);
|
|
1324
|
+
ae(() => (K.current = !0, () => {
|
|
1325
|
+
K.current = !1;
|
|
875
1326
|
}), []);
|
|
876
|
-
const
|
|
877
|
-
let
|
|
878
|
-
if (typeof
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
} else typeof
|
|
882
|
-
return { position:
|
|
883
|
-
}), [
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
}, [
|
|
889
|
-
|
|
890
|
-
}, [
|
|
891
|
-
const
|
|
892
|
-
(
|
|
893
|
-
if (
|
|
894
|
-
|
|
895
|
-
const
|
|
896
|
-
|
|
1327
|
+
const F = H({ size: c, valueOrFn: n, options: { sampleRange: { from: 0, to: 100 } } }), m = ot(F.current.size, F.current.valueOrFn, F.current.options), [Z] = le(() => {
|
|
1328
|
+
let h = 0, v = 0;
|
|
1329
|
+
if (typeof x == "number") {
|
|
1330
|
+
const I = z(x, 0, c - 1), t = z(I - s * 2, 0, c - 1), o = z(I + s * 2, 0, c - 1), T = x > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: t, to: o }] } } : void 0, { cumulative: y, total: w, currentValue: V } = m.prefixSum(x, T);
|
|
1331
|
+
h = y - V, v = w ?? m.getTotal();
|
|
1332
|
+
} else typeof P == "number" && (h = P), v = m.getTotal();
|
|
1333
|
+
return { position: h, total: v };
|
|
1334
|
+
}), [A, k] = le(Z.position), [C, B] = le(Z.total), [X, se] = le(Z.position), [l, Y] = le(c);
|
|
1335
|
+
be(() => {
|
|
1336
|
+
m.setValueFn(n), l !== c && (m.changeSize(c), Y(c));
|
|
1337
|
+
const h = m.getTotal();
|
|
1338
|
+
C !== h && B(h);
|
|
1339
|
+
}, [m, l, c, C, n]), be(() => {
|
|
1340
|
+
X !== null && N.current && (re.debug("[VirtualScroll] Scrolling to position:", X), N.current.scrollTo(X), se(null));
|
|
1341
|
+
}, [X]);
|
|
1342
|
+
const j = $(
|
|
1343
|
+
(h) => {
|
|
1344
|
+
if (N.current) {
|
|
1345
|
+
re.debug("[VirtualScroll] Scrolling to index:", h);
|
|
1346
|
+
const v = z(h, 0, l - 1), I = z(v - s * 2, 0, l - 1), t = z(v + s * 2, 0, l - 1), { cumulative: o, total: T, currentValue: y } = m.prefixSum(v, { materializeOption: { materialize: !0, ranges: [{ from: I, to: t }] } });
|
|
1347
|
+
re.debug("[VirtualScroll] Scrolling to index:", h, "Offset:", o, "Total height:", T, "Current value:", y, "safeIndex:", v, "safeIndexFrom:", I, "safeIndexTo:", t), T && (B(T), se(o - y)), re.debug("[VirtualScroll] Setting scroll position to:", o - y);
|
|
897
1348
|
}
|
|
898
1349
|
},
|
|
899
|
-
[
|
|
900
|
-
),
|
|
901
|
-
(
|
|
902
|
-
if (
|
|
903
|
-
const
|
|
904
|
-
|
|
1350
|
+
[m, s, l]
|
|
1351
|
+
), L = $(
|
|
1352
|
+
(h) => {
|
|
1353
|
+
if (N.current) {
|
|
1354
|
+
const v = m.getTotal(), I = z(Math.floor(h), 0, v), t = m.findIndexAtOrAfter(I, { materializeOption: { materialize: !1 } }).index;
|
|
1355
|
+
j(t);
|
|
905
1356
|
}
|
|
906
1357
|
},
|
|
907
|
-
[
|
|
908
|
-
),
|
|
909
|
-
(
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
|
|
1358
|
+
[m, j]
|
|
1359
|
+
), b = $(
|
|
1360
|
+
(h, v) => {
|
|
1361
|
+
re.debug("[VirtualScroll] Scroll position changed:", h), k(h);
|
|
1362
|
+
const I = m.getTotal();
|
|
1363
|
+
i?.(h, I);
|
|
913
1364
|
},
|
|
914
|
-
[
|
|
915
|
-
),
|
|
916
|
-
if (
|
|
1365
|
+
[m, i]
|
|
1366
|
+
), E = U(() => {
|
|
1367
|
+
if (l === 0)
|
|
917
1368
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
918
|
-
const { index:
|
|
919
|
-
let
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
let
|
|
923
|
-
for (;
|
|
924
|
-
const
|
|
925
|
-
|
|
1369
|
+
const { index: h, cumulative: v, currentValue: I } = m.findIndexAtOrAfter(A, { materializeOption: { materialize: !1 } });
|
|
1370
|
+
let t = 0;
|
|
1371
|
+
h === -1 ? t = 0 : (v ?? 0) < A + (I ?? 0) ? t = 1 : t = 0;
|
|
1372
|
+
const o = h === -1 ? 0 : h + t, T = z(o - s, 0, l - 1);
|
|
1373
|
+
let y = 0, w = h === -1 ? 0 : h + t;
|
|
1374
|
+
for (; w < l && y < r; ) {
|
|
1375
|
+
const D = n(w);
|
|
1376
|
+
y += D, w++;
|
|
926
1377
|
}
|
|
927
|
-
|
|
928
|
-
const
|
|
929
|
-
return
|
|
930
|
-
renderingStartIndex:
|
|
931
|
-
renderingEndIndex:
|
|
932
|
-
visibleStartIndex:
|
|
933
|
-
visibleEndIndex:
|
|
934
|
-
scrollPosition:
|
|
935
|
-
renderingContentSize:
|
|
1378
|
+
w -= 1;
|
|
1379
|
+
const V = z(w + s, 0, l - 1);
|
|
1380
|
+
return re.debug("[VirtualScroll] Calculated rendering range:", {
|
|
1381
|
+
renderingStartIndex: T,
|
|
1382
|
+
renderingEndIndex: V,
|
|
1383
|
+
visibleStartIndex: o,
|
|
1384
|
+
visibleEndIndex: w,
|
|
1385
|
+
scrollPosition: A,
|
|
1386
|
+
renderingContentSize: m.getTotal(),
|
|
936
1387
|
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
|
-
}),
|
|
951
|
-
}, [
|
|
952
|
-
const
|
|
953
|
-
(
|
|
954
|
-
const { renderingStartIndex:
|
|
955
|
-
if (
|
|
956
|
-
return /* @__PURE__ */
|
|
957
|
-
const
|
|
958
|
-
for (let
|
|
959
|
-
const
|
|
960
|
-
|
|
1388
|
+
viewportSize: r
|
|
1389
|
+
}), { renderingStartIndex: T, renderingEndIndex: V, visibleStartIndex: o, visibleEndIndex: w };
|
|
1390
|
+
}, [A, s, r, n, m, l]);
|
|
1391
|
+
ae(() => {
|
|
1392
|
+
const h = N.current?.getScrollPosition() ?? 0;
|
|
1393
|
+
re.debug("[VirtualScroll] Range change effect triggered", {
|
|
1394
|
+
renderingStartIndex: E.renderingStartIndex,
|
|
1395
|
+
renderingEndIndex: E.renderingEndIndex,
|
|
1396
|
+
visibleStartIndex: E.visibleStartIndex,
|
|
1397
|
+
visibleEndIndex: E.visibleEndIndex,
|
|
1398
|
+
scrollPosition: A,
|
|
1399
|
+
contentSize: C,
|
|
1400
|
+
scrollPaneScrollPosition: h
|
|
1401
|
+
}), f?.(E.renderingStartIndex, E.renderingEndIndex, E.visibleStartIndex, E.visibleEndIndex, A, C);
|
|
1402
|
+
}, [E.renderingStartIndex, E.renderingEndIndex, E.visibleStartIndex, E.visibleEndIndex, f, A, C]);
|
|
1403
|
+
const M = $(
|
|
1404
|
+
(h) => {
|
|
1405
|
+
const { renderingStartIndex: v, renderingEndIndex: I } = E;
|
|
1406
|
+
if (re.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: h, renderingStartIndex: v, renderingEndIndex: I, fenwickSize: l, viewportSize: r }), l === 0)
|
|
1407
|
+
return /* @__PURE__ */ q.jsx("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ q.jsx("div", { className: "text-center text-gray-500", children: "No items" }) });
|
|
1408
|
+
const t = z(v, 0, l - 1), { cumulative: o, currentValue: T } = m.prefixSum(t, { materializeOption: { materialize: !1 } }), y = o - T, w = [], V = [];
|
|
1409
|
+
for (let _ = v; _ <= I; _++) {
|
|
1410
|
+
const R = n(_);
|
|
1411
|
+
w.push({ item: e(_), height: R }), m.get(_) !== R && V.push({ index: _, value: R });
|
|
961
1412
|
}
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
|
|
1413
|
+
V.length > 0 && Promise.resolve().then(() => {
|
|
1414
|
+
const _ = m.updates(V);
|
|
1415
|
+
_ && (B(_), re.debug("[VirtualScroll] Updated heights for items", V, "New total height:", _));
|
|
965
1416
|
});
|
|
966
|
-
const
|
|
967
|
-
return
|
|
968
|
-
const
|
|
969
|
-
return /* @__PURE__ */
|
|
1417
|
+
const D = C < r ? 0 : y - h;
|
|
1418
|
+
return re.debug("[VirtualScroll] Rendering items", { visibleItems: w, containerTop: D }), /* @__PURE__ */ q.jsx("div", { className: "absolute w-full", style: { top: D }, children: w.map(({ item: _, height: R }, G) => {
|
|
1419
|
+
const J = v + G, u = z(J, 0, l - 1), { cumulative: ee, currentValue: W } = m.prefixSum(u, { materializeOption: { materialize: !1 } }), oe = ee - W;
|
|
1420
|
+
return /* @__PURE__ */ q.jsx(
|
|
970
1421
|
"div",
|
|
971
1422
|
{
|
|
972
|
-
"data-index":
|
|
1423
|
+
"data-index": J,
|
|
973
1424
|
style: {
|
|
974
1425
|
position: "absolute",
|
|
975
|
-
top:
|
|
1426
|
+
top: oe - y,
|
|
976
1427
|
width: "100%"
|
|
977
1428
|
},
|
|
978
|
-
children:
|
|
1429
|
+
children: p(_, J)
|
|
979
1430
|
},
|
|
980
|
-
|
|
1431
|
+
J
|
|
981
1432
|
);
|
|
982
1433
|
}) });
|
|
983
1434
|
},
|
|
984
|
-
[e,
|
|
1435
|
+
[e, p, C, r, E, m, l, n]
|
|
985
1436
|
);
|
|
986
|
-
return
|
|
987
|
-
|
|
1437
|
+
return Ae(
|
|
1438
|
+
ie,
|
|
988
1439
|
() => ({
|
|
989
|
-
getScrollPosition: () =>
|
|
990
|
-
getContentSize: () =>
|
|
991
|
-
getViewportSize: () =>
|
|
992
|
-
scrollTo: (
|
|
993
|
-
scrollToIndex: (
|
|
994
|
-
getFenwickTreeTotalHeight: () =>
|
|
995
|
-
getFenwickSize: () =>
|
|
1440
|
+
getScrollPosition: () => N.current?.getScrollPosition() ?? -1,
|
|
1441
|
+
getContentSize: () => N.current?.getContentSize() ?? -1,
|
|
1442
|
+
getViewportSize: () => N.current?.getViewportSize() ?? -1,
|
|
1443
|
+
scrollTo: (h) => L(h),
|
|
1444
|
+
scrollToIndex: (h) => j(h),
|
|
1445
|
+
getFenwickTreeTotalHeight: () => m.getTotal(),
|
|
1446
|
+
getFenwickSize: () => m.getSize()
|
|
996
1447
|
}),
|
|
997
|
-
[
|
|
998
|
-
), /* @__PURE__ */
|
|
1448
|
+
[j, m, L]
|
|
1449
|
+
), /* @__PURE__ */ q.jsx(
|
|
1450
|
+
nt,
|
|
1451
|
+
{
|
|
1452
|
+
ref: N,
|
|
1453
|
+
contentSize: C,
|
|
1454
|
+
viewportSize: r,
|
|
1455
|
+
className: a,
|
|
1456
|
+
onScroll: b,
|
|
1457
|
+
background: g,
|
|
1458
|
+
tapScrollCircleOptions: S,
|
|
1459
|
+
inertiaOptions: ne,
|
|
1460
|
+
itemCount: c,
|
|
1461
|
+
children: M
|
|
1462
|
+
}
|
|
1463
|
+
);
|
|
999
1464
|
}
|
|
1000
|
-
const
|
|
1001
|
-
class
|
|
1465
|
+
const ft = Re(at);
|
|
1466
|
+
class it {
|
|
1002
1467
|
key;
|
|
1003
1468
|
value;
|
|
1004
1469
|
prev = null;
|
|
1005
1470
|
next = null;
|
|
1006
|
-
constructor(e,
|
|
1007
|
-
this.key = e, this.value =
|
|
1471
|
+
constructor(e, n) {
|
|
1472
|
+
this.key = e, this.value = n;
|
|
1008
1473
|
}
|
|
1009
1474
|
}
|
|
1010
|
-
class
|
|
1475
|
+
class Ce {
|
|
1011
1476
|
head = null;
|
|
1012
1477
|
tail = null;
|
|
1013
1478
|
/**
|
|
@@ -1048,54 +1513,54 @@ class fe {
|
|
|
1048
1513
|
this.remove(e), this.addToTail(e);
|
|
1049
1514
|
}
|
|
1050
1515
|
}
|
|
1051
|
-
function
|
|
1052
|
-
const e =
|
|
1053
|
-
|
|
1054
|
-
for (; e.current.size >
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
e.current.delete(
|
|
1516
|
+
function lt(c) {
|
|
1517
|
+
const e = H(/* @__PURE__ */ new Map()), n = H(new Ce());
|
|
1518
|
+
ae(() => {
|
|
1519
|
+
for (; e.current.size > c; ) {
|
|
1520
|
+
const g = n.current.removeHead();
|
|
1521
|
+
if (g)
|
|
1522
|
+
e.current.delete(g.key);
|
|
1058
1523
|
else
|
|
1059
1524
|
break;
|
|
1060
1525
|
}
|
|
1061
|
-
}, [
|
|
1062
|
-
const
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1065
|
-
return
|
|
1066
|
-
}, []), s =
|
|
1067
|
-
(
|
|
1068
|
-
if (
|
|
1526
|
+
}, [c]);
|
|
1527
|
+
const r = $((g) => {
|
|
1528
|
+
const x = e.current.get(g);
|
|
1529
|
+
if (x)
|
|
1530
|
+
return n.current.moveToTail(x), x.value;
|
|
1531
|
+
}, []), s = $(
|
|
1532
|
+
(g, x) => {
|
|
1533
|
+
if (c <= 0)
|
|
1069
1534
|
return;
|
|
1070
|
-
let
|
|
1071
|
-
if (
|
|
1072
|
-
|
|
1535
|
+
let P = e.current.get(g);
|
|
1536
|
+
if (P)
|
|
1537
|
+
P.value = x, n.current.moveToTail(P);
|
|
1073
1538
|
else {
|
|
1074
|
-
if (e.current.size >=
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1539
|
+
if (e.current.size >= c) {
|
|
1540
|
+
const S = n.current.removeHead();
|
|
1541
|
+
S && e.current.delete(S.key);
|
|
1077
1542
|
}
|
|
1078
|
-
|
|
1543
|
+
P = new it(g, x), e.current.set(g, P), n.current.addToTail(P);
|
|
1079
1544
|
}
|
|
1080
1545
|
},
|
|
1081
|
-
[
|
|
1082
|
-
), a =
|
|
1083
|
-
e.current.clear(),
|
|
1084
|
-
}, []), [
|
|
1085
|
-
return
|
|
1546
|
+
[c]
|
|
1547
|
+
), a = $((g) => e.current.has(g), []), i = $(() => {
|
|
1548
|
+
e.current.clear(), n.current = new Ce();
|
|
1549
|
+
}, []), [f, p] = le(() => ({ get: r, set: s, has: a, clear: i }));
|
|
1550
|
+
return ae(() => p({ get: r, set: s, has: a, clear: i }), [r, s, a, i]), f;
|
|
1086
1551
|
}
|
|
1087
|
-
const
|
|
1088
|
-
const { get:
|
|
1089
|
-
return { get:
|
|
1552
|
+
const ct = 1e4, mt = () => {
|
|
1553
|
+
const { get: c, set: e, has: n, clear: r } = lt(ct);
|
|
1554
|
+
return { get: c, set: e, has: n, clear: r };
|
|
1090
1555
|
};
|
|
1091
1556
|
export {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1557
|
+
st as FenwickMapTree,
|
|
1558
|
+
rt as ScrollBar,
|
|
1559
|
+
nt as ScrollPane,
|
|
1560
|
+
ft as VirtualScroll,
|
|
1561
|
+
z as minmax,
|
|
1562
|
+
ot as useFenwickMapTree,
|
|
1563
|
+
mt as useHeightCache,
|
|
1564
|
+
lt as useLruCache
|
|
1100
1565
|
};
|
|
1101
1566
|
//# sourceMappingURL=index.js.map
|