prometeo-design-system 6.3.3 → 6.3.4
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/dist/PyrionLayout.es.js +2 -2
- package/dist/{Scrollable-BT8QYTgm.js → Scrollable-BhxCCeiu.js} +1 -1
- package/dist/Scrollable.es.js +1 -1
- package/dist/prometeo-design-system.es.js +1 -1
- package/dist/useScrollable-CSfF1lbV.js +483 -0
- package/package.json +1 -1
- package/dist/useScrollable-CTw5uK2c.js +0 -487
package/dist/PyrionLayout.es.js
CHANGED
|
@@ -9,14 +9,14 @@ import { c as Ie } from "./index-BOQuZ0gG.js";
|
|
|
9
9
|
import { B as We } from "./badge-CWYEc-DA.js";
|
|
10
10
|
import _t from "./PlainTooltip.es.js";
|
|
11
11
|
import { CrevronLeft as Pt } from "./Icons/CrevronLeft.es.js";
|
|
12
|
-
import { S as Oe, a as Mt } from "./Scrollable-
|
|
12
|
+
import { S as Oe, a as Mt } from "./Scrollable-BhxCCeiu.js";
|
|
13
13
|
import { useLocation as Ve } from "react-router";
|
|
14
14
|
import de from "./TicketCard.es.js";
|
|
15
15
|
import He from "./UserCard.es.js";
|
|
16
16
|
import Ee from "./Button.es.js";
|
|
17
17
|
import { Logout as Rt } from "./Icons/Logout.es.js";
|
|
18
18
|
import ae from "./Skeleton.es.js";
|
|
19
|
-
import { u as Bt } from "./useScrollable-
|
|
19
|
+
import { u as Bt } from "./useScrollable-CSfF1lbV.js";
|
|
20
20
|
import $e from "./IconButton.es.js";
|
|
21
21
|
import { Help as qe } from "./Icons/Help.es.js";
|
|
22
22
|
import { Close as _e } from "./Icons/Close.es.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { j as r } from "./jsx-runtime-GkKLlHH4.js";
|
|
2
2
|
import m, { useImperativeHandle as L } from "react";
|
|
3
|
-
import { u as V } from "./useScrollable-
|
|
3
|
+
import { u as V } from "./useScrollable-CSfF1lbV.js";
|
|
4
4
|
import { c as n } from "./cn-B6yFEsav.js";
|
|
5
5
|
import { CrevronLeft as N } from "./Icons/CrevronLeft.es.js";
|
|
6
6
|
const j = (t) => {
|
package/dist/Scrollable.es.js
CHANGED
|
@@ -49,7 +49,7 @@ import { useDropzone as q } from "react-dropzone";
|
|
|
49
49
|
import { u as Jt } from "./useDevice-vwn4GLwK.js";
|
|
50
50
|
import { default as Xt } from "./DropZone.es.js";
|
|
51
51
|
import { default as er } from "./PriorityChip.es.js";
|
|
52
|
-
import { u as rr } from "./useScrollable-
|
|
52
|
+
import { u as rr } from "./useScrollable-CSfF1lbV.js";
|
|
53
53
|
const b = {
|
|
54
54
|
label: "Buscar",
|
|
55
55
|
icon: /* @__PURE__ */ a.jsx(Z, {}),
|
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { u as Ze } from "./useDevice-vwn4GLwK.js";
|
|
2
|
+
import { g as be, r as x } from "./useLabelBackground-D5SzHhl_.js";
|
|
3
|
+
import k, { useState as v, useCallback as a, useLayoutEffect as Ce, useEffect as Pe } from "react";
|
|
4
|
+
function ct(Te) {
|
|
5
|
+
const { defaultBehavior: J = "scroll-on-click" } = Te, ve = Ze(), K = {
|
|
6
|
+
top: { show: !0, type: "shadow", behavior: J, hoverDelay: 300 },
|
|
7
|
+
bottom: { show: !0, type: "shadow", behavior: J, hoverDelay: 300 },
|
|
8
|
+
left: { show: !0, type: "icon", behavior: J, hoverDelay: 300 },
|
|
9
|
+
right: { show: !0, type: "icon", behavior: J, hoverDelay: 300 }
|
|
10
|
+
}, ye = {
|
|
11
|
+
hide: !1,
|
|
12
|
+
size: "small"
|
|
13
|
+
}, {
|
|
14
|
+
axis: f = "both",
|
|
15
|
+
indicators: G,
|
|
16
|
+
scrollbarProps: Be = ye,
|
|
17
|
+
disableMouseScroll: Se = !1,
|
|
18
|
+
persistScroll: A = !1,
|
|
19
|
+
children: Ae,
|
|
20
|
+
scrollTopButton: ce,
|
|
21
|
+
scrollMetadata: Le,
|
|
22
|
+
speed: ne = 5
|
|
23
|
+
} = Te, [l, We] = v(null), [qe, Oe] = v(!1), [ae, Q] = v(null), [ie, b] = v(!1), [p, M] = v({}), [i, N] = v(null), [y, Z] = v(null), [w, V] = v(null), [H, Fe] = v(null), [P, Ne] = v(null), [ue, Ve] = v(!1), [fe, _e] = v(!1), u = k.useRef({}), d = k.useRef(ne), _ = k.useRef([]), ee = k.useRef(null), we = k.useRef({ scrollTop: 0, scrollLeft: 0 }), he = k.useRef(Le), W = k.useRef(null), $ = k.useRef(null), z = k.useRef(!1);
|
|
24
|
+
he.current = Le;
|
|
25
|
+
const U = {
|
|
26
|
+
top: f === "x" ? { show: !1 } : { ...K.top, ...G?.top },
|
|
27
|
+
bottom: f === "x" ? { show: !1 } : { ...K.bottom, ...G?.bottom },
|
|
28
|
+
left: f === "y" ? { show: !1 } : { ...K.left, ...G?.left },
|
|
29
|
+
right: f === "y" ? { show: !1 } : { ...K.right, ...G?.right }
|
|
30
|
+
}, ze = { ...ye, ...Be }, xe = a(() => {
|
|
31
|
+
_.current.forEach((e) => {
|
|
32
|
+
e.config?.trip === "forth" && (e.triggered = !1);
|
|
33
|
+
});
|
|
34
|
+
}, []), q = a((e) => {
|
|
35
|
+
if (!l) return 0;
|
|
36
|
+
const { scrollTop: o, scrollLeft: t, scrollHeight: r, clientHeight: s, scrollWidth: c, clientWidth: n } = l;
|
|
37
|
+
switch (e) {
|
|
38
|
+
case "top":
|
|
39
|
+
return Math.max(0, o);
|
|
40
|
+
case "bottom":
|
|
41
|
+
return Math.max(0, r - (o + s));
|
|
42
|
+
case "left":
|
|
43
|
+
return Math.max(0, t);
|
|
44
|
+
case "right":
|
|
45
|
+
return Math.max(0, c - (t + n));
|
|
46
|
+
default:
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
}, [l]), Me = a((e) => {
|
|
50
|
+
if (!e || !l) return 0;
|
|
51
|
+
const { clientHeight: o, scrollHeight: t } = l;
|
|
52
|
+
if (e.includes("%")) {
|
|
53
|
+
const r = parseFloat(e.replace("%", "")), s = Math.max(0, t - o);
|
|
54
|
+
return r / 100 * s;
|
|
55
|
+
} else {
|
|
56
|
+
if (e.includes("px"))
|
|
57
|
+
return parseFloat(e.replace("px", ""));
|
|
58
|
+
if (e.includes("vh"))
|
|
59
|
+
return parseFloat(e.replace("vh", "")) / 100 * window.innerHeight;
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
}, [l]), de = a(() => {
|
|
63
|
+
if (!l || !ce) return;
|
|
64
|
+
const { scrollTop: e } = l, o = Me(ce.target || "40vh");
|
|
65
|
+
Oe(e >= o);
|
|
66
|
+
}, [l, ce, Me]), ge = a(() => {
|
|
67
|
+
if (!l) return { x: 0, y: 0 };
|
|
68
|
+
const { scrollTop: e, scrollLeft: o, scrollHeight: t, scrollWidth: r, clientHeight: s, clientWidth: c } = l, n = Math.max(0, t - s), h = Math.max(0, r - c), I = n > 0 ? e / n * 100 : 0;
|
|
69
|
+
return { x: h > 0 ? o / h * 100 : 0, y: I };
|
|
70
|
+
}, [l]), Ee = a((e) => {
|
|
71
|
+
const o = we.current;
|
|
72
|
+
let t = null;
|
|
73
|
+
return e.scrollTop > o.scrollTop ? t = "down" : e.scrollTop < o.scrollTop ? t = "up" : e.scrollLeft > o.scrollLeft ? t = "right" : e.scrollLeft < o.scrollLeft && (t = "left"), we.current = e, t;
|
|
74
|
+
}, []), Re = a((e) => {
|
|
75
|
+
if (!l) return;
|
|
76
|
+
let { scrollTop: o, scrollLeft: t, scrollHeight: r, scrollWidth: s, clientHeight: c, clientWidth: n } = l;
|
|
77
|
+
const h = Ee(e), { x: I, y: T } = ge(), g = {
|
|
78
|
+
percentage: T,
|
|
79
|
+
direction: h,
|
|
80
|
+
scrollTop: o,
|
|
81
|
+
scrollLeft: t,
|
|
82
|
+
scrollHeight: r,
|
|
83
|
+
scrollWidth: s,
|
|
84
|
+
clientHeight: c,
|
|
85
|
+
clientWidth: n,
|
|
86
|
+
metadata: he.current
|
|
87
|
+
}, B = {
|
|
88
|
+
percentage: I,
|
|
89
|
+
direction: h,
|
|
90
|
+
scrollTop: o,
|
|
91
|
+
scrollLeft: t,
|
|
92
|
+
scrollHeight: r,
|
|
93
|
+
scrollWidth: s,
|
|
94
|
+
clientHeight: c,
|
|
95
|
+
clientWidth: n,
|
|
96
|
+
metadata: he.current
|
|
97
|
+
};
|
|
98
|
+
_.current.forEach((m) => {
|
|
99
|
+
const { config: S, triggered: re } = m;
|
|
100
|
+
if (!S) {
|
|
101
|
+
(f === "y" || f === "both") && m.callback(g), (f === "x" || f === "both") && m.callback(B);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const oe = (S.direction === "y" || S.direction === "both") && (f === "y" || f === "both"), He = (S.direction === "x" || S.direction === "both") && (f === "x" || f === "both");
|
|
105
|
+
if (!oe && !He) return;
|
|
106
|
+
const $e = oe ? g : B;
|
|
107
|
+
let O = Math.round($e.percentage);
|
|
108
|
+
const Y = S.target * 100;
|
|
109
|
+
let F = !1;
|
|
110
|
+
if (S.trip === "forth")
|
|
111
|
+
F = !re && O >= Y, F && (m.triggered = !0), re && O < Y && (m.triggered = !1);
|
|
112
|
+
else if (S.trip === "back")
|
|
113
|
+
F = re && O < Y, F && (m.triggered = !1), !re && O >= Y && (m.triggered = !0);
|
|
114
|
+
else if (S.trip === "round-trip") {
|
|
115
|
+
const le = O >= Y;
|
|
116
|
+
F = m.triggered !== le;
|
|
117
|
+
}
|
|
118
|
+
if (F) {
|
|
119
|
+
const le = (j) => {
|
|
120
|
+
if (!h) return !1;
|
|
121
|
+
const se = j === "y" ? Math.max(1, Math.floor(Math.max(0, r - c) * 1e-3)) : Math.max(1, Math.floor(Math.max(0, s - n) * 1e-3));
|
|
122
|
+
if (j === "y") {
|
|
123
|
+
if (h === "down") {
|
|
124
|
+
const L = Math.max(0, o - se);
|
|
125
|
+
if (L < o)
|
|
126
|
+
return o = L, l.scrollTop = o, !0;
|
|
127
|
+
} else if (h === "up") {
|
|
128
|
+
const L = Math.min(Math.max(0, r - c), o + se);
|
|
129
|
+
if (L > o)
|
|
130
|
+
return o = L, l.scrollTop = o, !0;
|
|
131
|
+
}
|
|
132
|
+
} else if (h === "right") {
|
|
133
|
+
const L = Math.max(0, t - se);
|
|
134
|
+
if (L < t)
|
|
135
|
+
return t = L, l.scrollLeft = t, !0;
|
|
136
|
+
} else if (h === "left") {
|
|
137
|
+
const L = Math.min(Math.max(0, s - n), t + se);
|
|
138
|
+
if (L > t)
|
|
139
|
+
return t = L, l.scrollLeft = t, !0;
|
|
140
|
+
}
|
|
141
|
+
return !1;
|
|
142
|
+
}, De = () => {
|
|
143
|
+
const j = ge();
|
|
144
|
+
g.percentage = j.y, B.percentage = j.x, g.scrollTop = o, g.scrollLeft = t, B.scrollTop = o, B.scrollLeft = t;
|
|
145
|
+
};
|
|
146
|
+
le(oe ? "y" : "x") && (De(), O = $e.percentage), oe ? m.callback(g) : He && m.callback(B);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}, [l, f, Ee, ge]), Ue = a((e, o) => {
|
|
150
|
+
const t = {
|
|
151
|
+
callback: e,
|
|
152
|
+
config: o,
|
|
153
|
+
triggered: !1,
|
|
154
|
+
lastDirection: void 0
|
|
155
|
+
};
|
|
156
|
+
return _.current.push(t), () => {
|
|
157
|
+
const r = _.current.indexOf(t);
|
|
158
|
+
r > -1 && _.current.splice(r, 1);
|
|
159
|
+
};
|
|
160
|
+
}, []), D = a((e, o = 100, t = !0) => {
|
|
161
|
+
if (!l) return;
|
|
162
|
+
const r = q(e), s = Math.min(Math.abs(o), r);
|
|
163
|
+
if (s === 0) return;
|
|
164
|
+
const c = e === "top" || e === "left" ? -s : s, n = {
|
|
165
|
+
top: { top: c, left: 0 },
|
|
166
|
+
bottom: { top: c, left: 0 },
|
|
167
|
+
left: { top: 0, left: c },
|
|
168
|
+
right: { top: 0, left: c }
|
|
169
|
+
};
|
|
170
|
+
l.scrollBy({ ...n[e], behavior: t ? "smooth" : "auto" });
|
|
171
|
+
}, [l, q]), me = a((e) => {
|
|
172
|
+
if (!l) return;
|
|
173
|
+
const o = l, t = {
|
|
174
|
+
top: { top: 0, left: o.scrollLeft },
|
|
175
|
+
bottom: { top: o.scrollHeight, left: o.scrollLeft },
|
|
176
|
+
left: { top: o.scrollTop, left: 0 },
|
|
177
|
+
right: { top: o.scrollTop, left: o.scrollWidth }
|
|
178
|
+
};
|
|
179
|
+
o.scrollTo({ ...t[e], behavior: "smooth" });
|
|
180
|
+
}, [l]), Xe = a(() => {
|
|
181
|
+
l && l.scrollTo({ top: 0, behavior: "smooth" });
|
|
182
|
+
}, [l]), pe = a((e, o) => {
|
|
183
|
+
const t = u.current[e];
|
|
184
|
+
if (t) {
|
|
185
|
+
if (t.style.cursor = "pointer", o === "icon") {
|
|
186
|
+
const r = t.querySelector("svg");
|
|
187
|
+
r && (r.style.transition = "all 0.3s ease-in-out", r.style.transform = "scale(1.3)", r.style.backgroundColor = "rgba(255, 255, 255, 0.2)", r.style.borderRadius = "100%");
|
|
188
|
+
} else if (o === "shadow") {
|
|
189
|
+
const r = t.querySelector(".shadow-base"), s = t.querySelector(".shadow-hover"), c = be(l);
|
|
190
|
+
if (s && (s.style.opacity = "0"), r)
|
|
191
|
+
if (r.style.transition = "all 0.3s ease-in-out", e === "top" || e === "bottom")
|
|
192
|
+
r.style.height = "110px", r.style.zIndex = "100", r.style.background = `linear-gradient(to bottom, ${c} 5%, ${x(c, -2)} 10%, ${x(c, -5, 30)} 70%, transparent)`, r.style.animation = "scrollToEndPulse 3.5s ease-out", setTimeout(() => {
|
|
193
|
+
r && (r.style.animation = "");
|
|
194
|
+
}, 3500);
|
|
195
|
+
else {
|
|
196
|
+
r.style.width = "40px";
|
|
197
|
+
const n = e === "left" ? "to right" : "to left";
|
|
198
|
+
r.style.background = `linear-gradient(${n}, ${c} 5%, ${x(c, -2)} 10%, ${x(c, -5, 30)} 70%, transparent)`, r.style.animation = "scrollToEndPulseVertical 1.5s ease-out", setTimeout(() => {
|
|
199
|
+
r && (r.style.animation = "");
|
|
200
|
+
}, 1500);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}, [l]), E = a((e, o) => {
|
|
205
|
+
const t = u.current[e];
|
|
206
|
+
if (!t) return;
|
|
207
|
+
t.style.cursor = "";
|
|
208
|
+
const r = t.querySelector("svg");
|
|
209
|
+
r && (r.style.transform = "", r.style.backgroundColor = "", r.style.borderRadius = "");
|
|
210
|
+
const s = t.querySelector(".shadow-base");
|
|
211
|
+
if (s && (s.style.height = "", s.style.width = "", o === "shadow")) {
|
|
212
|
+
const c = be(l), n = e === "left" || e === "right" ? "to right" : "to bottom";
|
|
213
|
+
s.style.background = `linear-gradient(${n}, ${c} 5%, ${x(c, 0)} 10%, ${x(c, -2, 30)} 70%, transparent)`;
|
|
214
|
+
}
|
|
215
|
+
}, [l]), Ie = a((e, o) => {
|
|
216
|
+
if (o !== "shadow" || p[e]) return;
|
|
217
|
+
const t = u.current[e];
|
|
218
|
+
if (!t) return;
|
|
219
|
+
const r = t.querySelector(".shadow-hover");
|
|
220
|
+
r && (r.style.opacity = "1");
|
|
221
|
+
}, [p]), ke = a((e, o) => {
|
|
222
|
+
if (o !== "shadow" || p[e]) return;
|
|
223
|
+
const t = u.current[e];
|
|
224
|
+
if (!t) return;
|
|
225
|
+
const r = t.querySelector(".shadow-hover");
|
|
226
|
+
r && (r.style.opacity = "0");
|
|
227
|
+
}, [p]), Ye = a((e, o, t) => {
|
|
228
|
+
if (o === "scroll-on-click" && ie) {
|
|
229
|
+
b(!1);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (p[e]) {
|
|
233
|
+
w && (clearTimeout(w), V(null)), i && (clearInterval(i), N(null)), E(e, t), M((r) => ({ ...r, [e]: !1 })), me(e);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (o === "scroll-on-click") {
|
|
237
|
+
if (!l) return;
|
|
238
|
+
const { clientHeight: r, clientWidth: s } = l, c = e === "top" || e === "bottom" ? r * 0.8 : s * 0.8;
|
|
239
|
+
D(e, c);
|
|
240
|
+
}
|
|
241
|
+
}, [ie, p, w, i, E, me, l, D]), te = a((e, o) => {
|
|
242
|
+
w && (clearTimeout(w), V(null)), b(!0), d.current = ne;
|
|
243
|
+
let t = 0;
|
|
244
|
+
Q(e), M((s) => ({ ...s, [e]: !1 })), D(e, d.current, !1);
|
|
245
|
+
const r = setInterval(() => {
|
|
246
|
+
t += 16;
|
|
247
|
+
const s = t / 1e3;
|
|
248
|
+
if (q(e) === 0) {
|
|
249
|
+
R(e, !1, o);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (s >= 2 && !p[e] && (M((n) => ({ ...n, [e]: !0 })), pe(e, o)), s <= 2)
|
|
253
|
+
d.current = ne + s * 0.4;
|
|
254
|
+
else {
|
|
255
|
+
const n = s - 2;
|
|
256
|
+
d.current += Math.pow(n, 1.1) * 2;
|
|
257
|
+
}
|
|
258
|
+
d.current = Math.min(d.current, 100), D(e, d.current, !1);
|
|
259
|
+
}, 16);
|
|
260
|
+
N(r);
|
|
261
|
+
}, [w, D, q, p, pe]), R = a((e, o = !1, t) => {
|
|
262
|
+
y && (clearTimeout(y), Z(null));
|
|
263
|
+
const r = e || ae;
|
|
264
|
+
if (!o && r && i) {
|
|
265
|
+
let s = 0;
|
|
266
|
+
const c = d.current, n = 800, h = setInterval(() => {
|
|
267
|
+
s += 16;
|
|
268
|
+
const T = s / n, g = 1 - Math.pow(1 - T, 3);
|
|
269
|
+
if (d.current = c * (1 - g), q(r) === 0 || d.current <= 0.5) {
|
|
270
|
+
if (clearInterval(h), i && (clearInterval(i), N(null)), d.current = 5, r)
|
|
271
|
+
if (p[r]) {
|
|
272
|
+
const m = setTimeout(() => {
|
|
273
|
+
E(r, t), M((S) => ({ ...S, [r]: !1 })), b(!1);
|
|
274
|
+
}, 1e3);
|
|
275
|
+
V(m);
|
|
276
|
+
} else
|
|
277
|
+
E(r, t), M((m) => ({ ...m, [r]: !1 })), b(!1);
|
|
278
|
+
else
|
|
279
|
+
b(!1);
|
|
280
|
+
Q(null);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
D(r, d.current, !1);
|
|
284
|
+
}, 16), I = setTimeout(() => {
|
|
285
|
+
if (clearInterval(h), i && (clearInterval(i), N(null)), d.current = 5, r)
|
|
286
|
+
if (p[r]) {
|
|
287
|
+
const T = setTimeout(() => {
|
|
288
|
+
E(r, t), M((g) => ({ ...g, [r]: !1 })), b(!1);
|
|
289
|
+
}, 1e3);
|
|
290
|
+
V(T);
|
|
291
|
+
} else
|
|
292
|
+
E(r, t), M((T) => ({ ...T, [r]: !1 })), b(!1);
|
|
293
|
+
else
|
|
294
|
+
b(!1);
|
|
295
|
+
Q(null);
|
|
296
|
+
}, n);
|
|
297
|
+
Z(I);
|
|
298
|
+
} else {
|
|
299
|
+
if (i && (clearInterval(i), N(null)), d.current = 5, r)
|
|
300
|
+
if (p[r]) {
|
|
301
|
+
const s = setTimeout(() => {
|
|
302
|
+
E(r, t), M((c) => ({ ...c, [r]: !1 })), b(!1);
|
|
303
|
+
}, 1e3);
|
|
304
|
+
V(s);
|
|
305
|
+
} else
|
|
306
|
+
E(r, t), M((s) => ({ ...s, [r]: !1 })), b(!1);
|
|
307
|
+
else
|
|
308
|
+
b(!1);
|
|
309
|
+
Q(null);
|
|
310
|
+
}
|
|
311
|
+
}, [y, ae, i, q, D, p, E, pe]), X = a((e, o, t) => {
|
|
312
|
+
if (!ve && (W.current = { position: e, behavior: o, type: t }, Ie(e, t), !z.current && o === "scroll-on-hover")) {
|
|
313
|
+
const r = U[e]?.hoverDelay ?? 800, s = setTimeout(() => {
|
|
314
|
+
te(e, t);
|
|
315
|
+
}, r);
|
|
316
|
+
Z(s);
|
|
317
|
+
}
|
|
318
|
+
}, [ve, Ie, U, te]), je = a((e, o, t) => {
|
|
319
|
+
W.current = null, ke(e, t), o === "scroll-on-hover" && R(e, !0, t);
|
|
320
|
+
}, [ke, R]), Je = a((e, o, t) => {
|
|
321
|
+
if (o === "scroll-on-click") {
|
|
322
|
+
b(!1);
|
|
323
|
+
const r = setTimeout(() => {
|
|
324
|
+
te(e, t);
|
|
325
|
+
}, 200);
|
|
326
|
+
Z(r);
|
|
327
|
+
}
|
|
328
|
+
}, [te]), Ke = a((e, o, t) => {
|
|
329
|
+
o === "scroll-on-click" && R(e, !1, t);
|
|
330
|
+
}, [R]), Ge = a((e) => {
|
|
331
|
+
l && ((i || y) && R(void 0, !0), z.current = !0, l.scrollBy({
|
|
332
|
+
top: e.deltaY,
|
|
333
|
+
left: e.deltaX,
|
|
334
|
+
behavior: "auto"
|
|
335
|
+
}), $.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
336
|
+
if (z.current = !1, W.current) {
|
|
337
|
+
const { position: o, behavior: t, type: r } = W.current;
|
|
338
|
+
X(o, t, r);
|
|
339
|
+
}
|
|
340
|
+
}, 150));
|
|
341
|
+
}, [l, i, y, R, X]), C = a(() => {
|
|
342
|
+
if (!l) return;
|
|
343
|
+
const e = l, { scrollTop: o, scrollLeft: t, scrollHeight: r, scrollWidth: s, clientHeight: c, clientWidth: n } = e, h = o <= 10, I = o + c >= r - 10, T = t <= 10, g = t + n >= s - 10;
|
|
344
|
+
f !== "x" && (u.current.top?.classList.toggle("opacity-0", h), u.current.top?.classList.toggle("pointer-events-none", h), u.current.top?.classList.toggle("pointer-events-auto", !h), u.current.bottom?.classList.toggle("opacity-0", I), u.current.bottom?.classList.toggle("pointer-events-none", I), u.current.bottom?.classList.toggle("pointer-events-auto", !I)), f !== "y" && (u.current.left?.classList.toggle("opacity-0", T), u.current.left?.classList.toggle("pointer-events-none", T), u.current.left?.classList.toggle("pointer-events-auto", !T), u.current.right?.classList.toggle("opacity-0", g), u.current.right?.classList.toggle("pointer-events-none", g), u.current.right?.classList.toggle("pointer-events-auto", !g));
|
|
345
|
+
}, [l, f]), Qe = a((e) => {
|
|
346
|
+
We(e);
|
|
347
|
+
}, []);
|
|
348
|
+
return Ce(() => {
|
|
349
|
+
if (!l) return;
|
|
350
|
+
if (A && !P) {
|
|
351
|
+
const t = typeof A == "string" ? `scrollable-${A}` : `scrollable-session-${Math.random().toString(36).substr(2, 9)}`;
|
|
352
|
+
Ne(t);
|
|
353
|
+
}
|
|
354
|
+
if (A && P && !ue) {
|
|
355
|
+
Ve(!0);
|
|
356
|
+
try {
|
|
357
|
+
const t = sessionStorage.getItem(P);
|
|
358
|
+
if (t) {
|
|
359
|
+
const { scrollTop: r, scrollLeft: s } = JSON.parse(t);
|
|
360
|
+
l.scrollTop = r, l.scrollLeft = s;
|
|
361
|
+
}
|
|
362
|
+
} catch {
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
C(), fe || (_e(!0), requestAnimationFrame(() => {
|
|
366
|
+
Object.values(u.current).forEach((t) => {
|
|
367
|
+
t?.classList.add("transition-all", "duration-300");
|
|
368
|
+
}), setTimeout(() => {
|
|
369
|
+
C();
|
|
370
|
+
}, 0);
|
|
371
|
+
}));
|
|
372
|
+
const e = () => {
|
|
373
|
+
if (C(), de(), l) {
|
|
374
|
+
const t = {
|
|
375
|
+
scrollTop: l.scrollTop,
|
|
376
|
+
scrollLeft: l.scrollLeft
|
|
377
|
+
};
|
|
378
|
+
Re(t);
|
|
379
|
+
}
|
|
380
|
+
if (A && P) {
|
|
381
|
+
H && clearTimeout(H);
|
|
382
|
+
const t = setTimeout(() => {
|
|
383
|
+
try {
|
|
384
|
+
if (!l) return;
|
|
385
|
+
const r = {
|
|
386
|
+
scrollTop: l.scrollTop,
|
|
387
|
+
scrollLeft: l.scrollLeft
|
|
388
|
+
};
|
|
389
|
+
sessionStorage.setItem(P, JSON.stringify(r));
|
|
390
|
+
} catch {
|
|
391
|
+
}
|
|
392
|
+
}, 150);
|
|
393
|
+
Fe(t);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
l.addEventListener("scroll", e);
|
|
397
|
+
const o = (t) => {
|
|
398
|
+
if (Se) {
|
|
399
|
+
t.preventDefault();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
(i || y) && R(void 0, !0), z.current = !0, $.current && clearTimeout($.current), $.current = setTimeout(() => {
|
|
403
|
+
if (z.current = !1, W.current) {
|
|
404
|
+
const { position: r, behavior: s, type: c } = W.current;
|
|
405
|
+
X(r, s, c);
|
|
406
|
+
}
|
|
407
|
+
}, 350);
|
|
408
|
+
};
|
|
409
|
+
return l.addEventListener("wheel", o, { passive: !1 }), ee.current = new MutationObserver((t) => {
|
|
410
|
+
t.some((r) => r.type === "childList" && r.target === l) && (console.log("MutationObserver: childList changes detected.", t), C(), de(), l.scrollTop + l.clientHeight >= l.scrollHeight - 20 && xe());
|
|
411
|
+
}), ee.current.observe(l, { childList: !0, subtree: !1 }), () => {
|
|
412
|
+
l.removeEventListener("scroll", e), l.removeEventListener("wheel", o), H && clearTimeout(H), ee.current && ee.current.disconnect();
|
|
413
|
+
};
|
|
414
|
+
}, [
|
|
415
|
+
l,
|
|
416
|
+
A,
|
|
417
|
+
P,
|
|
418
|
+
ue,
|
|
419
|
+
fe,
|
|
420
|
+
Se,
|
|
421
|
+
C,
|
|
422
|
+
de,
|
|
423
|
+
Re,
|
|
424
|
+
i,
|
|
425
|
+
y,
|
|
426
|
+
R,
|
|
427
|
+
X,
|
|
428
|
+
xe
|
|
429
|
+
]), Ce(() => {
|
|
430
|
+
C();
|
|
431
|
+
}, [Ae, C]), Pe(() => {
|
|
432
|
+
if (!l) return;
|
|
433
|
+
let e = be(l);
|
|
434
|
+
Object.entries(U).forEach(([o, t]) => {
|
|
435
|
+
if (t?.show && t.type === "shadow") {
|
|
436
|
+
const r = u.current[o], s = r?.querySelector(".shadow-base"), c = r?.querySelector(".shadow-hover");
|
|
437
|
+
if (s) {
|
|
438
|
+
s.dataset.bgColor = e;
|
|
439
|
+
const n = o === "left" || o === "right" ? "to right" : "to bottom";
|
|
440
|
+
s.style.background = `linear-gradient(${n}, ${e} 2%, ${x(e, -2, 55)} 50%, ${x(e, -1, 30)} 80%, transparent)`;
|
|
441
|
+
}
|
|
442
|
+
if (c) {
|
|
443
|
+
const n = o === "left" || o === "right" ? "to right" : "to bottom";
|
|
444
|
+
c.style.height += "60px", c.style.background = `linear-gradient(${n}, ${e} 2%, ${x(e, 10, 20)} 20%, ${x(e, 6, 10)} 70%, transparent)`;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}, [l, U, f]), Pe(() => () => {
|
|
449
|
+
i && clearInterval(i), y && clearTimeout(y), w && clearTimeout(w), H && clearTimeout(H), $.current && clearTimeout($.current);
|
|
450
|
+
}, [i, y, w, H]), { state: {
|
|
451
|
+
scrollableElement: l,
|
|
452
|
+
indicatorRefs: u.current,
|
|
453
|
+
scrollTopButtonVisible: qe,
|
|
454
|
+
activePosition: ae,
|
|
455
|
+
continuousScrollStarted: ie,
|
|
456
|
+
clickToEndEnabled: p,
|
|
457
|
+
hoverScrollInterval: i,
|
|
458
|
+
hoverDebounceTimeout: y,
|
|
459
|
+
clickToEndTimeout: w,
|
|
460
|
+
saveScrollTimeout: H,
|
|
461
|
+
scrollKey: P,
|
|
462
|
+
hasRestoredScroll: ue,
|
|
463
|
+
hasRendered: fe,
|
|
464
|
+
finalIndicators: U,
|
|
465
|
+
finalScrollbarProps: ze
|
|
466
|
+
}, handlers: {
|
|
467
|
+
subscribeToScrollTarget: Ue,
|
|
468
|
+
scrollByAmount: D,
|
|
469
|
+
scrollToEnd: me,
|
|
470
|
+
scrollToTop: Xe,
|
|
471
|
+
handleIndicatorClick: Ye,
|
|
472
|
+
handleIndicatorMouseEnter: X,
|
|
473
|
+
handleIndicatorMouseLeave: je,
|
|
474
|
+
handleIndicatorMouseDown: Je,
|
|
475
|
+
handleIndicatorMouseUp: Ke,
|
|
476
|
+
handleIndicatorWheel: Ge,
|
|
477
|
+
setScrollableRef: Qe,
|
|
478
|
+
updateIndicatorsVisibility: C
|
|
479
|
+
} };
|
|
480
|
+
}
|
|
481
|
+
export {
|
|
482
|
+
ct as u
|
|
483
|
+
};
|
package/package.json
CHANGED
|
@@ -1,487 +0,0 @@
|
|
|
1
|
-
import { u as oe } from "./useDevice-vwn4GLwK.js";
|
|
2
|
-
import { g as bt, r as x } from "./useLabelBackground-D5SzHhl_.js";
|
|
3
|
-
import M, { useState as y, useCallback as a, useLayoutEffect as At, useEffect as Wt } from "react";
|
|
4
|
-
function ue(vt) {
|
|
5
|
-
const { defaultBehavior: j = "scroll-on-click" } = vt, yt = oe(), J = {
|
|
6
|
-
top: { show: !0, type: "shadow", behavior: j, hoverDelay: 300 },
|
|
7
|
-
bottom: { show: !0, type: "shadow", behavior: j, hoverDelay: 300 },
|
|
8
|
-
left: { show: !0, type: "icon", behavior: j, hoverDelay: 300 },
|
|
9
|
-
right: { show: !0, type: "icon", behavior: j, hoverDelay: 300 }
|
|
10
|
-
}, St = {
|
|
11
|
-
hide: !1,
|
|
12
|
-
size: "small"
|
|
13
|
-
}, {
|
|
14
|
-
axis: d = "both",
|
|
15
|
-
indicators: G,
|
|
16
|
-
scrollbarProps: Ot = St,
|
|
17
|
-
disableMouseScroll: Lt = !1,
|
|
18
|
-
persistScroll: W = !1,
|
|
19
|
-
children: qt,
|
|
20
|
-
scrollTopButton: ct,
|
|
21
|
-
scrollMetadata: wt,
|
|
22
|
-
speed: nt = 5
|
|
23
|
-
} = vt, [l, Ft] = y(null), [Nt, Vt] = y(!1), [at, Q] = y(null), [it, b] = y(!1), [T, E] = y({}), [i, _] = y(null), [S, Z] = y(null), [w, z] = y(null), [$, _t] = y(null), [P, zt] = y(null), [ut, Kt] = y(!1), [ft, Ut] = y(!1), u = M.useRef({}), g = M.useRef(nt), O = M.useRef([]), tt = M.useRef(null), xt = M.useRef(/* @__PURE__ */ new Map()), Mt = M.useRef({ scrollTop: 0, scrollLeft: 0 }), ht = M.useRef(wt), q = M.useRef(null), D = M.useRef(null), K = M.useRef(!1);
|
|
24
|
-
ht.current = wt;
|
|
25
|
-
const U = {
|
|
26
|
-
top: d === "x" ? { show: !1 } : { ...J.top, ...G?.top },
|
|
27
|
-
bottom: d === "x" ? { show: !1 } : { ...J.bottom, ...G?.bottom },
|
|
28
|
-
left: d === "y" ? { show: !1 } : { ...J.left, ...G?.left },
|
|
29
|
-
right: d === "y" ? { show: !1 } : { ...J.right, ...G?.right }
|
|
30
|
-
}, Xt = { ...St, ...Ot }, Et = a(() => {
|
|
31
|
-
O.current.forEach((t) => {
|
|
32
|
-
t.config?.trip === "forth" && (t.triggered = !1);
|
|
33
|
-
});
|
|
34
|
-
}, []), F = a((t) => {
|
|
35
|
-
if (!l) return 0;
|
|
36
|
-
const { scrollTop: o, scrollLeft: e, scrollHeight: r, clientHeight: s, scrollWidth: c, clientWidth: n } = l;
|
|
37
|
-
switch (t) {
|
|
38
|
-
case "top":
|
|
39
|
-
return Math.max(0, o);
|
|
40
|
-
case "bottom":
|
|
41
|
-
return Math.max(0, r - (o + s));
|
|
42
|
-
case "left":
|
|
43
|
-
return Math.max(0, e);
|
|
44
|
-
case "right":
|
|
45
|
-
return Math.max(0, c - (e + n));
|
|
46
|
-
default:
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
}, [l]), Rt = a((t) => {
|
|
50
|
-
if (!t || !l) return 0;
|
|
51
|
-
const { clientHeight: o, scrollHeight: e } = l;
|
|
52
|
-
if (t.includes("%")) {
|
|
53
|
-
const r = parseFloat(t.replace("%", "")), s = Math.max(0, e - o);
|
|
54
|
-
return r / 100 * s;
|
|
55
|
-
} else {
|
|
56
|
-
if (t.includes("px"))
|
|
57
|
-
return parseFloat(t.replace("px", ""));
|
|
58
|
-
if (t.includes("vh"))
|
|
59
|
-
return parseFloat(t.replace("vh", "")) / 100 * window.innerHeight;
|
|
60
|
-
}
|
|
61
|
-
return 0;
|
|
62
|
-
}, [l]), dt = a(() => {
|
|
63
|
-
if (!l || !ct) return;
|
|
64
|
-
const { scrollTop: t } = l, o = Rt(ct.target || "40vh");
|
|
65
|
-
Vt(t >= o);
|
|
66
|
-
}, [l, ct, Rt]), gt = a(() => {
|
|
67
|
-
if (!l) return { x: 0, y: 0 };
|
|
68
|
-
const { scrollTop: t, scrollLeft: o, scrollHeight: e, scrollWidth: r, clientHeight: s, clientWidth: c } = l, n = Math.max(0, e - s), f = Math.max(0, r - c), k = n > 0 ? t / n * 100 : 0;
|
|
69
|
-
return { x: f > 0 ? o / f * 100 : 0, y: k };
|
|
70
|
-
}, [l]), It = a((t) => {
|
|
71
|
-
const o = Mt.current;
|
|
72
|
-
let e = null;
|
|
73
|
-
return t.scrollTop > o.scrollTop ? e = "down" : t.scrollTop < o.scrollTop ? e = "up" : t.scrollLeft > o.scrollLeft ? e = "right" : t.scrollLeft < o.scrollLeft && (e = "left"), Mt.current = t, e;
|
|
74
|
-
}, []), kt = a((t) => {
|
|
75
|
-
if (!l) return;
|
|
76
|
-
let { scrollTop: o, scrollLeft: e, scrollHeight: r, scrollWidth: s, clientHeight: c, clientWidth: n } = l;
|
|
77
|
-
const f = It(t), { x: k, y: v } = gt(), m = {
|
|
78
|
-
percentage: v,
|
|
79
|
-
direction: f,
|
|
80
|
-
scrollTop: o,
|
|
81
|
-
scrollLeft: e,
|
|
82
|
-
scrollHeight: r,
|
|
83
|
-
scrollWidth: s,
|
|
84
|
-
clientHeight: c,
|
|
85
|
-
clientWidth: n,
|
|
86
|
-
metadata: ht.current
|
|
87
|
-
}, B = {
|
|
88
|
-
percentage: k,
|
|
89
|
-
direction: f,
|
|
90
|
-
scrollTop: o,
|
|
91
|
-
scrollLeft: e,
|
|
92
|
-
scrollHeight: r,
|
|
93
|
-
scrollWidth: s,
|
|
94
|
-
clientHeight: c,
|
|
95
|
-
clientWidth: n,
|
|
96
|
-
metadata: ht.current
|
|
97
|
-
};
|
|
98
|
-
O.current.forEach((h) => {
|
|
99
|
-
const { config: p, triggered: rt } = h;
|
|
100
|
-
if (!p) {
|
|
101
|
-
(d === "y" || d === "both") && h.callback(m), (d === "x" || d === "both") && h.callback(B);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const ot = (p.direction === "y" || p.direction === "both") && (d === "y" || d === "both"), Ht = (p.direction === "x" || p.direction === "both") && (d === "x" || d === "both");
|
|
105
|
-
if (!ot && !Ht) return;
|
|
106
|
-
const Ct = ot ? m : B;
|
|
107
|
-
let A = Math.round(Ct.percentage);
|
|
108
|
-
const N = p.target * 100;
|
|
109
|
-
let V = !1;
|
|
110
|
-
if (p.trip === "forth")
|
|
111
|
-
V = !rt && A >= N, V && (h.triggered = !0), rt && A < N && (h.triggered = !1);
|
|
112
|
-
else if (p.trip === "back")
|
|
113
|
-
V = rt && A < N, V && (h.triggered = !1), !rt && A >= N && (h.triggered = !0);
|
|
114
|
-
else if (p.trip === "round-trip") {
|
|
115
|
-
const lt = A >= N;
|
|
116
|
-
V = h.triggered !== lt;
|
|
117
|
-
}
|
|
118
|
-
if (V) {
|
|
119
|
-
const lt = (Y) => {
|
|
120
|
-
if (!f) return !1;
|
|
121
|
-
const st = Y === "y" ? Math.max(1, Math.floor(Math.max(0, r - c) * 1e-3)) : Math.max(1, Math.floor(Math.max(0, s - n) * 1e-3));
|
|
122
|
-
if (Y === "y") {
|
|
123
|
-
if (f === "down") {
|
|
124
|
-
const L = Math.max(0, o - st);
|
|
125
|
-
if (L < o)
|
|
126
|
-
return o = L, l.scrollTop = o, !0;
|
|
127
|
-
} else if (f === "up") {
|
|
128
|
-
const L = Math.min(Math.max(0, r - c), o + st);
|
|
129
|
-
if (L > o)
|
|
130
|
-
return o = L, l.scrollTop = o, !0;
|
|
131
|
-
}
|
|
132
|
-
} else if (f === "right") {
|
|
133
|
-
const L = Math.max(0, e - st);
|
|
134
|
-
if (L < e)
|
|
135
|
-
return e = L, l.scrollLeft = e, !0;
|
|
136
|
-
} else if (f === "left") {
|
|
137
|
-
const L = Math.min(Math.max(0, s - n), e + st);
|
|
138
|
-
if (L > e)
|
|
139
|
-
return e = L, l.scrollLeft = e, !0;
|
|
140
|
-
}
|
|
141
|
-
return !1;
|
|
142
|
-
}, Pt = () => {
|
|
143
|
-
const Y = gt();
|
|
144
|
-
m.percentage = Y.y, B.percentage = Y.x, m.scrollTop = o, m.scrollLeft = e, B.scrollTop = o, B.scrollLeft = e;
|
|
145
|
-
};
|
|
146
|
-
lt(ot ? "y" : "x") && (Pt(), A = Ct.percentage);
|
|
147
|
-
const Bt = `${O.current.indexOf(h)}-${p?.target || 0}-${p?.direction || "y"}`, Tt = Date.now(), re = xt.current.get(Bt) || 0;
|
|
148
|
-
if (Tt - re < 500)
|
|
149
|
-
return;
|
|
150
|
-
p.trip === "round-trip" && (h.triggered = A >= N, h.lastDirection = f || void 0), xt.current.set(Bt, Tt), h.lastTriggerTime = Tt, ot ? h.callback(m) : Ht && h.callback(B);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}, [l, d, It, gt]), Yt = a((t, o) => {
|
|
154
|
-
const e = {
|
|
155
|
-
callback: t,
|
|
156
|
-
config: o,
|
|
157
|
-
triggered: !1,
|
|
158
|
-
lastDirection: void 0
|
|
159
|
-
};
|
|
160
|
-
return O.current.push(e), () => {
|
|
161
|
-
const r = O.current.indexOf(e);
|
|
162
|
-
r > -1 && O.current.splice(r, 1);
|
|
163
|
-
};
|
|
164
|
-
}, []), H = a((t, o = 100, e = !0) => {
|
|
165
|
-
if (!l) return;
|
|
166
|
-
const r = F(t), s = Math.min(Math.abs(o), r);
|
|
167
|
-
if (s === 0) return;
|
|
168
|
-
const c = t === "top" || t === "left" ? -s : s, n = {
|
|
169
|
-
top: { top: c, left: 0 },
|
|
170
|
-
bottom: { top: c, left: 0 },
|
|
171
|
-
left: { top: 0, left: c },
|
|
172
|
-
right: { top: 0, left: c }
|
|
173
|
-
};
|
|
174
|
-
l.scrollBy({ ...n[t], behavior: e ? "smooth" : "auto" });
|
|
175
|
-
}, [l, F]), mt = a((t) => {
|
|
176
|
-
if (!l) return;
|
|
177
|
-
const o = l, e = {
|
|
178
|
-
top: { top: 0, left: o.scrollLeft },
|
|
179
|
-
bottom: { top: o.scrollHeight, left: o.scrollLeft },
|
|
180
|
-
left: { top: o.scrollTop, left: 0 },
|
|
181
|
-
right: { top: o.scrollTop, left: o.scrollWidth }
|
|
182
|
-
};
|
|
183
|
-
o.scrollTo({ ...e[t], behavior: "smooth" });
|
|
184
|
-
}, [l]), jt = a(() => {
|
|
185
|
-
l && l.scrollTo({ top: 0, behavior: "smooth" });
|
|
186
|
-
}, [l]), pt = a((t, o) => {
|
|
187
|
-
const e = u.current[t];
|
|
188
|
-
if (e) {
|
|
189
|
-
if (e.style.cursor = "pointer", o === "icon") {
|
|
190
|
-
const r = e.querySelector("svg");
|
|
191
|
-
r && (r.style.transition = "all 0.3s ease-in-out", r.style.transform = "scale(1.3)", r.style.backgroundColor = "rgba(255, 255, 255, 0.2)", r.style.borderRadius = "100%");
|
|
192
|
-
} else if (o === "shadow") {
|
|
193
|
-
const r = e.querySelector(".shadow-base"), s = e.querySelector(".shadow-hover"), c = bt(l);
|
|
194
|
-
if (s && (s.style.opacity = "0"), r)
|
|
195
|
-
if (r.style.transition = "all 0.3s ease-in-out", t === "top" || t === "bottom")
|
|
196
|
-
r.style.height = "110px", r.style.zIndex = "100", r.style.background = `linear-gradient(to bottom, ${c} 5%, ${x(c, -2)} 10%, ${x(c, -5, 30)} 70%, transparent)`, r.style.animation = "scrollToEndPulse 3.5s ease-out", setTimeout(() => {
|
|
197
|
-
r && (r.style.animation = "");
|
|
198
|
-
}, 3500);
|
|
199
|
-
else {
|
|
200
|
-
r.style.width = "40px";
|
|
201
|
-
const n = t === "left" ? "to right" : "to left";
|
|
202
|
-
r.style.background = `linear-gradient(${n}, ${c} 5%, ${x(c, -2)} 10%, ${x(c, -5, 30)} 70%, transparent)`, r.style.animation = "scrollToEndPulseVertical 1.5s ease-out", setTimeout(() => {
|
|
203
|
-
r && (r.style.animation = "");
|
|
204
|
-
}, 1500);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, [l]), R = a((t, o) => {
|
|
209
|
-
const e = u.current[t];
|
|
210
|
-
if (!e) return;
|
|
211
|
-
e.style.cursor = "";
|
|
212
|
-
const r = e.querySelector("svg");
|
|
213
|
-
r && (r.style.transform = "", r.style.backgroundColor = "", r.style.borderRadius = "");
|
|
214
|
-
const s = e.querySelector(".shadow-base");
|
|
215
|
-
if (s && (s.style.height = "", s.style.width = "", o === "shadow")) {
|
|
216
|
-
const c = bt(l), n = t === "left" || t === "right" ? "to right" : "to bottom";
|
|
217
|
-
s.style.background = `linear-gradient(${n}, ${c} 5%, ${x(c, 0)} 10%, ${x(c, -2, 30)} 70%, transparent)`;
|
|
218
|
-
}
|
|
219
|
-
}, [l]), $t = a((t, o) => {
|
|
220
|
-
if (o !== "shadow" || T[t]) return;
|
|
221
|
-
const e = u.current[t];
|
|
222
|
-
if (!e) return;
|
|
223
|
-
const r = e.querySelector(".shadow-hover");
|
|
224
|
-
r && (r.style.opacity = "1");
|
|
225
|
-
}, [T]), Dt = a((t, o) => {
|
|
226
|
-
if (o !== "shadow" || T[t]) return;
|
|
227
|
-
const e = u.current[t];
|
|
228
|
-
if (!e) return;
|
|
229
|
-
const r = e.querySelector(".shadow-hover");
|
|
230
|
-
r && (r.style.opacity = "0");
|
|
231
|
-
}, [T]), Jt = a((t, o, e) => {
|
|
232
|
-
if (o === "scroll-on-click" && it) {
|
|
233
|
-
b(!1);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
if (T[t]) {
|
|
237
|
-
w && (clearTimeout(w), z(null)), i && (clearInterval(i), _(null)), R(t, e), E((r) => ({ ...r, [t]: !1 })), mt(t);
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (o === "scroll-on-click") {
|
|
241
|
-
if (!l) return;
|
|
242
|
-
const { clientHeight: r, clientWidth: s } = l, c = t === "top" || t === "bottom" ? r * 0.8 : s * 0.8;
|
|
243
|
-
H(t, c);
|
|
244
|
-
}
|
|
245
|
-
}, [it, T, w, i, R, mt, l, H]), et = a((t, o) => {
|
|
246
|
-
w && (clearTimeout(w), z(null)), b(!0), g.current = nt;
|
|
247
|
-
let e = 0;
|
|
248
|
-
Q(t), E((s) => ({ ...s, [t]: !1 })), H(t, g.current, !1);
|
|
249
|
-
const r = setInterval(() => {
|
|
250
|
-
e += 16;
|
|
251
|
-
const s = e / 1e3;
|
|
252
|
-
if (F(t) === 0) {
|
|
253
|
-
I(t, !1, o);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (s >= 2 && !T[t] && (E((n) => ({ ...n, [t]: !0 })), pt(t, o)), s <= 2)
|
|
257
|
-
g.current = nt + s * 0.4;
|
|
258
|
-
else {
|
|
259
|
-
const n = s - 2;
|
|
260
|
-
g.current += Math.pow(n, 1.1) * 2;
|
|
261
|
-
}
|
|
262
|
-
g.current = Math.min(g.current, 100), H(t, g.current, !1);
|
|
263
|
-
}, 16);
|
|
264
|
-
_(r);
|
|
265
|
-
}, [w, H, F, T, pt]), I = a((t, o = !1, e) => {
|
|
266
|
-
S && (clearTimeout(S), Z(null));
|
|
267
|
-
const r = t || at;
|
|
268
|
-
if (!o && r && i) {
|
|
269
|
-
let s = 0;
|
|
270
|
-
const c = g.current, n = 800, f = setInterval(() => {
|
|
271
|
-
s += 16;
|
|
272
|
-
const v = s / n, m = 1 - Math.pow(1 - v, 3);
|
|
273
|
-
if (g.current = c * (1 - m), F(r) === 0 || g.current <= 0.5) {
|
|
274
|
-
if (clearInterval(f), i && (clearInterval(i), _(null)), g.current = 5, r)
|
|
275
|
-
if (T[r]) {
|
|
276
|
-
const h = setTimeout(() => {
|
|
277
|
-
R(r, e), E((p) => ({ ...p, [r]: !1 })), b(!1);
|
|
278
|
-
}, 1e3);
|
|
279
|
-
z(h);
|
|
280
|
-
} else
|
|
281
|
-
R(r, e), E((h) => ({ ...h, [r]: !1 })), b(!1);
|
|
282
|
-
else
|
|
283
|
-
b(!1);
|
|
284
|
-
Q(null);
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
H(r, g.current, !1);
|
|
288
|
-
}, 16), k = setTimeout(() => {
|
|
289
|
-
if (clearInterval(f), i && (clearInterval(i), _(null)), g.current = 5, r)
|
|
290
|
-
if (T[r]) {
|
|
291
|
-
const v = setTimeout(() => {
|
|
292
|
-
R(r, e), E((m) => ({ ...m, [r]: !1 })), b(!1);
|
|
293
|
-
}, 1e3);
|
|
294
|
-
z(v);
|
|
295
|
-
} else
|
|
296
|
-
R(r, e), E((v) => ({ ...v, [r]: !1 })), b(!1);
|
|
297
|
-
else
|
|
298
|
-
b(!1);
|
|
299
|
-
Q(null);
|
|
300
|
-
}, n);
|
|
301
|
-
Z(k);
|
|
302
|
-
} else {
|
|
303
|
-
if (i && (clearInterval(i), _(null)), g.current = 5, r)
|
|
304
|
-
if (T[r]) {
|
|
305
|
-
const s = setTimeout(() => {
|
|
306
|
-
R(r, e), E((c) => ({ ...c, [r]: !1 })), b(!1);
|
|
307
|
-
}, 1e3);
|
|
308
|
-
z(s);
|
|
309
|
-
} else
|
|
310
|
-
R(r, e), E((s) => ({ ...s, [r]: !1 })), b(!1);
|
|
311
|
-
else
|
|
312
|
-
b(!1);
|
|
313
|
-
Q(null);
|
|
314
|
-
}
|
|
315
|
-
}, [S, at, i, F, H, T, R, pt]), X = a((t, o, e) => {
|
|
316
|
-
if (!yt && (q.current = { position: t, behavior: o, type: e }, $t(t, e), !K.current && o === "scroll-on-hover")) {
|
|
317
|
-
const r = U[t]?.hoverDelay ?? 800, s = setTimeout(() => {
|
|
318
|
-
et(t, e);
|
|
319
|
-
}, r);
|
|
320
|
-
Z(s);
|
|
321
|
-
}
|
|
322
|
-
}, [yt, $t, U, et]), Gt = a((t, o, e) => {
|
|
323
|
-
q.current = null, Dt(t, e), o === "scroll-on-hover" && I(t, !0, e);
|
|
324
|
-
}, [Dt, I]), Qt = a((t, o, e) => {
|
|
325
|
-
if (o === "scroll-on-click") {
|
|
326
|
-
b(!1);
|
|
327
|
-
const r = setTimeout(() => {
|
|
328
|
-
et(t, e);
|
|
329
|
-
}, 200);
|
|
330
|
-
Z(r);
|
|
331
|
-
}
|
|
332
|
-
}, [et]), Zt = a((t, o, e) => {
|
|
333
|
-
o === "scroll-on-click" && I(t, !1, e);
|
|
334
|
-
}, [I]), te = a((t) => {
|
|
335
|
-
l && ((i || S) && I(void 0, !0), K.current = !0, l.scrollBy({
|
|
336
|
-
top: t.deltaY,
|
|
337
|
-
left: t.deltaX,
|
|
338
|
-
behavior: "auto"
|
|
339
|
-
}), D.current && clearTimeout(D.current), D.current = setTimeout(() => {
|
|
340
|
-
if (K.current = !1, q.current) {
|
|
341
|
-
const { position: o, behavior: e, type: r } = q.current;
|
|
342
|
-
X(o, e, r);
|
|
343
|
-
}
|
|
344
|
-
}, 150));
|
|
345
|
-
}, [l, i, S, I, X]), C = a(() => {
|
|
346
|
-
if (!l) return;
|
|
347
|
-
const t = l, { scrollTop: o, scrollLeft: e, scrollHeight: r, scrollWidth: s, clientHeight: c, clientWidth: n } = t, f = o <= 10, k = o + c >= r - 10, v = e <= 10, m = e + n >= s - 10;
|
|
348
|
-
d !== "x" && (u.current.top?.classList.toggle("opacity-0", f), u.current.top?.classList.toggle("pointer-events-none", f), u.current.top?.classList.toggle("pointer-events-auto", !f), u.current.bottom?.classList.toggle("opacity-0", k), u.current.bottom?.classList.toggle("pointer-events-none", k), u.current.bottom?.classList.toggle("pointer-events-auto", !k)), d !== "y" && (u.current.left?.classList.toggle("opacity-0", v), u.current.left?.classList.toggle("pointer-events-none", v), u.current.left?.classList.toggle("pointer-events-auto", !v), u.current.right?.classList.toggle("opacity-0", m), u.current.right?.classList.toggle("pointer-events-none", m), u.current.right?.classList.toggle("pointer-events-auto", !m));
|
|
349
|
-
}, [l, d]), ee = a((t) => {
|
|
350
|
-
Ft(t);
|
|
351
|
-
}, []);
|
|
352
|
-
return At(() => {
|
|
353
|
-
if (!l) return;
|
|
354
|
-
if (W && !P) {
|
|
355
|
-
const e = typeof W == "string" ? `scrollable-${W}` : `scrollable-session-${Math.random().toString(36).substr(2, 9)}`;
|
|
356
|
-
zt(e);
|
|
357
|
-
}
|
|
358
|
-
if (W && P && !ut) {
|
|
359
|
-
Kt(!0);
|
|
360
|
-
try {
|
|
361
|
-
const e = sessionStorage.getItem(P);
|
|
362
|
-
if (e) {
|
|
363
|
-
const { scrollTop: r, scrollLeft: s } = JSON.parse(e);
|
|
364
|
-
l.scrollTop = r, l.scrollLeft = s;
|
|
365
|
-
}
|
|
366
|
-
} catch {
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
C(), ft || (Ut(!0), requestAnimationFrame(() => {
|
|
370
|
-
Object.values(u.current).forEach((e) => {
|
|
371
|
-
e?.classList.add("transition-all", "duration-300");
|
|
372
|
-
}), setTimeout(() => {
|
|
373
|
-
C();
|
|
374
|
-
}, 0);
|
|
375
|
-
}));
|
|
376
|
-
const t = () => {
|
|
377
|
-
if (C(), dt(), l) {
|
|
378
|
-
const e = {
|
|
379
|
-
scrollTop: l.scrollTop,
|
|
380
|
-
scrollLeft: l.scrollLeft
|
|
381
|
-
};
|
|
382
|
-
kt(e);
|
|
383
|
-
}
|
|
384
|
-
if (W && P) {
|
|
385
|
-
$ && clearTimeout($);
|
|
386
|
-
const e = setTimeout(() => {
|
|
387
|
-
try {
|
|
388
|
-
if (!l) return;
|
|
389
|
-
const r = {
|
|
390
|
-
scrollTop: l.scrollTop,
|
|
391
|
-
scrollLeft: l.scrollLeft
|
|
392
|
-
};
|
|
393
|
-
sessionStorage.setItem(P, JSON.stringify(r));
|
|
394
|
-
} catch {
|
|
395
|
-
}
|
|
396
|
-
}, 150);
|
|
397
|
-
_t(e);
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
l.addEventListener("scroll", t);
|
|
401
|
-
const o = (e) => {
|
|
402
|
-
if (Lt) {
|
|
403
|
-
e.preventDefault();
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
(i || S) && I(void 0, !0), K.current = !0, D.current && clearTimeout(D.current), D.current = setTimeout(() => {
|
|
407
|
-
if (K.current = !1, q.current) {
|
|
408
|
-
const { position: r, behavior: s, type: c } = q.current;
|
|
409
|
-
X(r, s, c);
|
|
410
|
-
}
|
|
411
|
-
}, 350);
|
|
412
|
-
};
|
|
413
|
-
return l.addEventListener("wheel", o, { passive: !1 }), tt.current = new MutationObserver((e) => {
|
|
414
|
-
e.some((r) => r.type === "childList" && r.target === l) && (console.log("MutationObserver: childList changes detected.", e), C(), dt(), l.scrollTop + l.clientHeight >= l.scrollHeight - 20 && Et());
|
|
415
|
-
}), tt.current.observe(l, { childList: !0, subtree: !1 }), () => {
|
|
416
|
-
l.removeEventListener("scroll", t), l.removeEventListener("wheel", o), $ && clearTimeout($), tt.current && tt.current.disconnect();
|
|
417
|
-
};
|
|
418
|
-
}, [
|
|
419
|
-
l,
|
|
420
|
-
W,
|
|
421
|
-
P,
|
|
422
|
-
ut,
|
|
423
|
-
ft,
|
|
424
|
-
Lt,
|
|
425
|
-
C,
|
|
426
|
-
dt,
|
|
427
|
-
kt,
|
|
428
|
-
i,
|
|
429
|
-
S,
|
|
430
|
-
I,
|
|
431
|
-
X,
|
|
432
|
-
Et
|
|
433
|
-
]), At(() => {
|
|
434
|
-
C();
|
|
435
|
-
}, [qt, C]), Wt(() => {
|
|
436
|
-
if (!l) return;
|
|
437
|
-
let t = bt(l);
|
|
438
|
-
Object.entries(U).forEach(([o, e]) => {
|
|
439
|
-
if (e?.show && e.type === "shadow") {
|
|
440
|
-
const r = u.current[o], s = r?.querySelector(".shadow-base"), c = r?.querySelector(".shadow-hover");
|
|
441
|
-
if (s) {
|
|
442
|
-
s.dataset.bgColor = t;
|
|
443
|
-
const n = o === "left" || o === "right" ? "to right" : "to bottom";
|
|
444
|
-
s.style.background = `linear-gradient(${n}, ${t} 2%, ${x(t, -2, 55)} 50%, ${x(t, -1, 30)} 80%, transparent)`;
|
|
445
|
-
}
|
|
446
|
-
if (c) {
|
|
447
|
-
const n = o === "left" || o === "right" ? "to right" : "to bottom";
|
|
448
|
-
c.style.height += "60px", c.style.background = `linear-gradient(${n}, ${t} 2%, ${x(t, 10, 20)} 20%, ${x(t, 6, 10)} 70%, transparent)`;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
}, [l, U, d]), Wt(() => () => {
|
|
453
|
-
i && clearInterval(i), S && clearTimeout(S), w && clearTimeout(w), $ && clearTimeout($), D.current && clearTimeout(D.current);
|
|
454
|
-
}, [i, S, w, $]), { state: {
|
|
455
|
-
scrollableElement: l,
|
|
456
|
-
indicatorRefs: u.current,
|
|
457
|
-
scrollTopButtonVisible: Nt,
|
|
458
|
-
activePosition: at,
|
|
459
|
-
continuousScrollStarted: it,
|
|
460
|
-
clickToEndEnabled: T,
|
|
461
|
-
hoverScrollInterval: i,
|
|
462
|
-
hoverDebounceTimeout: S,
|
|
463
|
-
clickToEndTimeout: w,
|
|
464
|
-
saveScrollTimeout: $,
|
|
465
|
-
scrollKey: P,
|
|
466
|
-
hasRestoredScroll: ut,
|
|
467
|
-
hasRendered: ft,
|
|
468
|
-
finalIndicators: U,
|
|
469
|
-
finalScrollbarProps: Xt
|
|
470
|
-
}, handlers: {
|
|
471
|
-
subscribeToScrollTarget: Yt,
|
|
472
|
-
scrollByAmount: H,
|
|
473
|
-
scrollToEnd: mt,
|
|
474
|
-
scrollToTop: jt,
|
|
475
|
-
handleIndicatorClick: Jt,
|
|
476
|
-
handleIndicatorMouseEnter: X,
|
|
477
|
-
handleIndicatorMouseLeave: Gt,
|
|
478
|
-
handleIndicatorMouseDown: Qt,
|
|
479
|
-
handleIndicatorMouseUp: Zt,
|
|
480
|
-
handleIndicatorWheel: te,
|
|
481
|
-
setScrollableRef: ee,
|
|
482
|
-
updateIndicatorsVisibility: C
|
|
483
|
-
} };
|
|
484
|
-
}
|
|
485
|
-
export {
|
|
486
|
-
ue as u
|
|
487
|
-
};
|