@rolder/kit 3.0.0-alpha.8 → 3.0.0-alpha.80

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 (297) hide show
  1. package/dist/ai/index.d.ts +2 -0
  2. package/dist/ai/index.js +2 -0
  3. package/dist/ai/ui/chat/Empty.d.ts +1 -0
  4. package/dist/ai/ui/chat/Empty.js +21 -0
  5. package/dist/ai/ui/chat/File.d.ts +3 -0
  6. package/dist/ai/ui/chat/File.js +43 -0
  7. package/dist/ai/ui/chat/FileIcon.d.ts +3 -0
  8. package/dist/ai/ui/chat/FileIcon.js +43 -0
  9. package/dist/ai/ui/chat/Loader.d.ts +2 -0
  10. package/dist/ai/ui/chat/Loader.js +13 -0
  11. package/dist/ai/ui/chat/Message.d.ts +3 -0
  12. package/dist/ai/ui/chat/Message.js +23 -0
  13. package/dist/ai/ui/chat/Messages.d.ts +2 -0
  14. package/dist/ai/ui/chat/Messages.js +27 -0
  15. package/dist/ai/ui/chat/Root.d.ts +49 -0
  16. package/dist/ai/ui/chat/Root.js +18 -0
  17. package/dist/ai/ui/chat/chatInput/File.d.ts +2 -0
  18. package/dist/ai/ui/chat/chatInput/File.js +71 -0
  19. package/dist/ai/ui/chat/chatInput/FileIcon.d.ts +3 -0
  20. package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
  21. package/dist/ai/ui/chat/chatInput/Footer.d.ts +2 -0
  22. package/dist/ai/ui/chat/chatInput/Footer.js +8 -0
  23. package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
  24. package/dist/ai/ui/chat/chatInput/Root.js +24 -0
  25. package/dist/ai/ui/chat/chatInput/Submit.d.ts +2 -0
  26. package/dist/ai/ui/chat/chatInput/Submit.js +23 -0
  27. package/dist/ai/ui/chat/chatInput/Textarea.d.ts +2 -0
  28. package/dist/ai/ui/chat/chatInput/Textarea.js +34 -0
  29. package/dist/ai/ui/chat/chatInput/index.d.ts +7 -0
  30. package/dist/ai/ui/chat/chatInput/index.js +13 -0
  31. package/dist/ai/ui/chat/chatInput/store/file.d.ts +8 -0
  32. package/dist/ai/ui/chat/chatInput/store/file.js +32 -0
  33. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.d.ts +2 -0
  34. package/dist/ai/ui/chat/chatInput/store/fileErrorNotificaton.js +21 -0
  35. package/dist/ai/ui/chat/chatInput/store/index.d.ts +2 -0
  36. package/dist/ai/ui/chat/chatInput/store/index.js +2 -0
  37. package/dist/ai/ui/chat/chatInput/store/input.d.ts +13 -0
  38. package/dist/ai/ui/chat/chatInput/store/input.js +81 -0
  39. package/dist/ai/ui/chat/chatInput/store/parseFile.d.ts +2 -0
  40. package/dist/ai/ui/chat/chatInput/store/parseFile.js +23 -0
  41. package/dist/ai/ui/chat/index.d.ts +13 -0
  42. package/dist/ai/ui/chat/index.js +15 -0
  43. package/dist/ai/ui/chat/store/index.d.ts +5 -0
  44. package/dist/ai/ui/chat/store/index.js +5 -0
  45. package/dist/ai/ui/chat/store/messageIds.d.ts +8 -0
  46. package/dist/ai/ui/chat/store/messageIds.js +41 -0
  47. package/dist/ai/ui/chat/store/messagesMap.d.ts +5 -0
  48. package/dist/ai/ui/chat/store/messagesMap.js +15 -0
  49. package/dist/ai/ui/chat/store/send.d.ts +14 -0
  50. package/dist/ai/ui/chat/store/send.js +16 -0
  51. package/dist/ai/ui/chat/store/states.d.ts +11 -0
  52. package/dist/ai/ui/chat/store/states.js +17 -0
  53. package/dist/ai/ui/chat/store/useInitChat.d.ts +3 -0
  54. package/dist/ai/ui/chat/store/useInitChat.js +40 -0
  55. package/dist/ai/ui/index.d.ts +1 -0
  56. package/dist/ai/ui/index.js +1 -0
  57. package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
  58. package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
  59. package/dist/ai/utils/index.d.ts +2 -0
  60. package/dist/ai/utils/index.js +2 -0
  61. package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
  62. package/dist/ai/utils/parseAiMessagePart.js +12 -0
  63. package/dist/app/AppDefaults.d.ts +3 -0
  64. package/dist/app/AppDefaults.js +27 -0
  65. package/dist/app/DefaultApp.d.ts +6 -0
  66. package/dist/app/DefaultApp.js +43 -0
  67. package/dist/app/cookieColorSchemeManager.d.ts +6 -0
  68. package/dist/app/cookieColorSchemeManager.js +46 -0
  69. package/dist/app/defaultRequestMiddlewares.d.ts +4 -0
  70. package/dist/app/defaultRequestMiddlewares.js +24 -0
  71. package/dist/app/defaultTheme.d.ts +141 -0
  72. package/dist/app/defaultTheme.js +24 -0
  73. package/dist/app/index.d.ts +4 -0
  74. package/dist/app/index.js +4 -0
  75. package/dist/hooks/index.d.ts +2 -0
  76. package/dist/hooks/index.js +2 -0
  77. package/dist/hooks/useMutation.d.ts +4 -0
  78. package/dist/hooks/useMutation.js +8 -0
  79. package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
  80. package/dist/hooks/useMutationWithInvalidate.js +16 -0
  81. package/dist/index.d.ts +5 -0
  82. package/dist/index.js +5 -0
  83. package/{src → dist}/styles.css +14 -29
  84. package/dist/tanstackFunctions/cookie/getCookie.d.ts +3 -0
  85. package/dist/tanstackFunctions/cookie/getCookie.js +8 -0
  86. package/dist/tanstackFunctions/cookie/index.d.ts +3 -0
  87. package/dist/tanstackFunctions/cookie/index.js +4 -0
  88. package/dist/tanstackFunctions/cookie/setCookie.d.ts +10 -0
  89. package/dist/tanstackFunctions/cookie/setCookie.js +19 -0
  90. package/dist/tanstackFunctions/cookie/setCookies.d.ts +14 -0
  91. package/dist/tanstackFunctions/cookie/setCookies.js +13 -0
  92. package/dist/tanstackFunctions/index.d.ts +3 -0
  93. package/dist/tanstackFunctions/index.js +3 -0
  94. package/dist/tanstackFunctions/s3/getS3Client.d.ts +2 -0
  95. package/dist/tanstackFunctions/s3/getS3Client.js +18 -0
  96. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.d.ts +4 -0
  97. package/dist/tanstackFunctions/s3/getSignedFileUrlFn.js +21 -0
  98. package/dist/tanstackFunctions/s3/index.d.ts +2 -0
  99. package/dist/tanstackFunctions/s3/index.js +2 -0
  100. package/dist/tanstackFunctions/s3/uploadRequest.d.ts +3 -0
  101. package/dist/tanstackFunctions/s3/uploadRequest.js +21 -0
  102. package/dist/tanstackFunctions/surreal/connection.d.ts +9 -0
  103. package/dist/tanstackFunctions/surreal/connection.js +49 -0
  104. package/dist/tanstackFunctions/surreal/deafaultCrud.d.ts +2 -0
  105. package/dist/tanstackFunctions/surreal/deafaultCrud.js +18 -0
  106. package/dist/tanstackFunctions/surreal/deserialize.d.ts +17 -0
  107. package/dist/tanstackFunctions/surreal/deserialize.js +46 -0
  108. package/dist/tanstackFunctions/surreal/encryption.d.ts +6 -0
  109. package/dist/tanstackFunctions/surreal/encryption.js +30 -0
  110. package/dist/tanstackFunctions/surreal/index.d.ts +4 -0
  111. package/dist/tanstackFunctions/surreal/index.js +4 -0
  112. package/dist/ui/AnimatedChevron.d.ts +6 -0
  113. package/dist/ui/AnimatedChevron.js +13 -0
  114. package/dist/ui/JsonInput.d.ts +2 -0
  115. package/dist/ui/JsonInput.js +45 -0
  116. package/dist/ui/RouterLink.d.ts +16 -0
  117. package/dist/ui/RouterLink.js +36 -0
  118. package/dist/ui/editor/Content.d.ts +3 -0
  119. package/dist/ui/editor/Content.js +13 -0
  120. package/dist/ui/editor/Root.d.ts +8 -0
  121. package/dist/ui/editor/Root.js +55 -0
  122. package/dist/ui/editor/Toolbar.d.ts +5 -0
  123. package/dist/ui/editor/Toolbar.js +138 -0
  124. package/dist/ui/editor/index.d.ts +11 -0
  125. package/dist/ui/editor/index.js +10 -0
  126. package/dist/ui/editor/store.d.ts +6 -0
  127. package/dist/ui/editor/store.js +10 -0
  128. package/dist/ui/error/DefaultError.d.ts +2 -0
  129. package/dist/ui/error/DefaultError.js +62 -0
  130. package/dist/ui/error/DefaultNotFound.d.ts +1 -0
  131. package/dist/ui/error/DefaultNotFound.js +37 -0
  132. package/dist/ui/error/Forbidden.d.ts +1 -0
  133. package/dist/ui/error/Forbidden.js +32 -0
  134. package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
  135. package/dist/ui/error/defaultErrorNotification.js +8 -0
  136. package/dist/ui/error/index.js +5 -0
  137. package/dist/ui/form/blurOnError.d.ts +4 -0
  138. package/dist/ui/form/blurOnError.js +11 -0
  139. package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
  140. package/dist/ui/form/buttons/CancelButton.js +22 -0
  141. package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
  142. package/dist/ui/form/buttons/SubmitButton.js +22 -0
  143. package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
  144. package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
  145. package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
  146. package/dist/ui/form/buttons/SubscribeButton.js +16 -0
  147. package/dist/ui/form/buttons/index.js +4 -0
  148. package/dist/ui/form/context.d.ts +83 -0
  149. package/dist/ui/form/context.js +26 -0
  150. package/dist/ui/form/fields/JsonField.d.ts +2 -0
  151. package/dist/ui/form/fields/JsonField.js +13 -0
  152. package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
  153. package/dist/ui/form/fields/MultiSelectField.js +15 -0
  154. package/dist/ui/form/fields/NumberField.d.ts +2 -0
  155. package/dist/ui/form/fields/NumberField.js +15 -0
  156. package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
  157. package/dist/ui/form/fields/PassowrdField.js +18 -0
  158. package/dist/ui/form/fields/SelectField.d.ts +2 -0
  159. package/dist/ui/form/fields/SelectField.js +15 -0
  160. package/dist/ui/form/fields/SwitchField.d.ts +2 -0
  161. package/dist/ui/form/fields/SwitchField.js +15 -0
  162. package/dist/ui/form/fields/TextField.d.ts +2 -0
  163. package/dist/ui/form/fields/TextField.js +15 -0
  164. package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
  165. package/dist/ui/form/fields/TextPassowrdField.js +29 -0
  166. package/dist/ui/form/fields/TextareaField.d.ts +2 -0
  167. package/dist/ui/form/fields/TextareaField.js +15 -0
  168. package/dist/ui/form/fields/index.js +9 -0
  169. package/dist/ui/form/fieldsSchema.d.ts +12 -0
  170. package/dist/ui/form/fieldsSchema.js +13 -0
  171. package/dist/ui/form/index.js +4 -0
  172. package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
  173. package/dist/ui/hoverPaper/HoverPaper.js +15 -0
  174. package/dist/ui/hoverPaper/index.js +3 -0
  175. package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
  176. package/dist/ui/hoverPaper/usePaperHover.js +9 -0
  177. package/dist/ui/index.d.ts +9 -0
  178. package/dist/ui/index.js +9 -0
  179. package/dist/ui/saveInput/JsonInput.d.ts +6 -0
  180. package/dist/ui/saveInput/JsonInput.js +34 -0
  181. package/dist/ui/saveInput/NumberInput.d.ts +6 -0
  182. package/dist/ui/saveInput/NumberInput.js +27 -0
  183. package/dist/ui/saveInput/SaveInput.d.ts +36 -0
  184. package/dist/ui/saveInput/SaveInput.js +15 -0
  185. package/dist/ui/saveInput/Select.d.ts +6 -0
  186. package/dist/ui/saveInput/Select.js +27 -0
  187. package/dist/ui/saveInput/Switch.d.ts +6 -0
  188. package/dist/ui/saveInput/Switch.js +30 -0
  189. package/dist/ui/saveInput/TextInput.d.ts +6 -0
  190. package/dist/ui/saveInput/TextInput.js +26 -0
  191. package/dist/ui/saveInput/Textarea.d.ts +6 -0
  192. package/dist/ui/saveInput/Textarea.js +26 -0
  193. package/dist/ui/saveInput/index.js +2 -0
  194. package/dist/ui/scrollArea/Root.d.ts +7 -0
  195. package/dist/ui/scrollArea/Root.js +42 -0
  196. package/dist/ui/scrollArea/ScrollButton.d.ts +10 -0
  197. package/dist/ui/scrollArea/ScrollButton.js +30 -0
  198. package/dist/ui/scrollArea/index.d.ts +6 -0
  199. package/dist/ui/scrollArea/index.js +7 -0
  200. package/dist/ui/scrollArea/methods.d.ts +4 -0
  201. package/dist/ui/scrollArea/methods.js +32 -0
  202. package/dist/ui/scrollArea/store.d.ts +12 -0
  203. package/dist/ui/scrollArea/store.js +25 -0
  204. package/package.json +40 -28
  205. package/rslib.config.ts +0 -21
  206. package/src/ai/ui/conversation/ConversationContext.ts +0 -21
  207. package/src/ai/ui/conversation/ConversationProvider.tsx +0 -21
  208. package/src/ai/ui/conversation/Empty.tsx +0 -15
  209. package/src/ai/ui/conversation/File.tsx +0 -40
  210. package/src/ai/ui/conversation/FileIcon.tsx +0 -143
  211. package/src/ai/ui/conversation/Loader.tsx +0 -8
  212. package/src/ai/ui/conversation/Message.tsx +0 -34
  213. package/src/ai/ui/conversation/Root.tsx +0 -24
  214. package/src/ai/ui/conversation/index.ts +0 -16
  215. package/src/ai/ui/conversation/types.ts +0 -8
  216. package/src/ai/ui/conversation/useChatMessage.ts +0 -13
  217. package/src/ai/ui/promptInput/File.tsx +0 -98
  218. package/src/ai/ui/promptInput/FileIcon.tsx +0 -149
  219. package/src/ai/ui/promptInput/Footer.tsx +0 -5
  220. package/src/ai/ui/promptInput/PromptInputContext.ts +0 -24
  221. package/src/ai/ui/promptInput/PromptInputProvider.tsx +0 -54
  222. package/src/ai/ui/promptInput/Root.tsx +0 -29
  223. package/src/ai/ui/promptInput/Submit.tsx +0 -39
  224. package/src/ai/ui/promptInput/Textarea.tsx +0 -39
  225. package/src/ai/ui/promptInput/index.ts +0 -15
  226. package/src/ai/ui/promptInput/types.ts +0 -9
  227. package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +0 -29
  228. package/src/ai/utils/parseAiMessagePart.ts +0 -19
  229. package/src/app/AppDefaults.tsx +0 -21
  230. package/src/app/DefaultApp.tsx +0 -50
  231. package/src/app/cookieColorSchemeManager.ts +0 -70
  232. package/src/app/defaultRequestMiddlewares.ts +0 -22
  233. package/src/app/defaultTheme.ts +0 -22
  234. package/src/functions/getCookie.ts +0 -36
  235. package/src/functions/setCookie.ts +0 -29
  236. package/src/functions/setCookies.ts +0 -24
  237. package/src/hooks/useMutation.ts +0 -14
  238. package/src/hooks/useMutationWithInvalidate.ts +0 -23
  239. package/src/index.ts +0 -66
  240. package/src/surreal/connection.ts +0 -72
  241. package/src/surreal/deafaultCrud.ts +0 -25
  242. package/src/surreal/deserialize.ts +0 -144
  243. package/src/surreal/encryption.ts +0 -51
  244. package/src/ui/AnimatedChevron.tsx +0 -32
  245. package/src/ui/JsonInput.tsx +0 -52
  246. package/src/ui/RouterLink.tsx +0 -78
  247. package/src/ui/editor/Content.tsx +0 -11
  248. package/src/ui/editor/Provider.tsx +0 -96
  249. package/src/ui/editor/Root.tsx +0 -25
  250. package/src/ui/editor/Toolbar.tsx +0 -92
  251. package/src/ui/editor/index.ts +0 -13
  252. package/src/ui/editor/types.ts +0 -7
  253. package/src/ui/error/DefaultError.tsx +0 -60
  254. package/src/ui/error/DefaultNotFound.tsx +0 -19
  255. package/src/ui/error/Forbidden.tsx +0 -18
  256. package/src/ui/error/defaultErrorNotification.ts +0 -9
  257. package/src/ui/form/blurOnError.ts +0 -21
  258. package/src/ui/form/buttons/CancelButton.tsx +0 -42
  259. package/src/ui/form/buttons/SubmitButton.tsx +0 -43
  260. package/src/ui/form/buttons/SubscribeActionIcon.tsx +0 -18
  261. package/src/ui/form/buttons/SubscribeButton.tsx +0 -17
  262. package/src/ui/form/context.ts +0 -45
  263. package/src/ui/form/fields/JsonField.tsx +0 -16
  264. package/src/ui/form/fields/MultiSelectField.tsx +0 -17
  265. package/src/ui/form/fields/NumberField.tsx +0 -17
  266. package/src/ui/form/fields/PassowrdField.tsx +0 -20
  267. package/src/ui/form/fields/SelectField.tsx +0 -17
  268. package/src/ui/form/fields/SwitchField.tsx +0 -17
  269. package/src/ui/form/fields/TextField.tsx +0 -17
  270. package/src/ui/form/fields/TextPassowrdField.tsx +0 -51
  271. package/src/ui/form/fields/TextareaField.tsx +0 -17
  272. package/src/ui/form/fieldsSchema.ts +0 -24
  273. package/src/ui/hoverPaper/HoverPaper.tsx +0 -17
  274. package/src/ui/hoverPaper/usePaperHover.ts +0 -9
  275. package/src/ui/saveInput/JsonInput.tsx +0 -40
  276. package/src/ui/saveInput/NumberInput.tsx +0 -40
  277. package/src/ui/saveInput/SaveInput.tsx +0 -15
  278. package/src/ui/saveInput/Select.tsx +0 -41
  279. package/src/ui/saveInput/Switch.tsx +0 -46
  280. package/src/ui/saveInput/TextInput.tsx +0 -40
  281. package/src/ui/saveInput/Textarea.tsx +0 -40
  282. package/src/ui/scrollArea/ARCH.md +0 -204
  283. package/src/ui/scrollArea/README.md +0 -369
  284. package/src/ui/scrollArea/ScrollArea.tsx +0 -93
  285. package/src/ui/scrollArea/ScrollAreaButton.tsx +0 -56
  286. package/src/ui/scrollArea/ScrollAreaContent.tsx +0 -36
  287. package/src/ui/scrollArea/context.tsx +0 -43
  288. package/src/ui/scrollArea/index.ts +0 -10
  289. package/src/ui/scrollArea/types.ts +0 -77
  290. package/src/ui/scrollArea/useScrollArea.ts +0 -227
  291. package/tsconfig.json +0 -14
  292. /package/{src/ui/error/index.ts → dist/ui/error/index.d.ts} +0 -0
  293. /package/{src/ui/form/buttons/index.ts → dist/ui/form/buttons/index.d.ts} +0 -0
  294. /package/{src/ui/form/fields/index.ts → dist/ui/form/fields/index.d.ts} +0 -0
  295. /package/{src/ui/form/index.ts → dist/ui/form/index.d.ts} +0 -0
  296. /package/{src/ui/hoverPaper/index.ts → dist/ui/hoverPaper/index.d.ts} +0 -0
  297. /package/{src/ui/saveInput/index.ts → dist/ui/saveInput/index.d.ts} +0 -0
