@rolder/kit 3.0.0-alpha.16 → 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.
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +2 -0
- package/dist/ai/ui/conversation/ConversationContext.d.ts +7 -0
- package/dist/ai/ui/conversation/ConversationContext.js +8 -0
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +2 -0
- package/dist/ai/ui/conversation/ConversationProvider.js +14 -0
- package/dist/ai/ui/conversation/Empty.d.ts +1 -0
- package/dist/ai/ui/conversation/Empty.js +21 -0
- package/dist/ai/ui/conversation/File.d.ts +4 -0
- package/dist/ai/ui/conversation/File.js +42 -0
- package/dist/ai/ui/conversation/FileIcon.d.ts +3 -0
- package/dist/ai/ui/conversation/FileIcon.js +43 -0
- package/dist/ai/ui/conversation/Loader.d.ts +2 -0
- package/dist/ai/ui/conversation/Loader.js +12 -0
- package/dist/ai/ui/conversation/Message.d.ts +4 -0
- package/dist/ai/ui/conversation/Message.js +25 -0
- package/dist/ai/ui/conversation/Root.d.ts +2 -0
- package/dist/ai/ui/conversation/Root.js +26 -0
- package/dist/ai/ui/conversation/index.d.ts +13 -0
- package/dist/ai/ui/conversation/index.js +15 -0
- package/dist/ai/ui/conversation/types.d.ts +7 -0
- package/dist/ai/ui/conversation/types.js +0 -0
- package/dist/ai/ui/conversation/useChatMessage.d.ts +2 -0
- package/dist/ai/ui/conversation/useChatMessage.js +12 -0
- package/dist/ai/ui/index.d.ts +2 -0
- package/dist/ai/ui/index.js +2 -0
- package/dist/ai/ui/promptInput/File.d.ts +2 -0
- package/dist/ai/ui/promptInput/File.js +68 -0
- package/dist/ai/ui/promptInput/FileIcon.d.ts +3 -0
- package/dist/ai/ui/promptInput/FileIcon.js +43 -0
- package/dist/ai/ui/promptInput/Footer.d.ts +2 -0
- package/dist/ai/ui/promptInput/Footer.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +12 -0
- package/dist/ai/ui/promptInput/PromptInputContext.js +8 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +2 -0
- package/dist/ai/ui/promptInput/PromptInputProvider.js +50 -0
- package/dist/ai/ui/promptInput/Root.d.ts +3 -0
- package/dist/ai/ui/promptInput/Root.js +17 -0
- package/dist/ai/ui/promptInput/Submit.d.ts +2 -0
- package/dist/ai/ui/promptInput/Submit.js +21 -0
- package/dist/ai/ui/promptInput/Textarea.d.ts +2 -0
- package/dist/ai/ui/promptInput/Textarea.js +33 -0
- package/dist/ai/ui/promptInput/index.d.ts +8 -0
- package/dist/ai/ui/promptInput/index.js +14 -0
- package/dist/ai/ui/promptInput/types.d.ts +11 -0
- package/dist/ai/ui/promptInput/types.js +0 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +5 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +21 -0
- package/dist/ai/utils/index.d.ts +2 -0
- package/dist/ai/utils/index.js +2 -0
- package/dist/ai/utils/parseAiMessagePart.d.ts +2 -0
- package/dist/ai/utils/parseAiMessagePart.js +12 -0
- package/dist/app/AppDefaults.d.ts +3 -0
- package/dist/app/AppDefaults.js +27 -0
- package/dist/app/DefaultApp.d.ts +6 -0
- package/dist/app/DefaultApp.js +43 -0
- package/dist/app/cookieColorSchemeManager.d.ts +6 -0
- package/dist/app/cookieColorSchemeManager.js +46 -0
- package/dist/app/defaultRequestMiddlewares.d.ts +4 -0
- package/dist/app/defaultRequestMiddlewares.js +24 -0
- package/dist/app/defaultTheme.d.ts +141 -0
- package/dist/app/defaultTheme.js +24 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/index.js +4 -0
- package/dist/functions/getCookie.d.ts +3 -0
- package/dist/functions/getCookie.js +8 -0
- package/dist/functions/index.d.ts +3 -0
- package/dist/functions/index.js +4 -0
- package/dist/functions/setCookie.d.ts +10 -0
- package/dist/functions/setCookie.js +19 -0
- package/dist/functions/setCookies.d.ts +14 -0
- package/dist/functions/setCookies.js +13 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useMutation.d.ts +4 -0
- package/dist/hooks/useMutation.js +8 -0
- package/dist/hooks/useMutationWithInvalidate.d.ts +4 -0
- package/dist/hooks/useMutationWithInvalidate.js +16 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -2
- package/dist/styles.css +74 -0
- package/dist/ui/AnimatedChevron.d.ts +6 -0
- package/dist/ui/AnimatedChevron.js +13 -0
- package/dist/ui/JsonInput.d.ts +2 -0
- package/dist/ui/JsonInput.js +45 -0
- package/dist/ui/RouterLink.d.ts +16 -0
- package/dist/ui/RouterLink.js +36 -0
- package/dist/ui/editor/Content.d.ts +3 -0
- package/dist/ui/editor/Content.js +13 -0
- package/dist/ui/editor/Provider.d.ts +17 -0
- package/dist/ui/editor/Provider.js +80 -0
- package/dist/ui/editor/Root.d.ts +2 -0
- package/dist/ui/editor/Root.js +18 -0
- package/dist/ui/editor/Toolbar.d.ts +5 -0
- package/dist/ui/editor/Toolbar.js +138 -0
- package/dist/ui/editor/index.d.ts +12 -0
- package/dist/ui/editor/index.js +11 -0
- package/dist/ui/editor/types.d.ts +7 -0
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.d.ts +2 -0
- package/dist/ui/error/DefaultError.js +62 -0
- package/dist/ui/error/DefaultNotFound.d.ts +1 -0
- package/dist/ui/error/DefaultNotFound.js +37 -0
- package/dist/ui/error/Forbidden.d.ts +1 -0
- package/dist/ui/error/Forbidden.js +32 -0
- package/dist/ui/error/defaultErrorNotification.d.ts +1 -0
- package/dist/ui/error/defaultErrorNotification.js +8 -0
- package/dist/ui/error/index.d.ts +4 -0
- package/dist/ui/error/index.js +5 -0
- package/dist/ui/form/blurOnError.d.ts +4 -0
- package/dist/ui/form/blurOnError.js +11 -0
- package/dist/ui/form/buttons/CancelButton.d.ts +5 -0
- package/dist/ui/form/buttons/CancelButton.js +22 -0
- package/dist/ui/form/buttons/SubmitButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubmitButton.js +22 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +4 -0
- package/dist/ui/form/buttons/SubscribeActionIcon.js +15 -0
- package/dist/ui/form/buttons/SubscribeButton.d.ts +5 -0
- package/dist/ui/form/buttons/SubscribeButton.js +16 -0
- package/dist/ui/form/buttons/index.d.ts +4 -0
- package/dist/ui/form/buttons/index.js +4 -0
- package/dist/ui/form/context.d.ts +83 -0
- package/dist/ui/form/context.js +26 -0
- package/dist/ui/form/fields/JsonField.d.ts +2 -0
- package/dist/ui/form/fields/JsonField.js +13 -0
- package/dist/ui/form/fields/MultiSelectField.d.ts +2 -0
- package/dist/ui/form/fields/MultiSelectField.js +15 -0
- package/dist/ui/form/fields/NumberField.d.ts +2 -0
- package/dist/ui/form/fields/NumberField.js +15 -0
- package/dist/ui/form/fields/PassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/PassowrdField.js +18 -0
- package/dist/ui/form/fields/SelectField.d.ts +2 -0
- package/dist/ui/form/fields/SelectField.js +15 -0
- package/dist/ui/form/fields/SwitchField.d.ts +2 -0
- package/dist/ui/form/fields/SwitchField.js +15 -0
- package/dist/ui/form/fields/TextField.d.ts +2 -0
- package/dist/ui/form/fields/TextField.js +15 -0
- package/dist/ui/form/fields/TextPassowrdField.d.ts +2 -0
- package/dist/ui/form/fields/TextPassowrdField.js +29 -0
- package/dist/ui/form/fields/TextareaField.d.ts +2 -0
- package/dist/ui/form/fields/TextareaField.js +15 -0
- package/dist/ui/form/fields/index.d.ts +9 -0
- package/dist/ui/form/fields/index.js +9 -0
- package/dist/ui/form/fieldsSchema.d.ts +12 -0
- package/dist/ui/form/fieldsSchema.js +13 -0
- package/dist/ui/form/index.d.ts +3 -0
- package/dist/ui/form/index.js +4 -0
- package/dist/ui/hoverPaper/HoverPaper.d.ts +6 -0
- package/dist/ui/hoverPaper/HoverPaper.js +15 -0
- package/dist/ui/hoverPaper/index.d.ts +2 -0
- package/dist/ui/hoverPaper/index.js +3 -0
- package/dist/ui/hoverPaper/usePaperHover.d.ts +4 -0
- package/dist/ui/hoverPaper/usePaperHover.js +9 -0
- package/dist/ui/index.d.ts +9 -0
- package/dist/ui/index.js +9 -0
- package/dist/ui/saveInput/JsonInput.d.ts +6 -0
- package/dist/ui/saveInput/JsonInput.js +34 -0
- package/dist/ui/saveInput/NumberInput.d.ts +6 -0
- package/dist/ui/saveInput/NumberInput.js +27 -0
- package/dist/ui/saveInput/SaveInput.d.ts +36 -0
- package/dist/ui/saveInput/SaveInput.js +15 -0
- package/dist/ui/saveInput/Select.d.ts +6 -0
- package/dist/ui/saveInput/Select.js +27 -0
- package/dist/ui/saveInput/Switch.d.ts +6 -0
- package/dist/ui/saveInput/Switch.js +30 -0
- package/dist/ui/saveInput/TextInput.d.ts +6 -0
- package/dist/ui/saveInput/TextInput.js +26 -0
- package/dist/ui/saveInput/Textarea.d.ts +6 -0
- package/dist/ui/saveInput/Textarea.js +26 -0
- package/dist/ui/saveInput/index.d.ts +1 -0
- package/dist/ui/saveInput/index.js +2 -0
- package/dist/ui/scrollArea/ScrollArea.d.ts +62 -0
- package/dist/ui/scrollArea/ScrollArea.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +5 -0
- package/dist/ui/scrollArea/ScrollAreaButton.js +30 -0
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +6 -0
- package/dist/ui/scrollArea/ScrollAreaContent.js +29 -0
- package/dist/ui/scrollArea/context.d.ts +28 -0
- package/dist/ui/scrollArea/context.js +10 -0
- package/dist/ui/scrollArea/index.d.ts +3 -0
- package/dist/ui/scrollArea/index.js +3 -0
- package/dist/ui/scrollArea/types.d.ts +65 -0
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +9 -0
- package/dist/ui/scrollArea/useScrollArea.js +146 -0
- package/package.json +1 -1
- package/dist/TestIcon.d.ts +0 -1
- package/dist/TestIcon.js +0 -4
package/dist/ai/index.js
ADDED
|
@@ -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,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,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,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,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,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,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 };
|
|
File without changes
|
|
@@ -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,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,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,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,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,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,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,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
|
+
};
|