@rolder/kit 3.0.0-alpha.6 → 3.0.0-alpha.8
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/package.json +3 -3
- package/rslib.config.ts +21 -0
- package/src/ai/ui/conversation/ConversationContext.ts +21 -0
- package/src/ai/ui/conversation/ConversationProvider.tsx +21 -0
- package/src/ai/ui/conversation/Empty.tsx +15 -0
- package/src/ai/ui/conversation/File.tsx +40 -0
- package/src/ai/ui/conversation/FileIcon.tsx +143 -0
- package/src/ai/ui/conversation/Loader.tsx +8 -0
- package/src/ai/ui/conversation/Message.tsx +34 -0
- package/src/ai/ui/conversation/Root.tsx +24 -0
- package/src/ai/ui/conversation/index.ts +16 -0
- package/{dist/ai/ui/conversation/types.d.ts → src/ai/ui/conversation/types.ts} +5 -4
- package/src/ai/ui/conversation/useChatMessage.ts +13 -0
- package/src/ai/ui/promptInput/File.tsx +98 -0
- package/src/ai/ui/promptInput/FileIcon.tsx +149 -0
- package/src/ai/ui/promptInput/Footer.tsx +5 -0
- package/src/ai/ui/promptInput/PromptInputContext.ts +24 -0
- package/src/ai/ui/promptInput/PromptInputProvider.tsx +54 -0
- package/src/ai/ui/promptInput/Root.tsx +29 -0
- package/src/ai/ui/promptInput/Submit.tsx +39 -0
- package/src/ai/ui/promptInput/Textarea.tsx +39 -0
- package/src/ai/ui/promptInput/index.ts +15 -0
- package/src/ai/ui/promptInput/types.ts +9 -0
- package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +29 -0
- package/src/ai/utils/parseAiMessagePart.ts +19 -0
- package/src/app/AppDefaults.tsx +21 -0
- package/src/app/DefaultApp.tsx +50 -0
- package/src/app/cookieColorSchemeManager.ts +70 -0
- package/src/app/defaultRequestMiddlewares.ts +22 -0
- package/src/app/defaultTheme.ts +22 -0
- package/src/functions/getCookie.ts +36 -0
- package/src/functions/setCookie.ts +29 -0
- package/src/functions/setCookies.ts +24 -0
- package/src/hooks/useMutation.ts +14 -0
- package/src/hooks/useMutationWithInvalidate.ts +23 -0
- package/{dist/index.d.ts → src/index.ts} +45 -5
- package/{dist → src}/styles.css +21 -11
- package/src/surreal/connection.ts +72 -0
- package/src/surreal/deafaultCrud.ts +25 -0
- package/src/surreal/deserialize.ts +144 -0
- package/src/surreal/encryption.ts +51 -0
- package/src/ui/AnimatedChevron.tsx +32 -0
- package/src/ui/JsonInput.tsx +52 -0
- package/src/ui/RouterLink.tsx +78 -0
- package/src/ui/editor/Content.tsx +11 -0
- package/src/ui/editor/Provider.tsx +96 -0
- package/src/ui/editor/Root.tsx +25 -0
- package/src/ui/editor/Toolbar.tsx +92 -0
- package/src/ui/editor/index.ts +13 -0
- package/src/ui/editor/types.ts +7 -0
- package/src/ui/error/DefaultError.tsx +60 -0
- package/src/ui/error/DefaultNotFound.tsx +19 -0
- package/src/ui/error/Forbidden.tsx +18 -0
- package/src/ui/error/defaultErrorNotification.ts +9 -0
- package/src/ui/form/blurOnError.ts +21 -0
- package/src/ui/form/buttons/CancelButton.tsx +42 -0
- package/src/ui/form/buttons/SubmitButton.tsx +43 -0
- package/src/ui/form/buttons/SubscribeActionIcon.tsx +18 -0
- package/src/ui/form/buttons/SubscribeButton.tsx +17 -0
- package/src/ui/form/context.ts +45 -0
- package/src/ui/form/fields/JsonField.tsx +16 -0
- package/src/ui/form/fields/MultiSelectField.tsx +17 -0
- package/src/ui/form/fields/NumberField.tsx +17 -0
- package/src/ui/form/fields/PassowrdField.tsx +20 -0
- package/src/ui/form/fields/SelectField.tsx +17 -0
- package/src/ui/form/fields/SwitchField.tsx +17 -0
- package/src/ui/form/fields/TextField.tsx +17 -0
- package/src/ui/form/fields/TextPassowrdField.tsx +51 -0
- package/src/ui/form/fields/TextareaField.tsx +17 -0
- package/src/ui/form/fieldsSchema.ts +24 -0
- package/src/ui/hoverPaper/HoverPaper.tsx +17 -0
- package/src/ui/hoverPaper/usePaperHover.ts +9 -0
- package/src/ui/saveInput/JsonInput.tsx +40 -0
- package/src/ui/saveInput/NumberInput.tsx +40 -0
- package/src/ui/saveInput/SaveInput.tsx +15 -0
- package/src/ui/saveInput/Select.tsx +41 -0
- package/src/ui/saveInput/Switch.tsx +46 -0
- package/src/ui/saveInput/TextInput.tsx +40 -0
- package/src/ui/saveInput/Textarea.tsx +40 -0
- package/src/ui/scrollArea/ARCH.md +204 -0
- package/src/ui/scrollArea/README.md +369 -0
- package/{dist/ui/scrollArea/ScrollArea.d.ts → src/ui/scrollArea/ScrollArea.tsx} +41 -10
- package/src/ui/scrollArea/ScrollAreaButton.tsx +56 -0
- package/src/ui/scrollArea/ScrollAreaContent.tsx +36 -0
- package/{dist/ui/scrollArea/context.d.ts → src/ui/scrollArea/context.tsx} +18 -3
- package/src/ui/scrollArea/index.ts +10 -0
- package/src/ui/scrollArea/types.ts +77 -0
- package/src/ui/scrollArea/useScrollArea.ts +227 -0
- package/tsconfig.json +14 -0
- package/dist/ai/ui/conversation/ConversationContext.d.ts +0 -7
- package/dist/ai/ui/conversation/ConversationContext.js +0 -8
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +0 -2
- package/dist/ai/ui/conversation/ConversationProvider.js +0 -14
- package/dist/ai/ui/conversation/Empty.d.ts +0 -1
- package/dist/ai/ui/conversation/Empty.js +0 -21
- package/dist/ai/ui/conversation/File.d.ts +0 -4
- package/dist/ai/ui/conversation/File.js +0 -42
- package/dist/ai/ui/conversation/FileIcon.d.ts +0 -3
- package/dist/ai/ui/conversation/FileIcon.js +0 -225
- package/dist/ai/ui/conversation/Loader.d.ts +0 -2
- package/dist/ai/ui/conversation/Loader.js +0 -12
- package/dist/ai/ui/conversation/Message.d.ts +0 -4
- package/dist/ai/ui/conversation/Message.js +0 -25
- package/dist/ai/ui/conversation/Root.d.ts +0 -2
- package/dist/ai/ui/conversation/Root.js +0 -26
- package/dist/ai/ui/conversation/index.d.ts +0 -13
- package/dist/ai/ui/conversation/index.js +0 -14
- package/dist/ai/ui/conversation/types.js +0 -0
- package/dist/ai/ui/conversation/useChatMessage.d.ts +0 -2
- package/dist/ai/ui/conversation/useChatMessage.js +0 -12
- package/dist/ai/ui/promptInput/File.d.ts +0 -2
- package/dist/ai/ui/promptInput/File.js +0 -117
- package/dist/ai/ui/promptInput/FileIcon.d.ts +0 -3
- package/dist/ai/ui/promptInput/FileIcon.js +0 -225
- package/dist/ai/ui/promptInput/Footer.d.ts +0 -2
- package/dist/ai/ui/promptInput/Footer.js +0 -8
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +0 -12
- package/dist/ai/ui/promptInput/PromptInputContext.js +0 -8
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +0 -2
- package/dist/ai/ui/promptInput/PromptInputProvider.js +0 -50
- package/dist/ai/ui/promptInput/Root.d.ts +0 -3
- package/dist/ai/ui/promptInput/Root.js +0 -17
- package/dist/ai/ui/promptInput/Submit.d.ts +0 -2
- package/dist/ai/ui/promptInput/Submit.js +0 -40
- package/dist/ai/ui/promptInput/Textarea.d.ts +0 -2
- package/dist/ai/ui/promptInput/Textarea.js +0 -33
- package/dist/ai/ui/promptInput/index.d.ts +0 -8
- package/dist/ai/ui/promptInput/index.js +0 -13
- package/dist/ai/ui/promptInput/types.d.ts +0 -11
- package/dist/ai/ui/promptInput/types.js +0 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +0 -5
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +0 -21
- package/dist/ai/utils/parseAiMessagePart.d.ts +0 -2
- package/dist/ai/utils/parseAiMessagePart.js +0 -12
- package/dist/app/AppDefaults.d.ts +0 -3
- package/dist/app/AppDefaults.js +0 -27
- package/dist/app/DefaultApp.d.ts +0 -6
- package/dist/app/DefaultApp.js +0 -43
- package/dist/app/cookieColorSchemeManager.d.ts +0 -6
- package/dist/app/cookieColorSchemeManager.js +0 -46
- package/dist/app/defaultRequestMiddlewares.d.ts +0 -4
- package/dist/app/defaultRequestMiddlewares.js +0 -24
- package/dist/app/defaultTheme.d.ts +0 -141
- package/dist/app/defaultTheme.js +0 -24
- package/dist/functions/getCookie.d.ts +0 -3
- package/dist/functions/getCookie.js +0 -8
- package/dist/functions/setCookie.d.ts +0 -10
- package/dist/functions/setCookie.js +0 -19
- package/dist/functions/setCookies.d.ts +0 -14
- package/dist/functions/setCookies.js +0 -13
- package/dist/hooks/useMutation.d.ts +0 -4
- package/dist/hooks/useMutation.js +0 -8
- package/dist/hooks/useMutationWithInvalidate.d.ts +0 -4
- package/dist/hooks/useMutationWithInvalidate.js +0 -16
- package/dist/index.js +0 -26
- package/dist/surreal/connection.d.ts +0 -9
- package/dist/surreal/connection.js +0 -49
- package/dist/surreal/deafaultCrud.d.ts +0 -2
- package/dist/surreal/deafaultCrud.js +0 -18
- package/dist/surreal/deserialize.d.ts +0 -17
- package/dist/surreal/deserialize.js +0 -46
- package/dist/surreal/encryption.d.ts +0 -6
- package/dist/surreal/encryption.js +0 -30
- package/dist/ui/AnimatedChevron.d.ts +0 -6
- package/dist/ui/AnimatedChevron.js +0 -31
- package/dist/ui/JsonInput.d.ts +0 -2
- package/dist/ui/JsonInput.js +0 -45
- package/dist/ui/RouterLink.d.ts +0 -16
- package/dist/ui/RouterLink.js +0 -36
- package/dist/ui/editor/Content.d.ts +0 -3
- package/dist/ui/editor/Content.js +0 -13
- package/dist/ui/editor/Provider.d.ts +0 -17
- package/dist/ui/editor/Provider.js +0 -80
- package/dist/ui/editor/Root.d.ts +0 -2
- package/dist/ui/editor/Root.js +0 -18
- package/dist/ui/editor/Toolbar.d.ts +0 -5
- package/dist/ui/editor/Toolbar.js +0 -156
- package/dist/ui/editor/index.d.ts +0 -12
- package/dist/ui/editor/index.js +0 -11
- package/dist/ui/editor/types.d.ts +0 -7
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.d.ts +0 -2
- package/dist/ui/error/DefaultError.js +0 -62
- package/dist/ui/error/DefaultNotFound.d.ts +0 -1
- package/dist/ui/error/DefaultNotFound.js +0 -37
- package/dist/ui/error/Forbidden.d.ts +0 -1
- package/dist/ui/error/Forbidden.js +0 -32
- package/dist/ui/error/defaultErrorNotification.d.ts +0 -1
- package/dist/ui/error/defaultErrorNotification.js +0 -8
- package/dist/ui/error/index.js +0 -5
- package/dist/ui/form/blurOnError.d.ts +0 -4
- package/dist/ui/form/blurOnError.js +0 -11
- package/dist/ui/form/buttons/CancelButton.d.ts +0 -5
- package/dist/ui/form/buttons/CancelButton.js +0 -44
- package/dist/ui/form/buttons/SubmitButton.d.ts +0 -5
- package/dist/ui/form/buttons/SubmitButton.js +0 -47
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +0 -4
- package/dist/ui/form/buttons/SubscribeActionIcon.js +0 -15
- package/dist/ui/form/buttons/SubscribeButton.d.ts +0 -5
- package/dist/ui/form/buttons/SubscribeButton.js +0 -16
- package/dist/ui/form/buttons/index.js +0 -4
- package/dist/ui/form/context.d.ts +0 -83
- package/dist/ui/form/context.js +0 -26
- package/dist/ui/form/fields/JsonField.d.ts +0 -2
- package/dist/ui/form/fields/JsonField.js +0 -13
- package/dist/ui/form/fields/MultiSelectField.d.ts +0 -2
- package/dist/ui/form/fields/MultiSelectField.js +0 -15
- package/dist/ui/form/fields/NumberField.d.ts +0 -2
- package/dist/ui/form/fields/NumberField.js +0 -15
- package/dist/ui/form/fields/PassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/PassowrdField.js +0 -18
- package/dist/ui/form/fields/SelectField.d.ts +0 -2
- package/dist/ui/form/fields/SelectField.js +0 -15
- package/dist/ui/form/fields/SwitchField.d.ts +0 -2
- package/dist/ui/form/fields/SwitchField.js +0 -15
- package/dist/ui/form/fields/TextField.d.ts +0 -2
- package/dist/ui/form/fields/TextField.js +0 -15
- package/dist/ui/form/fields/TextPassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/TextPassowrdField.js +0 -51
- package/dist/ui/form/fields/TextareaField.d.ts +0 -2
- package/dist/ui/form/fields/TextareaField.js +0 -15
- package/dist/ui/form/fields/index.js +0 -9
- package/dist/ui/form/fieldsSchema.d.ts +0 -12
- package/dist/ui/form/fieldsSchema.js +0 -13
- package/dist/ui/form/index.js +0 -4
- package/dist/ui/hoverPaper/HoverPaper.d.ts +0 -6
- package/dist/ui/hoverPaper/HoverPaper.js +0 -15
- package/dist/ui/hoverPaper/index.js +0 -3
- package/dist/ui/hoverPaper/usePaperHover.d.ts +0 -4
- package/dist/ui/hoverPaper/usePaperHover.js +0 -9
- package/dist/ui/saveInput/JsonInput.d.ts +0 -6
- package/dist/ui/saveInput/JsonInput.js +0 -34
- package/dist/ui/saveInput/NumberInput.d.ts +0 -6
- package/dist/ui/saveInput/NumberInput.js +0 -27
- package/dist/ui/saveInput/SaveInput.d.ts +0 -36
- package/dist/ui/saveInput/SaveInput.js +0 -15
- package/dist/ui/saveInput/Select.d.ts +0 -6
- package/dist/ui/saveInput/Select.js +0 -27
- package/dist/ui/saveInput/Switch.d.ts +0 -6
- package/dist/ui/saveInput/Switch.js +0 -30
- package/dist/ui/saveInput/TextInput.d.ts +0 -6
- package/dist/ui/saveInput/TextInput.js +0 -26
- package/dist/ui/saveInput/Textarea.d.ts +0 -6
- package/dist/ui/saveInput/Textarea.js +0 -26
- package/dist/ui/saveInput/index.js +0 -2
- package/dist/ui/scrollArea/ScrollArea.js +0 -30
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +0 -5
- package/dist/ui/scrollArea/ScrollAreaButton.js +0 -51
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +0 -6
- package/dist/ui/scrollArea/ScrollAreaContent.js +0 -29
- package/dist/ui/scrollArea/context.js +0 -10
- package/dist/ui/scrollArea/index.d.ts +0 -3
- package/dist/ui/scrollArea/index.js +0 -3
- package/dist/ui/scrollArea/types.d.ts +0 -65
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +0 -9
- package/dist/ui/scrollArea/useScrollArea.js +0 -146
- /package/{dist/ui/error/index.d.ts → src/ui/error/index.ts} +0 -0
- /package/{dist/ui/form/buttons/index.d.ts → src/ui/form/buttons/index.ts} +0 -0
- /package/{dist/ui/form/fields/index.d.ts → src/ui/form/fields/index.ts} +0 -0
- /package/{dist/ui/form/index.d.ts → src/ui/form/index.ts} +0 -0
- /package/{dist/ui/hoverPaper/index.d.ts → src/ui/hoverPaper/index.ts} +0 -0
- /package/{dist/ui/saveInput/index.d.ts → src/ui/saveInput/index.ts} +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { useDebouncedCallback, useMergedRef, useResizeObserver } from "@mantine/hooks";
|
|
2
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
-
const useScrollAreaState = (options = {})=>{
|
|
4
|
-
const { autoScroll = false, scrollToBottomOnInit = false, animated = true, nearThreshold = 32 } = options;
|
|
5
|
-
const scrollAreaRef = useRef(null);
|
|
6
|
-
const isUserInteractingRef = useRef(false);
|
|
7
|
-
const userInteractionTimeoutRef = useRef(void 0);
|
|
8
|
-
const isInitializedRef = useRef(false);
|
|
9
|
-
const [contentResizeRef, contentRect] = useResizeObserver();
|
|
10
|
-
const [scrollPosition, setScrollPosition] = useState({
|
|
11
|
-
scrollTop: 0,
|
|
12
|
-
clientHeight: 0,
|
|
13
|
-
scrollHeight: 0
|
|
14
|
-
});
|
|
15
|
-
const isAtTop = 0 === scrollPosition.scrollTop;
|
|
16
|
-
const isAtBottom = scrollPosition.scrollTop + scrollPosition.clientHeight >= scrollPosition.scrollHeight;
|
|
17
|
-
const isNearTop = scrollPosition.scrollTop <= nearThreshold;
|
|
18
|
-
const isNearBottom = scrollPosition.scrollTop + scrollPosition.clientHeight >= scrollPosition.scrollHeight - nearThreshold;
|
|
19
|
-
const isAboveCenter = scrollPosition.scrollTop < (scrollPosition.scrollHeight - scrollPosition.clientHeight) / 2;
|
|
20
|
-
const hasScrollableContent = scrollPosition.scrollHeight > scrollPosition.clientHeight;
|
|
21
|
-
const debouncedUpdatePosition = useDebouncedCallback((element)=>{
|
|
22
|
-
const newPosition = {
|
|
23
|
-
scrollTop: element.scrollTop,
|
|
24
|
-
clientHeight: element.clientHeight,
|
|
25
|
-
scrollHeight: element.scrollHeight
|
|
26
|
-
};
|
|
27
|
-
setScrollPosition(newPosition);
|
|
28
|
-
}, {
|
|
29
|
-
delay: 16
|
|
30
|
-
});
|
|
31
|
-
const scrollToTop = useCallback((isAnimated)=>{
|
|
32
|
-
const element = scrollAreaRef.current;
|
|
33
|
-
if (!element) return;
|
|
34
|
-
const shouldAnimate = isAnimated ?? animated;
|
|
35
|
-
if (shouldAnimate) element.scrollTo({
|
|
36
|
-
top: 0,
|
|
37
|
-
behavior: 'smooth'
|
|
38
|
-
});
|
|
39
|
-
else element.scrollTop = 0;
|
|
40
|
-
}, [
|
|
41
|
-
animated
|
|
42
|
-
]);
|
|
43
|
-
const scrollToBottom = useCallback((isAnimated)=>{
|
|
44
|
-
const element = scrollAreaRef.current;
|
|
45
|
-
if (!element) return;
|
|
46
|
-
const shouldAnimate = isAnimated ?? animated;
|
|
47
|
-
if (shouldAnimate) element.scrollTo({
|
|
48
|
-
top: element.scrollHeight,
|
|
49
|
-
behavior: 'smooth'
|
|
50
|
-
});
|
|
51
|
-
else element.scrollTop = element.scrollHeight;
|
|
52
|
-
const scrollHeightBefore = element.scrollHeight;
|
|
53
|
-
setTimeout(()=>{
|
|
54
|
-
const scrollHeightAfter = element.scrollHeight;
|
|
55
|
-
const diff = element.scrollHeight - (element.scrollTop + element.clientHeight);
|
|
56
|
-
if (diff > 1 && scrollHeightAfter !== scrollHeightBefore) element.scrollTop = element.scrollHeight;
|
|
57
|
-
}, 50);
|
|
58
|
-
}, [
|
|
59
|
-
animated
|
|
60
|
-
]);
|
|
61
|
-
const performAutoScroll = useCallback(()=>{
|
|
62
|
-
if (!autoScroll || isUserInteractingRef.current || !scrollAreaRef.current) return;
|
|
63
|
-
if (isAtBottom) scrollToBottom(false);
|
|
64
|
-
}, [
|
|
65
|
-
autoScroll,
|
|
66
|
-
isAtBottom,
|
|
67
|
-
scrollToBottom
|
|
68
|
-
]);
|
|
69
|
-
const handleUserInteraction = useCallback(()=>{
|
|
70
|
-
isUserInteractingRef.current = true;
|
|
71
|
-
if (userInteractionTimeoutRef.current) clearTimeout(userInteractionTimeoutRef.current);
|
|
72
|
-
userInteractionTimeoutRef.current = setTimeout(()=>{
|
|
73
|
-
isUserInteractingRef.current = false;
|
|
74
|
-
}, 150);
|
|
75
|
-
}, []);
|
|
76
|
-
const handleScroll = useCallback((event)=>{
|
|
77
|
-
const element = event.target;
|
|
78
|
-
debouncedUpdatePosition(element);
|
|
79
|
-
}, [
|
|
80
|
-
debouncedUpdatePosition
|
|
81
|
-
]);
|
|
82
|
-
useEffect(()=>{
|
|
83
|
-
if (!scrollToBottomOnInit || isInitializedRef.current) return;
|
|
84
|
-
if (hasScrollableContent) {
|
|
85
|
-
scrollToBottom(animated);
|
|
86
|
-
isInitializedRef.current = true;
|
|
87
|
-
}
|
|
88
|
-
}, [
|
|
89
|
-
scrollToBottomOnInit,
|
|
90
|
-
hasScrollableContent,
|
|
91
|
-
scrollToBottom,
|
|
92
|
-
animated
|
|
93
|
-
]);
|
|
94
|
-
useEffect(()=>{
|
|
95
|
-
const element = scrollAreaRef.current;
|
|
96
|
-
if (!element || 0 === contentRect.height) return;
|
|
97
|
-
debouncedUpdatePosition(element);
|
|
98
|
-
const timeoutId = setTimeout(performAutoScroll, 10);
|
|
99
|
-
return ()=>clearTimeout(timeoutId);
|
|
100
|
-
}, [
|
|
101
|
-
contentRect.height,
|
|
102
|
-
debouncedUpdatePosition,
|
|
103
|
-
performAutoScroll
|
|
104
|
-
]);
|
|
105
|
-
useEffect(()=>{
|
|
106
|
-
const element = scrollAreaRef.current;
|
|
107
|
-
if (!element) return;
|
|
108
|
-
const events = [
|
|
109
|
-
'wheel',
|
|
110
|
-
'touchstart',
|
|
111
|
-
'touchmove',
|
|
112
|
-
'mousedown'
|
|
113
|
-
];
|
|
114
|
-
element.addEventListener('scroll', handleScroll);
|
|
115
|
-
events.forEach((event)=>{
|
|
116
|
-
element.addEventListener(event, handleUserInteraction);
|
|
117
|
-
});
|
|
118
|
-
debouncedUpdatePosition(element);
|
|
119
|
-
return ()=>{
|
|
120
|
-
element.removeEventListener('scroll', handleScroll);
|
|
121
|
-
events.forEach((event)=>{
|
|
122
|
-
element.removeEventListener(event, handleUserInteraction);
|
|
123
|
-
});
|
|
124
|
-
if (userInteractionTimeoutRef.current) clearTimeout(userInteractionTimeoutRef.current);
|
|
125
|
-
};
|
|
126
|
-
}, [
|
|
127
|
-
handleScroll,
|
|
128
|
-
handleUserInteraction,
|
|
129
|
-
debouncedUpdatePosition
|
|
130
|
-
]);
|
|
131
|
-
const callbackRef = useMergedRef(scrollAreaRef);
|
|
132
|
-
return {
|
|
133
|
-
isAtTop,
|
|
134
|
-
isNearTop,
|
|
135
|
-
isAtBottom,
|
|
136
|
-
isNearBottom,
|
|
137
|
-
isAboveCenter,
|
|
138
|
-
hasScrollableContent,
|
|
139
|
-
scrollToTop,
|
|
140
|
-
scrollToBottom,
|
|
141
|
-
viewportRef: scrollAreaRef,
|
|
142
|
-
_callbackRef: callbackRef,
|
|
143
|
-
_contentResizeRef: contentResizeRef
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
export { useScrollAreaState };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|