@orioncactuscorp/ui 1.8.0 → 1.9.1

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.
Files changed (40) hide show
  1. package/dist/components/Accordion/Accordion.css +1 -1
  2. package/dist/components/Button/Button.css +1 -1
  3. package/dist/components/Checkbox/Checkbox.css +1 -1
  4. package/dist/components/Modal/Modal.css +1 -1
  5. package/dist/components/Modal/Modal.js +698 -547
  6. package/dist/components/Modal/bottomSheetGeometry.js +88 -0
  7. package/dist/components/Modal/modalScrollArbitration.js +9 -7
  8. package/dist/components/Modal/snapPoints.js +9 -8
  9. package/dist/components/Modal/useModalContentBlockTransition.js +64 -0
  10. package/dist/components/Modal/useModalDrag.js +979 -784
  11. package/dist/components/Radio/Radio.css +1 -1
  12. package/dist/components/ScrollArea/ScrollArea.css +1 -1
  13. package/dist/components/ScrollArea/ScrollArea.js +250 -223
  14. package/dist/components/ScrollArea/useScrollAreaGeometryStabilizer.js +36 -0
  15. package/dist/components/TextButton/TextButton.css +1 -1
  16. package/dist/components/TextButton/TextButton.module.scss.js +8 -6
  17. package/dist/styles.css +7 -7
  18. package/dist/ui/src/components/Modal/Modal.d.ts +1 -1
  19. package/dist/ui/src/components/Modal/Modal.d.ts.map +1 -1
  20. package/dist/ui/src/components/Modal/bottomSheetGeometry.d.ts +36 -0
  21. package/dist/ui/src/components/Modal/bottomSheetGeometry.d.ts.map +1 -0
  22. package/dist/ui/src/components/Modal/index.d.ts +1 -1
  23. package/dist/ui/src/components/Modal/index.d.ts.map +1 -1
  24. package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts +6 -1
  25. package/dist/ui/src/components/Modal/modalScrollArbitration.d.ts.map +1 -1
  26. package/dist/ui/src/components/Modal/snapPoints.d.ts +1 -0
  27. package/dist/ui/src/components/Modal/snapPoints.d.ts.map +1 -1
  28. package/dist/ui/src/components/Modal/types.d.ts +8 -0
  29. package/dist/ui/src/components/Modal/types.d.ts.map +1 -1
  30. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts +5 -0
  31. package/dist/ui/src/components/Modal/useModalContentBlockTransition.d.ts.map +1 -0
  32. package/dist/ui/src/components/Modal/useModalDrag.d.ts +5 -1
  33. package/dist/ui/src/components/Modal/useModalDrag.d.ts.map +1 -1
  34. package/dist/ui/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
  35. package/dist/ui/src/components/ScrollArea/useScrollAreaGeometryStabilizer.d.ts +11 -0
  36. package/dist/ui/src/components/ScrollArea/useScrollAreaGeometryStabilizer.d.ts.map +1 -0
  37. package/package.json +2 -1
  38. package/src/scss/mixins/_element.scss +161 -14
  39. package/src/scss/mixins/_element.test.ts +94 -5
  40. package/src/scss/mixins/_icon.scss +27 -0
@@ -1,93 +1,98 @@
1
1
  'use client';
