@radix-ui/react-scroll-area 1.0.6-rc.8 → 1.1.0-rc.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.
- package/dist/index.d.mts +47 -35
- package/dist/index.d.ts +47 -35
- package/dist/index.js +665 -730
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +676 -743
- package/dist/index.mjs.map +7 -1
- package/package.json +10 -11
- package/dist/index.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,804 +1,737 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {Primitive
|
|
4
|
-
import {Presence
|
|
5
|
-
import {createContextScope
|
|
6
|
-
import {useComposedRefs
|
|
7
|
-
import {useCallbackRef
|
|
8
|
-
import {useDirection
|
|
9
|
-
import {useLayoutEffect
|
|
10
|
-
import {clamp
|
|
11
|
-
import {composeEventHandlers
|
|
1
|
+
// packages/react/scroll-area/src/ScrollArea.tsx
|
|
2
|
+
import * as React2 from "react";
|
|
3
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
4
|
+
import { Presence } from "@radix-ui/react-presence";
|
|
5
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
6
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
7
|
+
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
|
8
|
+
import { useDirection } from "@radix-ui/react-direction";
|
|
9
|
+
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
|
10
|
+
import { clamp } from "@radix-ui/number";
|
|
11
|
+
import { composeEventHandlers } from "@radix-ui/primitive";
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function $6c2e24571c90391f$export$3e6543de14f8614f(initialState, machine) {
|
|
26
|
-
return $fnFM9$useReducer((state, event)=>{
|
|
27
|
-
const nextState = machine[state][event];
|
|
28
|
-
return nextState !== null && nextState !== void 0 ? nextState : state;
|
|
29
|
-
}, initialState);
|
|
13
|
+
// packages/react/scroll-area/src/useStateMachine.ts
|
|
14
|
+
import * as React from "react";
|
|
15
|
+
function useStateMachine(initialState, machine) {
|
|
16
|
+
return React.useReducer((state, event) => {
|
|
17
|
+
const nextState = machine[state][event];
|
|
18
|
+
return nextState ?? state;
|
|
19
|
+
}, initialState);
|
|
30
20
|
}
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const [
|
|
47
|
-
const [
|
|
48
|
-
const [
|
|
49
|
-
const
|
|
50
|
-
);
|
|
51
|
-
const
|
|
52
|
-
|
|
22
|
+
// packages/react/scroll-area/src/ScrollArea.tsx
|
|
23
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
24
|
+
var SCROLL_AREA_NAME = "ScrollArea";
|
|
25
|
+
var [createScrollAreaContext, createScrollAreaScope] = createContextScope(SCROLL_AREA_NAME);
|
|
26
|
+
var [ScrollAreaProvider, useScrollAreaContext] = createScrollAreaContext(SCROLL_AREA_NAME);
|
|
27
|
+
var ScrollArea = React2.forwardRef(
|
|
28
|
+
(props, forwardedRef) => {
|
|
29
|
+
const {
|
|
30
|
+
__scopeScrollArea,
|
|
31
|
+
type = "hover",
|
|
32
|
+
dir,
|
|
33
|
+
scrollHideDelay = 600,
|
|
34
|
+
...scrollAreaProps
|
|
35
|
+
} = props;
|
|
36
|
+
const [scrollArea, setScrollArea] = React2.useState(null);
|
|
37
|
+
const [viewport, setViewport] = React2.useState(null);
|
|
38
|
+
const [content, setContent] = React2.useState(null);
|
|
39
|
+
const [scrollbarX, setScrollbarX] = React2.useState(null);
|
|
40
|
+
const [scrollbarY, setScrollbarY] = React2.useState(null);
|
|
41
|
+
const [cornerWidth, setCornerWidth] = React2.useState(0);
|
|
42
|
+
const [cornerHeight, setCornerHeight] = React2.useState(0);
|
|
43
|
+
const [scrollbarXEnabled, setScrollbarXEnabled] = React2.useState(false);
|
|
44
|
+
const [scrollbarYEnabled, setScrollbarYEnabled] = React2.useState(false);
|
|
45
|
+
const composedRefs = useComposedRefs(forwardedRef, (node) => setScrollArea(node));
|
|
46
|
+
const direction = useDirection(dir);
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
ScrollAreaProvider,
|
|
49
|
+
{
|
|
53
50
|
scope: __scopeScrollArea,
|
|
54
|
-
type
|
|
51
|
+
type,
|
|
55
52
|
dir: direction,
|
|
56
|
-
scrollHideDelay
|
|
57
|
-
scrollArea
|
|
58
|
-
viewport
|
|
53
|
+
scrollHideDelay,
|
|
54
|
+
scrollArea,
|
|
55
|
+
viewport,
|
|
59
56
|
onViewportChange: setViewport,
|
|
60
|
-
content
|
|
57
|
+
content,
|
|
61
58
|
onContentChange: setContent,
|
|
62
|
-
scrollbarX
|
|
59
|
+
scrollbarX,
|
|
63
60
|
onScrollbarXChange: setScrollbarX,
|
|
64
|
-
scrollbarXEnabled
|
|
61
|
+
scrollbarXEnabled,
|
|
65
62
|
onScrollbarXEnabledChange: setScrollbarXEnabled,
|
|
66
|
-
scrollbarY
|
|
63
|
+
scrollbarY,
|
|
67
64
|
onScrollbarYChange: setScrollbarY,
|
|
68
|
-
scrollbarYEnabled
|
|
65
|
+
scrollbarYEnabled,
|
|
69
66
|
onScrollbarYEnabledChange: setScrollbarYEnabled,
|
|
70
67
|
onCornerWidthChange: setCornerWidth,
|
|
71
|
-
onCornerHeightChange: setCornerHeight
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
68
|
+
onCornerHeightChange: setCornerHeight,
|
|
69
|
+
children: /* @__PURE__ */ jsx(
|
|
70
|
+
Primitive.div,
|
|
71
|
+
{
|
|
72
|
+
dir: direction,
|
|
73
|
+
...scrollAreaProps,
|
|
74
|
+
ref: composedRefs,
|
|
75
|
+
style: {
|
|
76
|
+
position: "relative",
|
|
77
|
+
// Pass corner sizes as CSS vars to reduce re-renders of context consumers
|
|
78
|
+
["--radix-scroll-area-corner-width"]: cornerWidth + "px",
|
|
79
|
+
["--radix-scroll-area-corner-height"]: cornerHeight + "px",
|
|
80
|
+
...props.style
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
ScrollArea.displayName = SCROLL_AREA_NAME;
|
|
89
|
+
var VIEWPORT_NAME = "ScrollAreaViewport";
|
|
90
|
+
var ScrollAreaViewport = React2.forwardRef(
|
|
91
|
+
(props, forwardedRef) => {
|
|
92
|
+
const { __scopeScrollArea, children, nonce, ...viewportProps } = props;
|
|
93
|
+
const context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea);
|
|
94
|
+
const ref = React2.useRef(null);
|
|
95
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
|
|
96
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
"style",
|
|
99
|
+
{
|
|
100
|
+
dangerouslySetInnerHTML: {
|
|
98
101
|
__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}`
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
},
|
|
103
|
+
nonce
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
Primitive.div,
|
|
108
|
+
{
|
|
109
|
+
"data-radix-scroll-area-viewport": "",
|
|
110
|
+
...viewportProps,
|
|
111
|
+
ref: composedRefs,
|
|
112
|
+
style: {
|
|
106
113
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
* We don't support `visible` because the intention is to have at least one scrollbar
|
|
115
|
+
* if this component is used and `visible` will behave like `auto` in that case
|
|
116
|
+
* https://developer.mozilla.org/en-US/docs/Web/CSS/overflowed#description
|
|
117
|
+
*
|
|
118
|
+
* We don't handle `auto` because the intention is for the native implementation
|
|
119
|
+
* to be hidden if using this component. We just want to ensure the node is scrollable
|
|
120
|
+
* so could have used either `scroll` or `auto` here. We picked `scroll` to prevent
|
|
121
|
+
* the browser from having to work out whether to render native scrollbars or not,
|
|
122
|
+
* we tell it to with the intention of hiding them in CSS.
|
|
123
|
+
*/
|
|
124
|
+
overflowX: context.scrollbarXEnabled ? "scroll" : "hidden",
|
|
125
|
+
overflowY: context.scrollbarYEnabled ? "scroll" : "hidden",
|
|
118
126
|
...props.style
|
|
127
|
+
},
|
|
128
|
+
children: /* @__PURE__ */ jsx("div", { ref: context.onContentChange, style: { minWidth: "100%", display: "table" }, children })
|
|
119
129
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
window.clearTimeout(hideTimer);
|
|
175
|
-
setVisible(true);
|
|
176
|
-
};
|
|
177
|
-
const handlePointerLeave = ()=>{
|
|
178
|
-
hideTimer = window.setTimeout(()=>setVisible(false)
|
|
179
|
-
, context.scrollHideDelay);
|
|
180
|
-
};
|
|
181
|
-
scrollArea.addEventListener('pointerenter', handlePointerEnter);
|
|
182
|
-
scrollArea.addEventListener('pointerleave', handlePointerLeave);
|
|
183
|
-
return ()=>{
|
|
184
|
-
window.clearTimeout(hideTimer);
|
|
185
|
-
scrollArea.removeEventListener('pointerenter', handlePointerEnter);
|
|
186
|
-
scrollArea.removeEventListener('pointerleave', handlePointerLeave);
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
}, [
|
|
190
|
-
context.scrollArea,
|
|
191
|
-
context.scrollHideDelay
|
|
192
|
-
]);
|
|
193
|
-
return /*#__PURE__*/ $fnFM9$createElement($fnFM9$Presence, {
|
|
194
|
-
present: forceMount || visible
|
|
195
|
-
}, /*#__PURE__*/ $fnFM9$createElement($57acba87d6e25586$var$ScrollAreaScrollbarAuto, $fnFM9$babelruntimehelpersesmextends({
|
|
196
|
-
"data-state": visible ? 'visible' : 'hidden'
|
|
197
|
-
}, scrollbarProps, {
|
|
198
|
-
ref: forwardedRef
|
|
199
|
-
})));
|
|
200
|
-
});
|
|
201
|
-
const $57acba87d6e25586$var$ScrollAreaScrollbarScroll = /*#__PURE__*/ $fnFM9$forwardRef((props, forwardedRef)=>{
|
|
202
|
-
const { forceMount: forceMount , ...scrollbarProps } = props;
|
|
203
|
-
const context = $57acba87d6e25586$var$useScrollAreaContext($57acba87d6e25586$var$SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
204
|
-
const isHorizontal = props.orientation === 'horizontal';
|
|
205
|
-
const debounceScrollEnd = $57acba87d6e25586$var$useDebounceCallback(()=>send('SCROLL_END')
|
|
206
|
-
, 100);
|
|
207
|
-
const [state, send] = $6c2e24571c90391f$export$3e6543de14f8614f('hidden', {
|
|
208
|
-
hidden: {
|
|
209
|
-
SCROLL: 'scrolling'
|
|
210
|
-
},
|
|
211
|
-
scrolling: {
|
|
212
|
-
SCROLL_END: 'idle',
|
|
213
|
-
POINTER_ENTER: 'interacting'
|
|
214
|
-
},
|
|
215
|
-
interacting: {
|
|
216
|
-
SCROLL: 'interacting',
|
|
217
|
-
POINTER_LEAVE: 'idle'
|
|
218
|
-
},
|
|
219
|
-
idle: {
|
|
220
|
-
HIDE: 'hidden',
|
|
221
|
-
SCROLL: 'scrolling',
|
|
222
|
-
POINTER_ENTER: 'interacting'
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
$fnFM9$useEffect(()=>{
|
|
226
|
-
if (state === 'idle') {
|
|
227
|
-
const hideTimer = window.setTimeout(()=>send('HIDE')
|
|
228
|
-
, context.scrollHideDelay);
|
|
229
|
-
return ()=>window.clearTimeout(hideTimer)
|
|
230
|
-
;
|
|
231
|
-
}
|
|
232
|
-
}, [
|
|
233
|
-
state,
|
|
234
|
-
context.scrollHideDelay,
|
|
235
|
-
send
|
|
236
|
-
]);
|
|
237
|
-
$fnFM9$useEffect(()=>{
|
|
238
|
-
const viewport = context.viewport;
|
|
239
|
-
const scrollDirection = isHorizontal ? 'scrollLeft' : 'scrollTop';
|
|
240
|
-
if (viewport) {
|
|
241
|
-
let prevScrollPos = viewport[scrollDirection];
|
|
242
|
-
const handleScroll = ()=>{
|
|
243
|
-
const scrollPos = viewport[scrollDirection];
|
|
244
|
-
const hasScrollInDirectionChanged = prevScrollPos !== scrollPos;
|
|
245
|
-
if (hasScrollInDirectionChanged) {
|
|
246
|
-
send('SCROLL');
|
|
247
|
-
debounceScrollEnd();
|
|
248
|
-
}
|
|
249
|
-
prevScrollPos = scrollPos;
|
|
250
|
-
};
|
|
251
|
-
viewport.addEventListener('scroll', handleScroll);
|
|
252
|
-
return ()=>viewport.removeEventListener('scroll', handleScroll)
|
|
253
|
-
;
|
|
254
|
-
}
|
|
255
|
-
}, [
|
|
256
|
-
context.viewport,
|
|
257
|
-
isHorizontal,
|
|
258
|
-
send,
|
|
259
|
-
debounceScrollEnd
|
|
260
|
-
]);
|
|
261
|
-
return /*#__PURE__*/ $fnFM9$createElement($fnFM9$Presence, {
|
|
262
|
-
present: forceMount || state !== 'hidden'
|
|
263
|
-
}, /*#__PURE__*/ $fnFM9$createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, $fnFM9$babelruntimehelpersesmextends({
|
|
264
|
-
"data-state": state === 'hidden' ? 'hidden' : 'visible'
|
|
265
|
-
}, scrollbarProps, {
|
|
266
|
-
ref: forwardedRef,
|
|
267
|
-
onPointerEnter: $fnFM9$composeEventHandlers(props.onPointerEnter, ()=>send('POINTER_ENTER')
|
|
268
|
-
),
|
|
269
|
-
onPointerLeave: $fnFM9$composeEventHandlers(props.onPointerLeave, ()=>send('POINTER_LEAVE')
|
|
270
|
-
)
|
|
271
|
-
})));
|
|
130
|
+
)
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
ScrollAreaViewport.displayName = VIEWPORT_NAME;
|
|
135
|
+
var SCROLLBAR_NAME = "ScrollAreaScrollbar";
|
|
136
|
+
var ScrollAreaScrollbar = React2.forwardRef(
|
|
137
|
+
(props, forwardedRef) => {
|
|
138
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
139
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
140
|
+
const { onScrollbarXEnabledChange, onScrollbarYEnabledChange } = context;
|
|
141
|
+
const isHorizontal = props.orientation === "horizontal";
|
|
142
|
+
React2.useEffect(() => {
|
|
143
|
+
isHorizontal ? onScrollbarXEnabledChange(true) : onScrollbarYEnabledChange(true);
|
|
144
|
+
return () => {
|
|
145
|
+
isHorizontal ? onScrollbarXEnabledChange(false) : onScrollbarYEnabledChange(false);
|
|
146
|
+
};
|
|
147
|
+
}, [isHorizontal, onScrollbarXEnabledChange, onScrollbarYEnabledChange]);
|
|
148
|
+
return context.type === "hover" ? /* @__PURE__ */ jsx(ScrollAreaScrollbarHover, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "scroll" ? /* @__PURE__ */ jsx(ScrollAreaScrollbarScroll, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "auto" ? /* @__PURE__ */ jsx(ScrollAreaScrollbarAuto, { ...scrollbarProps, ref: forwardedRef, forceMount }) : context.type === "always" ? /* @__PURE__ */ jsx(ScrollAreaScrollbarVisible, { ...scrollbarProps, ref: forwardedRef }) : null;
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
ScrollAreaScrollbar.displayName = SCROLLBAR_NAME;
|
|
152
|
+
var ScrollAreaScrollbarHover = React2.forwardRef((props, forwardedRef) => {
|
|
153
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
154
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
155
|
+
const [visible, setVisible] = React2.useState(false);
|
|
156
|
+
React2.useEffect(() => {
|
|
157
|
+
const scrollArea = context.scrollArea;
|
|
158
|
+
let hideTimer = 0;
|
|
159
|
+
if (scrollArea) {
|
|
160
|
+
const handlePointerEnter = () => {
|
|
161
|
+
window.clearTimeout(hideTimer);
|
|
162
|
+
setVisible(true);
|
|
163
|
+
};
|
|
164
|
+
const handlePointerLeave = () => {
|
|
165
|
+
hideTimer = window.setTimeout(() => setVisible(false), context.scrollHideDelay);
|
|
166
|
+
};
|
|
167
|
+
scrollArea.addEventListener("pointerenter", handlePointerEnter);
|
|
168
|
+
scrollArea.addEventListener("pointerleave", handlePointerLeave);
|
|
169
|
+
return () => {
|
|
170
|
+
window.clearTimeout(hideTimer);
|
|
171
|
+
scrollArea.removeEventListener("pointerenter", handlePointerEnter);
|
|
172
|
+
scrollArea.removeEventListener("pointerleave", handlePointerLeave);
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}, [context.scrollArea, context.scrollHideDelay]);
|
|
176
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || visible, children: /* @__PURE__ */ jsx(
|
|
177
|
+
ScrollAreaScrollbarAuto,
|
|
178
|
+
{
|
|
179
|
+
"data-state": visible ? "visible" : "hidden",
|
|
180
|
+
...scrollbarProps,
|
|
181
|
+
ref: forwardedRef
|
|
182
|
+
}
|
|
183
|
+
) });
|
|
272
184
|
});
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
185
|
+
var ScrollAreaScrollbarScroll = React2.forwardRef((props, forwardedRef) => {
|
|
186
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
187
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
188
|
+
const isHorizontal = props.orientation === "horizontal";
|
|
189
|
+
const debounceScrollEnd = useDebounceCallback(() => send("SCROLL_END"), 100);
|
|
190
|
+
const [state, send] = useStateMachine("hidden", {
|
|
191
|
+
hidden: {
|
|
192
|
+
SCROLL: "scrolling"
|
|
193
|
+
},
|
|
194
|
+
scrolling: {
|
|
195
|
+
SCROLL_END: "idle",
|
|
196
|
+
POINTER_ENTER: "interacting"
|
|
197
|
+
},
|
|
198
|
+
interacting: {
|
|
199
|
+
SCROLL: "interacting",
|
|
200
|
+
POINTER_LEAVE: "idle"
|
|
201
|
+
},
|
|
202
|
+
idle: {
|
|
203
|
+
HIDE: "hidden",
|
|
204
|
+
SCROLL: "scrolling",
|
|
205
|
+
POINTER_ENTER: "interacting"
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
React2.useEffect(() => {
|
|
209
|
+
if (state === "idle") {
|
|
210
|
+
const hideTimer = window.setTimeout(() => send("HIDE"), context.scrollHideDelay);
|
|
211
|
+
return () => window.clearTimeout(hideTimer);
|
|
212
|
+
}
|
|
213
|
+
}, [state, context.scrollHideDelay, send]);
|
|
214
|
+
React2.useEffect(() => {
|
|
215
|
+
const viewport = context.viewport;
|
|
216
|
+
const scrollDirection = isHorizontal ? "scrollLeft" : "scrollTop";
|
|
217
|
+
if (viewport) {
|
|
218
|
+
let prevScrollPos = viewport[scrollDirection];
|
|
219
|
+
const handleScroll = () => {
|
|
220
|
+
const scrollPos = viewport[scrollDirection];
|
|
221
|
+
const hasScrollInDirectionChanged = prevScrollPos !== scrollPos;
|
|
222
|
+
if (hasScrollInDirectionChanged) {
|
|
223
|
+
send("SCROLL");
|
|
224
|
+
debounceScrollEnd();
|
|
283
225
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
226
|
+
prevScrollPos = scrollPos;
|
|
227
|
+
};
|
|
228
|
+
viewport.addEventListener("scroll", handleScroll);
|
|
229
|
+
return () => viewport.removeEventListener("scroll", handleScroll);
|
|
230
|
+
}
|
|
231
|
+
}, [context.viewport, isHorizontal, send, debounceScrollEnd]);
|
|
232
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || state !== "hidden", children: /* @__PURE__ */ jsx(
|
|
233
|
+
ScrollAreaScrollbarVisible,
|
|
234
|
+
{
|
|
235
|
+
"data-state": state === "hidden" ? "hidden" : "visible",
|
|
236
|
+
...scrollbarProps,
|
|
237
|
+
ref: forwardedRef,
|
|
238
|
+
onPointerEnter: composeEventHandlers(props.onPointerEnter, () => send("POINTER_ENTER")),
|
|
239
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, () => send("POINTER_LEAVE"))
|
|
240
|
+
}
|
|
241
|
+
) });
|
|
294
242
|
});
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
onThumbChange: (thumb)=>thumbRef.current = thumb
|
|
316
|
-
,
|
|
317
|
-
onThumbPointerUp: ()=>pointerOffsetRef.current = 0
|
|
318
|
-
,
|
|
319
|
-
onThumbPointerDown: (pointerPos)=>pointerOffsetRef.current = pointerPos
|
|
320
|
-
};
|
|
321
|
-
function getScrollPosition(pointerPos, dir) {
|
|
322
|
-
return $57acba87d6e25586$var$getScrollPositionFromPointer(pointerPos, pointerOffsetRef.current, sizes, dir);
|
|
243
|
+
var ScrollAreaScrollbarAuto = React2.forwardRef((props, forwardedRef) => {
|
|
244
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
245
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
246
|
+
const [visible, setVisible] = React2.useState(false);
|
|
247
|
+
const isHorizontal = props.orientation === "horizontal";
|
|
248
|
+
const handleResize = useDebounceCallback(() => {
|
|
249
|
+
if (context.viewport) {
|
|
250
|
+
const isOverflowX = context.viewport.offsetWidth < context.viewport.scrollWidth;
|
|
251
|
+
const isOverflowY = context.viewport.offsetHeight < context.viewport.scrollHeight;
|
|
252
|
+
setVisible(isHorizontal ? isOverflowX : isOverflowY);
|
|
253
|
+
}
|
|
254
|
+
}, 10);
|
|
255
|
+
useResizeObserver(context.viewport, handleResize);
|
|
256
|
+
useResizeObserver(context.content, handleResize);
|
|
257
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || visible, children: /* @__PURE__ */ jsx(
|
|
258
|
+
ScrollAreaScrollbarVisible,
|
|
259
|
+
{
|
|
260
|
+
"data-state": visible ? "visible" : "hidden",
|
|
261
|
+
...scrollbarProps,
|
|
262
|
+
ref: forwardedRef
|
|
323
263
|
}
|
|
324
|
-
|
|
264
|
+
) });
|
|
265
|
+
});
|
|
266
|
+
var ScrollAreaScrollbarVisible = React2.forwardRef((props, forwardedRef) => {
|
|
267
|
+
const { orientation = "vertical", ...scrollbarProps } = props;
|
|
268
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
269
|
+
const thumbRef = React2.useRef(null);
|
|
270
|
+
const pointerOffsetRef = React2.useRef(0);
|
|
271
|
+
const [sizes, setSizes] = React2.useState({
|
|
272
|
+
content: 0,
|
|
273
|
+
viewport: 0,
|
|
274
|
+
scrollbar: { size: 0, paddingStart: 0, paddingEnd: 0 }
|
|
275
|
+
});
|
|
276
|
+
const thumbRatio = getThumbRatio(sizes.viewport, sizes.content);
|
|
277
|
+
const commonProps = {
|
|
278
|
+
...scrollbarProps,
|
|
279
|
+
sizes,
|
|
280
|
+
onSizesChange: setSizes,
|
|
281
|
+
hasThumb: Boolean(thumbRatio > 0 && thumbRatio < 1),
|
|
282
|
+
onThumbChange: (thumb) => thumbRef.current = thumb,
|
|
283
|
+
onThumbPointerUp: () => pointerOffsetRef.current = 0,
|
|
284
|
+
onThumbPointerDown: (pointerPos) => pointerOffsetRef.current = pointerPos
|
|
285
|
+
};
|
|
286
|
+
function getScrollPosition(pointerPos, dir) {
|
|
287
|
+
return getScrollPositionFromPointer(pointerPos, pointerOffsetRef.current, sizes, dir);
|
|
288
|
+
}
|
|
289
|
+
if (orientation === "horizontal") {
|
|
290
|
+
return /* @__PURE__ */ jsx(
|
|
291
|
+
ScrollAreaScrollbarX,
|
|
292
|
+
{
|
|
293
|
+
...commonProps,
|
|
325
294
|
ref: forwardedRef,
|
|
326
|
-
onThumbPositionChange: ()=>{
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
295
|
+
onThumbPositionChange: () => {
|
|
296
|
+
if (context.viewport && thumbRef.current) {
|
|
297
|
+
const scrollPos = context.viewport.scrollLeft;
|
|
298
|
+
const offset = getThumbOffsetFromScroll(scrollPos, sizes, context.dir);
|
|
299
|
+
thumbRef.current.style.transform = `translate3d(${offset}px, 0, 0)`;
|
|
300
|
+
}
|
|
332
301
|
},
|
|
333
|
-
onWheelScroll: (scrollPos)=>{
|
|
334
|
-
|
|
302
|
+
onWheelScroll: (scrollPos) => {
|
|
303
|
+
if (context.viewport) context.viewport.scrollLeft = scrollPos;
|
|
335
304
|
},
|
|
336
|
-
onDragScroll: (pointerPos)=>{
|
|
337
|
-
|
|
305
|
+
onDragScroll: (pointerPos) => {
|
|
306
|
+
if (context.viewport) {
|
|
307
|
+
context.viewport.scrollLeft = getScrollPosition(pointerPos, context.dir);
|
|
308
|
+
}
|
|
338
309
|
}
|
|
339
|
-
|
|
340
|
-
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
if (orientation === "vertical") {
|
|
314
|
+
return /* @__PURE__ */ jsx(
|
|
315
|
+
ScrollAreaScrollbarY,
|
|
316
|
+
{
|
|
317
|
+
...commonProps,
|
|
341
318
|
ref: forwardedRef,
|
|
342
|
-
onThumbPositionChange: ()=>{
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
319
|
+
onThumbPositionChange: () => {
|
|
320
|
+
if (context.viewport && thumbRef.current) {
|
|
321
|
+
const scrollPos = context.viewport.scrollTop;
|
|
322
|
+
const offset = getThumbOffsetFromScroll(scrollPos, sizes);
|
|
323
|
+
thumbRef.current.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
324
|
+
}
|
|
348
325
|
},
|
|
349
|
-
onWheelScroll: (scrollPos)=>{
|
|
350
|
-
|
|
326
|
+
onWheelScroll: (scrollPos) => {
|
|
327
|
+
if (context.viewport) context.viewport.scrollTop = scrollPos;
|
|
351
328
|
},
|
|
352
|
-
onDragScroll: (pointerPos)=>{
|
|
353
|
-
|
|
329
|
+
onDragScroll: (pointerPos) => {
|
|
330
|
+
if (context.viewport) context.viewport.scrollTop = getScrollPosition(pointerPos);
|
|
354
331
|
}
|
|
355
|
-
|
|
356
|
-
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
return null;
|
|
357
336
|
});
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
337
|
+
var ScrollAreaScrollbarX = React2.forwardRef((props, forwardedRef) => {
|
|
338
|
+
const { sizes, onSizesChange, ...scrollbarProps } = props;
|
|
339
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
340
|
+
const [computedStyle, setComputedStyle] = React2.useState();
|
|
341
|
+
const ref = React2.useRef(null);
|
|
342
|
+
const composeRefs = useComposedRefs(forwardedRef, ref, context.onScrollbarXChange);
|
|
343
|
+
React2.useEffect(() => {
|
|
344
|
+
if (ref.current) setComputedStyle(getComputedStyle(ref.current));
|
|
345
|
+
}, [ref]);
|
|
346
|
+
return /* @__PURE__ */ jsx(
|
|
347
|
+
ScrollAreaScrollbarImpl,
|
|
348
|
+
{
|
|
349
|
+
"data-orientation": "horizontal",
|
|
350
|
+
...scrollbarProps,
|
|
351
|
+
ref: composeRefs,
|
|
352
|
+
sizes,
|
|
353
|
+
style: {
|
|
354
|
+
bottom: 0,
|
|
355
|
+
left: context.dir === "rtl" ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
356
|
+
right: context.dir === "ltr" ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
357
|
+
["--radix-scroll-area-thumb-width"]: getThumbSize(sizes) + "px",
|
|
358
|
+
...props.style
|
|
359
|
+
},
|
|
360
|
+
onThumbPointerDown: (pointerPos) => props.onThumbPointerDown(pointerPos.x),
|
|
361
|
+
onDragScroll: (pointerPos) => props.onDragScroll(pointerPos.x),
|
|
362
|
+
onWheelScroll: (event, maxScrollPos) => {
|
|
363
|
+
if (context.viewport) {
|
|
364
|
+
const scrollPos = context.viewport.scrollLeft + event.deltaX;
|
|
365
|
+
props.onWheelScroll(scrollPos);
|
|
366
|
+
if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) {
|
|
367
|
+
event.preventDefault();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
onResize: () => {
|
|
372
|
+
if (ref.current && context.viewport && computedStyle) {
|
|
373
|
+
onSizesChange({
|
|
374
|
+
content: context.viewport.scrollWidth,
|
|
375
|
+
viewport: context.viewport.offsetWidth,
|
|
376
|
+
scrollbar: {
|
|
377
|
+
size: ref.current.clientWidth,
|
|
378
|
+
paddingStart: toInt(computedStyle.paddingLeft),
|
|
379
|
+
paddingEnd: toInt(computedStyle.paddingRight)
|
|
390
380
|
}
|
|
391
|
-
|
|
392
|
-
onResize: ()=>{
|
|
393
|
-
if (ref.current && context.viewport && computedStyle) onSizesChange({
|
|
394
|
-
content: context.viewport.scrollWidth,
|
|
395
|
-
viewport: context.viewport.offsetWidth,
|
|
396
|
-
scrollbar: {
|
|
397
|
-
size: ref.current.clientWidth,
|
|
398
|
-
paddingStart: $57acba87d6e25586$var$toInt(computedStyle.paddingLeft),
|
|
399
|
-
paddingEnd: $57acba87d6e25586$var$toInt(computedStyle.paddingRight)
|
|
400
|
-
}
|
|
401
|
-
});
|
|
381
|
+
});
|
|
402
382
|
}
|
|
403
|
-
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
);
|
|
404
386
|
});
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
387
|
+
var ScrollAreaScrollbarY = React2.forwardRef((props, forwardedRef) => {
|
|
388
|
+
const { sizes, onSizesChange, ...scrollbarProps } = props;
|
|
389
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
390
|
+
const [computedStyle, setComputedStyle] = React2.useState();
|
|
391
|
+
const ref = React2.useRef(null);
|
|
392
|
+
const composeRefs = useComposedRefs(forwardedRef, ref, context.onScrollbarYChange);
|
|
393
|
+
React2.useEffect(() => {
|
|
394
|
+
if (ref.current) setComputedStyle(getComputedStyle(ref.current));
|
|
395
|
+
}, [ref]);
|
|
396
|
+
return /* @__PURE__ */ jsx(
|
|
397
|
+
ScrollAreaScrollbarImpl,
|
|
398
|
+
{
|
|
399
|
+
"data-orientation": "vertical",
|
|
400
|
+
...scrollbarProps,
|
|
401
|
+
ref: composeRefs,
|
|
402
|
+
sizes,
|
|
403
|
+
style: {
|
|
404
|
+
top: 0,
|
|
405
|
+
right: context.dir === "ltr" ? 0 : void 0,
|
|
406
|
+
left: context.dir === "rtl" ? 0 : void 0,
|
|
407
|
+
bottom: "var(--radix-scroll-area-corner-height)",
|
|
408
|
+
["--radix-scroll-area-thumb-height"]: getThumbSize(sizes) + "px",
|
|
409
|
+
...props.style
|
|
410
|
+
},
|
|
411
|
+
onThumbPointerDown: (pointerPos) => props.onThumbPointerDown(pointerPos.y),
|
|
412
|
+
onDragScroll: (pointerPos) => props.onDragScroll(pointerPos.y),
|
|
413
|
+
onWheelScroll: (event, maxScrollPos) => {
|
|
414
|
+
if (context.viewport) {
|
|
415
|
+
const scrollPos = context.viewport.scrollTop + event.deltaY;
|
|
416
|
+
props.onWheelScroll(scrollPos);
|
|
417
|
+
if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) {
|
|
418
|
+
event.preventDefault();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
onResize: () => {
|
|
423
|
+
if (ref.current && context.viewport && computedStyle) {
|
|
424
|
+
onSizesChange({
|
|
425
|
+
content: context.viewport.scrollHeight,
|
|
426
|
+
viewport: context.viewport.offsetHeight,
|
|
427
|
+
scrollbar: {
|
|
428
|
+
size: ref.current.clientHeight,
|
|
429
|
+
paddingStart: toInt(computedStyle.paddingTop),
|
|
430
|
+
paddingEnd: toInt(computedStyle.paddingBottom)
|
|
438
431
|
}
|
|
439
|
-
|
|
440
|
-
onResize: ()=>{
|
|
441
|
-
if (ref.current && context.viewport && computedStyle) onSizesChange({
|
|
442
|
-
content: context.viewport.scrollHeight,
|
|
443
|
-
viewport: context.viewport.offsetHeight,
|
|
444
|
-
scrollbar: {
|
|
445
|
-
size: ref.current.clientHeight,
|
|
446
|
-
paddingStart: $57acba87d6e25586$var$toInt(computedStyle.paddingTop),
|
|
447
|
-
paddingEnd: $57acba87d6e25586$var$toInt(computedStyle.paddingBottom)
|
|
448
|
-
}
|
|
449
|
-
});
|
|
432
|
+
});
|
|
450
433
|
}
|
|
451
|
-
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
);
|
|
452
437
|
});
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
438
|
+
var [ScrollbarProvider, useScrollbarContext] = createScrollAreaContext(SCROLLBAR_NAME);
|
|
439
|
+
var ScrollAreaScrollbarImpl = React2.forwardRef((props, forwardedRef) => {
|
|
440
|
+
const {
|
|
441
|
+
__scopeScrollArea,
|
|
442
|
+
sizes,
|
|
443
|
+
hasThumb,
|
|
444
|
+
onThumbChange,
|
|
445
|
+
onThumbPointerUp,
|
|
446
|
+
onThumbPointerDown,
|
|
447
|
+
onThumbPositionChange,
|
|
448
|
+
onDragScroll,
|
|
449
|
+
onWheelScroll,
|
|
450
|
+
onResize,
|
|
451
|
+
...scrollbarProps
|
|
452
|
+
} = props;
|
|
453
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, __scopeScrollArea);
|
|
454
|
+
const [scrollbar, setScrollbar] = React2.useState(null);
|
|
455
|
+
const composeRefs = useComposedRefs(forwardedRef, (node) => setScrollbar(node));
|
|
456
|
+
const rectRef = React2.useRef(null);
|
|
457
|
+
const prevWebkitUserSelectRef = React2.useRef("");
|
|
458
|
+
const viewport = context.viewport;
|
|
459
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
460
|
+
const handleWheelScroll = useCallbackRef(onWheelScroll);
|
|
461
|
+
const handleThumbPositionChange = useCallbackRef(onThumbPositionChange);
|
|
462
|
+
const handleResize = useDebounceCallback(onResize, 10);
|
|
463
|
+
function handleDragScroll(event) {
|
|
464
|
+
if (rectRef.current) {
|
|
465
|
+
const x = event.clientX - rectRef.current.left;
|
|
466
|
+
const y = event.clientY - rectRef.current.top;
|
|
467
|
+
onDragScroll({ x, y });
|
|
476
468
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
return /*#__PURE__*/ $fnFM9$createElement($57acba87d6e25586$var$ScrollbarProvider, {
|
|
508
|
-
scope: __scopeScrollArea,
|
|
509
|
-
scrollbar: scrollbar,
|
|
510
|
-
hasThumb: hasThumb,
|
|
511
|
-
onThumbChange: $fnFM9$useCallbackRef(onThumbChange),
|
|
512
|
-
onThumbPointerUp: $fnFM9$useCallbackRef(onThumbPointerUp),
|
|
513
|
-
onThumbPositionChange: handleThumbPositionChange,
|
|
514
|
-
onThumbPointerDown: $fnFM9$useCallbackRef(onThumbPointerDown)
|
|
515
|
-
}, /*#__PURE__*/ $fnFM9$createElement($fnFM9$Primitive.div, $fnFM9$babelruntimehelpersesmextends({}, scrollbarProps, {
|
|
516
|
-
ref: composeRefs,
|
|
517
|
-
style: {
|
|
518
|
-
position: 'absolute',
|
|
519
|
-
...scrollbarProps.style
|
|
520
|
-
},
|
|
521
|
-
onPointerDown: $fnFM9$composeEventHandlers(props.onPointerDown, (event)=>{
|
|
469
|
+
}
|
|
470
|
+
React2.useEffect(() => {
|
|
471
|
+
const handleWheel = (event) => {
|
|
472
|
+
const element = event.target;
|
|
473
|
+
const isScrollbarWheel = scrollbar?.contains(element);
|
|
474
|
+
if (isScrollbarWheel) handleWheelScroll(event, maxScrollPos);
|
|
475
|
+
};
|
|
476
|
+
document.addEventListener("wheel", handleWheel, { passive: false });
|
|
477
|
+
return () => document.removeEventListener("wheel", handleWheel, { passive: false });
|
|
478
|
+
}, [viewport, scrollbar, maxScrollPos, handleWheelScroll]);
|
|
479
|
+
React2.useEffect(handleThumbPositionChange, [sizes, handleThumbPositionChange]);
|
|
480
|
+
useResizeObserver(scrollbar, handleResize);
|
|
481
|
+
useResizeObserver(context.content, handleResize);
|
|
482
|
+
return /* @__PURE__ */ jsx(
|
|
483
|
+
ScrollbarProvider,
|
|
484
|
+
{
|
|
485
|
+
scope: __scopeScrollArea,
|
|
486
|
+
scrollbar,
|
|
487
|
+
hasThumb,
|
|
488
|
+
onThumbChange: useCallbackRef(onThumbChange),
|
|
489
|
+
onThumbPointerUp: useCallbackRef(onThumbPointerUp),
|
|
490
|
+
onThumbPositionChange: handleThumbPositionChange,
|
|
491
|
+
onThumbPointerDown: useCallbackRef(onThumbPointerDown),
|
|
492
|
+
children: /* @__PURE__ */ jsx(
|
|
493
|
+
Primitive.div,
|
|
494
|
+
{
|
|
495
|
+
...scrollbarProps,
|
|
496
|
+
ref: composeRefs,
|
|
497
|
+
style: { position: "absolute", ...scrollbarProps.style },
|
|
498
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
522
499
|
const mainPointer = 0;
|
|
523
500
|
if (event.button === mainPointer) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
handleDragScroll(event);
|
|
501
|
+
const element = event.target;
|
|
502
|
+
element.setPointerCapture(event.pointerId);
|
|
503
|
+
rectRef.current = scrollbar.getBoundingClientRect();
|
|
504
|
+
prevWebkitUserSelectRef.current = document.body.style.webkitUserSelect;
|
|
505
|
+
document.body.style.webkitUserSelect = "none";
|
|
506
|
+
if (context.viewport) context.viewport.style.scrollBehavior = "auto";
|
|
507
|
+
handleDragScroll(event);
|
|
532
508
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
509
|
+
}),
|
|
510
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, handleDragScroll),
|
|
511
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
536
512
|
const element = event.target;
|
|
537
|
-
if (element.hasPointerCapture(event.pointerId))
|
|
513
|
+
if (element.hasPointerCapture(event.pointerId)) {
|
|
514
|
+
element.releasePointerCapture(event.pointerId);
|
|
515
|
+
}
|
|
538
516
|
document.body.style.webkitUserSelect = prevWebkitUserSelectRef.current;
|
|
539
|
-
if (context.viewport) context.viewport.style.scrollBehavior =
|
|
517
|
+
if (context.viewport) context.viewport.style.scrollBehavior = "";
|
|
540
518
|
rectRef.current = null;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
* -----------------------------------------------------------------------------------------------*/ const $57acba87d6e25586$var$THUMB_NAME = 'ScrollAreaThumb';
|
|
547
|
-
const $57acba87d6e25586$export$9fba1154677d7cd2 = /*#__PURE__*/ $fnFM9$forwardRef((props, forwardedRef)=>{
|
|
548
|
-
const { forceMount: forceMount , ...thumbProps } = props;
|
|
549
|
-
const scrollbarContext = $57acba87d6e25586$var$useScrollbarContext($57acba87d6e25586$var$THUMB_NAME, props.__scopeScrollArea);
|
|
550
|
-
return /*#__PURE__*/ $fnFM9$createElement($fnFM9$Presence, {
|
|
551
|
-
present: forceMount || scrollbarContext.hasThumb
|
|
552
|
-
}, /*#__PURE__*/ $fnFM9$createElement($57acba87d6e25586$var$ScrollAreaThumbImpl, $fnFM9$babelruntimehelpersesmextends({
|
|
553
|
-
ref: forwardedRef
|
|
554
|
-
}, thumbProps)));
|
|
519
|
+
})
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
);
|
|
555
524
|
});
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
|
|
525
|
+
var THUMB_NAME = "ScrollAreaThumb";
|
|
526
|
+
var ScrollAreaThumb = React2.forwardRef(
|
|
527
|
+
(props, forwardedRef) => {
|
|
528
|
+
const { forceMount, ...thumbProps } = props;
|
|
529
|
+
const scrollbarContext = useScrollbarContext(THUMB_NAME, props.__scopeScrollArea);
|
|
530
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || scrollbarContext.hasThumb, children: /* @__PURE__ */ jsx(ScrollAreaThumbImpl, { ref: forwardedRef, ...thumbProps }) });
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
var ScrollAreaThumbImpl = React2.forwardRef(
|
|
534
|
+
(props, forwardedRef) => {
|
|
535
|
+
const { __scopeScrollArea, style, ...thumbProps } = props;
|
|
536
|
+
const scrollAreaContext = useScrollAreaContext(THUMB_NAME, __scopeScrollArea);
|
|
537
|
+
const scrollbarContext = useScrollbarContext(THUMB_NAME, __scopeScrollArea);
|
|
538
|
+
const { onThumbPositionChange } = scrollbarContext;
|
|
539
|
+
const composedRef = useComposedRefs(
|
|
540
|
+
forwardedRef,
|
|
541
|
+
(node) => scrollbarContext.onThumbChange(node)
|
|
562
542
|
);
|
|
563
|
-
const removeUnlinkedScrollListenerRef =
|
|
564
|
-
const debounceScrollEnd =
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
543
|
+
const removeUnlinkedScrollListenerRef = React2.useRef();
|
|
544
|
+
const debounceScrollEnd = useDebounceCallback(() => {
|
|
545
|
+
if (removeUnlinkedScrollListenerRef.current) {
|
|
546
|
+
removeUnlinkedScrollListenerRef.current();
|
|
547
|
+
removeUnlinkedScrollListenerRef.current = void 0;
|
|
548
|
+
}
|
|
569
549
|
}, 100);
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
* https://developer.mozilla.org/en-US/docs/Mozilla/Performance/Scroll-linked_effects
|
|
579
|
-
*/ const handleScroll = ()=>{
|
|
580
|
-
debounceScrollEnd();
|
|
581
|
-
if (!removeUnlinkedScrollListenerRef.current) {
|
|
582
|
-
const listener = $57acba87d6e25586$var$addUnlinkedScrollListener(viewport, onThumbPositionChange);
|
|
583
|
-
removeUnlinkedScrollListenerRef.current = listener;
|
|
584
|
-
onThumbPositionChange();
|
|
585
|
-
}
|
|
586
|
-
};
|
|
550
|
+
React2.useEffect(() => {
|
|
551
|
+
const viewport = scrollAreaContext.viewport;
|
|
552
|
+
if (viewport) {
|
|
553
|
+
const handleScroll = () => {
|
|
554
|
+
debounceScrollEnd();
|
|
555
|
+
if (!removeUnlinkedScrollListenerRef.current) {
|
|
556
|
+
const listener = addUnlinkedScrollListener(viewport, onThumbPositionChange);
|
|
557
|
+
removeUnlinkedScrollListenerRef.current = listener;
|
|
587
558
|
onThumbPositionChange();
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
"data-state": scrollbarContext.hasThumb ?
|
|
599
|
-
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
onThumbPositionChange();
|
|
562
|
+
viewport.addEventListener("scroll", handleScroll);
|
|
563
|
+
return () => viewport.removeEventListener("scroll", handleScroll);
|
|
564
|
+
}
|
|
565
|
+
}, [scrollAreaContext.viewport, debounceScrollEnd, onThumbPositionChange]);
|
|
566
|
+
return /* @__PURE__ */ jsx(
|
|
567
|
+
Primitive.div,
|
|
568
|
+
{
|
|
569
|
+
"data-state": scrollbarContext.hasThumb ? "visible" : "hidden",
|
|
570
|
+
...thumbProps,
|
|
600
571
|
ref: composedRef,
|
|
601
572
|
style: {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
573
|
+
width: "var(--radix-scroll-area-thumb-width)",
|
|
574
|
+
height: "var(--radix-scroll-area-thumb-height)",
|
|
575
|
+
...style
|
|
605
576
|
},
|
|
606
|
-
onPointerDownCapture:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
x: x,
|
|
613
|
-
y: y
|
|
614
|
-
});
|
|
577
|
+
onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, (event) => {
|
|
578
|
+
const thumb = event.target;
|
|
579
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
580
|
+
const x = event.clientX - thumbRect.left;
|
|
581
|
+
const y = event.clientY - thumbRect.top;
|
|
582
|
+
scrollbarContext.onThumbPointerDown({ x, y });
|
|
615
583
|
}),
|
|
616
|
-
onPointerUp:
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
const context = $57acba87d6e25586$var$useScrollAreaContext($57acba87d6e25586$var$CORNER_NAME, props.__scopeScrollArea);
|
|
584
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, scrollbarContext.onThumbPointerUp)
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
ScrollAreaThumb.displayName = THUMB_NAME;
|
|
590
|
+
var CORNER_NAME = "ScrollAreaCorner";
|
|
591
|
+
var ScrollAreaCorner = React2.forwardRef(
|
|
592
|
+
(props, forwardedRef) => {
|
|
593
|
+
const context = useScrollAreaContext(CORNER_NAME, props.__scopeScrollArea);
|
|
627
594
|
const hasBothScrollbarsVisible = Boolean(context.scrollbarX && context.scrollbarY);
|
|
628
|
-
const hasCorner = context.type !==
|
|
629
|
-
return hasCorner ?
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
})) : null;
|
|
595
|
+
const hasCorner = context.type !== "scroll" && hasBothScrollbarsVisible;
|
|
596
|
+
return hasCorner ? /* @__PURE__ */ jsx(ScrollAreaCornerImpl, { ...props, ref: forwardedRef }) : null;
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
ScrollAreaCorner.displayName = CORNER_NAME;
|
|
600
|
+
var ScrollAreaCornerImpl = React2.forwardRef((props, forwardedRef) => {
|
|
601
|
+
const { __scopeScrollArea, ...cornerProps } = props;
|
|
602
|
+
const context = useScrollAreaContext(CORNER_NAME, __scopeScrollArea);
|
|
603
|
+
const [width, setWidth] = React2.useState(0);
|
|
604
|
+
const [height, setHeight] = React2.useState(0);
|
|
605
|
+
const hasSize = Boolean(width && height);
|
|
606
|
+
useResizeObserver(context.scrollbarX, () => {
|
|
607
|
+
const height2 = context.scrollbarX?.offsetHeight || 0;
|
|
608
|
+
context.onCornerHeightChange(height2);
|
|
609
|
+
setHeight(height2);
|
|
610
|
+
});
|
|
611
|
+
useResizeObserver(context.scrollbarY, () => {
|
|
612
|
+
const width2 = context.scrollbarY?.offsetWidth || 0;
|
|
613
|
+
context.onCornerWidthChange(width2);
|
|
614
|
+
setWidth(width2);
|
|
615
|
+
});
|
|
616
|
+
return hasSize ? /* @__PURE__ */ jsx(
|
|
617
|
+
Primitive.div,
|
|
618
|
+
{
|
|
619
|
+
...cornerProps,
|
|
620
|
+
ref: forwardedRef,
|
|
621
|
+
style: {
|
|
622
|
+
width,
|
|
623
|
+
height,
|
|
624
|
+
position: "absolute",
|
|
625
|
+
right: context.dir === "ltr" ? 0 : void 0,
|
|
626
|
+
left: context.dir === "rtl" ? 0 : void 0,
|
|
627
|
+
bottom: 0,
|
|
628
|
+
...props.style
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
) : null;
|
|
666
632
|
});
|
|
667
|
-
|
|
668
|
-
|
|
633
|
+
function toInt(value) {
|
|
634
|
+
return value ? parseInt(value, 10) : 0;
|
|
669
635
|
}
|
|
670
|
-
function
|
|
671
|
-
|
|
672
|
-
|
|
636
|
+
function getThumbRatio(viewportSize, contentSize) {
|
|
637
|
+
const ratio = viewportSize / contentSize;
|
|
638
|
+
return isNaN(ratio) ? 0 : ratio;
|
|
673
639
|
}
|
|
674
|
-
function
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
640
|
+
function getThumbSize(sizes) {
|
|
641
|
+
const ratio = getThumbRatio(sizes.viewport, sizes.content);
|
|
642
|
+
const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
|
|
643
|
+
const thumbSize = (sizes.scrollbar.size - scrollbarPadding) * ratio;
|
|
644
|
+
return Math.max(thumbSize, 18);
|
|
679
645
|
}
|
|
680
|
-
function
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
] : [
|
|
692
|
-
maxScrollPos * -1,
|
|
693
|
-
0
|
|
694
|
-
];
|
|
695
|
-
const interpolate = $57acba87d6e25586$var$linearScale([
|
|
696
|
-
minPointerPos,
|
|
697
|
-
maxPointerPos
|
|
698
|
-
], scrollRange);
|
|
699
|
-
return interpolate(pointerPos);
|
|
646
|
+
function getScrollPositionFromPointer(pointerPos, pointerOffset, sizes, dir = "ltr") {
|
|
647
|
+
const thumbSizePx = getThumbSize(sizes);
|
|
648
|
+
const thumbCenter = thumbSizePx / 2;
|
|
649
|
+
const offset = pointerOffset || thumbCenter;
|
|
650
|
+
const thumbOffsetFromEnd = thumbSizePx - offset;
|
|
651
|
+
const minPointerPos = sizes.scrollbar.paddingStart + offset;
|
|
652
|
+
const maxPointerPos = sizes.scrollbar.size - sizes.scrollbar.paddingEnd - thumbOffsetFromEnd;
|
|
653
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
654
|
+
const scrollRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
|
|
655
|
+
const interpolate = linearScale([minPointerPos, maxPointerPos], scrollRange);
|
|
656
|
+
return interpolate(pointerPos);
|
|
700
657
|
}
|
|
701
|
-
function
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
maxScrollPos * -1,
|
|
712
|
-
0
|
|
713
|
-
];
|
|
714
|
-
const scrollWithoutMomentum = $fnFM9$clamp(scrollPos, scrollClampRange);
|
|
715
|
-
const interpolate = $57acba87d6e25586$var$linearScale([
|
|
716
|
-
0,
|
|
717
|
-
maxScrollPos
|
|
718
|
-
], [
|
|
719
|
-
0,
|
|
720
|
-
maxThumbPos
|
|
721
|
-
]);
|
|
722
|
-
return interpolate(scrollWithoutMomentum);
|
|
723
|
-
} // https://github.com/tmcw-up-for-adoption/simple-linear-scale/blob/master/index.js
|
|
724
|
-
function $57acba87d6e25586$var$linearScale(input, output) {
|
|
725
|
-
return (value)=>{
|
|
726
|
-
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
727
|
-
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
728
|
-
return output[0] + ratio * (value - input[0]);
|
|
729
|
-
};
|
|
658
|
+
function getThumbOffsetFromScroll(scrollPos, sizes, dir = "ltr") {
|
|
659
|
+
const thumbSizePx = getThumbSize(sizes);
|
|
660
|
+
const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
|
|
661
|
+
const scrollbar = sizes.scrollbar.size - scrollbarPadding;
|
|
662
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
663
|
+
const maxThumbPos = scrollbar - thumbSizePx;
|
|
664
|
+
const scrollClampRange = dir === "ltr" ? [0, maxScrollPos] : [maxScrollPos * -1, 0];
|
|
665
|
+
const scrollWithoutMomentum = clamp(scrollPos, scrollClampRange);
|
|
666
|
+
const interpolate = linearScale([0, maxScrollPos], [0, maxThumbPos]);
|
|
667
|
+
return interpolate(scrollWithoutMomentum);
|
|
730
668
|
}
|
|
731
|
-
function
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
669
|
+
function linearScale(input, output) {
|
|
670
|
+
return (value) => {
|
|
671
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
672
|
+
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
673
|
+
return output[0] + ratio * (value - input[0]);
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) {
|
|
677
|
+
return scrollPos > 0 && scrollPos < maxScrollPos;
|
|
678
|
+
}
|
|
679
|
+
var addUnlinkedScrollListener = (node, handler = () => {
|
|
680
|
+
}) => {
|
|
681
|
+
let prevPosition = { left: node.scrollLeft, top: node.scrollTop };
|
|
682
|
+
let rAF = 0;
|
|
683
|
+
(function loop() {
|
|
684
|
+
const position = { left: node.scrollLeft, top: node.scrollTop };
|
|
685
|
+
const isHorizontalScroll = prevPosition.left !== position.left;
|
|
686
|
+
const isVerticalScroll = prevPosition.top !== position.top;
|
|
687
|
+
if (isHorizontalScroll || isVerticalScroll) handler();
|
|
688
|
+
prevPosition = position;
|
|
689
|
+
rAF = window.requestAnimationFrame(loop);
|
|
690
|
+
})();
|
|
691
|
+
return () => window.cancelAnimationFrame(rAF);
|
|
754
692
|
};
|
|
755
|
-
function
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
}, [
|
|
764
|
-
handleCallback,
|
|
765
|
-
delay
|
|
766
|
-
]);
|
|
693
|
+
function useDebounceCallback(callback, delay) {
|
|
694
|
+
const handleCallback = useCallbackRef(callback);
|
|
695
|
+
const debounceTimerRef = React2.useRef(0);
|
|
696
|
+
React2.useEffect(() => () => window.clearTimeout(debounceTimerRef.current), []);
|
|
697
|
+
return React2.useCallback(() => {
|
|
698
|
+
window.clearTimeout(debounceTimerRef.current);
|
|
699
|
+
debounceTimerRef.current = window.setTimeout(handleCallback, delay);
|
|
700
|
+
}, [handleCallback, delay]);
|
|
767
701
|
}
|
|
768
|
-
function
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
return ()=>{
|
|
785
|
-
window.cancelAnimationFrame(rAF);
|
|
786
|
-
resizeObserver.unobserve(element);
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
}, [
|
|
790
|
-
element,
|
|
791
|
-
handleResize
|
|
792
|
-
]);
|
|
702
|
+
function useResizeObserver(element, onResize) {
|
|
703
|
+
const handleResize = useCallbackRef(onResize);
|
|
704
|
+
useLayoutEffect(() => {
|
|
705
|
+
let rAF = 0;
|
|
706
|
+
if (element) {
|
|
707
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
708
|
+
cancelAnimationFrame(rAF);
|
|
709
|
+
rAF = window.requestAnimationFrame(handleResize);
|
|
710
|
+
});
|
|
711
|
+
resizeObserver.observe(element);
|
|
712
|
+
return () => {
|
|
713
|
+
window.cancelAnimationFrame(rAF);
|
|
714
|
+
resizeObserver.unobserve(element);
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
}, [element, handleResize]);
|
|
793
718
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
719
|
+
var Root = ScrollArea;
|
|
720
|
+
var Viewport = ScrollAreaViewport;
|
|
721
|
+
var Scrollbar = ScrollAreaScrollbar;
|
|
722
|
+
var Thumb = ScrollAreaThumb;
|
|
723
|
+
var Corner = ScrollAreaCorner;
|
|
724
|
+
export {
|
|
725
|
+
Corner,
|
|
726
|
+
Root,
|
|
727
|
+
ScrollArea,
|
|
728
|
+
ScrollAreaCorner,
|
|
729
|
+
ScrollAreaScrollbar,
|
|
730
|
+
ScrollAreaThumb,
|
|
731
|
+
ScrollAreaViewport,
|
|
732
|
+
Scrollbar,
|
|
733
|
+
Thumb,
|
|
734
|
+
Viewport,
|
|
735
|
+
createScrollAreaScope
|
|
736
|
+
};
|
|
804
737
|
//# sourceMappingURL=index.mjs.map
|