@orioncactuscorp/ui 1.8.0 → 1.9.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/dist/components/Accordion/Accordion.css +1 -1
- package/dist/components/Button/Button.css +1 -1
- package/dist/components/Checkbox/Checkbox.css +1 -1
- package/dist/components/Modal/Modal.css +1 -1
- package/dist/components/Modal/Modal.js +696 -544
- package/dist/components/Modal/bottomSheetGeometry.js +88 -0
- package/dist/components/Modal/modalScrollArbitration.js +8 -7
- package/dist/components/Modal/snapPoints.js +9 -8
- package/dist/components/Modal/useModalContentBlockTransition.js +64 -0
- package/dist/components/Modal/useModalDrag.js +917 -788
- package/dist/components/Radio/Radio.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +250 -223
- package/dist/components/ScrollArea/useScrollAreaGeometryStabilizer.js +36 -0
- package/dist/components/TextButton/TextButton.css +1 -1
- package/dist/components/TextButton/TextButton.module.scss.js +8 -6
- package/dist/styles.css +7 -7
- package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
- package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/bottomSheetGeometry.d.ts +36 -0
- package/dist/ui/src/components/Modal/bottomSheetGeometry.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/index.d.ts +1 -1
- package/dist/ui/src/components/Modal/index.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts +2 -1
- package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/snapPoints.d.ts +1 -0
- package/dist/ui/src/components/Modal/snapPoints.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/types.d.ts +8 -0
- package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
- package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts +5 -0
- package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -0
- package/dist/ui/src/components/Modal/useModalDrag.d.ts +5 -1
- package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
- package/dist/ui/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/ui/src/components/ScrollArea/useScrollAreaGeometryStabilizer.d.ts +11 -0
- package/dist/ui/src/components/ScrollArea/useScrollAreaGeometryStabilizer.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/scss/mixins/_element.scss +161 -14
- package/src/scss/mixins/_element.test.ts +94 -5
- package/src/scss/mixins/_icon.scss +27 -0
|
@@ -1,93 +1,98 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as w, jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import { ScrollAreaContext as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { jsx as w, jsxs as kt } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as p, useSyncExternalStore as wt, useState as X, useCallback as s, useMemo as At, useEffect as it, useLayoutEffect as vt, useContext as Nt } from "react";
|
|
4
|
+
import bt from "../Interaction/Interaction.js";
|
|
5
|
+
import { ScrollAreaContext as Tt } from "./contexts.js";
|
|
6
|
+
import b from "./ScrollArea.module.scss.js";
|
|
7
|
+
import { useScrollAreaGeometryStabilizer as Ot } from "./useScrollAreaGeometryStabilizer.js";
|
|
8
|
+
const lt = "oc-scroll-area-container-style", at = "oc-scroll-area-root-style";
|
|
9
|
+
let F = 0, q = 0;
|
|
10
|
+
function Et() {
|
|
10
11
|
return () => {
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function $t() {
|
|
14
15
|
return !0;
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
+
function Rt() {
|
|
17
18
|
return !1;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function Vt() {
|
|
20
21
|
return typeof window < "u" && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
23
|
+
function C(m) {
|
|
24
|
+
return m.preventDefault(), !1;
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function Ut(m, e) {
|
|
26
27
|
let E = !1;
|
|
27
28
|
return () => {
|
|
28
|
-
E || (
|
|
29
|
+
E || (m(), E = !0, window.setTimeout(() => {
|
|
29
30
|
E = !1;
|
|
30
31
|
}, e));
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
typeof
|
|
34
|
+
function yt(m, e) {
|
|
35
|
+
typeof m == "function" ? m(e) : m && (m.current = e);
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
37
|
+
function T(m, e) {
|
|
38
|
+
m && (m.dataset.state = e, m.dataset.ocState = e);
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
-
as:
|
|
40
|
+
function Qt({
|
|
41
|
+
as: m,
|
|
41
42
|
root: e = !1,
|
|
42
43
|
children: E,
|
|
43
44
|
className: L = "",
|
|
44
|
-
ref:
|
|
45
|
-
"data-oc-component":
|
|
46
|
-
...
|
|
45
|
+
ref: k,
|
|
46
|
+
"data-oc-component": A = "scroll-area",
|
|
47
|
+
...N
|
|
47
48
|
}) {
|
|
48
|
-
const M =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
), [o,
|
|
49
|
+
const M = m ?? "div", P = p(null), v = wt(
|
|
50
|
+
Et,
|
|
51
|
+
$t,
|
|
52
|
+
Rt
|
|
53
|
+
), y = wt(
|
|
54
|
+
Et,
|
|
55
|
+
Vt,
|
|
56
|
+
Rt
|
|
57
|
+
), [o, St] = X(null), [J, Ht] = X(!1), [K, Wt] = X(!1), B = p(null), f = p(null), u = p(null), D = p(null), g = p(null), d = p(null), [O, Ct] = X(null), [$, Lt] = X(null), x = p(!1), Y = p(!1), Q = p(0), Z = p(0), H = p(null), S = p(null), V = p(null), U = p(null), st = s(
|
|
57
58
|
(t) => {
|
|
58
|
-
|
|
59
|
+
P.current = t, yt(k, t);
|
|
59
60
|
},
|
|
60
|
-
[
|
|
61
|
-
),
|
|
62
|
-
|
|
63
|
-
}, []),
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
[k]
|
|
62
|
+
), ut = s((t) => {
|
|
63
|
+
St(t);
|
|
64
|
+
}, []), Mt = s((t) => {
|
|
65
|
+
f.current = t, Ct(t);
|
|
66
|
+
}, []), Pt = s((t) => {
|
|
67
|
+
g.current = t, Lt(t);
|
|
68
|
+
}, []), Bt = At(
|
|
69
|
+
() => ({ isRoot: e, setContainerRef: ut }),
|
|
70
|
+
[e, ut]
|
|
66
71
|
);
|
|
67
|
-
|
|
68
|
-
if (!(!v ||
|
|
69
|
-
if (
|
|
72
|
+
it(() => {
|
|
73
|
+
if (!(!v || y || typeof document > "u")) {
|
|
74
|
+
if (F += 1, e && (q += 1), !document.getElementById(lt)) {
|
|
70
75
|
const t = document.createElement("style");
|
|
71
|
-
t.id =
|
|
76
|
+
t.id = lt, t.textContent = `
|
|
72
77
|
[data-oc-scroll-container]::-webkit-scrollbar { display: none; }
|
|
73
78
|
[data-oc-scroll-container] { scrollbar-width: none; }
|
|
74
79
|
`, document.head.appendChild(t);
|
|
75
80
|
}
|
|
76
|
-
if (e && !document.getElementById(
|
|
81
|
+
if (e && !document.getElementById(at)) {
|
|
77
82
|
const t = document.createElement("style");
|
|
78
|
-
t.id =
|
|
83
|
+
t.id = at, t.textContent = `
|
|
79
84
|
::-webkit-scrollbar { display: none; }
|
|
80
85
|
body { scrollbar-width: none; }
|
|
81
86
|
`, document.head.appendChild(t);
|
|
82
87
|
}
|
|
83
88
|
return () => {
|
|
84
|
-
|
|
89
|
+
F = Math.max(0, F - 1), e && (q = Math.max(
|
|
85
90
|
0,
|
|
86
|
-
|
|
87
|
-
)),
|
|
91
|
+
q - 1
|
|
92
|
+
)), q === 0 && document.getElementById(at)?.remove(), F === 0 && document.getElementById(lt)?.remove();
|
|
88
93
|
};
|
|
89
94
|
}
|
|
90
|
-
}, [v, e,
|
|
95
|
+
}, [v, e, y]), it(() => {
|
|
91
96
|
if (!v || !e || typeof document > "u")
|
|
92
97
|
return;
|
|
93
98
|
const t = document.body.style.overflow;
|
|
@@ -101,7 +106,7 @@ function kt({
|
|
|
101
106
|
}, 1), window.clearTimeout(n);
|
|
102
107
|
};
|
|
103
108
|
}, [v, e]);
|
|
104
|
-
const
|
|
109
|
+
const dt = s(() => {
|
|
105
110
|
const t = o;
|
|
106
111
|
if (t) {
|
|
107
112
|
if (f.current) {
|
|
@@ -119,105 +124,123 @@ function kt({
|
|
|
119
124
|
);
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
|
-
}, [o, e]),
|
|
127
|
+
}, [o, e]), R = s(() => {
|
|
123
128
|
const t = o;
|
|
124
129
|
if (t) {
|
|
125
|
-
if (f.current &&
|
|
130
|
+
if (f.current && u.current)
|
|
126
131
|
if (e) {
|
|
127
132
|
const n = window.scrollY || document.documentElement.scrollTop, r = window.innerHeight, c = document.documentElement.scrollHeight;
|
|
128
133
|
if (c > r) {
|
|
129
|
-
const i = f.current.getBoundingClientRect().height -
|
|
130
|
-
let
|
|
131
|
-
n >
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const i = f.current.getBoundingClientRect().height - u.current.clientHeight, a = c - r;
|
|
135
|
+
let l = n, h = 0;
|
|
136
|
+
n > a ? (h = n - a, l = a) : n < 0 && (h = n, l = 0);
|
|
137
|
+
const ot = l / a * i + h;
|
|
138
|
+
u.current.style.transform = `translateY(${ot}px)`;
|
|
134
139
|
}
|
|
135
140
|
} else {
|
|
136
141
|
const { scrollTop: n, clientHeight: r, scrollHeight: c } = t;
|
|
137
142
|
if (c > r) {
|
|
138
|
-
const i = f.current.getBoundingClientRect().height -
|
|
139
|
-
|
|
143
|
+
const i = f.current.getBoundingClientRect().height - u.current.clientHeight, a = n / (c - r) * i;
|
|
144
|
+
u.current.style.transform = `translateY(${a}px)`;
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
|
-
if (g.current &&
|
|
147
|
+
if (g.current && d.current) {
|
|
143
148
|
const n = e ? window.scrollX || document.documentElement.scrollLeft : t.scrollLeft, r = e ? window.innerWidth : t.clientWidth, c = e ? document.documentElement.scrollWidth : t.scrollWidth;
|
|
144
149
|
if (c > r) {
|
|
145
|
-
const i = g.current.getBoundingClientRect().width -
|
|
146
|
-
|
|
150
|
+
const i = g.current.getBoundingClientRect().width - d.current.clientWidth, a = n / (c - r) * i;
|
|
151
|
+
d.current.style.transform = `translateX(${a}px)`;
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
|
-
}, [o, e]),
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
}, [o, e]), ht = s(() => {
|
|
156
|
+
T(B.current, "active"), T(D.current, "active"), H.current !== null && window.clearTimeout(H.current), H.current = window.setTimeout(() => {
|
|
157
|
+
T(B.current, "hidden"), T(D.current, "hidden"), H.current = null;
|
|
153
158
|
}, 1e3);
|
|
154
|
-
}, []),
|
|
155
|
-
|
|
156
|
-
}, [
|
|
159
|
+
}, []), tt = s(() => {
|
|
160
|
+
R(), ht();
|
|
161
|
+
}, [ht, R]), mt = s(() => {
|
|
157
162
|
const t = o;
|
|
158
163
|
if (!t) return;
|
|
159
164
|
const n = e ? window.innerHeight : t.clientHeight, r = e ? window.innerWidth : t.clientWidth;
|
|
160
|
-
|
|
161
|
-
}, [o, e]),
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const n =
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
Ht(t.scrollHeight > n), Wt(t.scrollWidth > r);
|
|
166
|
+
}, [o, e]), Dt = s(() => {
|
|
167
|
+
const t = o;
|
|
168
|
+
if (!t) return "";
|
|
169
|
+
const n = f.current?.getBoundingClientRect().height ?? 0, r = g.current?.getBoundingClientRect().width ?? 0;
|
|
170
|
+
return [
|
|
171
|
+
t.clientWidth,
|
|
172
|
+
t.clientHeight,
|
|
173
|
+
t.scrollWidth,
|
|
174
|
+
t.scrollHeight,
|
|
175
|
+
n,
|
|
176
|
+
r
|
|
177
|
+
].join(":");
|
|
178
|
+
}, [o]), xt = s(() => {
|
|
179
|
+
mt(), dt(), R();
|
|
180
|
+
}, [mt, dt, R]), { cancelGeometryUpdate: _, scheduleGeometryUpdate: W } = Ot({
|
|
181
|
+
enabled: v && !!o && !y,
|
|
182
|
+
getGeometrySignature: Dt,
|
|
183
|
+
updateGeometry: xt
|
|
184
|
+
}), Yt = (t) => {
|
|
185
|
+
if (t.preventDefault(), t.stopPropagation(), !f.current || !u.current || !o) return;
|
|
186
|
+
x.current = !0, u.current.dataset.state = "dragging", u.current.dataset.ocState = "dragging";
|
|
187
|
+
const n = e ? window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) : o.scrollTop / (o.scrollHeight - o.clientHeight), r = f.current.getBoundingClientRect().height - u.current.clientHeight;
|
|
188
|
+
Q.current = t.clientY - n * r, document.addEventListener("selectstart", C), document.addEventListener("dragstart", C);
|
|
189
|
+
}, It = (t) => {
|
|
190
|
+
if (t.preventDefault(), t.stopPropagation(), !g.current || !d.current || !o) return;
|
|
191
|
+
Y.current = !0, d.current.dataset.state = "dragging", d.current.dataset.ocState = "dragging";
|
|
192
|
+
const n = e ? window.scrollX / (document.documentElement.scrollWidth - window.innerWidth) : o.scrollLeft / (o.scrollWidth - o.clientWidth), r = g.current.getBoundingClientRect().width - d.current.clientWidth;
|
|
193
|
+
Z.current = t.clientX - n * r, document.addEventListener("selectstart", C), document.addEventListener("dragstart", C);
|
|
194
|
+
}, et = s(
|
|
172
195
|
(t, n, r) => {
|
|
173
|
-
const c = t === "vertical" ? f.current : g.current, i = t === "vertical" ?
|
|
196
|
+
const c = t === "vertical" ? f.current : g.current, i = t === "vertical" ? u.current : d.current;
|
|
174
197
|
if (!c || !i) return;
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
198
|
+
const a = t === "vertical" ? window.innerHeight : window.innerWidth, l = t === "vertical" ? document.documentElement.scrollHeight : document.documentElement.scrollWidth, h = t === "vertical" ? c.getBoundingClientRect().height : c.getBoundingClientRect().width, ot = t === "vertical" ? i.clientHeight : i.clientWidth, ct = h - ot;
|
|
199
|
+
if (ct <= 0) return;
|
|
200
|
+
const gt = Math.max(
|
|
178
201
|
0,
|
|
179
|
-
Math.min(n - r.current,
|
|
180
|
-
) /
|
|
181
|
-
t === "vertical" ? document.documentElement.scrollTop =
|
|
202
|
+
Math.min(n - r.current, ct)
|
|
203
|
+
) / ct;
|
|
204
|
+
t === "vertical" ? document.documentElement.scrollTop = gt * (l - a) : document.documentElement.scrollLeft = gt * (l - a);
|
|
182
205
|
},
|
|
183
206
|
[]
|
|
184
|
-
),
|
|
207
|
+
), nt = s(
|
|
185
208
|
(t) => {
|
|
186
209
|
if (!o) return;
|
|
187
210
|
let n = !1;
|
|
188
211
|
if (e) {
|
|
189
212
|
const r = document.documentElement.style.scrollBehavior;
|
|
190
|
-
document.documentElement.style.scrollBehavior = "auto",
|
|
213
|
+
document.documentElement.style.scrollBehavior = "auto", x.current && (t.preventDefault(), t.stopPropagation(), et("vertical", t.clientY, Q), n = !0), Y.current && (t.preventDefault(), t.stopPropagation(), et("horizontal", t.clientX, Z), n = !0), document.documentElement.style.scrollBehavior = r;
|
|
191
214
|
} else {
|
|
192
|
-
if (
|
|
215
|
+
if (x.current && f.current && u.current) {
|
|
193
216
|
t.preventDefault(), t.stopPropagation();
|
|
194
|
-
const r = f.current.getBoundingClientRect().height -
|
|
217
|
+
const r = f.current.getBoundingClientRect().height - u.current.clientHeight;
|
|
195
218
|
if (r > 0) {
|
|
196
219
|
const i = Math.max(
|
|
197
220
|
0,
|
|
198
|
-
Math.min(t.clientY -
|
|
221
|
+
Math.min(t.clientY - Q.current, r)
|
|
199
222
|
) / r * (o.scrollHeight - o.clientHeight);
|
|
200
223
|
o.scrollTo({ top: i, behavior: "auto" }), n = !0;
|
|
201
224
|
}
|
|
202
225
|
}
|
|
203
|
-
if (
|
|
226
|
+
if (Y.current && g.current && d.current) {
|
|
204
227
|
t.preventDefault(), t.stopPropagation();
|
|
205
|
-
const r = g.current.getBoundingClientRect().width -
|
|
228
|
+
const r = g.current.getBoundingClientRect().width - d.current.clientWidth;
|
|
206
229
|
if (r > 0) {
|
|
207
230
|
const i = Math.max(
|
|
208
231
|
0,
|
|
209
|
-
Math.min(t.clientX -
|
|
232
|
+
Math.min(t.clientX - Z.current, r)
|
|
210
233
|
) / r * (o.scrollWidth - o.clientWidth);
|
|
211
234
|
o.scrollTo({ left: i, behavior: "auto" }), n = !0;
|
|
212
235
|
}
|
|
213
236
|
}
|
|
214
237
|
}
|
|
215
|
-
n &&
|
|
238
|
+
n && R();
|
|
216
239
|
},
|
|
217
|
-
[o, e,
|
|
218
|
-
),
|
|
219
|
-
|
|
220
|
-
}, []),
|
|
240
|
+
[o, e, et, R]
|
|
241
|
+
), rt = s(() => {
|
|
242
|
+
x.current = !1, Y.current = !1, u.current && (u.current.dataset.state = "hidden", u.current.dataset.ocState = "hidden"), d.current && (d.current.dataset.state = "hidden", d.current.dataset.ocState = "hidden"), document.removeEventListener("selectstart", C), document.removeEventListener("dragstart", C);
|
|
243
|
+
}, []), ft = (t) => {
|
|
221
244
|
t.preventDefault();
|
|
222
245
|
const n = t.currentTarget.dataset.ocOrientation ?? t.currentTarget.dataset.orientation;
|
|
223
246
|
if (e) {
|
|
@@ -234,133 +257,137 @@ function kt({
|
|
|
234
257
|
top: o.scrollTop + t.deltaY,
|
|
235
258
|
behavior: "auto"
|
|
236
259
|
}));
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
}, []),
|
|
240
|
-
|
|
241
|
-
|
|
260
|
+
}, G = s(() => {
|
|
261
|
+
S.current !== null && (window.clearTimeout(S.current), S.current = null);
|
|
262
|
+
}, []), pt = s(() => {
|
|
263
|
+
G(), S.current = window.setTimeout(() => {
|
|
264
|
+
T(f.current, "hidden"), T(g.current, "hidden"), S.current = null;
|
|
242
265
|
}, 200);
|
|
243
|
-
}, [
|
|
266
|
+
}, [G]), j = s(
|
|
244
267
|
(t) => {
|
|
245
|
-
t ? (
|
|
268
|
+
t ? (T(f.current, "active"), T(g.current, "active"), G()) : !x.current && !Y.current && pt();
|
|
246
269
|
},
|
|
247
|
-
[
|
|
248
|
-
),
|
|
249
|
-
|
|
250
|
-
}, []),
|
|
251
|
-
|
|
252
|
-
}, []),
|
|
253
|
-
if (t.target !== t.currentTarget || !o || !
|
|
270
|
+
[G, pt]
|
|
271
|
+
), I = s(() => {
|
|
272
|
+
V.current !== null && (window.clearInterval(V.current), V.current = null);
|
|
273
|
+
}, []), z = s(() => {
|
|
274
|
+
U.current !== null && (window.clearInterval(U.current), U.current = null);
|
|
275
|
+
}, []), zt = (t) => {
|
|
276
|
+
if (t.target !== t.currentTarget || !o || !u.current)
|
|
254
277
|
return;
|
|
255
|
-
const n = t.clientY, r =
|
|
278
|
+
const n = t.clientY, r = u.current.getBoundingClientRect(), c = n < r.top ? "up" : n > r.bottom ? "down" : null;
|
|
256
279
|
if (!c) return;
|
|
257
|
-
const i = e ? window.innerHeight : o.clientHeight,
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
|
|
280
|
+
const i = e ? window.innerHeight : o.clientHeight, a = () => {
|
|
281
|
+
const l = u.current?.getBoundingClientRect();
|
|
282
|
+
if (l && n >= l.top && n <= l.bottom) {
|
|
283
|
+
I();
|
|
261
284
|
return;
|
|
262
285
|
}
|
|
263
286
|
if (e) {
|
|
264
|
-
const
|
|
287
|
+
const h = window.scrollY || document.documentElement.scrollTop;
|
|
265
288
|
window.scrollTo({
|
|
266
|
-
top: c === "up" ?
|
|
289
|
+
top: c === "up" ? h - i : h + i,
|
|
267
290
|
behavior: "smooth"
|
|
268
291
|
});
|
|
269
292
|
} else {
|
|
270
|
-
const
|
|
293
|
+
const h = o.scrollTop;
|
|
271
294
|
o.scrollTo({
|
|
272
|
-
top: c === "up" ?
|
|
295
|
+
top: c === "up" ? h - i : h + i,
|
|
273
296
|
behavior: "smooth"
|
|
274
297
|
});
|
|
275
298
|
}
|
|
276
|
-
|
|
299
|
+
R();
|
|
277
300
|
};
|
|
278
|
-
|
|
279
|
-
},
|
|
280
|
-
if (t.target !== t.currentTarget || !o || !
|
|
301
|
+
a(), V.current = window.setInterval(a, 300);
|
|
302
|
+
}, Xt = (t) => {
|
|
303
|
+
if (t.target !== t.currentTarget || !o || !d.current)
|
|
281
304
|
return;
|
|
282
|
-
const n = t.clientX, r =
|
|
305
|
+
const n = t.clientX, r = d.current.getBoundingClientRect(), c = n < r.left ? "left" : n > r.right ? "right" : null;
|
|
283
306
|
if (!c) return;
|
|
284
|
-
const i = e ? window.innerWidth : o.clientWidth,
|
|
285
|
-
const
|
|
286
|
-
if (
|
|
287
|
-
|
|
307
|
+
const i = e ? window.innerWidth : o.clientWidth, a = () => {
|
|
308
|
+
const l = d.current?.getBoundingClientRect();
|
|
309
|
+
if (l && n >= l.left && n <= l.right) {
|
|
310
|
+
z();
|
|
288
311
|
return;
|
|
289
312
|
}
|
|
290
313
|
if (e) {
|
|
291
|
-
const
|
|
314
|
+
const h = window.scrollX || document.documentElement.scrollLeft;
|
|
292
315
|
window.scrollTo({
|
|
293
|
-
left: c === "left" ?
|
|
316
|
+
left: c === "left" ? h - i : h + i,
|
|
294
317
|
behavior: "smooth"
|
|
295
318
|
});
|
|
296
319
|
} else {
|
|
297
|
-
const
|
|
320
|
+
const h = o.scrollLeft;
|
|
298
321
|
o.scrollTo({
|
|
299
|
-
left: c === "left" ?
|
|
322
|
+
left: c === "left" ? h - i : h + i,
|
|
300
323
|
behavior: "smooth"
|
|
301
324
|
});
|
|
302
325
|
}
|
|
303
|
-
|
|
326
|
+
R();
|
|
304
327
|
};
|
|
305
|
-
|
|
328
|
+
a(), U.current = window.setInterval(a, 300);
|
|
306
329
|
};
|
|
307
|
-
return
|
|
330
|
+
return vt(() => {
|
|
308
331
|
const t = o;
|
|
309
|
-
if (!v || !t ||
|
|
310
|
-
const n = window.requestAnimationFrame(
|
|
311
|
-
|
|
312
|
-
}), r = e ? window : t;
|
|
313
|
-
r.addEventListener("scroll", K, {
|
|
332
|
+
if (!v || !t || y) return;
|
|
333
|
+
const n = window.requestAnimationFrame(W), r = e ? window : t;
|
|
334
|
+
r.addEventListener("scroll", tt, {
|
|
314
335
|
passive: !0
|
|
315
336
|
});
|
|
316
337
|
const c = () => {
|
|
317
|
-
|
|
338
|
+
W();
|
|
318
339
|
};
|
|
319
|
-
window.addEventListener("resize", c), document.addEventListener("mousemove",
|
|
320
|
-
const i =
|
|
321
|
-
|
|
322
|
-
}, 100),
|
|
323
|
-
|
|
340
|
+
window.addEventListener("resize", c), document.addEventListener("mousemove", nt), document.addEventListener("mouseup", rt);
|
|
341
|
+
const i = Ut(() => {
|
|
342
|
+
W();
|
|
343
|
+
}, 100), a = new MutationObserver(i);
|
|
344
|
+
a.observe(t, {
|
|
324
345
|
attributes: !0,
|
|
325
346
|
characterData: !0,
|
|
326
347
|
childList: !0,
|
|
327
348
|
subtree: !0
|
|
328
|
-
})
|
|
329
|
-
|
|
349
|
+
});
|
|
350
|
+
const l = typeof ResizeObserver > "u" ? null : new ResizeObserver(i);
|
|
351
|
+
return l && (l.observe(t), P.current && l.observe(P.current), t.firstElementChild instanceof HTMLElement && l.observe(t.firstElementChild), B.current && l.observe(B.current), O && l.observe(O), D.current && l.observe(D.current), $ && l.observe($)), () => {
|
|
352
|
+
r.removeEventListener("scroll", tt), window.removeEventListener("resize", c), document.removeEventListener("mousemove", nt), document.removeEventListener("mouseup", rt), window.cancelAnimationFrame(n), _(), a.disconnect(), l?.disconnect();
|
|
330
353
|
};
|
|
331
354
|
}, [
|
|
332
|
-
|
|
355
|
+
_,
|
|
333
356
|
o,
|
|
357
|
+
W,
|
|
334
358
|
v,
|
|
335
|
-
K,
|
|
336
|
-
Z,
|
|
337
359
|
tt,
|
|
360
|
+
nt,
|
|
361
|
+
rt,
|
|
338
362
|
e,
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
363
|
+
K,
|
|
364
|
+
J,
|
|
365
|
+
$,
|
|
366
|
+
y,
|
|
367
|
+
O
|
|
368
|
+
]), vt(() => {
|
|
369
|
+
W();
|
|
344
370
|
}, [
|
|
345
371
|
o,
|
|
346
372
|
v,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
373
|
+
K,
|
|
374
|
+
J,
|
|
375
|
+
$,
|
|
376
|
+
W,
|
|
377
|
+
y,
|
|
378
|
+
O
|
|
379
|
+
]), it(
|
|
353
380
|
() => () => {
|
|
354
|
-
H.current !== null && window.clearTimeout(H.current),
|
|
381
|
+
H.current !== null && window.clearTimeout(H.current), S.current !== null && window.clearTimeout(S.current), I(), z(), _();
|
|
355
382
|
},
|
|
356
|
-
[
|
|
357
|
-
), !v ||
|
|
383
|
+
[_, z, I]
|
|
384
|
+
), !v || y ? /* @__PURE__ */ w(
|
|
358
385
|
M,
|
|
359
386
|
{
|
|
360
|
-
ref:
|
|
361
|
-
className: `${
|
|
362
|
-
...
|
|
363
|
-
"data-oc-component":
|
|
387
|
+
ref: st,
|
|
388
|
+
className: `${b.scrollArea} ${L}`.trim(),
|
|
389
|
+
...N,
|
|
390
|
+
"data-oc-component": A,
|
|
364
391
|
"data-root": e ? "" : void 0,
|
|
365
392
|
"data-oc-scroll-root": e ? "true" : void 0,
|
|
366
393
|
"data-scroll": "",
|
|
@@ -369,13 +396,13 @@ function kt({
|
|
|
369
396
|
"data-oc-scroll-label": e ? "root" : void 0,
|
|
370
397
|
children: E
|
|
371
398
|
}
|
|
372
|
-
) : /* @__PURE__ */ w(
|
|
399
|
+
) : /* @__PURE__ */ w(Tt.Provider, { value: Bt, children: /* @__PURE__ */ kt(
|
|
373
400
|
M,
|
|
374
401
|
{
|
|
375
|
-
ref:
|
|
376
|
-
className: `${
|
|
377
|
-
...
|
|
378
|
-
"data-oc-component":
|
|
402
|
+
ref: st,
|
|
403
|
+
className: `${b.scrollArea} ${L}`.trim(),
|
|
404
|
+
...N,
|
|
405
|
+
"data-oc-component": A,
|
|
379
406
|
"data-root": e ? "" : void 0,
|
|
380
407
|
"data-oc-scroll-root": e ? "true" : void 0,
|
|
381
408
|
"data-scroll": "",
|
|
@@ -384,42 +411,42 @@ function kt({
|
|
|
384
411
|
"data-oc-scroll-label": e ? "root" : void 0,
|
|
385
412
|
children: [
|
|
386
413
|
E,
|
|
387
|
-
|
|
414
|
+
J ? /* @__PURE__ */ w(
|
|
388
415
|
"div",
|
|
389
416
|
{
|
|
390
|
-
ref:
|
|
391
|
-
className:
|
|
417
|
+
ref: B,
|
|
418
|
+
className: b.scrollbar,
|
|
392
419
|
"data-oc-part": "scrollbar-vertical",
|
|
393
420
|
"data-orientation": "vertical",
|
|
394
421
|
"data-oc-orientation": "vertical",
|
|
395
422
|
"data-state": "hidden",
|
|
396
423
|
"data-oc-state": "hidden",
|
|
397
|
-
onWheel:
|
|
424
|
+
onWheel: ft,
|
|
398
425
|
children: /* @__PURE__ */ w(
|
|
399
426
|
"div",
|
|
400
427
|
{
|
|
401
|
-
ref:
|
|
402
|
-
className:
|
|
428
|
+
ref: Mt,
|
|
429
|
+
className: b.wrapper,
|
|
403
430
|
"data-oc-part": "scrollbar-track",
|
|
404
431
|
"data-state": "hidden",
|
|
405
432
|
"data-oc-state": "hidden",
|
|
406
433
|
role: "presentation",
|
|
407
|
-
onMouseDown:
|
|
408
|
-
onMouseEnter: () =>
|
|
434
|
+
onMouseDown: zt,
|
|
435
|
+
onMouseEnter: () => j(!0),
|
|
409
436
|
onMouseLeave: () => {
|
|
410
|
-
|
|
437
|
+
I(), j(!1);
|
|
411
438
|
},
|
|
412
|
-
onMouseUp:
|
|
439
|
+
onMouseUp: I,
|
|
413
440
|
children: /* @__PURE__ */ w(
|
|
414
441
|
"div",
|
|
415
442
|
{
|
|
416
|
-
ref:
|
|
417
|
-
className:
|
|
443
|
+
ref: u,
|
|
444
|
+
className: b.thumb,
|
|
418
445
|
"data-oc-part": "thumb",
|
|
419
446
|
"data-state": "hidden",
|
|
420
447
|
"data-oc-state": "hidden",
|
|
421
448
|
role: "presentation",
|
|
422
|
-
onMouseDown:
|
|
449
|
+
onMouseDown: Yt,
|
|
423
450
|
onPointerDownCapture: (t) => {
|
|
424
451
|
t.stopPropagation(), t.nativeEvent.stopImmediatePropagation();
|
|
425
452
|
},
|
|
@@ -432,9 +459,9 @@ function kt({
|
|
|
432
459
|
children: /* @__PURE__ */ w(
|
|
433
460
|
"div",
|
|
434
461
|
{
|
|
435
|
-
className:
|
|
462
|
+
className: b.background,
|
|
436
463
|
"data-oc-part": "thumb-background",
|
|
437
|
-
children: /* @__PURE__ */ w(
|
|
464
|
+
children: /* @__PURE__ */ w(bt, { variant: "light", self: !0 })
|
|
438
465
|
}
|
|
439
466
|
)
|
|
440
467
|
}
|
|
@@ -443,42 +470,42 @@ function kt({
|
|
|
443
470
|
)
|
|
444
471
|
}
|
|
445
472
|
) : null,
|
|
446
|
-
|
|
473
|
+
K ? /* @__PURE__ */ w(
|
|
447
474
|
"div",
|
|
448
475
|
{
|
|
449
|
-
ref:
|
|
450
|
-
className:
|
|
476
|
+
ref: D,
|
|
477
|
+
className: b.scrollbar,
|
|
451
478
|
"data-oc-part": "scrollbar-horizontal",
|
|
452
479
|
"data-orientation": "horizontal",
|
|
453
480
|
"data-oc-orientation": "horizontal",
|
|
454
481
|
"data-state": "hidden",
|
|
455
482
|
"data-oc-state": "hidden",
|
|
456
|
-
onWheel:
|
|
483
|
+
onWheel: ft,
|
|
457
484
|
children: /* @__PURE__ */ w(
|
|
458
485
|
"div",
|
|
459
486
|
{
|
|
460
|
-
ref:
|
|
461
|
-
className:
|
|
487
|
+
ref: Pt,
|
|
488
|
+
className: b.wrapper,
|
|
462
489
|
"data-oc-part": "scrollbar-track",
|
|
463
490
|
"data-state": "hidden",
|
|
464
491
|
"data-oc-state": "hidden",
|
|
465
492
|
role: "presentation",
|
|
466
|
-
onMouseDown:
|
|
467
|
-
onMouseEnter: () =>
|
|
493
|
+
onMouseDown: Xt,
|
|
494
|
+
onMouseEnter: () => j(!0),
|
|
468
495
|
onMouseLeave: () => {
|
|
469
|
-
|
|
496
|
+
z(), j(!1);
|
|
470
497
|
},
|
|
471
|
-
onMouseUp:
|
|
498
|
+
onMouseUp: z,
|
|
472
499
|
children: /* @__PURE__ */ w(
|
|
473
500
|
"div",
|
|
474
501
|
{
|
|
475
|
-
ref:
|
|
476
|
-
className:
|
|
502
|
+
ref: d,
|
|
503
|
+
className: b.thumb,
|
|
477
504
|
"data-oc-part": "thumb",
|
|
478
505
|
"data-state": "hidden",
|
|
479
506
|
"data-oc-state": "hidden",
|
|
480
507
|
role: "presentation",
|
|
481
|
-
onMouseDown:
|
|
508
|
+
onMouseDown: It,
|
|
482
509
|
onPointerDownCapture: (t) => {
|
|
483
510
|
t.stopPropagation(), t.nativeEvent.stopImmediatePropagation();
|
|
484
511
|
},
|
|
@@ -491,9 +518,9 @@ function kt({
|
|
|
491
518
|
children: /* @__PURE__ */ w(
|
|
492
519
|
"div",
|
|
493
520
|
{
|
|
494
|
-
className:
|
|
521
|
+
className: b.background,
|
|
495
522
|
"data-oc-part": "thumb-background",
|
|
496
|
-
children: /* @__PURE__ */ w(
|
|
523
|
+
children: /* @__PURE__ */ w(bt, { variant: "light", self: !0 })
|
|
497
524
|
}
|
|
498
525
|
)
|
|
499
526
|
}
|
|
@@ -506,28 +533,28 @@ function kt({
|
|
|
506
533
|
}
|
|
507
534
|
) });
|
|
508
535
|
}
|
|
509
|
-
function
|
|
510
|
-
as:
|
|
536
|
+
function Zt({
|
|
537
|
+
as: m,
|
|
511
538
|
children: e,
|
|
512
539
|
className: E = "",
|
|
513
540
|
ref: L,
|
|
514
|
-
"data-oc-component":
|
|
515
|
-
...
|
|
541
|
+
"data-oc-component": k = "scroll-area-container",
|
|
542
|
+
...A
|
|
516
543
|
}) {
|
|
517
|
-
const
|
|
544
|
+
const N = m ?? "div", M = Nt(Tt), P = s(
|
|
518
545
|
(v) => {
|
|
519
|
-
M?.setContainerRef(v),
|
|
546
|
+
M?.setContainerRef(v), yt(L, v);
|
|
520
547
|
},
|
|
521
548
|
[M, L]
|
|
522
549
|
);
|
|
523
550
|
return /* @__PURE__ */ w(
|
|
524
|
-
|
|
551
|
+
N,
|
|
525
552
|
{
|
|
526
|
-
ref:
|
|
527
|
-
className: `${
|
|
528
|
-
...
|
|
553
|
+
ref: P,
|
|
554
|
+
className: `${b.container} ${E}`.trim(),
|
|
555
|
+
...A,
|
|
529
556
|
"data-oc-part": "scroll-area-container",
|
|
530
|
-
"data-oc-component":
|
|
557
|
+
"data-oc-component": k,
|
|
531
558
|
"data-scroll-container": "",
|
|
532
559
|
"data-oc-scroll-container": "",
|
|
533
560
|
children: e
|
|
@@ -535,7 +562,7 @@ function $t({
|
|
|
535
562
|
);
|
|
536
563
|
}
|
|
537
564
|
export {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
565
|
+
Qt as ScrollArea,
|
|
566
|
+
Zt as ScrollAreaContainer,
|
|
567
|
+
Qt as default
|
|
541
568
|
};
|