@@ -1,93 +0,0 @@
1
- import { ScrollAreaProvider } from './context';
2
- import { ScrollAreaButton } from './ScrollAreaButton';
3
- import { ScrollAreaContent } from './ScrollAreaContent';
4
- import type { ScrollAreaContextValue, ScrollAreaProps } from './types';
5
- import { useScrollAreaState } from './useScrollArea';
6
-
7
- const ScrollAreaRoot = ({
8
- children,
9
- autoScroll = false,
10
- scrollToBottomOnInit = false,
11
- animated = true,
12
- nearThreshold = 100,
13
- radius,
14
- ...mantineProps
15
- }: ScrollAreaProps) => {
16
- const scrollAreaValue = useScrollAreaState({
17
- autoScroll,
18
- scrollToBottomOnInit,
19
- animated,
20
- nearThreshold,
21
- });
22
-
23
- // Создаем контекст с mantineProps
24
- const contextValue: ScrollAreaContextValue = {
25
- ...scrollAreaValue,
26
- radius,
27
- mantineProps,
28
- };
29
-
30
- return (
31
- <ScrollAreaProvider value={contextValue}>
32
- <ScrollAreaContent>{children}</ScrollAreaContent>
33
- </ScrollAreaProvider>
34
- );
35
- };
36
-
37
- ScrollAreaRoot.displayName = 'ScrollArea';
38
-
39
- /**
40
- * ScrollArea Component - Расширенная область прокрутки с автоскроллом
41
- *
42
- * @example
43
- * // Базовое использование
44
- * <ScrollArea h={300}>
45
- * <div>Контент для прокрутки</div>
46
- * </ScrollArea>
47
- *
48
- * @example
49
- * // С автоскроллом и кнопкой
50
- * <ScrollArea autoScroll scrollToBottomOnInit h={400}>
51
- * <div>Чат сообщения...</div>
52
- * <ScrollArea.ScrollButton className="absolute bottom-4 right-4" />
53
- * </ScrollArea>
54
- *
55
- * @example
56
- * // С кастомными настройками
57
- * <ScrollArea
58
- * autoScroll={true}
59
- * animated={true}
60
- * nearThreshold={50}
61
- * h={300}
62
- * scrollbarSize={6}
63
- * type="hover"
64
- * >
65
- * {messages.map(msg => <div key={msg.id}>{msg.text}</div>)}
66
- * <ScrollArea.ScrollButton
67
- * className="absolute bottom-4 right-4"
68
- * upIcon={<CustomUpIcon />}
69
- * downIcon={<CustomDownIcon />}
70
- * />
71
- * </ScrollArea>
72
- *
73
- * @example
74
- * // Использование хука для доступа к viewport
75
- * function CustomControl() {
76
- * const { isAtBottom, scrollToBottom, viewportRef } = useScrollArea();
77
- *
78
- * const scrollToElement = () => {
79
- * const target = viewportRef.current?.querySelector('[data-target]');
80
- * target?.scrollIntoView();
81
- * };
82
- *
83
- * return (
84
- * <button onClick={scrollToBottom} disabled={isAtBottom}>
85
- * Прокрутить вниз
86
- * </button>
87
- * );
88
- * }
89
- */
90
- export const ScrollArea = Object.assign(ScrollAreaRoot, {
91
- ScrollButton: ScrollAreaButton,
92
- Provider: ScrollAreaProvider,
93
- });
@@ -1,56 +0,0 @@
1
- import { ActionIcon } from '@mantine/core';
2
- import { useScrollArea } from './context';
3
- import type { ScrollButtonProps } from './types';
4
-
5
- export const ScrollAreaButton = ({ className }: ScrollButtonProps) => {
6
- const { hasScrollableContent, isAboveCenter, scrollToTop, scrollToBottom } =
7
- useScrollArea();
8
-
9
- // Не показываем кнопку, если нет прокручиваемого контента
10
- if (!hasScrollableContent) return null;
11
-
12
- const isScrollingDown = isAboveCenter;
13
- const icon = (
14
- <svg
15
- xmlns="http://www.w3.org/2000/svg"
16
- width="24"
17
- height="24"
18
- viewBox="0 0 24 24"
19
- fill="none"
20
- stroke="currentColor"
21
- strokeWidth="1.5"
22
- strokeLinecap="round"
23
- strokeLinejoin="round"
24
- role="img"
25
- aria-label="Chevron"
26
- style={{
27
- transition: 'transform 0.2s ease-in-out',
28
- transform: isScrollingDown ? 'rotate(-180deg)' : 'rotate(0deg)',
29
- }}
30
- >
31
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
32
- <path d="M6 9l6 6l6 -6" />
33
- </svg>
34
- );
35
-
36
- const handleClick = () => {
37
- if (isScrollingDown) scrollToBottom();
38
- else scrollToTop();
39
- };
40
-
41
- return (
42
- <ActionIcon
43
- pos="absolute"
44
- bottom={16}
45
- right={16}
46
- variant="light"
47
- onClick={handleClick}
48
- className={className}
49
- aria-label={isScrollingDown ? 'Scroll to bottom' : 'Scroll to top'}
50
- >
51
- {icon}
52
- </ActionIcon>
53
- );
54
- };
55
-
56
- ScrollAreaButton.displayName = 'ScrollArea.ScrollButton';
@@ -1,36 +0,0 @@
1
- import { Box, getRadius, ScrollArea as MantineScrollArea } from '@mantine/core';
2
- import { useContext } from 'react';
3
- import { ScrollAreaContext } from './context';
4
-
5
- export const ScrollAreaContent = ({
6
- children,
7
- }: {
8
- children: React.ReactNode;
9
- }) => {
10
- // Получаем полное состояние из контекста (включая внутренние детали)
11
- const fullContext = useContext(ScrollAreaContext);
12
- if (!fullContext) {
13
- throw new Error('ScrollAreaContent must be used within ScrollArea');
14
- }
15
-
16
- const { _callbackRef, mantineProps, radius, _contentResizeRef } = fullContext;
17
-
18
- return (
19
- <MantineScrollArea
20
- classNames={{
21
- viewport: 'rolder-scroll-area-viewport',
22
- content: 'rolder-scroll-area-content',
23
- scrollbar: 'rolder-scroll-area-scrollbar',
24
- }}
25
- style={{ '--radius': radius ? getRadius(radius) : undefined }}
26
- {...mantineProps}
27
- viewportRef={_callbackRef}
28
- >
29
- <Box h="100%" w="100%" ref={_contentResizeRef}>
30
- {children}
31
- </Box>
32
- </MantineScrollArea>
33
- );
34
- };
35
-
36
- ScrollAreaContent.displayName = 'ScrollArea.Content';
@@ -1,43 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- import type { ScrollAreaContextValue, ScrollAreaHook } from './types';
3
-
4
- /** Внутренний контекст для передачи состояния ScrollArea */
5
- export const ScrollAreaContext = createContext<ScrollAreaContextValue | null>(
6
- null,
7
- );
8
-
9
- export const ScrollAreaProvider = ScrollAreaContext.Provider;
10
-
11
- /**
12
- * Хук для доступа к состоянию и методам ScrollArea
13
- *
14
- * @returns Объект с индикаторами позиции, методами управления и ref на viewport
15
- *
16
- * @example
17
- * ```tsx
18
- * function MyComponent() {
19
- * const { isAtBottom, scrollToTop, viewportRef } = useScrollArea();
20
- *
21
- * const scrollToElement = () => {
22
- * const target = viewportRef.current?.querySelector('[data-target]');
23
- * target?.scrollIntoView();
24
- * };
25
- *
26
- * return (
27
- * <button onClick={scrollToTop} disabled={isAtTop}>
28
- * В начало
29
- * </button>
30
- * );
31
- * }
32
- * ```
33
- */
34
- export const useScrollArea = (): ScrollAreaHook => {
35
- const context = useContext(ScrollAreaContext);
36
- if (!context) {
37
- throw new Error('useScrollArea must be used within ScrollArea');
38
- }
39
-
40
- // Возвращаем только публичный API, скрывая внутренние детали
41
- const { _callbackRef, mantineProps: _, radius: __, ...publicAPI } = context;
42
- return publicAPI;
43
- };
@@ -1,10 +0,0 @@
1
- export { useScrollArea } from './context';
2
- export { ScrollArea } from './ScrollArea';
3
- export type {
4
- ScrollAreaContextValue,
5
- ScrollAreaHook,
6
- ScrollAreaProps,
7
- ScrollAreaState,
8
- ScrollButtonProps,
9
- ScrollPosition,
10
- } from './types';
@@ -1,77 +0,0 @@
1
- import type {
2
- MantineRadius,
3
- ScrollAreaProps as MantineScrollAreaProps,
4
- } from '@mantine/core';
5
- import type { ReactNode } from 'react';
6
-
7
- export interface ScrollAreaProps
8
- extends Omit<MantineScrollAreaProps, 'children'> {
9
- /** Включение автоскролла при добавлении контента (по умолчанию false) */
10
- autoScroll?: boolean;
11
- /** Прокрутить к концу при инициализации компонента (по умолчанию false) */
12
- scrollToBottomOnInit?: boolean;
13
- /** Анимированная прокрутка (по умолчанию true) */
14
- animated?: boolean;
15
- /** Отступ для near-зон в пикселях (по умолчанию 100) */
16
- nearThreshold?: number;
17
- /** Радиус для viewport и scrollbar на тот случай, когда они "торчат" углами*/
18
- radius?: MantineRadius;
19
- /** Дочерние элементы - автоматически оборачиваются в ScrollArea.Content */
20
- children: ReactNode;
21
- }
22
-
23
- export interface ScrollAreaHook {
24
- /** Точно в начале (scrollTop === 0) */
25
- isAtTop: boolean;
26
- /** В пределах nearThreshold от начала */
27
- isNearTop: boolean;
28
- /** Точно в конце (scrollTop + clientHeight >= scrollHeight) */
29
- isAtBottom: boolean;
30
- /** В пределах nearThreshold от конца */
31
- isNearBottom: boolean;
32
- /** Выше центральной точки области прокрутки */
33
- isAboveCenter: boolean;
34
- /** Есть контент требующий прокрутки */
35
- hasScrollableContent: boolean;
36
-
37
- /** Прокрутить к началу области */
38
- scrollToTop: (animated?: boolean) => void;
39
- /** Прокрутить к концу области */
40
- scrollToBottom: (animated?: boolean) => void;
41
-
42
- /** React ref на viewport элемент для прямого доступа к DOM */
43
- viewportRef: React.RefObject<HTMLDivElement | null>;
44
- }
45
-
46
- export interface ScrollAreaState extends ScrollAreaHook {
47
- /** Внутренний callback ref для подключения к Mantine ScrollArea */
48
- _callbackRef: (node: HTMLDivElement | null) => void;
49
- /** Внутренний ref для наблюдения за изменениями контента */
50
- _contentResizeRef: (node: HTMLDivElement | null) => void;
51
- }
52
-
53
- export interface ScrollAreaContextValue extends ScrollAreaState {
54
- /** Радиус для viewport и scrollbar на тот случай, когда они "торчат" углами*/
55
- radius?: MantineRadius;
56
- /** Пропсы Mantine ScrollArea, переданные в корневой компонент */
57
- mantineProps: Omit<MantineScrollAreaProps, 'children'>;
58
- }
59
-
60
- export interface ScrollButtonProps {
61
- /** CSS классы для стилизации кнопки */
62
- className?: string;
63
- /** Иконка для прокрутки вверх (по умолчанию IconChevronUp) */
64
- upIcon?: ReactNode;
65
- /** Иконка для прокрутки вниз (по умолчанию IconChevronDown) */
66
- downIcon?: ReactNode;
67
- }
68
-
69
- /** Внутренний тип для отслеживания позиции скролла */
70
- export interface ScrollPosition {
71
- /** Текущая позиция скролла сверху */
72
- scrollTop: number;
73
- /** Высота видимой области */
74
- clientHeight: number;
75
- /** Общая высота прокручиваемого контента */
76
- scrollHeight: number;
77
- }
@@ -1,227 +0,0 @@
1
- import {
2
- useDebouncedCallback,
3
- useMergedRef,
4
- useResizeObserver,
5
- } from '@mantine/hooks';
6
- import { useCallback, useEffect, useRef, useState } from 'react';
7
- import type { ScrollAreaState, ScrollPosition } from './types';
8
-
9
- interface UseScrollAreaOptions {
10
- autoScroll?: boolean;
11
- scrollToBottomOnInit?: boolean;
12
- animated?: boolean;
13
- nearThreshold?: number;
14
- }
15
-
16
- export const useScrollAreaState = (
17
- options: UseScrollAreaOptions = {},
18
- ): ScrollAreaState => {
19
- const {
20
- autoScroll = false,
21
- scrollToBottomOnInit = false,
22
- animated = true,
23
- nearThreshold = 32,
24
- } = options;
25
-
26
- const scrollAreaRef = useRef<HTMLDivElement | null>(null);
27
- const isUserInteractingRef = useRef(false);
28
- const userInteractionTimeoutRef = useRef<NodeJS.Timeout | undefined>(
29
- undefined,
30
- );
31
- const isInitializedRef = useRef(false);
32
-
33
- // Единый ResizeObserver для отслеживания изменений размера контента
34
- const [contentResizeRef, contentRect] = useResizeObserver();
35
-
36
- const [scrollPosition, setScrollPosition] = useState<ScrollPosition>({
37
- scrollTop: 0,
38
- clientHeight: 0,
39
- scrollHeight: 0,
40
- });
41
-
42
- // Вычисляемые состояния позиции
43
- const isAtTop = scrollPosition.scrollTop === 0;
44
- const isAtBottom =
45
- scrollPosition.scrollTop + scrollPosition.clientHeight >=
46
- scrollPosition.scrollHeight;
47
- const isNearTop = scrollPosition.scrollTop <= nearThreshold;
48
- const isNearBottom =
49
- scrollPosition.scrollTop + scrollPosition.clientHeight >=
50
- scrollPosition.scrollHeight - nearThreshold;
51
- const isAboveCenter =
52
- scrollPosition.scrollTop <
53
- (scrollPosition.scrollHeight - scrollPosition.clientHeight) / 2;
54
- const hasScrollableContent =
55
- scrollPosition.scrollHeight > scrollPosition.clientHeight;
56
-
57
- // Используем useDebouncedCallback для оптимизации производительности
58
- const debouncedUpdatePosition = useDebouncedCallback(
59
- (element: HTMLElement) => {
60
- const newPosition: ScrollPosition = {
61
- scrollTop: element.scrollTop,
62
- clientHeight: element.clientHeight,
63
- scrollHeight: element.scrollHeight,
64
- };
65
-
66
- setScrollPosition(newPosition);
67
- },
68
- { delay: 16 }, // 60fps
69
- );
70
-
71
- // Методы управления прокруткой
72
- const scrollToTop = useCallback(
73
- (isAnimated?: boolean) => {
74
- const element = scrollAreaRef.current;
75
- if (!element) return;
76
-
77
- const shouldAnimate = isAnimated ?? animated;
78
-
79
- if (shouldAnimate) {
80
- element.scrollTo({ top: 0, behavior: 'smooth' });
81
- } else {
82
- element.scrollTop = 0;
83
- }
84
- },
85
- [animated],
86
- );
87
-
88
- const scrollToBottom = useCallback(
89
- (isAnimated?: boolean) => {
90
- const element = scrollAreaRef.current;
91
- if (!element) return;
92
-
93
- const shouldAnimate = isAnimated ?? animated;
94
-
95
- if (shouldAnimate) {
96
- element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
97
- } else {
98
- element.scrollTop = element.scrollHeight;
99
- }
100
-
101
- // Запоминаем scrollHeight до скролла
102
- const scrollHeightBefore = element.scrollHeight;
103
-
104
- // Проверка результата и повтор если нужно
105
- setTimeout(() => {
106
- const scrollHeightAfter = element.scrollHeight;
107
- const diff =
108
- element.scrollHeight - (element.scrollTop + element.clientHeight);
109
-
110
- if (diff > 1 && scrollHeightAfter !== scrollHeightBefore) {
111
- // ScrollHeight изменился после скролла - повторяем
112
- element.scrollTop = element.scrollHeight;
113
- }
114
- }, 50);
115
- },
116
- [animated],
117
- );
118
-
119
- // Универсальная функция автоскролла
120
- const performAutoScroll = useCallback(() => {
121
- if (!autoScroll || isUserInteractingRef.current || !scrollAreaRef.current) {
122
- return;
123
- }
124
-
125
- // Для автоскролла используем isAtBottom (точная позиция)
126
- if (isAtBottom) {
127
- scrollToBottom(false);
128
- }
129
- }, [autoScroll, isAtBottom, scrollToBottom]);
130
-
131
- // Детекция пользовательского взаимодействия
132
- const handleUserInteraction = useCallback(() => {
133
- isUserInteractingRef.current = true;
134
-
135
- if (userInteractionTimeoutRef.current) {
136
- clearTimeout(userInteractionTimeoutRef.current);
137
- }
138
-
139
- userInteractionTimeoutRef.current = setTimeout(() => {
140
- isUserInteractingRef.current = false;
141
- }, 150);
142
- }, []);
143
-
144
- // Обработчик скролла
145
- const handleScroll = useCallback(
146
- (event: Event) => {
147
- const element = event.target as HTMLElement;
148
- debouncedUpdatePosition(element);
149
- },
150
- [debouncedUpdatePosition],
151
- );
152
-
153
- // Прокрутка к концу при инициализации
154
- useEffect(() => {
155
- if (!scrollToBottomOnInit || isInitializedRef.current) {
156
- return;
157
- }
158
-
159
- if (hasScrollableContent) {
160
- scrollToBottom(animated);
161
- isInitializedRef.current = true;
162
- }
163
- }, [scrollToBottomOnInit, hasScrollableContent, scrollToBottom, animated]);
164
-
165
- // Единый эффект для автоскролла при изменении контента
166
- useEffect(() => {
167
- const element = scrollAreaRef.current;
168
-
169
- if (!element || contentRect.height === 0) {
170
- return;
171
- }
172
-
173
- // Обновляем позицию
174
- debouncedUpdatePosition(element);
175
-
176
- // Автоскролл с небольшой задержкой
177
- const timeoutId = setTimeout(performAutoScroll, 10);
178
-
179
- return () => clearTimeout(timeoutId);
180
- }, [contentRect.height, debouncedUpdatePosition, performAutoScroll]);
181
-
182
- // Установка обработчиков событий
183
- useEffect(() => {
184
- const element = scrollAreaRef.current;
185
- if (!element) return;
186
-
187
- const events = ['wheel', 'touchstart', 'touchmove', 'mousedown'] as const;
188
-
189
- element.addEventListener('scroll', handleScroll);
190
- events.forEach((event) => {
191
- element.addEventListener(event, handleUserInteraction);
192
- });
193
-
194
- // Инициализация позиции
195
- debouncedUpdatePosition(element);
196
-
197
- return () => {
198
- element.removeEventListener('scroll', handleScroll);
199
- events.forEach((event) => {
200
- element.removeEventListener(event, handleUserInteraction);
201
- });
202
-
203
- if (userInteractionTimeoutRef.current) {
204
- clearTimeout(userInteractionTimeoutRef.current);
205
- }
206
- };
207
- }, [handleScroll, handleUserInteraction, debouncedUpdatePosition]);
208
-
209
- // Единый ref
210
- const callbackRef = useMergedRef(scrollAreaRef);
211
-
212
- return {
213
- isAtTop,
214
- isNearTop,
215
- isAtBottom,
216
- isNearBottom,
217
- isAboveCenter,
218
- hasScrollableContent,
219
- scrollToTop,
220
- scrollToBottom,
221
- viewportRef: scrollAreaRef,
222
- _callbackRef: callbackRef,
223
- _contentResizeRef: contentResizeRef as unknown as (
224
- node: HTMLDivElement | null,
225
- ) => void,
226
- };
227
- };
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["DOM", "ES2022"],
4
- "module": "ESNext",
5
- "jsx": "react-jsx",
6
- "strict": true,
7
- "skipLibCheck": true,
8
- "isolatedModules": true,
9
- "resolveJsonModule": true,
10
- "moduleResolution": "bundler",
11
- "useDefineForClassFields": true
12
- },
13
- "include": ["src"]
14
- }