@drjoshcsimmons/scl 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +35 -35
  2. package/dist/index100.js +15 -50
  3. package/dist/index102.js +48 -648
  4. package/dist/index103.js +205 -167
  5. package/dist/index104.js +30 -15
  6. package/dist/index11.js +2 -2
  7. package/dist/index110.js +1 -1
  8. package/dist/index112.js +1 -1
  9. package/dist/index12.js +1 -1
  10. package/dist/index13.js +2 -2
  11. package/dist/index14.js +2 -2
  12. package/dist/index15.js +2 -2
  13. package/dist/index17.js +4 -4
  14. package/dist/index18.js +2 -2
  15. package/dist/index20.js +2 -2
  16. package/dist/index21.js +1 -1
  17. package/dist/index22.js +1 -1
  18. package/dist/index23.js +2 -2
  19. package/dist/index24.js +1 -1
  20. package/dist/index25.js +4 -4
  21. package/dist/index26.js +1 -1
  22. package/dist/index27.js +3 -3
  23. package/dist/index29.js +1 -1
  24. package/dist/index31.js +1 -1
  25. package/dist/index33.js +1 -1
  26. package/dist/index36.js +2 -2
  27. package/dist/index37.js +1 -1
  28. package/dist/index4.js +2 -2
  29. package/dist/index45.js +220 -108
  30. package/dist/index46.js +11 -33
  31. package/dist/index47.js +418 -101
  32. package/dist/index48.js +147 -59
  33. package/dist/index49.js +298 -237
  34. package/dist/index5.js +1 -1
  35. package/dist/index50.js +5 -2
  36. package/dist/index51.js +33 -237
  37. package/dist/index52.js +118 -11
  38. package/dist/index53.js +70 -15
  39. package/dist/index54.js +12 -860
  40. package/dist/index55.js +2 -2
  41. package/dist/index56.js +229 -205
  42. package/dist/index57.js +60 -11
  43. package/dist/index58.js +225 -11
  44. package/dist/index59.js +11 -60
  45. package/dist/index6.js +1 -1
  46. package/dist/index60.js +11 -254
  47. package/dist/index61.js +112 -517
  48. package/dist/index62.js +216 -197
  49. package/dist/index63.js +12 -260
  50. package/dist/index64.js +82 -12
  51. package/dist/index65.js +236 -12
  52. package/dist/index66.js +487 -392
  53. package/dist/index67.js +21 -160
  54. package/dist/index68.js +823 -299
  55. package/dist/index69.js +9 -82
  56. package/dist/index7.js +1 -1
  57. package/dist/index70.js +242 -298
  58. package/dist/index71.js +31 -12
  59. package/dist/index72.js +332 -18
  60. package/dist/index73.js +206 -201
  61. package/dist/index74.js +17 -129
  62. package/dist/index75.js +130 -31
  63. package/dist/index77.js +44 -25
  64. package/dist/index78.js +25 -5
  65. package/dist/index79.js +6 -53
  66. package/dist/index8.js +1 -1
  67. package/dist/index80.js +1 -1
  68. package/dist/index81.js +34 -4
  69. package/dist/index82.js +10 -33
  70. package/dist/index83.js +7 -68
  71. package/dist/index84.js +3 -10
  72. package/dist/index85.js +5 -54
  73. package/dist/index86.js +24 -10
  74. package/dist/index87.js +181 -30
  75. package/dist/index88.js +67 -11
  76. package/dist/index89.js +14 -5
  77. package/dist/index9.js +2 -2
  78. package/dist/index90.js +30 -25
  79. package/dist/index91.js +52 -43
  80. package/dist/index92.js +10 -7
  81. package/dist/index93.js +4 -4
  82. package/dist/index94.js +11 -123
  83. package/dist/index95.js +52 -13
  84. package/dist/index96.js +633 -118
  85. package/dist/index97.js +113 -207
  86. package/dist/index98.js +134 -13
  87. package/dist/index99.js +14 -30
  88. package/package.json +1 -1
