@rolder/kit 3.0.0-alpha.17 → 3.0.0-alpha.18

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 (167) hide show
  1. package/dist/ai/index.d.ts +2 -0
  2. package/dist/ai/index.js +2 -0
  3. package/dist/ai/ui/conversation/ConversationContext.d.ts +7 -0
  4. package/dist/ai/ui/conversation/ConversationContext.js +8 -0
  5. package/dist/ai/ui/conversation/ConversationProvider.d.ts +2 -0
  6. package/dist/ai/ui/conversation/ConversationProvider.js +14 -0
  7. package/dist/ai/ui/conversation/Empty.d.ts +1 -0
  8. package/dist/ai/ui/conversation/Empty.js +21 -0
  9. package/dist/ai/ui/conversation/File.d.ts +4 -0
  10. package/dist/ai/ui/conversation/File.js +42 -0
  11. package/dist/ai/ui/conversation/FileIcon.d.ts +3 -0
  12. package/dist/ai/ui/conversation/FileIcon.js +43 -0
  13. package/dist/ai/ui/conversation/Loader.d.ts +2 -0
  14. package/dist/ai/ui/conversation/Loader.js +12 -0
  15. package/dist/ai/ui/conversation/Message.d.ts +4 -0
  16. package/dist/ai/ui/conversation/Message.js +25 -0
  17. package/dist/ai/ui/conversation/Root.d.ts +2 -0
  18. package/dist/ai/ui/conversation/Root.js +26 -0
  19. package/dist/ai/ui/conversation/index.d.ts +13 -0
  20. package/dist/ai/ui/conversation/index.js +15 -0
  21. package/dist/ai/ui/conversation/types.d.ts +7 -0
  22. package/dist/ai/ui/conversation/types.js +0 -0
  23. package/dist/ai/ui/conversation/useChatMessage.d.ts +2 -0
  24. package/dist/ai/ui/conversation/useChatMessage.js +12 -0
  25. package/dist/ai/ui/index.d.ts +2 -0
  26. package/dist/ai/ui/index.js +2 -0
  27. package/dist/ai/ui/promptInput/File.d.ts +2 -0
  28. package/dist/ai/ui/promptInput/File.js +68 -0
  29. package/dist/ai/ui/promptInput/FileIcon.d.ts +3 -0
  30. package/dist/ai/ui/promptInput/FileIcon.js +43 -0
  31. package/dist/ai/ui/promptInput/Footer.d.ts +2 -0
  32. package/dist/ai/ui/promptInput/Footer.js +8 -0
  33. package/dist/ai/ui/promptInput/PromptInputContext.d.ts +12 -0
  34. package/dist/ai/ui/promptInput/PromptInputContext.js +8 -0
  35. package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +2 -0
  36. package/dist/ai/ui/promptInput/PromptInputProvider.js +50 -0
  37. package/dist/ai/ui/promptInput/Root.d.ts +3 -0
  38. package/dist/ai/ui/promptInput/Root.js +17 -0
  39. package/dist/ai/ui/promptInput/Submit.d.ts +2 -0
  40. package/dist/ai/ui/promptInput/Submit.js +21 -0
  41. package/dist/ai/ui/promptInput/Textarea.d.ts +2 -0
  42. package/dist/ai/ui/promptInput/Textarea.js +33 -0
  43. package/dist/ai/ui/promptInput/index.d.ts +8 -0
  44. package/dist/ai/ui/promptInput/index.js +14 -0
  45. package/dist/ai/ui/promptInput/types.d.ts +11 -0
  46. package/dist/ai/ui/promptInput/types.js +0 -0
  47. package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
  48. package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
  49. package/dist/ai/utils/index.d.ts +2 -0
  50. package/dist/ai/utils/index.js +2 -0
  51. package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
  52. package/dist/ai/utils/parseAiMessagePart.js +12 -0
  53. package/dist/app/defaultTheme.d.ts +1 -1
  54. package/dist/hooks/index.d.ts +2 -0
  55. package/dist/hooks/index.js +2 -0
  56. package/dist/hooks/useMutation.d.ts +4 -0
  57. package/dist/hooks/useMutation.js +8 -0
  58. package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
  59. package/dist/hooks/useMutationWithInvalidate.js +16 -0
  60. package/dist/index.d.ts +3 -0
  61. package/dist/index.js +3 -0
  62. package/dist/styles.css +74 -0
  63. package/dist/ui/AnimatedChevron.d.ts +6 -0
  64. package/dist/ui/AnimatedChevron.js +13 -0
  65. package/dist/ui/JsonInput.d.ts +2 -0
  66. package/dist/ui/JsonInput.js +45 -0
  67. package/dist/ui/RouterLink.d.ts +16 -0
  68. package/dist/ui/RouterLink.js +36 -0
  69. package/dist/ui/editor/Content.d.ts +3 -0
  70. package/dist/ui/editor/Content.js +13 -0
  71. package/dist/ui/editor/Provider.d.ts +17 -0
  72. package/dist/ui/editor/Provider.js +80 -0
  73. package/dist/ui/editor/Root.d.ts +2 -0
  74. package/dist/ui/editor/Root.js +18 -0
  75. package/dist/ui/editor/Toolbar.d.ts +5 -0
  76. package/dist/ui/editor/Toolbar.js +138 -0
  77. package/dist/ui/editor/index.d.ts +12 -0
  78. package/dist/ui/editor/index.js +11 -0
  79. package/dist/ui/editor/types.d.ts +7 -0
  80. package/dist/ui/editor/types.js +0 -0
  81. package/dist/ui/error/DefaultError.d.ts +2 -0
  82. package/dist/ui/error/DefaultError.js +62 -0
  83. package/dist/ui/error/DefaultNotFound.d.ts +1 -0
  84. package/dist/ui/error/DefaultNotFound.js +37 -0
  85. package/dist/ui/error/Forbidden.d.ts +1 -0
  86. package/dist/ui/error/Forbidden.js +32 -0
  87. package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
  88. package/dist/ui/error/defaultErrorNotification.js +8 -0
  89. package/dist/ui/error/index.d.ts +4 -0
  90. package/dist/ui/error/index.js +5 -0
  91. package/dist/ui/form/blurOnError.d.ts +4 -0
  92. package/dist/ui/form/blurOnError.js +11 -0
  93. package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
  94. package/dist/ui/form/buttons/CancelButton.js +22 -0
  95. package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
  96. package/dist/ui/form/buttons/SubmitButton.js +22 -0
  97. package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
  98. package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
  99. package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
  100. package/dist/ui/form/buttons/SubscribeButton.js +16 -0
  101. package/dist/ui/form/buttons/index.d.ts +4 -0
  102. package/dist/ui/form/buttons/index.js +4 -0
  103. package/dist/ui/form/context.d.ts +83 -0
  104. package/dist/ui/form/context.js +26 -0
  105. package/dist/ui/form/fields/JsonField.d.ts +2 -0
  106. package/dist/ui/form/fields/JsonField.js +13 -0
  107. package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
  108. package/dist/ui/form/fields/MultiSelectField.js +15 -0
  109. package/dist/ui/form/fields/NumberField.d.ts +2 -0
  110. package/dist/ui/form/fields/NumberField.js +15 -0
  111. package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
  112. package/dist/ui/form/fields/PassowrdField.js +18 -0
  113. package/dist/ui/form/fields/SelectField.d.ts +2 -0
  114. package/dist/ui/form/fields/SelectField.js +15 -0
  115. package/dist/ui/form/fields/SwitchField.d.ts +2 -0
  116. package/dist/ui/form/fields/SwitchField.js +15 -0
  117. package/dist/ui/form/fields/TextField.d.ts +2 -0
  118. package/dist/ui/form/fields/TextField.js +15 -0
  119. package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
  120. package/dist/ui/form/fields/TextPassowrdField.js +29 -0
  121. package/dist/ui/form/fields/TextareaField.d.ts +2 -0
  122. package/dist/ui/form/fields/TextareaField.js +15 -0
  123. package/dist/ui/form/fields/index.d.ts +9 -0
  124. package/dist/ui/form/fields/index.js +9 -0
  125. package/dist/ui/form/fieldsSchema.d.ts +12 -0
  126. package/dist/ui/form/fieldsSchema.js +13 -0
  127. package/dist/ui/form/index.d.ts +3 -0
  128. package/dist/ui/form/index.js +4 -0
  129. package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
  130. package/dist/ui/hoverPaper/HoverPaper.js +15 -0
  131. package/dist/ui/hoverPaper/index.d.ts +2 -0
  132. package/dist/ui/hoverPaper/index.js +3 -0
  133. package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
  134. package/dist/ui/hoverPaper/usePaperHover.js +9 -0
  135. package/dist/ui/index.d.ts +9 -0
  136. package/dist/ui/index.js +9 -0
  137. package/dist/ui/saveInput/JsonInput.d.ts +6 -0
  138. package/dist/ui/saveInput/JsonInput.js +34 -0
  139. package/dist/ui/saveInput/NumberInput.d.ts +6 -0
  140. package/dist/ui/saveInput/NumberInput.js +27 -0
  141. package/dist/ui/saveInput/SaveInput.d.ts +36 -0
  142. package/dist/ui/saveInput/SaveInput.js +15 -0
  143. package/dist/ui/saveInput/Select.d.ts +6 -0
  144. package/dist/ui/saveInput/Select.js +27 -0
  145. package/dist/ui/saveInput/Switch.d.ts +6 -0
  146. package/dist/ui/saveInput/Switch.js +30 -0
  147. package/dist/ui/saveInput/TextInput.d.ts +6 -0
  148. package/dist/ui/saveInput/TextInput.js +26 -0
  149. package/dist/ui/saveInput/Textarea.d.ts +6 -0
  150. package/dist/ui/saveInput/Textarea.js +26 -0
  151. package/dist/ui/saveInput/index.d.ts +1 -0
  152. package/dist/ui/saveInput/index.js +2 -0
  153. package/dist/ui/scrollArea/ScrollArea.d.ts +62 -0
  154. package/dist/ui/scrollArea/ScrollArea.js +30 -0
  155. package/dist/ui/scrollArea/ScrollAreaButton.d.ts +5 -0
  156. package/dist/ui/scrollArea/ScrollAreaButton.js +30 -0
  157. package/dist/ui/scrollArea/ScrollAreaContent.d.ts +6 -0
  158. package/dist/ui/scrollArea/ScrollAreaContent.js +29 -0
  159. package/dist/ui/scrollArea/context.d.ts +28 -0
  160. package/dist/ui/scrollArea/context.js +10 -0
  161. package/dist/ui/scrollArea/index.d.ts +3 -0
  162. package/dist/ui/scrollArea/index.js +3 -0
  163. package/dist/ui/scrollArea/types.d.ts +65 -0
  164. package/dist/ui/scrollArea/types.js +0 -0
  165. package/dist/ui/scrollArea/useScrollArea.d.ts +9 -0
  166. package/dist/ui/scrollArea/useScrollArea.js +146 -0
  167. package/package.json +1 -1
