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