package/dist/index66.js CHANGED
@@ -1,437 +1,532 @@
1
- import * as d from "react";
2
- import { clamp as $ } from "./index93.js";
3
- import { composeEventHandlers as C } from "./index78.js";
4
- import { useComposedRefs as M } from "./index77.js";
5
- import { createContextScope as ce } from "./index76.js";
6
- import { useControllableState as le } from "./index80.js";
7
- import { useDirection as de } from "./index92.js";
8
- import { usePrevious as ue } from "./index89.js";
9
- import { useSize as fe } from "./index90.js";
10
- import { Primitive as K } from "./index82.js";
11
- import { createCollection as me } from "./index91.js";
12
- import { jsx as v, jsxs as pe } from "react/jsx-runtime";
13
- var j = ["PageUp", "PageDown"], X = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], G = {
14
- "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
15
- "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
16
- "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
17
- "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
18
- }, I = "Slider", [z, he, Se] = me(I), [W] = ce(I, [
19
- Se
20
- ]), [ge, T] = W(I), q = d.forwardRef(
1
+ import * as c from "react";
2
+ import { Primitive as L } from "./index81.js";
3
+ import { Presence as I } from "./index88.js";
4
+ import { createContextScope as te } from "./index76.js";
5
+ import { useComposedRefs as A } from "./index78.js";
6
+ import { useCallbackRef as C } from "./index92.js";
7
+ import { useDirection as ne } from "./index83.js";
8
+ import { useLayoutEffect as le } from "./index93.js";
9
+ import { clamp as ce } from "./index84.js";
10
+ import { composeEventHandlers as R } from "./index79.js";
11
+ import { jsx as b, jsxs as ie, Fragment as se } from "react/jsx-runtime";
12
+ function ae(e, t) {
13
+ return c.useReducer((r, l) => t[r][l] ?? r, e);
14
+ }
15
+ var V = "ScrollArea", [j] = te(V), [de, v] = j(V), q = c.forwardRef(
21
16
  (e, t) => {
22
17
  const {
23
- name: o,
24
- min: n = 0,
25
- max: a = 100,
26
- step: c = 1,
27
- orientation: r = "horizontal",
28
- disabled: s = !1,
29
- minStepsBetweenThumbs: l = 0,
30
- defaultValue: h = [n],
31
- value: S,
32
- onValueChange: i = () => {
33
- },
34
- onValueCommit: u = () => {
35
- },
36
- inverted: w = !1,
37
- form: P,
38
- ...g
39
- } = e, m = d.useRef(/* @__PURE__ */ new Set()), f = d.useRef(0), b = r === "horizontal" ? ve : we, [p = [], A] = le({
40
- prop: S,
41
- defaultProp: h,
42
- onChange: (R) => {
43
- var E;
44
- (E = [...m.current][f.current]) == null || E.focus(), i(R);
45
- }
46
- }), k = d.useRef(p);
47
- function H(R) {
48
- const x = ye(p, R);
49
- V(R, x);
50
- }
51
- function se(R) {
52
- V(R, f.current);
53
- }
54
- function ae() {
55
- const R = k.current[f.current];
56
- p[f.current] !== R && u(p);
57
- }
58
- function V(R, x, { commit: E } = { commit: !1 }) {
59
- const F = Ce(c), N = Me(Math.round((R - n) / c) * c + n, F), B = $(N, [n, a]);
60
- A((_ = []) => {
61
- const y = Pe(_, B, x);
62
- if (_e(y, l * c)) {
63
- f.current = y.indexOf(B);
64
- const Y = String(y) !== String(_);
65
- return Y && E && u(y), Y ? y : _;
66
- } else
67
- return _;
68
- });
69
- }
70
- return /* @__PURE__ */ v(
71
- ge,
18
+ __scopeScrollArea: r,
19
+ type: l = "hover",
20
+ dir: o,
21
+ scrollHideDelay: n = 600,
22
+ ...i
23
+ } = e, [s, a] = c.useState(null), [f, d] = c.useState(null), [h, u] = c.useState(null), [S, p] = c.useState(null), [y, M] = c.useState(null), [P, _] = c.useState(0), [U, D] = c.useState(0), [W, x] = c.useState(!1), [H, z] = c.useState(!1), m = A(t, (E) => a(E)), w = ne(o);
24
+ return /* @__PURE__ */ b(
25
+ de,
72
26
  {
73
- scope: e.__scopeSlider,
74
- name: o,
75
- disabled: s,
76
- min: n,
77
- max: a,
78
- valueIndexToChangeRef: f,
79
- thumbs: m.current,
80
- values: p,
81
- orientation: r,
82
- form: P,
83
- children: /* @__PURE__ */ v(z.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(z.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(
84
- b,
27
+ scope: r,
28
+ type: l,
29
+ dir: w,
30
+ scrollHideDelay: n,
31
+ scrollArea: s,
32
+ viewport: f,
33
+ onViewportChange: d,
34
+ content: h,
35
+ onContentChange: u,
36
+ scrollbarX: S,
37
+ onScrollbarXChange: p,
38
+ scrollbarXEnabled: W,
39
+ onScrollbarXEnabledChange: x,
40
+ scrollbarY: y,
41
+ onScrollbarYChange: M,
42
+ scrollbarYEnabled: H,
43
+ onScrollbarYEnabledChange: z,
44
+ onCornerWidthChange: _,
45
+ onCornerHeightChange: D,
46
+ children: /* @__PURE__ */ b(
47
+ L.div,
85
48
  {
86
- "aria-disabled": s,
87
- "data-disabled": s ? "" : void 0,
88
- ...g,
89
- ref: t,
90
- onPointerDown: C(g.onPointerDown, () => {
91
- s || (k.current = p);
92
- }),
93
- min: n,
94
- max: a,
95
- inverted: w,
96
- onSlideStart: s ? void 0 : H,
97
- onSlideMove: s ? void 0 : se,
98
- onSlideEnd: s ? void 0 : ae,
99
- onHomeKeyDown: () => !s && V(n, 0, { commit: !0 }),
100
- onEndKeyDown: () => !s && V(a, p.length - 1, { commit: !0 }),
101
- onStepKeyDown: ({ event: R, direction: x }) => {
102
- if (!s) {
103
- const N = j.includes(R.key) || R.shiftKey && X.includes(R.key) ? 10 : 1, B = f.current, _ = p[B], y = c * N * x;
104
- V(_ + y, B, { commit: !0 });
105
- }
49
+ dir: w,
50
+ ...i,
51
+ ref: m,
52
+ style: {
53
+ position: "relative",
54
+ // Pass corner sizes as CSS vars to reduce re-renders of context consumers
55
+ "--radix-scroll-area-corner-width": P + "px",
56
+ "--radix-scroll-area-corner-height": U + "px",
57
+ ...e.style
106
58
  }
107
59
  }
108
- ) }) })
60
+ )
109
61
  }
110
62
  );
111
63
  }
112
64
  );
