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