2
- import { jsx as w, jsxs as Lt } from "react/jsx-runtime";
3
- import { useRef as m, useSyncExternalStore as mt, useState as rt, useCallback as h, useMemo as Mt, useEffect as ot, useLayoutEffect as ft, useContext as Pt } from "react";
4
- import pt from "../Interaction/Interaction.js";
5
- import { ScrollAreaContext as vt } from "./contexts.js";
6
- import T from "./ScrollArea.module.scss.js";
7
- const ct = "oc-scroll-area-container-style", it = "oc-scroll-area-root-style";
8
- let O = 0, V = 0;
9
- function gt() {
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 Dt() {
14
+ function $t() {
14
15
  return !0;
15
16
  }
16
- function wt() {
17
+ function Rt() {
17
18
  return !1;
18
19
  }
19
- function xt() {
20
+ function Vt() {
20
21
  return typeof window < "u" && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
21
22
  }
22
- function W(d) {
23
- return d.preventDefault(), !1;
23
+ function C(m) {
24
+ return m.preventDefault(), !1;
24
25
  }
25
- function Bt(d, e) {
26
+ function Ut(m, e) {
26
27
  let E = !1;
27
28
  return () => {
28
- E || (d(), E = !0, window.setTimeout(() => {
29
+ E || (m(), E = !0, window.setTimeout(() => {
29
30
  E = !1;
30
31
  }, e));
31
32
  };
32
33
  }
33
- function bt(d, e) {
34
- typeof d == "function" ? d(e) : d && (d.current = e);
34
+ function yt(m, e) {
35
+ typeof m == "function" ? m(e) : m && (m.current = e);
35
36
  }
36
- function R(d, e) {
37
- d && (d.dataset.state = e, d.dataset.ocState = e);
37
+ function T(m, e) {
38
+ m && (m.dataset.state = e, m.dataset.ocState = e);
38
39
  }
39
- function kt({
40
- as: d,
40
+ function Qt({
41
+ as: m,
41
42
  root: e = !1,
42
43
  children: E,
43
44
  className: L = "",
44
- ref: Y,
45
- "data-oc-component": I = "scroll-area",
46
- ...X
45
+ ref: k,
46
+ "data-oc-component": A = "scroll-area",
47
+ ...N
47
48
  }) {
48
- const M = d ?? "div", U = m(null), v = mt(
49
- gt,
50
- Dt,
51
- wt
52
- ), S = mt(
53
- gt,
54
- xt,
55
- wt
56
- ), [o, Tt] = rt(null), [_, Et] = rt(!1), [j, Rt] = rt(!1), F = m(null), f = m(null), a = m(null), q = m(null), g = m(null), s = m(null), P = m(!1), D = m(!1), G = m(0), J = m(0), H = m(null), y = m(null), z = m(null), A = m(null), lt = h(
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
- U.current = t, bt(Y, t);
59
+ P.current = t, yt(k, t);
59
60
  },
60
- [Y]
61
- ), at = h((t) => {
62
- Tt(t);
63
- }, []), St = Mt(
64
- () => ({ isRoot: e, setContainerRef: at }),
65
- [e, at]
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
- ot(() => {
68
- if (!(!v || S || typeof document > "u")) {
69
- if (O += 1, e && (V += 1), !document.getElementById(ct)) {
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 = ct, t.textContent = `
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(it)) {
81
+ if (e && !document.getElementById(at)) {
77
82
  const t = document.createElement("style");
78
- t.id = it, t.textContent = `
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
- O = Math.max(0, O - 1), e && (V = Math.max(
89
+ F = Math.max(0, F - 1), e && (q = Math.max(
85
90
  0,
86
- V - 1
87
- )), V === 0 && document.getElementById(it)?.remove(), O === 0 && document.getElementById(ct)?.remove();
91
+ q - 1
92
+ )), q === 0 && document.getElementById(at)?.remove(), F === 0 && document.getElementById(lt)?.remove();
88
93
  };
89
94
  }
90
- }, [v, e, S]), ot(() => {
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 C = h(() => {
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]), b = h(() => {
127
+ }, [o, e]), R = s(() => {
123
128
  const t = o;
124
129
  if (t) {
125
- if (f.current && a.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 - a.current.clientHeight, l = c - r;
130
- let p = n, u = 0;
131
- n > l ? (u = n - l, p = l) : n < 0 && (u = n, p = 0);
132
- const et = p / l * i + u;
133
- a.current.style.transform = `translateY(${et}px)`;
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 - a.current.clientHeight, l = n / (c - r) * i;
139
- a.current.style.transform = `translateY(${l}px)`;
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 && s.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 - s.current.clientWidth, l = n / (c - r) * i;
146
- s.current.style.transform = `translateX(${l}px)`;
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]), st = h(() => {
151
- R(F.current, "active"), R(q.current, "active"), H.current !== null && window.clearTimeout(H.current), H.current = window.setTimeout(() => {
152
- R(F.current, "hidden"), R(q.current, "hidden"), H.current = null;
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
- }, []), K = h(() => {
155
- b(), st();
156
- }, [st, b]), N = h(() => {
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
- Et(t.scrollHeight > n), Rt(t.scrollWidth > r);
161
- }, [o, e]), yt = (t) => {
162
- if (t.preventDefault(), t.stopPropagation(), !f.current || !a.current || !o) return;
163
- P.current = !0, a.current.dataset.state = "dragging", a.current.dataset.ocState = "dragging";
164
- const n = e ? window.scrollY / (document.documentElement.scrollHeight - window.innerHeight) : o.scrollTop / (o.scrollHeight - o.clientHeight), r = f.current.getBoundingClientRect().height - a.current.clientHeight;
165
- G.current = t.clientY - n * r, document.addEventListener("selectstart", W), document.addEventListener("dragstart", W);
166
- }, Ht = (t) => {
167
- if (t.preventDefault(), t.stopPropagation(), !g.current || !s.current || !o) return;
168
- D.current = !0, s.current.dataset.state = "dragging", s.current.dataset.ocState = "dragging";
169
- const n = e ? window.scrollX / (document.documentElement.scrollWidth - window.innerWidth) : o.scrollLeft / (o.scrollWidth - o.clientWidth), r = g.current.getBoundingClientRect().width - s.current.clientWidth;
170
- J.current = t.clientX - n * r, document.addEventListener("selectstart", W), document.addEventListener("dragstart", W);
171
- }, Q = h(
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" ? a.current : s.current;
196
+ const c = t === "vertical" ? f.current : g.current, i = t === "vertical" ? u.current : d.current;
174
197
  if (!c || !i) return;
175
- const l = t === "vertical" ? window.innerHeight : window.innerWidth, p = t === "vertical" ? document.documentElement.scrollHeight : document.documentElement.scrollWidth, u = t === "vertical" ? c.getBoundingClientRect().height : c.getBoundingClientRect().width, et = t === "vertical" ? i.clientHeight : i.clientWidth, nt = u - et;
176
- if (nt <= 0) return;
177
- const ht = Math.max(
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, nt)
180
- ) / nt;
181
- t === "vertical" ? document.documentElement.scrollTop = ht * (p - l) : document.documentElement.scrollLeft = ht * (p - l);
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
- ), Z = h(
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", P.current && (t.preventDefault(), t.stopPropagation(), Q("vertical", t.clientY, G), n = !0), D.current && (t.preventDefault(), t.stopPropagation(), Q("horizontal", t.clientX, J), n = !0), document.documentElement.style.scrollBehavior = r;
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 (P.current && f.current && a.current) {
215
+ if (x.current && f.current && u.current) {
193
216
  t.preventDefault(), t.stopPropagation();
194
- const r = f.current.getBoundingClientRect().height - a.current.clientHeight;
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 - G.current, r)
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 (D.current && g.current && s.current) {
226
+ if (Y.current && g.current && d.current) {
204
227
  t.preventDefault(), t.stopPropagation();
205
- const r = g.current.getBoundingClientRect().width - s.current.clientWidth;
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 - J.current, r)
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 && b();
238
+ n && R();
216
239
  },
217
- [o, e, Q, b]
218
- ), tt = h(() => {
219
- P.current = !1, D.current = !1, a.current && (a.current.dataset.state = "hidden", a.current.dataset.ocState = "hidden"), s.current && (s.current.dataset.state = "hidden", s.current.dataset.ocState = "hidden"), document.removeEventListener("selectstart", W), document.removeEventListener("dragstart", W);
220
- }, []), ut = (t) => {
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
- }, k = h(() => {
238
- y.current !== null && (window.clearTimeout(y.current), y.current = null);
239
- }, []), dt = h(() => {
240
- k(), y.current = window.setTimeout(() => {
241
- R(f.current, "hidden"), R(g.current, "hidden"), y.current = null;
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
- }, [k]), $ = h(
266
+ }, [G]), j = s(
244
267
  (t) => {
245
- t ? (R(f.current, "active"), R(g.current, "active"), k()) : !P.current && !D.current && dt();
268
+ t ? (T(f.current, "active"), T(g.current, "active"), G()) : !x.current && !Y.current && pt();
246
269
  },
247
- [k, dt]
248
- ), x = h(() => {
249
- z.current !== null && (window.clearInterval(z.current), z.current = null);
250
- }, []), B = h(() => {
251
- A.current !== null && (window.clearInterval(A.current), A.current = null);
252
- }, []), Ct = (t) => {
253
- if (t.target !== t.currentTarget || !o || !a.current)
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 = a.current.getBoundingClientRect(), c = n < r.top ? "up" : n > r.bottom ? "down" : null;
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, l = () => {
258
- const p = a.current?.getBoundingClientRect();
259
- if (p && n >= p.top && n <= p.bottom) {
260
- x();
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 u = window.scrollY || document.documentElement.scrollTop;
287
+ const h = window.scrollY || document.documentElement.scrollTop;
265
288
  window.scrollTo({
266
- top: c === "up" ? u - i : u + i,
289
+ top: c === "up" ? h - i : h + i,
267
290
  behavior: "smooth"
268
291
  });
269
292
  } else {
270
- const u = o.scrollTop;
293
+ const h = o.scrollTop;
271
294
  o.scrollTo({
272
- top: c === "up" ? u - i : u + i,
295
+ top: c === "up" ? h - i : h + i,
273
296
  behavior: "smooth"
274
297
  });
275
298
  }
276
- b();
299
+ R();
277
300
  };
278
- l(), z.current = window.setInterval(l, 300);
279
- }, Wt = (t) => {
280
- if (t.target !== t.currentTarget || !o || !s.current)
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 = s.current.getBoundingClientRect(), c = n < r.left ? "left" : n > r.right ? "right" : null;
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, l = () => {
285
- const p = s.current?.getBoundingClientRect();
286
- if (p && n >= p.left && n <= p.right) {
287
- B();
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 u = window.scrollX || document.documentElement.scrollLeft;
314
+ const h = window.scrollX || document.documentElement.scrollLeft;
292
315
  window.scrollTo({
293
- left: c === "left" ? u - i : u + i,
316
+ left: c === "left" ? h - i : h + i,
294
317
  behavior: "smooth"
295
318
  });
296
319
  } else {
297
- const u = o.scrollLeft;
320
+ const h = o.scrollLeft;
298
321
  o.scrollTo({
299
- left: c === "left" ? u - i : u + i,
322
+ left: c === "left" ? h - i : h + i,
300
323
  behavior: "smooth"
301
324
  });
302
325
  }
303
- b();
326
+ R();
304
327
  };
305
- l(), A.current = window.setInterval(l, 300);
328
+ a(), U.current = window.setInterval(a, 300);
306
329
  };
307
- return ft(() => {
330
+ return vt(() => {
308
331
  const t = o;
309
- if (!v || !t || S) return;
310
- const n = window.requestAnimationFrame(() => {
311
- N(), C(), b();
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
- N(), C(), b();
338
+ W();
318
339
  };
319
- window.addEventListener("resize", c), document.addEventListener("mousemove", Z), document.addEventListener("mouseup", tt);
320
- const i = Bt(() => {
321
- C(), b(), N();
322
- }, 100), l = new MutationObserver(i);
323
- return l.observe(t, {
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
- r.removeEventListener("scroll", K), window.removeEventListener("resize", c), document.removeEventListener("mousemove", Z), document.removeEventListener("mouseup", tt), window.cancelAnimationFrame(n), l.disconnect();
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
- N,
355
+ _,
333
356
  o,
357
+ W,
334
358
  v,
335
- K,
336
- Z,
337
359
  tt,
360
+ nt,
361
+ rt,
338
362
  e,
339
- S,
340
- C,
341
- b
342
- ]), ft(() => {
343
- !v || !o || S || !_ && !j || (C(), b());
363
+ K,
364
+ J,
365
+ $,
366
+ y,
367
+ O
368
+ ]), vt(() => {
369
+ W();
344
370
  }, [
345
371
  o,
346
372
  v,
347
- j,
348
- _,
349
- S,
350
- C,
351
- b
352
- ]), ot(
373
+ K,
374
+ J,
375
+ $,
376
+ W,
377
+ y,
378
+ O
379
+ ]), it(
353
380
  () => () => {
354
- H.current !== null && window.clearTimeout(H.current), y.current !== null && window.clearTimeout(y.current), x(), B();
381
+ H.current !== null && window.clearTimeout(H.current), S.current !== null && window.clearTimeout(S.current), I(), z(), _();
355
382
  },
356
- [B, x]
357
- ), !v || S ? /* @__PURE__ */ w(
383
+ [_, z, I]
384
+ ), !v || y ? /* @__PURE__ */ w(
358
385
  M,
359
386
  {
360
- ref: lt,
361
- className: `${T.scrollArea} ${L}`.trim(),
362
- ...X,
363
- "data-oc-component": I,
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(vt.Provider, { value: St, children: /* @__PURE__ */ Lt(
399
+ ) : /* @__PURE__ */ w(Tt.Provider, { value: Bt, children: /* @__PURE__ */ kt(
373
400
  M,
374
401
  {
375
- ref: lt,
376
- className: `${T.scrollArea} ${L}`.trim(),
377
- ...X,
378
- "data-oc-component": I,
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
- _ ? /* @__PURE__ */ w(
414
+ J ? /* @__PURE__ */ w(
388
415
  "div",
389
416
  {
390
- ref: F,
391
- className: T.scrollbar,
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: ut,
424
+ onWheel: ft,
398
425
  children: /* @__PURE__ */ w(
399
426
  "div",
400
427
  {
401
- ref: f,
402
- className: T.wrapper,
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: Ct,
408
- onMouseEnter: () => $(!0),
434
+ onMouseDown: zt,
435
+ onMouseEnter: () => j(!0),
409
436
  onMouseLeave: () => {
410
- x(), $(!1);
437
+ I(), j(!1);
411
438
  },
412
- onMouseUp: x,
439
+ onMouseUp: I,
413
440
  children: /* @__PURE__ */ w(
414
441
  "div",
415
442
  {
416
- ref: a,
417
- className: T.thumb,
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: yt,
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: T.background,
462
+ className: b.background,
436
463
  "data-oc-part": "thumb-background",
437
- children: /* @__PURE__ */ w(pt, { variant: "light", self: !0 })
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
- j ? /* @__PURE__ */ w(
473
+ K ? /* @__PURE__ */ w(
447
474
  "div",
448
475
  {
449
- ref: q,
450
- className: T.scrollbar,
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: ut,
483
+ onWheel: ft,
457
484
  children: /* @__PURE__ */ w(
458
485
  "div",
459
486
  {
460
- ref: g,
461
- className: T.wrapper,
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: Wt,
467
- onMouseEnter: () => $(!0),
493
+ onMouseDown: Xt,
494
+ onMouseEnter: () => j(!0),
468
495
  onMouseLeave: () => {
469
- B(), $(!1);
496
+ z(), j(!1);
470
497
  },
471
- onMouseUp: B,
498
+ onMouseUp: z,
472
499
  children: /* @__PURE__ */ w(
473
500
  "div",
474
501
  {
475
- ref: s,
476
- className: T.thumb,
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: Ht,
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: T.background,
521
+ className: b.background,
495
522
  "data-oc-part": "thumb-background",
496
- children: /* @__PURE__ */ w(pt, { variant: "light", self: !0 })
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 $t({
510
- as: d,
536
+ function Zt({
537
+ as: m,
511
538
  children: e,
512
539
  className: E = "",
513
540
  ref: L,
514
- "data-oc-component": Y = "scroll-area-container",
515
- ...I
541
+ "data-oc-component": k = "scroll-area-container",
542
+ ...A
516
543
  }) {
517
- const X = d ?? "div", M = Pt(vt), U = h(
544
+ const N = m ?? "div", M = Nt(Tt), P = s(
518
545
  (v) => {
519
- M?.setContainerRef(v), bt(L, v);
546
+ M?.setContainerRef(v), yt(L, v);
520
547
  },
521
548
  [M, L]
522
549
  );
523
550
  return /* @__PURE__ */ w(
524
- X,
551
+ N,
525
552
  {
526
- ref: U,
527
- className: `${T.container} ${E}`.trim(),
528
- ...I,
553
+ ref: P,
554
+ className: `${b.container} ${E}`.trim(),
555
+ ...A,
529
556
  "data-oc-part": "scroll-area-container",
530
- "data-oc-component": Y,
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
- kt as ScrollArea,
539
- $t as ScrollAreaContainer,
540
- kt as default
565
+ Qt as ScrollArea,
566
+ Zt as ScrollAreaContainer,
567
+ Qt as default
541
568
  };