113
- q.displayName = I;
114
- var [J, Q] = W(I, {
115
- startEdge: "left",
116
- endEdge: "right",
117
- size: "width",
118
- direction: 1
119
- }), ve = d.forwardRef(
65
+ q.displayName = V;
66
+ var $ = "ScrollAreaViewport", G = c.forwardRef(
120
67
  (e, t) => {
121
- const {
122
- min: o,
123
- max: n,
124
- dir: a,
125
- inverted: c,
126
- onSlideStart: r,
127
- onSlideMove: s,
128
- onSlideEnd: l,
129
- onStepKeyDown: h,
130
- ...S
131
- } = e, [i, u] = d.useState(null), w = M(t, (b) => u(b)), P = d.useRef(void 0), g = de(a), m = g === "ltr", f = m && !c || !m && c;
132
- function D(b) {
133
- const p = P.current || i.getBoundingClientRect(), A = [0, p.width], H = U(A, f ? [o, n] : [n, o]);
134
- return P.current = p, H(b - p.left);
135
- }
136
- return /* @__PURE__ */ v(
137
- J,
138
- {
139
- scope: e.__scopeSlider,
140
- startEdge: f ? "left" : "right",
141
- endEdge: f ? "right" : "left",
142
- direction: f ? 1 : -1,
143
- size: "width",
144
- children: /* @__PURE__ */ v(
145
- Z,
146
- {
147
- dir: g,
148
- "data-orientation": "horizontal",
149
- ...S,
150
- ref: w,
151
- style: {
152
- ...S.style,
153
- "--radix-slider-thumb-transform": "translateX(-50%)"
154
- },
155
- onSlideStart: (b) => {
156
- const p = D(b.clientX);
157
- r == null || r(p);
158
- },
159
- onSlideMove: (b) => {
160
- const p = D(b.clientX);
161
- s == null || s(p);
162
- },
163
- onSlideEnd: () => {
164
- P.current = void 0, l == null || l();
165
- },
166
- onStepKeyDown: (b) => {
167
- const A = G[f ? "from-left" : "from-right"].includes(b.key);
168
- h == null || h({ event: b, direction: A ? -1 : 1 });
169
- }
170
- }
171
- )
172
- }
173
- );
68
+ const { __scopeScrollArea: r, children: l, nonce: o, ...n } = e, i = v($, r), s = c.useRef(null), a = A(t, s, i.onViewportChange);
69
+ return /* @__PURE__ */ ie(se, { children: [
70
+ /* @__PURE__ */ b(
71
+ "style",
72
+ {
73
+ dangerouslySetInnerHTML: {
74
+ __html: "[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"
75
+ },
76
+ nonce: o
77
+ }
78
+ ),
79
+ /* @__PURE__ */ b(
80
+ L.div,
81
+ {
82
+ "data-radix-scroll-area-viewport": "",
83
+ ...n,
84
+ ref: a,
85
+ style: {
86
+ /**
87
+ * We don't support `visible` because the intention is to have at least one scrollbar
88
+ * if this component is used and `visible` will behave like `auto` in that case
89
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#description
90
+ *
91
+ * We don't handle `auto` because the intention is for the native implementation
92
+ * to be hidden if using this component. We just want to ensure the node is scrollable
93
+ * so could have used either `scroll` or `auto` here. We picked `scroll` to prevent
94
+ * the browser from having to work out whether to render native scrollbars or not,
95
+ * we tell it to with the intention of hiding them in CSS.
96
+ */
97
+ overflowX: i.scrollbarXEnabled ? "scroll" : "hidden",
98
+ overflowY: i.scrollbarYEnabled ? "scroll" : "hidden",
99
+ ...e.style
100
+ },
101
+ children: /* @__PURE__ */ b("div", { ref: i.onContentChange, style: { minWidth: "100%", display: "table" }, children: l })
102
+ }
103
+ )
104
+ ] });
174
105
  }
175
- ), we = d.forwardRef(
106
+ );
107
+ G.displayName = $;
108
+ var g = "ScrollAreaScrollbar", ue = c.forwardRef(
176
109
  (e, t) => {
177
- const {
178
- min: o,
179
- max: n,
180
- inverted: a,
181
- onSlideStart: c,
182
- onSlideMove: r,
183
- onSlideEnd: s,
184
- onStepKeyDown: l,
185
- ...h
186
- } = e, S = d.useRef(null), i = M(t, S), u = d.useRef(void 0), w = !a;
187
- function P(g) {
188
- const m = u.current || S.current.getBoundingClientRect(), f = [0, m.height], b = U(f, w ? [n, o] : [o, n]);
189
- return u.current = m, b(g - m.top);
110
+ const { forceMount: r, ...l } = e, o = v(g, e.__scopeScrollArea), { onScrollbarXEnabledChange: n, onScrollbarYEnabledChange: i } = o, s = e.orientation === "horizontal";
111
+ return c.useEffect(() => (s ? n(!0) : i(!0), () => {
112
+ s ? n(!1) : i(!1);
113
+ }), [s, n, i]), o.type === "hover" ? /* @__PURE__ */ b(fe, { ...l, ref: t, forceMount: r }) : o.type === "scroll" ? /* @__PURE__ */ b(he, { ...l, ref: t, forceMount: r }) : o.type === "auto" ? /* @__PURE__ */ b(J, { ...l, ref: t, forceMount: r }) : o.type === "always" ? /* @__PURE__ */ b(k, { ...l, ref: t }) : null;
114
+ }
115
+ );
116
+ ue.displayName = g;
117
+ var fe = c.forwardRef((e, t) => {
118
+ const { forceMount: r, ...l } = e, o = v(g, e.__scopeScrollArea), [n, i] = c.useState(!1);
119
+ return c.useEffect(() => {
120
+ const s = o.scrollArea;
121
+ let a = 0;
122
+ if (s) {
123
+ const f = () => {
124
+ window.clearTimeout(a), i(!0);
125
+ }, d = () => {
126
+ a = window.setTimeout(() => i(!1), o.scrollHideDelay);
127
+ };
128
+ return s.addEventListener("pointerenter", f), s.addEventListener("pointerleave", d), () => {
129
+ window.clearTimeout(a), s.removeEventListener("pointerenter", f), s.removeEventListener("pointerleave", d);
130
+ };
190
131
  }
191
- return /* @__PURE__ */ v(
192
- J,
193
- {
194
- scope: e.__scopeSlider,
195
- startEdge: w ? "bottom" : "top",
196
- endEdge: w ? "top" : "bottom",
197
- size: "height",
198
- direction: w ? 1 : -1,
199
- children: /* @__PURE__ */ v(
200
- Z,
201
- {
202
- "data-orientation": "vertical",
203
- ...h,
204
- ref: i,
205
- style: {
206
- ...h.style,
207
- "--radix-slider-thumb-transform": "translateY(50%)"
208
- },
209
- onSlideStart: (g) => {
210
- const m = P(g.clientY);
211
- c == null || c(m);
212
- },
213
- onSlideMove: (g) => {
214
- const m = P(g.clientY);
215
- r == null || r(m);
216
- },
217
- onSlideEnd: () => {
218
- u.current = void 0, s == null || s();
219
- },
220
- onStepKeyDown: (g) => {
221
- const f = G[w ? "from-bottom" : "from-top"].includes(g.key);
222
- l == null || l({ event: g, direction: f ? -1 : 1 });
223
- }
224
- }
225
- )
226
- }
227
- );
132
+ }, [o.scrollArea, o.scrollHideDelay]), /* @__PURE__ */ b(I, { present: r || n, children: /* @__PURE__ */ b(
133
+ J,
134
+ {
135
+ "data-state": n ? "visible" : "hidden",
136
+ ...l,
137
+ ref: t
138
+ }
139
+ ) });
140
+ }), he = c.forwardRef((e, t) => {
141
+ const { forceMount: r, ...l } = e, o = v(g, e.__scopeScrollArea), n = e.orientation === "horizontal", i = Y(() => a("SCROLL_END"), 100), [s, a] = ae("hidden", {
142
+ hidden: {
143
+ SCROLL: "scrolling"
144
+ },
145
+ scrolling: {
146
+ SCROLL_END: "idle",
147
+ POINTER_ENTER: "interacting"
148
+ },
149
+ interacting: {
150
+ SCROLL: "interacting",
151
+ POINTER_LEAVE: "idle"
152
+ },
153
+ idle: {
154
+ HIDE: "hidden",
155
+ SCROLL: "scrolling",
156
+ POINTER_ENTER: "interacting"
157
+ }
158
+ });
159
+ return c.useEffect(() => {
160
+ if (s === "idle") {
161
+ const f = window.setTimeout(() => a("HIDE"), o.scrollHideDelay);
162
+ return () => window.clearTimeout(f);
163
+ }
164
+ }, [s, o.scrollHideDelay, a]), c.useEffect(() => {
165
+ const f = o.viewport, d = n ? "scrollLeft" : "scrollTop";
166
+ if (f) {
167
+ let h = f[d];
168
+ const u = () => {
169
+ const S = f[d];
170
+ h !== S && (a("SCROLL"), i()), h = S;
171
+ };
172
+ return f.addEventListener("scroll", u), () => f.removeEventListener("scroll", u);
173
+ }
174
+ }, [o.viewport, n, a, i]), /* @__PURE__ */ b(I, { present: r || s !== "hidden", children: /* @__PURE__ */ b(
175
+ k,
176
+ {
177
+ "data-state": s === "hidden" ? "hidden" : "visible",
178
+ ...l,
179
+ ref: t,
180
+ onPointerEnter: R(e.onPointerEnter, () => a("POINTER_ENTER")),
181
+ onPointerLeave: R(e.onPointerLeave, () => a("POINTER_LEAVE"))
182
+ }
183
+ ) });
184
+ }), J = c.forwardRef((e, t) => {
185
+ const r = v(g, e.__scopeScrollArea), { forceMount: l, ...o } = e, [n, i] = c.useState(!1), s = e.orientation === "horizontal", a = Y(() => {
186
+ if (r.viewport) {
187
+ const f = r.viewport.offsetWidth < r.viewport.scrollWidth, d = r.viewport.offsetHeight < r.viewport.scrollHeight;
188
+ i(s ? f : d);
189
+ }
190
+ }, 10);
191
+ return T(r.viewport, a), T(r.content, a), /* @__PURE__ */ b(I, { present: l || n, children: /* @__PURE__ */ b(
192
+ k,
193
+ {
194
+ "data-state": n ? "visible" : "hidden",
195
+ ...o,
196
+ ref: t
197
+ }
198
+ ) });
199
+ }), k = c.forwardRef((e, t) => {
200
+ const { orientation: r = "vertical", ...l } = e, o = v(g, e.__scopeScrollArea), n = c.useRef(null), i = c.useRef(0), [s, a] = c.useState({
201
+ content: 0,
202
+ viewport: 0,
203
+ scrollbar: { size: 0, paddingStart: 0, paddingEnd: 0 }
204
+ }), f = ee(s.viewport, s.content), d = {
205
+ ...l,
206
+ sizes: s,
207
+ onSizesChange: a,
208
+ hasThumb: f > 0 && f < 1,
209
+ onThumbChange: (u) => n.current = u,
210
+ onThumbPointerUp: () => i.current = 0,
211
+ onThumbPointerDown: (u) => i.current = u
212
+ };
213
+ function h(u, S) {
214
+ return ge(u, i.current, s, S);
228
215
  }
229
- ), Z = d.forwardRef(
230
- (e, t) => {
231
- const {
232
- __scopeSlider: o,
233
- onSlideStart: n,
234
- onSlideMove: a,
235
- onSlideEnd: c,
236
- onHomeKeyDown: r,
237
- onEndKeyDown: s,
238
- onStepKeyDown: l,
239
- ...h
240
- } = e, S = T(I, o);
241
- return /* @__PURE__ */ v(
242
- K.span,
243
- {
244
- ...h,
245
- ref: t,
246
- onKeyDown: C(e.onKeyDown, (i) => {
247
- i.key === "Home" ? (r(i), i.preventDefault()) : i.key === "End" ? (s(i), i.preventDefault()) : j.concat(X).includes(i.key) && (l(i), i.preventDefault());
248
- }),
249
- onPointerDown: C(e.onPointerDown, (i) => {
250
- const u = i.target;
251
- u.setPointerCapture(i.pointerId), i.preventDefault(), S.thumbs.has(u) ? u.focus() : n(i);
252
- }),
253
- onPointerMove: C(e.onPointerMove, (i) => {
254
- i.target.hasPointerCapture(i.pointerId) && a(i);
255
- }),
256
- onPointerUp: C(e.onPointerUp, (i) => {
257
- const u = i.target;
258
- u.hasPointerCapture(i.pointerId) && (u.releasePointerCapture(i.pointerId), c(i));
259
- })
216
+ return r === "horizontal" ? /* @__PURE__ */ b(
217
+ be,
218
+ {
219
+ ...d,
220
+ ref: t,
221
+ onThumbPositionChange: () => {
222
+ if (o.viewport && n.current) {
223
+ const u = o.viewport.scrollLeft, S = F(u, s, o.dir);
224
+ n.current.style.transform = `translate3d(${S}px, 0, 0)`;
225
+ }
226
+ },
227
+ onWheelScroll: (u) => {
228
+ o.viewport && (o.viewport.scrollLeft = u);
229
+ },
230
+ onDragScroll: (u) => {
231
+ o.viewport && (o.viewport.scrollLeft = h(u, o.dir));
260
232
  }
261
- );
262
- }
263
- ), ee = "SliderTrack", te = d.forwardRef(
264
- (e, t) => {
265
- const { __scopeSlider: o, ...n } = e, a = T(ee, o);
266
- return /* @__PURE__ */ v(
267
- K.span,
268
- {
269
- "data-disabled": a.disabled ? "" : void 0,
270
- "data-orientation": a.orientation,
271
- ...n,
272
- ref: t
233
+ }
234
+ ) : r === "vertical" ? /* @__PURE__ */ b(
235
+ Se,
236
+ {
237
+ ...d,
238
+ ref: t,
239
+ onThumbPositionChange: () => {
240
+ if (o.viewport && n.current) {
241
+ const u = o.viewport.scrollTop, S = F(u, s);
242
+ n.current.style.transform = `translate3d(0, ${S}px, 0)`;
243
+ }
244
+ },
245
+ onWheelScroll: (u) => {
246
+ o.viewport && (o.viewport.scrollTop = u);
247
+ },
248
+ onDragScroll: (u) => {
249
+ o.viewport && (o.viewport.scrollTop = h(u));
273
250
  }
274
- );
275
- }
276
- );
277
- te.displayName = ee;
278
- var L = "SliderRange", ne = d.forwardRef(
279
- (e, t) => {
280
- const { __scopeSlider: o, ...n } = e, a = T(L, o), c = Q(L, o), r = d.useRef(null), s = M(t, r), l = a.values.length, h = a.values.map(
281
- (u) => ie(u, a.min, a.max)
282
- ), S = l > 1 ? Math.min(...h) : 0, i = 100 - Math.max(...h);
283
- return /* @__PURE__ */ v(
284
- K.span,
285
- {
286
- "data-orientation": a.orientation,
287
- "data-disabled": a.disabled ? "" : void 0,
288
- ...n,
289
- ref: s,
290
- style: {
291
- ...e.style,
292
- [c.startEdge]: S + "%",
293
- [c.endEdge]: i + "%"
251
+ }
252
+ ) : null;
253
+ }), be = c.forwardRef((e, t) => {
254
+ const { sizes: r, onSizesChange: l, ...o } = e, n = v(g, e.__scopeScrollArea), [i, s] = c.useState(), a = c.useRef(null), f = A(t, a, n.onScrollbarXChange);
255
+ return c.useEffect(() => {
256
+ a.current && s(getComputedStyle(a.current));
257
+ }, [a]), /* @__PURE__ */ b(
258
+ Q,
259
+ {
260
+ "data-orientation": "horizontal",
261
+ ...o,
262
+ ref: f,
263
+ sizes: r,
264
+ style: {
265
+ bottom: 0,
266
+ left: n.dir === "rtl" ? "var(--radix-scroll-area-corner-width)" : 0,
267
+ right: n.dir === "ltr" ? "var(--radix-scroll-area-corner-width)" : 0,
268
+ "--radix-scroll-area-thumb-width": X(r) + "px",
269
+ ...e.style
270
+ },
271
+ onThumbPointerDown: (d) => e.onThumbPointerDown(d.x),
272
+ onDragScroll: (d) => e.onDragScroll(d.x),
273
+ onWheelScroll: (d, h) => {
274
+ if (n.viewport) {
275
+ const u = n.viewport.scrollLeft + d.deltaX;
276
+ e.onWheelScroll(u), oe(u, h) && d.preventDefault();
294
277
  }
278
+ },
279
+ onResize: () => {
280
+ a.current && n.viewport && i && l({
281
+ content: n.viewport.scrollWidth,
282
+ viewport: n.viewport.offsetWidth,
283
+ scrollbar: {
284
+ size: a.current.clientWidth,
285
+ paddingStart: O(i.paddingLeft),
286
+ paddingEnd: O(i.paddingRight)
287
+ }
288
+ });
295
289
  }
296
- );
290
+ }
291
+ );
292
+ }), Se = c.forwardRef((e, t) => {
293
+ const { sizes: r, onSizesChange: l, ...o } = e, n = v(g, e.__scopeScrollArea), [i, s] = c.useState(), a = c.useRef(null), f = A(t, a, n.onScrollbarYChange);
294
+ return c.useEffect(() => {
295
+ a.current && s(getComputedStyle(a.current));
296
+ }, [a]), /* @__PURE__ */ b(
297
+ Q,
298
+ {
299
+ "data-orientation": "vertical",
300
+ ...o,
301
+ ref: f,
302
+ sizes: r,
303
+ style: {
304
+ top: 0,
305
+ right: n.dir === "ltr" ? 0 : void 0,
306
+ left: n.dir === "rtl" ? 0 : void 0,
307
+ bottom: "var(--radix-scroll-area-corner-height)",
308
+ "--radix-scroll-area-thumb-height": X(r) + "px",
309
+ ...e.style
310
+ },
311
+ onThumbPointerDown: (d) => e.onThumbPointerDown(d.y),
312
+ onDragScroll: (d) => e.onDragScroll(d.y),
313
+ onWheelScroll: (d, h) => {
314
+ if (n.viewport) {
315
+ const u = n.viewport.scrollTop + d.deltaY;
316
+ e.onWheelScroll(u), oe(u, h) && d.preventDefault();
317
+ }
318
+ },
319
+ onResize: () => {
320
+ a.current && n.viewport && i && l({
321
+ content: n.viewport.scrollHeight,
322
+ viewport: n.viewport.offsetHeight,
323
+ scrollbar: {
324
+ size: a.current.clientHeight,
325
+ paddingStart: O(i.paddingTop),
326
+ paddingEnd: O(i.paddingBottom)
327
+ }
328
+ });
329
+ }
330
+ }
331
+ );
332
+ }), [me, K] = j(g), Q = c.forwardRef((e, t) => {
333
+ const {
334
+ __scopeScrollArea: r,
335
+ sizes: l,
336
+ hasThumb: o,
337
+ onThumbChange: n,
338
+ onThumbPointerUp: i,
339
+ onThumbPointerDown: s,
340
+ onThumbPositionChange: a,
341
+ onDragScroll: f,
342
+ onWheelScroll: d,
343
+ onResize: h,
344
+ ...u
345
+ } = e, S = v(g, r), [p, y] = c.useState(null), M = A(t, (m) => y(m)), P = c.useRef(null), _ = c.useRef(""), U = S.viewport, D = l.content - l.viewport, W = C(d), x = C(a), H = Y(h, 10);
346
+ function z(m) {
347
+ if (P.current) {
348
+ const w = m.clientX - P.current.left, E = m.clientY - P.current.top;
349
+ f({ x: w, y: E });
350
+ }
297
351
  }
298
- );
299
- ne.displayName = L;
300
- var O = "SliderThumb", oe = d.forwardRef(
352
+ return c.useEffect(() => {
353
+ const m = (w) => {
354
+ const E = w.target;
355
+ (p == null ? void 0 : p.contains(E)) && W(w, D);
356
+ };
357
+ return document.addEventListener("wheel", m, { passive: !1 }), () => document.removeEventListener("wheel", m, { passive: !1 });
358
+ }, [U, p, D, W]), c.useEffect(x, [l, x]), T(p, H), T(S.content, H), /* @__PURE__ */ b(
359
+ me,
360
+ {
361
+ scope: r,
362
+ scrollbar: p,
363
+ hasThumb: o,
364
+ onThumbChange: C(n),
365
+ onThumbPointerUp: C(i),
366
+ onThumbPositionChange: x,
367
+ onThumbPointerDown: C(s),
368
+ children: /* @__PURE__ */ b(
369
+ L.div,
370
+ {
371
+ ...u,
372
+ ref: M,
373
+ style: { position: "absolute", ...u.style },
374
+ onPointerDown: R(e.onPointerDown, (m) => {
375
+ m.button === 0 && (m.target.setPointerCapture(m.pointerId), P.current = p.getBoundingClientRect(), _.current = document.body.style.webkitUserSelect, document.body.style.webkitUserSelect = "none", S.viewport && (S.viewport.style.scrollBehavior = "auto"), z(m));
376
+ }),
377
+ onPointerMove: R(e.onPointerMove, z),
378
+ onPointerUp: R(e.onPointerUp, (m) => {
379
+ const w = m.target;
380
+ w.hasPointerCapture(m.pointerId) && w.releasePointerCapture(m.pointerId), document.body.style.webkitUserSelect = _.current, S.viewport && (S.viewport.style.scrollBehavior = ""), P.current = null;
381
+ })
382
+ }
383
+ )
384
+ }
385
+ );
386
+ }), N = "ScrollAreaThumb", pe = c.forwardRef(
301
387
  (e, t) => {
302
- const o = he(e.__scopeSlider), [n, a] = d.useState(null), c = M(t, (s) => a(s)), r = d.useMemo(
303
- () => n ? o().findIndex((s) => s.ref.current === n) : -1,
304
- [o, n]
305
- );
306
- return /* @__PURE__ */ v(be, { ...e, ref: c, index: r });
388
+ const { forceMount: r, ...l } = e, o = K(N, e.__scopeScrollArea);
389
+ return /* @__PURE__ */ b(I, { present: r || o.hasThumb, children: /* @__PURE__ */ b(ve, { ref: t, ...l }) });
307
390
  }
308
- ), be = d.forwardRef(
391
+ ), ve = c.forwardRef(
309
392
  (e, t) => {
310
- const { __scopeSlider: o, index: n, name: a, ...c } = e, r = T(O, o), s = Q(O, o), [l, h] = d.useState(null), S = M(t, (D) => h(D)), i = l ? r.form || !!l.closest("form") : !0, u = fe(l), w = r.values[n], P = w === void 0 ? 0 : ie(w, r.min, r.max), g = xe(n, r.values.length), m = u == null ? void 0 : u[s.size], f = m ? De(m, P, s.direction) : 0;
311
- return d.useEffect(() => {
312
- if (l)
313
- return r.thumbs.add(l), () => {
314
- r.thumbs.delete(l);
393
+ const { __scopeScrollArea: r, style: l, ...o } = e, n = v(N, r), i = K(N, r), { onThumbPositionChange: s } = i, a = A(
394
+ t,
395
+ (h) => i.onThumbChange(h)
396
+ ), f = c.useRef(void 0), d = Y(() => {
397
+ f.current && (f.current(), f.current = void 0);
398
+ }, 100);
399
+ return c.useEffect(() => {
400
+ const h = n.viewport;
401
+ if (h) {
402
+ const u = () => {
403
+ if (d(), !f.current) {
404
+ const S = Pe(h, s);
405
+ f.current = S, s();
406
+ }
315
407
  };
316
- }, [l, r.thumbs]), /* @__PURE__ */ pe(
317
- "span",
408
+ return s(), h.addEventListener("scroll", u), () => h.removeEventListener("scroll", u);
409
+ }
410
+ }, [n.viewport, d, s]), /* @__PURE__ */ b(
411
+ L.div,
318
412
  {
413
+ "data-state": i.hasThumb ? "visible" : "hidden",
414
+ ...o,
415
+ ref: a,
319
416
  style: {
320
- transform: "var(--radix-slider-thumb-transform)",
321
- position: "absolute",
322
- [s.startEdge]: `calc(${P}% + ${f}px)`
417
+ width: "var(--radix-scroll-area-thumb-width)",
418
+ height: "var(--radix-scroll-area-thumb-height)",
419
+ ...l
323
420
  },
324
- children: [
325
- /* @__PURE__ */ v(z.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(
326
- K.span,
327
- {
328
- role: "slider",
329
- "aria-label": e["aria-label"] || g,
330
- "aria-valuemin": r.min,
331
- "aria-valuenow": w,
332
- "aria-valuemax": r.max,
333
- "aria-orientation": r.orientation,
334
- "data-orientation": r.orientation,
335
- "data-disabled": r.disabled ? "" : void 0,
336
- tabIndex: r.disabled ? void 0 : 0,
337
- ...c,
338
- ref: S,
339
- style: w === void 0 ? { display: "none" } : e.style,
340
- onFocus: C(e.onFocus, () => {
341
- r.valueIndexToChangeRef.current = n;
342
- })
343
- }
344
- ) }),
345
- i && /* @__PURE__ */ v(
346
- re,
347
- {
348
- name: a ?? (r.name ? r.name + (r.values.length > 1 ? "[]" : "") : void 0),
349
- form: r.form,
350
- value: w
351
- },
352
- n
353
- )
354
- ]
421
+ onPointerDownCapture: R(e.onPointerDownCapture, (h) => {
422
+ const S = h.target.getBoundingClientRect(), p = h.clientX - S.left, y = h.clientY - S.top;
423
+ i.onThumbPointerDown({ x: p, y });
424
+ }),
425
+ onPointerUp: R(e.onPointerUp, i.onThumbPointerUp)
355
426
  }
356
427
  );
357
428
  }
358
429
  );
359
- oe.displayName = O;
360
- var Re = "RadioBubbleInput", re = d.forwardRef(
361
- ({ __scopeSlider: e, value: t, ...o }, n) => {
362
- const a = d.useRef(null), c = M(a, n), r = ue(t);
363
- return d.useEffect(() => {
364
- const s = a.current;
365
- if (!s) return;
366
- const l = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(l, "value").set;
367
- if (r !== t && S) {
368
- const i = new Event("input", { bubbles: !0 });
369
- S.call(s, t), s.dispatchEvent(i);
370
- }
371
- }, [r, t]), /* @__PURE__ */ v(
372
- K.input,
373
- {
374
- style: { display: "none" },
375
- ...o,
376
- ref: c,
377
- defaultValue: t
378
- }
379
- );
430
+ pe.displayName = N;
431
+ var B = "ScrollAreaCorner", Z = c.forwardRef(
432
+ (e, t) => {
433
+ const r = v(B, e.__scopeScrollArea), l = !!(r.scrollbarX && r.scrollbarY);
434
+ return r.type !== "scroll" && l ? /* @__PURE__ */ b(we, { ...e, ref: t }) : null;
380
435
  }
381
436
  );
382
- re.displayName = Re;
383
- function Pe(e = [], t, o) {
384
- const n = [...e];
385
- return n[o] = t, n.sort((a, c) => a - c);
386
- }
387
- function ie(e, t, o) {
388
- const c = 100 / (o - t) * (e - t);
389
- return $(c, [0, 100]);
390
- }
391
- function xe(e, t) {
392
- return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
437
+ Z.displayName = B;
438
+ var we = c.forwardRef((e, t) => {
439
+ const { __scopeScrollArea: r, ...l } = e, o = v(B, r), [n, i] = c.useState(0), [s, a] = c.useState(0), f = !!(n && s);
440
+ return T(o.scrollbarX, () => {
441
+ var h;
442
+ const d = ((h = o.scrollbarX) == null ? void 0 : h.offsetHeight) || 0;
443
+ o.onCornerHeightChange(d), a(d);
444
+ }), T(o.scrollbarY, () => {
445
+ var h;
446
+ const d = ((h = o.scrollbarY) == null ? void 0 : h.offsetWidth) || 0;
447
+ o.onCornerWidthChange(d), i(d);
448
+ }), f ? /* @__PURE__ */ b(
449
+ L.div,
450
+ {
451
+ ...l,
452
+ ref: t,
453
+ style: {
454
+ width: n,
455
+ height: s,
456
+ position: "absolute",
457
+ right: o.dir === "ltr" ? 0 : void 0,
458
+ left: o.dir === "rtl" ? 0 : void 0,
459
+ bottom: 0,
460
+ ...e.style
461
+ }
462
+ }
463
+ ) : null;
464
+ });
465
+ function O(e) {
466
+ return e ? parseInt(e, 10) : 0;
393
467
  }
394
- function ye(e, t) {
395
- if (e.length === 1) return 0;
396
- const o = e.map((a) => Math.abs(a - t)), n = Math.min(...o);
397
- return o.indexOf(n);
468
+ function ee(e, t) {
469
+ const r = e / t;
470
+ return isNaN(r) ? 0 : r;
398
471
  }
399
- function De(e, t, o) {
400
- const n = e / 2, c = U([0, 50], [0, n]);
401
- return (n - c(t) * o) * o;
472
+ function X(e) {
473
+ const t = ee(e.viewport, e.content), r = e.scrollbar.paddingStart + e.scrollbar.paddingEnd, l = (e.scrollbar.size - r) * t;
474
+ return Math.max(l, 18);
402
475
  }
403
- function Ee(e) {
404
- return e.slice(0, -1).map((t, o) => e[o + 1] - t);
476
+ function ge(e, t, r, l = "ltr") {
477
+ const o = X(r), n = o / 2, i = t || n, s = o - i, a = r.scrollbar.paddingStart + i, f = r.scrollbar.size - r.scrollbar.paddingEnd - s, d = r.content - r.viewport, h = l === "ltr" ? [0, d] : [d * -1, 0];
478
+ return re([a, f], h)(e);
405
479
  }
406
- function _e(e, t) {
407
- if (t > 0) {
408
- const o = Ee(e);
409
- return Math.min(...o) >= t;
410
- }
411
- return !0;
480
+ function F(e, t, r = "ltr") {
481
+ const l = X(t), o = t.scrollbar.paddingStart + t.scrollbar.paddingEnd, n = t.scrollbar.size - o, i = t.content - t.viewport, s = n - l, a = r === "ltr" ? [0, i] : [i * -1, 0], f = ce(e, a);
482
+ return re([0, i], [0, s])(f);
412
483
  }
413
- function U(e, t) {
414
- return (o) => {
484
+ function re(e, t) {
485
+ return (r) => {
415
486
  if (e[0] === e[1] || t[0] === t[1]) return t[0];
416
- const n = (t[1] - t[0]) / (e[1] - e[0]);
417
- return t[0] + n * (o - e[0]);
487
+ const l = (t[1] - t[0]) / (e[1] - e[0]);
488
+ return t[0] + l * (r - e[0]);
418
489
  };
419
490
  }
420
- function Ce(e) {
421
- return (String(e).split(".")[1] || "").length;
491
+ function oe(e, t) {
492
+ return e > 0 && e < t;
493
+ }
494
+ var Pe = (e, t = () => {
495
+ }) => {
496
+ let r = { left: e.scrollLeft, top: e.scrollTop }, l = 0;
497
+ return function o() {
498
+ const n = { left: e.scrollLeft, top: e.scrollTop }, i = r.left !== n.left, s = r.top !== n.top;
499
+ (i || s) && t(), r = n, l = window.requestAnimationFrame(o);
500
+ }(), () => window.cancelAnimationFrame(l);
501
+ };
502
+ function Y(e, t) {
503
+ const r = C(e), l = c.useRef(0);
504
+ return c.useEffect(() => () => window.clearTimeout(l.current), []), c.useCallback(() => {
505
+ window.clearTimeout(l.current), l.current = window.setTimeout(r, t);
506
+ }, [r, t]);
422
507
  }
423
- function Me(e, t) {
424
- const o = Math.pow(10, t);
425
- return Math.round(e * o) / o;
508
+ function T(e, t) {
509
+ const r = C(t);
510
+ le(() => {
511
+ let l = 0;
512
+ if (e) {
513
+ const o = new ResizeObserver(() => {
514
+ cancelAnimationFrame(l), l = window.requestAnimationFrame(r);
515
+ });
516
+ return o.observe(e), () => {
517
+ window.cancelAnimationFrame(l), o.unobserve(e);
518
+ };
519
+ }
520
+ }, [e, r]);
426
521
  }
427
- var Oe = q, Ue = te, Fe = ne, Ye = oe;
522
+ var He = q, ze = G, Ne = Z;
428
523
  export {
429
- Fe as Range,
430
- Oe as Root,
431
- q as Slider,
432
- ne as SliderRange,
433
- oe as SliderThumb,
434
- te as SliderTrack,
435
- Ye as Thumb,
436
- Ue as Track
524
+ Ne as Corner,
525
+ He as Root,
526
+ q as ScrollArea,
527
+ Z as ScrollAreaCorner,
528
+ ue as ScrollAreaScrollbar,
529
+ pe as ScrollAreaThumb,
530
+ G as ScrollAreaViewport,
531
+ ze as Viewport
437
532
  };