@@ -0,0 +1,2 @@
1
+ export * from './ui';
2
+ export * from './utils';
@@ -0,0 +1,2 @@
1
+ export * from "./ui/index.js";
2
+ export * from "./utils/index.js";
@@ -0,0 +1,7 @@
1
+ export interface ConversationContext {
2
+ loading: boolean;
3
+ streaming: boolean;
4
+ empty: boolean;
5
+ }
6
+ export declare const ConversationContext: import("react").Context<ConversationContext | null>;
7
+ export declare const useConversation: () => ConversationContext;
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from "react";
2
+ const ConversationContext = createContext(null);
3
+ const useConversation = ()=>{
4
+ const context = useContext(ConversationContext);
5
+ if (!context) throw new Error('useConversation must be used within a ConversationProvider');
6
+ return context;
7
+ };
8
+ export { ConversationContext, useConversation };
@@ -0,0 +1,2 @@
1
+ import type { ConversationProps } from './types';
2
+ export declare const Provider: ({ children, loading, streaming, empty, }: ConversationProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ConversationContext } from "./ConversationContext.js";
3
+ const Provider = ({ children, loading, streaming, empty })=>{
4
+ const value = {
5
+ loading,
6
+ streaming,
7
+ empty
8
+ };
9
+ return /*#__PURE__*/ jsx(ConversationContext.Provider, {
10
+ value: value,
11
+ children: children
12
+ });
13
+ };
14
+ export { Provider };
@@ -0,0 +1 @@
1
+ export declare const Empty: () => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,21 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Stack, Text } from "@mantine/core";
3
+ import { useConversation } from "./ConversationContext.js";
4
+ const Empty = ()=>{
5
+ const { empty } = useConversation();
6
+ return empty ? null : /*#__PURE__*/ jsxs(Stack, {
7
+ align: "center",
8
+ gap: 0,
9
+ children: [
10
+ /*#__PURE__*/ jsx(Text, {
11
+ children: "Нет сообщений"
12
+ }),
13
+ /*#__PURE__*/ jsx(Text, {
14
+ size: "sm",
15
+ c: "dimmed",
16
+ children: "Начните общение, чтобы увидеть сообщения здесь"
17
+ })
18
+ ]
19
+ });
20
+ };
21
+ export { Empty };
@@ -0,0 +1,4 @@
1
+ import type { UIMessage } from 'ai';
2
+ export declare const File: <T extends UIMessage>({ message }: {
3
+ message: T;
4
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,42 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Image, Paper } from "@mantine/core";
3
+ import { FileIcon } from "./FileIcon.js";
4
+ const File = ({ message })=>{
5
+ const textFileType = message.id.split('-')[1];
6
+ const fileParts = message.parts?.filter((i)=>'file' === i.type);
7
+ const lastFilePart = fileParts[fileParts.length - 1];
8
+ const FileComponent = ()=>{
9
+ switch(textFileType){
10
+ case 'excel':
11
+ return /*#__PURE__*/ jsx(FileIcon, {
12
+ mimeType: "excel"
13
+ });
14
+ case 'word':
15
+ return /*#__PURE__*/ jsx(FileIcon, {
16
+ mimeType: "word"
17
+ });
18
+ case 'powerpoint':
19
+ return /*#__PURE__*/ jsx(FileIcon, {
20
+ mimeType: "powerpoint"
21
+ });
22
+ }
23
+ if (lastFilePart.mediaType.includes('image/')) return /*#__PURE__*/ jsx(Image, {
24
+ radius: "md",
25
+ h: 128,
26
+ src: lastFilePart.url,
27
+ alt: "Image Preview"
28
+ });
29
+ return /*#__PURE__*/ jsx(FileIcon, {
30
+ mimeType: lastFilePart.mediaType
31
+ });
32
+ };
33
+ return textFileType || lastFilePart ? /*#__PURE__*/ jsx(Paper, {
34
+ radius: "md",
35
+ px: "md",
36
+ py: "sm",
37
+ ml: "auto",
38
+ bg: "var(--mantine-color-default-hover)",
39
+ children: /*#__PURE__*/ jsx(FileComponent, {})
40
+ }) : null;
41
+ };
42
+ export { File };
@@ -0,0 +1,3 @@
1
+ export declare const FileIcon: ({ mimeType }: {
2
+ mimeType: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IconFile, IconFileTypeDoc, IconFileTypePdf, IconFileTypePpt, IconFileTypeXls, IconPhoto } from "@tabler/icons-react";
3
+ const FileIcon = ({ mimeType })=>{
4
+ switch(true){
5
+ case mimeType.includes('image/'):
6
+ return /*#__PURE__*/ jsx(IconPhoto, {
7
+ size: 36,
8
+ stroke: 1.5,
9
+ color: "var(--mantine-color-text)"
10
+ });
11
+ case mimeType.includes('application/pdf'):
12
+ return /*#__PURE__*/ jsx(IconFileTypePdf, {
13
+ size: 36,
14
+ stroke: 1.5,
15
+ color: "var(--mantine-color-text)"
16
+ });
17
+ case 'word' === mimeType:
18
+ return /*#__PURE__*/ jsx(IconFileTypeDoc, {
19
+ size: 36,
20
+ stroke: 1.5,
21
+ color: "var(--mantine-color-text)"
22
+ });
23
+ case 'excel' === mimeType:
24
+ return /*#__PURE__*/ jsx(IconFileTypeXls, {
25
+ size: 36,
26
+ stroke: 1.5,
27
+ color: "var(--mantine-color-text)"
28
+ });
29
+ case 'powerpoint' === mimeType:
30
+ return /*#__PURE__*/ jsx(IconFileTypePpt, {
31
+ size: 36,
32
+ stroke: 1.5,
33
+ color: "var(--mantine-color-text)"
34
+ });
35
+ default:
36
+ return /*#__PURE__*/ jsx(IconFile, {
37
+ size: 36,
38
+ stroke: 1.5,
39
+ color: "var(--mantine-color-text)"
40
+ });
41
+ }
42
+ };
43
+ export { FileIcon };
@@ -0,0 +1,2 @@
1
+ import { type LoaderProps } from '@mantine/core';
2
+ export declare const Loader: (props: LoaderProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Loader } from "@mantine/core";
3
+ import { useConversation } from "./ConversationContext.js";
4
+ const Loader_Loader = (props)=>{
5
+ const { loading } = useConversation();
6
+ return loading ? /*#__PURE__*/ jsx(Loader, {
7
+ size: 28,
8
+ type: "dots",
9
+ ...props
10
+ }) : null;
11
+ };
12
+ export { Loader_Loader as Loader };
@@ -0,0 +1,4 @@
1
+ import type { UIMessage } from 'ai';
2
+ export declare const Message: <T extends UIMessage>({ message }: {
3
+ message: T;
4
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import { Streamdown } from "streamdown";
4
+ import { useConversation } from "./ConversationContext.js";
5
+ import { useChatMessage } from "./useChatMessage.js";
6
+ const Message = ({ message })=>{
7
+ const textParts = message?.parts?.filter((i)=>'text' === i.type);
8
+ const lastTextPart = textParts?.[textParts.length - 1];
9
+ const chatMessage = useChatMessage(lastTextPart);
10
+ const { streaming } = useConversation();
11
+ return chatMessage && 'system' !== message.role ? /*#__PURE__*/ jsx(Paper, {
12
+ radius: "md",
13
+ px: "md",
14
+ py: "sm",
15
+ maw: "80%",
16
+ ml: 'user' === message.role ? 'auto' : void 0,
17
+ bg: 'user' === message.role ? 'var(--mantine-color-default-hover)' : 'var(--mantine-primary-color-light)',
18
+ fz: "sm",
19
+ children: /*#__PURE__*/ jsx(Streamdown, {
20
+ isAnimating: streaming && 'assistant' === message.role,
21
+ children: chatMessage
22
+ })
23
+ }) : null;
24
+ };
25
+ export { Message };
@@ -0,0 +1,2 @@
1
+ import type { ConversationProps } from './types';
2
+ export declare const Root: ({ children, loading, streaming, empty, ...props }: ConversationProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Paper, Stack } from "@mantine/core";
3
+ import { ScrollArea } from "../../../ui/index.js";
4
+ import { Provider } from "./ConversationProvider.js";
5
+ const Root = ({ children, loading, streaming, empty, ...props })=>/*#__PURE__*/ jsx(Provider, {
6
+ loading: loading,
7
+ streaming: streaming,
8
+ empty: empty,
9
+ children: /*#__PURE__*/ jsx(Paper, {
10
+ withBorder: true,
11
+ radius: "md",
12
+ ...props,
13
+ children: /*#__PURE__*/ jsxs(ScrollArea, {
14
+ autoScroll: true,
15
+ scrollToBottomOnInit: true,
16
+ p: "md",
17
+ children: [
18
+ /*#__PURE__*/ jsx(Stack, {
19
+ children: children
20
+ }),
21
+ /*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
22
+ ]
23
+ })
24
+ })
25
+ });
26
+ export { Root };
@@ -0,0 +1,13 @@
1
+ export * from './types';
2
+ export * from './useChatMessage';
3
+ export declare const Conversation: {
4
+ Root: ({ children, loading, streaming, empty, ...props }: import("./types").ConversationProps) => import("react/jsx-runtime").JSX.Element;
5
+ Message: <T extends import("ai").UIMessage>({ message }: {
6
+ message: T;
7
+ }) => import("react/jsx-runtime").JSX.Element | null;
8
+ File: <T extends import("ai").UIMessage>({ message }: {
9
+ message: T;
10
+ }) => import("react/jsx-runtime").JSX.Element | null;
11
+ Loader: (props: import("@mantine/core").LoaderProps) => import("react/jsx-runtime").JSX.Element | null;
12
+ Empty: () => import("react/jsx-runtime").JSX.Element | null;
13
+ };
@@ -0,0 +1,15 @@
1
+ import { Empty } from "./Empty.js";
2
+ import { File } from "./File.js";
3
+ import { Loader } from "./Loader.js";
4
+ import { Message } from "./Message.js";
5
+ import { Root } from "./Root.js";
6
+ export * from "./types.js";
7
+ export * from "./useChatMessage.js";
8
+ const Conversation = {
9
+ Root: Root,
10
+ Message: Message,
11
+ File: File,
12
+ Loader: Loader,
13
+ Empty: Empty
14
+ };
15
+ export { Conversation };
@@ -0,0 +1,7 @@
1
+ import type { PaperProps } from '@mantine/core';
2
+ export interface ConversationProps extends PaperProps {
3
+ children?: React.ReactNode;
4
+ loading: boolean;
5
+ streaming: boolean;
6
+ empty: boolean;
7
+ }
File without changes
@@ -0,0 +1,2 @@
1
+ import type { TextUIPart } from 'ai';
2
+ export declare const useChatMessage: (part: TextUIPart) => string;
@@ -0,0 +1,12 @@
1
+ import { useEffect, useState } from "react";
2
+ import { parseAiMessagePart } from "../../utils/index.js";
3
+ const useChatMessage = (part)=>{
4
+ const [parsedText, setParsedText] = useState('');
5
+ useEffect(()=>{
6
+ parseAiMessagePart(part).then((i)=>setParsedText(i.text));
7
+ }, [
8
+ part
9
+ ]);
10
+ return parsedText;
11
+ };
12
+ export { useChatMessage };
@@ -0,0 +1,2 @@
1
+ export * from './conversation';
2
+ export * from './promptInput';
@@ -0,0 +1,2 @@
1
+ export * from "./conversation/index.js";
2
+ export * from "./promptInput/index.js";
@@ -0,0 +1,2 @@
1
+ import { type FileButtonProps } from '@mantine/core';
2
+ export declare const File: (props: Omit<FileButtonProps, "onChange" | "children">) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,68 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { ActionIcon, FileButton, Tooltip } from "@mantine/core";
3
+ import { IconPaperclip, IconTrash } from "@tabler/icons-react";
4
+ import { useRef } from "react";
5
+ import { FileIcon } from "./FileIcon.js";
6
+ import { usePromptInput } from "./PromptInputContext.js";
7
+ const File = (props)=>{
8
+ const resetRef = useRef(null);
9
+ const { file, setFile, accept, submiting, uploading } = usePromptInput();
10
+ return /*#__PURE__*/ jsx(FileButton, {
11
+ resetRef: resetRef,
12
+ onChange: async (file)=>{
13
+ if (file) setFile(file);
14
+ },
15
+ accept: accept,
16
+ disabled: submiting || uploading,
17
+ ...props,
18
+ children: (props)=>/*#__PURE__*/ jsxs(ActionIcon.Group, {
19
+ children: [
20
+ /*#__PURE__*/ jsx(ActionIcon, {
21
+ size: "lg",
22
+ variant: "default",
23
+ disabled: submiting,
24
+ loading: uploading,
25
+ classNames: {
26
+ root: 'rolder-prompt-input-file-action-action'
27
+ },
28
+ ...props,
29
+ children: /*#__PURE__*/ jsx(IconPaperclip, {
30
+ size: 24,
31
+ stroke: 1.5
32
+ })
33
+ }),
34
+ file && /*#__PURE__*/ jsxs(Fragment, {
35
+ children: [
36
+ /*#__PURE__*/ jsx(Tooltip, {
37
+ label: file.name,
38
+ openDelay: 500,
39
+ children: /*#__PURE__*/ jsx(ActionIcon.GroupSection, {
40
+ variant: "default",
41
+ size: "lg",
42
+ children: /*#__PURE__*/ jsx(FileIcon, {
43
+ mimeType: file.type
44
+ })
45
+ })
46
+ }),
47
+ /*#__PURE__*/ jsx(ActionIcon, {
48
+ size: "lg",
49
+ variant: "default",
50
+ classNames: {
51
+ root: 'rolder-prompt-input-file-action-action'
52
+ },
53
+ onClick: ()=>{
54
+ resetRef.current?.();
55
+ setFile(void 0);
56
+ },
57
+ children: /*#__PURE__*/ jsx(IconTrash, {
58
+ size: 24,
59
+ stroke: 1.5
60
+ })
61
+ })
62
+ ]
63
+ })
64
+ ]
65
+ })
66
+ });
67
+ };
68
+ export { File };
@@ -0,0 +1,3 @@
1
+ export declare const FileIcon: ({ mimeType }: {
2
+ mimeType: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IconFile, IconFileTypeDoc, IconFileTypePdf, IconFileTypePpt, IconFileTypeXls, IconPhoto } from "@tabler/icons-react";
3
+ const FileIcon = ({ mimeType })=>{
4
+ switch(true){
5
+ case mimeType.includes('image/'):
6
+ return /*#__PURE__*/ jsx(IconPhoto, {
7
+ size: 24,
8
+ stroke: 1.5,
9
+ color: "var(--mantine-color-dimmed)"
10
+ });
11
+ case mimeType.includes('application/pdf'):
12
+ return /*#__PURE__*/ jsx(IconFileTypePdf, {
13
+ size: 24,
14
+ stroke: 1.5,
15
+ color: "var(--mantine-color-dimmed)"
16
+ });
17
+ case mimeType.includes('application/vnd.openxmlformats-officedocument.wordprocessingml.document'):
18
+ return /*#__PURE__*/ jsx(IconFileTypeDoc, {
19
+ size: 24,
20
+ stroke: 1.5,
21
+ color: "var(--mantine-color-dimmed)"
22
+ });
23
+ case mimeType.includes('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'):
24
+ return /*#__PURE__*/ jsx(IconFileTypeXls, {
25
+ size: 24,
26
+ stroke: 1.5,
27
+ color: "var(--mantine-color-dimmed)"
28
+ });
29
+ case mimeType.includes('application/vnd.openxmlformats-officedocument.presentationml.presentation'):
30
+ return /*#__PURE__*/ jsx(IconFileTypePpt, {
31
+ size: 24,
32
+ stroke: 1.5,
33
+ color: "var(--mantine-color-dimmed)"
34
+ });
35
+ default:
36
+ return /*#__PURE__*/ jsx(IconFile, {
37
+ size: 24,
38
+ stroke: 1.5,
39
+ color: "var(--mantine-color-dimmed)"
40
+ });
41
+ }
42
+ };
43
+ export { FileIcon };
@@ -0,0 +1,2 @@
1
+ import { type GroupProps } from '@mantine/core';
2
+ export declare const Footer: (props: GroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Group } from "@mantine/core";
3
+ const Footer = (props)=>/*#__PURE__*/ jsx(Group, {
4
+ justify: "space-between",
5
+ p: "xs",
6
+ ...props
7
+ });
8
+ export { Footer };
@@ -0,0 +1,12 @@
1
+ export interface PromptInputContext {
2
+ text: string;
3
+ setText: (text: string) => void;
4
+ file?: File;
5
+ setFile: (file?: File) => void;
6
+ onSubmit: () => void;
7
+ submiting: boolean;
8
+ uploading: boolean;
9
+ accept?: string;
10
+ }
11
+ export declare const PromptInputContext: import("react").Context<PromptInputContext | null>;
12
+ export declare const usePromptInput: () => PromptInputContext;
@@ -0,0 +1,8 @@
1
+ import { createContext, useContext } from "react";
2
+ const PromptInputContext = createContext(null);
3
+ const usePromptInput = ()=>{
4
+ const context = useContext(PromptInputContext);
5
+ if (!context) throw new Error('usePromptInput must be used within a PromptInputProvider');
6
+ return context;
7
+ };
8
+ export { PromptInputContext, usePromptInput };
@@ -0,0 +1,2 @@
1
+ import type { PromptInputProps } from './types';
2
+ export declare const Provider: ({ children, onSubmit, submiting, uploading, accept, }: PromptInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,50 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { PromptInputContext } from "./PromptInputContext.js";
4
+ const Provider = ({ children, onSubmit, submiting, uploading, accept = [
5
+ 'text',
6
+ 'image',
7
+ 'pdf'
8
+ ] })=>{
9
+ const [text, setText] = useState('');
10
+ const [file, setFile] = useState();
11
+ const value = {
12
+ text,
13
+ setText,
14
+ file,
15
+ setFile,
16
+ onSubmit: ()=>{
17
+ if (text.trim()) {
18
+ onSubmit({
19
+ text: text.trim(),
20
+ file
21
+ });
22
+ setText('');
23
+ setFile(void 0);
24
+ }
25
+ },
26
+ submiting,
27
+ uploading,
28
+ accept: accept.map((type)=>{
29
+ switch(type){
30
+ case 'text':
31
+ return 'text/plain';
32
+ case 'image':
33
+ return 'image/*';
34
+ case 'pdf':
35
+ return 'application/pdf';
36
+ case 'excel':
37
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
38
+ case 'word':
39
+ return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
40
+ default:
41
+ return type;
42
+ }
43
+ }).join(',')
44
+ };
45
+ return /*#__PURE__*/ jsx(PromptInputContext.Provider, {
46
+ value: value,
47
+ children: children
48
+ });
49
+ };
50
+ export { Provider };
@@ -0,0 +1,3 @@
1
+ import { type PaperProps } from '@mantine/core';
2
+ import type { PromptInputProps } from './types';
3
+ export declare const Root: ({ className, onSubmit, submiting, uploading, accept, ...props }: PaperProps & PromptInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import clsx from "clsx";
4
+ import { Provider } from "./PromptInputProvider.js";
5
+ const Root = ({ className, onSubmit, submiting, uploading, accept, ...props })=>/*#__PURE__*/ jsx(Provider, {
6
+ onSubmit: onSubmit,
7
+ submiting: submiting,
8
+ uploading: uploading,
9
+ accept: accept,
10
+ children: /*#__PURE__*/ jsx(Paper, {
11
+ radius: "md",
12
+ withBorder: true,
13
+ className: clsx('rolder-prompt-input-root', className),
14
+ ...props
15
+ })
16
+ });
17
+ export { Root };
@@ -0,0 +1,2 @@
1
+ import { type ActionIconProps } from '@mantine/core';
2
+ export declare const Submit: ({ children, ...props }: ActionIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ActionIcon } from "@mantine/core";
3
+ import { IconArrowBigUp } from "@tabler/icons-react";
4
+ import { usePromptInput } from "./PromptInputContext.js";
5
+ const Submit = ({ children, ...props })=>{
6
+ const Icon = /*#__PURE__*/ jsx(IconArrowBigUp, {
7
+ strokeWidth: 1.5
8
+ });
9
+ const { onSubmit, submiting, uploading } = usePromptInput();
10
+ return /*#__PURE__*/ jsx(ActionIcon, {
11
+ "aria-label": "Submit",
12
+ variant: "light",
13
+ size: "lg",
14
+ onClick: onSubmit,
15
+ disabled: uploading,
16
+ loading: submiting,
17
+ ...props,
18
+ children: children ?? Icon
19
+ });
20
+ };
21
+ export { Submit };
@@ -0,0 +1,2 @@
1
+ import { type TextareaProps } from '@mantine/core';
2
+ export declare const Textarea: (props: TextareaProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Textarea } from "@mantine/core";
3
+ import { useState } from "react";
4
+ import { usePromptInput } from "./PromptInputContext.js";
5
+ const Textarea_Textarea = (props)=>{
6
+ const { text, setText, onSubmit, submiting, uploading } = usePromptInput();
7
+ const [isComposing, setIsComposing] = useState(false);
8
+ const handleKeyDown = (e)=>{
9
+ if ('Enter' === e.key) {
10
+ if (isComposing || e.nativeEvent.isComposing) return;
11
+ if (e.shiftKey) return;
12
+ e.preventDefault();
13
+ onSubmit();
14
+ }
15
+ };
16
+ return /*#__PURE__*/ jsx(Textarea, {
17
+ w: "100%",
18
+ size: "md",
19
+ rows: 3,
20
+ classNames: {
21
+ input: 'rolder-prompt-input-textarea'
22
+ },
23
+ placeholder: "Напишите сообщение",
24
+ onCompositionEnd: ()=>setIsComposing(false),
25
+ onCompositionStart: ()=>setIsComposing(true),
26
+ onKeyDown: handleKeyDown,
27
+ value: text,
28
+ onChange: (e)=>setText(e.target.value),
29
+ disabled: submiting || uploading,
30
+ ...props
31
+ });
32
+ };
33
+ export { Textarea_Textarea as Textarea };
@@ -0,0 +1,8 @@
1
+ export * from './types';
2
+ export declare const PromptInput: {
3
+ Root: ({ className, onSubmit, submiting, uploading, accept, ...props }: import("@mantine/core").PaperProps & import("./types").PromptInputProps) => import("react/jsx-runtime").JSX.Element;
4
+ Textarea: (props: import("@mantine/core").TextareaProps) => import("react/jsx-runtime").JSX.Element;
5
+ Footer: (props: import("@mantine/core").GroupProps) => import("react/jsx-runtime").JSX.Element;
6
+ Submit: ({ children, ...props }: import("@mantine/core").ActionIconProps) => import("react/jsx-runtime").JSX.Element;
7
+ File: (props: Omit<import("@mantine/core").FileButtonProps, "onChange" | "children">) => import("react/jsx-runtime").JSX.Element;
8
+ };