@aiquants/virtualscroll 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -6
- package/dist/index.cjs +1 -2
- package/dist/index.js +1523 -877
- package/dist/src/ScrollBar.d.ts +26 -3
- package/dist/src/ScrollBar.d.ts.map +1 -1
- package/dist/src/ScrollPane.d.ts +12 -2
- package/dist/src/ScrollPane.d.ts.map +1 -1
- package/dist/src/TapScrollCircle.d.ts.map +1 -1
- package/dist/src/VirtualScroll.d.ts +25 -0
- package/dist/src/VirtualScroll.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/useFenwickMapTree.d.ts +24 -10
- package/dist/src/useFenwickMapTree.d.ts.map +1 -1
- package/dist/src/useLruCache.d.ts +4 -3
- package/dist/src/useLruCache.d.ts.map +1 -1
- package/dist/styles/virtualscroll.css +2 -0
- package/dist/virtualscroll.css +1 -1
- package/dist/vite.config.d.ts.map +1 -1
- package/package.json +17 -14
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,722 +1,929 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { twMerge as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as Q, jsxs as Gt, Fragment as ye } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as me, useState as Yt, useRef as w, useCallback as M, useImperativeHandle as he, useMemo as Vt, useEffect as L, useLayoutEffect as se, useId as Le } from "react";
|
|
3
|
+
import { twMerge as jt } from "tailwind-merge";
|
|
4
|
+
const xe = {
|
|
5
5
|
active: !1,
|
|
6
6
|
offsetX: 0,
|
|
7
7
|
offsetY: 0,
|
|
8
8
|
distance: 0,
|
|
9
9
|
direction: 0
|
|
10
|
-
},
|
|
11
|
-
const
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
/* @__PURE__ */
|
|
10
|
+
}, de = 6, Ye = 8, ze = ({ dragState: r, normalizedDistance: t }) => {
|
|
11
|
+
const e = 1 + t * 0.18, n = 0.16 + t * 0.24, o = 0.38 + t * 0.28, a = r.active ? "80ms ease-out" : "220ms ease";
|
|
12
|
+
return /* @__PURE__ */ Gt(ye, { children: [
|
|
13
|
+
/* @__PURE__ */ Q(
|
|
14
14
|
"div",
|
|
15
15
|
{
|
|
16
16
|
className: "absolute inset-0 rounded-full",
|
|
17
17
|
style: {
|
|
18
18
|
background: "linear-gradient(140deg, rgba(255,255,255,0.62), rgba(72,72,72,0.48))",
|
|
19
19
|
boxShadow: `0 0 0 1px rgba(255,255,255,0.28), 0 10px 22px rgba(0,0,0,${n})`,
|
|
20
|
-
transform: `scale(${
|
|
21
|
-
transition: `${
|
|
20
|
+
transform: `scale(${e})`,
|
|
21
|
+
transition: `${a}, ${r.active ? "80ms" : "260ms"} box-shadow ease`
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
),
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ Q(
|
|
26
26
|
"div",
|
|
27
27
|
{
|
|
28
|
-
className: "absolute
|
|
28
|
+
className: "aqvs:tap-scroll-circle-inner absolute rounded-full",
|
|
29
29
|
style: {
|
|
30
30
|
background: "linear-gradient(140deg, rgba(255,255,255,0.72), rgba(28,28,28,0.58))",
|
|
31
31
|
boxShadow: "inset 0 4px 10px rgba(0,0,0,0.24), inset 0 0 2px rgba(255,255,255,0.55)",
|
|
32
|
-
opacity:
|
|
33
|
-
transition:
|
|
32
|
+
opacity: o,
|
|
33
|
+
transition: r.active ? "120ms opacity ease-out" : "220ms opacity ease"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
)
|
|
37
37
|
] });
|
|
38
|
-
},
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
}, Me = me(({ onDragChange: r, className: t, maxVisualDistance: e = 160, size: n = 40, style: o, opacity: a = 1, renderVisual: u }, f) => {
|
|
39
|
+
const [l, c] = Yt(xe), d = w(null), h = w({ x: 0, y: 0 }), b = w(null), T = w(0), k = M(
|
|
40
|
+
(C) => {
|
|
41
|
+
c(C), r(C);
|
|
42
|
+
},
|
|
43
|
+
[r]
|
|
44
|
+
), _ = M(
|
|
45
|
+
(C, P, j = !1) => {
|
|
46
|
+
const { x: rt, y: Ct } = h.current, ot = C - rt, $ = P - Ct, ct = Math.abs($), dt = ct < de ? 0 : $ < 0 ? -1 : 1, A = T.current;
|
|
47
|
+
let S = dt;
|
|
48
|
+
const v = de + Ye;
|
|
49
|
+
dt === 0 ? A !== 0 && ct < v ? S = A : (S = 0, j || (T.current = 0)) : dt !== A && A !== 0 && ct < v ? S = A : T.current = dt, k({
|
|
50
|
+
active: j || ct >= de,
|
|
51
|
+
offsetX: ot,
|
|
52
|
+
offsetY: $,
|
|
53
|
+
distance: ct,
|
|
54
|
+
direction: S
|
|
50
55
|
});
|
|
51
56
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
54
|
-
if (
|
|
57
|
+
[k]
|
|
58
|
+
), tt = M((C) => {
|
|
59
|
+
if (C === null)
|
|
55
60
|
return;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
}, []),
|
|
59
|
-
(
|
|
60
|
-
|
|
61
|
+
const P = b.current;
|
|
62
|
+
P?.hasPointerCapture(C) && P.releasePointerCapture(C);
|
|
63
|
+
}, []), Y = M(
|
|
64
|
+
(C = !1) => {
|
|
65
|
+
C && tt(d.current), d.current = null, T.current = 0, k(xe);
|
|
61
66
|
},
|
|
62
|
-
[
|
|
63
|
-
),
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
67
|
+
[k, tt]
|
|
68
|
+
), ut = M(
|
|
69
|
+
(C) => {
|
|
70
|
+
C.preventDefault(), C.stopPropagation();
|
|
71
|
+
const P = b.current ?? C.currentTarget, { left: j, top: rt, width: Ct, height: ot } = P.getBoundingClientRect();
|
|
72
|
+
h.current = { x: j + Ct / 2, y: rt + ot / 2 }, d.current = C.pointerId, P.setPointerCapture(C.pointerId), _(C.clientX, C.clientY, !0);
|
|
68
73
|
},
|
|
69
|
-
[
|
|
70
|
-
),
|
|
71
|
-
(
|
|
72
|
-
d.current ===
|
|
74
|
+
[_]
|
|
75
|
+
), V = M(
|
|
76
|
+
(C) => {
|
|
77
|
+
d.current === C.pointerId && (C.preventDefault(), _(C.clientX, C.clientY));
|
|
73
78
|
},
|
|
74
|
-
[
|
|
75
|
-
),
|
|
76
|
-
(
|
|
77
|
-
d.current ===
|
|
79
|
+
[_]
|
|
80
|
+
), D = M(
|
|
81
|
+
(C) => {
|
|
82
|
+
d.current === C.pointerId && (C.preventDefault(), C.stopPropagation(), Y(!0));
|
|
78
83
|
},
|
|
79
|
-
[
|
|
84
|
+
[Y]
|
|
80
85
|
);
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
he(
|
|
87
|
+
f,
|
|
83
88
|
() => ({
|
|
84
89
|
reset: () => {
|
|
85
|
-
|
|
90
|
+
Y(!0);
|
|
86
91
|
},
|
|
87
|
-
getElement: () =>
|
|
92
|
+
getElement: () => b.current
|
|
88
93
|
}),
|
|
89
|
-
[
|
|
94
|
+
[Y]
|
|
90
95
|
);
|
|
91
|
-
const
|
|
92
|
-
dragState:
|
|
93
|
-
normalizedDistance:
|
|
94
|
-
sizeScale:
|
|
96
|
+
const X = Math.min(Math.max(a, 0), 1), O = n / 64, R = Math.min(l.distance, e) / e, H = l.direction * R * 10 * O, q = u ?? ze, N = {
|
|
97
|
+
dragState: l,
|
|
98
|
+
normalizedDistance: R,
|
|
99
|
+
sizeScale: O,
|
|
95
100
|
size: n,
|
|
96
|
-
opacity:
|
|
97
|
-
},
|
|
98
|
-
...
|
|
101
|
+
opacity: X
|
|
102
|
+
}, g = {
|
|
103
|
+
...o,
|
|
99
104
|
width: n,
|
|
100
105
|
height: n,
|
|
101
|
-
transform: `translateY(${
|
|
106
|
+
transform: `translateY(${H}px)`
|
|
102
107
|
};
|
|
103
|
-
return
|
|
108
|
+
return g.opacity = X, /* @__PURE__ */ Q(
|
|
104
109
|
"div",
|
|
105
110
|
{
|
|
106
|
-
ref:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
onPointerUp: Z,
|
|
116
|
-
onPointerCancel: Z,
|
|
111
|
+
ref: b,
|
|
112
|
+
"data-testid": "virtual-scroll-tap-circle",
|
|
113
|
+
className: jt("relative flex touch-none select-none items-center justify-center", "transition-transform duration-100 ease-out", t),
|
|
114
|
+
style: g,
|
|
115
|
+
tabIndex: -1,
|
|
116
|
+
onPointerDown: ut,
|
|
117
|
+
onPointerMove: V,
|
|
118
|
+
onPointerUp: D,
|
|
119
|
+
onPointerCancel: D,
|
|
117
120
|
role: "presentation",
|
|
118
|
-
children:
|
|
121
|
+
children: q(N)
|
|
119
122
|
}
|
|
120
123
|
);
|
|
121
124
|
});
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const n = "touches" in o.nativeEvent, r = n ? o.nativeEvent.touches[0] : o.nativeEvent, i = (a) => {
|
|
125
|
-
n && a.cancelable && a.preventDefault();
|
|
126
|
-
const h = "touches" in a ? a.touches[0] : a;
|
|
127
|
-
e({
|
|
128
|
-
deltaX: h.clientX - r.clientX,
|
|
129
|
-
deltaY: h.clientY - r.clientY
|
|
130
|
-
});
|
|
131
|
-
}, l = () => {
|
|
132
|
-
n ? (document.removeEventListener("touchmove", i), document.removeEventListener("touchend", l)) : (document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", l)), t?.();
|
|
133
|
-
};
|
|
134
|
-
n ? (document.addEventListener("touchmove", i, { passive: !1 }), document.addEventListener("touchend", l)) : (document.addEventListener("mousemove", i), document.addEventListener("mouseup", l));
|
|
135
|
-
}, Ne = "virtualscroll:tap-scroll-cancel", We = 20, at = 250, lt = 60, ct = 20, ut = 20, dt = 220, Be = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, De = 2.2, ft = 8, ht = 120, pe = {
|
|
125
|
+
Me.displayName = "TapScrollCircle";
|
|
126
|
+
const pt = (r, t, e) => Math.min(e, Math.max(t, r)), pe = "virtualscroll:tap-scroll-cancel", Ie = 20, Xe = 250, He = 60, Ue = 20, qe = 20, Be = 240, Te = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, fe = 2.2, $e = 8, We = 120, Ke = 1 / 60, Lt = {
|
|
136
127
|
enabled: !0,
|
|
137
128
|
size: 40,
|
|
138
129
|
offsetX: -80,
|
|
139
130
|
offsetY: 0,
|
|
140
131
|
className: void 0,
|
|
141
|
-
maxVisualDistance:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
r
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
132
|
+
maxVisualDistance: Be,
|
|
133
|
+
minSpeedMultiplier: 0.2,
|
|
134
|
+
opacity: 0.9,
|
|
135
|
+
renderVisual: void 0,
|
|
136
|
+
maxSpeedCurve: void 0
|
|
137
|
+
}, je = (r) => r ? {
|
|
138
|
+
mainSizeKey: "width",
|
|
139
|
+
crossSizeKey: "height",
|
|
140
|
+
positionKey: "left",
|
|
141
|
+
selectDelta: (t, e) => t,
|
|
142
|
+
getPointerCoordinate: ({ clientX: t }) => t,
|
|
143
|
+
arrowLabels: ["Scroll left", "Scroll right"],
|
|
144
|
+
arrowIcons: ["◀", "▶"],
|
|
145
|
+
directionClass: "flex flex-row items-stretch",
|
|
146
|
+
orientation: "horizontal"
|
|
147
|
+
} : {
|
|
148
|
+
mainSizeKey: "height",
|
|
149
|
+
crossSizeKey: "width",
|
|
150
|
+
positionKey: "top",
|
|
151
|
+
selectDelta: (t, e) => e,
|
|
152
|
+
getPointerCoordinate: ({ clientY: t }) => t,
|
|
153
|
+
arrowLabels: ["Scroll up", "Scroll down"],
|
|
154
|
+
arrowIcons: ["▲", "▼"],
|
|
155
|
+
directionClass: "flex flex-col items-stretch",
|
|
156
|
+
orientation: "vertical"
|
|
157
|
+
}, Ge = (r, t) => {
|
|
158
|
+
const e = r?.maxSpeedMultiplier, n = typeof e == "number" ? e : Qe(t);
|
|
159
|
+
return {
|
|
160
|
+
enabled: r?.enabled ?? Lt.enabled,
|
|
161
|
+
size: r?.size ?? Lt.size,
|
|
162
|
+
offsetX: r?.offsetX ?? Lt.offsetX,
|
|
163
|
+
offsetY: r?.offsetY ?? Lt.offsetY,
|
|
164
|
+
className: r?.className ?? Lt.className,
|
|
165
|
+
maxVisualDistance: r?.maxVisualDistance ?? Lt.maxVisualDistance,
|
|
166
|
+
maxSpeedMultiplier: n,
|
|
167
|
+
minSpeedMultiplier: Math.max(r?.minSpeedMultiplier ?? Lt.minSpeedMultiplier, 0),
|
|
168
|
+
opacity: pt(r?.opacity ?? Lt.opacity, 0, 1),
|
|
169
|
+
renderVisual: r?.renderVisual ?? Lt.renderVisual,
|
|
170
|
+
maxSpeedCurve: r?.maxSpeedCurve ?? Lt.maxSpeedCurve
|
|
171
|
+
};
|
|
172
|
+
}, Ze = ({ isDragging: r, isThumbHovered: t, enableThumbDrag: e }) => Vt(() => e ? r ? "dragging" : t ? "hover" : "idle" : "disabled", [e, r, t]), Je = ({ canUseArrowButtons: r, enableArrowButtons: t, resetTapScroll: e, scrollByStep: n }) => {
|
|
173
|
+
const o = w(null), a = w(null), u = M(() => {
|
|
174
|
+
o.current !== null && (window.clearInterval(o.current), o.current = null), a.current !== null && (window.clearTimeout(a.current), a.current = null);
|
|
175
|
+
}, []), f = M(() => {
|
|
176
|
+
u();
|
|
177
|
+
}, [u]), l = M(
|
|
178
|
+
(d) => (h) => {
|
|
179
|
+
r && (h.preventDefault(), h.stopPropagation(), e(), u(), n(d), a.current = window.setTimeout(() => {
|
|
180
|
+
o.current = window.setInterval(() => {
|
|
181
|
+
n(d);
|
|
182
|
+
}, He);
|
|
183
|
+
}, Xe));
|
|
184
|
+
},
|
|
185
|
+
[r, u, e, n]
|
|
186
|
+
), c = M(
|
|
187
|
+
(d) => (h) => {
|
|
188
|
+
t && (h.key === "Enter" || h.key === " " || h.key === "Spacebar") && (h.preventDefault(), n(d));
|
|
189
|
+
},
|
|
190
|
+
[t, n]
|
|
191
|
+
);
|
|
192
|
+
return L(() => () => {
|
|
193
|
+
u();
|
|
194
|
+
}, [u]), { handleArrowPointerDown: l, handleArrowPointerUp: f, handleArrowKeyDown: c };
|
|
195
|
+
}, Qe = (r) => {
|
|
196
|
+
if (!r || r <= 0)
|
|
197
|
+
return fe;
|
|
198
|
+
const t = Math.max(1, r), e = Math.log10(t), n = fe + e * $e;
|
|
199
|
+
return pt(n, fe, We);
|
|
200
|
+
}, tn = ({
|
|
201
|
+
contentSize: r,
|
|
202
|
+
viewportSize: t,
|
|
203
|
+
scrollPosition: e,
|
|
204
|
+
onScroll: n,
|
|
205
|
+
enableThumbDrag: o = !0,
|
|
206
|
+
enableTrackClick: a = !0,
|
|
207
|
+
enableArrowButtons: u = !0,
|
|
208
|
+
horizontal: f = !1,
|
|
209
|
+
scrollBarWidth: l = 12,
|
|
210
|
+
className: c,
|
|
211
|
+
ariaControls: d,
|
|
212
|
+
tapScrollCircleOptions: h,
|
|
213
|
+
itemCount: b,
|
|
214
|
+
renderThumbOverlay: T
|
|
215
|
+
}) => {
|
|
216
|
+
const [k, _] = Yt(!1), [tt, Y] = Yt(!1), [ut, V] = Yt(!1), D = w(null), X = w({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), O = w({ pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }), R = w(e), H = w(Te), q = w(null), N = w(null), g = w(null), C = Vt(() => Ge(h, b), [b, h]), P = Vt(() => je(f), [f]), {
|
|
217
|
+
enabled: j,
|
|
218
|
+
size: rt,
|
|
219
|
+
offsetX: Ct,
|
|
220
|
+
offsetY: ot,
|
|
221
|
+
className: $,
|
|
222
|
+
maxVisualDistance: ct,
|
|
223
|
+
maxSpeedMultiplier: dt,
|
|
224
|
+
minSpeedMultiplier: A,
|
|
225
|
+
opacity: S,
|
|
226
|
+
renderVisual: v,
|
|
227
|
+
maxSpeedCurve: it
|
|
228
|
+
} = C, W = w({
|
|
229
|
+
viewportSize: t,
|
|
230
|
+
maxScrollPosition: Math.max(r - t, 0),
|
|
231
|
+
scrollBarVisible: r > t,
|
|
232
|
+
effectiveTapMaxDistance: Math.max(ct, 1),
|
|
233
|
+
tapCircleMaxSpeedMultiplier: dt,
|
|
234
|
+
tapCircleMinSpeedMultiplier: A,
|
|
235
|
+
tapCircleMaxSpeedCurve: it,
|
|
236
|
+
tapScrollCircleOptions: h
|
|
237
|
+
}), { mainSizeKey: G, crossSizeKey: ft, positionKey: et, selectDelta: st, getPointerCoordinate: nt, arrowLabels: gt, arrowIcons: mt, directionClass: xt, orientation: St } = P, Et = Math.max(ct, 1), Dt = t / r, p = l, m = Math.max(t - p * 2, 0), ht = Dt * m, Z = Math.min(Math.max(Ie, ht || 0), m || Ie), z = r - t, Rt = Math.max(m - Z, 0), It = z <= 0 || Rt <= 0 ? 0 : e / z * Rt, At = It + Z / 2, Tt = r > t, _t = Tt && u;
|
|
238
|
+
W.current = {
|
|
239
|
+
viewportSize: t,
|
|
240
|
+
maxScrollPosition: z,
|
|
241
|
+
scrollBarVisible: Tt,
|
|
242
|
+
effectiveTapMaxDistance: Et,
|
|
243
|
+
tapCircleMaxSpeedMultiplier: dt,
|
|
244
|
+
tapCircleMinSpeedMultiplier: A,
|
|
245
|
+
tapCircleMaxSpeedCurve: it,
|
|
246
|
+
tapScrollCircleOptions: h
|
|
247
|
+
}, L(() => {
|
|
248
|
+
R.current = e;
|
|
249
|
+
}, [e]), L(() => {
|
|
250
|
+
o || Y(!1);
|
|
251
|
+
}, [o]);
|
|
252
|
+
const Ut = Ze({ isDragging: k, isThumbHovered: tt, enableThumbDrag: o }), vt = M(
|
|
253
|
+
(i, x) => {
|
|
254
|
+
const E = W.current, J = x ?? R.current;
|
|
255
|
+
if (n) {
|
|
256
|
+
const kt = n(i, J);
|
|
257
|
+
if (typeof kt == "number" && Number.isFinite(kt))
|
|
258
|
+
return R.current = kt, kt;
|
|
259
|
+
}
|
|
260
|
+
const bt = typeof i == "function" ? i(J) : i, Pt = Math.max(E.maxScrollPosition, 0), Nt = E.scrollBarVisible ? pt(bt, 0, Pt) : 0;
|
|
261
|
+
return R.current = Nt, Nt;
|
|
262
|
+
},
|
|
263
|
+
[n]
|
|
264
|
+
), Ot = M(
|
|
265
|
+
(i) => {
|
|
266
|
+
const x = W.current, E = R.current;
|
|
267
|
+
if (!x.scrollBarVisible || x.maxScrollPosition <= 0) {
|
|
268
|
+
const kt = vt(0, E), ce = kt - E;
|
|
269
|
+
return { nextPosition: kt, actualDelta: ce, reachedBoundary: !0 };
|
|
270
|
+
}
|
|
271
|
+
if (i === 0)
|
|
272
|
+
return { nextPosition: E, actualDelta: 0, reachedBoundary: !1 };
|
|
273
|
+
const bt = vt((kt) => pt(kt + i, 0, x.maxScrollPosition), E), Pt = bt - E, Nt = Pt === 0 || i < 0 && bt <= 0 || i > 0 && bt >= x.maxScrollPosition;
|
|
274
|
+
return { nextPosition: bt, actualDelta: Pt, reachedBoundary: Nt };
|
|
275
|
+
},
|
|
276
|
+
[vt]
|
|
277
|
+
), at = M(() => {
|
|
278
|
+
N.current !== null && (window.cancelAnimationFrame(N.current), N.current = null), g.current = null;
|
|
279
|
+
}, []), yt = M(() => {
|
|
280
|
+
H.current = { ...Te }, V(!1), q.current?.reset(), at();
|
|
281
|
+
}, [at]), Bt = M(
|
|
282
|
+
(i) => {
|
|
283
|
+
const x = H.current, E = W.current;
|
|
284
|
+
if (!x.active || x.direction === 0) {
|
|
285
|
+
at();
|
|
204
286
|
return;
|
|
205
287
|
}
|
|
206
|
-
if (!
|
|
207
|
-
|
|
288
|
+
if (!E.scrollBarVisible || E.maxScrollPosition <= 0) {
|
|
289
|
+
at();
|
|
208
290
|
return;
|
|
209
291
|
}
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
|
|
292
|
+
const J = g.current ?? i, bt = Math.max((i - J) / 1e3, 0), Pt = Math.min(bt, Ke);
|
|
293
|
+
if (g.current = i, Pt <= 0) {
|
|
294
|
+
N.current = window.requestAnimationFrame(Bt);
|
|
213
295
|
return;
|
|
214
296
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
297
|
+
const Nt = Math.min(x.distance, E.effectiveTapMaxDistance) / E.effectiveTapMaxDistance, kt = Nt ** 1.1, ce = typeof E.tapScrollCircleOptions?.maxSpeedMultiplier == "number", Zt = Math.max(E.viewportSize * E.tapCircleMinSpeedMultiplier, 40), we = ce ? Zt : 1200;
|
|
298
|
+
let ue = Math.max(E.viewportSize * E.tapCircleMaxSpeedMultiplier, we);
|
|
299
|
+
const ne = E.tapCircleMaxSpeedCurve;
|
|
300
|
+
if (ne) {
|
|
301
|
+
const re = Math.max(ne.exponentialSteepness, 0), Fe = Math.max(ne.exponentialScale ?? E.tapCircleMaxSpeedMultiplier, 0), Ne = re === 0 ? Nt : Math.expm1(re * Nt), ge = re === 0 ? 1 : Math.expm1(re) || 1, ke = ge === 0 ? Nt : Math.min(Math.max(Ne / ge, 0), 1), Oe = E.viewportSize * Fe * ke;
|
|
302
|
+
ue = Math.min(ue, Math.max(Oe, Zt));
|
|
303
|
+
}
|
|
304
|
+
const Ce = Math.max(ue, Zt), Re = Math.max(ne?.easedOffset ?? 0, 0), Ae = Math.min(1, kt + Re), Ve = Zt + (Ce - Zt) * Ae, Ee = x.direction * Ve * Pt, { actualDelta: De, reachedBoundary: _e } = Ot(Ee);
|
|
305
|
+
if (_e || De === 0) {
|
|
306
|
+
at();
|
|
218
307
|
return;
|
|
219
308
|
}
|
|
220
|
-
|
|
309
|
+
N.current = window.requestAnimationFrame(Bt);
|
|
221
310
|
},
|
|
222
|
-
[
|
|
223
|
-
),
|
|
224
|
-
|
|
225
|
-
}, [
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}, [
|
|
229
|
-
const
|
|
230
|
-
(
|
|
231
|
-
|
|
311
|
+
[Ot, at]
|
|
312
|
+
), te = M(() => {
|
|
313
|
+
N.current === null && (g.current = null, N.current = window.requestAnimationFrame(Bt));
|
|
314
|
+
}, [Bt]);
|
|
315
|
+
L(() => () => {
|
|
316
|
+
at();
|
|
317
|
+
}, [at]);
|
|
318
|
+
const ae = M(
|
|
319
|
+
(i) => {
|
|
320
|
+
H.current = i, V(i.active), i.active && i.direction !== 0 ? te() : at();
|
|
232
321
|
},
|
|
233
|
-
[
|
|
322
|
+
[te, at]
|
|
234
323
|
);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}, [
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
324
|
+
L(() => {
|
|
325
|
+
j || yt();
|
|
326
|
+
}, [yt, j]), L(() => {
|
|
327
|
+
const i = (x) => {
|
|
328
|
+
const J = x.detail?.paneId;
|
|
329
|
+
J && d && J !== d || yt();
|
|
241
330
|
};
|
|
242
|
-
return window.addEventListener(
|
|
243
|
-
window.removeEventListener(
|
|
331
|
+
return window.addEventListener(pe, i), () => {
|
|
332
|
+
window.removeEventListener(pe, i);
|
|
244
333
|
};
|
|
245
|
-
}, [d,
|
|
246
|
-
if (!
|
|
334
|
+
}, [d, yt]), L(() => {
|
|
335
|
+
if (!j)
|
|
247
336
|
return;
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
337
|
+
const i = (x) => {
|
|
338
|
+
if (!H.current.active)
|
|
250
339
|
return;
|
|
251
|
-
const
|
|
252
|
-
if (!(
|
|
253
|
-
|
|
340
|
+
const E = x.target;
|
|
341
|
+
if (!(E instanceof Node)) {
|
|
342
|
+
yt();
|
|
254
343
|
return;
|
|
255
344
|
}
|
|
256
|
-
|
|
345
|
+
q.current?.getElement()?.contains(E) || yt();
|
|
257
346
|
};
|
|
258
|
-
return document.addEventListener("pointerdown",
|
|
259
|
-
document.removeEventListener("pointerdown",
|
|
347
|
+
return document.addEventListener("pointerdown", i, !0), () => {
|
|
348
|
+
document.removeEventListener("pointerdown", i, !0);
|
|
260
349
|
};
|
|
261
|
-
}, [
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
350
|
+
}, [yt, j]);
|
|
351
|
+
const s = (i) => {
|
|
352
|
+
if (!Tt || Rt <= 0 || z <= 0)
|
|
264
353
|
return 0;
|
|
265
|
-
const
|
|
266
|
-
return
|
|
267
|
-
},
|
|
268
|
-
|
|
354
|
+
const x = pt(i, 0, Rt);
|
|
355
|
+
return pt(x / Rt * z, 0, z);
|
|
356
|
+
}, I = (i) => {
|
|
357
|
+
const x = Math.max(Math.round(t / qe), Ue);
|
|
358
|
+
Ot(i * x);
|
|
359
|
+
}, { handleArrowPointerDown: y, handleArrowPointerUp: F, handleArrowKeyDown: B } = Je({
|
|
360
|
+
canUseArrowButtons: _t,
|
|
361
|
+
enableArrowButtons: u,
|
|
362
|
+
resetTapScroll: yt,
|
|
363
|
+
scrollByStep: I
|
|
364
|
+
}), K = (i) => {
|
|
365
|
+
if (!Tt)
|
|
269
366
|
return;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, Pe = () => {
|
|
273
|
-
Ie();
|
|
274
|
-
}, He = (s) => (v) => {
|
|
275
|
-
Ye && (v.preventDefault(), v.stopPropagation(), ue(), Ie(), Re(s), O.current = window.setTimeout(() => {
|
|
276
|
-
U.current = window.setInterval(() => {
|
|
277
|
-
Re(s);
|
|
278
|
-
}, lt);
|
|
279
|
-
}, at));
|
|
280
|
-
}, tt = (s) => (v) => {
|
|
281
|
-
l && (v.key === "Enter" || v.key === " " || v.key === "Spacebar") && (v.preventDefault(), Re(s));
|
|
282
|
-
}, $e = (s) => {
|
|
283
|
-
if (!he)
|
|
284
|
-
return;
|
|
285
|
-
if (!r) {
|
|
286
|
-
s.preventDefault(), s.stopPropagation();
|
|
367
|
+
if (!o) {
|
|
368
|
+
i.preventDefault(), i.stopPropagation();
|
|
287
369
|
return;
|
|
288
370
|
}
|
|
289
|
-
if ("
|
|
371
|
+
if (i.pointerType === "mouse" && i.button !== 0 || i.ctrlKey)
|
|
290
372
|
return;
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
);
|
|
303
|
-
}, Xe = (s) => {
|
|
304
|
-
if (!he)
|
|
373
|
+
yt();
|
|
374
|
+
const x = i.currentTarget;
|
|
375
|
+
x.setPointerCapture && x.setPointerCapture(i.pointerId), X.current = {
|
|
376
|
+
pointerId: i.pointerId,
|
|
377
|
+
startThumbPosition: It,
|
|
378
|
+
startClientX: i.clientX,
|
|
379
|
+
startClientY: i.clientY
|
|
380
|
+
}, _(!0), Y(!0), i.preventDefault(), i.stopPropagation();
|
|
381
|
+
}, Mt = (i) => {
|
|
382
|
+
const x = X.current;
|
|
383
|
+
if (x.pointerId !== i.pointerId)
|
|
305
384
|
return;
|
|
306
|
-
|
|
307
|
-
|
|
385
|
+
const E = i.clientX - x.startClientX, J = i.clientY - x.startClientY, bt = st(E, J), Pt = s(x.startThumbPosition + bt);
|
|
386
|
+
vt(Pt), i.cancelable && i.preventDefault();
|
|
387
|
+
}, zt = (i) => {
|
|
388
|
+
if (X.current.pointerId !== i.pointerId)
|
|
389
|
+
return;
|
|
390
|
+
const x = i.currentTarget;
|
|
391
|
+
x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), X.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, _(!1), D.current && !D.current.matches(":hover") && Y(!1), i.preventDefault(), i.stopPropagation();
|
|
392
|
+
}, Ft = (i) => {
|
|
393
|
+
if (X.current.pointerId !== i.pointerId)
|
|
394
|
+
return;
|
|
395
|
+
const x = i.currentTarget;
|
|
396
|
+
x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), X.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, _(!1), D.current && !D.current.matches(":hover") && Y(!1);
|
|
397
|
+
}, Xt = (i) => {
|
|
398
|
+
if (!Tt)
|
|
399
|
+
return;
|
|
400
|
+
if (!a) {
|
|
401
|
+
i.preventDefault(), i.stopPropagation();
|
|
308
402
|
return;
|
|
309
403
|
}
|
|
310
|
-
if ("
|
|
404
|
+
if (i.pointerType === "mouse" && i.button !== 0 || i.ctrlKey)
|
|
311
405
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
406
|
+
const x = i.currentTarget, E = x.getBoundingClientRect(), bt = nt(i) - (f ? E.left : E.top);
|
|
407
|
+
yt();
|
|
408
|
+
const Pt = bt - Z / 2, Nt = s(Pt);
|
|
409
|
+
vt(Nt), x.setPointerCapture && x.setPointerCapture(i.pointerId), O.current = {
|
|
410
|
+
pointerId: i.pointerId,
|
|
411
|
+
startThumbPosition: Pt,
|
|
412
|
+
startClientX: i.clientX,
|
|
413
|
+
startClientY: i.clientY
|
|
414
|
+
}, i.preventDefault(), i.stopPropagation();
|
|
415
|
+
}, $t = (i) => {
|
|
416
|
+
const x = O.current;
|
|
417
|
+
if (x.pointerId !== i.pointerId)
|
|
418
|
+
return;
|
|
419
|
+
const E = i.clientX - x.startClientX, J = i.clientY - x.startClientY, bt = st(E, J), Pt = s(x.startThumbPosition + bt);
|
|
420
|
+
vt(Pt), i.cancelable && i.preventDefault();
|
|
421
|
+
}, Ht = (i) => {
|
|
422
|
+
if (O.current.pointerId !== i.pointerId)
|
|
423
|
+
return;
|
|
424
|
+
const x = i.currentTarget;
|
|
425
|
+
x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), O.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 }, i.preventDefault(), i.stopPropagation();
|
|
426
|
+
}, Wt = (i) => {
|
|
427
|
+
if (O.current.pointerId !== i.pointerId)
|
|
428
|
+
return;
|
|
429
|
+
const x = i.currentTarget;
|
|
430
|
+
x.hasPointerCapture(i.pointerId) && x.releasePointerCapture(i.pointerId), O.current = { pointerId: null, startThumbPosition: 0, startClientX: 0, startClientY: 0 };
|
|
431
|
+
}, U = Vt(() => pt((ut ? 1 : 0.8) * S, 0, 1), [ut, S]), Kt = Vt(() => {
|
|
432
|
+
const x = `calc(50% - ${rt / 2}px + ${ot}px)`;
|
|
321
433
|
return {
|
|
322
|
-
left:
|
|
323
|
-
top:
|
|
434
|
+
left: Ct,
|
|
435
|
+
top: x
|
|
324
436
|
};
|
|
325
|
-
}, [
|
|
437
|
+
}, [Ct, ot, rt]), le = (i, x, E) => /* @__PURE__ */ Q(
|
|
326
438
|
"button",
|
|
327
439
|
{
|
|
328
440
|
type: "button",
|
|
329
|
-
|
|
441
|
+
tabIndex: -1,
|
|
442
|
+
className: "aqvs:scrollbar-arrow-button flex items-center justify-center text-xs transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
330
443
|
style: {
|
|
331
|
-
[
|
|
332
|
-
[
|
|
333
|
-
backgroundColor: "#E0E0E0"
|
|
444
|
+
[G]: p,
|
|
445
|
+
[ft]: l
|
|
334
446
|
},
|
|
335
|
-
"aria-label":
|
|
336
|
-
onMouseDown:
|
|
337
|
-
onTouchStart:
|
|
338
|
-
onMouseUp:
|
|
339
|
-
onMouseLeave:
|
|
340
|
-
onTouchEnd:
|
|
341
|
-
onTouchCancel:
|
|
342
|
-
onKeyDown:
|
|
343
|
-
"aria-disabled": !
|
|
344
|
-
disabled: !
|
|
345
|
-
children: /* @__PURE__ */
|
|
447
|
+
"aria-label": x,
|
|
448
|
+
onMouseDown: y(i),
|
|
449
|
+
onTouchStart: y(i),
|
|
450
|
+
onMouseUp: F,
|
|
451
|
+
onMouseLeave: F,
|
|
452
|
+
onTouchEnd: F,
|
|
453
|
+
onTouchCancel: F,
|
|
454
|
+
onKeyDown: B(i),
|
|
455
|
+
"aria-disabled": !u,
|
|
456
|
+
disabled: !_t,
|
|
457
|
+
children: /* @__PURE__ */ Q("span", { "aria-hidden": "true", children: E })
|
|
346
458
|
}
|
|
347
|
-
)
|
|
348
|
-
|
|
459
|
+
), ee = T && Tt ? {
|
|
460
|
+
orientation: St,
|
|
461
|
+
scrollPosition: e,
|
|
462
|
+
maxScrollPosition: z,
|
|
463
|
+
contentSize: r,
|
|
464
|
+
viewportSize: t,
|
|
465
|
+
thumbSize: Z,
|
|
466
|
+
thumbPosition: It,
|
|
467
|
+
thumbCenter: At,
|
|
468
|
+
trackSize: m,
|
|
469
|
+
isDragging: k,
|
|
470
|
+
isTapScrollActive: ut
|
|
471
|
+
} : null;
|
|
472
|
+
return /* @__PURE__ */ Gt(
|
|
349
473
|
"div",
|
|
350
474
|
{
|
|
351
|
-
className:
|
|
352
|
-
"group relative cursor-default select-none",
|
|
353
|
-
ne,
|
|
354
|
-
u
|
|
355
|
-
),
|
|
475
|
+
className: jt("group relative cursor-default select-none", xt, c),
|
|
356
476
|
style: {
|
|
357
|
-
[
|
|
358
|
-
[
|
|
477
|
+
[G]: t,
|
|
478
|
+
[ft]: l,
|
|
359
479
|
backgroundColor: "white",
|
|
360
480
|
userSelect: "none",
|
|
361
|
-
position: "relative"
|
|
481
|
+
position: "relative",
|
|
482
|
+
touchAction: "none"
|
|
362
483
|
},
|
|
363
484
|
role: "scrollbar",
|
|
364
485
|
tabIndex: -1,
|
|
365
486
|
"aria-controls": d,
|
|
366
|
-
"aria-valuenow":
|
|
487
|
+
"aria-valuenow": e,
|
|
367
488
|
"aria-valuemin": 0,
|
|
368
489
|
"aria-valuemax": z,
|
|
369
|
-
"aria-orientation":
|
|
490
|
+
"aria-orientation": f ? "horizontal" : "vertical",
|
|
370
491
|
children: [
|
|
371
|
-
!
|
|
372
|
-
|
|
492
|
+
!f && Tt && j && /* @__PURE__ */ Q(
|
|
493
|
+
Me,
|
|
373
494
|
{
|
|
374
|
-
ref:
|
|
375
|
-
className:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
opacity: nt,
|
|
383
|
-
renderVisual: y,
|
|
384
|
-
onDragChange: et
|
|
495
|
+
ref: q,
|
|
496
|
+
className: jt("pointer-events-auto absolute transition-opacity duration-150", $),
|
|
497
|
+
size: rt,
|
|
498
|
+
maxVisualDistance: Et,
|
|
499
|
+
style: Kt,
|
|
500
|
+
opacity: U,
|
|
501
|
+
renderVisual: v,
|
|
502
|
+
onDragChange: ae
|
|
385
503
|
}
|
|
386
504
|
),
|
|
387
|
-
|
|
388
|
-
/* @__PURE__ */
|
|
505
|
+
le(-1, gt[0], mt[0]),
|
|
506
|
+
/* @__PURE__ */ Gt(
|
|
389
507
|
"div",
|
|
390
508
|
{
|
|
391
|
-
className: "relative flex-1",
|
|
509
|
+
className: "aqvs:scrollbar-track relative flex-1",
|
|
392
510
|
style: {
|
|
393
|
-
|
|
394
|
-
|
|
511
|
+
borderRadius: l / 2,
|
|
512
|
+
touchAction: "none"
|
|
395
513
|
},
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
{
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
"
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
514
|
+
onPointerDown: Xt,
|
|
515
|
+
onPointerMove: $t,
|
|
516
|
+
onPointerUp: Ht,
|
|
517
|
+
onPointerCancel: Wt,
|
|
518
|
+
"aria-disabled": !a,
|
|
519
|
+
children: [
|
|
520
|
+
ee && /* @__PURE__ */ Q("div", { className: "pointer-events-none absolute inset-0", "aria-hidden": !0, children: T?.(ee) }),
|
|
521
|
+
Tt && // スクロールバーのつまみの当たり判定を広げるためのラッパー
|
|
522
|
+
/* @__PURE__ */ Q(
|
|
523
|
+
"div",
|
|
524
|
+
{
|
|
525
|
+
className: "group absolute",
|
|
526
|
+
style: {
|
|
527
|
+
[G]: Z,
|
|
528
|
+
[et]: It,
|
|
529
|
+
...f ? { top: 0, bottom: 0 } : { left: 0, right: 0 },
|
|
530
|
+
touchAction: "none"
|
|
531
|
+
},
|
|
532
|
+
onPointerDown: K,
|
|
533
|
+
onPointerMove: Mt,
|
|
534
|
+
onPointerUp: zt,
|
|
535
|
+
onPointerCancel: Ft,
|
|
536
|
+
role: "slider",
|
|
537
|
+
"aria-orientation": f ? "horizontal" : "vertical",
|
|
538
|
+
"aria-valuenow": e,
|
|
539
|
+
"aria-valuemin": 0,
|
|
540
|
+
"aria-valuemax": z,
|
|
541
|
+
"aria-disabled": !o,
|
|
542
|
+
tabIndex: -1,
|
|
543
|
+
children: /* @__PURE__ */ Q(
|
|
544
|
+
"div",
|
|
545
|
+
{
|
|
546
|
+
ref: D,
|
|
547
|
+
className: jt("aqvs:scrollbar-thumb absolute", f ? "aqvs:scrollbar-thumb-horizontal" : "aqvs:scrollbar-thumb-vertical"),
|
|
548
|
+
"data-thumb-state": Ut,
|
|
549
|
+
style: {
|
|
550
|
+
borderRadius: l - 1,
|
|
551
|
+
cursor: o ? "pointer" : "default"
|
|
552
|
+
},
|
|
553
|
+
onMouseEnter: () => {
|
|
554
|
+
o && Y(!0);
|
|
555
|
+
},
|
|
556
|
+
onMouseLeave: () => {
|
|
557
|
+
o && Y(!1);
|
|
440
558
|
}
|
|
441
|
-
},
|
|
442
|
-
onMouseEnter: () => {
|
|
443
|
-
r && b(!0);
|
|
444
|
-
},
|
|
445
|
-
onMouseLeave: () => {
|
|
446
|
-
r && b(!1);
|
|
447
559
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
]
|
|
452
564
|
}
|
|
453
565
|
),
|
|
454
|
-
|
|
566
|
+
le(1, gt[1], mt[1])
|
|
455
567
|
]
|
|
456
568
|
}
|
|
457
569
|
);
|
|
458
|
-
},
|
|
459
|
-
debug(
|
|
460
|
-
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${
|
|
570
|
+
}, wt = {
|
|
571
|
+
debug(r, ...t) {
|
|
572
|
+
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${r}`, ...t);
|
|
461
573
|
},
|
|
462
|
-
warn(
|
|
463
|
-
console.warn(`[VirtualScroll] ${
|
|
574
|
+
warn(r, ...t) {
|
|
575
|
+
console.warn(`[VirtualScroll] ${r}`, ...t);
|
|
464
576
|
},
|
|
465
|
-
error(
|
|
466
|
-
console.error(`[VirtualScroll] ${
|
|
577
|
+
error(r, ...t) {
|
|
578
|
+
console.error(`[VirtualScroll] ${r}`, ...t);
|
|
467
579
|
}
|
|
468
|
-
},
|
|
580
|
+
}, Jt = {
|
|
469
581
|
maxVelocity: 6,
|
|
470
582
|
minVelocity: 0.02,
|
|
471
583
|
deceleration: 25e-4,
|
|
472
584
|
velocitySampleWindow: 90,
|
|
473
585
|
startVelocityThreshold: 0.04
|
|
474
|
-
},
|
|
475
|
-
for (const [n,
|
|
476
|
-
|
|
477
|
-
},
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
586
|
+
}, oe = (r, t, e) => {
|
|
587
|
+
for (const [n, o, a] of t)
|
|
588
|
+
e === "add" ? r.addEventListener(n, o, a) : r.removeEventListener(n, o, a);
|
|
589
|
+
}, en = me(
|
|
590
|
+
({
|
|
591
|
+
children: r,
|
|
592
|
+
contentSize: t,
|
|
593
|
+
viewportSize: e,
|
|
594
|
+
scrollBarWidth: n = 12,
|
|
595
|
+
enableThumbDrag: o = !0,
|
|
596
|
+
enableTrackClick: a = !0,
|
|
597
|
+
enableArrowButtons: u = !0,
|
|
598
|
+
enablePointerDrag: f = !0,
|
|
599
|
+
onScroll: l,
|
|
600
|
+
className: c,
|
|
601
|
+
style: d,
|
|
602
|
+
background: h,
|
|
603
|
+
tapScrollCircleOptions: b,
|
|
604
|
+
inertiaOptions: T,
|
|
605
|
+
itemCount: k,
|
|
606
|
+
renderThumbOverlay: _,
|
|
607
|
+
wheelSpeedMultiplier: tt = 1,
|
|
608
|
+
contentInsets: Y
|
|
609
|
+
}, ut) => {
|
|
610
|
+
const V = w(0), D = w(null), X = w(null), O = w({
|
|
611
|
+
frame: null,
|
|
612
|
+
velocity: 0,
|
|
613
|
+
lastTimestamp: null
|
|
614
|
+
}), R = Vt(
|
|
615
|
+
() => ({
|
|
616
|
+
maxVelocity: T?.maxVelocity ?? Jt.maxVelocity,
|
|
617
|
+
minVelocity: T?.minVelocity ?? Jt.minVelocity,
|
|
618
|
+
deceleration: T?.deceleration ?? Jt.deceleration,
|
|
619
|
+
velocitySampleWindow: T?.velocitySampleWindow ?? Jt.velocitySampleWindow,
|
|
620
|
+
startVelocityThreshold: T?.startVelocityThreshold ?? Jt.startVelocityThreshold
|
|
621
|
+
}),
|
|
622
|
+
[T]
|
|
623
|
+
), H = Vt(() => ({
|
|
624
|
+
top: Math.max(0, Y?.top ?? 0),
|
|
625
|
+
bottom: Math.max(0, Y?.bottom ?? 0)
|
|
626
|
+
}), [Y]);
|
|
627
|
+
wt.debug("[ScrollPane] ScrollPane rendered", {
|
|
628
|
+
contentSize: t,
|
|
629
|
+
viewportSize: e,
|
|
630
|
+
scrollBarWidth: n,
|
|
631
|
+
className: c,
|
|
632
|
+
style: d,
|
|
633
|
+
tapScrollCircleOptions: b,
|
|
634
|
+
inertiaOptions: T,
|
|
635
|
+
enablePointerDrag: f,
|
|
636
|
+
contentInsets: H
|
|
637
|
+
});
|
|
638
|
+
const q = w({ contentSize: t, viewportSize: e }), N = Vt(() => t > e, [t, e]), g = M(
|
|
639
|
+
(S) => {
|
|
640
|
+
const { contentSize: v, viewportSize: it } = q.current, W = v > it, G = V.current;
|
|
641
|
+
if (wt.debug("[ScrollPane] scrollTo called", { newPosition: S, contentSize: v, viewportSize: it, currentIsScrollable: W, prevPosition: G }), !W)
|
|
642
|
+
return V.current !== 0 && (V.current = 0, l?.(0, G)), V.current;
|
|
643
|
+
const ft = typeof S == "function" ? S(V.current) : S, et = Math.max(v - it, 0), st = pt(ft, 0, et);
|
|
644
|
+
return V.current !== st && (V.current = st, l?.(st, G)), V.current;
|
|
645
|
+
},
|
|
646
|
+
[l]
|
|
647
|
+
), C = M(() => {
|
|
648
|
+
const S = O.current;
|
|
649
|
+
S.frame !== null && cancelAnimationFrame(S.frame), S.frame = null, S.velocity = 0, S.lastTimestamp = null;
|
|
650
|
+
}, []), P = w(C);
|
|
651
|
+
L(() => {
|
|
652
|
+
P.current = C;
|
|
653
|
+
}, [C]);
|
|
654
|
+
const j = M(
|
|
655
|
+
(S) => {
|
|
656
|
+
if (!N)
|
|
657
|
+
return;
|
|
658
|
+
const { maxVelocity: v, minVelocity: it, deceleration: W, startVelocityThreshold: G } = R, ft = pt(S, -v, v);
|
|
659
|
+
if (Math.abs(ft) < G)
|
|
660
|
+
return;
|
|
661
|
+
C(), O.current.velocity = ft, O.current.lastTimestamp = null;
|
|
662
|
+
const et = (st) => {
|
|
663
|
+
const nt = O.current;
|
|
664
|
+
if (nt.lastTimestamp === null) {
|
|
665
|
+
nt.lastTimestamp = st, nt.frame = requestAnimationFrame(et);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
const gt = st - nt.lastTimestamp;
|
|
669
|
+
if (nt.lastTimestamp = st, gt <= 0) {
|
|
670
|
+
nt.frame = requestAnimationFrame(et);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const mt = nt.velocity;
|
|
674
|
+
let xt = mt;
|
|
675
|
+
const St = W * gt;
|
|
676
|
+
mt > 0 ? xt = Math.max(0, mt - St) : mt < 0 && (xt = Math.min(0, mt + St));
|
|
677
|
+
const Dt = (mt + xt) / 2 * gt, p = V.current;
|
|
678
|
+
Dt !== 0 && g((It) => It + Dt);
|
|
679
|
+
const m = V.current, { contentSize: ht, viewportSize: Z } = q.current, z = Math.max(ht - Z, 0);
|
|
680
|
+
nt.velocity = xt;
|
|
681
|
+
const Rt = m === p || m <= 0 && xt <= 0 || m >= z && xt >= 0;
|
|
682
|
+
if (Math.abs(xt) < it || Rt) {
|
|
683
|
+
C();
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
nt.frame = requestAnimationFrame(et);
|
|
687
|
+
};
|
|
688
|
+
O.current.frame = requestAnimationFrame(et);
|
|
689
|
+
},
|
|
690
|
+
[N, R, g, C]
|
|
691
|
+
), rt = w(j);
|
|
692
|
+
L(() => {
|
|
693
|
+
rt.current = j;
|
|
694
|
+
}, [j]), se(() => {
|
|
695
|
+
q.current = { contentSize: t, viewportSize: e };
|
|
696
|
+
}, [t, e]), se(() => {
|
|
697
|
+
if (N) {
|
|
698
|
+
wt.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: t, viewportSize: e, scrollPosition: V.current });
|
|
699
|
+
const S = pt(t - e, 0, t);
|
|
700
|
+
V.current > S && g(S);
|
|
701
|
+
} else
|
|
702
|
+
g(0);
|
|
703
|
+
}, [N, g, t, e]), L(() => {
|
|
704
|
+
const S = (it) => {
|
|
705
|
+
if (!N)
|
|
706
|
+
return;
|
|
707
|
+
it.preventDefault(), C();
|
|
708
|
+
let W = it.deltaY;
|
|
709
|
+
it.deltaMode === 1 ? W *= 16 : it.deltaMode === 2 && (W *= e), tt !== 1 && (W *= tt), wt.debug("[ScrollPane] wheel event", { deltaY: W, scrollPosition: V.current, wheelSpeedMultiplier: tt }), g((G) => G + W);
|
|
710
|
+
}, v = D.current;
|
|
711
|
+
return v && v.addEventListener("wheel", S, { passive: !1 }), () => {
|
|
712
|
+
v && v.removeEventListener("wheel", S);
|
|
713
|
+
};
|
|
714
|
+
}, [N, g, C, e, tt]), he(
|
|
715
|
+
ut,
|
|
716
|
+
() => ({
|
|
717
|
+
scrollTo: g,
|
|
718
|
+
getScrollPosition: () => V.current,
|
|
719
|
+
getContentSize: () => t,
|
|
720
|
+
getViewportSize: () => e
|
|
721
|
+
}),
|
|
722
|
+
[g, t, e]
|
|
723
|
+
);
|
|
724
|
+
const Ct = w(g);
|
|
725
|
+
L(() => {
|
|
726
|
+
Ct.current = g;
|
|
727
|
+
}, [g]);
|
|
728
|
+
const ot = Le(), $ = w({
|
|
729
|
+
pointerId: null,
|
|
730
|
+
startClientY: 0,
|
|
731
|
+
startScroll: 0,
|
|
732
|
+
isDragging: !1,
|
|
733
|
+
shouldCancelNextClick: !1,
|
|
734
|
+
clickResetTimer: null,
|
|
735
|
+
velocitySamples: []
|
|
736
|
+
}), ct = w(f);
|
|
737
|
+
L(() => {
|
|
738
|
+
ct.current = f;
|
|
739
|
+
}, [f]);
|
|
740
|
+
const dt = w(N);
|
|
741
|
+
L(() => {
|
|
742
|
+
dt.current = N;
|
|
743
|
+
}, [N]);
|
|
744
|
+
const A = w(R);
|
|
745
|
+
return L(() => {
|
|
746
|
+
A.current = R;
|
|
747
|
+
}, [R]), L(() => {
|
|
748
|
+
if (f)
|
|
510
749
|
return;
|
|
511
|
-
const
|
|
512
|
-
|
|
750
|
+
const S = X.current, v = $.current;
|
|
751
|
+
v.pointerId !== null && S && S.hasPointerCapture(v.pointerId) && S.releasePointerCapture(v.pointerId), v.clickResetTimer !== null && (window.clearTimeout(v.clickResetTimer), v.clickResetTimer = null), v.pointerId = null, v.startClientY = 0, v.startScroll = 0, v.isDragging = !1, v.shouldCancelNextClick = !1, v.velocitySamples = [];
|
|
752
|
+
}, [f]), L(() => {
|
|
753
|
+
const S = X.current;
|
|
754
|
+
if (!S)
|
|
513
755
|
return;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
756
|
+
const v = 6, it = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), W = () => {
|
|
757
|
+
const p = $.current;
|
|
758
|
+
p.pointerId = null, p.startClientY = 0, p.startScroll = 0, p.isDragging = !1, p.velocitySamples = [];
|
|
759
|
+
}, G = () => {
|
|
760
|
+
const p = $.current;
|
|
761
|
+
p.clickResetTimer !== null && (window.clearTimeout(p.clickResetTimer), p.clickResetTimer = null);
|
|
762
|
+
}, ft = (p) => {
|
|
763
|
+
const m = $.current, ht = it();
|
|
764
|
+
m.velocitySamples.push({ clientY: p, time: ht });
|
|
765
|
+
const Z = A.current.velocitySampleWindow;
|
|
766
|
+
m.velocitySamples = m.velocitySamples.filter((z) => ht - z.time <= Z);
|
|
767
|
+
}, et = (p) => p instanceof HTMLElement && p.closest("[data-scrollpane-ignore-drag='true']") !== null, st = (p) => {
|
|
768
|
+
const m = $.current;
|
|
769
|
+
m.shouldCancelNextClick && (p.preventDefault(), p.stopPropagation(), m.shouldCancelNextClick = !1);
|
|
770
|
+
}, nt = (p) => {
|
|
771
|
+
const m = $.current;
|
|
772
|
+
m.isDragging || (m.isDragging = !0, m.shouldCancelNextClick = !0, S.hasPointerCapture(p.pointerId) || S.setPointerCapture(p.pointerId), ft(p.clientY));
|
|
773
|
+
}, gt = (p) => {
|
|
774
|
+
const m = $.current;
|
|
775
|
+
if (m.pointerId !== p.pointerId || !(ct.current && dt.current) || !m.isDragging && (Math.abs(p.clientY - m.startClientY) < v || (nt(p), !m.isDragging)))
|
|
519
776
|
return;
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
777
|
+
ft(p.clientY);
|
|
778
|
+
const ht = p.clientY - m.startClientY, Z = m.startScroll - ht;
|
|
779
|
+
Ct.current(Z), p.cancelable && p.preventDefault();
|
|
780
|
+
}, mt = (p) => {
|
|
781
|
+
const m = $.current;
|
|
782
|
+
if (m.pointerId !== p.pointerId)
|
|
524
783
|
return;
|
|
784
|
+
m.isDragging && m.shouldCancelNextClick && p.cancelable && (p.preventDefault(), p.stopPropagation()), S.hasPointerCapture(p.pointerId) && S.releasePointerCapture(p.pointerId);
|
|
785
|
+
let ht = 0;
|
|
786
|
+
if (m.isDragging && m.velocitySamples.length >= 2) {
|
|
787
|
+
const z = m.velocitySamples, Rt = A.current.velocitySampleWindow, It = z[z.length - 1], At = z.find((Tt) => It.time - Tt.time <= Rt) ?? z[0];
|
|
788
|
+
if (It && At && It.time !== At.time) {
|
|
789
|
+
const Tt = It.clientY - At.clientY, _t = It.time - At.time;
|
|
790
|
+
ht = -(Tt / _t);
|
|
791
|
+
}
|
|
525
792
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
const c = ne === W || ne <= 0 && E <= 0 || ne >= Y && E >= 0;
|
|
535
|
-
if (Math.abs(E) < g || c) {
|
|
536
|
-
H();
|
|
793
|
+
G(), m.shouldCancelNextClick && (m.clickResetTimer = window.setTimeout(() => {
|
|
794
|
+
const z = $.current;
|
|
795
|
+
z.shouldCancelNextClick = !1, z.clickResetTimer = null;
|
|
796
|
+
}, 0));
|
|
797
|
+
const Z = A.current.startVelocityThreshold;
|
|
798
|
+
W(), Math.abs(ht) >= Z && rt.current?.(ht);
|
|
799
|
+
}, xt = (p) => {
|
|
800
|
+
if (!(ct.current && dt.current) || p.button !== 0 && p.pointerType === "mouse" || p.ctrlKey || p.metaKey || p.altKey || et(p.target))
|
|
537
801
|
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
802
|
+
window.dispatchEvent(new CustomEvent(pe, { detail: { paneId: ot } })), P.current?.();
|
|
803
|
+
const m = $.current;
|
|
804
|
+
G(), m.pointerId = p.pointerId, m.startClientY = p.clientY, m.startScroll = V.current, m.isDragging = !1, m.shouldCancelNextClick = !1, m.velocitySamples = [];
|
|
805
|
+
}, St = (p) => {
|
|
806
|
+
const m = $.current;
|
|
807
|
+
m.pointerId === p.pointerId && (m.shouldCancelNextClick = !1, S.hasPointerCapture(p.pointerId) && S.releasePointerCapture(p.pointerId), G(), W());
|
|
808
|
+
}, Et = [
|
|
809
|
+
["click", st, !0],
|
|
810
|
+
["pointerdown", xt, { passive: !1 }],
|
|
811
|
+
["pointermove", gt, { passive: !1 }],
|
|
812
|
+
["pointerup", mt, void 0],
|
|
813
|
+
["pointercancel", St, void 0]
|
|
814
|
+
], Dt = [
|
|
815
|
+
["pointermove", gt, { passive: !1 }],
|
|
816
|
+
["pointerup", mt, void 0],
|
|
817
|
+
["pointercancel", St, void 0]
|
|
818
|
+
];
|
|
819
|
+
return oe(S, Et, "add"), oe(window, Dt, "add"), () => {
|
|
820
|
+
oe(S, Et, "remove"), oe(window, Dt, "remove");
|
|
821
|
+
const p = $.current;
|
|
822
|
+
p.pointerId !== null && S.hasPointerCapture(p.pointerId) && S.releasePointerCapture(p.pointerId), G(), W();
|
|
540
823
|
};
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
g.preventDefault(), H();
|
|
559
|
-
let N = g.deltaY;
|
|
560
|
-
g.deltaMode === 1 ? N *= 16 : g.deltaMode === 2 && (N *= t), re.debug("[ScrollPane] wheel event", { deltaY: N, scrollPosition: b.current }), w((L) => L + N);
|
|
561
|
-
}, F = Z.current;
|
|
562
|
-
return F && F.addEventListener("wheel", f, { passive: !1 }), () => {
|
|
563
|
-
F && F.removeEventListener("wheel", f);
|
|
564
|
-
};
|
|
565
|
-
}, [P, w, H, t]), Oe(
|
|
566
|
-
ee,
|
|
567
|
-
() => ({
|
|
568
|
-
scrollTo: w,
|
|
569
|
-
getScrollPosition: () => b.current,
|
|
570
|
-
getContentSize: () => e,
|
|
571
|
-
getViewportSize: () => t
|
|
572
|
-
}),
|
|
573
|
-
[w, e, t]
|
|
574
|
-
);
|
|
575
|
-
const D = ot();
|
|
576
|
-
return se(() => {
|
|
577
|
-
const f = _.current;
|
|
578
|
-
if (!f)
|
|
579
|
-
return;
|
|
580
|
-
if (!a) {
|
|
581
|
-
H();
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const F = 6;
|
|
585
|
-
let g = null, N = 0, L = 0, C = !1, M = !1, y = null, I = [];
|
|
586
|
-
const T = () => {
|
|
587
|
-
g = null, N = 0, L = 0, C = !1, I = [];
|
|
588
|
-
}, S = (c) => {
|
|
589
|
-
const J = performance.now();
|
|
590
|
-
I.push({ clientY: c, time: J }), I = I.filter((Q) => J - Q.time <= O.velocitySampleWindow);
|
|
591
|
-
}, E = (c) => c instanceof HTMLElement && c.closest("[data-scrollpane-ignore-drag='true']") !== null, q = (c) => {
|
|
592
|
-
M && (c.preventDefault(), c.stopPropagation(), M = !1);
|
|
593
|
-
}, oe = (c) => {
|
|
594
|
-
C || (C = !0, M = !0, f.hasPointerCapture(c.pointerId) || f.setPointerCapture(c.pointerId), S(c.clientY));
|
|
595
|
-
}, j = (c) => {
|
|
596
|
-
if (g !== c.pointerId || !C && (Math.abs(c.clientY - N) < F || (oe(c), !C)))
|
|
597
|
-
return;
|
|
598
|
-
S(c.clientY);
|
|
599
|
-
const J = c.clientY - N, Q = L - J;
|
|
600
|
-
w(Q), c.cancelable && c.preventDefault();
|
|
601
|
-
}, W = (c) => {
|
|
602
|
-
if (g !== c.pointerId)
|
|
603
|
-
return;
|
|
604
|
-
C && M && c.cancelable && (c.preventDefault(), c.stopPropagation()), f.hasPointerCapture(c.pointerId) && f.releasePointerCapture(c.pointerId);
|
|
605
|
-
let J = 0;
|
|
606
|
-
if (C && I.length >= 2) {
|
|
607
|
-
const Q = I[I.length - 1], z = I.find((ie) => Q.time - ie.time <= O.velocitySampleWindow) ?? I[0];
|
|
608
|
-
if (Q && z && Q.time !== z.time) {
|
|
609
|
-
const ie = Q.clientY - z.clientY, ge = Q.time - z.time;
|
|
610
|
-
J = -(ie / ge);
|
|
824
|
+
}, [ot]), /* @__PURE__ */ Gt("div", { ref: D, className: jt("flex", c), style: d, children: [
|
|
825
|
+
/* @__PURE__ */ Gt(
|
|
826
|
+
"div",
|
|
827
|
+
{
|
|
828
|
+
ref: X,
|
|
829
|
+
className: jt("relative h-full flex-1 overflow-hidden"),
|
|
830
|
+
style: {
|
|
831
|
+
height: e,
|
|
832
|
+
paddingTop: H.top,
|
|
833
|
+
paddingBottom: H.bottom,
|
|
834
|
+
...f ? { touchAction: "none" } : {}
|
|
835
|
+
},
|
|
836
|
+
id: ot,
|
|
837
|
+
children: [
|
|
838
|
+
h,
|
|
839
|
+
r(V.current)
|
|
840
|
+
]
|
|
611
841
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
];
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
/* @__PURE__ */
|
|
636
|
-
"div",
|
|
637
|
-
{
|
|
638
|
-
ref: _,
|
|
639
|
-
className: "relative h-full flex-1 overflow-hidden",
|
|
640
|
-
style: { height: t, ...a ? { touchAction: "none" } : {} },
|
|
641
|
-
id: D,
|
|
642
|
-
children: [
|
|
643
|
-
p,
|
|
644
|
-
o(b.current)
|
|
645
|
-
]
|
|
646
|
-
}
|
|
647
|
-
),
|
|
648
|
-
P && /* @__PURE__ */ $(
|
|
649
|
-
pt,
|
|
650
|
-
{
|
|
651
|
-
contentSize: e,
|
|
652
|
-
viewportSize: t,
|
|
653
|
-
scrollPosition: b.current,
|
|
654
|
-
onScroll: w,
|
|
655
|
-
enableThumbDrag: r,
|
|
656
|
-
enableTrackClick: i,
|
|
657
|
-
enableArrowButtons: l,
|
|
658
|
-
scrollBarWidth: n,
|
|
659
|
-
ariaControls: D,
|
|
660
|
-
tapScrollCircleOptions: R,
|
|
661
|
-
itemCount: X
|
|
662
|
-
}
|
|
663
|
-
)
|
|
664
|
-
] });
|
|
665
|
-
}), Ge = (o, e, t) => Math.min(Math.max(o, e), t), Mt = ({ dragState: o, normalizedDistance: e, sizeScale: t, size: n }) => {
|
|
666
|
-
const r = Math.max(n / 2, 1), i = 1 + e * 0.65, l = Math.max(0.65, 1 - e * 0.25), a = o.direction * e * 26 * t, h = 0.8 + e * 0.18, u = 3 * t, d = 6 * t, p = 22 * t, R = Math.abs(a) + d, V = a > 0 ? u : -Math.abs(a) - u, X = Math.max(2.5, 3 * t), ee = Ge(o.offsetX, -r, r), b = Ge(o.offsetY, -r, r), ae = r * 0.35, le = ee / r * ae, Z = b / r * ae, _ = le * 0.45, U = Z * 0.45, O = Math.max(p * 0.38, 6), x = 0.65 + e * 0.2, P = o.active;
|
|
667
|
-
return /* @__PURE__ */ Se(Je, { children: [
|
|
668
|
-
/* @__PURE__ */ $(
|
|
842
|
+
),
|
|
843
|
+
N && /* @__PURE__ */ Q(
|
|
844
|
+
tn,
|
|
845
|
+
{
|
|
846
|
+
contentSize: t,
|
|
847
|
+
viewportSize: e,
|
|
848
|
+
scrollPosition: V.current,
|
|
849
|
+
onScroll: g,
|
|
850
|
+
enableThumbDrag: o,
|
|
851
|
+
enableTrackClick: a,
|
|
852
|
+
enableArrowButtons: u,
|
|
853
|
+
scrollBarWidth: n,
|
|
854
|
+
ariaControls: ot,
|
|
855
|
+
tapScrollCircleOptions: b,
|
|
856
|
+
itemCount: k,
|
|
857
|
+
renderThumbOverlay: _
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
] });
|
|
861
|
+
}
|
|
862
|
+
), be = (r, t, e) => Math.min(Math.max(r, t), e), In = ({ dragState: r, normalizedDistance: t, sizeScale: e, size: n }) => {
|
|
863
|
+
const o = Math.max(n / 2, 1), a = 1 + t * 0.65, u = Math.max(0.65, 1 - t * 0.25), f = r.direction * t * 26 * e, l = 0.8 + t * 0.18, c = 3 * e, d = 6 * e, h = 22 * e, b = Math.abs(f) + d, T = f > 0 ? c : -Math.abs(f) - c, k = Math.max(2.5, 3 * e), _ = be(r.offsetX, -o, o), tt = be(r.offsetY, -o, o), Y = o * 0.35, ut = _ / o * Y, V = tt / o * Y, D = ut * 0.45, X = V * 0.45, O = Math.max(h * 0.38, 6), R = 0.65 + t * 0.2, H = r.active;
|
|
864
|
+
return /* @__PURE__ */ Gt(ye, { children: [
|
|
865
|
+
/* @__PURE__ */ Q(
|
|
669
866
|
"div",
|
|
670
867
|
{
|
|
671
|
-
className: "absolute inset-0 rounded-full border border-white/40
|
|
868
|
+
className: "aqvs:tap-scroll-circle-gradient absolute inset-0 rounded-full border border-white/40 shadow-md",
|
|
672
869
|
style: {
|
|
673
|
-
transform: `scale(${
|
|
674
|
-
transition:
|
|
870
|
+
transform: `scale(${u}, ${a})`,
|
|
871
|
+
transition: H ? "40ms transform ease-out" : "200ms ease transform"
|
|
675
872
|
}
|
|
676
873
|
}
|
|
677
874
|
),
|
|
678
|
-
/* @__PURE__ */
|
|
875
|
+
/* @__PURE__ */ Q(
|
|
679
876
|
"div",
|
|
680
877
|
{
|
|
681
878
|
className: "absolute top-1/2 left-1/2 rounded-full border border-white/50 bg-white/85",
|
|
682
879
|
style: {
|
|
683
|
-
width:
|
|
684
|
-
height:
|
|
685
|
-
transform: `translate(calc(-50% + ${
|
|
686
|
-
transition:
|
|
880
|
+
width: h,
|
|
881
|
+
height: h,
|
|
882
|
+
transform: `translate(calc(-50% + ${ut}px), calc(-50% + ${V}px)) scale(${u}, ${l * a})`,
|
|
883
|
+
transition: H ? "70ms transform ease-out" : "200ms ease transform"
|
|
687
884
|
}
|
|
688
885
|
}
|
|
689
886
|
),
|
|
690
|
-
/* @__PURE__ */
|
|
887
|
+
/* @__PURE__ */ Q(
|
|
691
888
|
"div",
|
|
692
889
|
{
|
|
693
890
|
className: "absolute top-1/2 left-1/2 rounded-full bg-white/80",
|
|
694
891
|
style: {
|
|
695
892
|
width: O,
|
|
696
893
|
height: O,
|
|
697
|
-
transform: `translate(calc(-50% + ${
|
|
698
|
-
opacity:
|
|
894
|
+
transform: `translate(calc(-50% + ${D}px), calc(-50% + ${X}px)) scale(${u}, ${a})`,
|
|
895
|
+
opacity: R,
|
|
699
896
|
boxShadow: "0 0 8px rgba(255,255,255,0.45)",
|
|
700
|
-
transition:
|
|
897
|
+
transition: H ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
|
|
701
898
|
}
|
|
702
899
|
}
|
|
703
900
|
),
|
|
704
|
-
/* @__PURE__ */
|
|
901
|
+
/* @__PURE__ */ Q(
|
|
705
902
|
"div",
|
|
706
903
|
{
|
|
707
904
|
className: "absolute top-1/2 left-1/2 rounded-full bg-white/50",
|
|
708
905
|
style: {
|
|
709
|
-
width:
|
|
710
|
-
height:
|
|
711
|
-
transform: `translate(-50%, ${
|
|
712
|
-
opacity:
|
|
713
|
-
transition:
|
|
906
|
+
width: k,
|
|
907
|
+
height: b,
|
|
908
|
+
transform: `translate(-50%, ${T}px)`,
|
|
909
|
+
opacity: t,
|
|
910
|
+
transition: H ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
|
|
714
911
|
}
|
|
715
912
|
}
|
|
716
913
|
)
|
|
717
914
|
] });
|
|
915
|
+
}, nn = (r) => {
|
|
916
|
+
if (!Number.isFinite(r))
|
|
917
|
+
return 0n;
|
|
918
|
+
const t = Math.trunc(r);
|
|
919
|
+
return t <= 0 ? 0n : BigInt(t);
|
|
920
|
+
}, ie = (r) => {
|
|
921
|
+
if (r <= 0 || !Number.isFinite(r))
|
|
922
|
+
return 0;
|
|
923
|
+
const t = Math.trunc(r), e = BigInt(t) & -BigInt(t);
|
|
924
|
+
return Number(e);
|
|
718
925
|
};
|
|
719
|
-
class
|
|
926
|
+
class rn {
|
|
720
927
|
/**
|
|
721
928
|
* @private
|
|
722
929
|
* @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
|
|
@@ -756,8 +963,8 @@ class xt {
|
|
|
756
963
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
757
964
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
758
965
|
*/
|
|
759
|
-
constructor(
|
|
760
|
-
this.reset(
|
|
966
|
+
constructor(t, e, n) {
|
|
967
|
+
this.reset(t, e, n);
|
|
761
968
|
}
|
|
762
969
|
/**
|
|
763
970
|
* @method reset
|
|
@@ -767,26 +974,26 @@ class xt {
|
|
|
767
974
|
* @param {number | ((index: number) => number)} valueOrFn - The value for all elements, or a function to generate values.
|
|
768
975
|
* @param {{ sampleRange?: { from: number; to: number }, materialize?: boolean }} [options] - Optional settings for initialization.
|
|
769
976
|
*/
|
|
770
|
-
reset(
|
|
771
|
-
if (this.size =
|
|
772
|
-
if (this.valueFn =
|
|
773
|
-
const
|
|
977
|
+
reset(t, e, n) {
|
|
978
|
+
if (this.size = t, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof e == "function") {
|
|
979
|
+
if (this.valueFn = e, this.size > 0) {
|
|
980
|
+
const a = n?.sampleRange ?? {
|
|
774
981
|
from: 0,
|
|
775
982
|
to: Math.min(99, this.size - 1)
|
|
776
|
-
}, { mode:
|
|
777
|
-
if (this.baseValue =
|
|
778
|
-
for (let
|
|
779
|
-
const
|
|
983
|
+
}, { mode: u, materializedValues: f } = this._calculateMode(a.from, a.to);
|
|
984
|
+
if (this.baseValue = u, n?.materialize)
|
|
985
|
+
for (let l = 0; l < f.length; l++) {
|
|
986
|
+
const c = f[l], d = a.from + l;
|
|
780
987
|
if (d >= this.size)
|
|
781
988
|
break;
|
|
782
|
-
const
|
|
783
|
-
this.deltas.set(d,
|
|
989
|
+
const h = c - this.baseValue;
|
|
990
|
+
this.deltas.set(d, h), this._updateTree(d, h);
|
|
784
991
|
}
|
|
785
992
|
} else
|
|
786
993
|
this.baseValue = 0;
|
|
787
994
|
this.total = this.getTotal();
|
|
788
995
|
} else
|
|
789
|
-
this.valueFn = void 0, this.baseValue =
|
|
996
|
+
this.valueFn = void 0, this.baseValue = e, this.total = this.baseValue * this.size;
|
|
790
997
|
}
|
|
791
998
|
/**
|
|
792
999
|
* @method setValueFn
|
|
@@ -794,8 +1001,8 @@ class xt {
|
|
|
794
1001
|
* @description 値関数を更新し、ツリーを再初期化する。
|
|
795
1002
|
* @param {number | ((index: number) => number)} valueOrFn - The new value for all elements, or a function to generate values.
|
|
796
1003
|
*/
|
|
797
|
-
setValueFn(
|
|
798
|
-
typeof
|
|
1004
|
+
setValueFn(t) {
|
|
1005
|
+
typeof t == "function" ? this.valueFn = t : (this.valueFn = void 0, this.baseValue = t);
|
|
799
1006
|
}
|
|
800
1007
|
/**
|
|
801
1008
|
* @private
|
|
@@ -806,33 +1013,33 @@ class xt {
|
|
|
806
1013
|
* @param {number} to - The ending index of the range (inclusive).
|
|
807
1014
|
* @returns {{ mode: number; materializedValues: number[] }} An object containing the calculated mode and the array of generated values.
|
|
808
1015
|
*/
|
|
809
|
-
_calculateMode(
|
|
1016
|
+
_calculateMode(t, e) {
|
|
810
1017
|
if (!this.valueFn)
|
|
811
1018
|
return { mode: 0, materializedValues: [] };
|
|
812
1019
|
const n = [];
|
|
813
|
-
for (let
|
|
814
|
-
n.push(this.valueFn(
|
|
815
|
-
const
|
|
1020
|
+
for (let c = t; c <= e && !(c >= this.size); c++)
|
|
1021
|
+
n.push(this.valueFn(c));
|
|
1022
|
+
const o = [...n];
|
|
816
1023
|
if (n.length === 0)
|
|
817
1024
|
return { mode: 0, materializedValues: [] };
|
|
818
|
-
n.sort((
|
|
819
|
-
const
|
|
820
|
-
let
|
|
821
|
-
n.length % 2 === 0 ?
|
|
822
|
-
const
|
|
823
|
-
let
|
|
824
|
-
for (const
|
|
825
|
-
const d = (
|
|
826
|
-
|
|
1025
|
+
n.sort((c, d) => c - d);
|
|
1026
|
+
const a = Math.floor(n.length / 2);
|
|
1027
|
+
let u;
|
|
1028
|
+
n.length % 2 === 0 ? u = Math.floor((n[a - 1] + n[a]) / 2) : u = n[a];
|
|
1029
|
+
const f = /* @__PURE__ */ new Map();
|
|
1030
|
+
let l = 0;
|
|
1031
|
+
for (const c of n) {
|
|
1032
|
+
const d = (f.get(c) ?? 0) + 1;
|
|
1033
|
+
f.set(c, d), d > l && (l = d);
|
|
827
1034
|
}
|
|
828
|
-
if (
|
|
829
|
-
const
|
|
830
|
-
for (const [
|
|
831
|
-
|
|
832
|
-
const d =
|
|
833
|
-
|
|
1035
|
+
if (l > 1) {
|
|
1036
|
+
const c = [];
|
|
1037
|
+
for (const [h, b] of f.entries())
|
|
1038
|
+
b === l && c.push(h);
|
|
1039
|
+
const d = c.reduce((h, b) => h + b, 0);
|
|
1040
|
+
u = Math.floor(d / c.length);
|
|
834
1041
|
}
|
|
835
|
-
return { mode:
|
|
1042
|
+
return { mode: u, materializedValues: o };
|
|
836
1043
|
}
|
|
837
1044
|
/**
|
|
838
1045
|
* @method update
|
|
@@ -841,18 +1048,18 @@ class xt {
|
|
|
841
1048
|
* @param {number} index - The 0-based index to update.
|
|
842
1049
|
* @param {number} value - The new value.
|
|
843
1050
|
*/
|
|
844
|
-
update(
|
|
845
|
-
return this.updates([{ index:
|
|
1051
|
+
update(t, e) {
|
|
1052
|
+
return this.updates([{ index: t, value: e }]);
|
|
846
1053
|
}
|
|
847
1054
|
/**
|
|
848
1055
|
* @method updates
|
|
849
1056
|
* @description Updates the values at given indices.
|
|
850
1057
|
* @description 指定されたインデックスの値を更新。
|
|
851
|
-
|
|
1058
|
+
* @param {ValueUpdate[]} updates - An array of updates, each with an index and the new value.
|
|
852
1059
|
*/
|
|
853
|
-
updates(
|
|
854
|
-
const
|
|
855
|
-
return
|
|
1060
|
+
updates(t) {
|
|
1061
|
+
const e = this._buildDeltaUpdates(t);
|
|
1062
|
+
return e.length > 0 ? this.updateDeltas(e) : this.total;
|
|
856
1063
|
}
|
|
857
1064
|
/**
|
|
858
1065
|
* @method updateDelta
|
|
@@ -861,21 +1068,21 @@ class xt {
|
|
|
861
1068
|
* @param {number} index - The 0-based index to update.
|
|
862
1069
|
* @param {number} change - The value to add to the delta at the given index.
|
|
863
1070
|
*/
|
|
864
|
-
updateDelta(
|
|
865
|
-
return this.updateDeltas([{ index:
|
|
1071
|
+
updateDelta(t, e) {
|
|
1072
|
+
return this.updateDeltas([{ index: t, change: e }]);
|
|
866
1073
|
}
|
|
867
1074
|
/**
|
|
868
1075
|
* @method updateDeltas
|
|
869
1076
|
* @description Updates the deltas at given indices and propagates the changes through the tree.
|
|
870
1077
|
* @description 指定されたインデックスのデルタを更新し、変更をツリーに伝播させる。
|
|
871
|
-
|
|
1078
|
+
* @param {DeltaUpdate[]} updates - An array of updates, each with an index and the change to apply.
|
|
872
1079
|
*/
|
|
873
|
-
updateDeltas(
|
|
874
|
-
for (const { index:
|
|
875
|
-
if (
|
|
876
|
-
throw new Error(`Index ${
|
|
877
|
-
const
|
|
878
|
-
this.deltas.set(
|
|
1080
|
+
updateDeltas(t) {
|
|
1081
|
+
for (const { index: e, change: n } of t) {
|
|
1082
|
+
if (e < 0 || e >= this.size)
|
|
1083
|
+
throw new Error(`Index ${e} out of bounds`);
|
|
1084
|
+
const o = this.deltas.get(e) ?? 0;
|
|
1085
|
+
this.deltas.set(e, o + n), this._updateTree(e, n);
|
|
879
1086
|
}
|
|
880
1087
|
return this.total;
|
|
881
1088
|
}
|
|
@@ -887,13 +1094,18 @@ class xt {
|
|
|
887
1094
|
* @param {number} index - The 0-based index that changed.
|
|
888
1095
|
* @param {number} change - The change in value.
|
|
889
1096
|
*/
|
|
890
|
-
_updateTree(
|
|
891
|
-
if (
|
|
1097
|
+
_updateTree(t, e) {
|
|
1098
|
+
if (e === 0)
|
|
892
1099
|
return;
|
|
893
|
-
let n =
|
|
894
|
-
for (; n <= this.size; )
|
|
895
|
-
this.tree.set(n, (this.tree.get(n) ?? 0) +
|
|
896
|
-
|
|
1100
|
+
let n = t + 1;
|
|
1101
|
+
for (; n <= this.size; ) {
|
|
1102
|
+
this.tree.set(n, (this.tree.get(n) ?? 0) + e);
|
|
1103
|
+
const o = ie(n);
|
|
1104
|
+
if (o === 0)
|
|
1105
|
+
break;
|
|
1106
|
+
n += o;
|
|
1107
|
+
}
|
|
1108
|
+
this.total !== void 0 && (this.total += e);
|
|
897
1109
|
}
|
|
898
1110
|
/**
|
|
899
1111
|
* @private
|
|
@@ -903,17 +1115,37 @@ class xt {
|
|
|
903
1115
|
* @param {ValueUpdate[]} updates - Requested value updates.
|
|
904
1116
|
* @returns {DeltaUpdate[]} Sanitized delta updates ready to apply.
|
|
905
1117
|
*/
|
|
906
|
-
_buildDeltaUpdates(
|
|
907
|
-
const
|
|
908
|
-
for (const { index: n, value:
|
|
1118
|
+
_buildDeltaUpdates(t) {
|
|
1119
|
+
const e = [];
|
|
1120
|
+
for (const { index: n, value: o } of t) {
|
|
909
1121
|
if (n < 0 || n >= this.size)
|
|
910
1122
|
throw new Error(`Index ${n} out of bounds`);
|
|
911
|
-
if (
|
|
1123
|
+
if (o < 0)
|
|
912
1124
|
throw new Error("Value cannot be negative.");
|
|
913
|
-
const
|
|
914
|
-
|
|
1125
|
+
const a = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, u = o - a;
|
|
1126
|
+
u !== 0 && e.push({ index: n, change: u });
|
|
1127
|
+
}
|
|
1128
|
+
return e;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* @private
|
|
1132
|
+
* @method _computeTreeTotal
|
|
1133
|
+
* @description Calculates the total height represented by the current Fenwick tree structure, reproducing the same traversal used by `prefixSum` at the last index to avoid floating-point drift.
|
|
1134
|
+
* @description Fenwick 木が保持する合計値を算出する。末尾インデックスでの `prefixSum` と同一の走査手順を再現し、浮動小数点の誤差を防ぐ。
|
|
1135
|
+
* @returns {number} The total height encoded in the Fenwick tree.
|
|
1136
|
+
*/
|
|
1137
|
+
_computeTreeTotal() {
|
|
1138
|
+
if (this.size <= 0)
|
|
1139
|
+
return 0;
|
|
1140
|
+
let t = 0, e = this.size;
|
|
1141
|
+
for (; e > 0; ) {
|
|
1142
|
+
t += this.tree.get(e) ?? 0;
|
|
1143
|
+
const n = ie(e);
|
|
1144
|
+
if (n === 0)
|
|
1145
|
+
break;
|
|
1146
|
+
e -= n;
|
|
915
1147
|
}
|
|
916
|
-
return t;
|
|
1148
|
+
return t + this.baseValue * this.size;
|
|
917
1149
|
}
|
|
918
1150
|
/**
|
|
919
1151
|
* @private
|
|
@@ -923,12 +1155,12 @@ class xt {
|
|
|
923
1155
|
* @param {number} index - The 0-based index to materialize.
|
|
924
1156
|
* @param {boolean} [updateTree=true] - Whether to update the Fenwick tree after materialization.
|
|
925
1157
|
*/
|
|
926
|
-
_materialize(
|
|
1158
|
+
_materialize(t, e = !0) {
|
|
927
1159
|
if (this.valueFn) {
|
|
928
|
-
const n = this.deltas.get(
|
|
929
|
-
if (
|
|
930
|
-
const
|
|
931
|
-
this._updateTree(
|
|
1160
|
+
const n = this.deltas.get(t) ?? 0, a = this.valueFn(t) - this.baseValue;
|
|
1161
|
+
if (a !== n && (this.deltas.set(t, a), e)) {
|
|
1162
|
+
const u = a - n;
|
|
1163
|
+
this._updateTree(t, u);
|
|
932
1164
|
}
|
|
933
1165
|
}
|
|
934
1166
|
}
|
|
@@ -941,27 +1173,27 @@ class xt {
|
|
|
941
1173
|
* @param {number | undefined} index - Target index for materialization.
|
|
942
1174
|
* @param {boolean} [forceIndex=false] - When true, materializes the index even if it is outside the provided ranges.
|
|
943
1175
|
*/
|
|
944
|
-
_materializeRanges(
|
|
945
|
-
if (!(
|
|
1176
|
+
_materializeRanges(t, e, n = !1) {
|
|
1177
|
+
if (!(t?.materialize && this.valueFn))
|
|
946
1178
|
return;
|
|
947
|
-
const
|
|
948
|
-
if (
|
|
949
|
-
for (const
|
|
950
|
-
const
|
|
951
|
-
for (let d =
|
|
1179
|
+
const o = t.ranges;
|
|
1180
|
+
if (o && o.length > 0) {
|
|
1181
|
+
for (const f of o) {
|
|
1182
|
+
const l = f.from, c = Math.min(f.to, this.size - 1);
|
|
1183
|
+
for (let d = l; d <= c; d++)
|
|
952
1184
|
this._materialize(d);
|
|
953
1185
|
}
|
|
954
|
-
if (
|
|
1186
|
+
if (e === void 0)
|
|
955
1187
|
return;
|
|
956
1188
|
if (n) {
|
|
957
|
-
this._materialize(
|
|
1189
|
+
this._materialize(e);
|
|
958
1190
|
return;
|
|
959
1191
|
}
|
|
960
|
-
const
|
|
961
|
-
|
|
1192
|
+
const a = o[0].from, u = o[o.length - 1].to;
|
|
1193
|
+
e >= a && e <= u && this._materialize(e);
|
|
962
1194
|
return;
|
|
963
1195
|
}
|
|
964
|
-
|
|
1196
|
+
e !== void 0 && this._materialize(e);
|
|
965
1197
|
}
|
|
966
1198
|
/**
|
|
967
1199
|
* @private
|
|
@@ -973,15 +1205,55 @@ class xt {
|
|
|
973
1205
|
* @param {boolean} chooseLowerBound - When true, finds the smallest index meeting or exceeding the target; otherwise finds the largest index not exceeding it.
|
|
974
1206
|
* @returns {{ index: number; total: number | undefined; cumulative: number | undefined; currentValue: number | undefined; safeIndex: number | undefined }} Binary search result.
|
|
975
1207
|
*/
|
|
976
|
-
_findIndex(
|
|
1208
|
+
_findIndex(t, e = {}, n) {
|
|
1209
|
+
if (this.size >= Number.MAX_SAFE_INTEGER)
|
|
1210
|
+
return this._findIndexLarge(t, e, n);
|
|
977
1211
|
if (this.size === 0)
|
|
978
1212
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
979
|
-
let
|
|
980
|
-
for (;
|
|
981
|
-
const
|
|
982
|
-
|
|
1213
|
+
let o = 0, a = this.size - 1, u = -1, f, l = this.total;
|
|
1214
|
+
for (; o <= a; ) {
|
|
1215
|
+
const c = Math.floor((o + a) / 2);
|
|
1216
|
+
f = this.prefixSum(c, e), l = f.total, (n ? f.cumulative >= t : f.cumulative <= t) ? (u = c, n ? a = c - 1 : o = c + 1) : n ? o = c + 1 : a = c - 1;
|
|
983
1217
|
}
|
|
984
|
-
return { index:
|
|
1218
|
+
return { index: u, total: l, cumulative: f?.cumulative, currentValue: f?.currentValue, safeIndex: f?.safeIndex };
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Executes a binary search using bigint arithmetic for extremely large sizes.
|
|
1222
|
+
*
|
|
1223
|
+
* 非常に大きなサイズに対して bigint 演算を用いた二分探索を実施。
|
|
1224
|
+
*/
|
|
1225
|
+
_findIndexLarge(t, e, n) {
|
|
1226
|
+
if (this.size === 0)
|
|
1227
|
+
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1228
|
+
const o = nn(this.size);
|
|
1229
|
+
if (o === 0n)
|
|
1230
|
+
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
1231
|
+
let a = 0n, u = o - 1n, f, l, c, d = this.total;
|
|
1232
|
+
for (; a <= u; ) {
|
|
1233
|
+
const T = a + u >> 1n, k = Number(T), _ = this.prefixSum(k, e);
|
|
1234
|
+
if (c = _, d = _.total, n ? _.cumulative >= t : _.cumulative <= t)
|
|
1235
|
+
if (f = T, l = _, n) {
|
|
1236
|
+
if (T === 0n)
|
|
1237
|
+
break;
|
|
1238
|
+
u = T - 1n;
|
|
1239
|
+
} else
|
|
1240
|
+
a = T + 1n;
|
|
1241
|
+
else if (n)
|
|
1242
|
+
a = T + 1n;
|
|
1243
|
+
else {
|
|
1244
|
+
if (T === 0n)
|
|
1245
|
+
break;
|
|
1246
|
+
u = T - 1n;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
const h = l ?? c;
|
|
1250
|
+
return {
|
|
1251
|
+
index: f !== void 0 ? Number(f) : -1,
|
|
1252
|
+
total: d,
|
|
1253
|
+
cumulative: h?.cumulative,
|
|
1254
|
+
currentValue: h?.currentValue,
|
|
1255
|
+
safeIndex: h?.safeIndex
|
|
1256
|
+
};
|
|
985
1257
|
}
|
|
986
1258
|
/**
|
|
987
1259
|
* @method prefixSum
|
|
@@ -991,18 +1263,22 @@ class xt {
|
|
|
991
1263
|
* @param {MaterializeConfig} [options] - Optional settings for materializing values.
|
|
992
1264
|
* @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.
|
|
993
1265
|
*/
|
|
994
|
-
prefixSum(
|
|
995
|
-
if (
|
|
1266
|
+
prefixSum(t, e) {
|
|
1267
|
+
if (t < 0)
|
|
996
1268
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
997
|
-
const n =
|
|
998
|
-
this._materializeRanges(
|
|
999
|
-
let
|
|
1000
|
-
for (;
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1269
|
+
const n = pt(t, 0, this.size - 1), o = e?.materializeOption;
|
|
1270
|
+
this._materializeRanges(o, n, !0);
|
|
1271
|
+
let a = 0, u = n + 1;
|
|
1272
|
+
for (; u > 0; ) {
|
|
1273
|
+
const l = this.tree.get(u) ?? 0;
|
|
1274
|
+
a += l;
|
|
1275
|
+
const c = ie(u);
|
|
1276
|
+
if (c === 0)
|
|
1277
|
+
break;
|
|
1278
|
+
u -= c;
|
|
1003
1279
|
}
|
|
1004
|
-
const
|
|
1005
|
-
return { cumulative:
|
|
1280
|
+
const f = o?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
|
|
1281
|
+
return { cumulative: a + this.baseValue * (n + 1), total: this.total, currentValue: f, safeIndex: n };
|
|
1006
1282
|
}
|
|
1007
1283
|
/**
|
|
1008
1284
|
* @method get
|
|
@@ -1012,11 +1288,11 @@ class xt {
|
|
|
1012
1288
|
* @param {MaterializeConfig} [options] - Optional settings for materializing values.
|
|
1013
1289
|
* @returns {number} The value at the given index.
|
|
1014
1290
|
*/
|
|
1015
|
-
get(
|
|
1016
|
-
if (
|
|
1291
|
+
get(t, e) {
|
|
1292
|
+
if (t < 0 || t >= this.size)
|
|
1017
1293
|
throw new Error("Index out of bounds");
|
|
1018
|
-
const n =
|
|
1019
|
-
return this._materializeRanges(n,
|
|
1294
|
+
const n = e?.materializeOption;
|
|
1295
|
+
return this._materializeRanges(n, t), (this.deltas.get(t) ?? 0) + this.baseValue;
|
|
1020
1296
|
}
|
|
1021
1297
|
/**
|
|
1022
1298
|
* @method getTotal
|
|
@@ -1025,18 +1301,15 @@ class xt {
|
|
|
1025
1301
|
* @param {MaterializeConfig} [options] - Optional settings for materializing values.
|
|
1026
1302
|
* @returns {number} The total sum of all values.
|
|
1027
1303
|
*/
|
|
1028
|
-
getTotal(
|
|
1029
|
-
const
|
|
1030
|
-
if (this._materializeRanges(
|
|
1304
|
+
getTotal(t) {
|
|
1305
|
+
const e = t?.materializeOption;
|
|
1306
|
+
if (this._materializeRanges(e), this.total === void 0)
|
|
1031
1307
|
if (this.size === 0)
|
|
1032
1308
|
this.total = 0;
|
|
1033
1309
|
else {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
this.total = n;
|
|
1038
|
-
const r = this.prefixSum(this.getSize() - 1);
|
|
1039
|
-
console.assert(r.cumulative === r.total, "Inconsistent Fenwick Tree state");
|
|
1310
|
+
this.total = this._computeTreeTotal();
|
|
1311
|
+
const n = this.prefixSum(this.getSize() - 1);
|
|
1312
|
+
console.assert(n.cumulative === n.total, "Inconsistent Fenwick Tree state");
|
|
1040
1313
|
}
|
|
1041
1314
|
return this.total;
|
|
1042
1315
|
}
|
|
@@ -1047,22 +1320,26 @@ class xt {
|
|
|
1047
1320
|
* @param {object} [options] - Optional settings for rebuilding.
|
|
1048
1321
|
* @param {boolean} [options.materialize=false] - If true and `valueFn` is provided, re-materializes all values, recalculating `deltas` and `baseValue`.
|
|
1049
1322
|
*/
|
|
1050
|
-
rebuildTree(
|
|
1051
|
-
if (
|
|
1052
|
-
const
|
|
1053
|
-
this.reset(this.size, (
|
|
1323
|
+
rebuildTree(t) {
|
|
1324
|
+
if (t?.materialize && this.valueFn) {
|
|
1325
|
+
const n = this.valueFn;
|
|
1326
|
+
this.reset(this.size, (o) => n(o), { materialize: !0 });
|
|
1054
1327
|
return;
|
|
1055
1328
|
}
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
if (n += i, i === 0)
|
|
1329
|
+
const e = /* @__PURE__ */ new Map();
|
|
1330
|
+
for (const [n, o] of this.deltas.entries()) {
|
|
1331
|
+
if (o === 0)
|
|
1060
1332
|
continue;
|
|
1061
|
-
let
|
|
1062
|
-
for (;
|
|
1063
|
-
|
|
1333
|
+
let a = n + 1;
|
|
1334
|
+
for (; a <= this.size; ) {
|
|
1335
|
+
e.set(a, (e.get(a) ?? 0) + o);
|
|
1336
|
+
const u = ie(a);
|
|
1337
|
+
if (u === 0)
|
|
1338
|
+
break;
|
|
1339
|
+
a += u;
|
|
1340
|
+
}
|
|
1064
1341
|
}
|
|
1065
|
-
this.tree =
|
|
1342
|
+
this.tree = e, this.total = this._computeTreeTotal();
|
|
1066
1343
|
}
|
|
1067
1344
|
/**
|
|
1068
1345
|
* @method calculateAccumulatedError
|
|
@@ -1073,10 +1350,10 @@ class xt {
|
|
|
1073
1350
|
calculateAccumulatedError() {
|
|
1074
1351
|
if (this.total === void 0)
|
|
1075
1352
|
return 0;
|
|
1076
|
-
let
|
|
1077
|
-
for (const
|
|
1078
|
-
|
|
1079
|
-
return this.total -
|
|
1353
|
+
let t = this.baseValue * this.size;
|
|
1354
|
+
for (const e of this.deltas.values())
|
|
1355
|
+
t += e;
|
|
1356
|
+
return this.total - t;
|
|
1080
1357
|
}
|
|
1081
1358
|
/**
|
|
1082
1359
|
* @method changeSize
|
|
@@ -1084,14 +1361,14 @@ class xt {
|
|
|
1084
1361
|
* @description Fenwick Tree のサイズを変更する。
|
|
1085
1362
|
* @param {number} newSize - The new size of the tree.
|
|
1086
1363
|
*/
|
|
1087
|
-
changeSize(
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1364
|
+
changeSize(t) {
|
|
1365
|
+
const e = this.size;
|
|
1366
|
+
if (t === e)
|
|
1090
1367
|
return;
|
|
1091
|
-
if (
|
|
1092
|
-
for (const
|
|
1093
|
-
|
|
1094
|
-
this.size =
|
|
1368
|
+
if (t < e)
|
|
1369
|
+
for (const o of this.deltas.keys())
|
|
1370
|
+
o >= t && this.deltas.delete(o);
|
|
1371
|
+
this.size = t, this.rebuildTree();
|
|
1095
1372
|
const n = this.prefixSum(this.getSize() - 1);
|
|
1096
1373
|
console.assert(n.cumulative === n.total, "Inconsistent Fenwick Tree state");
|
|
1097
1374
|
}
|
|
@@ -1109,44 +1386,44 @@ class xt {
|
|
|
1109
1386
|
* @description Finds the first index where the cumulative sum is greater than or equal to a target value.
|
|
1110
1387
|
* @description 累積和がターゲット値以上になる最初のインデックスを検索。
|
|
1111
1388
|
* @param {number} target - The target cumulative sum.
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1389
|
+
* @param {MaterializeConfig} [options] - Optional settings for materializing values.
|
|
1390
|
+
* @param {MaterializeOption} [options.materializeOption] - Options to control materialization.
|
|
1391
|
+
* @param {boolean} [options.materializeOption.materialize=false] - Whether to materialize values.
|
|
1392
|
+
* @param {MaterializeRange[]} [options.materializeOption.ranges] - Optional ranges for eager materialization.
|
|
1116
1393
|
* @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.
|
|
1117
1394
|
*/
|
|
1118
|
-
findIndexAtOrAfter(
|
|
1119
|
-
return this._findIndex(
|
|
1395
|
+
findIndexAtOrAfter(t, e) {
|
|
1396
|
+
return this._findIndex(t, e ?? {}, !0);
|
|
1120
1397
|
}
|
|
1121
1398
|
/**
|
|
1122
1399
|
* @method findIndexAtOrBefore
|
|
1123
1400
|
* @description Finds the last index where the cumulative sum is less than or equal to a target value.
|
|
1124
1401
|
* @description 累積和がターゲット値以下になる最後のインデックスを検索。
|
|
1125
1402
|
* @param {number} target - The target cumulative sum.
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1403
|
+
* @param {MaterializeConfig} [options] - Optional settings for materializing values.
|
|
1404
|
+
* @param {MaterializeOption} [options.materializeOption] - Options to control materialization。
|
|
1405
|
+
* @param {boolean} [options.materializeOption.materialize=false] - Whether to materialize values。
|
|
1406
|
+
* @param {MaterializeRange[]} [options.materializeOption.ranges] - Optional ranges for eager materialization。
|
|
1130
1407
|
* @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.
|
|
1131
1408
|
*/
|
|
1132
|
-
findIndexAtOrBefore(
|
|
1133
|
-
return this._findIndex(
|
|
1409
|
+
findIndexAtOrBefore(t, e) {
|
|
1410
|
+
return this._findIndex(t, e ?? {}, !1);
|
|
1134
1411
|
}
|
|
1135
1412
|
}
|
|
1136
|
-
const
|
|
1137
|
-
const n = Math.max(0,
|
|
1138
|
-
return Object.is(
|
|
1413
|
+
const on = (r, t, e) => {
|
|
1414
|
+
const n = Math.max(0, r), o = w(null), a = Vt(() => new rn(n, t, e), [n, t, e]);
|
|
1415
|
+
return Object.is(o.current, a) || console.warn("[useFenwickMapTree] instance changed"), o.current = a, a;
|
|
1139
1416
|
};
|
|
1140
|
-
class
|
|
1417
|
+
class sn {
|
|
1141
1418
|
key;
|
|
1142
1419
|
value;
|
|
1143
1420
|
prev = null;
|
|
1144
1421
|
next = null;
|
|
1145
|
-
constructor(
|
|
1146
|
-
this.key =
|
|
1422
|
+
constructor(t, e) {
|
|
1423
|
+
this.key = t, this.value = e;
|
|
1147
1424
|
}
|
|
1148
1425
|
}
|
|
1149
|
-
class
|
|
1426
|
+
class Pe {
|
|
1150
1427
|
head = null;
|
|
1151
1428
|
tail = null;
|
|
1152
1429
|
/**
|
|
@@ -1155,8 +1432,8 @@ class Ze {
|
|
|
1155
1432
|
* @description ノードをリストの末尾に追加し、最も最近使用されたものとしてマークします。
|
|
1156
1433
|
* @param {DoublyLinkedListNode<K, V>} node - The node to add.
|
|
1157
1434
|
*/
|
|
1158
|
-
addToTail(
|
|
1159
|
-
this.tail ? (this.tail.next =
|
|
1435
|
+
addToTail(t) {
|
|
1436
|
+
this.tail ? (this.tail.next = t, t.prev = this.tail, this.tail = t) : this.head = this.tail = t;
|
|
1160
1437
|
}
|
|
1161
1438
|
/**
|
|
1162
1439
|
* @method remove
|
|
@@ -1164,8 +1441,8 @@ class Ze {
|
|
|
1164
1441
|
* @description 指定されたノードをリストから削除します。
|
|
1165
1442
|
* @param {DoublyLinkedListNode<K, V>} node - The node to remove.
|
|
1166
1443
|
*/
|
|
1167
|
-
remove(
|
|
1168
|
-
|
|
1444
|
+
remove(t) {
|
|
1445
|
+
t.prev ? t.prev.next = t.next : this.head = t.next, t.next ? t.next.prev = t.prev : this.tail = t.prev, t.prev = null, t.next = null;
|
|
1169
1446
|
}
|
|
1170
1447
|
/**
|
|
1171
1448
|
* @method removeHead
|
|
@@ -1174,8 +1451,8 @@ class Ze {
|
|
|
1174
1451
|
* @returns {DoublyLinkedListNode<K, V> | null} The removed head node, or null if the list is empty.
|
|
1175
1452
|
*/
|
|
1176
1453
|
removeHead() {
|
|
1177
|
-
const
|
|
1178
|
-
return
|
|
1454
|
+
const t = this.head;
|
|
1455
|
+
return t && this.remove(t), t;
|
|
1179
1456
|
}
|
|
1180
1457
|
/**
|
|
1181
1458
|
* @method moveToTail
|
|
@@ -1183,197 +1460,566 @@ class Ze {
|
|
|
1183
1460
|
* @description 既存のノードをリストの末尾に移動し、最も最近使用されたものとしてマークします。
|
|
1184
1461
|
* @param {DoublyLinkedListNode<K, V>} node - The node to move.
|
|
1185
1462
|
*/
|
|
1186
|
-
moveToTail(
|
|
1187
|
-
this.remove(
|
|
1463
|
+
moveToTail(t) {
|
|
1464
|
+
this.remove(t), this.addToTail(t);
|
|
1188
1465
|
}
|
|
1189
1466
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
for (;
|
|
1194
|
-
const
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1467
|
+
function an(r) {
|
|
1468
|
+
const t = w(/* @__PURE__ */ new Map()), e = w(new Pe());
|
|
1469
|
+
L(() => {
|
|
1470
|
+
for (; t.current.size > r; ) {
|
|
1471
|
+
const d = e.current.removeHead();
|
|
1472
|
+
if (d)
|
|
1473
|
+
t.current.delete(d.key);
|
|
1197
1474
|
else
|
|
1198
1475
|
break;
|
|
1199
1476
|
}
|
|
1200
|
-
}, [
|
|
1201
|
-
const n =
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
return
|
|
1205
|
-
}, []),
|
|
1206
|
-
(
|
|
1207
|
-
if (
|
|
1477
|
+
}, [r]);
|
|
1478
|
+
const n = M((d) => {
|
|
1479
|
+
const h = t.current.get(d);
|
|
1480
|
+
if (h)
|
|
1481
|
+
return e.current.moveToTail(h), h.value;
|
|
1482
|
+
}, []), o = M(
|
|
1483
|
+
(d, h) => {
|
|
1484
|
+
if (r <= 0)
|
|
1208
1485
|
return;
|
|
1209
|
-
let
|
|
1210
|
-
if (
|
|
1211
|
-
|
|
1486
|
+
let b = t.current.get(d);
|
|
1487
|
+
if (b)
|
|
1488
|
+
b.value = h, e.current.moveToTail(b);
|
|
1212
1489
|
else {
|
|
1213
|
-
if (
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1490
|
+
if (t.current.size >= r) {
|
|
1491
|
+
const T = e.current.removeHead();
|
|
1492
|
+
T && t.current.delete(T.key);
|
|
1216
1493
|
}
|
|
1217
|
-
|
|
1494
|
+
b = new sn(d, h), t.current.set(d, b), e.current.addToTail(b);
|
|
1218
1495
|
}
|
|
1219
1496
|
},
|
|
1220
|
-
[
|
|
1221
|
-
),
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1497
|
+
[r]
|
|
1498
|
+
), a = M((d) => t.current.has(d), []), u = M((d) => {
|
|
1499
|
+
const h = t.current.get(d);
|
|
1500
|
+
h && (e.current.remove(h), t.current.delete(d));
|
|
1501
|
+
}, []), f = M(() => {
|
|
1502
|
+
t.current.clear(), e.current = new Pe();
|
|
1503
|
+
}, []), [l, c] = Yt(() => ({ get: n, set: o, has: a, remove: u, clear: f }));
|
|
1504
|
+
return L(() => c({ get: n, set: o, has: a, remove: u, clear: f }), [n, o, a, u, f]), l;
|
|
1225
1505
|
}
|
|
1226
|
-
const
|
|
1227
|
-
const { get:
|
|
1228
|
-
return { get:
|
|
1229
|
-
},
|
|
1506
|
+
const ln = 1e4, Tn = () => {
|
|
1507
|
+
const { get: r, set: t, has: e, clear: n } = an(ln);
|
|
1508
|
+
return { get: r, set: t, has: e, clear: n };
|
|
1509
|
+
}, lt = (r, t) => t <= 0 ? 0 : pt(r, 0, t - 1), cn = (r) => ({
|
|
1510
|
+
top: Math.max(0, r?.top ?? 0),
|
|
1511
|
+
bottom: Math.max(0, r?.bottom ?? 0)
|
|
1512
|
+
}), qt = (r, t) => r <= t ? 0 : r - t, Qt = (r, t) => r <= 0 ? t : r + t, Se = (r) => {
|
|
1513
|
+
if (!Number.isFinite(r))
|
|
1514
|
+
return 0n;
|
|
1515
|
+
const t = Math.trunc(r);
|
|
1516
|
+
return t <= 0 ? 0n : BigInt(t);
|
|
1517
|
+
}, un = (r, t, e, n, o, a, u, f) => {
|
|
1518
|
+
const l = Se(n);
|
|
1519
|
+
if (l === 0n)
|
|
1520
|
+
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
1521
|
+
const c = (D) => D < 0n ? 0n : D >= l ? l - 1n : D, d = { materializeOption: { materialize: !1 } }, { index: h } = a.findIndexAtOrAfter(r, d);
|
|
1522
|
+
let b;
|
|
1523
|
+
h === -1 ? b = l - 1n : (b = Se(h), b >= l && (b = l - 1n)), r <= 0 && (b = 0n), f && r >= u && (b = l - 1n);
|
|
1524
|
+
const T = (D) => {
|
|
1525
|
+
let X = 0, O = D, R = D, H = 0n;
|
|
1526
|
+
for (; O < l && X < t; ) {
|
|
1527
|
+
const q = Number(O), N = o(q);
|
|
1528
|
+
if (X += N, R = O, O += 1n, H += 1n, !Number.isFinite(N) || N <= 0)
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
return H === 0n && (R = D), { height: X, end: R };
|
|
1532
|
+
};
|
|
1533
|
+
let { height: k, end: _ } = T(b);
|
|
1534
|
+
if (k < t && b > 0n) {
|
|
1535
|
+
let D = b, X = k;
|
|
1536
|
+
for (; D > 0n && X < t; ) {
|
|
1537
|
+
D -= 1n;
|
|
1538
|
+
const R = Number(D), H = o(R);
|
|
1539
|
+
if (X += H, !Number.isFinite(H) || H <= 0)
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
b = c(D);
|
|
1543
|
+
const O = T(b);
|
|
1544
|
+
k = O.height, _ = O.end;
|
|
1545
|
+
}
|
|
1546
|
+
const tt = c(b), Y = c(_), ut = c(tt - BigInt(Math.max(0, e))), V = c(Y + BigInt(Math.max(0, e)));
|
|
1547
|
+
return {
|
|
1548
|
+
renderingStartIndex: lt(Number(ut), n),
|
|
1549
|
+
renderingEndIndex: lt(Number(V), n),
|
|
1550
|
+
visibleStartIndex: lt(Number(tt), n),
|
|
1551
|
+
visibleEndIndex: lt(Number(Y), n)
|
|
1552
|
+
};
|
|
1553
|
+
}, dn = (r, t, e, n, o, a) => {
|
|
1230
1554
|
if (n === 0)
|
|
1231
1555
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1556
|
+
const u = a.getTotal(), f = Number.isFinite(u), l = f ? Math.min(r, u) : r;
|
|
1557
|
+
if (n > Number.MAX_SAFE_INTEGER)
|
|
1558
|
+
return un(l, t, e, n, o, a, u, f);
|
|
1559
|
+
const { index: c, cumulative: d, currentValue: h } = a.findIndexAtOrAfter(l, { materializeOption: { materialize: !1 } }), b = c === -1 ? t <= 0 || (d ?? 0) < l + (h ?? 0) ? n - 1 : 0 : c;
|
|
1560
|
+
let T = lt(b, n), k = 0, _ = T;
|
|
1561
|
+
for (; _ < n && k < t; )
|
|
1562
|
+
k += o(_), _++;
|
|
1563
|
+
if (k < t && T > 0) {
|
|
1564
|
+
let V = k, D = T - 1;
|
|
1565
|
+
for (; D >= 0 && V < t; )
|
|
1566
|
+
V += o(D), D--;
|
|
1567
|
+
for (T = lt(D + 1, n), k = 0, _ = T; _ < n && k < t; )
|
|
1568
|
+
k += o(_), _++;
|
|
1569
|
+
}
|
|
1570
|
+
const tt = lt(T - e, n), Y = lt(Math.max(_ - 1, T), n), ut = lt(Y + e, n);
|
|
1571
|
+
return { renderingStartIndex: tt, renderingEndIndex: ut, visibleStartIndex: T, visibleEndIndex: Y };
|
|
1572
|
+
}, fn = () => typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now(), ve = (r, t, e) => {
|
|
1573
|
+
const n = Math.max(0, t ?? 0), o = w({
|
|
1574
|
+
lastInvokeAt: 0,
|
|
1575
|
+
rafId: null,
|
|
1576
|
+
pendingPayload: null,
|
|
1577
|
+
loopActive: !1,
|
|
1578
|
+
normalizedThrottle: n
|
|
1579
|
+
}), a = M(() => {
|
|
1580
|
+
const l = o.current;
|
|
1581
|
+
l.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(l.rafId), l.rafId = null, l.loopActive = !1;
|
|
1582
|
+
}, []), u = M(
|
|
1583
|
+
(l) => {
|
|
1584
|
+
const c = o.current;
|
|
1585
|
+
c.rafId = null;
|
|
1586
|
+
const d = typeof l == "number" ? l : fn(), h = c.normalizedThrottle, b = c.pendingPayload, T = r.current;
|
|
1587
|
+
if (b !== null && T) {
|
|
1588
|
+
const k = d - c.lastInvokeAt;
|
|
1589
|
+
(h === 0 || c.lastInvokeAt === 0 || k >= h) && (c.pendingPayload = null, c.lastInvokeAt = d, e(T, b));
|
|
1590
|
+
}
|
|
1591
|
+
if (c.pendingPayload !== null) {
|
|
1592
|
+
typeof requestAnimationFrame == "function" ? c.rafId = requestAnimationFrame(u) : c.loopActive = !1;
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
c.loopActive = !1;
|
|
1596
|
+
},
|
|
1597
|
+
[r, e]
|
|
1598
|
+
), f = M(() => {
|
|
1599
|
+
const l = o.current;
|
|
1600
|
+
if (!l.loopActive) {
|
|
1601
|
+
if (l.loopActive = !0, typeof requestAnimationFrame == "function") {
|
|
1602
|
+
l.rafId = requestAnimationFrame(u);
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
l.loopActive = !1;
|
|
1606
|
+
}
|
|
1607
|
+
}, [u]);
|
|
1608
|
+
return L(() => () => {
|
|
1609
|
+
a(), o.current.pendingPayload = null;
|
|
1610
|
+
}, [a]), L(() => {
|
|
1611
|
+
a();
|
|
1612
|
+
const l = o.current;
|
|
1613
|
+
l.lastInvokeAt = 0, l.pendingPayload = null, l.normalizedThrottle = n;
|
|
1614
|
+
}, [n, a]), M(
|
|
1615
|
+
(l) => {
|
|
1616
|
+
const c = o.current;
|
|
1617
|
+
c.pendingPayload = l, f();
|
|
1618
|
+
},
|
|
1619
|
+
[f]
|
|
1620
|
+
);
|
|
1621
|
+
}, pn = ({
|
|
1622
|
+
itemCount: r,
|
|
1623
|
+
getItem: t,
|
|
1624
|
+
getItemHeight: e,
|
|
1625
|
+
viewportSize: n,
|
|
1626
|
+
overscanCount: o = 15,
|
|
1627
|
+
className: a,
|
|
1628
|
+
onScroll: u,
|
|
1629
|
+
onRangeChange: f,
|
|
1630
|
+
children: l,
|
|
1631
|
+
background: c,
|
|
1632
|
+
initialScrollIndex: d,
|
|
1633
|
+
initialScrollOffset: h,
|
|
1634
|
+
tapScrollCircleOptions: b,
|
|
1635
|
+
scrollBarWidth: T,
|
|
1636
|
+
enableThumbDrag: k,
|
|
1637
|
+
enableTrackClick: _,
|
|
1638
|
+
enableArrowButtons: tt,
|
|
1639
|
+
enablePointerDrag: Y,
|
|
1640
|
+
inertiaOptions: ut,
|
|
1641
|
+
callbackThrottleMs: V = 5,
|
|
1642
|
+
renderThumbOverlay: D,
|
|
1643
|
+
wheelSpeedMultiplier: X,
|
|
1644
|
+
contentInsets: O,
|
|
1645
|
+
enableKeyboardNavigation: R = !0
|
|
1646
|
+
}, H) => {
|
|
1647
|
+
const q = w(null), N = w(!1), g = Vt(() => cn(O), [O]), C = w({ size: r, valueOrFn: e, options: { sampleRange: { from: 0, to: 100 } } }), P = on(C.current.size, C.current.valueOrFn, C.current.options), [j] = Yt(() => {
|
|
1648
|
+
let s = g.top, I = 0;
|
|
1246
1649
|
if (typeof d == "number") {
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
} else typeof
|
|
1250
|
-
return { position:
|
|
1251
|
-
}), [
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1650
|
+
const y = pt(d, 0, r - 1), F = pt(y - o * 2, 0, r - 1), B = pt(y + o * 2, 0, r - 1), K = d > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: F, to: B }] } } : void 0, { cumulative: Mt, total: zt, currentValue: Ft } = P.prefixSum(d, K), Xt = Math.max(Mt - Ft, 0);
|
|
1651
|
+
s = Qt(Xt, g.top), I = zt ?? P.getTotal();
|
|
1652
|
+
} else typeof h == "number" && (s = Qt(Math.max(h, 0), g.top)), I = P.getTotal();
|
|
1653
|
+
return { position: s, total: I };
|
|
1654
|
+
}), [rt, Ct] = Yt(j.position), [ot, $] = Yt(j.total), [ct, dt] = Yt(j.position), [A, S] = Yt(r), v = w(j.position), it = w(g.top), W = w(u ?? void 0), G = w(f ?? void 0), ft = w(/* @__PURE__ */ new Map()), et = w(null), st = w(null);
|
|
1655
|
+
L(() => {
|
|
1656
|
+
W.current = u ?? void 0, G.current = f ?? void 0;
|
|
1657
|
+
}, [f, u]);
|
|
1658
|
+
const nt = M(
|
|
1659
|
+
(s) => {
|
|
1660
|
+
if (R && s && typeof s.focus == "function")
|
|
1661
|
+
try {
|
|
1662
|
+
s.focus({ preventScroll: !0 });
|
|
1663
|
+
} catch {
|
|
1664
|
+
s.focus();
|
|
1665
|
+
}
|
|
1666
|
+
},
|
|
1667
|
+
[R]
|
|
1668
|
+
), gt = ve(W, V, (s, { position: I, totalHeight: y }) => {
|
|
1669
|
+
s(I, y);
|
|
1670
|
+
}), mt = ve(G, V, (s, { renderingStartIndex: I, renderingEndIndex: y, visibleStartIndex: F, visibleEndIndex: B, scrollPosition: K, totalHeight: Mt }) => {
|
|
1671
|
+
s(I, y, F, B, K, Mt);
|
|
1672
|
+
});
|
|
1673
|
+
L(() => (N.current = !0, () => {
|
|
1674
|
+
N.current = !1;
|
|
1675
|
+
}), []), L(() => {
|
|
1676
|
+
R || (ft.current.clear(), et.current = null, st.current = null);
|
|
1677
|
+
}, [R]);
|
|
1678
|
+
const xt = 0.01, St = w({
|
|
1679
|
+
rafId: null,
|
|
1680
|
+
loopActive: !1,
|
|
1681
|
+
idleFrames: 0,
|
|
1682
|
+
lastRenderedPosition: j.position
|
|
1683
|
+
}), Et = M(() => {
|
|
1684
|
+
const s = St.current;
|
|
1685
|
+
s.rafId !== null && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(s.rafId), s.rafId = null, s.loopActive = !1, s.idleFrames = 0;
|
|
1686
|
+
}, []);
|
|
1687
|
+
L(
|
|
1688
|
+
() => () => {
|
|
1689
|
+
Et();
|
|
1690
|
+
},
|
|
1691
|
+
[Et]
|
|
1692
|
+
);
|
|
1693
|
+
const Dt = M(() => {
|
|
1694
|
+
const s = St.current;
|
|
1695
|
+
s.rafId = null;
|
|
1696
|
+
const I = v.current, y = qt(I, g.top), F = P.getTotal();
|
|
1697
|
+
if (Ct((K) => Math.abs(K - I) < xt ? K : I), gt({ position: y, totalHeight: F }), Math.abs(s.lastRenderedPosition - I) >= xt ? (s.lastRenderedPosition = I, s.idleFrames = 0) : s.idleFrames += 1, s.idleFrames >= 2) {
|
|
1698
|
+
Et();
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
if (typeof requestAnimationFrame == "function") {
|
|
1702
|
+
s.rafId = requestAnimationFrame(Dt);
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
s.loopActive = !1;
|
|
1706
|
+
}, [P, g.top, gt, Et]), p = M(() => {
|
|
1707
|
+
const s = St.current;
|
|
1708
|
+
if (s.idleFrames = 0, !s.loopActive) {
|
|
1709
|
+
if (s.loopActive = !0, typeof requestAnimationFrame == "function") {
|
|
1710
|
+
s.rafId = requestAnimationFrame(Dt);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
s.loopActive = !1;
|
|
1714
|
+
}
|
|
1715
|
+
}, [Dt]), m = M(
|
|
1716
|
+
(s, I) => {
|
|
1717
|
+
const y = I?.immediate ?? !1, F = qt(s, g.top);
|
|
1718
|
+
if (v.current = s, y) {
|
|
1719
|
+
St.current.lastRenderedPosition = s, St.current.idleFrames = 0, Ct(s), gt({ position: F, totalHeight: P.getTotal() });
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
p();
|
|
1723
|
+
},
|
|
1724
|
+
[p, P, g.top, gt]
|
|
1725
|
+
), ht = w(!1);
|
|
1726
|
+
L(() => {
|
|
1727
|
+
if (!ht.current)
|
|
1728
|
+
if (ht.current = !0, typeof h == "number") {
|
|
1729
|
+
const s = Qt(Math.max(h, 0), g.top), I = Math.abs(s - v.current) > 0.5;
|
|
1730
|
+
m(s, { immediate: !0 }), I && dt(s);
|
|
1731
|
+
} else
|
|
1732
|
+
m(v.current, { immediate: !0 });
|
|
1733
|
+
}, [h, g.top, m]), se(() => {
|
|
1734
|
+
P.setValueFn(e), A !== r && (P.changeSize(r), S(r));
|
|
1735
|
+
const s = P.getTotal();
|
|
1736
|
+
ot !== s && $(s);
|
|
1737
|
+
}, [P, A, r, ot, e]), se(() => {
|
|
1738
|
+
ct !== null && q.current && (wt.debug("[VirtualScroll] Scrolling to position:", ct), q.current.scrollTo(ct), dt(null));
|
|
1739
|
+
}, [ct]), L(() => {
|
|
1740
|
+
const s = it.current;
|
|
1741
|
+
if (s === g.top)
|
|
1742
|
+
return;
|
|
1743
|
+
const I = qt(v.current, s), y = Qt(I, g.top);
|
|
1744
|
+
it.current = g.top, v.current = y, dt(y), m(y, { immediate: !0 });
|
|
1745
|
+
}, [g.top, m]);
|
|
1746
|
+
const Z = M(
|
|
1747
|
+
(s) => {
|
|
1748
|
+
if (!q.current)
|
|
1262
1749
|
return;
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1750
|
+
const I = lt(s, A), y = lt(I - o * 2, A), F = lt(I + o * 2, A), { cumulative: B, total: K, currentValue: Mt } = P.prefixSum(I, { materializeOption: { materialize: !0, ranges: [{ from: y, to: F }] } });
|
|
1751
|
+
if (wt.debug("[VirtualScroll] Scrolling to index:", I, "Offset:", B, "Total height:", K, "Current value:", Mt, "safeIndexFrom:", y, "safeIndexTo:", F), !K)
|
|
1752
|
+
return;
|
|
1753
|
+
const zt = Math.max(B - Mt, 0), Ft = Qt(zt, g.top);
|
|
1754
|
+
$(K), dt(Ft), wt.debug("[VirtualScroll] Setting scroll position to:", Ft);
|
|
1265
1755
|
},
|
|
1266
|
-
[
|
|
1267
|
-
),
|
|
1268
|
-
(
|
|
1269
|
-
if (!
|
|
1756
|
+
[P, o, A, g.top]
|
|
1757
|
+
), z = M(
|
|
1758
|
+
(s) => {
|
|
1759
|
+
if (!q.current)
|
|
1270
1760
|
return;
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1761
|
+
const I = P.getTotal(), y = pt(Math.floor(s), 0, I), F = P.findIndexAtOrAfter(y, { materializeOption: { materialize: !1 } }).index;
|
|
1762
|
+
Z(F);
|
|
1273
1763
|
},
|
|
1274
|
-
[
|
|
1275
|
-
),
|
|
1276
|
-
(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1764
|
+
[P, Z]
|
|
1765
|
+
), Rt = M(
|
|
1766
|
+
(s) => {
|
|
1767
|
+
const I = qt(v.current, g.top), y = typeof s == "function" ? s(I) : s;
|
|
1768
|
+
z(y);
|
|
1769
|
+
const F = q.current?.getScrollPosition(), B = typeof F == "number" ? F : v.current;
|
|
1770
|
+
return m(B), B;
|
|
1280
1771
|
},
|
|
1281
|
-
[
|
|
1282
|
-
),
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1772
|
+
[g.top, z, m]
|
|
1773
|
+
), It = M(
|
|
1774
|
+
(s, I) => {
|
|
1775
|
+
wt.debug("[VirtualScroll] Scroll position changed:", s), m(s);
|
|
1776
|
+
},
|
|
1777
|
+
[m]
|
|
1778
|
+
), At = Vt(() => qt(rt, g.top), [g.top, rt]), Tt = Vt(() => {
|
|
1779
|
+
const s = dn(At, n, o, A, e, P);
|
|
1780
|
+
return wt.debug("[VirtualScroll] Calculated rendering range:", {
|
|
1781
|
+
...s,
|
|
1782
|
+
scrollPosition: At,
|
|
1783
|
+
renderingContentSize: P.getTotal(),
|
|
1784
|
+
overscanCount: o,
|
|
1289
1785
|
viewportSize: n
|
|
1290
|
-
}),
|
|
1291
|
-
}, [
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
const
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1786
|
+
}), s;
|
|
1787
|
+
}, [At, n, o, A, e, P]), { renderingStartIndex: _t, renderingEndIndex: Ut, visibleStartIndex: vt, visibleEndIndex: Ot } = Tt, at = M(
|
|
1788
|
+
(s, I) => {
|
|
1789
|
+
if (!R || A === 0)
|
|
1790
|
+
return;
|
|
1791
|
+
const y = lt(s, A);
|
|
1792
|
+
if (!(I?.ensureVisible ?? !0)) {
|
|
1793
|
+
const Wt = ft.current.get(y);
|
|
1794
|
+
Wt && (et.current = null, st.current = y, nt(Wt));
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
const B = P.prefixSum(y, { materializeOption: { materialize: !1 } }), K = B.currentValue, Mt = Math.max(B.cumulative - K, 0), zt = Mt + K, Ft = qt(v.current, g.top), Xt = Ft + n;
|
|
1798
|
+
if (Mt < Ft || zt > Xt) {
|
|
1799
|
+
et.current = y, Z(y);
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
const Ht = ft.current.get(y);
|
|
1803
|
+
if (Ht) {
|
|
1804
|
+
et.current = null, st.current = y, nt(Ht);
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1807
|
+
et.current = y;
|
|
1808
|
+
},
|
|
1809
|
+
[R, A, P, g.top, Z, nt, n]
|
|
1810
|
+
), yt = M(
|
|
1811
|
+
(s, I) => {
|
|
1812
|
+
if (!R || s.defaultPrevented || s.altKey || s.metaKey || s.ctrlKey)
|
|
1813
|
+
return;
|
|
1814
|
+
const y = s.target;
|
|
1815
|
+
if (y) {
|
|
1816
|
+
const F = y.tagName;
|
|
1817
|
+
if (F === "INPUT" || F === "TEXTAREA" || F === "SELECT" || y.isContentEditable)
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
if (s.key === "ArrowDown") {
|
|
1821
|
+
I < A - 1 && (s.preventDefault(), at(I + 1));
|
|
1822
|
+
return;
|
|
1823
|
+
}
|
|
1824
|
+
if (s.key === "ArrowUp") {
|
|
1825
|
+
I > 0 && (s.preventDefault(), at(I - 1));
|
|
1826
|
+
return;
|
|
1827
|
+
}
|
|
1828
|
+
if (s.key === "PageDown") {
|
|
1829
|
+
if (I < A - 1) {
|
|
1830
|
+
s.preventDefault();
|
|
1831
|
+
const F = Math.max(Ot - vt + 1, 1), B = Math.max(F, 1), K = lt(Math.min(I + B, A - 1), A);
|
|
1832
|
+
at(K);
|
|
1833
|
+
}
|
|
1834
|
+
return;
|
|
1313
1835
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1836
|
+
if (s.key === "PageUp" && I > 0) {
|
|
1837
|
+
s.preventDefault();
|
|
1838
|
+
const F = Math.max(Ot - vt + 1, 1), B = Math.max(F, 1), K = lt(I - B, A);
|
|
1839
|
+
at(K);
|
|
1840
|
+
}
|
|
1841
|
+
},
|
|
1842
|
+
[R, A, at, Ot, vt]
|
|
1843
|
+
), Bt = M(
|
|
1844
|
+
(s) => {
|
|
1845
|
+
if (!R)
|
|
1846
|
+
return;
|
|
1847
|
+
const I = lt(s, A);
|
|
1848
|
+
et.current = null, st.current = I;
|
|
1849
|
+
},
|
|
1850
|
+
[R, A]
|
|
1851
|
+
);
|
|
1852
|
+
L(() => {
|
|
1853
|
+
const s = q.current?.getScrollPosition() ?? 0, I = v.current, y = qt(I, g.top);
|
|
1854
|
+
wt.debug("[VirtualScroll] Range change effect triggered", {
|
|
1855
|
+
renderingStartIndex: _t,
|
|
1856
|
+
renderingEndIndex: Ut,
|
|
1857
|
+
visibleStartIndex: vt,
|
|
1858
|
+
visibleEndIndex: Ot,
|
|
1859
|
+
scrollPositionState: rt,
|
|
1860
|
+
paneScrollPosition: I,
|
|
1861
|
+
logicalScrollPosition: y,
|
|
1862
|
+
contentSize: ot,
|
|
1863
|
+
scrollPaneScrollPosition: s
|
|
1864
|
+
}), mt({
|
|
1865
|
+
renderingStartIndex: _t,
|
|
1866
|
+
renderingEndIndex: Ut,
|
|
1867
|
+
visibleStartIndex: vt,
|
|
1868
|
+
visibleEndIndex: Ot,
|
|
1869
|
+
scrollPosition: y,
|
|
1870
|
+
totalHeight: ot
|
|
1871
|
+
});
|
|
1872
|
+
}, [ot, Ut, _t, g.top, mt, rt, Ot, vt]);
|
|
1873
|
+
const te = M(
|
|
1874
|
+
(s) => {
|
|
1875
|
+
const I = (V ?? 0) > 0, y = Math.abs(s - rt), F = I && y > 0.5 ? rt : s, B = qt(F, g.top);
|
|
1876
|
+
if (wt.debug("[VirtualScroll] Rendering visible items", {
|
|
1877
|
+
currentScrollPosition: s,
|
|
1878
|
+
effectiveScrollPosition: B,
|
|
1879
|
+
renderingStartIndex: _t,
|
|
1880
|
+
renderingEndIndex: Ut,
|
|
1881
|
+
fenwickSize: A,
|
|
1882
|
+
viewportSize: n,
|
|
1883
|
+
callbackThrottleMs: V,
|
|
1884
|
+
diff: y,
|
|
1885
|
+
rawEffectiveScrollPosition: F
|
|
1886
|
+
}), A === 0)
|
|
1887
|
+
return /* @__PURE__ */ Q("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ Q("div", { className: "text-center text-gray-500", children: "No items" }) });
|
|
1888
|
+
const K = lt(_t, A), Mt = lt(Ut, A), { cumulative: zt, currentValue: Ft } = P.prefixSum(K, { materializeOption: { materialize: !1 } }), Xt = zt - Ft, $t = [], Ht = [];
|
|
1889
|
+
for (let U = K; U <= Mt; U++) {
|
|
1890
|
+
const Kt = e(U);
|
|
1891
|
+
P.get(U) !== Kt && $t.push({ index: U, value: Kt });
|
|
1892
|
+
const { cumulative: ee, currentValue: i } = P.prefixSum(U, { materializeOption: { materialize: !1 } }), x = ee - i, E = (J) => {
|
|
1893
|
+
if (!J) {
|
|
1894
|
+
ft.current.delete(U);
|
|
1895
|
+
return;
|
|
1896
|
+
}
|
|
1897
|
+
R && (ft.current.set(U, J), et.current === U && (et.current = null, st.current = U, nt(J)));
|
|
1898
|
+
};
|
|
1899
|
+
Ht.push(
|
|
1900
|
+
/* @__PURE__ */ Q(
|
|
1901
|
+
"div",
|
|
1902
|
+
{
|
|
1903
|
+
ref: E,
|
|
1904
|
+
"data-index": U,
|
|
1905
|
+
"data-virtualscroll-item": "true",
|
|
1906
|
+
style: {
|
|
1907
|
+
position: "absolute",
|
|
1908
|
+
top: x - Xt + g.top,
|
|
1909
|
+
width: "100%"
|
|
1910
|
+
},
|
|
1911
|
+
tabIndex: R ? -1 : void 0,
|
|
1912
|
+
onKeyDownCapture: R ? (J) => yt(J, U) : void 0,
|
|
1913
|
+
onFocusCapture: R ? () => Bt(U) : void 0,
|
|
1914
|
+
children: l(t(U), U)
|
|
1915
|
+
},
|
|
1916
|
+
U
|
|
1917
|
+
)
|
|
1918
|
+
);
|
|
1919
|
+
}
|
|
1920
|
+
$t.length > 0 && Promise.resolve().then(() => {
|
|
1921
|
+
if (!N.current)
|
|
1922
|
+
return;
|
|
1923
|
+
const U = P.updates($t);
|
|
1924
|
+
if (!N.current || typeof U != "number")
|
|
1925
|
+
return;
|
|
1926
|
+
$(U), wt.debug("[VirtualScroll] Updated heights for items", $t, "New total height:", U);
|
|
1927
|
+
const Kt = q.current?.getScrollPosition() ?? v.current;
|
|
1928
|
+
Kt === v.current || !N.current || m(Kt);
|
|
1317
1929
|
});
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1930
|
+
const Wt = Xt - B;
|
|
1931
|
+
if (g.bottom > 0) {
|
|
1932
|
+
const U = P.getTotal() + g.top - Xt;
|
|
1933
|
+
Ht.push(
|
|
1934
|
+
/* @__PURE__ */ Q(
|
|
1935
|
+
"div",
|
|
1936
|
+
{
|
|
1937
|
+
style: {
|
|
1938
|
+
position: "absolute",
|
|
1939
|
+
top: U,
|
|
1940
|
+
height: g.bottom,
|
|
1941
|
+
width: "100%"
|
|
1942
|
+
}
|
|
1329
1943
|
},
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
c
|
|
1944
|
+
"virtualscroll-bottom-inset"
|
|
1945
|
+
)
|
|
1333
1946
|
);
|
|
1334
|
-
}
|
|
1947
|
+
}
|
|
1948
|
+
return wt.debug("[VirtualScroll] Rendering items", {
|
|
1949
|
+
nodeCount: Ht.length,
|
|
1950
|
+
containerTop: Wt,
|
|
1951
|
+
logicalScrollPosition: At,
|
|
1952
|
+
resolvedInsets: g,
|
|
1953
|
+
effectiveScrollPosition: B
|
|
1954
|
+
}), /* @__PURE__ */ Q("div", { className: "absolute w-full", style: { top: Wt }, children: Ht });
|
|
1335
1955
|
},
|
|
1336
|
-
[
|
|
1956
|
+
[
|
|
1957
|
+
V,
|
|
1958
|
+
l,
|
|
1959
|
+
R,
|
|
1960
|
+
P,
|
|
1961
|
+
A,
|
|
1962
|
+
t,
|
|
1963
|
+
e,
|
|
1964
|
+
Bt,
|
|
1965
|
+
yt,
|
|
1966
|
+
At,
|
|
1967
|
+
Ut,
|
|
1968
|
+
_t,
|
|
1969
|
+
g,
|
|
1970
|
+
rt,
|
|
1971
|
+
nt,
|
|
1972
|
+
m,
|
|
1973
|
+
n
|
|
1974
|
+
]
|
|
1975
|
+
);
|
|
1976
|
+
he(
|
|
1977
|
+
H,
|
|
1978
|
+
() => ({
|
|
1979
|
+
getScrollPosition: () => q.current?.getScrollPosition() ?? -1,
|
|
1980
|
+
getContentSize: () => q.current?.getContentSize() ?? -1,
|
|
1981
|
+
getViewportSize: () => q.current?.getViewportSize() ?? -1,
|
|
1982
|
+
scrollTo: Rt,
|
|
1983
|
+
scrollToIndex: Z,
|
|
1984
|
+
getFenwickTreeTotalHeight: () => P.getTotal(),
|
|
1985
|
+
getFenwickSize: () => P.getSize(),
|
|
1986
|
+
focusItemAtIndex: at
|
|
1987
|
+
}),
|
|
1988
|
+
[Rt, Z, P, at]
|
|
1337
1989
|
);
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
getViewportSize: () => _.current?.getViewportSize() ?? -1,
|
|
1342
|
-
scrollTo: C,
|
|
1343
|
-
scrollToIndex: L,
|
|
1344
|
-
getFenwickTreeTotalHeight: () => x.getTotal(),
|
|
1345
|
-
getFenwickSize: () => x.getSize()
|
|
1346
|
-
}), [C, L, x]), /* @__PURE__ */ $(
|
|
1347
|
-
gt,
|
|
1990
|
+
const ae = ot + g.top + g.bottom;
|
|
1991
|
+
return /* @__PURE__ */ Q(
|
|
1992
|
+
en,
|
|
1348
1993
|
{
|
|
1349
|
-
ref:
|
|
1350
|
-
contentSize:
|
|
1994
|
+
ref: q,
|
|
1995
|
+
contentSize: ae,
|
|
1351
1996
|
viewportSize: n,
|
|
1352
|
-
className:
|
|
1353
|
-
onScroll:
|
|
1354
|
-
background:
|
|
1355
|
-
tapScrollCircleOptions:
|
|
1356
|
-
inertiaOptions:
|
|
1357
|
-
itemCount:
|
|
1358
|
-
scrollBarWidth:
|
|
1359
|
-
enableThumbDrag:
|
|
1360
|
-
enableTrackClick:
|
|
1361
|
-
enableArrowButtons:
|
|
1362
|
-
enablePointerDrag:
|
|
1363
|
-
|
|
1997
|
+
className: a,
|
|
1998
|
+
onScroll: It,
|
|
1999
|
+
background: c,
|
|
2000
|
+
tapScrollCircleOptions: b,
|
|
2001
|
+
inertiaOptions: ut,
|
|
2002
|
+
itemCount: r,
|
|
2003
|
+
scrollBarWidth: T,
|
|
2004
|
+
enableThumbDrag: k,
|
|
2005
|
+
enableTrackClick: _,
|
|
2006
|
+
enableArrowButtons: tt,
|
|
2007
|
+
enablePointerDrag: Y,
|
|
2008
|
+
renderThumbOverlay: D,
|
|
2009
|
+
wheelSpeedMultiplier: X,
|
|
2010
|
+
contentInsets: g,
|
|
2011
|
+
children: te
|
|
1364
2012
|
}
|
|
1365
2013
|
);
|
|
1366
|
-
}
|
|
1367
|
-
const At = ke(St);
|
|
2014
|
+
}, bn = me(pn);
|
|
1368
2015
|
export {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
2016
|
+
rn as FenwickMapTree,
|
|
2017
|
+
tn as ScrollBar,
|
|
2018
|
+
en as ScrollPane,
|
|
2019
|
+
bn as VirtualScroll,
|
|
2020
|
+
pt as minmax,
|
|
2021
|
+
In as tapScrollCircleSampleVisual,
|
|
2022
|
+
on as useFenwickMapTree,
|
|
2023
|
+
Tn as useHeightCache,
|
|
2024
|
+
an as useLruCache
|
|
1378
2025
|
};
|
|
1379
|
-
//# sourceMappingURL=index.js.map
|