@aiquants/virtualscroll 1.20.0 → 1.22.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/CHANGELOG.md +73 -0
- package/README.md +5 -3
- package/dist/ScrollBar.d.cts +123 -0
- package/dist/ScrollBar.d.ts +123 -0
- package/dist/ScrollBar.d.ts.map +1 -1
- package/dist/ScrollPane.d.cts +16 -0
- package/dist/ScrollPane.d.ts +16 -0
- package/dist/ScrollPane.d.ts.map +1 -1
- package/dist/TapScrollCircle.d.ts.map +1 -1
- package/dist/VirtualScroll.d.cts +9 -0
- package/dist/VirtualScroll.d.ts +9 -0
- package/dist/VirtualScroll.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1558 -1436
- package/dist/styles/virtualscroll.css +1 -1
- package/dist/styles/virtualscroll.standalone.css +1 -1
- package/dist/tapScrollCircleSampleVisual.d.ts.map +1 -1
- package/dist/useFenwickMapTree.d.cts +43 -0
- package/dist/useFenwickMapTree.d.ts +43 -0
- package/dist/useFenwickMapTree.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/ScrollBar.tsx +218 -33
- package/src/ScrollPane.tsx +366 -24
- package/src/TapScrollCircle.tsx +10 -0
- package/src/VirtualScroll.tsx +11 -1
- package/src/index.ts +1 -1
- package/src/styles/virtualscroll.css +3 -3
- package/src/tapScrollCircleSampleVisual.tsx +22 -5
- package/src/useFenwickMapTree.ts +95 -13
- package/src/ScrollBar.spec.tsx +0 -620
- package/src/ScrollPane.spec.tsx +0 -496
- package/src/TapScrollCircle.spec.tsx +0 -275
- package/src/VirtualScroll.spec.ts +0 -641
- package/src/cli.server.spec.ts +0 -137
- package/src/logger.spec.ts +0 -128
- package/src/useFenwickMapTree.huge.spec.ts +0 -388
- package/src/useFenwickMapTree.spec.ts +0 -1518
- package/src/useLruCache.spec.ts +0 -382
- package/src/utils.spec.ts +0 -39
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { twMerge as
|
|
4
|
-
class
|
|
1
|
+
import { jsx as it, jsxs as de, Fragment as je } from "react/jsx-runtime";
|
|
2
|
+
import Je, { memo as Qe, forwardRef as Ye, useState as Zt, useRef as T, useCallback as v, useImperativeHandle as Be, useMemo as At, useLayoutEffect as xe, useEffect as Y, useId as tr } from "react";
|
|
3
|
+
import { twMerge as ue } from "tailwind-merge";
|
|
4
|
+
class C {
|
|
5
5
|
level;
|
|
6
6
|
prefix;
|
|
7
7
|
impl;
|
|
@@ -14,7 +14,7 @@ class N {
|
|
|
14
14
|
constructor(t = 2, e = "[virtualscroll]", r = console) {
|
|
15
15
|
this.level = t, this.prefix = e, this.impl = r;
|
|
16
16
|
}
|
|
17
|
-
static instance = new
|
|
17
|
+
static instance = new C(2, "[virtualscroll]");
|
|
18
18
|
/**
|
|
19
19
|
* @method setLevel
|
|
20
20
|
* @description Updates the current log level for the static instance.
|
|
@@ -22,7 +22,7 @@ class N {
|
|
|
22
22
|
* @param {LogLevel} level - The new log level.
|
|
23
23
|
*/
|
|
24
24
|
static setLevel(t) {
|
|
25
|
-
|
|
25
|
+
C.instance.setLevel(t);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* @method setLevel
|
|
@@ -40,7 +40,7 @@ class N {
|
|
|
40
40
|
* @param {ILogger} impl - The new logger implementation.
|
|
41
41
|
*/
|
|
42
42
|
static setImplementation(t) {
|
|
43
|
-
|
|
43
|
+
C.instance.setImplementation(t);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* @method setImplementation
|
|
@@ -58,7 +58,7 @@ class N {
|
|
|
58
58
|
* @param {string} prefix - The new prefix.
|
|
59
59
|
*/
|
|
60
60
|
static setPrefix(t) {
|
|
61
|
-
|
|
61
|
+
C.instance.setPrefix(t);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* @method setPrefix
|
|
@@ -77,7 +77,7 @@ class N {
|
|
|
77
77
|
* @returns {boolean} True if a message at `level` would be emitted. / `level` のメッセージが出力されるなら true。
|
|
78
78
|
*/
|
|
79
79
|
static isEnabled(t) {
|
|
80
|
-
return
|
|
80
|
+
return C.instance.isEnabled(t);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* @method isEnabled
|
|
@@ -122,41 +122,41 @@ class N {
|
|
|
122
122
|
return typeof t == "string" ? [`${this.prefix} ${t}`] : [this.prefix, t];
|
|
123
123
|
}
|
|
124
124
|
static debug(t, ...e) {
|
|
125
|
-
|
|
125
|
+
C.instance.debug(t, ...e);
|
|
126
126
|
}
|
|
127
127
|
debug(t, ...e) {
|
|
128
|
-
this.level <= 0 && this.impl.debug(...this.formatMessage(
|
|
128
|
+
this.level <= 0 && this.impl.debug(...this.formatMessage(C.resolveLazy(t)), ...e.map(C.resolveLazy));
|
|
129
129
|
}
|
|
130
130
|
static info(t, ...e) {
|
|
131
|
-
|
|
131
|
+
C.instance.info(t, ...e);
|
|
132
132
|
}
|
|
133
133
|
info(t, ...e) {
|
|
134
|
-
this.level <= 1 && this.impl.info(...this.formatMessage(
|
|
134
|
+
this.level <= 1 && this.impl.info(...this.formatMessage(C.resolveLazy(t)), ...e.map(C.resolveLazy));
|
|
135
135
|
}
|
|
136
136
|
static warn(t, ...e) {
|
|
137
|
-
|
|
137
|
+
C.instance.warn(t, ...e);
|
|
138
138
|
}
|
|
139
139
|
warn(t, ...e) {
|
|
140
|
-
this.level <= 2 && this.impl.warn(...this.formatMessage(
|
|
140
|
+
this.level <= 2 && this.impl.warn(...this.formatMessage(C.resolveLazy(t)), ...e.map(C.resolveLazy));
|
|
141
141
|
}
|
|
142
142
|
static error(t, ...e) {
|
|
143
|
-
|
|
143
|
+
C.instance.error(t, ...e);
|
|
144
144
|
}
|
|
145
145
|
error(t, ...e) {
|
|
146
|
-
this.level <= 3 && this.impl.error(...this.formatMessage(
|
|
146
|
+
this.level <= 3 && this.impl.error(...this.formatMessage(C.resolveLazy(t)), ...e.map(C.resolveLazy));
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
const
|
|
149
|
+
const qe = {
|
|
150
150
|
active: !1,
|
|
151
151
|
offsetX: 0,
|
|
152
152
|
offsetY: 0,
|
|
153
153
|
distance: 0,
|
|
154
154
|
direction: 0,
|
|
155
155
|
pointerId: null
|
|
156
|
-
},
|
|
157
|
-
const e = 1 + t * 0.18, r = 0.16 + t * 0.24,
|
|
158
|
-
return /* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
156
|
+
}, Le = 6, er = 8, rr = ({ dragState: n, normalizedDistance: t }) => {
|
|
157
|
+
const e = 1 + t * 0.18, r = 0.16 + t * 0.24, i = 0.38 + t * 0.28, s = n.active ? "80ms ease-out" : "220ms ease";
|
|
158
|
+
return /* @__PURE__ */ de(je, { children: [
|
|
159
|
+
/* @__PURE__ */ it(
|
|
160
160
|
"div",
|
|
161
161
|
{
|
|
162
162
|
className: "aqvs-tap-scroll-circle-visual-outer",
|
|
@@ -164,166 +164,171 @@ const Ye = {
|
|
|
164
164
|
background: "linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",
|
|
165
165
|
boxShadow: `0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${r})`,
|
|
166
166
|
transform: `scale(${e})`,
|
|
167
|
-
transition: `${s}, ${
|
|
167
|
+
transition: `${s}, ${n.active ? "80ms" : "260ms"} box-shadow ease`
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
),
|
|
171
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ it(
|
|
172
172
|
"div",
|
|
173
173
|
{
|
|
174
174
|
className: "aqvs-tap-scroll-circle-inner",
|
|
175
175
|
style: {
|
|
176
176
|
background: "linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",
|
|
177
177
|
boxShadow: "inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",
|
|
178
|
-
opacity:
|
|
179
|
-
transition:
|
|
178
|
+
opacity: i,
|
|
179
|
+
transition: n.active ? "120ms opacity ease-out" : "220ms opacity ease"
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
)
|
|
183
183
|
] });
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
const [f, x] =
|
|
187
|
-
(
|
|
188
|
-
x(
|
|
184
|
+
}, Ge = Qe(
|
|
185
|
+
Ye(({ onDragChange: n, className: t, maxVisualDistance: e = 160, size: r = 40, style: i, opacity: s = 1, renderVisual: l }, c) => {
|
|
186
|
+
const [f, x] = Zt(qe), I = T(null), P = T(null), E = T({ x: 0, y: 0 }), g = T(null), _ = T(0), z = v(
|
|
187
|
+
(h) => {
|
|
188
|
+
x(h), n(h);
|
|
189
189
|
},
|
|
190
|
-
[
|
|
191
|
-
),
|
|
192
|
-
(
|
|
193
|
-
const { x:
|
|
194
|
-
let
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
active:
|
|
198
|
-
offsetX:
|
|
199
|
-
offsetY:
|
|
200
|
-
distance:
|
|
201
|
-
direction:
|
|
190
|
+
[n]
|
|
191
|
+
), j = v(
|
|
192
|
+
(h, $, Tt = !1) => {
|
|
193
|
+
const { x: wt, y: Z } = E.current, k = h - wt, Rt = $ - Z, U = Math.abs(Rt), Ct = U < Le ? 0 : Rt < 0 ? -1 : 1, w = _.current;
|
|
194
|
+
let Yt = Ct;
|
|
195
|
+
const Xt = Le + er;
|
|
196
|
+
Ct === 0 ? w !== 0 && U < Xt ? Yt = w : (Yt = 0, Tt || (_.current = 0)) : Ct !== w && w !== 0 && U < Xt ? Yt = w : _.current = Ct, z({
|
|
197
|
+
active: Tt || U >= Le,
|
|
198
|
+
offsetX: k,
|
|
199
|
+
offsetY: Rt,
|
|
200
|
+
distance: U,
|
|
201
|
+
direction: Yt,
|
|
202
202
|
pointerId: I.current
|
|
203
203
|
});
|
|
204
204
|
},
|
|
205
|
-
[
|
|
206
|
-
),
|
|
207
|
-
if (
|
|
205
|
+
[z]
|
|
206
|
+
), ft = v((h) => {
|
|
207
|
+
if (h === null)
|
|
208
208
|
return;
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
}, []),
|
|
212
|
-
(
|
|
213
|
-
|
|
209
|
+
const $ = g.current;
|
|
210
|
+
$?.hasPointerCapture(h) && $.releasePointerCapture(h);
|
|
211
|
+
}, []), Q = v(
|
|
212
|
+
(h = !1) => {
|
|
213
|
+
h && ft(I.current), I.current = null, P.current = null, _.current = 0, z(qe);
|
|
214
214
|
},
|
|
215
|
-
[
|
|
216
|
-
),
|
|
217
|
-
(
|
|
218
|
-
if (I.current !== null && I.current !==
|
|
219
|
-
|
|
215
|
+
[z, ft]
|
|
216
|
+
), tt = v(
|
|
217
|
+
(h) => {
|
|
218
|
+
if (I.current !== null && I.current !== h.pointerId) {
|
|
219
|
+
P.current = { pointerId: h.pointerId, clientX: h.clientX, clientY: h.clientY }, h.preventDefault(), h.stopPropagation();
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
222
|
+
h.preventDefault(), h.stopPropagation();
|
|
223
|
+
const $ = g.current ?? h.currentTarget, { left: Tt, top: wt, width: Z, height: k } = $.getBoundingClientRect();
|
|
224
|
+
E.current = { x: Tt + Z / 2, y: wt + k / 2 }, I.current = h.pointerId;
|
|
225
225
|
try {
|
|
226
|
-
|
|
226
|
+
$.setPointerCapture(h.pointerId);
|
|
227
227
|
} catch {
|
|
228
228
|
}
|
|
229
|
-
|
|
229
|
+
j(h.clientX, h.clientY, !0);
|
|
230
230
|
},
|
|
231
|
-
[
|
|
232
|
-
),
|
|
233
|
-
(
|
|
234
|
-
if (I.current !==
|
|
235
|
-
|
|
231
|
+
[j]
|
|
232
|
+
), pt = v(
|
|
233
|
+
(h) => {
|
|
234
|
+
if (I.current !== h.pointerId) {
|
|
235
|
+
P.current !== null && P.current.pointerId === h.pointerId && (P.current = { pointerId: h.pointerId, clientX: h.clientX, clientY: h.clientY });
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
|
|
238
|
+
h.preventDefault(), j(h.clientX, h.clientY);
|
|
239
239
|
},
|
|
240
|
-
[
|
|
241
|
-
),
|
|
242
|
-
(
|
|
243
|
-
if (I.current !==
|
|
244
|
-
|
|
240
|
+
[j]
|
|
241
|
+
), It = v(
|
|
242
|
+
(h) => {
|
|
243
|
+
if (I.current !== h.pointerId) {
|
|
244
|
+
P.current !== null && P.current.pointerId === h.pointerId && (P.current = null);
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
let
|
|
253
|
-
if (
|
|
247
|
+
h.preventDefault(), h.stopPropagation();
|
|
248
|
+
const $ = P.current;
|
|
249
|
+
if (P.current = null, $ !== null) {
|
|
250
|
+
ft(h.pointerId);
|
|
251
|
+
const Tt = g.current;
|
|
252
|
+
let wt = !0;
|
|
253
|
+
if (Tt !== null && typeof Tt.setPointerCapture == "function")
|
|
254
254
|
try {
|
|
255
|
-
|
|
256
|
-
} catch (
|
|
257
|
-
(typeof
|
|
255
|
+
Tt.setPointerCapture($.pointerId);
|
|
256
|
+
} catch (Z) {
|
|
257
|
+
(typeof Z == "object" && Z !== null && "name" in Z ? Z.name : void 0) === "NotFoundError" && (wt = !1);
|
|
258
258
|
}
|
|
259
|
-
if (
|
|
260
|
-
I.current =
|
|
259
|
+
if (wt) {
|
|
260
|
+
I.current = $.pointerId, j($.clientX, $.clientY, !0);
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
|
|
264
|
+
Q(!0);
|
|
265
265
|
},
|
|
266
|
-
[
|
|
267
|
-
),
|
|
268
|
-
(
|
|
269
|
-
I.current ===
|
|
266
|
+
[Q, ft, j]
|
|
267
|
+
), D = v(
|
|
268
|
+
(h) => {
|
|
269
|
+
h.target === h.currentTarget && I.current === h.pointerId && Q(!1);
|
|
270
270
|
},
|
|
271
|
-
[
|
|
271
|
+
[Q]
|
|
272
272
|
);
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
Be(
|
|
274
|
+
c,
|
|
275
275
|
() => ({
|
|
276
276
|
reset: () => {
|
|
277
|
-
|
|
277
|
+
Q(!0);
|
|
278
278
|
},
|
|
279
|
-
getElement: () =>
|
|
279
|
+
getElement: () => g.current
|
|
280
280
|
}),
|
|
281
|
-
[
|
|
281
|
+
[Q]
|
|
282
282
|
);
|
|
283
|
-
const
|
|
283
|
+
const O = Math.min(Math.max(s, 0), 1), M = r / 64, B = Math.min(f.distance, e) / e, N = f.direction * B * 10 * M, q = l ?? rr, et = {
|
|
284
284
|
dragState: f,
|
|
285
|
-
normalizedDistance:
|
|
286
|
-
sizeScale:
|
|
285
|
+
normalizedDistance: B,
|
|
286
|
+
sizeScale: M,
|
|
287
287
|
size: r,
|
|
288
|
-
opacity:
|
|
289
|
-
},
|
|
290
|
-
...
|
|
288
|
+
opacity: O
|
|
289
|
+
}, G = {
|
|
290
|
+
...i,
|
|
291
291
|
width: r,
|
|
292
292
|
height: r,
|
|
293
|
-
transform: `translateY(${
|
|
293
|
+
transform: `translateY(${N}px)`
|
|
294
294
|
};
|
|
295
|
-
return
|
|
295
|
+
return G.opacity = O, /* @__PURE__ */ it(
|
|
296
296
|
"div",
|
|
297
297
|
{
|
|
298
|
-
ref:
|
|
298
|
+
ref: g,
|
|
299
299
|
"data-testid": "virtual-scroll-tap-circle",
|
|
300
|
-
className:
|
|
301
|
-
style:
|
|
300
|
+
className: ue("aqvs-tap-scroll-circle", t),
|
|
301
|
+
style: G,
|
|
302
302
|
tabIndex: -1,
|
|
303
|
-
onPointerDown:
|
|
304
|
-
onPointerMove:
|
|
305
|
-
onPointerUp:
|
|
306
|
-
onPointerCancel:
|
|
307
|
-
onLostPointerCapture:
|
|
303
|
+
onPointerDown: tt,
|
|
304
|
+
onPointerMove: pt,
|
|
305
|
+
onPointerUp: It,
|
|
306
|
+
onPointerCancel: It,
|
|
307
|
+
onLostPointerCapture: D,
|
|
308
308
|
role: "presentation",
|
|
309
|
-
children:
|
|
309
|
+
children: q(et)
|
|
310
310
|
}
|
|
311
311
|
);
|
|
312
312
|
})
|
|
313
313
|
);
|
|
314
|
-
|
|
315
|
-
const
|
|
314
|
+
Ge.displayName = "TapScrollCircle";
|
|
315
|
+
const xt = (n, t, e) => Math.max(t, Math.min(e, n)), ze = "virtualscroll:tap-scroll-cancel", He = 20, nr = 250, ir = 60, sr = 20, or = 20, Ze = {
|
|
316
|
+
/** 速度が最大に達する引き距離 (px)。`maxVisualDistance` の既定値。 */
|
|
317
|
+
maxDistance: 240,
|
|
318
|
+
/** 最小速度倍率 (ビューポート比)。 */
|
|
319
|
+
minSpeedMultiplier: 0.2
|
|
320
|
+
}, ar = Ze.maxDistance, Xe = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0, pointerId: null }, _e = 2.2, lr = 8, cr = 120, ur = 1 / 10, Gt = {
|
|
316
321
|
enabled: !0,
|
|
317
322
|
size: 40,
|
|
318
323
|
offsetX: -80,
|
|
319
324
|
offsetY: 0,
|
|
320
325
|
className: void 0,
|
|
321
|
-
maxVisualDistance:
|
|
322
|
-
minSpeedMultiplier:
|
|
326
|
+
maxVisualDistance: ar,
|
|
327
|
+
minSpeedMultiplier: Ze.minSpeedMultiplier,
|
|
323
328
|
opacity: 0.9,
|
|
324
329
|
renderVisual: void 0,
|
|
325
330
|
maxSpeedCurve: void 0
|
|
326
|
-
},
|
|
331
|
+
}, dr = (n) => n ? {
|
|
327
332
|
mainSizeKey: "width",
|
|
328
333
|
crossSizeKey: "height",
|
|
329
334
|
positionKey: "left",
|
|
@@ -343,493 +348,512 @@ const pt = (i, t, e) => Math.max(t, Math.min(e, i)), Oe = "virtualscroll:tap-scr
|
|
|
343
348
|
arrowIcons: ["▲", "▼"],
|
|
344
349
|
directionClass: "aqvs-scrollbar-vertical",
|
|
345
350
|
orientation: "vertical"
|
|
346
|
-
},
|
|
347
|
-
const e =
|
|
351
|
+
}, fr = (n, t) => {
|
|
352
|
+
const e = n?.maxSpeedMultiplier, r = typeof e == "number" ? e : br(t);
|
|
348
353
|
return {
|
|
349
|
-
enabled:
|
|
350
|
-
size:
|
|
351
|
-
offsetX:
|
|
352
|
-
offsetY:
|
|
353
|
-
className:
|
|
354
|
-
maxVisualDistance:
|
|
354
|
+
enabled: n?.enabled ?? Gt.enabled,
|
|
355
|
+
size: n?.size ?? Gt.size,
|
|
356
|
+
offsetX: n?.offsetX ?? Gt.offsetX,
|
|
357
|
+
offsetY: n?.offsetY ?? Gt.offsetY,
|
|
358
|
+
className: n?.className ?? Gt.className,
|
|
359
|
+
maxVisualDistance: n?.maxVisualDistance ?? Gt.maxVisualDistance,
|
|
355
360
|
maxSpeedMultiplier: r,
|
|
356
|
-
minSpeedMultiplier: Math.max(
|
|
357
|
-
opacity:
|
|
358
|
-
renderVisual:
|
|
359
|
-
maxSpeedCurve:
|
|
361
|
+
minSpeedMultiplier: Math.max(n?.minSpeedMultiplier ?? Gt.minSpeedMultiplier, 0),
|
|
362
|
+
opacity: xt(n?.opacity ?? Gt.opacity, 0, 1),
|
|
363
|
+
renderVisual: n?.renderVisual ?? Gt.renderVisual,
|
|
364
|
+
maxSpeedCurve: n?.maxSpeedCurve ?? Gt.maxSpeedCurve
|
|
360
365
|
};
|
|
361
|
-
},
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
}, []), f =
|
|
365
|
-
|
|
366
|
-
}, [
|
|
367
|
-
(
|
|
368
|
-
if (!
|
|
366
|
+
}, mr = ({ isDragging: n, isThumbHovered: t, enableThumbDrag: e }) => At(() => e ? n ? "dragging" : t ? "hover" : "idle" : "disabled", [e, n, t]), pr = ({ canUseArrowButtons: n, enableArrowButtons: t, resetTapScroll: e, scrollByStep: r }) => {
|
|
367
|
+
const i = T(null), s = T(null), l = T(null), c = v(() => {
|
|
368
|
+
i.current !== null && (window.clearInterval(i.current), i.current = null), s.current !== null && (window.clearTimeout(s.current), s.current = null), l.current !== null && (window.removeEventListener("pointerup", l.current), window.removeEventListener("pointercancel", l.current), window.removeEventListener("blur", l.current), l.current = null);
|
|
369
|
+
}, []), f = v(() => {
|
|
370
|
+
c();
|
|
371
|
+
}, [c]), x = v(
|
|
372
|
+
(P) => (E) => {
|
|
373
|
+
if (!n)
|
|
369
374
|
return;
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
r(
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
const
|
|
376
|
-
l.current =
|
|
375
|
+
E.cancelable && E.preventDefault(), E.stopPropagation(), e(), c(), r(P), s.current = window.setTimeout(() => {
|
|
376
|
+
i.current = window.setInterval(() => {
|
|
377
|
+
r(P);
|
|
378
|
+
}, ir);
|
|
379
|
+
}, nr);
|
|
380
|
+
const g = () => c();
|
|
381
|
+
l.current = g, window.addEventListener("pointerup", g), window.addEventListener("pointercancel", g), window.addEventListener("blur", g);
|
|
377
382
|
},
|
|
378
|
-
[
|
|
379
|
-
), I =
|
|
380
|
-
(
|
|
381
|
-
t && (
|
|
383
|
+
[n, c, e, r]
|
|
384
|
+
), I = v(
|
|
385
|
+
(P) => (E) => {
|
|
386
|
+
t && (E.key === "Enter" || E.key === " " || E.key === "Spacebar") && (E.preventDefault(), r(P));
|
|
382
387
|
},
|
|
383
388
|
[t, r]
|
|
384
389
|
);
|
|
385
|
-
return
|
|
386
|
-
|
|
387
|
-
}, [
|
|
388
|
-
|
|
389
|
-
}, [
|
|
390
|
-
}, gr = (i) => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
return Y(() => {
|
|
391
|
+
n || c();
|
|
392
|
+
}, [n, c]), Y(() => () => {
|
|
393
|
+
c();
|
|
394
|
+
}, [c]), { handleArrowPointerDown: x, handleArrowPointerUp: f, handleArrowKeyDown: I };
|
|
395
|
+
}, hr = 700, oe = (n, t) => typeof n == "number" && Number.isFinite(n) ? n : t, gr = ({ distance: n, maxDistance: t, viewportSize: e, minSpeedMultiplier: r, maxSpeedMultiplier: i, hasCustomMaxSpeedMultiplier: s, curve: l }) => {
|
|
396
|
+
const c = Math.max(oe(n, 0), 0), f = oe(t, 0), x = f > 0 ? Math.min(c, f) / f : 1, I = Math.max(oe(e, 0), 0), P = Math.max(oe(r, 0), 0), E = Math.max(oe(i, 0), 0), g = Math.max(I * P, 40), _ = s ? g : 1200, z = Math.max(I * E, _), j = l ? Math.max(oe(l.exponentialScale, E), 0) : 0, ft = l ? Math.min(z, Math.max(I * j, g)) : z, Q = Math.max(ft, g);
|
|
397
|
+
let tt = x ** 1.1;
|
|
398
|
+
if (l) {
|
|
399
|
+
const It = Math.min(Math.max(oe(l.exponentialSteepness, 0), 0), hr);
|
|
400
|
+
if (It === 0)
|
|
401
|
+
tt = x;
|
|
402
|
+
else {
|
|
403
|
+
const D = Math.expm1(It) || 1;
|
|
404
|
+
tt = Math.min(Math.max(Math.expm1(It * x) / D, 0), 1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const pt = Math.min(Math.max(oe(l?.easedOffset, 0), 0), 1);
|
|
408
|
+
return g + (Q - g) * (pt + (1 - pt) * tt);
|
|
409
|
+
}, br = (n) => {
|
|
410
|
+
if (!n || n <= 0)
|
|
411
|
+
return _e;
|
|
412
|
+
const t = Math.max(1, n), e = Math.log10(t), r = _e + e * lr;
|
|
413
|
+
return xt(r, _e, cr);
|
|
414
|
+
}, xr = ({
|
|
415
|
+
contentSize: n,
|
|
397
416
|
viewportSize: t,
|
|
398
417
|
scrollPosition: e,
|
|
399
418
|
onScroll: r,
|
|
400
|
-
enableThumbDrag:
|
|
419
|
+
enableThumbDrag: i = !0,
|
|
401
420
|
enableTrackClick: s = !0,
|
|
402
421
|
enableArrowButtons: l = !0,
|
|
403
|
-
horizontal:
|
|
422
|
+
horizontal: c = !1,
|
|
404
423
|
scrollBarWidth: f = 12,
|
|
405
424
|
className: x,
|
|
406
425
|
ariaControls: I,
|
|
407
|
-
tapScrollCircleOptions:
|
|
408
|
-
itemCount:
|
|
409
|
-
renderThumbOverlay:
|
|
410
|
-
visibleStartIndex:
|
|
411
|
-
visibleEndIndex:
|
|
426
|
+
tapScrollCircleOptions: P,
|
|
427
|
+
itemCount: E,
|
|
428
|
+
renderThumbOverlay: g,
|
|
429
|
+
visibleStartIndex: _,
|
|
430
|
+
visibleEndIndex: z
|
|
412
431
|
}) => {
|
|
413
|
-
const [
|
|
432
|
+
const [j, ft] = Zt(!1), [Q, tt] = Zt(!1), [pt, It] = Zt(!1), D = T(null), O = T({
|
|
414
433
|
pointerId: null,
|
|
415
434
|
startThumbPosition: 0,
|
|
416
435
|
startClientX: 0,
|
|
417
436
|
startClientY: 0,
|
|
418
437
|
scale: 1,
|
|
419
438
|
captureTarget: null
|
|
420
|
-
}),
|
|
421
|
-
enabled:
|
|
422
|
-
size:
|
|
423
|
-
offsetX:
|
|
424
|
-
offsetY:
|
|
425
|
-
className:
|
|
426
|
-
maxVisualDistance:
|
|
427
|
-
maxSpeedMultiplier:
|
|
428
|
-
minSpeedMultiplier:
|
|
429
|
-
opacity:
|
|
430
|
-
renderVisual:
|
|
431
|
-
maxSpeedCurve:
|
|
432
|
-
} =
|
|
439
|
+
}), M = T({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 }), B = T(e), N = T(r), q = T(Xe), et = T(null), G = T(null), h = T(null), $ = T(0), Tt = T(0), wt = At(() => fr(P, E), [E, P]), Z = At(() => dr(c), [c]), {
|
|
440
|
+
enabled: k,
|
|
441
|
+
size: Rt,
|
|
442
|
+
offsetX: U,
|
|
443
|
+
offsetY: Ct,
|
|
444
|
+
className: w,
|
|
445
|
+
maxVisualDistance: Yt,
|
|
446
|
+
maxSpeedMultiplier: Xt,
|
|
447
|
+
minSpeedMultiplier: S,
|
|
448
|
+
opacity: $t,
|
|
449
|
+
renderVisual: Bt,
|
|
450
|
+
maxSpeedCurve: Jt
|
|
451
|
+
} = wt, lt = T({
|
|
433
452
|
viewportSize: t,
|
|
434
|
-
maxScrollPosition: Math.max(
|
|
435
|
-
scrollBarVisible:
|
|
436
|
-
effectiveTapMaxDistance: Math.max(
|
|
437
|
-
tapCircleMaxSpeedMultiplier:
|
|
438
|
-
tapCircleMinSpeedMultiplier:
|
|
439
|
-
tapCircleMaxSpeedCurve:
|
|
440
|
-
tapScrollCircleOptions:
|
|
453
|
+
maxScrollPosition: Math.max(n - t, 0),
|
|
454
|
+
scrollBarVisible: n > t,
|
|
455
|
+
effectiveTapMaxDistance: Math.max(Yt, 1),
|
|
456
|
+
tapCircleMaxSpeedMultiplier: Xt,
|
|
457
|
+
tapCircleMinSpeedMultiplier: S,
|
|
458
|
+
tapCircleMaxSpeedCurve: Jt,
|
|
459
|
+
tapScrollCircleOptions: P,
|
|
441
460
|
effectiveTrackLength: 0,
|
|
442
461
|
onScroll: r,
|
|
443
462
|
scrollPosition: e
|
|
444
|
-
}), { mainSizeKey:
|
|
445
|
-
|
|
446
|
-
|
|
463
|
+
}), { mainSizeKey: Wt, crossSizeKey: d, positionKey: mt, selectDelta: ct, getPointerCoordinate: H, arrowLabels: nt, arrowIcons: J, directionClass: Pt, orientation: Mt } = Z, Et = Math.max(Yt, 1), st = t / n, St = Math.max(t - f * 2, 0), yt = st * St, ut = Math.min(Math.max(He, yt || 0), St || He), ot = n - t, Dt = Math.max(St - ut, 0), qt = ot <= 0 || Dt <= 0 ? 0 : xt(e / ot * Dt, 0, Dt), le = qt + ut / 2, dt = n > t || j, Qt = dt && l;
|
|
464
|
+
xe(() => {
|
|
465
|
+
lt.current = {
|
|
447
466
|
viewportSize: t,
|
|
448
|
-
maxScrollPosition:
|
|
449
|
-
scrollBarVisible:
|
|
450
|
-
effectiveTapMaxDistance:
|
|
451
|
-
tapCircleMaxSpeedMultiplier:
|
|
452
|
-
tapCircleMinSpeedMultiplier:
|
|
453
|
-
tapCircleMaxSpeedCurve:
|
|
454
|
-
tapScrollCircleOptions:
|
|
455
|
-
effectiveTrackLength:
|
|
467
|
+
maxScrollPosition: ot,
|
|
468
|
+
scrollBarVisible: dt,
|
|
469
|
+
effectiveTapMaxDistance: Et,
|
|
470
|
+
tapCircleMaxSpeedMultiplier: Xt,
|
|
471
|
+
tapCircleMinSpeedMultiplier: S,
|
|
472
|
+
tapCircleMaxSpeedCurve: Jt,
|
|
473
|
+
tapScrollCircleOptions: P,
|
|
474
|
+
effectiveTrackLength: Dt,
|
|
456
475
|
onScroll: r,
|
|
457
476
|
scrollPosition: e
|
|
458
477
|
};
|
|
459
|
-
}),
|
|
460
|
-
|
|
461
|
-
}, [e]),
|
|
462
|
-
|
|
463
|
-
}, [r]),
|
|
464
|
-
|
|
465
|
-
}, [
|
|
466
|
-
const
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
const
|
|
470
|
-
if (typeof
|
|
471
|
-
return
|
|
478
|
+
}), xe(() => {
|
|
479
|
+
B.current = e;
|
|
480
|
+
}, [e]), xe(() => {
|
|
481
|
+
N.current = r;
|
|
482
|
+
}, [r]), Y(() => {
|
|
483
|
+
i || tt(!1);
|
|
484
|
+
}, [i]);
|
|
485
|
+
const m = mr({ isDragging: j, isThumbHovered: Q, enableThumbDrag: i }), y = v((o, b) => {
|
|
486
|
+
const R = lt.current, L = b ?? B.current;
|
|
487
|
+
if (N.current) {
|
|
488
|
+
const p = N.current(o, L);
|
|
489
|
+
if (typeof p == "number" && Number.isFinite(p))
|
|
490
|
+
return B.current = p, p;
|
|
472
491
|
}
|
|
473
|
-
const
|
|
474
|
-
return
|
|
475
|
-
}, []),
|
|
476
|
-
(
|
|
477
|
-
const
|
|
478
|
-
if (!
|
|
479
|
-
const
|
|
480
|
-
return { nextPosition:
|
|
492
|
+
const X = typeof o == "function" ? o(L) : o, a = Math.max(R.maxScrollPosition, 0), u = R.scrollBarVisible ? xt(X, 0, a) : 0;
|
|
493
|
+
return B.current = u, u;
|
|
494
|
+
}, []), Nt = v(
|
|
495
|
+
(o) => {
|
|
496
|
+
const b = lt.current, R = B.current;
|
|
497
|
+
if (!b.scrollBarVisible || b.maxScrollPosition <= 0) {
|
|
498
|
+
const A = y(0, R), F = A - R;
|
|
499
|
+
return { nextPosition: A, actualDelta: F, reachedBoundary: !0 };
|
|
481
500
|
}
|
|
482
|
-
if (
|
|
483
|
-
return { nextPosition:
|
|
484
|
-
const
|
|
485
|
-
return { nextPosition:
|
|
501
|
+
if (o === 0)
|
|
502
|
+
return { nextPosition: R, actualDelta: 0, reachedBoundary: !1 };
|
|
503
|
+
const X = y((A) => xt(A + o, 0, b.maxScrollPosition), R), a = X - R, u = o < 0 && R + o <= 0, p = o > 0 && R + o >= b.maxScrollPosition, V = o < 0 && (X <= 0 || u && a === 0) || o > 0 && (X >= b.maxScrollPosition || p && a === 0);
|
|
504
|
+
return { nextPosition: X, actualDelta: a, reachedBoundary: V };
|
|
486
505
|
},
|
|
487
|
-
[
|
|
488
|
-
),
|
|
489
|
-
(
|
|
490
|
-
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
const
|
|
494
|
-
return
|
|
506
|
+
[y]
|
|
507
|
+
), Lt = v(
|
|
508
|
+
(o, b) => {
|
|
509
|
+
o.current += b;
|
|
510
|
+
const R = Math.max(lt.current.maxScrollPosition, 0);
|
|
511
|
+
R > 0 && (o.current = xt(o.current, -R, R));
|
|
512
|
+
const L = Nt(o.current);
|
|
513
|
+
return o.current -= L.actualDelta, L.reachedBoundary && (o.current = 0), L;
|
|
495
514
|
},
|
|
496
|
-
[
|
|
497
|
-
),
|
|
498
|
-
|
|
499
|
-
}, []),
|
|
500
|
-
|
|
501
|
-
}, [
|
|
502
|
-
(
|
|
503
|
-
const
|
|
504
|
-
if (!
|
|
505
|
-
|
|
515
|
+
[Nt]
|
|
516
|
+
), at = v(() => {
|
|
517
|
+
G.current !== null && (window.cancelAnimationFrame(G.current), G.current = null), h.current = null, $.current = 0, Tt.current = 0;
|
|
518
|
+
}, []), _t = v(() => {
|
|
519
|
+
q.current = { ...Xe }, It(!1), et.current?.reset(), at();
|
|
520
|
+
}, [at]), Ht = v(
|
|
521
|
+
(o) => {
|
|
522
|
+
const b = q.current, R = lt.current;
|
|
523
|
+
if (!b.active || b.direction === 0) {
|
|
524
|
+
at();
|
|
506
525
|
return;
|
|
507
526
|
}
|
|
508
|
-
if (!
|
|
509
|
-
|
|
527
|
+
if (!R.scrollBarVisible || R.maxScrollPosition <= 0) {
|
|
528
|
+
at();
|
|
510
529
|
return;
|
|
511
530
|
}
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
|
|
531
|
+
const L = h.current ?? o, X = Math.max((o - L) / 1e3, 0), a = Math.min(X, ur);
|
|
532
|
+
if (h.current = o, a <= 0) {
|
|
533
|
+
G.current = window.requestAnimationFrame(Ht);
|
|
515
534
|
return;
|
|
516
535
|
}
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
536
|
+
const u = gr({
|
|
537
|
+
distance: b.distance,
|
|
538
|
+
maxDistance: R.effectiveTapMaxDistance,
|
|
539
|
+
viewportSize: R.viewportSize,
|
|
540
|
+
minSpeedMultiplier: R.tapCircleMinSpeedMultiplier,
|
|
541
|
+
maxSpeedMultiplier: R.tapCircleMaxSpeedMultiplier,
|
|
542
|
+
hasCustomMaxSpeedMultiplier: typeof R.tapScrollCircleOptions?.maxSpeedMultiplier == "number",
|
|
543
|
+
curve: R.tapCircleMaxSpeedCurve
|
|
544
|
+
});
|
|
545
|
+
Tt.current !== b.direction && (Tt.current = b.direction, $.current = 0);
|
|
546
|
+
const { reachedBoundary: p } = Lt($, b.direction * u * a);
|
|
547
|
+
if (p) {
|
|
548
|
+
at();
|
|
529
549
|
return;
|
|
530
550
|
}
|
|
531
|
-
|
|
551
|
+
G.current = window.requestAnimationFrame(Ht);
|
|
532
552
|
},
|
|
533
|
-
[
|
|
534
|
-
),
|
|
535
|
-
|
|
536
|
-
}, [
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
(
|
|
542
|
-
|
|
553
|
+
[Lt, at]
|
|
554
|
+
), kt = v(() => {
|
|
555
|
+
G.current === null && (h.current = null, $.current = 0, G.current = window.requestAnimationFrame(Ht));
|
|
556
|
+
}, [Ht]);
|
|
557
|
+
Y(() => {
|
|
558
|
+
const o = q.current;
|
|
559
|
+
!o.active || o.direction === 0 || kt();
|
|
560
|
+
}, [n, t, kt]), Y(() => () => {
|
|
561
|
+
at();
|
|
562
|
+
}, [at]);
|
|
563
|
+
const jt = v(
|
|
564
|
+
(o) => {
|
|
565
|
+
q.current = o, It(o.active), o.active && o.direction !== 0 ? kt() : at();
|
|
543
566
|
},
|
|
544
|
-
[
|
|
567
|
+
[kt, at]
|
|
545
568
|
);
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}, [
|
|
549
|
-
const
|
|
550
|
-
const
|
|
551
|
-
|
|
569
|
+
Y(() => {
|
|
570
|
+
k || _t();
|
|
571
|
+
}, [_t, k]), Y(() => {
|
|
572
|
+
const o = (b) => {
|
|
573
|
+
const L = b.detail?.paneId;
|
|
574
|
+
L && I && L !== I || _t();
|
|
552
575
|
};
|
|
553
|
-
return window.addEventListener(
|
|
554
|
-
window.removeEventListener(
|
|
576
|
+
return window.addEventListener(ze, o), () => {
|
|
577
|
+
window.removeEventListener(ze, o);
|
|
555
578
|
};
|
|
556
|
-
}, [I,
|
|
557
|
-
if (!
|
|
579
|
+
}, [I, _t]), Y(() => {
|
|
580
|
+
if (!k)
|
|
558
581
|
return;
|
|
559
|
-
const
|
|
560
|
-
if (!
|
|
582
|
+
const o = (b) => {
|
|
583
|
+
if (!q.current.active || q.current.pointerId === b.pointerId)
|
|
561
584
|
return;
|
|
562
|
-
const
|
|
563
|
-
if (!(
|
|
564
|
-
|
|
585
|
+
const R = b.target;
|
|
586
|
+
if (!(R instanceof Node)) {
|
|
587
|
+
_t();
|
|
565
588
|
return;
|
|
566
589
|
}
|
|
567
|
-
|
|
590
|
+
et.current?.getElement()?.contains(R) || _t();
|
|
568
591
|
};
|
|
569
|
-
return document.addEventListener("pointerdown",
|
|
570
|
-
document.removeEventListener("pointerdown",
|
|
592
|
+
return document.addEventListener("pointerdown", o, !0), () => {
|
|
593
|
+
document.removeEventListener("pointerdown", o, !0);
|
|
571
594
|
};
|
|
572
|
-
}, [
|
|
573
|
-
const
|
|
574
|
-
if (!
|
|
595
|
+
}, [_t, k]);
|
|
596
|
+
const ce = (o) => {
|
|
597
|
+
if (!dt || Dt <= 0 || ot <= 0)
|
|
575
598
|
return 0;
|
|
576
|
-
const
|
|
577
|
-
return
|
|
578
|
-
},
|
|
579
|
-
const { scrollBarVisible:
|
|
580
|
-
if (
|
|
599
|
+
const b = xt(o, 0, Dt);
|
|
600
|
+
return xt(b / Dt * ot, 0, ot);
|
|
601
|
+
}, fe = v((o) => {
|
|
602
|
+
const { scrollBarVisible: b, effectiveTrackLength: R, maxScrollPosition: L } = lt.current;
|
|
603
|
+
if (C.debug("[ScrollBar] calculateScrollPositionFromThumb", () => ({ thumbPos: o, trackLen: R, maxScroll: L })), R <= 0 || L <= 0)
|
|
581
604
|
return null;
|
|
582
|
-
const
|
|
583
|
-
return
|
|
584
|
-
}, []),
|
|
585
|
-
(
|
|
586
|
-
const
|
|
587
|
-
const
|
|
588
|
-
return Number.isFinite(
|
|
589
|
-
},
|
|
590
|
-
return
|
|
605
|
+
const X = xt(o, 0, R);
|
|
606
|
+
return xt(X / R * L, 0, L);
|
|
607
|
+
}, []), Ie = v(
|
|
608
|
+
(o) => {
|
|
609
|
+
const b = o.getBoundingClientRect(), R = c ? b.width : b.height, L = (V) => {
|
|
610
|
+
const A = Number.parseFloat(V);
|
|
611
|
+
return Number.isFinite(A) ? A : 0;
|
|
612
|
+
}, X = window.getComputedStyle(o), a = L(c ? X.width : X.height), u = a > 0 ? a + L(c ? X.paddingLeft : X.paddingTop) + L(c ? X.paddingRight : X.paddingBottom) + L(c ? X.borderLeftWidth : X.borderTopWidth) + L(c ? X.borderRightWidth : X.borderBottomWidth) : 0, p = u > 0 ? u : c ? o.offsetWidth : o.offsetHeight;
|
|
613
|
+
return p <= 0 || R <= 0 ? 1 : R / p;
|
|
591
614
|
},
|
|
592
|
-
[
|
|
593
|
-
),
|
|
594
|
-
(
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
615
|
+
[c]
|
|
616
|
+
), rt = v(
|
|
617
|
+
(o) => {
|
|
618
|
+
const b = O.current;
|
|
619
|
+
if (b.pointerId !== o.pointerId)
|
|
597
620
|
return;
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
delta:
|
|
601
|
-
startThumbPosition:
|
|
602
|
-
clientY:
|
|
603
|
-
startClientY:
|
|
604
|
-
metrics:
|
|
621
|
+
const R = o.clientX - b.startClientX, L = o.clientY - b.startClientY, X = ct(R, L) / (b.scale || 1);
|
|
622
|
+
C.debug("[ScrollBar] handleThumbPointerMove", () => ({
|
|
623
|
+
delta: X,
|
|
624
|
+
startThumbPosition: b.startThumbPosition,
|
|
625
|
+
clientY: o.clientY,
|
|
626
|
+
startClientY: b.startClientY,
|
|
627
|
+
metrics: lt.current
|
|
605
628
|
}));
|
|
606
|
-
const
|
|
607
|
-
|
|
629
|
+
const a = fe(b.startThumbPosition + X);
|
|
630
|
+
a !== null && y(a), o.cancelable && o.preventDefault();
|
|
608
631
|
},
|
|
609
|
-
[
|
|
610
|
-
),
|
|
611
|
-
(
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
632
|
+
[ct, fe, y]
|
|
633
|
+
), zt = v(
|
|
634
|
+
(o) => {
|
|
635
|
+
const b = O.current;
|
|
636
|
+
if (b.pointerId !== o.pointerId)
|
|
614
637
|
return;
|
|
615
|
-
document.removeEventListener("pointermove",
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
618
|
-
const
|
|
619
|
-
|
|
638
|
+
document.removeEventListener("pointermove", rt), document.removeEventListener("pointerup", zt), document.removeEventListener("pointercancel", zt);
|
|
639
|
+
const R = b.captureTarget;
|
|
640
|
+
if (R?.hasPointerCapture?.(o.pointerId) && R.releasePointerCapture(o.pointerId), O.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1, captureTarget: null }, ft(!1), D.current) {
|
|
641
|
+
const L = D.current.getBoundingClientRect();
|
|
642
|
+
o.clientX >= L.left && o.clientX <= L.right && o.clientY >= L.top && o.clientY <= L.bottom || tt(!1);
|
|
620
643
|
} else
|
|
621
|
-
|
|
644
|
+
tt(!1);
|
|
622
645
|
},
|
|
623
|
-
[
|
|
646
|
+
[rt]
|
|
624
647
|
);
|
|
625
|
-
|
|
626
|
-
document.removeEventListener("pointermove",
|
|
627
|
-
}, [
|
|
628
|
-
const
|
|
629
|
-
(
|
|
630
|
-
const
|
|
631
|
-
|
|
648
|
+
Y(() => () => {
|
|
649
|
+
document.removeEventListener("pointermove", rt), document.removeEventListener("pointerup", zt), document.removeEventListener("pointercancel", zt);
|
|
650
|
+
}, [rt, zt]);
|
|
651
|
+
const Te = T(0), Se = T(0), Kt = v(
|
|
652
|
+
(o) => {
|
|
653
|
+
const b = Math.max(Math.round(lt.current.viewportSize / or), sr);
|
|
654
|
+
Se.current !== o && (Se.current = o, Te.current = 0), Lt(Te, o * b);
|
|
632
655
|
},
|
|
633
|
-
[
|
|
634
|
-
), { handleArrowPointerDown: ye, handleArrowPointerUp:
|
|
635
|
-
canUseArrowButtons:
|
|
656
|
+
[Lt]
|
|
657
|
+
), { handleArrowPointerDown: ye, handleArrowPointerUp: me, handleArrowKeyDown: Ae } = pr({
|
|
658
|
+
canUseArrowButtons: Qt,
|
|
636
659
|
enableArrowButtons: l,
|
|
637
|
-
resetTapScroll:
|
|
638
|
-
scrollByStep:
|
|
639
|
-
}),
|
|
640
|
-
if (!
|
|
660
|
+
resetTapScroll: _t,
|
|
661
|
+
scrollByStep: Kt
|
|
662
|
+
}), te = (o) => {
|
|
663
|
+
if (!dt)
|
|
641
664
|
return;
|
|
642
|
-
if (!
|
|
643
|
-
|
|
665
|
+
if (!i) {
|
|
666
|
+
o.preventDefault(), o.stopPropagation();
|
|
644
667
|
return;
|
|
645
668
|
}
|
|
646
|
-
if (
|
|
669
|
+
if (o.pointerType === "mouse" && o.button !== 0 || o.ctrlKey)
|
|
647
670
|
return;
|
|
648
|
-
|
|
649
|
-
const
|
|
650
|
-
let
|
|
651
|
-
if (
|
|
671
|
+
_t();
|
|
672
|
+
const b = o.currentTarget, R = Ie(b);
|
|
673
|
+
let L = null;
|
|
674
|
+
if (b.setPointerCapture)
|
|
652
675
|
try {
|
|
653
|
-
|
|
676
|
+
b.setPointerCapture(o.pointerId), L = b;
|
|
654
677
|
} catch {
|
|
655
|
-
|
|
678
|
+
L = null;
|
|
656
679
|
}
|
|
657
|
-
|
|
658
|
-
pointerId:
|
|
659
|
-
startThumbPosition:
|
|
660
|
-
startClientX:
|
|
661
|
-
startClientY:
|
|
662
|
-
scale:
|
|
663
|
-
captureTarget:
|
|
664
|
-
}, document.addEventListener("pointermove",
|
|
665
|
-
},
|
|
666
|
-
if (!
|
|
680
|
+
O.current = {
|
|
681
|
+
pointerId: o.pointerId,
|
|
682
|
+
startThumbPosition: qt,
|
|
683
|
+
startClientX: o.clientX,
|
|
684
|
+
startClientY: o.clientY,
|
|
685
|
+
scale: R,
|
|
686
|
+
captureTarget: L
|
|
687
|
+
}, document.addEventListener("pointermove", rt), document.addEventListener("pointerup", zt), document.addEventListener("pointercancel", zt), ft(!0), tt(!0), o.preventDefault(), o.stopPropagation();
|
|
688
|
+
}, ie = (o) => {
|
|
689
|
+
if (!dt)
|
|
667
690
|
return;
|
|
668
691
|
if (!s) {
|
|
669
|
-
|
|
692
|
+
o.preventDefault(), o.stopPropagation();
|
|
670
693
|
return;
|
|
671
694
|
}
|
|
672
|
-
if (
|
|
695
|
+
if (o.pointerType === "mouse" && o.button !== 0 || o.ctrlKey)
|
|
673
696
|
return;
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
697
|
+
const b = o.currentTarget, R = b.getBoundingClientRect(), L = H(o), X = Ie(b), a = (L - (c ? R.left : R.top)) / X;
|
|
698
|
+
_t();
|
|
699
|
+
const u = a - ut / 2, p = ce(u);
|
|
700
|
+
if (y(p), b.setPointerCapture)
|
|
678
701
|
try {
|
|
679
|
-
|
|
702
|
+
b.setPointerCapture(o.pointerId);
|
|
680
703
|
} catch {
|
|
681
704
|
}
|
|
682
|
-
|
|
683
|
-
pointerId:
|
|
684
|
-
startThumbPosition:
|
|
685
|
-
startClientX:
|
|
686
|
-
startClientY:
|
|
687
|
-
scale:
|
|
688
|
-
},
|
|
689
|
-
},
|
|
690
|
-
|
|
691
|
-
},
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
705
|
+
M.current = {
|
|
706
|
+
pointerId: o.pointerId,
|
|
707
|
+
startThumbPosition: u,
|
|
708
|
+
startClientX: o.clientX,
|
|
709
|
+
startClientY: o.clientY,
|
|
710
|
+
scale: X
|
|
711
|
+
}, o.preventDefault(), o.stopPropagation();
|
|
712
|
+
}, Ut = () => {
|
|
713
|
+
M.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0, scale: 1 };
|
|
714
|
+
}, ee = (o) => {
|
|
715
|
+
const b = M.current;
|
|
716
|
+
if (b.pointerId !== o.pointerId)
|
|
694
717
|
return;
|
|
695
|
-
if (
|
|
696
|
-
|
|
718
|
+
if (o.pointerType === "mouse" && o.buttons === 0) {
|
|
719
|
+
Ut();
|
|
697
720
|
return;
|
|
698
721
|
}
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
},
|
|
702
|
-
if (
|
|
722
|
+
const R = o.clientX - b.startClientX, L = o.clientY - b.startClientY, X = ct(R, L) / (b.scale || 1), a = ce(b.startThumbPosition + X);
|
|
723
|
+
y(a), o.cancelable && o.preventDefault();
|
|
724
|
+
}, se = (o) => {
|
|
725
|
+
if (M.current.pointerId !== o.pointerId)
|
|
703
726
|
return;
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
},
|
|
707
|
-
if (
|
|
727
|
+
const b = o.currentTarget;
|
|
728
|
+
b.hasPointerCapture?.(o.pointerId) && b.releasePointerCapture(o.pointerId), Ut(), o.preventDefault(), o.stopPropagation();
|
|
729
|
+
}, pe = (o) => {
|
|
730
|
+
if (M.current.pointerId !== o.pointerId)
|
|
708
731
|
return;
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
},
|
|
712
|
-
|
|
713
|
-
},
|
|
714
|
-
const
|
|
732
|
+
const b = o.currentTarget;
|
|
733
|
+
b.hasPointerCapture?.(o.pointerId) && b.releasePointerCapture(o.pointerId), Ut();
|
|
734
|
+
}, re = (o) => {
|
|
735
|
+
o.target === o.currentTarget && M.current.pointerId === o.pointerId && Ut();
|
|
736
|
+
}, we = At(() => xt((pt ? 1 : 0.8) * $t, 0, 1), [pt, $t]), Re = At(() => {
|
|
737
|
+
const b = `calc(50% - ${Rt / 2}px + ${Ct}px)`;
|
|
715
738
|
return {
|
|
716
|
-
left:
|
|
717
|
-
top:
|
|
739
|
+
left: U,
|
|
740
|
+
top: b
|
|
718
741
|
};
|
|
719
|
-
}, [
|
|
742
|
+
}, [U, Ct, Rt]), Ce = (o, b, R, L) => /* @__PURE__ */ it(
|
|
720
743
|
"button",
|
|
721
744
|
{
|
|
722
745
|
type: "button",
|
|
723
746
|
tabIndex: 0,
|
|
724
747
|
className: "aqvs-scrollbar-arrow-button",
|
|
725
748
|
style: {
|
|
726
|
-
[
|
|
727
|
-
[
|
|
749
|
+
[Wt]: f,
|
|
750
|
+
[d]: f
|
|
728
751
|
},
|
|
729
|
-
"aria-label":
|
|
730
|
-
onPointerDown: ye(
|
|
731
|
-
onPointerUp:
|
|
732
|
-
onPointerLeave:
|
|
733
|
-
onPointerCancel:
|
|
734
|
-
onKeyDown:
|
|
752
|
+
"aria-label": b,
|
|
753
|
+
onPointerDown: ye(o),
|
|
754
|
+
onPointerUp: me,
|
|
755
|
+
onPointerLeave: me,
|
|
756
|
+
onPointerCancel: me,
|
|
757
|
+
onKeyDown: Ae(o),
|
|
735
758
|
"aria-disabled": !l,
|
|
736
|
-
disabled: !
|
|
737
|
-
children: /* @__PURE__ */
|
|
759
|
+
disabled: !Qt,
|
|
760
|
+
children: /* @__PURE__ */ it("span", { "aria-hidden": "true", children: R })
|
|
738
761
|
},
|
|
739
|
-
|
|
740
|
-
),
|
|
741
|
-
orientation:
|
|
762
|
+
L
|
|
763
|
+
), he = g && dt ? {
|
|
764
|
+
orientation: Mt,
|
|
742
765
|
scrollPosition: e,
|
|
743
|
-
maxScrollPosition:
|
|
744
|
-
contentSize:
|
|
766
|
+
maxScrollPosition: ot,
|
|
767
|
+
contentSize: n,
|
|
745
768
|
viewportSize: t,
|
|
746
|
-
thumbSize:
|
|
747
|
-
thumbPosition:
|
|
748
|
-
thumbCenter:
|
|
749
|
-
trackSize:
|
|
750
|
-
isDragging:
|
|
751
|
-
isTapScrollActive:
|
|
752
|
-
visibleStartIndex:
|
|
753
|
-
visibleEndIndex:
|
|
769
|
+
thumbSize: ut,
|
|
770
|
+
thumbPosition: qt,
|
|
771
|
+
thumbCenter: le,
|
|
772
|
+
trackSize: St,
|
|
773
|
+
isDragging: j,
|
|
774
|
+
isTapScrollActive: pt,
|
|
775
|
+
visibleStartIndex: _,
|
|
776
|
+
visibleEndIndex: z
|
|
754
777
|
} : null;
|
|
755
|
-
return /* @__PURE__ */
|
|
778
|
+
return /* @__PURE__ */ de(
|
|
756
779
|
"div",
|
|
757
780
|
{
|
|
758
|
-
className:
|
|
781
|
+
className: ue("aqvs-scrollbar", Pt, !dt && "pointer-events-none opacity-0", x),
|
|
759
782
|
style: {
|
|
760
|
-
[
|
|
761
|
-
[
|
|
783
|
+
[Wt]: t,
|
|
784
|
+
[d]: f
|
|
762
785
|
},
|
|
763
786
|
role: "scrollbar",
|
|
764
787
|
tabIndex: -1,
|
|
765
788
|
"aria-controls": I,
|
|
766
789
|
"aria-valuenow": e,
|
|
767
790
|
"aria-valuemin": 0,
|
|
768
|
-
"aria-valuemax":
|
|
769
|
-
"aria-orientation":
|
|
791
|
+
"aria-valuemax": ot,
|
|
792
|
+
"aria-orientation": c ? "horizontal" : "vertical",
|
|
770
793
|
children: [
|
|
771
|
-
!
|
|
772
|
-
|
|
794
|
+
!c && dt && k && /* @__PURE__ */ it(
|
|
795
|
+
Ge,
|
|
773
796
|
{
|
|
774
|
-
ref:
|
|
775
|
-
className:
|
|
776
|
-
size:
|
|
777
|
-
maxVisualDistance:
|
|
778
|
-
style:
|
|
779
|
-
opacity:
|
|
780
|
-
renderVisual:
|
|
781
|
-
onDragChange:
|
|
797
|
+
ref: et,
|
|
798
|
+
className: ue("aqvs-scrollbar-tap-circle-wrapper", w),
|
|
799
|
+
size: Rt,
|
|
800
|
+
maxVisualDistance: Et,
|
|
801
|
+
style: Re,
|
|
802
|
+
opacity: we,
|
|
803
|
+
renderVisual: Bt,
|
|
804
|
+
onDragChange: jt
|
|
782
805
|
},
|
|
783
806
|
"tap-circle"
|
|
784
807
|
),
|
|
785
|
-
|
|
786
|
-
/* @__PURE__ */
|
|
808
|
+
Ce(-1, nt[0], J[0], "arrow-start"),
|
|
809
|
+
/* @__PURE__ */ de(
|
|
787
810
|
"div",
|
|
788
811
|
{
|
|
789
812
|
className: "aqvs-scrollbar-track",
|
|
790
813
|
style: {
|
|
791
814
|
borderRadius: f / 2
|
|
792
815
|
},
|
|
793
|
-
onPointerDown:
|
|
794
|
-
onPointerMove:
|
|
795
|
-
onPointerUp:
|
|
796
|
-
onPointerCancel:
|
|
797
|
-
onLostPointerCapture:
|
|
816
|
+
onPointerDown: ie,
|
|
817
|
+
onPointerMove: ee,
|
|
818
|
+
onPointerUp: se,
|
|
819
|
+
onPointerCancel: pe,
|
|
820
|
+
onLostPointerCapture: re,
|
|
798
821
|
"aria-disabled": !s,
|
|
799
822
|
children: [
|
|
800
|
-
|
|
801
|
-
/* @__PURE__ */
|
|
823
|
+
he && /* @__PURE__ */ it("div", { className: "aqvs-scrollbar-overlay", "aria-hidden": !0, children: g?.(he) }, "overlay"),
|
|
824
|
+
/* @__PURE__ */ it(
|
|
802
825
|
"div",
|
|
803
826
|
{
|
|
804
|
-
className:
|
|
827
|
+
className: ue("aqvs-scrollbar-thumb-wrapper", !(dt || j) && "pointer-events-none opacity-0"),
|
|
805
828
|
style: {
|
|
806
|
-
[
|
|
807
|
-
[
|
|
808
|
-
...
|
|
829
|
+
[Wt]: ut,
|
|
830
|
+
[mt]: qt,
|
|
831
|
+
...c ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
809
832
|
},
|
|
810
|
-
onPointerDown:
|
|
833
|
+
onPointerDown: te,
|
|
811
834
|
role: "slider",
|
|
812
|
-
"aria-orientation":
|
|
835
|
+
"aria-orientation": c ? "horizontal" : "vertical",
|
|
813
836
|
"aria-valuenow": e,
|
|
814
837
|
"aria-valuemin": 0,
|
|
815
|
-
"aria-valuemax":
|
|
816
|
-
"aria-disabled": !
|
|
838
|
+
"aria-valuemax": ot,
|
|
839
|
+
"aria-disabled": !i,
|
|
817
840
|
tabIndex: -1,
|
|
818
|
-
children: /* @__PURE__ */
|
|
841
|
+
children: /* @__PURE__ */ it(
|
|
819
842
|
"div",
|
|
820
843
|
{
|
|
821
|
-
ref:
|
|
822
|
-
className:
|
|
823
|
-
"data-
|
|
844
|
+
ref: D,
|
|
845
|
+
className: ue("aqvs-scrollbar-thumb", c ? "aqvs-scrollbar-thumb-horizontal" : "aqvs-scrollbar-thumb-vertical"),
|
|
846
|
+
"data-testid": "aqvs-scrollbar-thumb",
|
|
847
|
+
"data-thumb-state": m,
|
|
824
848
|
style: {
|
|
825
849
|
borderRadius: f - 1,
|
|
826
|
-
cursor:
|
|
850
|
+
cursor: i ? "pointer" : "default"
|
|
827
851
|
},
|
|
828
852
|
onMouseEnter: () => {
|
|
829
|
-
|
|
853
|
+
i && tt(!0);
|
|
830
854
|
},
|
|
831
855
|
onMouseLeave: () => {
|
|
832
|
-
|
|
856
|
+
i && tt(!1);
|
|
833
857
|
}
|
|
834
858
|
},
|
|
835
859
|
"thumb"
|
|
@@ -841,198 +865,202 @@ const pt = (i, t, e) => Math.max(t, Math.min(e, i)), Oe = "virtualscroll:tap-scr
|
|
|
841
865
|
},
|
|
842
866
|
"track"
|
|
843
867
|
),
|
|
844
|
-
|
|
868
|
+
Ce(1, nt[1], J[1], "arrow-end")
|
|
845
869
|
]
|
|
846
870
|
}
|
|
847
871
|
);
|
|
848
|
-
},
|
|
872
|
+
}, Ir = ["mouse", "pen", "touch"], ke = (n, t) => !(n === "mouse" || n === "pen" || n === "touch") || t.includes(n), Tr = (n) => n === "mouse" || n === "pen", Pe = {
|
|
849
873
|
maxVelocity: 6,
|
|
850
874
|
minVelocity: 0.02,
|
|
851
875
|
deceleration: 25e-4,
|
|
852
876
|
velocitySampleWindow: 90,
|
|
853
877
|
startVelocityThreshold: 0.04
|
|
854
|
-
},
|
|
855
|
-
for (const [r,
|
|
856
|
-
e === "add" ?
|
|
857
|
-
},
|
|
878
|
+
}, Ee = (n, t, e) => {
|
|
879
|
+
for (const [r, i, s] of t)
|
|
880
|
+
e === "add" ? n.addEventListener(r, i, s) : n.removeEventListener(r, i, s);
|
|
881
|
+
}, Sr = Ye(
|
|
858
882
|
({
|
|
859
|
-
children:
|
|
883
|
+
children: n,
|
|
860
884
|
contentSize: t,
|
|
861
885
|
viewportSize: e,
|
|
862
886
|
scrollBarWidth: r = 12,
|
|
863
|
-
enableThumbDrag:
|
|
887
|
+
enableThumbDrag: i = !0,
|
|
864
888
|
enableTrackClick: s = !0,
|
|
865
889
|
enableArrowButtons: l = !0,
|
|
866
|
-
enablePointerDrag:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
890
|
+
enablePointerDrag: c = !0,
|
|
891
|
+
pointerDragInputs: f = Ir,
|
|
892
|
+
onScroll: x,
|
|
893
|
+
className: I,
|
|
894
|
+
testId: P,
|
|
895
|
+
style: E,
|
|
896
|
+
background: g,
|
|
897
|
+
tapScrollCircleOptions: _,
|
|
898
|
+
inertiaOptions: z,
|
|
899
|
+
itemCount: j,
|
|
900
|
+
renderThumbOverlay: ft,
|
|
901
|
+
wheelSpeedMultiplier: Q = 1,
|
|
902
|
+
onWheelHorizontal: tt,
|
|
903
|
+
contentInsets: pt,
|
|
904
|
+
visibleStartIndex: It,
|
|
905
|
+
visibleEndIndex: D,
|
|
906
|
+
renderOverlay: O,
|
|
907
|
+
initialScrollPosition: M = 0
|
|
908
|
+
}, B) => {
|
|
909
|
+
const N = T(Number.isFinite(M) ? Math.max(0, M) : 0), q = T(null), et = T(null), G = T(tt);
|
|
910
|
+
Y(() => {
|
|
911
|
+
G.current = tt;
|
|
912
|
+
}, [tt]);
|
|
913
|
+
const h = T({
|
|
889
914
|
frame: null,
|
|
890
915
|
velocity: 0,
|
|
891
916
|
lastTimestamp: null,
|
|
892
917
|
generation: 0
|
|
893
|
-
}),
|
|
918
|
+
}), $ = At(
|
|
894
919
|
() => ({
|
|
895
|
-
maxVelocity:
|
|
896
|
-
minVelocity:
|
|
897
|
-
deceleration:
|
|
898
|
-
velocitySampleWindow:
|
|
899
|
-
startVelocityThreshold:
|
|
920
|
+
maxVelocity: z?.maxVelocity ?? Pe.maxVelocity,
|
|
921
|
+
minVelocity: z?.minVelocity ?? Pe.minVelocity,
|
|
922
|
+
deceleration: z?.deceleration ?? Pe.deceleration,
|
|
923
|
+
velocitySampleWindow: z?.velocitySampleWindow ?? Pe.velocitySampleWindow,
|
|
924
|
+
startVelocityThreshold: z?.startVelocityThreshold ?? Pe.startVelocityThreshold
|
|
900
925
|
}),
|
|
901
|
-
[
|
|
902
|
-
),
|
|
903
|
-
top: Math.max(0,
|
|
904
|
-
bottom: Math.max(0,
|
|
905
|
-
}), [
|
|
906
|
-
|
|
926
|
+
[z]
|
|
927
|
+
), Tt = At(() => ({
|
|
928
|
+
top: Math.max(0, pt?.top ?? 0),
|
|
929
|
+
bottom: Math.max(0, pt?.bottom ?? 0)
|
|
930
|
+
}), [pt]);
|
|
931
|
+
C.debug("[ScrollPane] ScrollPane rendered", () => ({
|
|
907
932
|
contentSize: t,
|
|
908
933
|
viewportSize: e,
|
|
909
934
|
scrollBarWidth: r,
|
|
910
|
-
className:
|
|
911
|
-
style:
|
|
912
|
-
tapScrollCircleOptions:
|
|
913
|
-
inertiaOptions:
|
|
914
|
-
enablePointerDrag:
|
|
915
|
-
contentInsets:
|
|
935
|
+
className: I,
|
|
936
|
+
style: E,
|
|
937
|
+
tapScrollCircleOptions: _,
|
|
938
|
+
inertiaOptions: z,
|
|
939
|
+
enablePointerDrag: c,
|
|
940
|
+
contentInsets: Tt
|
|
916
941
|
}));
|
|
917
|
-
const
|
|
918
|
-
|
|
919
|
-
const
|
|
920
|
-
(
|
|
921
|
-
const { contentSize:
|
|
922
|
-
if (
|
|
923
|
-
return
|
|
924
|
-
const
|
|
925
|
-
if (!Number.isFinite(
|
|
926
|
-
return
|
|
927
|
-
const
|
|
928
|
-
return
|
|
942
|
+
const wt = T({ contentSize: t, viewportSize: e });
|
|
943
|
+
wt.current = { contentSize: t, viewportSize: e };
|
|
944
|
+
const Z = At(() => t > e, [t, e]), k = v(
|
|
945
|
+
(d) => {
|
|
946
|
+
const { contentSize: mt, viewportSize: ct } = wt.current, H = mt > ct, nt = N.current;
|
|
947
|
+
if (C.debug("[ScrollPane] scrollTo called", () => ({ newPosition: d, contentSize: mt, viewportSize: ct, currentIsScrollable: H, prevPosition: nt })), !H)
|
|
948
|
+
return N.current !== 0 && (N.current = 0, x?.(0, nt)), N.current;
|
|
949
|
+
const J = typeof d == "function" ? d(N.current) : d;
|
|
950
|
+
if (!Number.isFinite(J))
|
|
951
|
+
return C.warn("[ScrollPane] scrollTo received a non-finite position; keeping the current position", { nextPosition: J }), N.current;
|
|
952
|
+
const Pt = Math.max(mt - ct, 0), Mt = xt(J, 0, Pt);
|
|
953
|
+
return N.current !== Mt && (N.current = Mt, x?.(Mt, nt)), N.current;
|
|
929
954
|
},
|
|
930
|
-
[
|
|
931
|
-
),
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
}, [])
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
955
|
+
[x]
|
|
956
|
+
), Rt = T(k);
|
|
957
|
+
Y(() => {
|
|
958
|
+
Rt.current = k;
|
|
959
|
+
}, [k]);
|
|
960
|
+
const U = v(() => {
|
|
961
|
+
const d = h.current;
|
|
962
|
+
d.generation += 1, d.frame !== null && cancelAnimationFrame(d.frame), d.frame = null, d.velocity = 0, d.lastTimestamp = null;
|
|
963
|
+
}, []), Ct = T(U);
|
|
964
|
+
Y(() => {
|
|
965
|
+
Ct.current = U;
|
|
966
|
+
}, [U]), Y(() => () => {
|
|
967
|
+
Ct.current();
|
|
939
968
|
}, []);
|
|
940
|
-
const
|
|
941
|
-
(
|
|
942
|
-
if (!
|
|
969
|
+
const w = v(
|
|
970
|
+
(d) => {
|
|
971
|
+
if (!Z)
|
|
943
972
|
return;
|
|
944
|
-
const { maxVelocity:
|
|
945
|
-
if (Math.abs(
|
|
973
|
+
const { maxVelocity: mt, minVelocity: ct, deceleration: H, startVelocityThreshold: nt } = $, J = xt(d, -mt, mt);
|
|
974
|
+
if (Math.abs(J) < nt)
|
|
946
975
|
return;
|
|
947
|
-
|
|
948
|
-
const
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
976
|
+
U(), h.current.velocity = J, h.current.lastTimestamp = null;
|
|
977
|
+
const Pt = h.current.generation, Mt = (Et) => {
|
|
978
|
+
const st = h.current;
|
|
979
|
+
if (st.generation !== Pt)
|
|
951
980
|
return;
|
|
952
|
-
if (
|
|
953
|
-
|
|
981
|
+
if (st.lastTimestamp === null) {
|
|
982
|
+
st.lastTimestamp = Et, st.frame = requestAnimationFrame(Mt);
|
|
954
983
|
return;
|
|
955
984
|
}
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
|
|
985
|
+
const St = Et - st.lastTimestamp;
|
|
986
|
+
if (st.lastTimestamp = Et, St <= 0) {
|
|
987
|
+
st.frame = requestAnimationFrame(Mt);
|
|
959
988
|
return;
|
|
960
989
|
}
|
|
961
|
-
const
|
|
962
|
-
let
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
990
|
+
const yt = st.velocity;
|
|
991
|
+
let ut = yt;
|
|
992
|
+
const ot = H * St;
|
|
993
|
+
yt > 0 ? ut = Math.max(0, yt - ot) : yt < 0 && (ut = Math.min(0, yt + ot));
|
|
994
|
+
const qt = (yt + ut) / 2 * St, le = N.current;
|
|
995
|
+
if (qt !== 0 && Rt.current((Lt) => Lt + qt), h.current.generation !== Pt)
|
|
967
996
|
return;
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
const
|
|
971
|
-
if (Math.abs(
|
|
972
|
-
|
|
997
|
+
const dt = N.current, { contentSize: Qt, viewportSize: m } = wt.current, y = Math.max(Qt - m, 0);
|
|
998
|
+
st.velocity = ut;
|
|
999
|
+
const Nt = dt === le || dt <= 0 && ut <= 0 || dt >= y && ut >= 0;
|
|
1000
|
+
if (Math.abs(ut) < ct || Nt) {
|
|
1001
|
+
U();
|
|
973
1002
|
return;
|
|
974
1003
|
}
|
|
975
|
-
|
|
1004
|
+
st.frame = requestAnimationFrame(Mt);
|
|
976
1005
|
};
|
|
977
|
-
|
|
1006
|
+
h.current.frame = requestAnimationFrame(Mt);
|
|
978
1007
|
},
|
|
979
|
-
[
|
|
980
|
-
),
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
}, [
|
|
984
|
-
|
|
985
|
-
}, [t, e]),
|
|
986
|
-
const
|
|
987
|
-
if (!
|
|
988
|
-
const
|
|
989
|
-
|
|
1008
|
+
[Z, $, U]
|
|
1009
|
+
), Yt = T(w);
|
|
1010
|
+
Y(() => {
|
|
1011
|
+
Yt.current = w;
|
|
1012
|
+
}, [w]), xe(() => {
|
|
1013
|
+
wt.current = { contentSize: t, viewportSize: e };
|
|
1014
|
+
}, [t, e]), xe(() => {
|
|
1015
|
+
const d = et.current;
|
|
1016
|
+
if (!d) return;
|
|
1017
|
+
const mt = () => {
|
|
1018
|
+
d.scrollTop !== 0 && (C.debug("[ScrollPane] Native scroll detected, resetting to 0", () => ({ scrollTop: d.scrollTop })), d.scrollTop = 0), d.scrollLeft !== 0 && (d.scrollLeft = 0);
|
|
990
1019
|
};
|
|
991
|
-
return
|
|
992
|
-
}, []),
|
|
993
|
-
if (
|
|
994
|
-
|
|
995
|
-
const
|
|
996
|
-
|
|
1020
|
+
return d.addEventListener("scroll", mt), () => d.removeEventListener("scroll", mt);
|
|
1021
|
+
}, []), xe(() => {
|
|
1022
|
+
if (Z) {
|
|
1023
|
+
C.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", () => ({ contentSize: t, viewportSize: e, scrollPosition: N.current }));
|
|
1024
|
+
const d = xt(t - e, 0, t);
|
|
1025
|
+
N.current > d && k(d);
|
|
997
1026
|
} else
|
|
998
|
-
|
|
999
|
-
}, [
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1027
|
+
k(0);
|
|
1028
|
+
}, [Z, k, t, e]), Y(() => {
|
|
1029
|
+
const d = (H) => {
|
|
1030
|
+
if (H.ctrlKey)
|
|
1002
1031
|
return;
|
|
1003
|
-
const
|
|
1004
|
-
if (
|
|
1005
|
-
if (
|
|
1006
|
-
|
|
1007
|
-
let
|
|
1008
|
-
|
|
1032
|
+
const nt = H.shiftKey && H.deltaX === 0, J = nt ? H.deltaY : H.deltaX, Pt = nt ? 0 : H.deltaY;
|
|
1033
|
+
if (J !== 0 && Math.abs(J) >= Math.abs(Pt)) {
|
|
1034
|
+
if (G.current) {
|
|
1035
|
+
H.preventDefault(), U();
|
|
1036
|
+
let st = J;
|
|
1037
|
+
H.deltaMode === 1 ? st *= 16 : H.deltaMode === 2 && (st *= e), G.current(st);
|
|
1009
1038
|
}
|
|
1010
1039
|
return;
|
|
1011
1040
|
}
|
|
1012
|
-
if (!
|
|
1041
|
+
if (!Z || H.deltaY === 0)
|
|
1013
1042
|
return;
|
|
1014
|
-
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
},
|
|
1018
|
-
|
|
1019
|
-
|
|
1043
|
+
H.preventDefault(), U();
|
|
1044
|
+
let Et = H.deltaY;
|
|
1045
|
+
H.deltaMode === 1 ? Et *= 16 : H.deltaMode === 2 && (Et *= e), Q !== 1 && (Et *= Q), C.debug("[ScrollPane] wheel event", () => ({ deltaY: Et, scrollPosition: N.current, wheelSpeedMultiplier: Q, deltaMode: H.deltaMode, scrollTop: et.current?.scrollTop })), k((st) => st + Et);
|
|
1046
|
+
}, mt = () => {
|
|
1047
|
+
U();
|
|
1048
|
+
}, ct = q.current;
|
|
1049
|
+
return ct && (ct.addEventListener("wheel", d, { passive: !1 }), ct.addEventListener("pointerdown", mt, { capture: !0, passive: !0 })), () => {
|
|
1050
|
+
ct && (ct.removeEventListener("wheel", d), ct.removeEventListener("pointerdown", mt, { capture: !0 }));
|
|
1020
1051
|
};
|
|
1021
|
-
}, [
|
|
1022
|
-
|
|
1052
|
+
}, [Z, k, U, e, Q]), Be(
|
|
1053
|
+
B,
|
|
1023
1054
|
() => ({
|
|
1024
|
-
scrollTo: (
|
|
1025
|
-
getScrollPosition: () =>
|
|
1055
|
+
scrollTo: (d) => (U(), k(d)),
|
|
1056
|
+
getScrollPosition: () => N.current,
|
|
1026
1057
|
getContentSize: () => t,
|
|
1027
1058
|
getViewportSize: () => e
|
|
1028
1059
|
}),
|
|
1029
|
-
[
|
|
1060
|
+
[k, t, e, U]
|
|
1030
1061
|
);
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
Ft.current = Y;
|
|
1034
|
-
}, [Y]);
|
|
1035
|
-
const Lt = er(), v = g({
|
|
1062
|
+
const Xt = tr(), S = T({
|
|
1063
|
+
pointerType: "",
|
|
1036
1064
|
pointerId: null,
|
|
1037
1065
|
startClientY: 0,
|
|
1038
1066
|
startScroll: 0,
|
|
@@ -1040,225 +1068,264 @@ const pt = (i, t, e) => Math.max(t, Math.min(e, i)), Oe = "virtualscroll:tap-scr
|
|
|
1040
1068
|
shouldCancelNextClick: !1,
|
|
1041
1069
|
clickResetTimer: null,
|
|
1042
1070
|
velocitySamples: []
|
|
1043
|
-
}),
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
}, [
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1071
|
+
}), $t = T(c), Bt = T(f);
|
|
1072
|
+
Y(() => {
|
|
1073
|
+
$t.current = c;
|
|
1074
|
+
}, [c]), Y(() => {
|
|
1075
|
+
Bt.current = f;
|
|
1076
|
+
}, [f]);
|
|
1077
|
+
const Jt = T(Z);
|
|
1078
|
+
Y(() => {
|
|
1079
|
+
Jt.current = Z;
|
|
1080
|
+
}, [Z]);
|
|
1081
|
+
const lt = T($);
|
|
1082
|
+
Y(() => {
|
|
1083
|
+
lt.current = $;
|
|
1084
|
+
}, [$]), Y(() => {
|
|
1085
|
+
const d = S.current;
|
|
1086
|
+
if (c && Z && (d.pointerId === null || ke(d.pointerType, f)) || d.pointerId === null)
|
|
1056
1087
|
return;
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1088
|
+
const mt = et.current;
|
|
1089
|
+
d.clickResetTimer !== null && (window.clearTimeout(d.clickResetTimer), d.clickResetTimer = null);
|
|
1090
|
+
const ct = d.isDragging && d.shouldCancelNextClick, H = d.pointerId;
|
|
1091
|
+
d.pointerId = null, d.pointerType = "", d.startClientY = 0, d.startScroll = 0, d.isDragging = !1, d.shouldCancelNextClick = ct, d.velocitySamples = [], mt?.hasPointerCapture(H) && mt.releasePointerCapture(H);
|
|
1092
|
+
}, [c, f, Z]), Y(() => {
|
|
1093
|
+
const d = et.current;
|
|
1094
|
+
if (!d)
|
|
1062
1095
|
return;
|
|
1063
|
-
const
|
|
1064
|
-
const m =
|
|
1065
|
-
m.pointerId = null, m.startClientY = 0, m.startScroll = 0, m.isDragging = !1, m.velocitySamples = [];
|
|
1066
|
-
},
|
|
1067
|
-
const m =
|
|
1096
|
+
const mt = 6, ct = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), H = () => {
|
|
1097
|
+
const m = S.current;
|
|
1098
|
+
m.pointerId = null, m.pointerType = "", m.startClientY = 0, m.startScroll = 0, m.isDragging = !1, m.velocitySamples = [];
|
|
1099
|
+
}, nt = () => {
|
|
1100
|
+
const m = S.current;
|
|
1068
1101
|
m.clickResetTimer !== null && (window.clearTimeout(m.clickResetTimer), m.clickResetTimer = null);
|
|
1069
|
-
},
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
},
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1077
|
-
},
|
|
1078
|
-
const
|
|
1079
|
-
if (!
|
|
1080
|
-
if (
|
|
1102
|
+
}, J = (m) => {
|
|
1103
|
+
const y = S.current, Nt = ct();
|
|
1104
|
+
y.velocitySamples.push({ clientY: m, time: Nt });
|
|
1105
|
+
const Lt = lt.current.velocitySampleWindow;
|
|
1106
|
+
y.velocitySamples = y.velocitySamples.filter((at) => Nt - at.time <= Lt);
|
|
1107
|
+
}, Pt = (m) => m instanceof HTMLElement && m.closest("[data-scrollpane-ignore-drag='true']") !== null, Mt = (m) => {
|
|
1108
|
+
const y = S.current;
|
|
1109
|
+
y.shouldCancelNextClick && (m.preventDefault(), m.stopPropagation(), y.shouldCancelNextClick = !1);
|
|
1110
|
+
}, Et = (m) => {
|
|
1111
|
+
const y = S.current;
|
|
1112
|
+
if (!y.isDragging) {
|
|
1113
|
+
if (y.isDragging = !0, y.shouldCancelNextClick = !0, !d.hasPointerCapture(m.pointerId))
|
|
1081
1114
|
try {
|
|
1082
|
-
|
|
1115
|
+
d.setPointerCapture(m.pointerId);
|
|
1083
1116
|
} catch {
|
|
1084
1117
|
}
|
|
1085
|
-
|
|
1118
|
+
J(m.clientY);
|
|
1086
1119
|
}
|
|
1087
|
-
},
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
},
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1120
|
+
}, st = (m) => m.isTrusted || m.target === d, St = (m) => {
|
|
1121
|
+
const y = S.current;
|
|
1122
|
+
d.hasPointerCapture(m) && d.releasePointerCapture(m), y.shouldCancelNextClick = !1, nt(), H();
|
|
1123
|
+
}, yt = (m) => {
|
|
1124
|
+
const y = S.current;
|
|
1125
|
+
if (y.pointerId !== m.pointerId)
|
|
1093
1126
|
return;
|
|
1094
|
-
if (m.buttons === 0) {
|
|
1095
|
-
|
|
1127
|
+
if (m.buttons === 0 && Tr(m.pointerType)) {
|
|
1128
|
+
St(m.pointerId);
|
|
1096
1129
|
return;
|
|
1097
1130
|
}
|
|
1098
|
-
if (!(
|
|
1131
|
+
if (!($t.current && Jt.current) || !ke(m.pointerType, Bt.current) || !y.isDragging && (Math.abs(m.clientY - y.startClientY) < mt || (Et(m), !y.isDragging)))
|
|
1099
1132
|
return;
|
|
1100
|
-
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
},
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1133
|
+
J(m.clientY);
|
|
1134
|
+
const Nt = m.clientY - y.startClientY, Lt = y.startScroll - Nt;
|
|
1135
|
+
Rt.current(Lt), m.cancelable && m.preventDefault();
|
|
1136
|
+
}, ut = () => {
|
|
1137
|
+
const m = S.current;
|
|
1138
|
+
return m.pointerId !== null || !m.shouldCancelNextClick ? !1 : (nt(), m.clickResetTimer = window.setTimeout(() => {
|
|
1139
|
+
const y = S.current;
|
|
1140
|
+
y.shouldCancelNextClick = !1, y.clickResetTimer = null;
|
|
1141
|
+
}, 0), !0);
|
|
1142
|
+
}, ot = (m) => {
|
|
1143
|
+
const y = S.current;
|
|
1144
|
+
if (y.pointerId !== m.pointerId) {
|
|
1145
|
+
ut();
|
|
1106
1146
|
return;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1147
|
+
}
|
|
1148
|
+
y.isDragging && y.shouldCancelNextClick && m.cancelable && (m.preventDefault(), m.stopPropagation()), y.isDragging && J(m.clientY);
|
|
1149
|
+
let Nt = 0;
|
|
1150
|
+
if (y.isDragging && y.velocitySamples.length >= 2) {
|
|
1151
|
+
const at = y.velocitySamples, _t = lt.current.velocitySampleWindow, Ht = at[at.length - 1], kt = at.find((jt) => Ht.time - jt.time <= _t) ?? at[0];
|
|
1152
|
+
if (Ht && kt && Ht.time !== kt.time) {
|
|
1153
|
+
const jt = Ht.clientY - kt.clientY, ce = Ht.time - kt.time;
|
|
1154
|
+
Nt = -(jt / ce);
|
|
1114
1155
|
}
|
|
1115
1156
|
}
|
|
1116
|
-
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1157
|
+
nt(), y.shouldCancelNextClick && (y.clickResetTimer = window.setTimeout(() => {
|
|
1158
|
+
const at = S.current;
|
|
1159
|
+
at.shouldCancelNextClick = !1, at.clickResetTimer = null;
|
|
1119
1160
|
}, 0));
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
},
|
|
1123
|
-
if (
|
|
1161
|
+
const Lt = lt.current.startVelocityThreshold;
|
|
1162
|
+
H(), d.hasPointerCapture(m.pointerId) && d.releasePointerCapture(m.pointerId), Math.abs(Nt) >= Lt && Yt.current?.(Nt);
|
|
1163
|
+
}, Dt = (m) => {
|
|
1164
|
+
if (S.current.pointerId !== null) {
|
|
1165
|
+
if (!m.isPrimary || m.pointerType !== S.current.pointerType)
|
|
1166
|
+
return;
|
|
1167
|
+
St(S.current.pointerId);
|
|
1168
|
+
}
|
|
1169
|
+
if (S.current.shouldCancelNextClick && (nt(), S.current.shouldCancelNextClick = !1), !($t.current && Jt.current) || !ke(m.pointerType, Bt.current) || m.button !== 0 && m.pointerType === "mouse" || m.ctrlKey || m.metaKey || m.altKey || Pt(m.target))
|
|
1124
1170
|
return;
|
|
1125
|
-
window.dispatchEvent(new CustomEvent(
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1128
|
-
},
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1171
|
+
window.dispatchEvent(new CustomEvent(ze, { detail: { paneId: Xt } })), Ct.current?.();
|
|
1172
|
+
const y = S.current;
|
|
1173
|
+
nt(), y.pointerId = m.pointerId, y.pointerType = m.pointerType, y.startClientY = m.clientY, y.startScroll = N.current, y.isDragging = !1, y.shouldCancelNextClick = !1, y.velocitySamples = [];
|
|
1174
|
+
}, qt = (m) => {
|
|
1175
|
+
if (S.current.pointerId !== m.pointerId) {
|
|
1176
|
+
ut();
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
st(m) && St(m.pointerId);
|
|
1180
|
+
}, dt = [
|
|
1181
|
+
["click", Mt, !0],
|
|
1182
|
+
["pointerdown", Dt, { passive: !1 }],
|
|
1133
1183
|
["lostpointercapture", (m) => {
|
|
1134
|
-
|
|
1184
|
+
m.target !== d || S.current.pointerId !== m.pointerId || St(m.pointerId);
|
|
1135
1185
|
}, void 0]
|
|
1136
|
-
],
|
|
1137
|
-
["pointermove",
|
|
1138
|
-
["pointerup",
|
|
1139
|
-
["pointercancel",
|
|
1186
|
+
], Qt = [
|
|
1187
|
+
["pointermove", yt, { passive: !1 }],
|
|
1188
|
+
["pointerup", ot, void 0],
|
|
1189
|
+
["pointercancel", qt, void 0]
|
|
1140
1190
|
];
|
|
1141
|
-
return
|
|
1142
|
-
|
|
1143
|
-
const m =
|
|
1144
|
-
m.pointerId !== null &&
|
|
1191
|
+
return Ee(d, dt, "add"), Ee(window, Qt, "add"), () => {
|
|
1192
|
+
Ee(d, dt, "remove"), Ee(window, Qt, "remove");
|
|
1193
|
+
const m = S.current;
|
|
1194
|
+
m.pointerId !== null && d.hasPointerCapture(m.pointerId) && d.releasePointerCapture(m.pointerId), nt(), H();
|
|
1145
1195
|
};
|
|
1146
|
-
}, [
|
|
1147
|
-
|
|
1196
|
+
}, [Xt]);
|
|
1197
|
+
const Wt = v(
|
|
1198
|
+
(d) => (U(), k(d)),
|
|
1199
|
+
[k, U]
|
|
1200
|
+
);
|
|
1201
|
+
return /* @__PURE__ */ de("div", { ref: q, "data-testid": P, className: ue("aqvs-scroll-pane", I), style: E, children: [
|
|
1202
|
+
/* @__PURE__ */ de(
|
|
1148
1203
|
"div",
|
|
1149
1204
|
{
|
|
1150
|
-
ref:
|
|
1151
|
-
className:
|
|
1205
|
+
ref: et,
|
|
1206
|
+
className: ue("aqvs-scroll-pane-content"),
|
|
1207
|
+
"data-testid": "aqvs-scroll-pane-content",
|
|
1152
1208
|
style: {
|
|
1153
1209
|
height: e,
|
|
1154
|
-
paddingTop:
|
|
1155
|
-
paddingBottom:
|
|
1210
|
+
paddingTop: Tt.top,
|
|
1211
|
+
paddingBottom: Tt.bottom,
|
|
1156
1212
|
// スクロール不能時 (contentSize <= viewportSize) は touch-action を通常に戻し、
|
|
1157
|
-
//
|
|
1158
|
-
|
|
1213
|
+
// 短いリスト上のタッチがページ全体のパンを妨げるデッドゾーン化を防ぐ。
|
|
1214
|
+
// 直接操作 (指・ペン) のドラッグを許可していない場合も付けない。
|
|
1215
|
+
// touch-action はペン入力にも効くため、判定は touch と pen の論理和にする
|
|
1216
|
+
//
|
|
1217
|
+
// ❗ この値はタッチ開始時にラッチされる (実測: 1ms 後に none へ変えても手遅れ)。
|
|
1218
|
+
// 中身が非同期に届くリストでは、「まだスクロール不能」な一瞬に指が着地すると
|
|
1219
|
+
// **そのジェスチャ 1 回分**はブラウザに接収されたまま戻らない。
|
|
1220
|
+
// 指を離して置き直せば次のジェスチャからは正常に効くため、損失は 1 ジェスチャに
|
|
1221
|
+
// 限られ恒久破損にはならない (実測で確認)。ドラッグ許可の判定 (isScrollable) と
|
|
1222
|
+
// 同一条件で揃えてあるため状態としても一貫している。
|
|
1223
|
+
// 非同期コンテンツを先読みして確保する挙動は意図的に入れていない
|
|
1224
|
+
// (空のペインがページのパンを殺すデッドゾーンになり、そちらの実害の方が大きいため)。
|
|
1225
|
+
...c && Z && f.some((d) => d === "touch" || d === "pen") ? { touchAction: "none" } : {}
|
|
1159
1226
|
},
|
|
1160
|
-
id:
|
|
1227
|
+
id: Xt,
|
|
1161
1228
|
children: [
|
|
1162
|
-
|
|
1163
|
-
|
|
1229
|
+
g,
|
|
1230
|
+
n(N.current)
|
|
1164
1231
|
]
|
|
1165
1232
|
}
|
|
1166
1233
|
),
|
|
1167
|
-
/* @__PURE__ */
|
|
1168
|
-
|
|
1234
|
+
/* @__PURE__ */ it(
|
|
1235
|
+
xr,
|
|
1169
1236
|
{
|
|
1170
1237
|
contentSize: t,
|
|
1171
1238
|
viewportSize: e,
|
|
1172
|
-
scrollPosition:
|
|
1173
|
-
onScroll:
|
|
1174
|
-
enableThumbDrag:
|
|
1239
|
+
scrollPosition: N.current,
|
|
1240
|
+
onScroll: Wt,
|
|
1241
|
+
enableThumbDrag: i,
|
|
1175
1242
|
enableTrackClick: s,
|
|
1176
1243
|
enableArrowButtons: l,
|
|
1177
1244
|
scrollBarWidth: r,
|
|
1178
|
-
ariaControls:
|
|
1179
|
-
tapScrollCircleOptions:
|
|
1180
|
-
itemCount:
|
|
1181
|
-
renderThumbOverlay:
|
|
1182
|
-
visibleStartIndex:
|
|
1183
|
-
visibleEndIndex:
|
|
1245
|
+
ariaControls: Xt,
|
|
1246
|
+
tapScrollCircleOptions: _,
|
|
1247
|
+
itemCount: j,
|
|
1248
|
+
renderThumbOverlay: ft,
|
|
1249
|
+
visibleStartIndex: It,
|
|
1250
|
+
visibleEndIndex: D
|
|
1184
1251
|
},
|
|
1185
1252
|
"scrollbar"
|
|
1186
1253
|
),
|
|
1187
|
-
|
|
1254
|
+
O?.()
|
|
1188
1255
|
] });
|
|
1189
1256
|
}
|
|
1190
|
-
),
|
|
1191
|
-
const
|
|
1192
|
-
return /* @__PURE__ */
|
|
1193
|
-
/* @__PURE__ */
|
|
1257
|
+
), $e = (n, t, e) => Math.min(Math.max(n, t), e), kr = ({ dragState: n, normalizedDistance: t, sizeScale: e, size: r }) => {
|
|
1258
|
+
const i = Math.max(r / 2, 1), s = 1 + t * 0.65, l = Math.max(0.65, 1 - t * 0.25), c = n.direction * t * 26 * e, f = 0.8 + t * 0.18, x = 3 * e, I = 6 * e, P = 22 * e, E = Math.abs(c) + I, g = c > 0 ? x : -Math.abs(c) - x, _ = Math.max(2.5, 3 * e), z = $e(n.offsetX, -i, i), j = $e(n.offsetY, -i, i), ft = i * 0.35, Q = z / i * ft, tt = j / i * ft, pt = Q * 0.45, It = tt * 0.45, D = Math.max(P * 0.38, 6), O = 0.65 + t * 0.2, M = n.active;
|
|
1259
|
+
return /* @__PURE__ */ de(je, { children: [
|
|
1260
|
+
/* @__PURE__ */ it(
|
|
1194
1261
|
"div",
|
|
1195
1262
|
{
|
|
1196
1263
|
className: "aqvs-tap-scroll-circle-gradient",
|
|
1197
1264
|
style: {
|
|
1198
1265
|
transform: `scale(${l}, ${s})`,
|
|
1199
|
-
transition:
|
|
1266
|
+
transition: M ? "40ms transform ease-out" : "200ms ease transform"
|
|
1200
1267
|
}
|
|
1201
1268
|
}
|
|
1202
1269
|
),
|
|
1203
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ it(
|
|
1204
1271
|
"div",
|
|
1205
1272
|
{
|
|
1206
|
-
className: "aqvs-sample-visual-
|
|
1273
|
+
className: "aqvs-sample-visual-pupil",
|
|
1207
1274
|
style: {
|
|
1208
|
-
width:
|
|
1209
|
-
height:
|
|
1210
|
-
transform: `translate(calc(-50% + ${
|
|
1211
|
-
transition:
|
|
1275
|
+
width: P,
|
|
1276
|
+
height: P,
|
|
1277
|
+
transform: `translate(calc(-50% + ${Q}px), calc(-50% + ${tt}px)) scale(${l}, ${f * s})`,
|
|
1278
|
+
transition: M ? "70ms transform ease-out" : "200ms ease transform"
|
|
1212
1279
|
}
|
|
1213
1280
|
}
|
|
1214
1281
|
),
|
|
1215
|
-
/* @__PURE__ */
|
|
1282
|
+
/* @__PURE__ */ it(
|
|
1216
1283
|
"div",
|
|
1217
1284
|
{
|
|
1218
|
-
className: "aqvs-sample-visual-
|
|
1285
|
+
className: "aqvs-sample-visual-highlight",
|
|
1219
1286
|
style: {
|
|
1220
|
-
width:
|
|
1221
|
-
height:
|
|
1222
|
-
transform: `translate(calc(-50% + ${
|
|
1223
|
-
opacity:
|
|
1287
|
+
width: D,
|
|
1288
|
+
height: D,
|
|
1289
|
+
transform: `translate(calc(-50% + ${pt}px), calc(-50% + ${It}px)) scale(${l}, ${s})`,
|
|
1290
|
+
opacity: O,
|
|
1224
1291
|
boxShadow: "0 0 8px rgba(255,255,255,0.45)",
|
|
1225
|
-
transition:
|
|
1292
|
+
transition: M ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
|
|
1226
1293
|
}
|
|
1227
1294
|
}
|
|
1228
1295
|
),
|
|
1229
|
-
/* @__PURE__ */
|
|
1296
|
+
/* @__PURE__ */ it(
|
|
1230
1297
|
"div",
|
|
1231
1298
|
{
|
|
1232
|
-
className: "aqvs-sample-visual-
|
|
1299
|
+
className: "aqvs-sample-visual-rod",
|
|
1233
1300
|
style: {
|
|
1234
|
-
width:
|
|
1235
|
-
height:
|
|
1236
|
-
transform: `translate(-50%, ${
|
|
1301
|
+
width: _,
|
|
1302
|
+
height: E,
|
|
1303
|
+
transform: `translate(-50%, ${g}px)`,
|
|
1237
1304
|
opacity: t,
|
|
1238
|
-
transition:
|
|
1305
|
+
transition: M ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
|
|
1239
1306
|
}
|
|
1240
1307
|
}
|
|
1241
1308
|
)
|
|
1242
1309
|
] });
|
|
1243
|
-
},
|
|
1244
|
-
if (!Number.isFinite(
|
|
1310
|
+
}, Ne = 100, vr = (n) => {
|
|
1311
|
+
if (!Number.isFinite(n))
|
|
1245
1312
|
return 0n;
|
|
1246
|
-
const t = Math.trunc(
|
|
1313
|
+
const t = Math.trunc(n);
|
|
1247
1314
|
return t <= 0 ? 0n : BigInt(t);
|
|
1248
|
-
},
|
|
1249
|
-
if (!Number.isFinite(
|
|
1250
|
-
throw new Error(`valueFn returned a non-finite value at index ${t}: ${
|
|
1251
|
-
return
|
|
1252
|
-
},
|
|
1253
|
-
if (
|
|
1315
|
+
}, Oe = (n, t) => {
|
|
1316
|
+
if (!Number.isFinite(n))
|
|
1317
|
+
throw new Error(`valueFn returned a non-finite value at index ${t}: ${n}`);
|
|
1318
|
+
return n;
|
|
1319
|
+
}, ge = (n) => {
|
|
1320
|
+
if (n <= 0 || !Number.isFinite(n))
|
|
1254
1321
|
return 0;
|
|
1255
|
-
const t = Math.trunc(
|
|
1322
|
+
const t = Math.trunc(n);
|
|
1256
1323
|
if (t <= 2147483647)
|
|
1257
1324
|
return t & -t;
|
|
1258
1325
|
const e = BigInt(t) & -BigInt(t);
|
|
1259
1326
|
return Number(e);
|
|
1260
1327
|
};
|
|
1261
|
-
class
|
|
1328
|
+
class ae {
|
|
1262
1329
|
/**
|
|
1263
1330
|
* @private
|
|
1264
1331
|
* @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
|
|
@@ -1317,31 +1384,31 @@ class oe {
|
|
|
1317
1384
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
1318
1385
|
*/
|
|
1319
1386
|
reset(t, e, r) {
|
|
1320
|
-
const
|
|
1387
|
+
const i = Number.isFinite(t) && t > 0 ? Math.trunc(t) : 0;
|
|
1321
1388
|
if (typeof e != "function") {
|
|
1322
|
-
this.size =
|
|
1389
|
+
this.size = i, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.valueFn = void 0, this.baseValue = e, this.total = this.baseValue * this.size;
|
|
1323
1390
|
return;
|
|
1324
1391
|
}
|
|
1325
1392
|
let s = 0, l;
|
|
1326
|
-
if (
|
|
1327
|
-
const
|
|
1393
|
+
if (i > 0) {
|
|
1394
|
+
const c = r?.sampleRange ?? {
|
|
1328
1395
|
from: 0,
|
|
1329
|
-
to: Math.min(
|
|
1396
|
+
to: Math.min(Ne - 1, i - 1)
|
|
1330
1397
|
};
|
|
1331
|
-
let f = Math.max(0, Math.trunc(
|
|
1332
|
-
if (f > x && (f = 0, x = Math.min(
|
|
1333
|
-
s =
|
|
1398
|
+
let f = Math.max(0, Math.trunc(c.from)), x = Math.min(Math.trunc(c.to), i - 1);
|
|
1399
|
+
if (f > x && (f = 0, x = Math.min(Ne - 1, i - 1)), i > Ne)
|
|
1400
|
+
s = ae._sampleBaseValueStrided(e, i, Ne), r?.materialize && (l = { from: f, values: ae._collectValidatedValues(e, f, x) });
|
|
1334
1401
|
else {
|
|
1335
|
-
const I =
|
|
1336
|
-
s =
|
|
1402
|
+
const I = ae._collectValidatedValues(e, f, x);
|
|
1403
|
+
s = ae._modeOrMedian([...I]), r?.materialize && (l = { from: f, values: I });
|
|
1337
1404
|
}
|
|
1338
1405
|
}
|
|
1339
|
-
if (this.size =
|
|
1340
|
-
for (let
|
|
1341
|
-
const f = l.from +
|
|
1406
|
+
if (this.size = i, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, this.valueFn = e, this.baseValue = s, l)
|
|
1407
|
+
for (let c = 0; c < l.values.length; c++) {
|
|
1408
|
+
const f = l.from + c;
|
|
1342
1409
|
if (f >= this.size)
|
|
1343
1410
|
break;
|
|
1344
|
-
const x = l.values[
|
|
1411
|
+
const x = l.values[c] - this.baseValue;
|
|
1345
1412
|
x !== 0 && (this.deltas.set(f, x), this._updateTree(f, x));
|
|
1346
1413
|
}
|
|
1347
1414
|
this.total = this.getTotal();
|
|
@@ -1371,10 +1438,10 @@ class oe {
|
|
|
1371
1438
|
* @returns {number[]} The validated (finite-only) values in index order.
|
|
1372
1439
|
*/
|
|
1373
1440
|
static _collectValidatedValues(t, e, r) {
|
|
1374
|
-
const
|
|
1441
|
+
const i = [];
|
|
1375
1442
|
for (let s = e; s <= r; s++)
|
|
1376
|
-
|
|
1377
|
-
return
|
|
1443
|
+
i.push(Oe(t(s), s));
|
|
1444
|
+
return i;
|
|
1378
1445
|
}
|
|
1379
1446
|
/**
|
|
1380
1447
|
* @private
|
|
@@ -1387,22 +1454,22 @@ class oe {
|
|
|
1387
1454
|
static _modeOrMedian(t) {
|
|
1388
1455
|
if (t.length === 0)
|
|
1389
1456
|
return 0;
|
|
1390
|
-
t.sort((l,
|
|
1457
|
+
t.sort((l, c) => l - c);
|
|
1391
1458
|
const e = Math.floor(t.length / 2);
|
|
1392
1459
|
let r;
|
|
1393
1460
|
t.length % 2 === 0 ? r = Math.floor((t[e - 1] + t[e]) / 2) : r = t[e];
|
|
1394
|
-
const
|
|
1461
|
+
const i = /* @__PURE__ */ new Map();
|
|
1395
1462
|
let s = 0;
|
|
1396
1463
|
for (const l of t) {
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1464
|
+
const c = (i.get(l) ?? 0) + 1;
|
|
1465
|
+
i.set(l, c), c > s && (s = c);
|
|
1399
1466
|
}
|
|
1400
1467
|
if (s > t.length * 0.2) {
|
|
1401
1468
|
const l = [];
|
|
1402
|
-
for (const [f, x] of
|
|
1469
|
+
for (const [f, x] of i.entries())
|
|
1403
1470
|
x === s && l.push(f);
|
|
1404
|
-
const
|
|
1405
|
-
r = Math.floor(
|
|
1471
|
+
const c = l.reduce((f, x) => f + x, 0);
|
|
1472
|
+
r = Math.floor(c / l.length);
|
|
1406
1473
|
}
|
|
1407
1474
|
return r;
|
|
1408
1475
|
}
|
|
@@ -1419,12 +1486,12 @@ class oe {
|
|
|
1419
1486
|
static _sampleBaseValueStrided(t, e, r) {
|
|
1420
1487
|
if (e <= 0)
|
|
1421
1488
|
return 0;
|
|
1422
|
-
let
|
|
1423
|
-
|
|
1489
|
+
let i = Math.max(1, Math.ceil(e / r));
|
|
1490
|
+
i % 2 === 0 && (i += 1);
|
|
1424
1491
|
const s = [];
|
|
1425
|
-
for (let l = 0; l < e && s.length < r; l +=
|
|
1426
|
-
s.push(
|
|
1427
|
-
return
|
|
1492
|
+
for (let l = 0; l < e && s.length < r; l += i)
|
|
1493
|
+
s.push(Oe(t(l), l));
|
|
1494
|
+
return ae._modeOrMedian(s);
|
|
1428
1495
|
}
|
|
1429
1496
|
/**
|
|
1430
1497
|
* @method update
|
|
@@ -1464,21 +1531,21 @@ class oe {
|
|
|
1464
1531
|
*/
|
|
1465
1532
|
updateDeltas(t) {
|
|
1466
1533
|
const e = /* @__PURE__ */ new Map();
|
|
1467
|
-
for (const { index: r, change:
|
|
1534
|
+
for (const { index: r, change: i } of t) {
|
|
1468
1535
|
if (r < 0 || r >= this.size)
|
|
1469
1536
|
throw new Error(`Index ${r} out of bounds`);
|
|
1470
1537
|
if (!Number.isInteger(r))
|
|
1471
1538
|
throw new Error(`Index must be an integer: ${r}`);
|
|
1472
|
-
if (!Number.isFinite(
|
|
1473
|
-
throw new Error(`Change must be a finite number: ${
|
|
1474
|
-
const l = (e.get(r) ?? this.deltas.get(r) ?? 0) +
|
|
1539
|
+
if (!Number.isFinite(i))
|
|
1540
|
+
throw new Error(`Change must be a finite number: ${i}`);
|
|
1541
|
+
const l = (e.get(r) ?? this.deltas.get(r) ?? 0) + i;
|
|
1475
1542
|
if (l + this.baseValue < -1e-9)
|
|
1476
1543
|
throw new Error(`Change would make the value at index ${r} negative: ${l + this.baseValue}`);
|
|
1477
1544
|
e.set(r, l);
|
|
1478
1545
|
}
|
|
1479
|
-
for (const { index: r, change:
|
|
1480
|
-
const l = (this.deltas.get(r) ?? 0) +
|
|
1481
|
-
l === 0 ? this.deltas.delete(r) : this.deltas.set(r, l), this._updateTree(r,
|
|
1546
|
+
for (const { index: r, change: i } of t) {
|
|
1547
|
+
const l = (this.deltas.get(r) ?? 0) + i;
|
|
1548
|
+
l === 0 ? this.deltas.delete(r) : this.deltas.set(r, l), this._updateTree(r, i);
|
|
1482
1549
|
}
|
|
1483
1550
|
return this.total;
|
|
1484
1551
|
}
|
|
@@ -1496,10 +1563,10 @@ class oe {
|
|
|
1496
1563
|
let r = t + 1;
|
|
1497
1564
|
for (; r <= this.size; ) {
|
|
1498
1565
|
this.tree.set(r, (this.tree.get(r) ?? 0) + e);
|
|
1499
|
-
const
|
|
1500
|
-
if (
|
|
1566
|
+
const i = ge(r);
|
|
1567
|
+
if (i === 0)
|
|
1501
1568
|
break;
|
|
1502
|
-
r +=
|
|
1569
|
+
r += i;
|
|
1503
1570
|
}
|
|
1504
1571
|
this.total !== void 0 && (this.total += e);
|
|
1505
1572
|
}
|
|
@@ -1513,17 +1580,17 @@ class oe {
|
|
|
1513
1580
|
*/
|
|
1514
1581
|
_buildDeltaUpdates(t) {
|
|
1515
1582
|
const e = [], r = /* @__PURE__ */ new Map();
|
|
1516
|
-
for (const { index:
|
|
1517
|
-
if (
|
|
1518
|
-
throw new Error(`Index ${
|
|
1519
|
-
if (!Number.isInteger(
|
|
1520
|
-
throw new Error(`Index must be an integer: ${
|
|
1583
|
+
for (const { index: i, value: s } of t) {
|
|
1584
|
+
if (i < 0 || i >= this.size)
|
|
1585
|
+
throw new Error(`Index ${i} out of bounds`);
|
|
1586
|
+
if (!Number.isInteger(i))
|
|
1587
|
+
throw new Error(`Index must be an integer: ${i}`);
|
|
1521
1588
|
if (!Number.isFinite(s))
|
|
1522
1589
|
throw new Error(`Value must be a finite number: ${s}`);
|
|
1523
1590
|
if (s < 0)
|
|
1524
1591
|
throw new Error("Value cannot be negative.");
|
|
1525
|
-
const l = r.has(
|
|
1526
|
-
f !== 0 && e.push({ index:
|
|
1592
|
+
const l = r.has(i) ? r.get(i) ?? 0 : this.deltas.get(i) ?? 0, c = l + this.baseValue, f = s - c;
|
|
1593
|
+
f !== 0 && e.push({ index: i, change: f }), r.set(i, l + f);
|
|
1527
1594
|
}
|
|
1528
1595
|
return e;
|
|
1529
1596
|
}
|
|
@@ -1540,7 +1607,7 @@ class oe {
|
|
|
1540
1607
|
let t = 0, e = this.size;
|
|
1541
1608
|
for (; e > 0; ) {
|
|
1542
1609
|
t += this.tree.get(e) ?? 0;
|
|
1543
|
-
const r =
|
|
1610
|
+
const r = ge(e);
|
|
1544
1611
|
if (r === 0)
|
|
1545
1612
|
break;
|
|
1546
1613
|
e -= r;
|
|
@@ -1557,7 +1624,7 @@ class oe {
|
|
|
1557
1624
|
*/
|
|
1558
1625
|
_materialize(t, e = !0) {
|
|
1559
1626
|
if (this.valueFn) {
|
|
1560
|
-
const r = this.deltas.get(t) ?? 0, s =
|
|
1627
|
+
const r = this.deltas.get(t) ?? 0, s = Oe(this.valueFn(t), t) - this.baseValue;
|
|
1561
1628
|
if (s !== r && (s === 0 ? this.deltas.delete(t) : this.deltas.set(t, s), e)) {
|
|
1562
1629
|
const l = s - r;
|
|
1563
1630
|
this._updateTree(t, l);
|
|
@@ -1576,10 +1643,10 @@ class oe {
|
|
|
1576
1643
|
_materializeRanges(t, e, r = !1) {
|
|
1577
1644
|
if (!(t?.materialize && this.valueFn))
|
|
1578
1645
|
return;
|
|
1579
|
-
const
|
|
1580
|
-
if (
|
|
1581
|
-
for (const
|
|
1582
|
-
const f = Math.max(0, Math.trunc(
|
|
1646
|
+
const i = t.ranges;
|
|
1647
|
+
if (i && i.length > 0) {
|
|
1648
|
+
for (const c of i) {
|
|
1649
|
+
const f = Math.max(0, Math.trunc(c.from)), x = Math.min(Math.trunc(c.to), this.size - 1);
|
|
1583
1650
|
for (let I = f; I <= x; I++)
|
|
1584
1651
|
this._materialize(I);
|
|
1585
1652
|
}
|
|
@@ -1589,7 +1656,7 @@ class oe {
|
|
|
1589
1656
|
this._materialize(e);
|
|
1590
1657
|
return;
|
|
1591
1658
|
}
|
|
1592
|
-
const s =
|
|
1659
|
+
const s = i[0].from, l = i[i.length - 1].to;
|
|
1593
1660
|
e >= s && e <= l && this._materialize(e);
|
|
1594
1661
|
return;
|
|
1595
1662
|
}
|
|
@@ -1611,15 +1678,15 @@ class oe {
|
|
|
1611
1678
|
if (this.size === 0)
|
|
1612
1679
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1613
1680
|
this._materializeRanges(e.materializeOption);
|
|
1614
|
-
const
|
|
1681
|
+
const i = e.materializeOption?.materialize === !0;
|
|
1615
1682
|
let s;
|
|
1616
1683
|
for (; ; ) {
|
|
1617
1684
|
if (s = this._descend(t, r), s < 0 || s >= this.size)
|
|
1618
1685
|
return { index: -1, total: this.total ?? this.getTotal(), cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1619
|
-
if (!
|
|
1686
|
+
if (!i)
|
|
1620
1687
|
break;
|
|
1621
|
-
const
|
|
1622
|
-
if (this._materialize(s), (this.deltas.get(s) ?? 0) ===
|
|
1688
|
+
const c = this.deltas.get(s) ?? 0;
|
|
1689
|
+
if (this._materialize(s), (this.deltas.get(s) ?? 0) === c)
|
|
1623
1690
|
break;
|
|
1624
1691
|
}
|
|
1625
1692
|
const l = this.prefixSum(s);
|
|
@@ -1641,14 +1708,14 @@ class oe {
|
|
|
1641
1708
|
* @returns {number} The candidate index (may be out of range when no index satisfies the condition).
|
|
1642
1709
|
*/
|
|
1643
1710
|
_descend(t, e) {
|
|
1644
|
-
let r = 0,
|
|
1711
|
+
let r = 0, i = 0, s = 1;
|
|
1645
1712
|
for (; s << 1 <= this.size; )
|
|
1646
1713
|
s <<= 1;
|
|
1647
1714
|
for (; s > 0; s >>= 1) {
|
|
1648
1715
|
const l = r + s;
|
|
1649
1716
|
if (l <= this.size) {
|
|
1650
1717
|
const f = (this.tree.get(l) ?? 0) + this.baseValue * s;
|
|
1651
|
-
(e ?
|
|
1718
|
+
(e ? i + f < t : i + f <= t) && (r = l, i += f);
|
|
1652
1719
|
}
|
|
1653
1720
|
}
|
|
1654
1721
|
return e ? r : r - 1;
|
|
@@ -1661,42 +1728,42 @@ class oe {
|
|
|
1661
1728
|
_findIndexLarge(t, e, r) {
|
|
1662
1729
|
if (this.size === 0)
|
|
1663
1730
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1664
|
-
const
|
|
1665
|
-
if (
|
|
1731
|
+
const i = vr(this.size);
|
|
1732
|
+
if (i === 0n)
|
|
1666
1733
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1667
1734
|
this._materializeRanges(e.materializeOption);
|
|
1668
1735
|
const s = e.materializeOption?.materialize === !0;
|
|
1669
1736
|
for (; ; ) {
|
|
1670
|
-
let l = 0n,
|
|
1671
|
-
for (; l <=
|
|
1672
|
-
const
|
|
1673
|
-
if (I =
|
|
1674
|
-
if (f =
|
|
1675
|
-
if (
|
|
1737
|
+
let l = 0n, c = i - 1n, f, x, I = this.total;
|
|
1738
|
+
for (; l <= c; ) {
|
|
1739
|
+
const g = l + c >> 1n, _ = Number(g), z = this.prefixSum(_);
|
|
1740
|
+
if (I = z.total, r ? z.cumulative >= t : z.cumulative <= t)
|
|
1741
|
+
if (f = g, x = z, r) {
|
|
1742
|
+
if (g === 0n)
|
|
1676
1743
|
break;
|
|
1677
|
-
|
|
1744
|
+
c = g - 1n;
|
|
1678
1745
|
} else
|
|
1679
|
-
l =
|
|
1746
|
+
l = g + 1n;
|
|
1680
1747
|
else if (r)
|
|
1681
|
-
l =
|
|
1748
|
+
l = g + 1n;
|
|
1682
1749
|
else {
|
|
1683
|
-
if (
|
|
1750
|
+
if (g === 0n)
|
|
1684
1751
|
break;
|
|
1685
|
-
|
|
1752
|
+
c = g - 1n;
|
|
1686
1753
|
}
|
|
1687
1754
|
}
|
|
1688
|
-
const
|
|
1689
|
-
if (s &&
|
|
1690
|
-
const
|
|
1691
|
-
if (this._materialize(
|
|
1755
|
+
const P = x, E = f !== void 0 ? Number(f) : -1;
|
|
1756
|
+
if (s && E >= 0) {
|
|
1757
|
+
const g = this.deltas.get(E) ?? 0;
|
|
1758
|
+
if (this._materialize(E), (this.deltas.get(E) ?? 0) !== g)
|
|
1692
1759
|
continue;
|
|
1693
1760
|
}
|
|
1694
1761
|
return {
|
|
1695
|
-
index:
|
|
1762
|
+
index: E,
|
|
1696
1763
|
total: I,
|
|
1697
|
-
cumulative:
|
|
1698
|
-
currentValue:
|
|
1699
|
-
safeIndex:
|
|
1764
|
+
cumulative: P?.cumulative,
|
|
1765
|
+
currentValue: P?.currentValue,
|
|
1766
|
+
safeIndex: P?.safeIndex
|
|
1700
1767
|
};
|
|
1701
1768
|
}
|
|
1702
1769
|
}
|
|
@@ -1713,19 +1780,19 @@ class oe {
|
|
|
1713
1780
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
1714
1781
|
if (this.size === 0)
|
|
1715
1782
|
return { cumulative: 0, total: this.total ?? 0, currentValue: 0, safeIndex: 0 };
|
|
1716
|
-
const r =
|
|
1717
|
-
this._materializeRanges(
|
|
1783
|
+
const r = xt(Math.trunc(t), 0, this.size - 1), i = e?.materializeOption;
|
|
1784
|
+
this._materializeRanges(i, r, !0);
|
|
1718
1785
|
let s = 0, l = r + 1;
|
|
1719
1786
|
for (; l > 0; ) {
|
|
1720
1787
|
const f = this.tree.get(l) ?? 0;
|
|
1721
1788
|
s += f;
|
|
1722
|
-
const x =
|
|
1789
|
+
const x = ge(l);
|
|
1723
1790
|
if (x === 0)
|
|
1724
1791
|
break;
|
|
1725
1792
|
l -= x;
|
|
1726
1793
|
}
|
|
1727
|
-
const
|
|
1728
|
-
return { cumulative: s + this.baseValue * (r + 1), total: this.total, currentValue:
|
|
1794
|
+
const c = i?.materialize ? this.get(r) : (this.deltas.get(r) || 0) + this.baseValue;
|
|
1795
|
+
return { cumulative: s + this.baseValue * (r + 1), total: this.total, currentValue: c, safeIndex: r };
|
|
1729
1796
|
}
|
|
1730
1797
|
/**
|
|
1731
1798
|
* @method get
|
|
@@ -1758,7 +1825,7 @@ class oe {
|
|
|
1758
1825
|
else {
|
|
1759
1826
|
this.total = this._computeTreeTotal();
|
|
1760
1827
|
const r = this.prefixSum(this.getSize() - 1);
|
|
1761
|
-
r.cumulative !== r.total &&
|
|
1828
|
+
r.cumulative !== r.total && C.error("Inconsistent Fenwick Tree state");
|
|
1762
1829
|
}
|
|
1763
1830
|
return this.total;
|
|
1764
1831
|
}
|
|
@@ -1772,17 +1839,17 @@ class oe {
|
|
|
1772
1839
|
rebuildTree(t) {
|
|
1773
1840
|
if (t?.materialize && this.valueFn) {
|
|
1774
1841
|
const r = this.valueFn;
|
|
1775
|
-
this.reset(this.size, (
|
|
1842
|
+
this.reset(this.size, (i) => r(i), { materialize: !0 });
|
|
1776
1843
|
return;
|
|
1777
1844
|
}
|
|
1778
1845
|
const e = /* @__PURE__ */ new Map();
|
|
1779
|
-
for (const [r,
|
|
1780
|
-
if (
|
|
1846
|
+
for (const [r, i] of this.deltas.entries()) {
|
|
1847
|
+
if (i === 0)
|
|
1781
1848
|
continue;
|
|
1782
1849
|
let s = r + 1;
|
|
1783
1850
|
for (; s <= this.size; ) {
|
|
1784
|
-
e.set(s, (e.get(s) ?? 0) +
|
|
1785
|
-
const l =
|
|
1851
|
+
e.set(s, (e.get(s) ?? 0) + i);
|
|
1852
|
+
const l = ge(s);
|
|
1786
1853
|
if (l === 0)
|
|
1787
1854
|
break;
|
|
1788
1855
|
s += l;
|
|
@@ -1794,14 +1861,19 @@ class oe {
|
|
|
1794
1861
|
* @method calculateAccumulatedError
|
|
1795
1862
|
* @description Compares the cached total sum with a theoretical total calculated directly from the source values (`deltas` and `baseValue`, or `valueFn`). This helps detect any discrepancy in the tree's cached state, which might be caused by floating-point errors or other inconsistencies.
|
|
1796
1863
|
* @description キャッシュされている合計値と、元の値 (`deltas` と `baseValue`、または `valueFn`) から直接計算した理論上の合計値とを比較します。これにより、浮動小数点数の累積誤差やその他の不整合によって生じる可能性のある、ツリーのキャッシュ状態の不一致を検出できます。
|
|
1864
|
+
*
|
|
1865
|
+
* ❗ 集計対象は `[0, size)` の範囲内にある delta だけです。`changeSize(0)` は
|
|
1866
|
+
* ロード中の一時クリアとみなして delta を温存する (再伸長時にキャッシュを再利用するため) ので、
|
|
1867
|
+
* 範囲外の delta まで数えると**木は健全なのに空リストの間ずっと非ゼロ**が返り、
|
|
1868
|
+
* この値を破損検知に使う利用者が毎回不要な復旧処理を走らせてしまいます。
|
|
1797
1869
|
* @returns {number} The difference between the cached total and the theoretical total.
|
|
1798
1870
|
*/
|
|
1799
1871
|
calculateAccumulatedError() {
|
|
1800
1872
|
if (this.total === void 0)
|
|
1801
1873
|
return 0;
|
|
1802
1874
|
let t = this.baseValue * this.size;
|
|
1803
|
-
for (const e of this.deltas
|
|
1804
|
-
t +=
|
|
1875
|
+
for (const [e, r] of this.deltas)
|
|
1876
|
+
e < this.size && (t += r);
|
|
1805
1877
|
return this.total - t;
|
|
1806
1878
|
}
|
|
1807
1879
|
/**
|
|
@@ -1818,6 +1890,18 @@ class oe {
|
|
|
1818
1890
|
* サイズ差分のみを受け取りインデックスの対応表は受け取らないため、要素は末尾に追加/末尾から削除
|
|
1819
1891
|
* されると仮定する。既存行は index↔高さ の対応を保つ。したがって中間挿入/削除は表現できず、その
|
|
1820
1892
|
* ような構造変更の後は index↔高さ の対応が保存されず、木の delta が誤った行へ適用されてしまう。
|
|
1893
|
+
* ❗ `changeSize(0)` は例外的に delta を消去しない。ロード中に一覧が一瞬空になるフローで
|
|
1894
|
+
* 実測済みの行高を捨てないための特例で、`changeSize(N > 0)` で再伸長したときに範囲内の delta が
|
|
1895
|
+
* そのまま復元される (範囲外の delta はそこで刈られる)。size が 0 に留まっている間、
|
|
1896
|
+
* `get()` / `getTotal()` は 0 を返し、`calculateAccumulatedError()` は範囲内 delta だけを
|
|
1897
|
+
* 集計するので 0 のままになる。**別データセットへ差し替える場合は温存が害になる**ため、
|
|
1898
|
+
* `reset()` を呼ぶか新しい `key` で作り直すこと。
|
|
1899
|
+
* ❗ `changeSize(0)` intentionally keeps its deltas so a list that briefly empties while loading
|
|
1900
|
+
* does not lose measured row heights; growing back restores the in-range ones (out-of-range
|
|
1901
|
+
* deltas are pruned then). While the size stays 0, `get()` / `getTotal()` return 0 and
|
|
1902
|
+
* `calculateAccumulatedError()` stays 0 because it only sums in-range deltas. Replacing the
|
|
1903
|
+
* dataset instead of reloading the same one must go through `reset()` or a fresh instance.
|
|
1904
|
+
*
|
|
1821
1905
|
* 中間で要素を挿入/削除する消費側は、代わりに木をリセットするか (`useFenwickMapTree` の
|
|
1822
1906
|
* `resetOnValueFnChange`。VirtualScroll では `resetOnGetItemHeightChange` として公開) 、新しい
|
|
1823
1907
|
* `key` でコンポーネントを再マウントすること。
|
|
@@ -1835,14 +1919,20 @@ class oe {
|
|
|
1835
1919
|
if (e === r)
|
|
1836
1920
|
return;
|
|
1837
1921
|
if (e > r)
|
|
1838
|
-
|
|
1922
|
+
if (r === 0 && this.deltas.size > 0) {
|
|
1923
|
+
for (const s of this.deltas.keys())
|
|
1924
|
+
s >= e && this.deltas.delete(s);
|
|
1925
|
+
this.size = e, this.rebuildTree();
|
|
1926
|
+
} else
|
|
1927
|
+
this._growSize(r, e);
|
|
1839
1928
|
else {
|
|
1840
|
-
|
|
1841
|
-
|
|
1929
|
+
if (e > 0)
|
|
1930
|
+
for (const s of this.deltas.keys())
|
|
1931
|
+
s >= e && this.deltas.delete(s);
|
|
1842
1932
|
this.size = e, this.rebuildTree();
|
|
1843
1933
|
}
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1934
|
+
const i = this.prefixSum(this.getSize() - 1);
|
|
1935
|
+
i.cumulative !== i.total && C.error("Inconsistent Fenwick Tree state");
|
|
1846
1936
|
}
|
|
1847
1937
|
/**
|
|
1848
1938
|
* @private
|
|
@@ -1856,10 +1946,10 @@ class oe {
|
|
|
1856
1946
|
static _minCoveredLowBound(t, e) {
|
|
1857
1947
|
let r = 1;
|
|
1858
1948
|
for (; ; ) {
|
|
1859
|
-
const
|
|
1860
|
-
if (Math.floor(e /
|
|
1949
|
+
const i = r * 2;
|
|
1950
|
+
if (Math.floor(e / i) * i <= t)
|
|
1861
1951
|
break;
|
|
1862
|
-
r =
|
|
1952
|
+
r = i;
|
|
1863
1953
|
}
|
|
1864
1954
|
return r * Math.floor(t / r);
|
|
1865
1955
|
}
|
|
@@ -1873,17 +1963,17 @@ class oe {
|
|
|
1873
1963
|
* @param {number} oldSize - The previous size.
|
|
1874
1964
|
* @param {number} newSize - The new (larger) size.
|
|
1875
1965
|
*/
|
|
1876
|
-
_propagateDeltaToGrownNodes(t, e, r,
|
|
1966
|
+
_propagateDeltaToGrownNodes(t, e, r, i) {
|
|
1877
1967
|
let s = t + 1;
|
|
1878
1968
|
for (; s <= r; ) {
|
|
1879
|
-
const l =
|
|
1969
|
+
const l = ge(s);
|
|
1880
1970
|
if (l === 0)
|
|
1881
1971
|
break;
|
|
1882
1972
|
s += l;
|
|
1883
1973
|
}
|
|
1884
|
-
for (; s <=
|
|
1974
|
+
for (; s <= i; ) {
|
|
1885
1975
|
this.tree.set(s, (this.tree.get(s) ?? 0) + e);
|
|
1886
|
-
const l =
|
|
1976
|
+
const l = ge(s);
|
|
1887
1977
|
if (l === 0)
|
|
1888
1978
|
break;
|
|
1889
1979
|
s += l;
|
|
@@ -1899,7 +1989,7 @@ class oe {
|
|
|
1899
1989
|
*/
|
|
1900
1990
|
_growSize(t, e) {
|
|
1901
1991
|
if (this.size = e, this.deltas.size > 0) {
|
|
1902
|
-
const r =
|
|
1992
|
+
const r = ae._minCoveredLowBound(t, e);
|
|
1903
1993
|
if (t - r < this.deltas.size)
|
|
1904
1994
|
for (let s = r; s < t; s++) {
|
|
1905
1995
|
const l = this.deltas.get(s);
|
|
@@ -1920,6 +2010,34 @@ class oe {
|
|
|
1920
2010
|
getSize() {
|
|
1921
2011
|
return this.size;
|
|
1922
2012
|
}
|
|
2013
|
+
/**
|
|
2014
|
+
* @description Gets the base value of the tree — the height every row starts from before
|
|
2015
|
+
* its own delta is applied. `useFenwickMapTree` reads it to decide whether a `0 → N` growth
|
|
2016
|
+
* should re-sample from scratch (`reset`) or reuse the measured heights kept across the
|
|
2017
|
+
* empty state (`changeSize`), so removing or renaming it silently disables that cache
|
|
2018
|
+
* preservation.
|
|
2019
|
+
*
|
|
2020
|
+
* ❗ This is NOT a "has the tree warmed up?" flag. `0` is a legitimate base — it is what a
|
|
2021
|
+
* tree constructed with `new FenwickMapTree(n, 0)` has, and what sampling produces when the
|
|
2022
|
+
* value function returns 0 for not-yet-measured rows (a common virtualization pattern).
|
|
2023
|
+
* Such a tree can hold plenty of measured deltas while `base` stays `0`. The hook's
|
|
2024
|
+
* `0 → N` guard therefore trades cache preservation for correctness in exactly that case:
|
|
2025
|
+
* a base of `0` cannot be distinguished from "never established", and growing incrementally
|
|
2026
|
+
* from a zero base would pin `total` at `0 × N = 0`.
|
|
2027
|
+
* @description ツリーの基準値 (各行が自身の delta を適用される前の高さ) を取得。
|
|
2028
|
+
* `useFenwickMapTree` は `0 → N` の伸長を再サンプリング (`reset`) と実測高さの温存 (`changeSize`) の
|
|
2029
|
+
* どちらへ倒すかの判定にこの値を読むため、削除・改名するとキャッシュ温存が黙って無効化される。
|
|
2030
|
+
*
|
|
2031
|
+
* ❗ **「木が温まったか」のフラグではない。** `0` は正当な基準値であり、
|
|
2032
|
+
* `new FenwickMapTree(n, 0)` や「未計測行に 0 を返す `getItemHeight`」(仮想化では定番) の
|
|
2033
|
+
* サンプリング結果として普通に発生する。その木は実測 delta を大量に持っていても `base` は `0` のまま。
|
|
2034
|
+
* フックの `0 → N` ガードは、まさにこの場合にキャッシュ温存より整合を優先する
|
|
2035
|
+
* (基準値 0 は「未確立」と区別できず、0 のまま増分伸長すると `total = 0 × N = 0` で固着するため)。
|
|
2036
|
+
* @returns {number} The base value. 基準値。
|
|
2037
|
+
*/
|
|
2038
|
+
get base() {
|
|
2039
|
+
return this.baseValue;
|
|
2040
|
+
}
|
|
1923
2041
|
/**
|
|
1924
2042
|
* @method findIndexAtOrAfter
|
|
1925
2043
|
* @description Finds the first index where the cumulative sum is greater than or equal to a target value.
|
|
@@ -1949,20 +2067,20 @@ class oe {
|
|
|
1949
2067
|
return this._findIndex(t, e ?? {}, !1);
|
|
1950
2068
|
}
|
|
1951
2069
|
}
|
|
1952
|
-
const
|
|
1953
|
-
const e =
|
|
2070
|
+
const Pr = (n, t) => {
|
|
2071
|
+
const e = n?.sampleRange, r = t?.sampleRange;
|
|
1954
2072
|
return e === r ? !1 : e && r ? e.from !== r.from || e.to !== r.to : !0;
|
|
1955
|
-
},
|
|
1956
|
-
const r = Number.isFinite(
|
|
1957
|
-
|
|
1958
|
-
const l =
|
|
2073
|
+
}, Mr = (n, t, e) => {
|
|
2074
|
+
const r = Number.isFinite(n) && n > 0 ? Math.trunc(n) : 0, i = T(null), s = T({ size: r, valueOrFn: t, options: e });
|
|
2075
|
+
i.current === null && (i.current = new ae(r, t, e));
|
|
2076
|
+
const l = i.current, c = s.current, f = c.size !== r, x = c.valueOrFn !== t, I = Pr(c.options, e), P = c.size === 0 && r > 0 && (!i.current || i.current.base === 0);
|
|
1959
2077
|
if (x || I) {
|
|
1960
|
-
const
|
|
1961
|
-
I || x &&
|
|
1962
|
-
} else f && (e?.debug &&
|
|
2078
|
+
const E = e?.resetOnValueFnChange ?? !0;
|
|
2079
|
+
I || x && E || P ? (e?.debug && C.debug("[useFenwickMapTree] reset", { valueOrFnChanged: x, optionsChanged: I }), l.reset(r, t, e)) : (f && (e?.debug && C.debug("[useFenwickMapTree] resize (with valueFn change)", { from: c.size, to: r }), l.changeSize(r)), e?.debug && C.debug("[useFenwickMapTree] setValueFn (no reset)", { valueOrFnChanged: x }), l.setValueFn(t, { reset: !1 })), s.current = { size: r, valueOrFn: t, options: e };
|
|
2080
|
+
} else f && (e?.debug && C.debug("[useFenwickMapTree] resize", { from: c.size, to: r }), P ? l.reset(r, t, e) : l.changeSize(r), s.current = { size: r, valueOrFn: t, options: e });
|
|
1963
2081
|
return l;
|
|
1964
2082
|
};
|
|
1965
|
-
class
|
|
2083
|
+
class yr {
|
|
1966
2084
|
key;
|
|
1967
2085
|
value;
|
|
1968
2086
|
prev = null;
|
|
@@ -1971,7 +2089,7 @@ class Sr {
|
|
|
1971
2089
|
this.key = t, this.value = e;
|
|
1972
2090
|
}
|
|
1973
2091
|
}
|
|
1974
|
-
class
|
|
2092
|
+
class Fe {
|
|
1975
2093
|
head = null;
|
|
1976
2094
|
tail = null;
|
|
1977
2095
|
/**
|
|
@@ -2012,11 +2130,11 @@ class _e {
|
|
|
2012
2130
|
this.remove(t), this.addToTail(t);
|
|
2013
2131
|
}
|
|
2014
2132
|
}
|
|
2015
|
-
function
|
|
2016
|
-
const t =
|
|
2017
|
-
|
|
2018
|
-
if (
|
|
2019
|
-
|
|
2133
|
+
function wr(n) {
|
|
2134
|
+
const t = T(/* @__PURE__ */ new Map()), e = T(new Fe()), r = Math.floor(n), i = T(r);
|
|
2135
|
+
Y(() => {
|
|
2136
|
+
if (i.current = r, Number.isNaN(r) || r < 0) {
|
|
2137
|
+
C.warn(`useLruCache: invalid capacity ${n}; the cache will not store any entries.`), t.current.clear(), e.current = new Fe();
|
|
2020
2138
|
return;
|
|
2021
2139
|
}
|
|
2022
2140
|
if (Number.isFinite(r))
|
|
@@ -2027,228 +2145,228 @@ function Mr(i) {
|
|
|
2027
2145
|
else
|
|
2028
2146
|
break;
|
|
2029
2147
|
}
|
|
2030
|
-
}, [
|
|
2031
|
-
const s =
|
|
2032
|
-
const
|
|
2033
|
-
if (
|
|
2034
|
-
return e.current.moveToTail(
|
|
2035
|
-
}, []), l =
|
|
2036
|
-
const
|
|
2037
|
-
if (Number.isNaN(
|
|
2148
|
+
}, [n, r]);
|
|
2149
|
+
const s = v((I) => {
|
|
2150
|
+
const P = t.current.get(I);
|
|
2151
|
+
if (P)
|
|
2152
|
+
return e.current.moveToTail(P), P.value;
|
|
2153
|
+
}, []), l = v((I, P) => {
|
|
2154
|
+
const E = i.current;
|
|
2155
|
+
if (Number.isNaN(E) || E <= 0)
|
|
2038
2156
|
return;
|
|
2039
|
-
let
|
|
2040
|
-
if (
|
|
2041
|
-
|
|
2157
|
+
let g = t.current.get(I);
|
|
2158
|
+
if (g)
|
|
2159
|
+
g.value = P, e.current.moveToTail(g);
|
|
2042
2160
|
else {
|
|
2043
|
-
if (t.current.size >=
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2161
|
+
if (t.current.size >= E) {
|
|
2162
|
+
const _ = e.current.removeHead();
|
|
2163
|
+
_ && t.current.delete(_.key);
|
|
2046
2164
|
}
|
|
2047
|
-
|
|
2165
|
+
g = new yr(I, P), t.current.set(I, g), e.current.addToTail(g);
|
|
2048
2166
|
}
|
|
2049
|
-
}, []),
|
|
2050
|
-
const
|
|
2051
|
-
|
|
2052
|
-
}, []), x =
|
|
2053
|
-
t.current.clear(), e.current = new
|
|
2167
|
+
}, []), c = v((I) => t.current.has(I), []), f = v((I) => {
|
|
2168
|
+
const P = t.current.get(I);
|
|
2169
|
+
P && (e.current.remove(P), t.current.delete(I));
|
|
2170
|
+
}, []), x = v(() => {
|
|
2171
|
+
t.current.clear(), e.current = new Fe();
|
|
2054
2172
|
}, []);
|
|
2055
|
-
return
|
|
2173
|
+
return At(() => ({ get: s, set: l, has: c, remove: f, clear: x }), [s, l, c, f, x]);
|
|
2056
2174
|
}
|
|
2057
|
-
const
|
|
2058
|
-
const { get:
|
|
2059
|
-
return
|
|
2060
|
-
},
|
|
2061
|
-
top: Math.max(0,
|
|
2062
|
-
bottom: Math.max(0,
|
|
2063
|
-
}),
|
|
2064
|
-
if (!Number.isFinite(
|
|
2065
|
-
const t = Math.trunc(
|
|
2175
|
+
const Rr = 1e4, Or = () => {
|
|
2176
|
+
const { get: n, set: t, has: e, clear: r } = wr(Rr);
|
|
2177
|
+
return At(() => ({ get: n, set: t, has: e, clear: r }), [n, t, e, r]);
|
|
2178
|
+
}, bt = (n, t) => t <= 0 ? 0 : xt(n, 0, t - 1), Ue = (n) => ({
|
|
2179
|
+
top: Math.max(0, n?.top ?? 0),
|
|
2180
|
+
bottom: Math.max(0, n?.bottom ?? 0)
|
|
2181
|
+
}), ne = (n, t) => n <= t ? 0 : n - t, be = (n, t) => n <= 0 ? t : n + t, Ve = 1e3, Ke = 2e3, Cr = 1048576, Me = (n) => {
|
|
2182
|
+
if (!Number.isFinite(n)) return 0n;
|
|
2183
|
+
const t = Math.trunc(n);
|
|
2066
2184
|
return t <= 0 ? 0n : BigInt(t);
|
|
2067
|
-
},
|
|
2068
|
-
const f =
|
|
2185
|
+
}, Er = (n, t, e, r, i, s, l, c) => {
|
|
2186
|
+
const f = Me(r);
|
|
2069
2187
|
if (f === 0n)
|
|
2070
2188
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
2071
|
-
const x = (
|
|
2072
|
-
let
|
|
2073
|
-
|
|
2074
|
-
const
|
|
2075
|
-
const
|
|
2076
|
-
if (!Number.isSafeInteger(
|
|
2189
|
+
const x = (D) => D < 0n ? 0n : D >= f ? f - 1n : D, I = { materializeOption: { materialize: !1 } }, { index: P, cumulative: E } = s.findIndexAtOrAfter(n, I);
|
|
2190
|
+
let g;
|
|
2191
|
+
P === -1 ? g = f - 1n : (E === n ? g = Me(P + 1) : g = Me(P), g >= f && (g = f - 1n)), n <= 0 && (g = 0n), c && n >= l && (g = f - 1n);
|
|
2192
|
+
const _ = (D) => {
|
|
2193
|
+
const O = Number(D);
|
|
2194
|
+
if (!Number.isSafeInteger(O))
|
|
2077
2195
|
return null;
|
|
2078
|
-
const { cumulative:
|
|
2079
|
-
if (!Number.isFinite(
|
|
2196
|
+
const { cumulative: M } = s.prefixSum(O, { materializeOption: { materialize: !1 } });
|
|
2197
|
+
if (!Number.isFinite(M))
|
|
2080
2198
|
return null;
|
|
2081
|
-
const { index:
|
|
2082
|
-
if (
|
|
2199
|
+
const { index: B } = s.findIndexAtOrAfter(M + 0.5, { materializeOption: { materialize: !1 } });
|
|
2200
|
+
if (B === -1)
|
|
2083
2201
|
return null;
|
|
2084
|
-
const
|
|
2085
|
-
return
|
|
2086
|
-
},
|
|
2087
|
-
let
|
|
2088
|
-
for (;
|
|
2089
|
-
const
|
|
2090
|
-
if (
|
|
2202
|
+
const N = Me(B);
|
|
2203
|
+
return N > D ? N : null;
|
|
2204
|
+
}, z = (D) => {
|
|
2205
|
+
let O = 0, M = D, B = D, N = 0n, q = 0;
|
|
2206
|
+
for (; M < f && O < t; ) {
|
|
2207
|
+
const et = Number(M), G = i(et);
|
|
2208
|
+
if (O += G, B = M, M += 1n, N += 1n, !Number.isFinite(G) || G < 0)
|
|
2091
2209
|
break;
|
|
2092
|
-
if (
|
|
2093
|
-
if (
|
|
2094
|
-
const
|
|
2095
|
-
if (
|
|
2096
|
-
|
|
2097
|
-
else if (
|
|
2098
|
-
|
|
2210
|
+
if (G === 0) {
|
|
2211
|
+
if (q += 1, q > Ve) {
|
|
2212
|
+
const h = _(B);
|
|
2213
|
+
if (h !== null && h > M)
|
|
2214
|
+
M = h, q = 0;
|
|
2215
|
+
else if (h !== null && h === M && i(Number(M)) > 0)
|
|
2216
|
+
q = 0;
|
|
2099
2217
|
else
|
|
2100
2218
|
break;
|
|
2101
2219
|
}
|
|
2102
2220
|
} else
|
|
2103
|
-
|
|
2221
|
+
q = 0;
|
|
2104
2222
|
}
|
|
2105
|
-
return
|
|
2223
|
+
return N === 0n && (B = D), { height: O, end: B };
|
|
2106
2224
|
};
|
|
2107
|
-
let { height:
|
|
2108
|
-
if (
|
|
2109
|
-
let
|
|
2110
|
-
for (;
|
|
2111
|
-
|
|
2112
|
-
const
|
|
2113
|
-
if (
|
|
2225
|
+
let { height: j, end: ft } = z(g);
|
|
2226
|
+
if (j < t && g > 0n) {
|
|
2227
|
+
let D = g, O = j, M = 0;
|
|
2228
|
+
for (; D > 0n && O < t; ) {
|
|
2229
|
+
D -= 1n;
|
|
2230
|
+
const N = Number(D), q = i(N);
|
|
2231
|
+
if (O += q, !Number.isFinite(q) || q < 0)
|
|
2114
2232
|
break;
|
|
2115
|
-
if (
|
|
2116
|
-
if (
|
|
2117
|
-
const
|
|
2118
|
-
if (!Number.isSafeInteger(
|
|
2233
|
+
if (q === 0) {
|
|
2234
|
+
if (M += 1, M > Ve) {
|
|
2235
|
+
const et = Number(D);
|
|
2236
|
+
if (!Number.isSafeInteger(et))
|
|
2119
2237
|
break;
|
|
2120
|
-
const { cumulative:
|
|
2121
|
-
if (!Number.isFinite(
|
|
2238
|
+
const { cumulative: G } = s.prefixSum(et, { materializeOption: { materialize: !1 } });
|
|
2239
|
+
if (!Number.isFinite(G))
|
|
2122
2240
|
break;
|
|
2123
|
-
const { index:
|
|
2124
|
-
if (
|
|
2125
|
-
|
|
2126
|
-
else if (
|
|
2127
|
-
|
|
2241
|
+
const { index: h } = s.findIndexAtOrAfter(G - 0.5, { materializeOption: { materialize: !1 } }), $ = h === -1 ? -1n : Me(h);
|
|
2242
|
+
if ($ >= 0n && $ < D)
|
|
2243
|
+
D = $ + 1n, M = 0;
|
|
2244
|
+
else if ($ === D && D >= 1n && i(Number(D - 1n)) > 0)
|
|
2245
|
+
M = 0;
|
|
2128
2246
|
else
|
|
2129
2247
|
break;
|
|
2130
2248
|
}
|
|
2131
2249
|
} else
|
|
2132
|
-
|
|
2250
|
+
M = 0;
|
|
2133
2251
|
}
|
|
2134
|
-
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2252
|
+
g = x(D);
|
|
2253
|
+
const B = z(g);
|
|
2254
|
+
j = B.height, ft = B.end;
|
|
2137
2255
|
}
|
|
2138
|
-
const
|
|
2256
|
+
const Q = x(g), tt = x(ft), pt = x(Q - BigInt(Math.max(0, e))), It = x(tt + BigInt(Math.max(0, e)));
|
|
2139
2257
|
return {
|
|
2140
|
-
renderingStartIndex:
|
|
2141
|
-
renderingEndIndex:
|
|
2142
|
-
visibleStartIndex:
|
|
2143
|
-
visibleEndIndex:
|
|
2258
|
+
renderingStartIndex: bt(Number(pt), r),
|
|
2259
|
+
renderingEndIndex: bt(Number(It), r),
|
|
2260
|
+
visibleStartIndex: bt(Number(Q), r),
|
|
2261
|
+
visibleEndIndex: bt(Number(tt), r)
|
|
2144
2262
|
};
|
|
2145
|
-
},
|
|
2263
|
+
}, Nr = (n, t, e, r, i, s, l) => {
|
|
2146
2264
|
if (r === 0)
|
|
2147
2265
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
2148
|
-
const
|
|
2266
|
+
const c = Number.isFinite(l), f = c ? Math.min(Math.max(0, n), l) : Math.max(0, n);
|
|
2149
2267
|
if (r >= Number.MAX_SAFE_INTEGER)
|
|
2150
|
-
return
|
|
2151
|
-
const { index: x, cumulative: I, currentValue:
|
|
2152
|
-
let
|
|
2268
|
+
return Er(f, t, e, r, i, s, l, c);
|
|
2269
|
+
const { index: x, cumulative: I, currentValue: P } = s.findIndexAtOrAfter(f, { materializeOption: { materialize: !1 } }), E = x === -1 ? t <= 0 || (I ?? 0) < f + (P ?? 0) ? r - 1 : 0 : x;
|
|
2270
|
+
let g = bt(E, r), _ = 0;
|
|
2153
2271
|
if (x !== -1 && I === f)
|
|
2154
|
-
|
|
2155
|
-
else if (
|
|
2156
|
-
|
|
2272
|
+
g = bt(x + 1, r), _ = 0;
|
|
2273
|
+
else if (g === x && I !== void 0 && P !== void 0)
|
|
2274
|
+
_ = I - P - f;
|
|
2157
2275
|
else {
|
|
2158
|
-
const { cumulative:
|
|
2159
|
-
|
|
2276
|
+
const { cumulative: D, currentValue: O } = s.prefixSum(g, { materializeOption: { materialize: !1 } });
|
|
2277
|
+
_ = (D ?? 0) - (O ?? 0) - f;
|
|
2160
2278
|
}
|
|
2161
|
-
const
|
|
2162
|
-
let
|
|
2163
|
-
for (;
|
|
2164
|
-
const
|
|
2165
|
-
if (
|
|
2279
|
+
const z = _, j = (D, O) => {
|
|
2280
|
+
let M = D, B = O, N = 0;
|
|
2281
|
+
for (; M < r && B < t; ) {
|
|
2282
|
+
const q = i(M);
|
|
2283
|
+
if (B += q, M++, !Number.isFinite(q) || q < 0)
|
|
2166
2284
|
break;
|
|
2167
|
-
if (
|
|
2168
|
-
if (
|
|
2169
|
-
const { cumulative:
|
|
2170
|
-
if (
|
|
2171
|
-
|
|
2172
|
-
else if (
|
|
2173
|
-
|
|
2285
|
+
if (q === 0) {
|
|
2286
|
+
if (N++, N > Ve) {
|
|
2287
|
+
const { cumulative: et } = s.prefixSum(M - 1, { materializeOption: { materialize: !1 } }), { index: G } = Number.isFinite(et) ? s.findIndexAtOrAfter(et + 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
|
|
2288
|
+
if (G > M)
|
|
2289
|
+
M = G, N = 0;
|
|
2290
|
+
else if (G === M && i(M) > 0)
|
|
2291
|
+
N = 0;
|
|
2174
2292
|
else
|
|
2175
2293
|
break;
|
|
2176
2294
|
}
|
|
2177
2295
|
} else
|
|
2178
|
-
|
|
2296
|
+
N = 0;
|
|
2179
2297
|
}
|
|
2180
|
-
return { cursor:
|
|
2181
|
-
},
|
|
2182
|
-
let
|
|
2183
|
-
if (
|
|
2184
|
-
let
|
|
2185
|
-
for (;
|
|
2186
|
-
const
|
|
2187
|
-
if (
|
|
2188
|
-
|
|
2298
|
+
return { cursor: M, height: B };
|
|
2299
|
+
}, ft = j(g, _);
|
|
2300
|
+
let Q = ft.cursor;
|
|
2301
|
+
if (_ = ft.height, _ < t && g > 0) {
|
|
2302
|
+
let D = _ + Math.abs(Math.min(0, z)), O = g - 1, M = 0;
|
|
2303
|
+
for (; O >= 0 && D < t; ) {
|
|
2304
|
+
const N = i(O);
|
|
2305
|
+
if (D += N, !Number.isFinite(N) || N < 0) {
|
|
2306
|
+
O--;
|
|
2189
2307
|
break;
|
|
2190
2308
|
}
|
|
2191
|
-
if (
|
|
2192
|
-
if (
|
|
2193
|
-
const { cumulative:
|
|
2194
|
-
if (
|
|
2195
|
-
|
|
2309
|
+
if (N === 0) {
|
|
2310
|
+
if (M++, M > Ve) {
|
|
2311
|
+
const { cumulative: q } = s.prefixSum(O, { materializeOption: { materialize: !1 } }), { index: et } = Number.isFinite(q) ? s.findIndexAtOrAfter(q - 0.5, { materializeOption: { materialize: !1 } }) : { index: -1 };
|
|
2312
|
+
if (et !== -1 && et < O) {
|
|
2313
|
+
O = et, M = 0;
|
|
2196
2314
|
continue;
|
|
2197
2315
|
}
|
|
2198
|
-
if (
|
|
2199
|
-
|
|
2316
|
+
if (et === O && O >= 1 && i(O - 1) > 0)
|
|
2317
|
+
M = 0;
|
|
2200
2318
|
else {
|
|
2201
|
-
|
|
2319
|
+
O--;
|
|
2202
2320
|
break;
|
|
2203
2321
|
}
|
|
2204
2322
|
}
|
|
2205
2323
|
} else
|
|
2206
|
-
|
|
2207
|
-
|
|
2324
|
+
M = 0;
|
|
2325
|
+
O--;
|
|
2208
2326
|
}
|
|
2209
|
-
|
|
2210
|
-
const
|
|
2211
|
-
|
|
2327
|
+
g = bt(O + 1, r);
|
|
2328
|
+
const B = j(g, 0);
|
|
2329
|
+
Q = B.cursor, _ = B.height;
|
|
2212
2330
|
}
|
|
2213
|
-
const
|
|
2214
|
-
return { renderingStartIndex:
|
|
2215
|
-
},
|
|
2216
|
-
const r = Math.max(0, t ?? 0),
|
|
2217
|
-
return
|
|
2331
|
+
const tt = bt(g - e, r), pt = bt(Math.max(Q - 1, g), r), It = bt(pt + e, r);
|
|
2332
|
+
return { renderingStartIndex: tt, renderingEndIndex: It, visibleStartIndex: g, visibleEndIndex: pt };
|
|
2333
|
+
}, We = (n, t, e) => {
|
|
2334
|
+
const r = Math.max(0, t ?? 0), i = T({ last: 0, id: null, arg: null }).current;
|
|
2335
|
+
return Y(
|
|
2218
2336
|
() => () => {
|
|
2219
|
-
|
|
2337
|
+
i.id !== null && (cancelAnimationFrame(i.id), i.id = null);
|
|
2220
2338
|
},
|
|
2221
|
-
[
|
|
2222
|
-
),
|
|
2339
|
+
[i]
|
|
2340
|
+
), v(
|
|
2223
2341
|
(s) => {
|
|
2224
|
-
if (
|
|
2225
|
-
const l = (
|
|
2226
|
-
if (
|
|
2227
|
-
const f =
|
|
2228
|
-
if (r === 0 ||
|
|
2229
|
-
if (
|
|
2342
|
+
if (i.arg = s, i.id !== null) return;
|
|
2343
|
+
const l = (c) => {
|
|
2344
|
+
if (i.id = null, i.arg === null) return;
|
|
2345
|
+
const f = c - i.last;
|
|
2346
|
+
if (r === 0 || i.last === 0 || f >= r) {
|
|
2347
|
+
if (n.current)
|
|
2230
2348
|
try {
|
|
2231
|
-
e(
|
|
2349
|
+
e(n.current, i.arg);
|
|
2232
2350
|
} catch (x) {
|
|
2233
2351
|
console.error("[useThrottledInvoker] Error invoking callback", x);
|
|
2234
2352
|
}
|
|
2235
|
-
|
|
2353
|
+
i.arg = null, i.last = c;
|
|
2236
2354
|
}
|
|
2237
|
-
|
|
2355
|
+
i.arg !== null && (i.id = requestAnimationFrame(l));
|
|
2238
2356
|
};
|
|
2239
|
-
|
|
2357
|
+
i.id = requestAnimationFrame(l);
|
|
2240
2358
|
},
|
|
2241
|
-
[r, e,
|
|
2359
|
+
[r, e, n, i]
|
|
2242
2360
|
);
|
|
2243
|
-
},
|
|
2244
|
-
const I =
|
|
2245
|
-
|
|
2361
|
+
}, Vr = Je.memo(({ index: n, top: t, height: e, item: r, children: i, clipItemHeight: s, enableKeyboardNavigation: l, onKeyDown: c, onFocus: f, registerItemRef: x }) => {
|
|
2362
|
+
const I = v((_) => x(n, _), [n, x]), P = v((_) => c(_, n), [n, c]), E = v(() => f(n), [n, f]), g = v((_) => {
|
|
2363
|
+
_.currentTarget.focus({ preventScroll: !0 });
|
|
2246
2364
|
}, []);
|
|
2247
|
-
return /* @__PURE__ */
|
|
2365
|
+
return /* @__PURE__ */ it(
|
|
2248
2366
|
"div",
|
|
2249
2367
|
{
|
|
2250
2368
|
ref: I,
|
|
2251
|
-
"data-index":
|
|
2369
|
+
"data-index": n,
|
|
2252
2370
|
"data-virtualscroll-item": "true",
|
|
2253
2371
|
className: "aqvs-item-container",
|
|
2254
2372
|
style: {
|
|
@@ -2257,575 +2375,579 @@ const Pr = 1e4, Lr = () => {
|
|
|
2257
2375
|
overflow: s ? "hidden" : void 0
|
|
2258
2376
|
},
|
|
2259
2377
|
tabIndex: l ? -1 : void 0,
|
|
2260
|
-
onPointerDown: l ?
|
|
2261
|
-
onKeyDownCapture: l ?
|
|
2262
|
-
onFocusCapture: l ?
|
|
2263
|
-
children:
|
|
2378
|
+
onPointerDown: l ? g : void 0,
|
|
2379
|
+
onKeyDownCapture: l ? P : void 0,
|
|
2380
|
+
onFocusCapture: l ? E : void 0,
|
|
2381
|
+
children: i(r, n)
|
|
2264
2382
|
}
|
|
2265
2383
|
);
|
|
2266
|
-
}),
|
|
2267
|
-
itemCount:
|
|
2384
|
+
}), Ar = ({
|
|
2385
|
+
itemCount: n,
|
|
2268
2386
|
getItem: t,
|
|
2269
2387
|
getItemKey: e,
|
|
2270
2388
|
getItemHeight: r,
|
|
2271
|
-
viewportSize:
|
|
2389
|
+
viewportSize: i,
|
|
2272
2390
|
overscanCount: s = 15,
|
|
2273
2391
|
className: l,
|
|
2274
|
-
testId:
|
|
2392
|
+
testId: c,
|
|
2275
2393
|
onScroll: f,
|
|
2276
2394
|
onRangeChange: x,
|
|
2277
2395
|
children: I,
|
|
2278
|
-
background:
|
|
2279
|
-
initialScrollIndex:
|
|
2280
|
-
initialScrollOffset:
|
|
2281
|
-
callbackThrottleMs:
|
|
2282
|
-
contentInsets:
|
|
2283
|
-
onItemFocus:
|
|
2284
|
-
scrollBarOptions:
|
|
2285
|
-
behaviorOptions:
|
|
2286
|
-
onWheelHorizontal:
|
|
2287
|
-
},
|
|
2288
|
-
const { width:
|
|
2396
|
+
background: P,
|
|
2397
|
+
initialScrollIndex: E,
|
|
2398
|
+
initialScrollOffset: g,
|
|
2399
|
+
callbackThrottleMs: _ = 5,
|
|
2400
|
+
contentInsets: z,
|
|
2401
|
+
onItemFocus: j,
|
|
2402
|
+
scrollBarOptions: ft,
|
|
2403
|
+
behaviorOptions: Q,
|
|
2404
|
+
onWheelHorizontal: tt
|
|
2405
|
+
}, pt) => {
|
|
2406
|
+
const { width: It, enableThumbDrag: D, enableTrackClick: O, enableArrowButtons: M, enableScrollToTopBottomButtons: B, renderThumbOverlay: N, tapScrollCircleOptions: q } = ft ?? {}, { enablePointerDrag: et, pointerDragInputs: G, enableKeyboardNavigation: h = !0, wheelSpeedMultiplier: $, inertiaOptions: Tt, clipItemHeight: wt = !1, resetOnGetItemHeightChange: Z = !1 } = Q ?? {}, k = T(null), Rt = T({
|
|
2289
2407
|
renderingStartIndex: 0,
|
|
2290
2408
|
renderingEndIndex: 0,
|
|
2291
2409
|
visibleStartIndex: 0,
|
|
2292
2410
|
visibleEndIndex: 0,
|
|
2293
2411
|
scrollPosition: 0,
|
|
2294
2412
|
totalHeight: 0
|
|
2295
|
-
}),
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
}, [
|
|
2299
|
-
const
|
|
2300
|
-
const
|
|
2301
|
-
return { from: Math.max(0,
|
|
2302
|
-
}),
|
|
2413
|
+
}), U = T(null), Ct = T(!1);
|
|
2414
|
+
Y(() => {
|
|
2415
|
+
Z && (U.current = null);
|
|
2416
|
+
}, [Z, r]);
|
|
2417
|
+
const w = At(() => Ue(z), [z]), [Yt] = Zt(() => {
|
|
2418
|
+
const u = typeof E == "number" && Number.isFinite(E) ? Math.max(0, Math.trunc(E)) : 0;
|
|
2419
|
+
return { from: Math.max(0, u - 50), to: u + 50 };
|
|
2420
|
+
}), Xt = At(
|
|
2303
2421
|
// 目的: Fenwick Tree のオプション設定
|
|
2304
2422
|
// 依存関係: resetOnGetItemHeightChange, initialSampleRange (マウント時固定)
|
|
2305
2423
|
// itemCount には依存させない (依存させると追記のたびに options 参照が変わり、計測済み高さが全消去される)。
|
|
2306
2424
|
// この useMemo により sampleRange を毎レンダー新規生成しない = 参照同一性由来の破壊的 reset を防ぐ。
|
|
2307
2425
|
() => ({
|
|
2308
|
-
sampleRange:
|
|
2309
|
-
resetOnValueFnChange:
|
|
2426
|
+
sampleRange: Yt,
|
|
2427
|
+
resetOnValueFnChange: Z,
|
|
2310
2428
|
materialize: !0
|
|
2311
2429
|
}),
|
|
2312
|
-
[
|
|
2313
|
-
),
|
|
2314
|
-
let
|
|
2315
|
-
if (typeof
|
|
2316
|
-
const
|
|
2317
|
-
|
|
2318
|
-
} else typeof
|
|
2319
|
-
return { position:
|
|
2320
|
-
}), [
|
|
2321
|
-
|
|
2322
|
-
|
|
2430
|
+
[Z, Yt]
|
|
2431
|
+
), S = Mr(n, r, Xt), [$t] = Zt(() => {
|
|
2432
|
+
let a = 0, u = 0;
|
|
2433
|
+
if (typeof E == "number") {
|
|
2434
|
+
const p = xt(E, 0, n - 1), V = xt(p - s * 2, 0, n - 1), A = xt(p + s * 2, 0, n - 1), F = E > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: V, to: A }] } } : void 0, { cumulative: K, total: W, currentValue: vt } = S.prefixSum(E, F), ht = Math.max(K - vt, 0);
|
|
2435
|
+
a = be(ht, w.top), u = W ?? S.getTotal();
|
|
2436
|
+
} else typeof g == "number" && (a = be(Math.max(g, 0), w.top)), u = S.getTotal();
|
|
2437
|
+
return { position: a, total: u };
|
|
2438
|
+
}), [Bt, Jt] = Zt($t.position), [lt, Wt] = Zt($t.total), d = T($t.position), mt = T(w.top), ct = T(f ?? void 0), H = T(x ?? void 0), nt = T(/* @__PURE__ */ new Map()), J = T(null), Pt = T(null), [Mt, Et] = Zt(null), [st, St] = Zt(!1), yt = T(null), ut = T(!1), ot = T(0), Dt = T(!1), qt = T(!1), le = T(n);
|
|
2439
|
+
le.current !== n && (le.current = n, qt.current = !0), Y(() => {
|
|
2440
|
+
ct.current = f ?? void 0, H.current = x ?? void 0;
|
|
2323
2441
|
}, [x, f]);
|
|
2324
|
-
const
|
|
2325
|
-
(
|
|
2326
|
-
if (
|
|
2442
|
+
const dt = v(
|
|
2443
|
+
(a) => {
|
|
2444
|
+
if (h && a && typeof a.focus == "function")
|
|
2327
2445
|
try {
|
|
2328
|
-
|
|
2446
|
+
a.focus({ preventScroll: !0 });
|
|
2329
2447
|
} catch {
|
|
2330
|
-
|
|
2448
|
+
a.focus();
|
|
2331
2449
|
}
|
|
2332
2450
|
},
|
|
2333
|
-
[
|
|
2334
|
-
),
|
|
2335
|
-
|
|
2336
|
-
}, []),
|
|
2337
|
-
|
|
2338
|
-
}, []), Nt =
|
|
2339
|
-
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
}), []),
|
|
2344
|
-
|
|
2345
|
-
}, [
|
|
2346
|
-
const
|
|
2347
|
-
(
|
|
2348
|
-
if (!
|
|
2349
|
-
|
|
2451
|
+
[h]
|
|
2452
|
+
), Qt = v((a, { position: u, totalHeight: p }) => {
|
|
2453
|
+
a(u, p);
|
|
2454
|
+
}, []), m = We(ct, _, Qt), y = v((a, u) => {
|
|
2455
|
+
a(u);
|
|
2456
|
+
}, []), Nt = We(H, _, y), Lt = T(w.top);
|
|
2457
|
+
Lt.current = w.top;
|
|
2458
|
+
const at = T(m);
|
|
2459
|
+
at.current = m, Y(() => (Ct.current = !1, () => {
|
|
2460
|
+
Ct.current = !0, yt.current && (clearTimeout(yt.current), yt.current = null);
|
|
2461
|
+
}), []), Y(() => {
|
|
2462
|
+
h || (nt.current.clear(), J.current = null, Pt.current = null);
|
|
2463
|
+
}, [h]);
|
|
2464
|
+
const _t = v(
|
|
2465
|
+
(a, u) => {
|
|
2466
|
+
if (!u) {
|
|
2467
|
+
nt.current.delete(a);
|
|
2350
2468
|
return;
|
|
2351
2469
|
}
|
|
2352
|
-
|
|
2470
|
+
h && (nt.current.set(a, u), J.current === a && (J.current = null, Pt.current = a, dt(u)));
|
|
2353
2471
|
},
|
|
2354
|
-
[
|
|
2355
|
-
),
|
|
2472
|
+
[h, dt]
|
|
2473
|
+
), Ht = 0.01, kt = T({
|
|
2356
2474
|
rafId: null,
|
|
2357
2475
|
loopActive: !1,
|
|
2358
2476
|
idleFrames: 0,
|
|
2359
|
-
lastRenderedPosition:
|
|
2360
|
-
}),
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2477
|
+
lastRenderedPosition: $t.position
|
|
2478
|
+
}), jt = v(() => {
|
|
2479
|
+
const a = kt.current;
|
|
2480
|
+
a.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(a.rafId), a.rafId = null, a.loopActive = !1, a.idleFrames = 0;
|
|
2363
2481
|
}, []);
|
|
2364
|
-
|
|
2482
|
+
Y(
|
|
2365
2483
|
() => () => {
|
|
2366
|
-
|
|
2484
|
+
jt();
|
|
2367
2485
|
},
|
|
2368
|
-
[
|
|
2486
|
+
[jt]
|
|
2369
2487
|
);
|
|
2370
|
-
const
|
|
2371
|
-
}),
|
|
2372
|
-
const
|
|
2373
|
-
|
|
2374
|
-
const
|
|
2375
|
-
if (
|
|
2376
|
-
|
|
2488
|
+
const ce = T(() => {
|
|
2489
|
+
}), fe = v(() => {
|
|
2490
|
+
const a = kt.current;
|
|
2491
|
+
a.rafId = null;
|
|
2492
|
+
const u = d.current, p = ne(u, Lt.current), V = S.getTotal();
|
|
2493
|
+
if (Jt((F) => Math.abs(F - u) < Ht ? F : u), Math.abs(a.lastRenderedPosition - u) >= Ht ? (at.current({ position: p, totalHeight: V }), a.lastRenderedPosition = u, a.idleFrames = 0) : a.idleFrames += 1, a.idleFrames >= 2) {
|
|
2494
|
+
jt();
|
|
2377
2495
|
return;
|
|
2378
2496
|
}
|
|
2379
2497
|
if (typeof requestAnimationFrame == "function") {
|
|
2380
|
-
|
|
2498
|
+
a.rafId = requestAnimationFrame((F) => ce.current(F));
|
|
2381
2499
|
return;
|
|
2382
2500
|
}
|
|
2383
|
-
|
|
2384
|
-
}, [
|
|
2385
|
-
|
|
2386
|
-
const
|
|
2387
|
-
const
|
|
2388
|
-
if (
|
|
2389
|
-
if (
|
|
2390
|
-
|
|
2501
|
+
a.loopActive = !1;
|
|
2502
|
+
}, [S, jt]);
|
|
2503
|
+
ce.current = fe;
|
|
2504
|
+
const Ie = v(() => {
|
|
2505
|
+
const a = kt.current;
|
|
2506
|
+
if (a.idleFrames = 0, !a.loopActive) {
|
|
2507
|
+
if (a.loopActive = !0, typeof requestAnimationFrame == "function") {
|
|
2508
|
+
a.rafId = requestAnimationFrame(fe);
|
|
2391
2509
|
return;
|
|
2392
2510
|
}
|
|
2393
|
-
|
|
2511
|
+
a.loopActive = !1;
|
|
2394
2512
|
}
|
|
2395
|
-
}, [
|
|
2396
|
-
(
|
|
2397
|
-
const
|
|
2398
|
-
if (
|
|
2399
|
-
|
|
2513
|
+
}, [fe]), rt = v(
|
|
2514
|
+
(a, u) => {
|
|
2515
|
+
const p = u?.immediate ?? !1, V = ne(a, w.top);
|
|
2516
|
+
if (d.current = a, p) {
|
|
2517
|
+
kt.current.lastRenderedPosition = a, kt.current.idleFrames = 0, Jt(a), m({ position: V, totalHeight: S.getTotal() });
|
|
2400
2518
|
return;
|
|
2401
2519
|
}
|
|
2402
|
-
|
|
2520
|
+
Ie();
|
|
2403
2521
|
},
|
|
2404
|
-
[
|
|
2405
|
-
),
|
|
2406
|
-
const
|
|
2407
|
-
if (!
|
|
2408
|
-
return
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2411
|
-
const
|
|
2412
|
-
return
|
|
2413
|
-
}, []),
|
|
2414
|
-
|
|
2415
|
-
if (!
|
|
2416
|
-
if (
|
|
2417
|
-
const
|
|
2418
|
-
|
|
2522
|
+
[Ie, S, w.top, m]
|
|
2523
|
+
), zt = v((a) => {
|
|
2524
|
+
const u = k.current;
|
|
2525
|
+
if (!u)
|
|
2526
|
+
return a;
|
|
2527
|
+
const p = u.getScrollPosition();
|
|
2528
|
+
ot.current += 1;
|
|
2529
|
+
const V = u.scrollTo(a);
|
|
2530
|
+
return V === p && (ot.current = Math.max(0, ot.current - 1)), Math.abs(V - a) > 0.5 && (Dt.current = !0), V;
|
|
2531
|
+
}, []), Te = T(!1);
|
|
2532
|
+
Y(() => {
|
|
2533
|
+
if (!Te.current)
|
|
2534
|
+
if (Te.current = !0, typeof g == "number") {
|
|
2535
|
+
const a = be(Math.max(g, 0), w.top), u = Math.abs(a - d.current) > 0.5;
|
|
2536
|
+
rt(a, { immediate: !0 }), u && k.current?.scrollTo(a);
|
|
2419
2537
|
} else
|
|
2420
|
-
|
|
2421
|
-
}, [
|
|
2422
|
-
const
|
|
2423
|
-
if (
|
|
2424
|
-
|
|
2538
|
+
rt(d.current, { immediate: !0 });
|
|
2539
|
+
}, [g, w.top, rt]), Y(() => {
|
|
2540
|
+
const a = S.getTotal();
|
|
2541
|
+
if (lt !== a) {
|
|
2542
|
+
Wt(a);
|
|
2425
2543
|
return;
|
|
2426
2544
|
}
|
|
2427
|
-
if (
|
|
2428
|
-
|
|
2429
|
-
const
|
|
2430
|
-
if (
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2545
|
+
if (Dt.current) {
|
|
2546
|
+
Dt.current = !1;
|
|
2547
|
+
const u = k.current;
|
|
2548
|
+
if (u && Math.abs(u.getScrollPosition() - d.current) > 0.5) {
|
|
2549
|
+
const p = zt(d.current);
|
|
2550
|
+
Dt.current = !1, rt(p, { immediate: !0 });
|
|
2433
2551
|
}
|
|
2434
2552
|
}
|
|
2435
|
-
}, [
|
|
2436
|
-
if (
|
|
2437
|
-
const { index:
|
|
2438
|
-
if (
|
|
2439
|
-
const
|
|
2440
|
-
let
|
|
2441
|
-
|
|
2442
|
-
const
|
|
2443
|
-
Math.abs(
|
|
2444
|
-
from:
|
|
2445
|
-
to:
|
|
2446
|
-
targetIndex:
|
|
2447
|
-
}),
|
|
2553
|
+
}, [S, lt, n, zt, rt]), Y(() => {
|
|
2554
|
+
if (U.current !== null) {
|
|
2555
|
+
const { index: a, align: u, offset: p } = U.current, V = bt(a, n), { cumulative: A, currentValue: F } = S.prefixSum(V, { materializeOption: { materialize: !1 } });
|
|
2556
|
+
if (A !== void 0 && F !== void 0) {
|
|
2557
|
+
const K = Math.max(A - F, 0);
|
|
2558
|
+
let W = K;
|
|
2559
|
+
u === "bottom" ? W = A - i : u === "center" && (W = K + F / 2 - i / 2), p && (W -= p), W = Math.max(0, W);
|
|
2560
|
+
const vt = Math.max(0, lt + w.top + w.bottom - i), ht = Math.min(be(W, w.top), vt);
|
|
2561
|
+
Math.abs(ht - d.current) > 1 && (C.debug("[VirtualScroll] Drift correction", {
|
|
2562
|
+
from: d.current,
|
|
2563
|
+
to: ht,
|
|
2564
|
+
targetIndex: V
|
|
2565
|
+
}), ot.current === 0 && (ot.current += 1), k.current?.scrollTo(ht), rt(ht, { immediate: !0 }));
|
|
2448
2566
|
}
|
|
2449
2567
|
}
|
|
2450
|
-
|
|
2451
|
-
}, [
|
|
2452
|
-
const
|
|
2453
|
-
if (
|
|
2454
|
-
const
|
|
2455
|
-
|
|
2456
|
-
}, [
|
|
2457
|
-
const
|
|
2458
|
-
(
|
|
2459
|
-
if (
|
|
2568
|
+
qt.current = !1;
|
|
2569
|
+
}, [lt, S, n, w.top, rt, i, w.bottom]), Y(() => {
|
|
2570
|
+
const a = mt.current;
|
|
2571
|
+
if (a === w.top) return;
|
|
2572
|
+
const u = ne(d.current, a), p = be(u, w.top);
|
|
2573
|
+
mt.current = w.top, d.current = p, k.current?.scrollTo(p), rt(p, { immediate: !0 });
|
|
2574
|
+
}, [w.top, rt]);
|
|
2575
|
+
const Se = v(
|
|
2576
|
+
(a, u) => {
|
|
2577
|
+
if (n === 0)
|
|
2460
2578
|
return;
|
|
2461
|
-
const
|
|
2462
|
-
|
|
2463
|
-
let
|
|
2464
|
-
if (
|
|
2465
|
-
const
|
|
2466
|
-
|
|
2579
|
+
const p = bt(a, n), V = S.get(p), A = u - V, F = S.update(p, u);
|
|
2580
|
+
F !== void 0 && Wt(F), C.debug("[VirtualScroll] Updated item size manually", { index: p, size: u, total: F });
|
|
2581
|
+
let K = U.current ? U.current.index : null;
|
|
2582
|
+
if (K === null) {
|
|
2583
|
+
const W = d.current, vt = Ue(z).top, ht = ne(W, vt), { index: gt, cumulative: Ot } = S.findIndexAtOrAfter(ht, { materializeOption: { materialize: !1 } });
|
|
2584
|
+
K = Ot !== void 0 && Ot === ht ? gt + 1 : gt;
|
|
2467
2585
|
}
|
|
2468
|
-
if (
|
|
2469
|
-
const
|
|
2470
|
-
|
|
2586
|
+
if (K !== -1 && p < K && A !== 0) {
|
|
2587
|
+
const W = d.current, vt = W + A;
|
|
2588
|
+
zt(vt), rt(vt, { immediate: !0 }), C.debug("[VirtualScroll] Adjusted scroll for layout shift (manual update)", { from: W, to: vt, causedByIndex: p, delta: A, activeVisibleStartIndex: K });
|
|
2471
2589
|
}
|
|
2472
2590
|
},
|
|
2473
|
-
[
|
|
2474
|
-
),
|
|
2475
|
-
(
|
|
2476
|
-
if (!
|
|
2591
|
+
[S, n, zt, rt, z]
|
|
2592
|
+
), Kt = v(
|
|
2593
|
+
(a, u) => {
|
|
2594
|
+
if (!k.current || n === 0)
|
|
2477
2595
|
return;
|
|
2478
|
-
const
|
|
2479
|
-
if (
|
|
2596
|
+
const p = bt(a, n), V = bt(p - s * 2, n), A = bt(p + s * 2, n), { cumulative: F, total: K, currentValue: W } = S.prefixSum(p, { materializeOption: { materialize: !0, ranges: [{ from: V, to: A }] } });
|
|
2597
|
+
if (C.debug("[VirtualScroll] Scrolling to index:", p, "ItemBottom:", F, "Total height:", K, "ItemHeight:", W, "safeIndexFrom:", V, "safeIndexTo:", A), !K)
|
|
2480
2598
|
return;
|
|
2481
|
-
const
|
|
2482
|
-
let
|
|
2483
|
-
|
|
2484
|
-
const
|
|
2485
|
-
|
|
2486
|
-
index:
|
|
2487
|
-
align:
|
|
2488
|
-
offset:
|
|
2599
|
+
const vt = Math.max(F - W, 0);
|
|
2600
|
+
let ht = vt;
|
|
2601
|
+
u?.align === "bottom" ? ht = F - i : u?.align === "center" && (ht = vt + W / 2 - i / 2), u?.offset && (ht -= u.offset), ht = Math.max(0, ht);
|
|
2602
|
+
const gt = be(ht, w.top), Ot = k.current?.getContentSize() ?? K + w.top + w.bottom, Vt = Math.max(0, Ot - i), Ft = Math.min(gt, Vt);
|
|
2603
|
+
U.current = {
|
|
2604
|
+
index: p,
|
|
2605
|
+
align: u?.align,
|
|
2606
|
+
offset: u?.offset
|
|
2489
2607
|
};
|
|
2490
|
-
const
|
|
2491
|
-
|
|
2608
|
+
const ve = k.current?.getScrollPosition() ?? -1, De = Math.abs(ve - Ft) > 0.5;
|
|
2609
|
+
ut.current = !1, ot.current = 0, De && (ut.current = !0, ot.current += 1, k.current?.scrollTo(Ft)), Wt(K), rt(Ft, { immediate: !0 }), C.debug("[VirtualScroll] Setting scroll position to:", Ft, { original: gt, max: Vt });
|
|
2492
2610
|
},
|
|
2493
|
-
[
|
|
2494
|
-
),
|
|
2495
|
-
(
|
|
2496
|
-
if (!
|
|
2611
|
+
[S, s, n, w.top, w.bottom, i, rt]
|
|
2612
|
+
), ye = v(
|
|
2613
|
+
(a) => {
|
|
2614
|
+
if (!k.current || n === 0)
|
|
2497
2615
|
return;
|
|
2498
|
-
const
|
|
2499
|
-
|
|
2616
|
+
const u = S.getTotal(), p = xt(Math.floor(a), 0, u), { index: V, cumulative: A, currentValue: F } = S.findIndexAtOrAfter(p, { materializeOption: { materialize: !1 } }), W = (A ?? 0) - (F ?? 0) - p;
|
|
2617
|
+
Kt(V, { offset: W });
|
|
2500
2618
|
},
|
|
2501
|
-
[
|
|
2502
|
-
),
|
|
2503
|
-
(
|
|
2504
|
-
const
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2507
|
-
return
|
|
2619
|
+
[S, n, Kt]
|
|
2620
|
+
), me = v(
|
|
2621
|
+
(a) => {
|
|
2622
|
+
const u = ne(d.current, w.top), p = typeof a == "function" ? a(u) : a;
|
|
2623
|
+
ye(p);
|
|
2624
|
+
const V = k.current?.getScrollPosition(), A = typeof V == "number" ? V : d.current;
|
|
2625
|
+
return rt(A), A;
|
|
2508
2626
|
},
|
|
2509
|
-
[
|
|
2510
|
-
),
|
|
2511
|
-
(
|
|
2512
|
-
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2515
|
-
const
|
|
2516
|
-
if (
|
|
2517
|
-
if (
|
|
2627
|
+
[w.top, ye, rt]
|
|
2628
|
+
), Ae = v(
|
|
2629
|
+
(a, u) => {
|
|
2630
|
+
C.debug("[VirtualScroll] Scroll position changed:", a);
|
|
2631
|
+
const p = ut.current;
|
|
2632
|
+
p && (ut.current = !1);
|
|
2633
|
+
const V = ot.current > 0;
|
|
2634
|
+
if (V && (ot.current = 0), p || V || qt.current || (U.current = null), rt(a), B) {
|
|
2635
|
+
if (p || V)
|
|
2518
2636
|
return;
|
|
2519
|
-
const
|
|
2520
|
-
if (
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2523
|
-
|
|
2637
|
+
const A = a - u;
|
|
2638
|
+
if (C.debug("[VirtualScroll] Scroll diff:", A, "New:", a, "Prev:", u), Math.abs(A) > 1) {
|
|
2639
|
+
const F = A > 0 ? "down" : "up";
|
|
2640
|
+
Et(F), St(!0), C.debug("[VirtualScroll] Showing scroll buttons. Direction:", F), yt.current && clearTimeout(yt.current), yt.current = setTimeout(() => {
|
|
2641
|
+
St(!1), C.debug("[VirtualScroll] Hiding scroll buttons");
|
|
2524
2642
|
}, 2e3);
|
|
2525
2643
|
}
|
|
2526
2644
|
}
|
|
2527
2645
|
},
|
|
2528
|
-
[
|
|
2529
|
-
),
|
|
2530
|
-
const
|
|
2531
|
-
return
|
|
2532
|
-
...
|
|
2533
|
-
scrollPosition:
|
|
2534
|
-
renderingContentSize:
|
|
2646
|
+
[rt, B]
|
|
2647
|
+
), te = At(() => ne(Bt, w.top), [w.top, Bt]), ie = At(() => {
|
|
2648
|
+
const a = S.getTotal(), u = Nr(te, i, s, n, r, S, a);
|
|
2649
|
+
return C.debug("[VirtualScroll] Calculated rendering range:", () => ({
|
|
2650
|
+
...u,
|
|
2651
|
+
scrollPosition: te,
|
|
2652
|
+
renderingContentSize: a,
|
|
2535
2653
|
overscanCount: s,
|
|
2536
|
-
viewportSize:
|
|
2537
|
-
})),
|
|
2538
|
-
}, [
|
|
2539
|
-
(
|
|
2540
|
-
if (!
|
|
2654
|
+
viewportSize: i
|
|
2655
|
+
})), u;
|
|
2656
|
+
}, [te, i, s, n, r, S]), { renderingStartIndex: Ut, renderingEndIndex: ee, visibleStartIndex: se, visibleEndIndex: pe } = ie, re = v(
|
|
2657
|
+
(a, u) => {
|
|
2658
|
+
if (!h || n === 0)
|
|
2541
2659
|
return;
|
|
2542
|
-
const
|
|
2543
|
-
if (!(
|
|
2544
|
-
const
|
|
2545
|
-
|
|
2660
|
+
const p = bt(a, n);
|
|
2661
|
+
if (!(u?.ensureVisible ?? !0)) {
|
|
2662
|
+
const Vt = nt.current.get(p);
|
|
2663
|
+
Vt && (J.current = null, Pt.current = p, dt(Vt));
|
|
2546
2664
|
return;
|
|
2547
2665
|
}
|
|
2548
|
-
const
|
|
2549
|
-
if (
|
|
2550
|
-
|
|
2551
|
-
const
|
|
2552
|
-
|
|
2666
|
+
const A = S.prefixSum(p, { materializeOption: { materialize: !1 } }), F = A.currentValue, K = Math.max(A.cumulative - F, 0), W = K + F, vt = ne(d.current, w.top), ht = vt + i;
|
|
2667
|
+
if (K < vt || W > ht) {
|
|
2668
|
+
Kt(p);
|
|
2669
|
+
const Vt = nt.current.get(p);
|
|
2670
|
+
Vt ? (J.current = null, Pt.current = p, dt(Vt)) : J.current = p;
|
|
2553
2671
|
return;
|
|
2554
2672
|
}
|
|
2555
|
-
const
|
|
2556
|
-
if (
|
|
2557
|
-
|
|
2673
|
+
const Ot = nt.current.get(p);
|
|
2674
|
+
if (Ot) {
|
|
2675
|
+
J.current = null, Pt.current = p, dt(Ot);
|
|
2558
2676
|
return;
|
|
2559
2677
|
}
|
|
2560
|
-
|
|
2678
|
+
J.current = p;
|
|
2561
2679
|
},
|
|
2562
|
-
[
|
|
2563
|
-
), we =
|
|
2564
|
-
(
|
|
2565
|
-
if (!
|
|
2680
|
+
[h, n, S, w.top, Kt, dt, i]
|
|
2681
|
+
), we = v(
|
|
2682
|
+
(a, u) => {
|
|
2683
|
+
if (!h || a.defaultPrevented || a.altKey || a.metaKey || a.ctrlKey)
|
|
2566
2684
|
return;
|
|
2567
|
-
const
|
|
2568
|
-
if (
|
|
2569
|
-
const
|
|
2570
|
-
if (
|
|
2685
|
+
const p = a.target;
|
|
2686
|
+
if (p) {
|
|
2687
|
+
const V = p.tagName;
|
|
2688
|
+
if (V === "INPUT" || V === "TEXTAREA" || V === "SELECT" || p.isContentEditable)
|
|
2571
2689
|
return;
|
|
2572
2690
|
}
|
|
2573
|
-
if (
|
|
2574
|
-
|
|
2691
|
+
if (a.key === "ArrowDown") {
|
|
2692
|
+
u < n - 1 && (a.preventDefault(), re(u + 1));
|
|
2575
2693
|
return;
|
|
2576
2694
|
}
|
|
2577
|
-
if (
|
|
2578
|
-
|
|
2695
|
+
if (a.key === "ArrowUp") {
|
|
2696
|
+
u > 0 && (a.preventDefault(), re(u - 1));
|
|
2579
2697
|
return;
|
|
2580
2698
|
}
|
|
2581
|
-
if (
|
|
2582
|
-
if (
|
|
2583
|
-
|
|
2584
|
-
const { visibleStartIndex:
|
|
2585
|
-
|
|
2699
|
+
if (a.key === "PageDown") {
|
|
2700
|
+
if (u < n - 1) {
|
|
2701
|
+
a.preventDefault();
|
|
2702
|
+
const { visibleStartIndex: V, visibleEndIndex: A } = Rt.current, F = Math.max(A - V + 1, 1), K = Math.max(F, 1), W = bt(Math.min(u + K, n - 1), n);
|
|
2703
|
+
re(W);
|
|
2586
2704
|
}
|
|
2587
2705
|
return;
|
|
2588
2706
|
}
|
|
2589
|
-
if (
|
|
2590
|
-
|
|
2591
|
-
const { visibleStartIndex:
|
|
2592
|
-
|
|
2707
|
+
if (a.key === "PageUp" && u > 0) {
|
|
2708
|
+
a.preventDefault();
|
|
2709
|
+
const { visibleStartIndex: V, visibleEndIndex: A } = Rt.current, F = Math.max(A - V + 1, 1), K = Math.max(F, 1), W = bt(u - K, n);
|
|
2710
|
+
re(W);
|
|
2593
2711
|
}
|
|
2594
2712
|
},
|
|
2595
|
-
[
|
|
2596
|
-
), Re =
|
|
2597
|
-
(
|
|
2598
|
-
if (!
|
|
2713
|
+
[h, n, re]
|
|
2714
|
+
), Re = v(
|
|
2715
|
+
(a) => {
|
|
2716
|
+
if (!h)
|
|
2599
2717
|
return;
|
|
2600
|
-
const
|
|
2601
|
-
|
|
2718
|
+
const u = bt(a, n);
|
|
2719
|
+
J.current = null, Pt.current = u, j?.(u);
|
|
2602
2720
|
},
|
|
2603
|
-
[
|
|
2721
|
+
[h, n, j]
|
|
2604
2722
|
);
|
|
2605
|
-
|
|
2606
|
-
const
|
|
2607
|
-
|
|
2608
|
-
renderingStartIndex:
|
|
2609
|
-
renderingEndIndex:
|
|
2610
|
-
visibleStartIndex:
|
|
2611
|
-
visibleEndIndex:
|
|
2612
|
-
scrollPositionState:
|
|
2613
|
-
paneScrollPosition:
|
|
2614
|
-
logicalScrollPosition:
|
|
2615
|
-
contentSize:
|
|
2616
|
-
scrollPaneScrollPosition:
|
|
2723
|
+
Y(() => {
|
|
2724
|
+
const a = k.current?.getScrollPosition() ?? 0, u = d.current, p = ne(u, w.top);
|
|
2725
|
+
C.debug("[VirtualScroll] Range change effect triggered", () => ({
|
|
2726
|
+
renderingStartIndex: Ut,
|
|
2727
|
+
renderingEndIndex: ee,
|
|
2728
|
+
visibleStartIndex: se,
|
|
2729
|
+
visibleEndIndex: pe,
|
|
2730
|
+
scrollPositionState: Bt,
|
|
2731
|
+
paneScrollPosition: u,
|
|
2732
|
+
logicalScrollPosition: p,
|
|
2733
|
+
contentSize: lt,
|
|
2734
|
+
scrollPaneScrollPosition: a
|
|
2617
2735
|
})), Nt({
|
|
2618
|
-
renderingStartIndex:
|
|
2619
|
-
renderingEndIndex:
|
|
2620
|
-
visibleStartIndex:
|
|
2621
|
-
visibleEndIndex:
|
|
2622
|
-
scrollPosition:
|
|
2623
|
-
totalHeight:
|
|
2736
|
+
renderingStartIndex: Ut,
|
|
2737
|
+
renderingEndIndex: ee,
|
|
2738
|
+
visibleStartIndex: se,
|
|
2739
|
+
visibleEndIndex: pe,
|
|
2740
|
+
scrollPosition: p,
|
|
2741
|
+
totalHeight: lt
|
|
2624
2742
|
});
|
|
2625
|
-
}, [
|
|
2626
|
-
const
|
|
2743
|
+
}, [lt, ee, Ut, w.top, Nt, Bt, pe, se]);
|
|
2744
|
+
const Ce = v(() => B ? /* @__PURE__ */ it("div", { className: "aqvs-scroll-to-edge-overlay", "data-visible": st && Mt !== null, children: Mt === "up" ? /* @__PURE__ */ it("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-top", children: /* @__PURE__ */ it(
|
|
2627
2745
|
"button",
|
|
2628
2746
|
{
|
|
2629
2747
|
type: "button",
|
|
2630
2748
|
className: "aqvs-scroll-to-edge-button",
|
|
2631
|
-
onClick: (
|
|
2632
|
-
|
|
2749
|
+
onClick: (p) => {
|
|
2750
|
+
p.stopPropagation(), ut.current = !0, Kt(0), St(!1);
|
|
2633
2751
|
},
|
|
2634
2752
|
children: "Top"
|
|
2635
2753
|
}
|
|
2636
|
-
) }) : /* @__PURE__ */
|
|
2754
|
+
) }) : /* @__PURE__ */ it("div", { className: "aqvs-scroll-to-edge-button-container aqvs-scroll-to-edge-button-container-bottom", children: /* @__PURE__ */ it(
|
|
2637
2755
|
"button",
|
|
2638
2756
|
{
|
|
2639
2757
|
type: "button",
|
|
2640
2758
|
className: "aqvs-scroll-to-edge-button",
|
|
2641
|
-
onClick: (
|
|
2642
|
-
|
|
2759
|
+
onClick: (p) => {
|
|
2760
|
+
p.stopPropagation(), ut.current = !0, Kt(n - 1), St(!1);
|
|
2643
2761
|
},
|
|
2644
2762
|
children: "Bottom"
|
|
2645
2763
|
}
|
|
2646
|
-
) }) }) : null, [
|
|
2647
|
-
if (
|
|
2764
|
+
) }) }) : null, [B, st, Mt, Kt, n]), he = T(0), { visibleItems: o, renderAnchor: b } = At(() => {
|
|
2765
|
+
if (n === 0)
|
|
2648
2766
|
return {
|
|
2649
|
-
visibleItems: /* @__PURE__ */
|
|
2767
|
+
visibleItems: /* @__PURE__ */ it("div", { className: "aqvs-no-items-container", children: /* @__PURE__ */ it("div", { className: "aqvs-no-items-text", children: "No items" }) }),
|
|
2650
2768
|
renderAnchor: 0
|
|
2651
2769
|
};
|
|
2652
|
-
const
|
|
2653
|
-
Number.isFinite(
|
|
2654
|
-
const
|
|
2655
|
-
let
|
|
2656
|
-
for (let
|
|
2657
|
-
if (
|
|
2658
|
-
|
|
2770
|
+
const a = bt(Ut, n), u = bt(ee, n), { cumulative: p, currentValue: V } = S.prefixSum(a, { materializeOption: { materialize: !1 } }), A = p - V;
|
|
2771
|
+
Number.isFinite(A) && Math.abs(A - he.current) > Cr && (he.current = A);
|
|
2772
|
+
const F = he.current, K = [], W = [];
|
|
2773
|
+
let vt = 0, ht = A;
|
|
2774
|
+
for (let gt = a; gt <= u; gt++) {
|
|
2775
|
+
if (W.length >= Ke) {
|
|
2776
|
+
C.warn("[VirtualScroll] Rendered item count reached the safety cap; truncating render window.", { cap: Ke, safeRenderingStartIndex: a, safeRenderingEndIndex: u });
|
|
2659
2777
|
break;
|
|
2660
2778
|
}
|
|
2661
|
-
const
|
|
2662
|
-
|
|
2663
|
-
const
|
|
2664
|
-
|
|
2665
|
-
/* @__PURE__ */
|
|
2666
|
-
|
|
2779
|
+
const Ot = r(gt), Vt = S.get(gt), Ft = Ot - Vt;
|
|
2780
|
+
Ft !== 0 && K.push({ index: gt, value: Ot });
|
|
2781
|
+
const ve = ht + vt, De = e ? e(gt) : gt;
|
|
2782
|
+
W.push(
|
|
2783
|
+
/* @__PURE__ */ it(
|
|
2784
|
+
Vr,
|
|
2667
2785
|
{
|
|
2668
|
-
index:
|
|
2669
|
-
top:
|
|
2670
|
-
height:
|
|
2671
|
-
item: t(
|
|
2672
|
-
clipItemHeight:
|
|
2673
|
-
enableKeyboardNavigation:
|
|
2786
|
+
index: gt,
|
|
2787
|
+
top: ve - F,
|
|
2788
|
+
height: Ot,
|
|
2789
|
+
item: t(gt),
|
|
2790
|
+
clipItemHeight: wt,
|
|
2791
|
+
enableKeyboardNavigation: h,
|
|
2674
2792
|
onKeyDown: we,
|
|
2675
2793
|
onFocus: Re,
|
|
2676
|
-
registerItemRef:
|
|
2794
|
+
registerItemRef: _t,
|
|
2677
2795
|
children: I
|
|
2678
2796
|
},
|
|
2679
|
-
|
|
2797
|
+
De
|
|
2680
2798
|
)
|
|
2681
|
-
),
|
|
2799
|
+
), vt += Ft, ht += Vt;
|
|
2682
2800
|
}
|
|
2683
|
-
return
|
|
2684
|
-
if (
|
|
2801
|
+
return K.length > 0 && Promise.resolve().then(() => {
|
|
2802
|
+
if (Ct.current)
|
|
2685
2803
|
return;
|
|
2686
|
-
let
|
|
2687
|
-
for (const
|
|
2688
|
-
if (
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2804
|
+
let gt = 0;
|
|
2805
|
+
for (const Ft of K)
|
|
2806
|
+
if (Ft.index < se) {
|
|
2807
|
+
const ve = S.get(Ft.index);
|
|
2808
|
+
gt += Ft.value - ve;
|
|
2691
2809
|
}
|
|
2692
|
-
const
|
|
2693
|
-
if (
|
|
2810
|
+
const Ot = S.updates(K);
|
|
2811
|
+
if (Ct.current || typeof Ot != "number")
|
|
2694
2812
|
return;
|
|
2695
|
-
|
|
2696
|
-
const
|
|
2697
|
-
if (
|
|
2698
|
-
const
|
|
2699
|
-
|
|
2700
|
-
} else
|
|
2701
|
-
}), { visibleItems:
|
|
2813
|
+
Wt(Ot), C.debug("[VirtualScroll] Updated heights for items", K, "New total height:", Ot);
|
|
2814
|
+
const Vt = k.current?.getScrollPosition() ?? d.current;
|
|
2815
|
+
if (gt !== 0) {
|
|
2816
|
+
const Ft = Vt + gt;
|
|
2817
|
+
zt(Ft), rt(Ft, { immediate: !0 }), C.debug("[VirtualScroll] Adjusted scroll for layout shift (auto update)", { from: Vt, to: Ft, shiftAmount: gt });
|
|
2818
|
+
} else Vt !== d.current && rt(Vt);
|
|
2819
|
+
}), { visibleItems: W, renderAnchor: F };
|
|
2702
2820
|
}, [
|
|
2703
2821
|
I,
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2822
|
+
wt,
|
|
2823
|
+
lt,
|
|
2824
|
+
h,
|
|
2825
|
+
n,
|
|
2826
|
+
S,
|
|
2709
2827
|
t,
|
|
2710
2828
|
e,
|
|
2711
2829
|
r,
|
|
2712
2830
|
Re,
|
|
2713
2831
|
we,
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
]),
|
|
2721
|
-
(
|
|
2722
|
-
const
|
|
2723
|
-
if (
|
|
2724
|
-
currentScrollPosition:
|
|
2725
|
-
effectiveScrollPosition:
|
|
2726
|
-
renderingStartIndex:
|
|
2727
|
-
renderingEndIndex:
|
|
2728
|
-
itemCount:
|
|
2729
|
-
viewportSize:
|
|
2730
|
-
callbackThrottleMs:
|
|
2731
|
-
diff:
|
|
2732
|
-
rawEffectiveScrollPosition:
|
|
2733
|
-
})),
|
|
2734
|
-
return
|
|
2735
|
-
const
|
|
2832
|
+
zt,
|
|
2833
|
+
_t,
|
|
2834
|
+
ee,
|
|
2835
|
+
Ut,
|
|
2836
|
+
rt,
|
|
2837
|
+
se
|
|
2838
|
+
]), R = v(
|
|
2839
|
+
(a) => {
|
|
2840
|
+
const u = (_ ?? 0) > 0, p = Math.abs(a - Bt), V = u && p > 0.5 ? Bt : a, A = ne(V, w.top);
|
|
2841
|
+
if (C.debug("[VirtualScroll] Rendering visible items", () => ({
|
|
2842
|
+
currentScrollPosition: a,
|
|
2843
|
+
effectiveScrollPosition: A,
|
|
2844
|
+
renderingStartIndex: Ut,
|
|
2845
|
+
renderingEndIndex: ee,
|
|
2846
|
+
itemCount: n,
|
|
2847
|
+
viewportSize: i,
|
|
2848
|
+
callbackThrottleMs: _,
|
|
2849
|
+
diff: p,
|
|
2850
|
+
rawEffectiveScrollPosition: V
|
|
2851
|
+
})), n === 0)
|
|
2852
|
+
return o;
|
|
2853
|
+
const F = w.top + b - V, K = w.bottom > 0 ? /* @__PURE__ */ it(
|
|
2736
2854
|
"div",
|
|
2737
2855
|
{
|
|
2738
2856
|
className: "aqvs-bottom-inset",
|
|
2739
2857
|
style: {
|
|
2740
2858
|
// ラッパー座標での bottom インセット位置 = コンテンツ総高さ (最終行の下端) - アンカー。
|
|
2741
|
-
top:
|
|
2742
|
-
height:
|
|
2859
|
+
top: S.getTotal() - b,
|
|
2860
|
+
height: w.bottom
|
|
2743
2861
|
}
|
|
2744
2862
|
},
|
|
2745
2863
|
"virtualscroll-bottom-inset"
|
|
2746
2864
|
) : null;
|
|
2747
|
-
return
|
|
2748
|
-
containerTop:
|
|
2749
|
-
logicalScrollPosition:
|
|
2750
|
-
resolvedInsets:
|
|
2751
|
-
effectiveScrollPosition:
|
|
2752
|
-
})), /* @__PURE__ */
|
|
2753
|
-
|
|
2754
|
-
|
|
2865
|
+
return C.debug("[VirtualScroll] Rendering items", () => ({
|
|
2866
|
+
containerTop: F,
|
|
2867
|
+
logicalScrollPosition: te,
|
|
2868
|
+
resolvedInsets: w,
|
|
2869
|
+
effectiveScrollPosition: A
|
|
2870
|
+
})), /* @__PURE__ */ de("div", { className: "aqvs-items-wrapper", style: { top: 0, transform: `translateY(${F}px)`, willChange: "transform" }, children: [
|
|
2871
|
+
o,
|
|
2872
|
+
K
|
|
2755
2873
|
] });
|
|
2756
2874
|
},
|
|
2757
|
-
[
|
|
2758
|
-
),
|
|
2875
|
+
[_, n, S, te, b, ee, Ut, w, Bt, i, o]
|
|
2876
|
+
), L = At(
|
|
2759
2877
|
() => ({
|
|
2760
|
-
renderingStartIndex:
|
|
2761
|
-
renderingEndIndex:
|
|
2762
|
-
visibleStartIndex:
|
|
2763
|
-
visibleEndIndex:
|
|
2764
|
-
scrollPosition:
|
|
2765
|
-
totalHeight:
|
|
2878
|
+
renderingStartIndex: ie.renderingStartIndex,
|
|
2879
|
+
renderingEndIndex: ie.renderingEndIndex,
|
|
2880
|
+
visibleStartIndex: ie.visibleStartIndex,
|
|
2881
|
+
visibleEndIndex: ie.visibleEndIndex,
|
|
2882
|
+
scrollPosition: te,
|
|
2883
|
+
totalHeight: S.getTotal()
|
|
2766
2884
|
// contentSize (State) ではなく最新値を反映
|
|
2767
2885
|
}),
|
|
2768
2886
|
// contentSize を依存に含めることで、updateItemSize/updates 等で木の総高さが変わった際に
|
|
2769
2887
|
// (fenwickTree は安定参照のため getTotal() の変化だけでは再計算されない) 総高さを再取得する。
|
|
2770
|
-
[
|
|
2888
|
+
[ie, te, S, lt]
|
|
2771
2889
|
);
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
}, [
|
|
2775
|
-
|
|
2890
|
+
Y(() => {
|
|
2891
|
+
Rt.current = L;
|
|
2892
|
+
}, [L]), Be(
|
|
2893
|
+
pt,
|
|
2776
2894
|
() => ({
|
|
2777
|
-
getScrollPosition: () =>
|
|
2778
|
-
getContentSize: () =>
|
|
2779
|
-
getViewportSize: () =>
|
|
2780
|
-
scrollTo:
|
|
2781
|
-
scrollToIndex:
|
|
2782
|
-
getFenwickTreeTotalHeight: () =>
|
|
2783
|
-
getFenwickSize: () =>
|
|
2784
|
-
focusItemAtIndex:
|
|
2785
|
-
getRange: () =>
|
|
2786
|
-
updateItemSize:
|
|
2895
|
+
getScrollPosition: () => k.current?.getScrollPosition() ?? -1,
|
|
2896
|
+
getContentSize: () => k.current?.getContentSize() ?? -1,
|
|
2897
|
+
getViewportSize: () => k.current?.getViewportSize() ?? -1,
|
|
2898
|
+
scrollTo: me,
|
|
2899
|
+
scrollToIndex: Kt,
|
|
2900
|
+
getFenwickTreeTotalHeight: () => S.getTotal(),
|
|
2901
|
+
getFenwickSize: () => S.getSize(),
|
|
2902
|
+
focusItemAtIndex: re,
|
|
2903
|
+
getRange: () => Rt.current,
|
|
2904
|
+
updateItemSize: Se
|
|
2787
2905
|
}),
|
|
2788
|
-
[
|
|
2906
|
+
[me, Kt, S, re, Se]
|
|
2789
2907
|
);
|
|
2790
|
-
const
|
|
2791
|
-
return /* @__PURE__ */
|
|
2792
|
-
|
|
2908
|
+
const X = S.getTotal() + w.top + w.bottom;
|
|
2909
|
+
return /* @__PURE__ */ it(
|
|
2910
|
+
Sr,
|
|
2793
2911
|
{
|
|
2794
|
-
ref:
|
|
2795
|
-
contentSize:
|
|
2796
|
-
viewportSize:
|
|
2912
|
+
ref: k,
|
|
2913
|
+
contentSize: X,
|
|
2914
|
+
viewportSize: i,
|
|
2797
2915
|
className: l,
|
|
2798
|
-
testId:
|
|
2799
|
-
onScroll:
|
|
2800
|
-
background:
|
|
2801
|
-
tapScrollCircleOptions:
|
|
2802
|
-
inertiaOptions:
|
|
2803
|
-
itemCount:
|
|
2804
|
-
scrollBarWidth:
|
|
2805
|
-
enableThumbDrag:
|
|
2806
|
-
enableTrackClick:
|
|
2807
|
-
enableArrowButtons:
|
|
2808
|
-
enablePointerDrag:
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2916
|
+
testId: c,
|
|
2917
|
+
onScroll: Ae,
|
|
2918
|
+
background: P,
|
|
2919
|
+
tapScrollCircleOptions: q,
|
|
2920
|
+
inertiaOptions: Tt,
|
|
2921
|
+
itemCount: n,
|
|
2922
|
+
scrollBarWidth: It,
|
|
2923
|
+
enableThumbDrag: D,
|
|
2924
|
+
enableTrackClick: O,
|
|
2925
|
+
enableArrowButtons: M,
|
|
2926
|
+
enablePointerDrag: et,
|
|
2927
|
+
pointerDragInputs: G,
|
|
2928
|
+
renderThumbOverlay: N,
|
|
2929
|
+
wheelSpeedMultiplier: $,
|
|
2930
|
+
onWheelHorizontal: tt,
|
|
2931
|
+
contentInsets: w,
|
|
2932
|
+
visibleStartIndex: se,
|
|
2933
|
+
visibleEndIndex: pe,
|
|
2934
|
+
renderOverlay: Ce,
|
|
2935
|
+
initialScrollPosition: $t.position,
|
|
2936
|
+
children: R
|
|
2818
2937
|
}
|
|
2819
2938
|
);
|
|
2820
|
-
},
|
|
2939
|
+
}, Fr = Ye(Ar);
|
|
2821
2940
|
export {
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2941
|
+
ae as FenwickMapTree,
|
|
2942
|
+
xr as ScrollBar,
|
|
2943
|
+
Sr as ScrollPane,
|
|
2944
|
+
Ze as TAP_SCROLL_SPEED_DEFAULTS,
|
|
2945
|
+
Fr as VirtualScroll,
|
|
2946
|
+
br as computeAutoTapScrollMaxSpeedMultiplier,
|
|
2947
|
+
gr as computeTapScrollSpeed,
|
|
2948
|
+
xt as minmax,
|
|
2949
|
+
kr as tapScrollCircleSampleVisual,
|
|
2950
|
+
Mr as useFenwickMapTree,
|
|
2951
|
+
Or as useHeightCache,
|
|
2952
|
+
wr as useLruCache
|
|
2831
2953
|
};
|