@aiquants/virtualscroll 1.0.0 → 1.2.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 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +745 -669
- package/dist/index.js.map +1 -1
- package/dist/src/ScrollBar.d.ts +24 -1
- package/dist/src/ScrollBar.d.ts.map +1 -1
- package/dist/src/ScrollPane.d.ts +5 -1
- package/dist/src/ScrollPane.d.ts.map +1 -1
- package/dist/src/VirtualScroll.d.ts +2 -0
- package/dist/src/VirtualScroll.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/virtualscroll.css +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as ke, useState as
|
|
3
|
-
import { twMerge as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as H, jsxs as Se, Fragment as rt } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ke, useState as pe, useRef as F, useCallback as y, useImperativeHandle as Ye, useMemo as Te, useEffect as se, useReducer as bt, useLayoutEffect as Ae, useId as Tt } from "react";
|
|
3
|
+
import { twMerge as Ie } from "tailwind-merge";
|
|
4
|
+
const Ze = {
|
|
5
5
|
active: !1,
|
|
6
6
|
offsetX: 0,
|
|
7
7
|
offsetY: 0,
|
|
8
8
|
distance: 0,
|
|
9
9
|
direction: 0
|
|
10
|
-
},
|
|
11
|
-
const t = 1 + e * 0.18, n = 0.16 + e * 0.24, r = 0.38 + e * 0.28,
|
|
12
|
-
return /* @__PURE__ */ Se(
|
|
13
|
-
/* @__PURE__ */
|
|
10
|
+
}, Je = 6, yt = ({ dragState: s, normalizedDistance: e }) => {
|
|
11
|
+
const t = 1 + e * 0.18, n = 0.16 + e * 0.24, r = 0.38 + e * 0.28, o = s.active ? "80ms ease-out" : "220ms ease";
|
|
12
|
+
return /* @__PURE__ */ Se(rt, { children: [
|
|
13
|
+
/* @__PURE__ */ H(
|
|
14
14
|
"div",
|
|
15
15
|
{
|
|
16
16
|
className: "absolute inset-0 rounded-full",
|
|
@@ -18,11 +18,11 @@ const Ke = {
|
|
|
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
20
|
transform: `scale(${t})`,
|
|
21
|
-
transition: `${
|
|
21
|
+
transition: `${o}, ${s.active ? "80ms" : "260ms"} box-shadow ease`
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
),
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ H(
|
|
26
26
|
"div",
|
|
27
27
|
{
|
|
28
28
|
className: "absolute inset-[18%] rounded-full",
|
|
@@ -30,693 +30,767 @@ const Ke = {
|
|
|
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
32
|
opacity: r,
|
|
33
|
-
transition:
|
|
33
|
+
transition: s.active ? "120ms opacity ease-out" : "220ms opacity ease"
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
)
|
|
37
37
|
] });
|
|
38
|
-
},
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
(
|
|
43
|
-
const { x:
|
|
44
|
-
|
|
45
|
-
active:
|
|
46
|
-
offsetX:
|
|
47
|
-
offsetY:
|
|
48
|
-
distance:
|
|
49
|
-
direction:
|
|
38
|
+
}, st = ke(({ onDragChange: s, className: e, maxVisualDistance: t = 160, size: n = 40, style: r, opacity: o = 1, renderVisual: i }, a) => {
|
|
39
|
+
const [f, c] = pe(Ze), u = F(null), p = F({ x: 0, y: 0 }), E = F(null), A = y((d) => {
|
|
40
|
+
c(d), s(d);
|
|
41
|
+
}, [s]), O = y(
|
|
42
|
+
(d, M, z = !1) => {
|
|
43
|
+
const { x: Z, y: h } = p.current, _ = d - Z, g = M - h, P = Math.abs(g), R = P < Je ? 0 : g < 0 ? -1 : 1;
|
|
44
|
+
A({
|
|
45
|
+
active: z || P >= Je,
|
|
46
|
+
offsetX: _,
|
|
47
|
+
offsetY: g,
|
|
48
|
+
distance: P,
|
|
49
|
+
direction: R
|
|
50
50
|
});
|
|
51
51
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
54
|
-
if (
|
|
52
|
+
[A]
|
|
53
|
+
), te = y((d) => {
|
|
54
|
+
if (d === null)
|
|
55
55
|
return;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
}, []),
|
|
59
|
-
(
|
|
60
|
-
|
|
56
|
+
const M = E.current;
|
|
57
|
+
M?.hasPointerCapture(d) && M.releasePointerCapture(d);
|
|
58
|
+
}, []), X = y(
|
|
59
|
+
(d = !1) => {
|
|
60
|
+
d && te(u.current), u.current = null, A(Ze);
|
|
61
61
|
},
|
|
62
|
-
[
|
|
63
|
-
),
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
p.current = { x:
|
|
62
|
+
[A, te]
|
|
63
|
+
), ne = y(
|
|
64
|
+
(d) => {
|
|
65
|
+
d.preventDefault(), d.stopPropagation();
|
|
66
|
+
const M = E.current ?? d.currentTarget, { left: z, top: Z, width: h, height: _ } = M.getBoundingClientRect();
|
|
67
|
+
p.current = { x: z + h / 2, y: Z + _ / 2 }, u.current = d.pointerId, M.setPointerCapture(d.pointerId), O(d.clientX, d.clientY, !0);
|
|
68
68
|
},
|
|
69
|
-
[
|
|
70
|
-
),
|
|
71
|
-
(
|
|
72
|
-
|
|
69
|
+
[O]
|
|
70
|
+
), S = y(
|
|
71
|
+
(d) => {
|
|
72
|
+
u.current === d.pointerId && (d.preventDefault(), O(d.clientX, d.clientY));
|
|
73
73
|
},
|
|
74
|
-
[
|
|
75
|
-
),
|
|
76
|
-
(
|
|
77
|
-
|
|
74
|
+
[O]
|
|
75
|
+
), ce = y(
|
|
76
|
+
(d) => {
|
|
77
|
+
u.current === d.pointerId && (d.preventDefault(), d.stopPropagation(), X(!0));
|
|
78
78
|
},
|
|
79
|
-
[
|
|
79
|
+
[X]
|
|
80
80
|
);
|
|
81
|
-
|
|
81
|
+
Ye(
|
|
82
82
|
a,
|
|
83
83
|
() => ({
|
|
84
84
|
reset: () => {
|
|
85
|
-
|
|
85
|
+
X(!0);
|
|
86
86
|
},
|
|
87
|
-
getElement: () =>
|
|
87
|
+
getElement: () => E.current
|
|
88
88
|
}),
|
|
89
|
-
[
|
|
89
|
+
[X]
|
|
90
90
|
);
|
|
91
|
-
const
|
|
92
|
-
dragState:
|
|
93
|
-
normalizedDistance:
|
|
94
|
-
sizeScale:
|
|
91
|
+
const le = Math.min(Math.max(o, 0), 1), G = n / 64, C = Math.min(f.distance, t) / t, K = f.direction * C * 10 * G, I = i ?? yt, x = {
|
|
92
|
+
dragState: f,
|
|
93
|
+
normalizedDistance: C,
|
|
94
|
+
sizeScale: G,
|
|
95
95
|
size: n,
|
|
96
|
-
opacity:
|
|
97
|
-
},
|
|
96
|
+
opacity: le
|
|
97
|
+
}, $ = {
|
|
98
98
|
...r,
|
|
99
99
|
width: n,
|
|
100
100
|
height: n,
|
|
101
|
-
transform: `translateY(${
|
|
101
|
+
transform: `translateY(${K}px)`
|
|
102
102
|
};
|
|
103
|
-
return
|
|
103
|
+
return $.opacity = le, /* @__PURE__ */ H(
|
|
104
104
|
"div",
|
|
105
105
|
{
|
|
106
|
-
ref:
|
|
107
|
-
className:
|
|
106
|
+
ref: E,
|
|
107
|
+
className: Ie(
|
|
108
108
|
"relative flex touch-none select-none items-center justify-center",
|
|
109
109
|
"transition-transform duration-100 ease-out",
|
|
110
110
|
e
|
|
111
111
|
),
|
|
112
|
-
style:
|
|
113
|
-
onPointerDown:
|
|
114
|
-
onPointerMove:
|
|
115
|
-
onPointerUp:
|
|
116
|
-
onPointerCancel:
|
|
112
|
+
style: $,
|
|
113
|
+
onPointerDown: ne,
|
|
114
|
+
onPointerMove: S,
|
|
115
|
+
onPointerUp: ce,
|
|
116
|
+
onPointerCancel: ce,
|
|
117
117
|
role: "presentation",
|
|
118
|
-
children:
|
|
118
|
+
children: I(x)
|
|
119
119
|
}
|
|
120
120
|
);
|
|
121
121
|
});
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
const n = "touches" in
|
|
122
|
+
st.displayName = "TapScrollCircle";
|
|
123
|
+
const W = (s, e, t) => Math.min(t, Math.max(e, s)), Qe = (s, e, t) => {
|
|
124
|
+
const n = "touches" in s.nativeEvent, r = n ? s.nativeEvent.touches[0] : s.nativeEvent, o = (a) => {
|
|
125
125
|
n && a.cancelable && a.preventDefault();
|
|
126
|
-
const
|
|
126
|
+
const f = "touches" in a ? a.touches[0] : a;
|
|
127
127
|
e({
|
|
128
|
-
deltaX:
|
|
129
|
-
deltaY:
|
|
128
|
+
deltaX: f.clientX - r.clientX,
|
|
129
|
+
deltaY: f.clientY - r.clientY
|
|
130
130
|
});
|
|
131
|
-
},
|
|
132
|
-
n ? (document.removeEventListener("touchmove",
|
|
131
|
+
}, i = () => {
|
|
132
|
+
n ? (document.removeEventListener("touchmove", o), document.removeEventListener("touchend", i)) : (document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", i)), t?.();
|
|
133
133
|
};
|
|
134
|
-
n ? (document.addEventListener("touchmove",
|
|
135
|
-
},
|
|
134
|
+
n ? (document.addEventListener("touchmove", o, { passive: !1 }), document.addEventListener("touchend", i)) : (document.addEventListener("mousemove", o), document.addEventListener("mouseup", i));
|
|
135
|
+
}, ze = "virtualscroll:tap-scroll-cancel", Be = 20, St = 250, wt = 60, It = 20, Mt = 20, Pt = 220, et = { active: !1, offsetX: 0, offsetY: 0, distance: 0, direction: 0 }, Oe = 2.2, Vt = 8, Et = 120, me = {
|
|
136
136
|
enabled: !0,
|
|
137
137
|
size: 40,
|
|
138
138
|
offsetX: -80,
|
|
139
139
|
offsetY: 0,
|
|
140
140
|
className: void 0,
|
|
141
|
-
maxVisualDistance:
|
|
141
|
+
maxVisualDistance: Pt,
|
|
142
|
+
minSpeedMultiplier: 0.2,
|
|
142
143
|
opacity: 1,
|
|
143
|
-
renderVisual: void 0
|
|
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
|
-
|
|
144
|
+
renderVisual: void 0,
|
|
145
|
+
maxSpeedCurve: void 0
|
|
146
|
+
}, Ct = (s) => s ? {
|
|
147
|
+
mainSizeKey: "width",
|
|
148
|
+
crossSizeKey: "height",
|
|
149
|
+
positionKey: "left",
|
|
150
|
+
selectDelta: (e, t) => e,
|
|
151
|
+
getPointerCoordinate: ({ clientX: e }) => e,
|
|
152
|
+
arrowLabels: ["Scroll left", "Scroll right"],
|
|
153
|
+
arrowIcons: ["◀", "▶"],
|
|
154
|
+
directionClass: "flex flex-row items-stretch",
|
|
155
|
+
orientation: "horizontal"
|
|
156
|
+
} : {
|
|
157
|
+
mainSizeKey: "height",
|
|
158
|
+
crossSizeKey: "width",
|
|
159
|
+
positionKey: "top",
|
|
160
|
+
selectDelta: (e, t) => t,
|
|
161
|
+
getPointerCoordinate: ({ clientY: e }) => e,
|
|
162
|
+
arrowLabels: ["Scroll up", "Scroll down"],
|
|
163
|
+
arrowIcons: ["▲", "▼"],
|
|
164
|
+
directionClass: "flex flex-col items-stretch",
|
|
165
|
+
orientation: "vertical"
|
|
166
|
+
}, At = (s, e) => {
|
|
167
|
+
const t = s?.maxSpeedMultiplier, n = typeof t == "number" ? t : Ft(e);
|
|
168
|
+
return {
|
|
169
|
+
enabled: s?.enabled ?? me.enabled,
|
|
170
|
+
size: s?.size ?? me.size,
|
|
171
|
+
offsetX: s?.offsetX ?? me.offsetX,
|
|
172
|
+
offsetY: s?.offsetY ?? me.offsetY,
|
|
173
|
+
className: s?.className ?? me.className,
|
|
174
|
+
maxVisualDistance: s?.maxVisualDistance ?? me.maxVisualDistance,
|
|
175
|
+
maxSpeedMultiplier: n,
|
|
176
|
+
minSpeedMultiplier: Math.max(s?.minSpeedMultiplier ?? me.minSpeedMultiplier, 0),
|
|
177
|
+
opacity: W(s?.opacity ?? me.opacity, 0, 1),
|
|
178
|
+
renderVisual: s?.renderVisual ?? me.renderVisual,
|
|
179
|
+
maxSpeedCurve: s?.maxSpeedCurve ?? me.maxSpeedCurve
|
|
180
|
+
};
|
|
181
|
+
}, _t = ({ thumbRef: s, isDragging: e, isThumbHovered: t, enableThumbDrag: n, horizontal: r }) => {
|
|
174
182
|
se(() => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
r || b(!1);
|
|
178
|
-
}, [r]), se(() => {
|
|
179
|
-
const s = Z.current;
|
|
180
|
-
if (!s)
|
|
183
|
+
const o = s.current;
|
|
184
|
+
if (!o)
|
|
181
185
|
return;
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
184
|
-
|
|
186
|
+
const i = r ? "scaleY(1.06)" : "scaleX(1.06)", a = r ? "scaleY(1.12)" : "scaleX(1.12)";
|
|
187
|
+
if (!n) {
|
|
188
|
+
o.style.removeProperty("transform"), o.style.backgroundColor = "#7F7F7F", o.style.removeProperty("transition");
|
|
185
189
|
return;
|
|
186
190
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
191
|
+
if (e) {
|
|
192
|
+
o.style.transform = a, o.style.backgroundColor = "#4F4F4F", o.style.transition = "transform 60ms ease-out";
|
|
189
193
|
return;
|
|
190
194
|
}
|
|
191
|
-
|
|
192
|
-
}, [r,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
o.style.transition = "transform 80ms ease-out", t ? (o.style.transform = i, o.style.backgroundColor = "#5F5F5F") : (o.style.removeProperty("transform"), o.style.backgroundColor = "#7F7F7F");
|
|
196
|
+
}, [n, r, e, t, s]);
|
|
197
|
+
}, Rt = ({ canUseArrowButtons: s, enableArrowButtons: e, resetTapScroll: t, scrollByStep: n }) => {
|
|
198
|
+
const r = F(null), o = F(null), i = y(() => {
|
|
199
|
+
r.current !== null && (window.clearInterval(r.current), r.current = null), o.current !== null && (window.clearTimeout(o.current), o.current = null);
|
|
200
|
+
}, []), a = y(() => {
|
|
201
|
+
i();
|
|
202
|
+
}, [i]), f = y(
|
|
203
|
+
(u) => (p) => {
|
|
204
|
+
s && (p.preventDefault(), p.stopPropagation(), t(), i(), n(u), o.current = window.setTimeout(() => {
|
|
205
|
+
r.current = window.setInterval(() => {
|
|
206
|
+
n(u);
|
|
207
|
+
}, wt);
|
|
208
|
+
}, St));
|
|
209
|
+
},
|
|
210
|
+
[s, i, t, n]
|
|
211
|
+
), c = y(
|
|
212
|
+
(u) => (p) => {
|
|
213
|
+
e && (p.key === "Enter" || p.key === " " || p.key === "Spacebar") && (p.preventDefault(), n(u));
|
|
214
|
+
},
|
|
215
|
+
[e, n]
|
|
216
|
+
);
|
|
217
|
+
return se(() => () => {
|
|
218
|
+
i();
|
|
219
|
+
}, [i]), { handleArrowPointerDown: f, handleArrowPointerUp: a, handleArrowKeyDown: c };
|
|
220
|
+
}, Ft = (s) => {
|
|
221
|
+
if (!s || s <= 0)
|
|
222
|
+
return Oe;
|
|
223
|
+
const e = Math.max(1, s), t = Math.log10(e), n = Oe + t * Vt;
|
|
224
|
+
return W(n, Oe, Et);
|
|
225
|
+
}, Lt = ({
|
|
226
|
+
contentSize: s,
|
|
227
|
+
viewportSize: e,
|
|
228
|
+
scrollPosition: t,
|
|
229
|
+
onScroll: n,
|
|
230
|
+
enableThumbDrag: r = !0,
|
|
231
|
+
enableTrackClick: o = !0,
|
|
232
|
+
enableArrowButtons: i = !0,
|
|
233
|
+
horizontal: a = !1,
|
|
234
|
+
scrollBarWidth: f = 12,
|
|
235
|
+
className: c,
|
|
236
|
+
ariaControls: u,
|
|
237
|
+
tapScrollCircleOptions: p,
|
|
238
|
+
itemCount: E,
|
|
239
|
+
renderThumbOverlay: A
|
|
240
|
+
}) => {
|
|
241
|
+
const [O, te] = pe(!1), [X, ne] = pe(!1), [S, ce] = pe(!1), le = F(null), G = F(t), C = F(et), K = F(null), I = F(null), x = F(null), $ = Te(() => At(p, E), [E, p]), d = Te(() => Ct(a), [a]), {
|
|
242
|
+
enabled: M,
|
|
243
|
+
size: z,
|
|
244
|
+
offsetX: Z,
|
|
245
|
+
offsetY: h,
|
|
246
|
+
className: _,
|
|
247
|
+
maxVisualDistance: g,
|
|
248
|
+
maxSpeedMultiplier: P,
|
|
249
|
+
minSpeedMultiplier: R,
|
|
250
|
+
opacity: k,
|
|
251
|
+
renderVisual: L,
|
|
252
|
+
maxSpeedCurve: v
|
|
253
|
+
} = $, { mainSizeKey: w, crossSizeKey: b, positionKey: T, selectDelta: V, getPointerCoordinate: J, arrowLabels: oe, arrowIcons: q, directionClass: Q, orientation: ie } = d, j = Math.max(g, 1), ge = e / s, D = f, l = Math.max(e - D * 2, 0), B = ge * l, U = Math.min(Math.max(Be, B || 0), l || Be), N = s - e, ue = Math.max(l - U, 0), xe = N <= 0 || ue <= 0 ? 0 : t / N * ue, ot = xe + U / 2, de = s > e, He = de && i;
|
|
254
|
+
se(() => {
|
|
255
|
+
G.current = t;
|
|
256
|
+
}, [t]), se(() => {
|
|
257
|
+
r || ne(!1);
|
|
258
|
+
}, [r]), _t({ thumbRef: le, isDragging: O, isThumbHovered: X, enableThumbDrag: r, horizontal: a });
|
|
259
|
+
const fe = y(() => {
|
|
260
|
+
I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null), x.current = null;
|
|
261
|
+
}, []), he = y(() => {
|
|
262
|
+
C.current = { ...et }, ce(!1), K.current?.reset(), fe();
|
|
263
|
+
}, [fe]), Me = y(
|
|
264
|
+
(m) => {
|
|
265
|
+
const Y = C.current;
|
|
266
|
+
if (!Y.active || Y.direction === 0) {
|
|
267
|
+
fe();
|
|
204
268
|
return;
|
|
205
269
|
}
|
|
206
|
-
if (!
|
|
207
|
-
|
|
270
|
+
if (!de || N <= 0) {
|
|
271
|
+
fe();
|
|
208
272
|
return;
|
|
209
273
|
}
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
|
|
274
|
+
const ee = x.current ?? m, re = Math.max((m - ee) / 1e3, 0);
|
|
275
|
+
if (x.current = m, re <= 0) {
|
|
276
|
+
I.current = window.requestAnimationFrame(Me);
|
|
213
277
|
return;
|
|
214
278
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
279
|
+
const ve = Math.min(Y.distance, j) / j, Re = ve ** 1.1, Ve = typeof p?.maxSpeedMultiplier == "number", ye = Math.max(e * R, 40), Fe = Ve ? ye : 1200;
|
|
280
|
+
let Le = Math.max(e * P, Fe);
|
|
281
|
+
if (v) {
|
|
282
|
+
const Ee = Math.max(v.exponentialSteepness, 0), pt = Math.max(v.exponentialScale ?? P, 0), gt = Ee === 0 ? ve : Math.expm1(Ee * ve), Ge = Ee === 0 ? 1 : Math.expm1(Ee) || 1, xt = Ge === 0 ? ve : Math.min(Math.max(gt / Ge, 0), 1), vt = e * pt * xt;
|
|
283
|
+
Le = Math.min(Le, Math.max(vt, ye));
|
|
284
|
+
}
|
|
285
|
+
const dt = Math.max(Le, ye), ft = Math.max(v?.easedOffset ?? 0, 0), ht = Math.min(1, Re + ft), mt = ye + (dt - ye) * ht, De = G.current, Ne = W(De + Y.direction * mt * re, 0, N);
|
|
286
|
+
if (Ne === De) {
|
|
287
|
+
fe();
|
|
218
288
|
return;
|
|
219
289
|
}
|
|
220
|
-
|
|
290
|
+
G.current = Ne, n?.(Ne, De), I.current = window.requestAnimationFrame(Me);
|
|
221
291
|
},
|
|
222
|
-
[
|
|
223
|
-
),
|
|
224
|
-
|
|
225
|
-
}, [
|
|
292
|
+
[j, N, n, de, fe, v, P, R, p, e]
|
|
293
|
+
), $e = y(() => {
|
|
294
|
+
I.current === null && (x.current = null, I.current = window.requestAnimationFrame(Me));
|
|
295
|
+
}, [Me]);
|
|
226
296
|
se(() => () => {
|
|
227
|
-
|
|
228
|
-
}, [
|
|
229
|
-
const
|
|
230
|
-
(
|
|
231
|
-
|
|
297
|
+
fe();
|
|
298
|
+
}, [fe]);
|
|
299
|
+
const it = y(
|
|
300
|
+
(m) => {
|
|
301
|
+
C.current = m, ce(m.active), m.active && m.direction !== 0 ? $e() : fe();
|
|
232
302
|
},
|
|
233
|
-
[
|
|
303
|
+
[$e, fe]
|
|
234
304
|
);
|
|
235
305
|
se(() => {
|
|
236
|
-
|
|
237
|
-
}, [
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
|
|
306
|
+
M || he();
|
|
307
|
+
}, [he, M]), se(() => {
|
|
308
|
+
const m = (Y) => {
|
|
309
|
+
const re = Y.detail?.paneId;
|
|
310
|
+
re && u && re !== u || he();
|
|
241
311
|
};
|
|
242
|
-
return window.addEventListener(
|
|
243
|
-
window.removeEventListener(
|
|
312
|
+
return window.addEventListener(ze, m), () => {
|
|
313
|
+
window.removeEventListener(ze, m);
|
|
244
314
|
};
|
|
245
|
-
}, [
|
|
246
|
-
if (!
|
|
315
|
+
}, [u, he]), se(() => {
|
|
316
|
+
if (!M)
|
|
247
317
|
return;
|
|
248
|
-
const
|
|
249
|
-
if (!
|
|
318
|
+
const m = (Y) => {
|
|
319
|
+
if (!C.current.active)
|
|
250
320
|
return;
|
|
251
|
-
const
|
|
252
|
-
if (!(
|
|
253
|
-
|
|
321
|
+
const ee = Y.target;
|
|
322
|
+
if (!(ee instanceof Node)) {
|
|
323
|
+
he();
|
|
254
324
|
return;
|
|
255
325
|
}
|
|
256
|
-
|
|
326
|
+
K.current?.getElement()?.contains(ee) || he();
|
|
257
327
|
};
|
|
258
|
-
return document.addEventListener("pointerdown",
|
|
259
|
-
document.removeEventListener("pointerdown",
|
|
328
|
+
return document.addEventListener("pointerdown", m, !0), () => {
|
|
329
|
+
document.removeEventListener("pointerdown", m, !0);
|
|
260
330
|
};
|
|
261
|
-
}, [
|
|
262
|
-
const
|
|
263
|
-
if (!
|
|
331
|
+
}, [he, M]);
|
|
332
|
+
const _e = (m) => {
|
|
333
|
+
if (!de || ue <= 0 || N <= 0)
|
|
264
334
|
return 0;
|
|
265
|
-
const
|
|
266
|
-
return
|
|
267
|
-
},
|
|
268
|
-
if (!
|
|
335
|
+
const Y = W(m, 0, ue);
|
|
336
|
+
return W(Y / ue * N, 0, N);
|
|
337
|
+
}, at = (m) => {
|
|
338
|
+
if (!de || N <= 0)
|
|
269
339
|
return;
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
}, Pe = (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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)
|
|
340
|
+
const Y = Math.max(Math.round(e / Mt), It), ee = G.current, re = W(ee + m * Y, 0, N);
|
|
341
|
+
re !== ee && (G.current = re, n?.(re, ee));
|
|
342
|
+
}, { handleArrowPointerDown: Xe, handleArrowPointerUp: Pe, handleArrowKeyDown: lt } = Rt({
|
|
343
|
+
canUseArrowButtons: He,
|
|
344
|
+
enableArrowButtons: i,
|
|
345
|
+
resetTapScroll: he,
|
|
346
|
+
scrollByStep: at
|
|
347
|
+
}), Ue = (m) => {
|
|
348
|
+
if (!de)
|
|
284
349
|
return;
|
|
285
350
|
if (!r) {
|
|
286
|
-
|
|
351
|
+
m.preventDefault(), m.stopPropagation();
|
|
287
352
|
return;
|
|
288
353
|
}
|
|
289
|
-
if ("button" in
|
|
354
|
+
if ("button" in m && m.button !== 0 || m.ctrlKey)
|
|
290
355
|
return;
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
({ deltaX:
|
|
296
|
-
const ve =
|
|
297
|
-
n?.(
|
|
356
|
+
m.stopPropagation(), he();
|
|
357
|
+
const Y = xe;
|
|
358
|
+
te(!0), ne(!0), Qe(
|
|
359
|
+
m,
|
|
360
|
+
({ deltaX: ee, deltaY: re }) => {
|
|
361
|
+
const ve = V(ee, re);
|
|
362
|
+
n?.(_e(Y + ve), xe);
|
|
298
363
|
},
|
|
299
364
|
() => {
|
|
300
|
-
|
|
365
|
+
te(!1), le.current && !le.current.matches(":hover") && ne(!1);
|
|
301
366
|
}
|
|
302
367
|
);
|
|
303
|
-
},
|
|
304
|
-
if (!
|
|
368
|
+
}, Ke = (m) => {
|
|
369
|
+
if (!de)
|
|
305
370
|
return;
|
|
306
|
-
if (!
|
|
307
|
-
|
|
371
|
+
if (!o) {
|
|
372
|
+
m.preventDefault(), m.stopPropagation();
|
|
308
373
|
return;
|
|
309
374
|
}
|
|
310
|
-
if ("button" in
|
|
375
|
+
if ("button" in m && m.button !== 0 || m.ctrlKey)
|
|
311
376
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
n?.(
|
|
316
|
-
const
|
|
317
|
-
n?.(
|
|
377
|
+
const ee = "touches" in m.nativeEvent ? m.nativeEvent.touches[0] : m.nativeEvent, re = J(ee), ve = m.currentTarget.getBoundingClientRect(), Re = re - (a ? ve.left : ve.top);
|
|
378
|
+
he();
|
|
379
|
+
const Ve = Re - U / 2;
|
|
380
|
+
n?.(_e(Ve), xe), Qe(m, ({ deltaX: ye, deltaY: Fe }) => {
|
|
381
|
+
const We = V(ye, Fe);
|
|
382
|
+
n?.(_e(Ve + We), xe);
|
|
318
383
|
});
|
|
319
|
-
},
|
|
320
|
-
const
|
|
384
|
+
}, ct = Te(() => W((S ? 1 : 0.8) * k, 0, 1), [S, k]), ut = Te(() => {
|
|
385
|
+
const Y = `calc(50% - ${z / 2}px + ${h}px)`;
|
|
321
386
|
return {
|
|
322
|
-
left:
|
|
323
|
-
top:
|
|
387
|
+
left: Z,
|
|
388
|
+
top: Y
|
|
324
389
|
};
|
|
325
|
-
}, [
|
|
390
|
+
}, [Z, h, z]), qe = (m, Y, ee) => /* @__PURE__ */ H(
|
|
326
391
|
"button",
|
|
327
392
|
{
|
|
328
393
|
type: "button",
|
|
329
394
|
className: "flex items-center justify-center text-[#313131] text-xs transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[#60a5fa] focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
330
395
|
style: {
|
|
331
|
-
[
|
|
332
|
-
[
|
|
396
|
+
[w]: D,
|
|
397
|
+
[b]: f,
|
|
333
398
|
backgroundColor: "#E0E0E0"
|
|
334
399
|
},
|
|
335
|
-
"aria-label":
|
|
336
|
-
onMouseDown:
|
|
337
|
-
onTouchStart:
|
|
400
|
+
"aria-label": Y,
|
|
401
|
+
onMouseDown: Xe(m),
|
|
402
|
+
onTouchStart: Xe(m),
|
|
338
403
|
onMouseUp: Pe,
|
|
339
404
|
onMouseLeave: Pe,
|
|
340
405
|
onTouchEnd: Pe,
|
|
341
406
|
onTouchCancel: Pe,
|
|
342
|
-
onKeyDown:
|
|
343
|
-
"aria-disabled": !
|
|
344
|
-
disabled: !
|
|
345
|
-
children: /* @__PURE__ */
|
|
407
|
+
onKeyDown: lt(m),
|
|
408
|
+
"aria-disabled": !i,
|
|
409
|
+
disabled: !He,
|
|
410
|
+
children: /* @__PURE__ */ H("span", { "aria-hidden": "true", children: ee })
|
|
346
411
|
}
|
|
347
|
-
)
|
|
412
|
+
), je = A && de ? {
|
|
413
|
+
orientation: ie,
|
|
414
|
+
scrollPosition: t,
|
|
415
|
+
maxScrollPosition: N,
|
|
416
|
+
contentSize: s,
|
|
417
|
+
viewportSize: e,
|
|
418
|
+
thumbSize: U,
|
|
419
|
+
thumbPosition: xe,
|
|
420
|
+
thumbCenter: ot,
|
|
421
|
+
trackSize: l,
|
|
422
|
+
isDragging: O,
|
|
423
|
+
isTapScrollActive: S
|
|
424
|
+
} : null;
|
|
348
425
|
return /* @__PURE__ */ Se(
|
|
349
426
|
"div",
|
|
350
427
|
{
|
|
351
|
-
className:
|
|
352
|
-
"group relative cursor-default select-none",
|
|
353
|
-
ne,
|
|
354
|
-
u
|
|
355
|
-
),
|
|
428
|
+
className: Ie("group relative cursor-default select-none", Q, c),
|
|
356
429
|
style: {
|
|
357
|
-
[
|
|
358
|
-
[
|
|
430
|
+
[w]: e,
|
|
431
|
+
[b]: f,
|
|
359
432
|
backgroundColor: "white",
|
|
360
433
|
userSelect: "none",
|
|
361
434
|
position: "relative"
|
|
362
435
|
},
|
|
363
436
|
role: "scrollbar",
|
|
364
437
|
tabIndex: -1,
|
|
365
|
-
"aria-controls":
|
|
438
|
+
"aria-controls": u,
|
|
366
439
|
"aria-valuenow": t,
|
|
367
440
|
"aria-valuemin": 0,
|
|
368
|
-
"aria-valuemax":
|
|
441
|
+
"aria-valuemax": N,
|
|
369
442
|
"aria-orientation": a ? "horizontal" : "vertical",
|
|
370
443
|
children: [
|
|
371
|
-
!a &&
|
|
372
|
-
|
|
444
|
+
!a && de && M && /* @__PURE__ */ H(
|
|
445
|
+
st,
|
|
373
446
|
{
|
|
374
|
-
ref:
|
|
375
|
-
className:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
opacity: nt,
|
|
383
|
-
renderVisual: y,
|
|
384
|
-
onDragChange: et
|
|
447
|
+
ref: K,
|
|
448
|
+
className: Ie("pointer-events-auto absolute transition-opacity duration-150", _),
|
|
449
|
+
size: z,
|
|
450
|
+
maxVisualDistance: j,
|
|
451
|
+
style: ut,
|
|
452
|
+
opacity: ct,
|
|
453
|
+
renderVisual: L,
|
|
454
|
+
onDragChange: it
|
|
385
455
|
}
|
|
386
456
|
),
|
|
387
|
-
|
|
388
|
-
/* @__PURE__ */
|
|
457
|
+
qe(-1, oe[0], q[0]),
|
|
458
|
+
/* @__PURE__ */ Se(
|
|
389
459
|
"div",
|
|
390
460
|
{
|
|
391
461
|
className: "relative flex-1",
|
|
392
462
|
style: {
|
|
393
463
|
backgroundColor: "#F5F5F5",
|
|
394
|
-
borderRadius:
|
|
464
|
+
borderRadius: f / 2
|
|
395
465
|
},
|
|
396
|
-
onMouseDown:
|
|
397
|
-
onTouchStart:
|
|
398
|
-
"aria-disabled": !
|
|
399
|
-
children:
|
|
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
|
-
|
|
466
|
+
onMouseDown: Ke,
|
|
467
|
+
onTouchStart: Ke,
|
|
468
|
+
"aria-disabled": !o,
|
|
469
|
+
children: [
|
|
470
|
+
je && /* @__PURE__ */ H("div", { className: "pointer-events-none absolute inset-0", "aria-hidden": !0, children: A?.(je) }),
|
|
471
|
+
de && // スクロールバーのつまみの当たり判定を広げるためのラッパー
|
|
472
|
+
/* @__PURE__ */ H(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
className: "group absolute",
|
|
476
|
+
style: {
|
|
477
|
+
[w]: U,
|
|
478
|
+
[T]: xe,
|
|
479
|
+
...a ? { top: 0, bottom: 0 } : { left: 0, right: 0 }
|
|
480
|
+
},
|
|
481
|
+
onMouseDown: Ue,
|
|
482
|
+
onTouchStart: Ue,
|
|
483
|
+
role: "slider",
|
|
484
|
+
"aria-orientation": a ? "horizontal" : "vertical",
|
|
485
|
+
"aria-valuenow": t,
|
|
486
|
+
"aria-valuemin": 0,
|
|
487
|
+
"aria-valuemax": N,
|
|
488
|
+
"aria-disabled": !r,
|
|
489
|
+
tabIndex: r ? 0 : -1,
|
|
490
|
+
children: /* @__PURE__ */ H(
|
|
491
|
+
"div",
|
|
492
|
+
{
|
|
493
|
+
ref: le,
|
|
494
|
+
className: Ie(
|
|
495
|
+
"absolute",
|
|
496
|
+
a ? `inset-x-0 inset-y-[1.5px] group-hover:inset-y-[-0.5px] ${O ? "-inset-y-0.5" : "group-active:-inset-y-0.5"}` : `inset-x-[1.5px] inset-y-0 group-hover:inset-x-[-0.5px] ${O ? "-inset-x-0.5" : "group-active:-inset-x-0.5"}`
|
|
497
|
+
),
|
|
498
|
+
style: {
|
|
499
|
+
backgroundColor: "#7F7F7F",
|
|
500
|
+
borderRadius: f - 1,
|
|
501
|
+
cursor: r ? "pointer" : "default",
|
|
502
|
+
...a ? {
|
|
503
|
+
left: 0,
|
|
504
|
+
right: 0,
|
|
505
|
+
top: 1.5,
|
|
506
|
+
bottom: 1.5
|
|
507
|
+
} : {
|
|
508
|
+
top: 0,
|
|
509
|
+
bottom: 0,
|
|
510
|
+
left: 1.5,
|
|
511
|
+
right: 1.5
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
onMouseEnter: () => {
|
|
515
|
+
r && ne(!0);
|
|
516
|
+
},
|
|
517
|
+
onMouseLeave: () => {
|
|
518
|
+
r && ne(!1);
|
|
440
519
|
}
|
|
441
|
-
},
|
|
442
|
-
onMouseEnter: () => {
|
|
443
|
-
r && b(!0);
|
|
444
|
-
},
|
|
445
|
-
onMouseLeave: () => {
|
|
446
|
-
r && b(!1);
|
|
447
520
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
]
|
|
452
525
|
}
|
|
453
526
|
),
|
|
454
|
-
|
|
527
|
+
qe(1, oe[1], q[1])
|
|
455
528
|
]
|
|
456
529
|
}
|
|
457
530
|
);
|
|
458
|
-
},
|
|
459
|
-
debug(
|
|
460
|
-
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${
|
|
531
|
+
}, ae = {
|
|
532
|
+
debug(s, ...e) {
|
|
533
|
+
typeof window < "u" && window.localStorage?.getItem("debug") === "true" && console.debug(`[VirtualScroll] ${s}`, ...e);
|
|
461
534
|
},
|
|
462
|
-
warn(
|
|
463
|
-
console.warn(`[VirtualScroll] ${
|
|
535
|
+
warn(s, ...e) {
|
|
536
|
+
console.warn(`[VirtualScroll] ${s}`, ...e);
|
|
464
537
|
},
|
|
465
|
-
error(
|
|
466
|
-
console.error(`[VirtualScroll] ${
|
|
538
|
+
error(s, ...e) {
|
|
539
|
+
console.error(`[VirtualScroll] ${s}`, ...e);
|
|
467
540
|
}
|
|
468
|
-
},
|
|
541
|
+
}, we = {
|
|
469
542
|
maxVelocity: 6,
|
|
470
543
|
minVelocity: 0.02,
|
|
471
544
|
deceleration: 25e-4,
|
|
472
545
|
velocitySampleWindow: 90,
|
|
473
546
|
startVelocityThreshold: 0.04
|
|
474
|
-
},
|
|
475
|
-
for (const [n, r,
|
|
476
|
-
t === "add" ?
|
|
477
|
-
},
|
|
478
|
-
const
|
|
547
|
+
}, Ce = (s, e, t) => {
|
|
548
|
+
for (const [n, r, o] of e)
|
|
549
|
+
t === "add" ? s.addEventListener(n, r, o) : s.removeEventListener(n, r, o);
|
|
550
|
+
}, Dt = ke(({ children: s, contentSize: e, viewportSize: t, scrollBarWidth: n = 12, enableThumbDrag: r = !0, enableTrackClick: o = !0, enableArrowButtons: i = !0, enablePointerDrag: a = !0, onScroll: f, className: c, style: u, background: p, tapScrollCircleOptions: E, inertiaOptions: A, itemCount: O, renderThumbOverlay: te, wheelSpeedMultiplier: X = 1 }, ne) => {
|
|
551
|
+
const S = F(0), [ce, le] = bt((h) => h + 1, 0), G = F(null), C = F(null), K = F({
|
|
479
552
|
frame: null,
|
|
480
553
|
velocity: 0,
|
|
481
554
|
lastTimestamp: null
|
|
482
|
-
}),
|
|
555
|
+
}), I = Te(
|
|
483
556
|
() => ({
|
|
484
|
-
maxVelocity:
|
|
485
|
-
minVelocity:
|
|
486
|
-
deceleration:
|
|
487
|
-
velocitySampleWindow:
|
|
488
|
-
startVelocityThreshold:
|
|
557
|
+
maxVelocity: A?.maxVelocity ?? we.maxVelocity,
|
|
558
|
+
minVelocity: A?.minVelocity ?? we.minVelocity,
|
|
559
|
+
deceleration: A?.deceleration ?? we.deceleration,
|
|
560
|
+
velocitySampleWindow: A?.velocitySampleWindow ?? we.velocitySampleWindow,
|
|
561
|
+
startVelocityThreshold: A?.startVelocityThreshold ?? we.startVelocityThreshold
|
|
489
562
|
}),
|
|
490
|
-
[
|
|
563
|
+
[A]
|
|
491
564
|
);
|
|
492
|
-
|
|
493
|
-
const x =
|
|
494
|
-
(
|
|
495
|
-
const { contentSize:
|
|
496
|
-
if (
|
|
497
|
-
|
|
565
|
+
ae.debug("[ScrollPane] ScrollPane rendered", { contentSize: e, viewportSize: t, scrollBarWidth: n, className: c, style: u, tapScrollCircleOptions: E, inertiaOptions: A, enablePointerDrag: a });
|
|
566
|
+
const x = F({ contentSize: e, viewportSize: t }), $ = Te(() => e > t, [e, t]), d = y(
|
|
567
|
+
(h) => {
|
|
568
|
+
const { contentSize: _, viewportSize: g } = x.current, P = _ > g, R = S.current;
|
|
569
|
+
if (ae.debug("[ScrollPane] scrollTo called", { newPosition: h, contentSize: _, viewportSize: g, currentIsScrollable: P, prevPosition: R }), !P) {
|
|
570
|
+
S.current !== 0 && (S.current = 0, f?.(0, R));
|
|
498
571
|
return;
|
|
499
572
|
}
|
|
500
|
-
const
|
|
501
|
-
|
|
573
|
+
const k = typeof h == "function" ? h(S.current) : h, L = W(k, 0, _ - g);
|
|
574
|
+
S.current !== L && (S.current = L, f?.(L, R));
|
|
502
575
|
},
|
|
503
|
-
[
|
|
504
|
-
),
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
}, []),
|
|
508
|
-
(
|
|
509
|
-
if (
|
|
576
|
+
[f]
|
|
577
|
+
), M = y(() => {
|
|
578
|
+
const h = K.current;
|
|
579
|
+
h.frame !== null && cancelAnimationFrame(h.frame), h.frame = null, h.velocity = 0, h.lastTimestamp = null;
|
|
580
|
+
}, []), z = y(
|
|
581
|
+
(h) => {
|
|
582
|
+
if (!$)
|
|
510
583
|
return;
|
|
511
|
-
const { maxVelocity:
|
|
512
|
-
if (Math.abs(
|
|
584
|
+
const { maxVelocity: _, minVelocity: g, deceleration: P, startVelocityThreshold: R } = I, k = W(h, -_, _);
|
|
585
|
+
if (Math.abs(k) < R)
|
|
513
586
|
return;
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
if (
|
|
518
|
-
|
|
587
|
+
M(), K.current.velocity = k, K.current.lastTimestamp = null;
|
|
588
|
+
const L = (v) => {
|
|
589
|
+
const w = K.current;
|
|
590
|
+
if (w.lastTimestamp === null) {
|
|
591
|
+
w.lastTimestamp = v, w.frame = requestAnimationFrame(L);
|
|
519
592
|
return;
|
|
520
593
|
}
|
|
521
|
-
const
|
|
522
|
-
if (
|
|
523
|
-
|
|
594
|
+
const b = v - w.lastTimestamp;
|
|
595
|
+
if (w.lastTimestamp = v, b <= 0) {
|
|
596
|
+
w.frame = requestAnimationFrame(L);
|
|
524
597
|
return;
|
|
525
598
|
}
|
|
526
|
-
const
|
|
527
|
-
let
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
if (Math.abs(
|
|
536
|
-
|
|
599
|
+
const T = w.velocity;
|
|
600
|
+
let V = T;
|
|
601
|
+
const J = P * b;
|
|
602
|
+
T > 0 ? V = Math.max(0, T - J) : T < 0 && (V = Math.min(0, T + J));
|
|
603
|
+
const q = (T + V) / 2 * b, Q = S.current;
|
|
604
|
+
q !== 0 && d((B) => B + q);
|
|
605
|
+
const ie = S.current, { contentSize: j, viewportSize: ge } = x.current, D = Math.max(j - ge, 0);
|
|
606
|
+
w.velocity = V;
|
|
607
|
+
const l = ie === Q || ie <= 0 && V <= 0 || ie >= D && V >= 0;
|
|
608
|
+
if (Math.abs(V) < g || l) {
|
|
609
|
+
M();
|
|
537
610
|
return;
|
|
538
611
|
}
|
|
539
|
-
|
|
612
|
+
w.frame = requestAnimationFrame(L);
|
|
540
613
|
};
|
|
541
|
-
|
|
614
|
+
K.current.frame = requestAnimationFrame(L);
|
|
542
615
|
},
|
|
543
|
-
[
|
|
616
|
+
[$, I, d, M]
|
|
544
617
|
);
|
|
545
|
-
|
|
618
|
+
Ae(() => {
|
|
546
619
|
x.current = { contentSize: e, viewportSize: t };
|
|
547
|
-
}, [e, t]),
|
|
548
|
-
if (
|
|
549
|
-
|
|
550
|
-
const
|
|
551
|
-
|
|
620
|
+
}, [e, t]), Ae(() => {
|
|
621
|
+
if ($) {
|
|
622
|
+
ae.debug("[ScrollPane] Adjusting scroll position due to content or viewport size change", { contentSize: e, viewportSize: t, scrollPosition: S.current });
|
|
623
|
+
const h = W(e - t, 0, e);
|
|
624
|
+
S.current > h && d(h);
|
|
552
625
|
} else
|
|
553
|
-
|
|
554
|
-
}, [
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
626
|
+
d(0);
|
|
627
|
+
}, [$, d, e, t]), se(() => {
|
|
628
|
+
const h = (g) => {
|
|
629
|
+
if (!$)
|
|
557
630
|
return;
|
|
558
|
-
g.preventDefault(),
|
|
559
|
-
let
|
|
560
|
-
g.deltaMode === 1 ?
|
|
561
|
-
},
|
|
562
|
-
return
|
|
563
|
-
|
|
631
|
+
g.preventDefault(), M();
|
|
632
|
+
let P = g.deltaY;
|
|
633
|
+
g.deltaMode === 1 ? P *= 16 : g.deltaMode === 2 && (P *= t), X !== 1 && (P *= X), ae.debug("[ScrollPane] wheel event", { deltaY: P, scrollPosition: S.current, wheelSpeedMultiplier: X }), d((R) => R + P);
|
|
634
|
+
}, _ = G.current;
|
|
635
|
+
return _ && _.addEventListener("wheel", h, { passive: !1 }), () => {
|
|
636
|
+
_ && _.removeEventListener("wheel", h);
|
|
564
637
|
};
|
|
565
|
-
}, [
|
|
566
|
-
|
|
638
|
+
}, [$, d, M, t, X]), Ye(
|
|
639
|
+
ne,
|
|
567
640
|
() => ({
|
|
568
|
-
scrollTo:
|
|
569
|
-
getScrollPosition: () =>
|
|
641
|
+
scrollTo: d,
|
|
642
|
+
getScrollPosition: () => S.current,
|
|
570
643
|
getContentSize: () => e,
|
|
571
644
|
getViewportSize: () => t
|
|
572
645
|
}),
|
|
573
|
-
[
|
|
646
|
+
[d, e, t]
|
|
574
647
|
);
|
|
575
|
-
const
|
|
648
|
+
const Z = Tt();
|
|
576
649
|
return se(() => {
|
|
577
|
-
const
|
|
578
|
-
if (!
|
|
650
|
+
const h = C.current;
|
|
651
|
+
if (!h)
|
|
579
652
|
return;
|
|
580
653
|
if (!a) {
|
|
581
|
-
|
|
654
|
+
M();
|
|
582
655
|
return;
|
|
583
656
|
}
|
|
584
|
-
const
|
|
585
|
-
let g = null,
|
|
586
|
-
const
|
|
587
|
-
g = null,
|
|
588
|
-
},
|
|
589
|
-
const
|
|
590
|
-
|
|
591
|
-
},
|
|
592
|
-
|
|
593
|
-
}, oe = (
|
|
594
|
-
|
|
595
|
-
},
|
|
596
|
-
if (g !==
|
|
657
|
+
const _ = 6;
|
|
658
|
+
let g = null, P = 0, R = 0, k = !1, L = !1, v = null, w = [];
|
|
659
|
+
const b = () => {
|
|
660
|
+
g = null, P = 0, R = 0, k = !1, w = [];
|
|
661
|
+
}, T = (l) => {
|
|
662
|
+
const B = performance.now();
|
|
663
|
+
w.push({ clientY: l, time: B }), w = w.filter((U) => B - U.time <= I.velocitySampleWindow);
|
|
664
|
+
}, V = (l) => l instanceof HTMLElement && l.closest("[data-scrollpane-ignore-drag='true']") !== null, J = (l) => {
|
|
665
|
+
L && (l.preventDefault(), l.stopPropagation(), L = !1);
|
|
666
|
+
}, oe = (l) => {
|
|
667
|
+
k || (k = !0, L = !0, h.hasPointerCapture(l.pointerId) || h.setPointerCapture(l.pointerId), T(l.clientY));
|
|
668
|
+
}, q = (l) => {
|
|
669
|
+
if (g !== l.pointerId || !k && (Math.abs(l.clientY - P) < _ || (oe(l), !k)))
|
|
597
670
|
return;
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
},
|
|
602
|
-
if (g !==
|
|
671
|
+
T(l.clientY);
|
|
672
|
+
const B = l.clientY - P, U = R - B;
|
|
673
|
+
d(U), l.cancelable && l.preventDefault();
|
|
674
|
+
}, Q = (l) => {
|
|
675
|
+
if (g !== l.pointerId)
|
|
603
676
|
return;
|
|
604
|
-
|
|
605
|
-
let
|
|
606
|
-
if (
|
|
607
|
-
const
|
|
608
|
-
if (
|
|
609
|
-
const
|
|
610
|
-
|
|
677
|
+
k && L && l.cancelable && (l.preventDefault(), l.stopPropagation()), h.hasPointerCapture(l.pointerId) && h.releasePointerCapture(l.pointerId);
|
|
678
|
+
let B = 0;
|
|
679
|
+
if (k && w.length >= 2) {
|
|
680
|
+
const U = w[w.length - 1], N = w.find((ue) => U.time - ue.time <= I.velocitySampleWindow) ?? w[0];
|
|
681
|
+
if (U && N && U.time !== N.time) {
|
|
682
|
+
const ue = U.clientY - N.clientY, xe = U.time - N.time;
|
|
683
|
+
B = -(ue / xe);
|
|
611
684
|
}
|
|
612
685
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
}, 0)), Math.abs(
|
|
616
|
-
},
|
|
617
|
-
|
|
618
|
-
},
|
|
619
|
-
g ===
|
|
620
|
-
},
|
|
621
|
-
["click",
|
|
622
|
-
["pointerdown",
|
|
623
|
-
["pointermove",
|
|
624
|
-
["pointerup",
|
|
625
|
-
["pointercancel",
|
|
626
|
-
],
|
|
627
|
-
["pointermove",
|
|
628
|
-
["pointerup",
|
|
629
|
-
["pointercancel",
|
|
686
|
+
b(), v !== null && window.clearTimeout(v), L && (v = window.setTimeout(() => {
|
|
687
|
+
L = !1, v = null;
|
|
688
|
+
}, 0)), Math.abs(B) >= I.startVelocityThreshold && z(B);
|
|
689
|
+
}, ie = (l) => {
|
|
690
|
+
$ && (l.button !== 0 && l.pointerType === "mouse" || l.ctrlKey || l.metaKey || l.altKey || V(l.target) || (window.dispatchEvent(new CustomEvent(ze, { detail: { paneId: Z } })), M(), g = l.pointerId, P = l.clientY, R = S.current, k = !1, L = !1, w = []));
|
|
691
|
+
}, j = (l) => {
|
|
692
|
+
g === l.pointerId && (L = !1, h.hasPointerCapture(l.pointerId) && h.releasePointerCapture(l.pointerId), v !== null && (window.clearTimeout(v), v = null), b());
|
|
693
|
+
}, ge = [
|
|
694
|
+
["click", J, !0],
|
|
695
|
+
["pointerdown", ie, { passive: !1 }],
|
|
696
|
+
["pointermove", q, { passive: !1 }],
|
|
697
|
+
["pointerup", Q, void 0],
|
|
698
|
+
["pointercancel", j, void 0]
|
|
699
|
+
], D = [
|
|
700
|
+
["pointermove", q, { passive: !1 }],
|
|
701
|
+
["pointerup", Q, void 0],
|
|
702
|
+
["pointercancel", j, void 0]
|
|
630
703
|
];
|
|
631
|
-
return
|
|
632
|
-
|
|
704
|
+
return Ce(h, ge, "add"), Ce(window, D, "add"), () => {
|
|
705
|
+
Ce(h, ge, "remove"), Ce(window, D, "remove"), g !== null && h.hasPointerCapture(g) && h.releasePointerCapture(g), v !== null && window.clearTimeout(v), M();
|
|
633
706
|
};
|
|
634
|
-
}, [a,
|
|
707
|
+
}, [a, Z, $, I, d, z, M]), /* @__PURE__ */ Se("div", { ref: G, className: Ie("flex", c), style: u, children: [
|
|
635
708
|
/* @__PURE__ */ Se(
|
|
636
709
|
"div",
|
|
637
710
|
{
|
|
638
|
-
ref:
|
|
711
|
+
ref: C,
|
|
639
712
|
className: "relative h-full flex-1 overflow-hidden",
|
|
640
713
|
style: { height: t, ...a ? { touchAction: "none" } : {} },
|
|
641
|
-
id:
|
|
714
|
+
id: Z,
|
|
642
715
|
children: [
|
|
643
716
|
p,
|
|
644
|
-
|
|
717
|
+
s(S.current)
|
|
645
718
|
]
|
|
646
719
|
}
|
|
647
720
|
),
|
|
648
|
-
|
|
649
|
-
|
|
721
|
+
$ && /* @__PURE__ */ H(
|
|
722
|
+
Lt,
|
|
650
723
|
{
|
|
651
724
|
contentSize: e,
|
|
652
725
|
viewportSize: t,
|
|
653
|
-
scrollPosition:
|
|
654
|
-
onScroll:
|
|
726
|
+
scrollPosition: S.current,
|
|
727
|
+
onScroll: d,
|
|
655
728
|
enableThumbDrag: r,
|
|
656
|
-
enableTrackClick:
|
|
657
|
-
enableArrowButtons:
|
|
729
|
+
enableTrackClick: o,
|
|
730
|
+
enableArrowButtons: i,
|
|
658
731
|
scrollBarWidth: n,
|
|
659
|
-
ariaControls:
|
|
660
|
-
tapScrollCircleOptions:
|
|
661
|
-
itemCount:
|
|
732
|
+
ariaControls: Z,
|
|
733
|
+
tapScrollCircleOptions: E,
|
|
734
|
+
itemCount: O,
|
|
735
|
+
renderThumbOverlay: te
|
|
662
736
|
}
|
|
663
737
|
)
|
|
664
738
|
] });
|
|
665
|
-
}),
|
|
666
|
-
const r = Math.max(n / 2, 1),
|
|
667
|
-
return /* @__PURE__ */ Se(
|
|
668
|
-
/* @__PURE__ */
|
|
739
|
+
}), tt = (s, e, t) => Math.min(Math.max(s, e), t), qt = ({ dragState: s, normalizedDistance: e, sizeScale: t, size: n }) => {
|
|
740
|
+
const r = Math.max(n / 2, 1), o = 1 + e * 0.65, i = Math.max(0.65, 1 - e * 0.25), a = s.direction * e * 26 * t, f = 0.8 + e * 0.18, c = 3 * t, u = 6 * t, p = 22 * t, E = Math.abs(a) + u, A = a > 0 ? c : -Math.abs(a) - c, O = Math.max(2.5, 3 * t), te = tt(s.offsetX, -r, r), X = tt(s.offsetY, -r, r), ne = r * 0.35, S = te / r * ne, ce = X / r * ne, le = S * 0.45, G = ce * 0.45, C = Math.max(p * 0.38, 6), K = 0.65 + e * 0.2, I = s.active;
|
|
741
|
+
return /* @__PURE__ */ Se(rt, { children: [
|
|
742
|
+
/* @__PURE__ */ H(
|
|
669
743
|
"div",
|
|
670
744
|
{
|
|
671
745
|
className: "absolute inset-0 rounded-full border border-white/40 bg-linear-to-br from-[#1d4ed8]/60 via-[#60a5fa]/55 to-[#bfdbfe]/40 shadow-md",
|
|
672
746
|
style: {
|
|
673
|
-
transform: `scale(${
|
|
674
|
-
transition:
|
|
747
|
+
transform: `scale(${i}, ${o})`,
|
|
748
|
+
transition: I ? "40ms transform ease-out" : "200ms ease transform"
|
|
675
749
|
}
|
|
676
750
|
}
|
|
677
751
|
),
|
|
678
|
-
/* @__PURE__ */
|
|
752
|
+
/* @__PURE__ */ H(
|
|
679
753
|
"div",
|
|
680
754
|
{
|
|
681
755
|
className: "absolute top-1/2 left-1/2 rounded-full border border-white/50 bg-white/85",
|
|
682
756
|
style: {
|
|
683
757
|
width: p,
|
|
684
758
|
height: p,
|
|
685
|
-
transform: `translate(calc(-50% + ${
|
|
686
|
-
transition:
|
|
759
|
+
transform: `translate(calc(-50% + ${S}px), calc(-50% + ${ce}px)) scale(${i}, ${f * o})`,
|
|
760
|
+
transition: I ? "70ms transform ease-out" : "200ms ease transform"
|
|
687
761
|
}
|
|
688
762
|
}
|
|
689
763
|
),
|
|
690
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ H(
|
|
691
765
|
"div",
|
|
692
766
|
{
|
|
693
767
|
className: "absolute top-1/2 left-1/2 rounded-full bg-white/80",
|
|
694
768
|
style: {
|
|
695
|
-
width:
|
|
696
|
-
height:
|
|
697
|
-
transform: `translate(calc(-50% + ${
|
|
698
|
-
opacity:
|
|
769
|
+
width: C,
|
|
770
|
+
height: C,
|
|
771
|
+
transform: `translate(calc(-50% + ${le}px), calc(-50% + ${G}px)) scale(${i}, ${o})`,
|
|
772
|
+
opacity: K,
|
|
699
773
|
boxShadow: "0 0 8px rgba(255,255,255,0.45)",
|
|
700
|
-
transition:
|
|
774
|
+
transition: I ? "120ms opacity 150ms, 120ms transform ease-out ease-out" : "220ms ease transform, 240ms opacity ease"
|
|
701
775
|
}
|
|
702
776
|
}
|
|
703
777
|
),
|
|
704
|
-
/* @__PURE__ */
|
|
778
|
+
/* @__PURE__ */ H(
|
|
705
779
|
"div",
|
|
706
780
|
{
|
|
707
781
|
className: "absolute top-1/2 left-1/2 rounded-full bg-white/50",
|
|
708
782
|
style: {
|
|
709
|
-
width:
|
|
710
|
-
height:
|
|
711
|
-
transform: `translate(-50%, ${
|
|
783
|
+
width: O,
|
|
784
|
+
height: E,
|
|
785
|
+
transform: `translate(-50%, ${A}px)`,
|
|
712
786
|
opacity: e,
|
|
713
|
-
transition:
|
|
787
|
+
transition: I ? "40ms height, 60ms opacity ease-out ease-out" : "200ms ease height, 120ms ease opacity"
|
|
714
788
|
}
|
|
715
789
|
}
|
|
716
790
|
)
|
|
717
791
|
] });
|
|
718
792
|
};
|
|
719
|
-
class
|
|
793
|
+
class Nt {
|
|
720
794
|
/**
|
|
721
795
|
* @private
|
|
722
796
|
* @property {Map<number, number>} tree - The Map storing the Fenwick tree structure, specifically the sums of deltas. It is 1-indexed.
|
|
@@ -770,17 +844,17 @@ class xt {
|
|
|
770
844
|
reset(e, t, n) {
|
|
771
845
|
if (this.size = e, this.tree = /* @__PURE__ */ new Map(), this.deltas = /* @__PURE__ */ new Map(), this.total = void 0, typeof t == "function") {
|
|
772
846
|
if (this.valueFn = t, this.size > 0) {
|
|
773
|
-
const
|
|
847
|
+
const o = n?.sampleRange ?? {
|
|
774
848
|
from: 0,
|
|
775
849
|
to: Math.min(99, this.size - 1)
|
|
776
|
-
}, { mode:
|
|
777
|
-
if (this.baseValue =
|
|
778
|
-
for (let
|
|
779
|
-
const
|
|
780
|
-
if (
|
|
850
|
+
}, { mode: i, materializedValues: a } = this._calculateMode(o.from, o.to);
|
|
851
|
+
if (this.baseValue = i, n?.materialize)
|
|
852
|
+
for (let f = 0; f < a.length; f++) {
|
|
853
|
+
const c = a[f], u = o.from + f;
|
|
854
|
+
if (u >= this.size)
|
|
781
855
|
break;
|
|
782
|
-
const p =
|
|
783
|
-
this.deltas.set(
|
|
856
|
+
const p = c - this.baseValue;
|
|
857
|
+
this.deltas.set(u, p), this._updateTree(u, p);
|
|
784
858
|
}
|
|
785
859
|
} else
|
|
786
860
|
this.baseValue = 0;
|
|
@@ -810,29 +884,29 @@ class xt {
|
|
|
810
884
|
if (!this.valueFn)
|
|
811
885
|
return { mode: 0, materializedValues: [] };
|
|
812
886
|
const n = [];
|
|
813
|
-
for (let
|
|
814
|
-
n.push(this.valueFn(
|
|
887
|
+
for (let c = e; c <= t && !(c >= this.size); c++)
|
|
888
|
+
n.push(this.valueFn(c));
|
|
815
889
|
const r = [...n];
|
|
816
890
|
if (n.length === 0)
|
|
817
891
|
return { mode: 0, materializedValues: [] };
|
|
818
|
-
n.sort((
|
|
819
|
-
const
|
|
820
|
-
let
|
|
821
|
-
n.length % 2 === 0 ?
|
|
892
|
+
n.sort((c, u) => c - u);
|
|
893
|
+
const o = Math.floor(n.length / 2);
|
|
894
|
+
let i;
|
|
895
|
+
n.length % 2 === 0 ? i = Math.floor((n[o - 1] + n[o]) / 2) : i = n[o];
|
|
822
896
|
const a = /* @__PURE__ */ new Map();
|
|
823
|
-
let
|
|
824
|
-
for (const
|
|
825
|
-
const
|
|
826
|
-
a.set(
|
|
897
|
+
let f = 0;
|
|
898
|
+
for (const c of n) {
|
|
899
|
+
const u = (a.get(c) ?? 0) + 1;
|
|
900
|
+
a.set(c, u), u > f && (f = u);
|
|
827
901
|
}
|
|
828
|
-
if (
|
|
829
|
-
const
|
|
830
|
-
for (const [p,
|
|
831
|
-
|
|
832
|
-
const
|
|
833
|
-
|
|
902
|
+
if (f > 1) {
|
|
903
|
+
const c = [];
|
|
904
|
+
for (const [p, E] of a.entries())
|
|
905
|
+
E === f && c.push(p);
|
|
906
|
+
const u = c.reduce((p, E) => p + E, 0);
|
|
907
|
+
i = Math.floor(u / c.length);
|
|
834
908
|
}
|
|
835
|
-
return { mode:
|
|
909
|
+
return { mode: i, materializedValues: r };
|
|
836
910
|
}
|
|
837
911
|
/**
|
|
838
912
|
* @method update
|
|
@@ -910,8 +984,8 @@ class xt {
|
|
|
910
984
|
throw new Error(`Index ${n} out of bounds`);
|
|
911
985
|
if (r < 0)
|
|
912
986
|
throw new Error("Value cannot be negative.");
|
|
913
|
-
const
|
|
914
|
-
|
|
987
|
+
const o = this.deltas.has(n) ? (this.deltas.get(n) ?? 0) + this.baseValue : this.baseValue, i = r - o;
|
|
988
|
+
i !== 0 && t.push({ index: n, change: i });
|
|
915
989
|
}
|
|
916
990
|
return t;
|
|
917
991
|
}
|
|
@@ -925,10 +999,10 @@ class xt {
|
|
|
925
999
|
*/
|
|
926
1000
|
_materialize(e, t = !0) {
|
|
927
1001
|
if (this.valueFn) {
|
|
928
|
-
const n = this.deltas.get(e) ?? 0,
|
|
929
|
-
if (
|
|
930
|
-
const
|
|
931
|
-
this._updateTree(e,
|
|
1002
|
+
const n = this.deltas.get(e) ?? 0, o = this.valueFn(e) - this.baseValue;
|
|
1003
|
+
if (o !== n && (this.deltas.set(e, o), t)) {
|
|
1004
|
+
const i = o - n;
|
|
1005
|
+
this._updateTree(e, i);
|
|
932
1006
|
}
|
|
933
1007
|
}
|
|
934
1008
|
}
|
|
@@ -947,9 +1021,9 @@ class xt {
|
|
|
947
1021
|
const r = e.ranges;
|
|
948
1022
|
if (r && r.length > 0) {
|
|
949
1023
|
for (const a of r) {
|
|
950
|
-
const
|
|
951
|
-
for (let
|
|
952
|
-
this._materialize(
|
|
1024
|
+
const f = a.from, c = Math.min(a.to, this.size - 1);
|
|
1025
|
+
for (let u = f; u <= c; u++)
|
|
1026
|
+
this._materialize(u);
|
|
953
1027
|
}
|
|
954
1028
|
if (t === void 0)
|
|
955
1029
|
return;
|
|
@@ -957,8 +1031,8 @@ class xt {
|
|
|
957
1031
|
this._materialize(t);
|
|
958
1032
|
return;
|
|
959
1033
|
}
|
|
960
|
-
const
|
|
961
|
-
t >=
|
|
1034
|
+
const o = r[0].from, i = r[r.length - 1].to;
|
|
1035
|
+
t >= o && t <= i && this._materialize(t);
|
|
962
1036
|
return;
|
|
963
1037
|
}
|
|
964
1038
|
t !== void 0 && this._materialize(t);
|
|
@@ -976,12 +1050,12 @@ class xt {
|
|
|
976
1050
|
_findIndex(e, t = {}, n) {
|
|
977
1051
|
if (this.size === 0)
|
|
978
1052
|
return { index: -1, total: this.total ?? 0, cumulative: void 0, currentValue: void 0, safeIndex: void 0 };
|
|
979
|
-
let r = 0,
|
|
980
|
-
for (; r <=
|
|
981
|
-
const
|
|
982
|
-
a = this.prefixSum(
|
|
1053
|
+
let r = 0, o = this.size - 1, i = -1, a, f = this.total;
|
|
1054
|
+
for (; r <= o; ) {
|
|
1055
|
+
const c = Math.floor((r + o) / 2);
|
|
1056
|
+
a = this.prefixSum(c, t), f = a.total, (n ? a.cumulative >= e : a.cumulative <= e) ? (i = c, n ? o = c - 1 : r = c + 1) : n ? r = c + 1 : o = c - 1;
|
|
983
1057
|
}
|
|
984
|
-
return { index:
|
|
1058
|
+
return { index: i, total: f, cumulative: a?.cumulative, currentValue: a?.currentValue, safeIndex: a?.safeIndex };
|
|
985
1059
|
}
|
|
986
1060
|
/**
|
|
987
1061
|
* @method prefixSum
|
|
@@ -994,15 +1068,15 @@ class xt {
|
|
|
994
1068
|
prefixSum(e, t) {
|
|
995
1069
|
if (e < 0)
|
|
996
1070
|
return { cumulative: 0, total: this.total, currentValue: 0, safeIndex: 0 };
|
|
997
|
-
const n =
|
|
1071
|
+
const n = W(e, 0, this.size - 1), r = t?.materializeOption;
|
|
998
1072
|
this._materializeRanges(r, n, !0);
|
|
999
|
-
let
|
|
1000
|
-
for (;
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1073
|
+
let o = 0, i = n + 1;
|
|
1074
|
+
for (; i > 0; ) {
|
|
1075
|
+
const f = this.tree.get(i) ?? 0;
|
|
1076
|
+
o += f, i -= i & -i;
|
|
1003
1077
|
}
|
|
1004
1078
|
const a = r?.materialize ? this.get(n) : (this.deltas.get(n) || 0) + this.baseValue;
|
|
1005
|
-
return { cumulative:
|
|
1079
|
+
return { cumulative: o + this.baseValue * (n + 1), total: this.total, currentValue: a, safeIndex: n };
|
|
1006
1080
|
}
|
|
1007
1081
|
/**
|
|
1008
1082
|
* @method get
|
|
@@ -1032,8 +1106,8 @@ class xt {
|
|
|
1032
1106
|
this.total = 0;
|
|
1033
1107
|
else {
|
|
1034
1108
|
let n = this.baseValue * this.size;
|
|
1035
|
-
for (const
|
|
1036
|
-
n +=
|
|
1109
|
+
for (const o of this.deltas.values())
|
|
1110
|
+
n += o;
|
|
1037
1111
|
this.total = n;
|
|
1038
1112
|
const r = this.prefixSum(this.getSize() - 1);
|
|
1039
1113
|
console.assert(r.cumulative === r.total, "Inconsistent Fenwick Tree state");
|
|
@@ -1050,17 +1124,17 @@ class xt {
|
|
|
1050
1124
|
rebuildTree(e) {
|
|
1051
1125
|
if (e?.materialize && this.valueFn) {
|
|
1052
1126
|
const r = this.valueFn;
|
|
1053
|
-
this.reset(this.size, (
|
|
1127
|
+
this.reset(this.size, (o) => r(o), { materialize: !0 });
|
|
1054
1128
|
return;
|
|
1055
1129
|
}
|
|
1056
1130
|
const t = /* @__PURE__ */ new Map();
|
|
1057
1131
|
let n = this.baseValue * this.size;
|
|
1058
|
-
for (const [r,
|
|
1059
|
-
if (n +=
|
|
1132
|
+
for (const [r, o] of this.deltas.entries()) {
|
|
1133
|
+
if (n += o, o === 0)
|
|
1060
1134
|
continue;
|
|
1061
|
-
let
|
|
1062
|
-
for (;
|
|
1063
|
-
t.set(
|
|
1135
|
+
let i = r + 1;
|
|
1136
|
+
for (; i <= this.size; )
|
|
1137
|
+
t.set(i, (t.get(i) ?? 0) + o), i += i & -i;
|
|
1064
1138
|
}
|
|
1065
1139
|
this.tree = t, this.total = n;
|
|
1066
1140
|
}
|
|
@@ -1133,11 +1207,11 @@ class xt {
|
|
|
1133
1207
|
return this._findIndex(e, t ?? {}, !1);
|
|
1134
1208
|
}
|
|
1135
1209
|
}
|
|
1136
|
-
const
|
|
1137
|
-
const n = Math.max(0,
|
|
1138
|
-
return Object.is(r.current,
|
|
1210
|
+
const Ot = (s, e, t) => {
|
|
1211
|
+
const n = Math.max(0, s), r = F(null), o = Te(() => new Nt(n, e, t), [n, e, t]);
|
|
1212
|
+
return Object.is(r.current, o) || console.warn("[useFenwickMapTree] instance changed"), r.current = o, o;
|
|
1139
1213
|
};
|
|
1140
|
-
class
|
|
1214
|
+
class zt {
|
|
1141
1215
|
key;
|
|
1142
1216
|
value;
|
|
1143
1217
|
prev = null;
|
|
@@ -1146,7 +1220,7 @@ class bt {
|
|
|
1146
1220
|
this.key = e, this.value = t;
|
|
1147
1221
|
}
|
|
1148
1222
|
}
|
|
1149
|
-
class
|
|
1223
|
+
class nt {
|
|
1150
1224
|
head = null;
|
|
1151
1225
|
tail = null;
|
|
1152
1226
|
/**
|
|
@@ -1187,193 +1261,195 @@ class Ze {
|
|
|
1187
1261
|
this.remove(e), this.addToTail(e);
|
|
1188
1262
|
}
|
|
1189
1263
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const e =
|
|
1264
|
+
function kt(s) {
|
|
1265
|
+
const e = F(/* @__PURE__ */ new Map()), t = F(new nt());
|
|
1192
1266
|
se(() => {
|
|
1193
|
-
for (; e.current.size >
|
|
1194
|
-
const
|
|
1195
|
-
if (
|
|
1196
|
-
e.current.delete(
|
|
1267
|
+
for (; e.current.size > s; ) {
|
|
1268
|
+
const c = t.current.removeHead();
|
|
1269
|
+
if (c)
|
|
1270
|
+
e.current.delete(c.key);
|
|
1197
1271
|
else
|
|
1198
1272
|
break;
|
|
1199
1273
|
}
|
|
1200
|
-
}, [
|
|
1201
|
-
const n =
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1204
|
-
return t.current.moveToTail(
|
|
1205
|
-
}, []), r =
|
|
1206
|
-
(
|
|
1207
|
-
if (
|
|
1274
|
+
}, [s]);
|
|
1275
|
+
const n = y((c) => {
|
|
1276
|
+
const u = e.current.get(c);
|
|
1277
|
+
if (u)
|
|
1278
|
+
return t.current.moveToTail(u), u.value;
|
|
1279
|
+
}, []), r = y(
|
|
1280
|
+
(c, u) => {
|
|
1281
|
+
if (s <= 0)
|
|
1208
1282
|
return;
|
|
1209
|
-
let p = e.current.get(
|
|
1283
|
+
let p = e.current.get(c);
|
|
1210
1284
|
if (p)
|
|
1211
|
-
p.value =
|
|
1285
|
+
p.value = u, t.current.moveToTail(p);
|
|
1212
1286
|
else {
|
|
1213
|
-
if (e.current.size >=
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1287
|
+
if (e.current.size >= s) {
|
|
1288
|
+
const E = t.current.removeHead();
|
|
1289
|
+
E && e.current.delete(E.key);
|
|
1216
1290
|
}
|
|
1217
|
-
p = new
|
|
1291
|
+
p = new zt(c, u), e.current.set(c, p), t.current.addToTail(p);
|
|
1218
1292
|
}
|
|
1219
1293
|
},
|
|
1220
|
-
[
|
|
1221
|
-
),
|
|
1222
|
-
e.current.clear(), t.current = new
|
|
1223
|
-
}, []), [a,
|
|
1224
|
-
return se(() =>
|
|
1294
|
+
[s]
|
|
1295
|
+
), o = y((c) => e.current.has(c), []), i = y(() => {
|
|
1296
|
+
e.current.clear(), t.current = new nt();
|
|
1297
|
+
}, []), [a, f] = pe(() => ({ get: n, set: r, has: o, clear: i }));
|
|
1298
|
+
return se(() => f({ get: n, set: r, has: o, clear: i }), [n, r, o, i]), a;
|
|
1225
1299
|
}
|
|
1226
|
-
const
|
|
1227
|
-
const { get:
|
|
1228
|
-
return { get:
|
|
1229
|
-
},
|
|
1300
|
+
const Yt = 1e4, jt = () => {
|
|
1301
|
+
const { get: s, set: e, has: t, clear: n } = kt(Yt);
|
|
1302
|
+
return { get: s, set: e, has: t, clear: n };
|
|
1303
|
+
}, be = (s, e) => e <= 0 ? 0 : W(s, 0, e - 1), Ht = (s, e, t, n, r, o) => {
|
|
1230
1304
|
if (n === 0)
|
|
1231
1305
|
return { renderingStartIndex: 0, renderingEndIndex: 0, visibleStartIndex: 0, visibleEndIndex: 0 };
|
|
1232
|
-
const { index:
|
|
1233
|
-
let
|
|
1234
|
-
for (;
|
|
1235
|
-
|
|
1236
|
-
const
|
|
1237
|
-
return { renderingStartIndex:
|
|
1306
|
+
const { index: i, cumulative: a, currentValue: f } = o.findIndexAtOrAfter(s, { materializeOption: { materialize: !1 } }), c = i === -1 ? 0 : i, u = i !== -1 && (a ?? 0) < s + (f ?? 0) ? c + 1 : c, p = be(u, n), E = be(p - t, n);
|
|
1307
|
+
let A = 0, O = p;
|
|
1308
|
+
for (; O < n && A < e; )
|
|
1309
|
+
A += r(O), O++;
|
|
1310
|
+
const te = be(O - 1, n), X = be(te + t, n);
|
|
1311
|
+
return { renderingStartIndex: E, renderingEndIndex: X, visibleStartIndex: p, visibleEndIndex: te };
|
|
1238
1312
|
};
|
|
1239
|
-
function
|
|
1240
|
-
const
|
|
1241
|
-
se(() => (
|
|
1242
|
-
|
|
1313
|
+
function $t({ itemCount: s, getItem: e, getItemHeight: t, viewportSize: n, overscanCount: r = 5, className: o, onScroll: i, onRangeChange: a, children: f, background: c, initialScrollIndex: u, initialScrollOffset: p, tapScrollCircleOptions: E, scrollBarWidth: A, enableThumbDrag: O, enableTrackClick: te, enableArrowButtons: X, enablePointerDrag: ne, inertiaOptions: S, renderThumbOverlay: ce, wheelSpeedMultiplier: le }, G) {
|
|
1314
|
+
const C = F(null), K = F(!1);
|
|
1315
|
+
se(() => (K.current = !0, () => {
|
|
1316
|
+
K.current = !1;
|
|
1243
1317
|
}), []);
|
|
1244
|
-
const
|
|
1245
|
-
let
|
|
1246
|
-
if (typeof
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
} else typeof p == "number" && (
|
|
1250
|
-
return { position:
|
|
1251
|
-
}), [
|
|
1252
|
-
|
|
1253
|
-
x.setValueFn(t), g !==
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
-
}, [x, g,
|
|
1257
|
-
|
|
1258
|
-
}, [
|
|
1259
|
-
const
|
|
1260
|
-
(
|
|
1261
|
-
if (!
|
|
1318
|
+
const I = F({ size: s, valueOrFn: t, options: { sampleRange: { from: 0, to: 100 } } }), x = Ot(I.current.size, I.current.valueOrFn, I.current.options), [$] = pe(() => {
|
|
1319
|
+
let b = 0, T = 0;
|
|
1320
|
+
if (typeof u == "number") {
|
|
1321
|
+
const V = W(u, 0, s - 1), J = W(V - r * 2, 0, s - 1), oe = W(V + r * 2, 0, s - 1), q = u > 0 ? { materializeOption: { materialize: !0, ranges: [{ from: J, to: oe }] } } : void 0, { cumulative: Q, total: ie, currentValue: j } = x.prefixSum(u, q);
|
|
1322
|
+
b = Q - j, T = ie ?? x.getTotal();
|
|
1323
|
+
} else typeof p == "number" && (b = p), T = x.getTotal();
|
|
1324
|
+
return { position: b, total: T };
|
|
1325
|
+
}), [d, M] = pe($.position), [z, Z] = pe($.total), [h, _] = pe($.position), [g, P] = pe(s);
|
|
1326
|
+
Ae(() => {
|
|
1327
|
+
x.setValueFn(t), g !== s && (x.changeSize(s), P(s));
|
|
1328
|
+
const b = x.getTotal();
|
|
1329
|
+
z !== b && Z(b);
|
|
1330
|
+
}, [x, g, s, z, t]), Ae(() => {
|
|
1331
|
+
h !== null && C.current && (ae.debug("[VirtualScroll] Scrolling to position:", h), C.current.scrollTo(h), _(null));
|
|
1332
|
+
}, [h]);
|
|
1333
|
+
const R = y(
|
|
1334
|
+
(b) => {
|
|
1335
|
+
if (!C.current)
|
|
1262
1336
|
return;
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1337
|
+
const T = be(b, g), V = be(T - r * 2, g), J = be(T + r * 2, g), { cumulative: oe, total: q, currentValue: Q } = x.prefixSum(T, { materializeOption: { materialize: !0, ranges: [{ from: V, to: J }] } });
|
|
1338
|
+
ae.debug("[VirtualScroll] Scrolling to index:", T, "Offset:", oe, "Total height:", q, "Current value:", Q, "safeIndexFrom:", V, "safeIndexTo:", J), q && (Z(q), _(oe - Q), ae.debug("[VirtualScroll] Setting scroll position to:", oe - Q));
|
|
1265
1339
|
},
|
|
1266
1340
|
[x, r, g]
|
|
1267
|
-
),
|
|
1268
|
-
(
|
|
1269
|
-
if (!
|
|
1341
|
+
), k = y(
|
|
1342
|
+
(b) => {
|
|
1343
|
+
if (!C.current)
|
|
1270
1344
|
return;
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1345
|
+
const T = x.getTotal(), V = W(Math.floor(b), 0, T), J = x.findIndexAtOrAfter(V, { materializeOption: { materialize: !1 } }).index;
|
|
1346
|
+
R(J);
|
|
1273
1347
|
},
|
|
1274
|
-
[x,
|
|
1275
|
-
),
|
|
1276
|
-
(
|
|
1277
|
-
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1348
|
+
[x, R]
|
|
1349
|
+
), L = y(
|
|
1350
|
+
(b, T) => {
|
|
1351
|
+
ae.debug("[VirtualScroll] Scroll position changed:", b), M(b);
|
|
1352
|
+
const V = x.getTotal();
|
|
1353
|
+
i?.(b, V);
|
|
1280
1354
|
},
|
|
1281
|
-
[x,
|
|
1282
|
-
),
|
|
1283
|
-
const
|
|
1284
|
-
return
|
|
1285
|
-
...
|
|
1286
|
-
scrollPosition:
|
|
1355
|
+
[x, i]
|
|
1356
|
+
), v = Te(() => {
|
|
1357
|
+
const b = Ht(d, n, r, g, t, x);
|
|
1358
|
+
return ae.debug("[VirtualScroll] Calculated rendering range:", {
|
|
1359
|
+
...b,
|
|
1360
|
+
scrollPosition: d,
|
|
1287
1361
|
renderingContentSize: x.getTotal(),
|
|
1288
1362
|
overscanCount: r,
|
|
1289
1363
|
viewportSize: n
|
|
1290
|
-
}),
|
|
1291
|
-
}, [
|
|
1364
|
+
}), b;
|
|
1365
|
+
}, [d, n, r, g, t, x]);
|
|
1292
1366
|
se(() => {
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1295
|
-
renderingStartIndex:
|
|
1296
|
-
renderingEndIndex:
|
|
1297
|
-
visibleStartIndex:
|
|
1298
|
-
visibleEndIndex:
|
|
1299
|
-
scrollPosition:
|
|
1300
|
-
contentSize:
|
|
1301
|
-
scrollPaneScrollPosition:
|
|
1302
|
-
}), a?.(
|
|
1303
|
-
}, [
|
|
1304
|
-
const
|
|
1305
|
-
(
|
|
1306
|
-
const { renderingStartIndex:
|
|
1307
|
-
if (
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
const
|
|
1310
|
-
for (let
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1367
|
+
const b = C.current?.getScrollPosition() ?? 0;
|
|
1368
|
+
ae.debug("[VirtualScroll] Range change effect triggered", {
|
|
1369
|
+
renderingStartIndex: v.renderingStartIndex,
|
|
1370
|
+
renderingEndIndex: v.renderingEndIndex,
|
|
1371
|
+
visibleStartIndex: v.visibleStartIndex,
|
|
1372
|
+
visibleEndIndex: v.visibleEndIndex,
|
|
1373
|
+
scrollPosition: d,
|
|
1374
|
+
contentSize: z,
|
|
1375
|
+
scrollPaneScrollPosition: b
|
|
1376
|
+
}), a?.(v.renderingStartIndex, v.renderingEndIndex, v.visibleStartIndex, v.visibleEndIndex, d, z);
|
|
1377
|
+
}, [v.renderingStartIndex, v.renderingEndIndex, v.visibleStartIndex, v.visibleEndIndex, a, d, z]);
|
|
1378
|
+
const w = y(
|
|
1379
|
+
(b) => {
|
|
1380
|
+
const { renderingStartIndex: T, renderingEndIndex: V } = v;
|
|
1381
|
+
if (ae.debug("[VirtualScroll] Rendering visible items", { currentScrollPosition: b, renderingStartIndex: T, renderingEndIndex: V, fenwickSize: g, viewportSize: n }), g === 0)
|
|
1382
|
+
return /* @__PURE__ */ H("div", { className: "absolute w-full", style: { top: 0 }, children: /* @__PURE__ */ H("div", { className: "text-center text-gray-500", children: "No items" }) });
|
|
1383
|
+
const J = be(T, g), { cumulative: oe, currentValue: q } = x.prefixSum(J, { materializeOption: { materialize: !1 } }), Q = oe - q, ie = [], j = [];
|
|
1384
|
+
for (let D = T; D <= V; D++) {
|
|
1385
|
+
const l = t(D);
|
|
1386
|
+
ie.push({ item: e(D), height: l, index: D }), x.get(D) !== l && j.push({ index: D, value: l });
|
|
1313
1387
|
}
|
|
1314
|
-
|
|
1315
|
-
const
|
|
1316
|
-
|
|
1388
|
+
j.length > 0 && Promise.resolve().then(() => {
|
|
1389
|
+
const D = x.updates(j);
|
|
1390
|
+
D && (Z(D), ae.debug("[VirtualScroll] Updated heights for items", j, "New total height:", D));
|
|
1317
1391
|
});
|
|
1318
|
-
const
|
|
1319
|
-
return
|
|
1320
|
-
const
|
|
1321
|
-
return /* @__PURE__ */
|
|
1392
|
+
const ge = z < n ? 0 : Q - b;
|
|
1393
|
+
return ae.debug("[VirtualScroll] Rendering items", { visibleItems: ie, containerTop: ge }), /* @__PURE__ */ H("div", { className: "absolute w-full", style: { top: ge }, children: ie.map(({ item: D, index: l }) => {
|
|
1394
|
+
const B = be(l, g), { cumulative: U, currentValue: N } = x.prefixSum(B, { materializeOption: { materialize: !1 } }), ue = U - N;
|
|
1395
|
+
return /* @__PURE__ */ H(
|
|
1322
1396
|
"div",
|
|
1323
1397
|
{
|
|
1324
|
-
"data-index":
|
|
1398
|
+
"data-index": l,
|
|
1325
1399
|
style: {
|
|
1326
1400
|
position: "absolute",
|
|
1327
|
-
top:
|
|
1401
|
+
top: ue - Q,
|
|
1328
1402
|
width: "100%"
|
|
1329
1403
|
},
|
|
1330
|
-
children:
|
|
1404
|
+
children: f(D, l)
|
|
1331
1405
|
},
|
|
1332
|
-
|
|
1406
|
+
l
|
|
1333
1407
|
);
|
|
1334
1408
|
}) });
|
|
1335
1409
|
},
|
|
1336
|
-
[e,
|
|
1410
|
+
[e, f, z, n, v, x, g, t]
|
|
1337
1411
|
);
|
|
1338
|
-
return
|
|
1339
|
-
getScrollPosition: () =>
|
|
1340
|
-
getContentSize: () =>
|
|
1341
|
-
getViewportSize: () =>
|
|
1342
|
-
scrollTo:
|
|
1343
|
-
scrollToIndex:
|
|
1412
|
+
return Ye(G, () => ({
|
|
1413
|
+
getScrollPosition: () => C.current?.getScrollPosition() ?? -1,
|
|
1414
|
+
getContentSize: () => C.current?.getContentSize() ?? -1,
|
|
1415
|
+
getViewportSize: () => C.current?.getViewportSize() ?? -1,
|
|
1416
|
+
scrollTo: k,
|
|
1417
|
+
scrollToIndex: R,
|
|
1344
1418
|
getFenwickTreeTotalHeight: () => x.getTotal(),
|
|
1345
1419
|
getFenwickSize: () => x.getSize()
|
|
1346
|
-
}), [
|
|
1347
|
-
|
|
1420
|
+
}), [k, R, x]), /* @__PURE__ */ H(
|
|
1421
|
+
Dt,
|
|
1348
1422
|
{
|
|
1349
|
-
ref:
|
|
1350
|
-
contentSize:
|
|
1423
|
+
ref: C,
|
|
1424
|
+
contentSize: z,
|
|
1351
1425
|
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
|
-
|
|
1426
|
+
className: o,
|
|
1427
|
+
onScroll: L,
|
|
1428
|
+
background: c,
|
|
1429
|
+
tapScrollCircleOptions: E,
|
|
1430
|
+
inertiaOptions: S,
|
|
1431
|
+
itemCount: s,
|
|
1432
|
+
scrollBarWidth: A,
|
|
1433
|
+
enableThumbDrag: O,
|
|
1434
|
+
enableTrackClick: te,
|
|
1435
|
+
enableArrowButtons: X,
|
|
1436
|
+
enablePointerDrag: ne,
|
|
1437
|
+
renderThumbOverlay: ce,
|
|
1438
|
+
wheelSpeedMultiplier: le,
|
|
1439
|
+
children: w
|
|
1364
1440
|
}
|
|
1365
1441
|
);
|
|
1366
1442
|
}
|
|
1367
|
-
const
|
|
1443
|
+
const Wt = ke($t);
|
|
1368
1444
|
export {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1445
|
+
Nt as FenwickMapTree,
|
|
1446
|
+
Lt as ScrollBar,
|
|
1447
|
+
Dt as ScrollPane,
|
|
1448
|
+
Wt as VirtualScroll,
|
|
1449
|
+
W as minmax,
|
|
1450
|
+
qt as tapScrollCircleSampleVisual,
|
|
1451
|
+
Ot as useFenwickMapTree,
|
|
1452
|
+
jt as useHeightCache,
|
|
1453
|
+
kt as useLruCache
|
|
1378
1454
|
};
|
|
1379
1455
|
//# sourceMappingURL=index.js.map
|