@rolder/kit 3.0.0-alpha.6 → 3.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/rslib.config.ts +21 -0
- package/src/ai/ui/conversation/ConversationContext.ts +21 -0
- package/src/ai/ui/conversation/ConversationProvider.tsx +21 -0
- package/src/ai/ui/conversation/Empty.tsx +15 -0
- package/src/ai/ui/conversation/File.tsx +40 -0
- package/src/ai/ui/conversation/FileIcon.tsx +143 -0
- package/src/ai/ui/conversation/Loader.tsx +8 -0
- package/src/ai/ui/conversation/Message.tsx +34 -0
- package/src/ai/ui/conversation/Root.tsx +24 -0
- package/src/ai/ui/conversation/index.ts +16 -0
- package/{dist/ai/ui/conversation/types.d.ts → src/ai/ui/conversation/types.ts} +5 -4
- package/src/ai/ui/conversation/useChatMessage.ts +13 -0
- package/src/ai/ui/promptInput/File.tsx +98 -0
- package/src/ai/ui/promptInput/FileIcon.tsx +149 -0
- package/src/ai/ui/promptInput/Footer.tsx +5 -0
- package/src/ai/ui/promptInput/PromptInputContext.ts +24 -0
- package/src/ai/ui/promptInput/PromptInputProvider.tsx +54 -0
- package/src/ai/ui/promptInput/Root.tsx +29 -0
- package/src/ai/ui/promptInput/Submit.tsx +39 -0
- package/src/ai/ui/promptInput/Textarea.tsx +39 -0
- package/src/ai/ui/promptInput/index.ts +15 -0
- package/src/ai/ui/promptInput/types.ts +9 -0
- package/src/ai/utils/convertFileUIPartBlobToDataURL.ts +29 -0
- package/src/ai/utils/parseAiMessagePart.ts +19 -0
- package/src/app/AppDefaults.tsx +21 -0
- package/src/app/DefaultApp.tsx +50 -0
- package/src/app/cookieColorSchemeManager.ts +70 -0
- package/src/app/defaultRequestMiddlewares.ts +22 -0
- package/src/app/defaultTheme.ts +22 -0
- package/src/functions/getCookie.ts +36 -0
- package/src/functions/setCookie.ts +29 -0
- package/src/functions/setCookies.ts +24 -0
- package/src/hooks/useMutation.ts +14 -0
- package/src/hooks/useMutationWithInvalidate.ts +23 -0
- package/{dist/index.d.ts → src/index.ts} +45 -5
- package/{dist → src}/styles.css +21 -11
- package/src/surreal/connection.ts +72 -0
- package/src/surreal/deafaultCrud.ts +25 -0
- package/src/surreal/deserialize.ts +144 -0
- package/src/surreal/encryption.ts +51 -0
- package/src/ui/AnimatedChevron.tsx +32 -0
- package/src/ui/JsonInput.tsx +52 -0
- package/src/ui/RouterLink.tsx +78 -0
- package/src/ui/editor/Content.tsx +11 -0
- package/src/ui/editor/Provider.tsx +96 -0
- package/src/ui/editor/Root.tsx +25 -0
- package/src/ui/editor/Toolbar.tsx +92 -0
- package/src/ui/editor/index.ts +13 -0
- package/src/ui/editor/types.ts +7 -0
- package/src/ui/error/DefaultError.tsx +60 -0
- package/src/ui/error/DefaultNotFound.tsx +19 -0
- package/src/ui/error/Forbidden.tsx +18 -0
- package/src/ui/error/defaultErrorNotification.ts +9 -0
- package/src/ui/form/blurOnError.ts +21 -0
- package/src/ui/form/buttons/CancelButton.tsx +42 -0
- package/src/ui/form/buttons/SubmitButton.tsx +43 -0
- package/src/ui/form/buttons/SubscribeActionIcon.tsx +18 -0
- package/src/ui/form/buttons/SubscribeButton.tsx +17 -0
- package/src/ui/form/context.ts +45 -0
- package/src/ui/form/fields/JsonField.tsx +16 -0
- package/src/ui/form/fields/MultiSelectField.tsx +17 -0
- package/src/ui/form/fields/NumberField.tsx +17 -0
- package/src/ui/form/fields/PassowrdField.tsx +20 -0
- package/src/ui/form/fields/SelectField.tsx +17 -0
- package/src/ui/form/fields/SwitchField.tsx +17 -0
- package/src/ui/form/fields/TextField.tsx +17 -0
- package/src/ui/form/fields/TextPassowrdField.tsx +51 -0
- package/src/ui/form/fields/TextareaField.tsx +17 -0
- package/src/ui/form/fieldsSchema.ts +24 -0
- package/src/ui/hoverPaper/HoverPaper.tsx +17 -0
- package/src/ui/hoverPaper/usePaperHover.ts +9 -0
- package/src/ui/saveInput/JsonInput.tsx +40 -0
- package/src/ui/saveInput/NumberInput.tsx +40 -0
- package/src/ui/saveInput/SaveInput.tsx +15 -0
- package/src/ui/saveInput/Select.tsx +41 -0
- package/src/ui/saveInput/Switch.tsx +46 -0
- package/src/ui/saveInput/TextInput.tsx +40 -0
- package/src/ui/saveInput/Textarea.tsx +40 -0
- package/src/ui/scrollArea/ARCH.md +204 -0
- package/src/ui/scrollArea/README.md +369 -0
- package/{dist/ui/scrollArea/ScrollArea.d.ts → src/ui/scrollArea/ScrollArea.tsx} +41 -10
- package/src/ui/scrollArea/ScrollAreaButton.tsx +56 -0
- package/src/ui/scrollArea/ScrollAreaContent.tsx +36 -0
- package/{dist/ui/scrollArea/context.d.ts → src/ui/scrollArea/context.tsx} +18 -3
- package/src/ui/scrollArea/index.ts +10 -0
- package/src/ui/scrollArea/types.ts +77 -0
- package/src/ui/scrollArea/useScrollArea.ts +227 -0
- package/tsconfig.json +14 -0
- package/dist/ai/ui/conversation/ConversationContext.d.ts +0 -7
- package/dist/ai/ui/conversation/ConversationContext.js +0 -8
- package/dist/ai/ui/conversation/ConversationProvider.d.ts +0 -2
- package/dist/ai/ui/conversation/ConversationProvider.js +0 -14
- package/dist/ai/ui/conversation/Empty.d.ts +0 -1
- package/dist/ai/ui/conversation/Empty.js +0 -21
- package/dist/ai/ui/conversation/File.d.ts +0 -4
- package/dist/ai/ui/conversation/File.js +0 -42
- package/dist/ai/ui/conversation/FileIcon.d.ts +0 -3
- package/dist/ai/ui/conversation/FileIcon.js +0 -225
- package/dist/ai/ui/conversation/Loader.d.ts +0 -2
- package/dist/ai/ui/conversation/Loader.js +0 -12
- package/dist/ai/ui/conversation/Message.d.ts +0 -4
- package/dist/ai/ui/conversation/Message.js +0 -25
- package/dist/ai/ui/conversation/Root.d.ts +0 -2
- package/dist/ai/ui/conversation/Root.js +0 -26
- package/dist/ai/ui/conversation/index.d.ts +0 -13
- package/dist/ai/ui/conversation/index.js +0 -14
- package/dist/ai/ui/conversation/types.js +0 -0
- package/dist/ai/ui/conversation/useChatMessage.d.ts +0 -2
- package/dist/ai/ui/conversation/useChatMessage.js +0 -12
- package/dist/ai/ui/promptInput/File.d.ts +0 -2
- package/dist/ai/ui/promptInput/File.js +0 -117
- package/dist/ai/ui/promptInput/FileIcon.d.ts +0 -3
- package/dist/ai/ui/promptInput/FileIcon.js +0 -225
- package/dist/ai/ui/promptInput/Footer.d.ts +0 -2
- package/dist/ai/ui/promptInput/Footer.js +0 -8
- package/dist/ai/ui/promptInput/PromptInputContext.d.ts +0 -12
- package/dist/ai/ui/promptInput/PromptInputContext.js +0 -8
- package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +0 -2
- package/dist/ai/ui/promptInput/PromptInputProvider.js +0 -50
- package/dist/ai/ui/promptInput/Root.d.ts +0 -3
- package/dist/ai/ui/promptInput/Root.js +0 -17
- package/dist/ai/ui/promptInput/Submit.d.ts +0 -2
- package/dist/ai/ui/promptInput/Submit.js +0 -40
- package/dist/ai/ui/promptInput/Textarea.d.ts +0 -2
- package/dist/ai/ui/promptInput/Textarea.js +0 -33
- package/dist/ai/ui/promptInput/index.d.ts +0 -8
- package/dist/ai/ui/promptInput/index.js +0 -13
- package/dist/ai/ui/promptInput/types.d.ts +0 -11
- package/dist/ai/ui/promptInput/types.js +0 -0
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.d.ts +0 -5
- package/dist/ai/utils/convertFileUIPartBlobToDataURL.js +0 -21
- package/dist/ai/utils/parseAiMessagePart.d.ts +0 -2
- package/dist/ai/utils/parseAiMessagePart.js +0 -12
- package/dist/app/AppDefaults.d.ts +0 -3
- package/dist/app/AppDefaults.js +0 -27
- package/dist/app/DefaultApp.d.ts +0 -6
- package/dist/app/DefaultApp.js +0 -43
- package/dist/app/cookieColorSchemeManager.d.ts +0 -6
- package/dist/app/cookieColorSchemeManager.js +0 -46
- package/dist/app/defaultRequestMiddlewares.d.ts +0 -4
- package/dist/app/defaultRequestMiddlewares.js +0 -24
- package/dist/app/defaultTheme.d.ts +0 -141
- package/dist/app/defaultTheme.js +0 -24
- package/dist/functions/getCookie.d.ts +0 -3
- package/dist/functions/getCookie.js +0 -8
- package/dist/functions/setCookie.d.ts +0 -10
- package/dist/functions/setCookie.js +0 -19
- package/dist/functions/setCookies.d.ts +0 -14
- package/dist/functions/setCookies.js +0 -13
- package/dist/hooks/useMutation.d.ts +0 -4
- package/dist/hooks/useMutation.js +0 -8
- package/dist/hooks/useMutationWithInvalidate.d.ts +0 -4
- package/dist/hooks/useMutationWithInvalidate.js +0 -16
- package/dist/index.js +0 -26
- package/dist/surreal/connection.d.ts +0 -9
- package/dist/surreal/connection.js +0 -49
- package/dist/surreal/deafaultCrud.d.ts +0 -2
- package/dist/surreal/deafaultCrud.js +0 -18
- package/dist/surreal/deserialize.d.ts +0 -17
- package/dist/surreal/deserialize.js +0 -46
- package/dist/surreal/encryption.d.ts +0 -6
- package/dist/surreal/encryption.js +0 -30
- package/dist/ui/AnimatedChevron.d.ts +0 -6
- package/dist/ui/AnimatedChevron.js +0 -31
- package/dist/ui/JsonInput.d.ts +0 -2
- package/dist/ui/JsonInput.js +0 -45
- package/dist/ui/RouterLink.d.ts +0 -16
- package/dist/ui/RouterLink.js +0 -36
- package/dist/ui/editor/Content.d.ts +0 -3
- package/dist/ui/editor/Content.js +0 -13
- package/dist/ui/editor/Provider.d.ts +0 -17
- package/dist/ui/editor/Provider.js +0 -80
- package/dist/ui/editor/Root.d.ts +0 -2
- package/dist/ui/editor/Root.js +0 -18
- package/dist/ui/editor/Toolbar.d.ts +0 -5
- package/dist/ui/editor/Toolbar.js +0 -156
- package/dist/ui/editor/index.d.ts +0 -12
- package/dist/ui/editor/index.js +0 -11
- package/dist/ui/editor/types.d.ts +0 -7
- package/dist/ui/editor/types.js +0 -0
- package/dist/ui/error/DefaultError.d.ts +0 -2
- package/dist/ui/error/DefaultError.js +0 -62
- package/dist/ui/error/DefaultNotFound.d.ts +0 -1
- package/dist/ui/error/DefaultNotFound.js +0 -37
- package/dist/ui/error/Forbidden.d.ts +0 -1
- package/dist/ui/error/Forbidden.js +0 -32
- package/dist/ui/error/defaultErrorNotification.d.ts +0 -1
- package/dist/ui/error/defaultErrorNotification.js +0 -8
- package/dist/ui/error/index.js +0 -5
- package/dist/ui/form/blurOnError.d.ts +0 -4
- package/dist/ui/form/blurOnError.js +0 -11
- package/dist/ui/form/buttons/CancelButton.d.ts +0 -5
- package/dist/ui/form/buttons/CancelButton.js +0 -44
- package/dist/ui/form/buttons/SubmitButton.d.ts +0 -5
- package/dist/ui/form/buttons/SubmitButton.js +0 -47
- package/dist/ui/form/buttons/SubscribeActionIcon.d.ts +0 -4
- package/dist/ui/form/buttons/SubscribeActionIcon.js +0 -15
- package/dist/ui/form/buttons/SubscribeButton.d.ts +0 -5
- package/dist/ui/form/buttons/SubscribeButton.js +0 -16
- package/dist/ui/form/buttons/index.js +0 -4
- package/dist/ui/form/context.d.ts +0 -83
- package/dist/ui/form/context.js +0 -26
- package/dist/ui/form/fields/JsonField.d.ts +0 -2
- package/dist/ui/form/fields/JsonField.js +0 -13
- package/dist/ui/form/fields/MultiSelectField.d.ts +0 -2
- package/dist/ui/form/fields/MultiSelectField.js +0 -15
- package/dist/ui/form/fields/NumberField.d.ts +0 -2
- package/dist/ui/form/fields/NumberField.js +0 -15
- package/dist/ui/form/fields/PassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/PassowrdField.js +0 -18
- package/dist/ui/form/fields/SelectField.d.ts +0 -2
- package/dist/ui/form/fields/SelectField.js +0 -15
- package/dist/ui/form/fields/SwitchField.d.ts +0 -2
- package/dist/ui/form/fields/SwitchField.js +0 -15
- package/dist/ui/form/fields/TextField.d.ts +0 -2
- package/dist/ui/form/fields/TextField.js +0 -15
- package/dist/ui/form/fields/TextPassowrdField.d.ts +0 -2
- package/dist/ui/form/fields/TextPassowrdField.js +0 -51
- package/dist/ui/form/fields/TextareaField.d.ts +0 -2
- package/dist/ui/form/fields/TextareaField.js +0 -15
- package/dist/ui/form/fields/index.js +0 -9
- package/dist/ui/form/fieldsSchema.d.ts +0 -12
- package/dist/ui/form/fieldsSchema.js +0 -13
- package/dist/ui/form/index.js +0 -4
- package/dist/ui/hoverPaper/HoverPaper.d.ts +0 -6
- package/dist/ui/hoverPaper/HoverPaper.js +0 -15
- package/dist/ui/hoverPaper/index.js +0 -3
- package/dist/ui/hoverPaper/usePaperHover.d.ts +0 -4
- package/dist/ui/hoverPaper/usePaperHover.js +0 -9
- package/dist/ui/saveInput/JsonInput.d.ts +0 -6
- package/dist/ui/saveInput/JsonInput.js +0 -34
- package/dist/ui/saveInput/NumberInput.d.ts +0 -6
- package/dist/ui/saveInput/NumberInput.js +0 -27
- package/dist/ui/saveInput/SaveInput.d.ts +0 -36
- package/dist/ui/saveInput/SaveInput.js +0 -15
- package/dist/ui/saveInput/Select.d.ts +0 -6
- package/dist/ui/saveInput/Select.js +0 -27
- package/dist/ui/saveInput/Switch.d.ts +0 -6
- package/dist/ui/saveInput/Switch.js +0 -30
- package/dist/ui/saveInput/TextInput.d.ts +0 -6
- package/dist/ui/saveInput/TextInput.js +0 -26
- package/dist/ui/saveInput/Textarea.d.ts +0 -6
- package/dist/ui/saveInput/Textarea.js +0 -26
- package/dist/ui/saveInput/index.js +0 -2
- package/dist/ui/scrollArea/ScrollArea.js +0 -30
- package/dist/ui/scrollArea/ScrollAreaButton.d.ts +0 -5
- package/dist/ui/scrollArea/ScrollAreaButton.js +0 -51
- package/dist/ui/scrollArea/ScrollAreaContent.d.ts +0 -6
- package/dist/ui/scrollArea/ScrollAreaContent.js +0 -29
- package/dist/ui/scrollArea/context.js +0 -10
- package/dist/ui/scrollArea/index.d.ts +0 -3
- package/dist/ui/scrollArea/index.js +0 -3
- package/dist/ui/scrollArea/types.d.ts +0 -65
- package/dist/ui/scrollArea/types.js +0 -0
- package/dist/ui/scrollArea/useScrollArea.d.ts +0 -9
- package/dist/ui/scrollArea/useScrollArea.js +0 -146
- /package/{dist/ui/error/index.d.ts → src/ui/error/index.ts} +0 -0
- /package/{dist/ui/form/buttons/index.d.ts → src/ui/form/buttons/index.ts} +0 -0
- /package/{dist/ui/form/fields/index.d.ts → src/ui/form/fields/index.ts} +0 -0
- /package/{dist/ui/form/index.d.ts → src/ui/form/index.ts} +0 -0
- /package/{dist/ui/hoverPaper/index.d.ts → src/ui/hoverPaper/index.ts} +0 -0
- /package/{dist/ui/saveInput/index.d.ts → src/ui/saveInput/index.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolder/kit",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"./styles.css": "./styles.css"
|
|
11
11
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"*.css"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rslib build",
|
package/rslib.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { pluginReact } from '@rsbuild/plugin-react';
|
|
2
|
+
import { defineConfig } from '@rslib/core';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
source: {
|
|
6
|
+
entry: {
|
|
7
|
+
index: ['./src/**/*.{ts,tsx,js,jsx,css}'],
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
lib: [
|
|
11
|
+
{
|
|
12
|
+
bundle: false,
|
|
13
|
+
dts: true,
|
|
14
|
+
format: 'esm',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
output: {
|
|
18
|
+
target: 'web',
|
|
19
|
+
},
|
|
20
|
+
plugins: [pluginReact()],
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface ConversationContext {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
streaming: boolean;
|
|
6
|
+
empty: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ConversationContext = createContext<ConversationContext | null>(
|
|
10
|
+
null,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const useConversation = () => {
|
|
14
|
+
const context = useContext(ConversationContext);
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
'useConversation must be used within a ConversationProvider',
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConversationContext } from './ConversationContext';
|
|
2
|
+
import type { ConversationProps } from './types';
|
|
3
|
+
|
|
4
|
+
export const Provider = ({
|
|
5
|
+
children,
|
|
6
|
+
loading,
|
|
7
|
+
streaming,
|
|
8
|
+
empty,
|
|
9
|
+
}: ConversationProps) => {
|
|
10
|
+
const value: ConversationContext = {
|
|
11
|
+
loading,
|
|
12
|
+
streaming,
|
|
13
|
+
empty,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ConversationContext.Provider value={value}>
|
|
18
|
+
{children}
|
|
19
|
+
</ConversationContext.Provider>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Stack, Text } from '@mantine/core';
|
|
2
|
+
import { useConversation } from './ConversationContext';
|
|
3
|
+
|
|
4
|
+
export const Empty = () => {
|
|
5
|
+
const { empty } = useConversation();
|
|
6
|
+
|
|
7
|
+
return !empty ? (
|
|
8
|
+
<Stack align="center" gap={0}>
|
|
9
|
+
<Text>Нет сообщений</Text>
|
|
10
|
+
<Text size="sm" c="dimmed">
|
|
11
|
+
Начните общение, чтобы увидеть сообщения здесь
|
|
12
|
+
</Text>
|
|
13
|
+
</Stack>
|
|
14
|
+
) : null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Image, Paper } from '@mantine/core';
|
|
2
|
+
import type { UIMessage } from 'ai';
|
|
3
|
+
import { FileIcon } from './FileIcon';
|
|
4
|
+
|
|
5
|
+
export const File = <T extends UIMessage>({ message }: { message: T }) => {
|
|
6
|
+
const textFileType = message.id.split('-')[1];
|
|
7
|
+
|
|
8
|
+
const fileParts = message.parts?.filter((i) => i.type === 'file');
|
|
9
|
+
const lastFilePart = fileParts[fileParts.length - 1];
|
|
10
|
+
|
|
11
|
+
const FileComponent = () => {
|
|
12
|
+
switch (textFileType) {
|
|
13
|
+
case 'excel':
|
|
14
|
+
return <FileIcon mimeType="excel" />;
|
|
15
|
+
case 'word':
|
|
16
|
+
return <FileIcon mimeType="word" />;
|
|
17
|
+
case 'powerpoint':
|
|
18
|
+
return <FileIcon mimeType="powerpoint" />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (lastFilePart.mediaType.includes('image/'))
|
|
22
|
+
return (
|
|
23
|
+
<Image radius="md" h={128} src={lastFilePart.url} alt="Image Preview" />
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return <FileIcon mimeType={lastFilePart.mediaType} />;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return textFileType || lastFilePart ? (
|
|
30
|
+
<Paper
|
|
31
|
+
radius="md"
|
|
32
|
+
px="md"
|
|
33
|
+
py="sm"
|
|
34
|
+
ml="auto"
|
|
35
|
+
bg="var(--mantine-color-default-hover)"
|
|
36
|
+
>
|
|
37
|
+
<FileComponent />
|
|
38
|
+
</Paper>
|
|
39
|
+
) : null;
|
|
40
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
export const FileIcon = ({ mimeType }: { mimeType: string }) => {
|
|
2
|
+
switch (true) {
|
|
3
|
+
case mimeType.includes('image/'):
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="36"
|
|
8
|
+
height="36"
|
|
9
|
+
viewBox="0 0 36 36"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke="var(--mantine-color-text)"
|
|
12
|
+
strokeWidth="1.5"
|
|
13
|
+
strokeLinecap="round"
|
|
14
|
+
strokeLinejoin="round"
|
|
15
|
+
role="img"
|
|
16
|
+
aria-label="Image"
|
|
17
|
+
>
|
|
18
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
19
|
+
<path d="M15 8h.01" />
|
|
20
|
+
<path d="M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12" />
|
|
21
|
+
<path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5" />
|
|
22
|
+
<path d="M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3" />
|
|
23
|
+
</svg>
|
|
24
|
+
);
|
|
25
|
+
case mimeType.includes('application/pdf'):
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
width="36"
|
|
30
|
+
height="36"
|
|
31
|
+
viewBox="0 0 36 36"
|
|
32
|
+
fill="none"
|
|
33
|
+
stroke="var(--mantine-color-text)"
|
|
34
|
+
strokeWidth="1.5"
|
|
35
|
+
strokeLinecap="round"
|
|
36
|
+
strokeLinejoin="round"
|
|
37
|
+
role="img"
|
|
38
|
+
aria-label="FilePdf"
|
|
39
|
+
>
|
|
40
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
41
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
42
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
43
|
+
<path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
44
|
+
<path d="M17 18h2" />
|
|
45
|
+
<path d="M20 15h-3v6" />
|
|
46
|
+
<path d="M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" />
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
case mimeType === 'word':
|
|
50
|
+
return (
|
|
51
|
+
<svg
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
width="36"
|
|
54
|
+
height="36"
|
|
55
|
+
viewBox="0 0 36 36"
|
|
56
|
+
fill="none"
|
|
57
|
+
stroke="var(--mantine-color-text)"
|
|
58
|
+
strokeWidth="1.5"
|
|
59
|
+
strokeLinecap="round"
|
|
60
|
+
strokeLinejoin="round"
|
|
61
|
+
role="img"
|
|
62
|
+
aria-label="FileDoc"
|
|
63
|
+
>
|
|
64
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
65
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
66
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
67
|
+
<path d="M5 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" />
|
|
68
|
+
<path d="M20 16.5a1.5 1.5 0 0 0 -3 0v3a1.5 1.5 0 0 0 3 0" />
|
|
69
|
+
<path d="M12.5 15a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -3 0v-3a1.5 1.5 0 0 1 1.5 -1.5" />
|
|
70
|
+
</svg>
|
|
71
|
+
);
|
|
72
|
+
case mimeType === 'excel':
|
|
73
|
+
return (
|
|
74
|
+
<svg
|
|
75
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
76
|
+
width="36"
|
|
77
|
+
height="36"
|
|
78
|
+
viewBox="0 0 36 36"
|
|
79
|
+
fill="none"
|
|
80
|
+
stroke="var(--mantine-color-text)"
|
|
81
|
+
strokeWidth="1.5"
|
|
82
|
+
strokeLinecap="round"
|
|
83
|
+
strokeLinejoin="round"
|
|
84
|
+
role="img"
|
|
85
|
+
aria-label="FileXls"
|
|
86
|
+
>
|
|
87
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
88
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
89
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
90
|
+
<path d="M4 15l4 6" />
|
|
91
|
+
<path d="M4 21l4 -6" />
|
|
92
|
+
<path d="M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75" />
|
|
93
|
+
<path d="M11 15v6h3" />
|
|
94
|
+
</svg>
|
|
95
|
+
);
|
|
96
|
+
case mimeType === 'powerpoint':
|
|
97
|
+
return (
|
|
98
|
+
<svg
|
|
99
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
100
|
+
width="36"
|
|
101
|
+
height="36"
|
|
102
|
+
viewBox="0 0 36 36"
|
|
103
|
+
fill="none"
|
|
104
|
+
stroke="var(--mantine-color-text)"
|
|
105
|
+
strokeWidth="1.5"
|
|
106
|
+
strokeLinecap="round"
|
|
107
|
+
strokeLinejoin="round"
|
|
108
|
+
role="img"
|
|
109
|
+
aria-label="FilePpt"
|
|
110
|
+
>
|
|
111
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
112
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
113
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
114
|
+
<path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
115
|
+
<path d="M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
116
|
+
<path d="M16.5 15h3" />
|
|
117
|
+
<path d="M18 15v6" />
|
|
118
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
119
|
+
</svg>
|
|
120
|
+
);
|
|
121
|
+
default:
|
|
122
|
+
return (
|
|
123
|
+
<svg
|
|
124
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
125
|
+
width="36"
|
|
126
|
+
height="36"
|
|
127
|
+
viewBox="0 0 36 36"
|
|
128
|
+
fill="none"
|
|
129
|
+
stroke="var(--mantine-color-text)"
|
|
130
|
+
strokeWidth="1.5"
|
|
131
|
+
strokeLinecap="round"
|
|
132
|
+
strokeLinejoin="round"
|
|
133
|
+
role="img"
|
|
134
|
+
aria-label="File"
|
|
135
|
+
>
|
|
136
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
137
|
+
<path d="M15 3v4a1 1 0 0 0 1 1h4" />
|
|
138
|
+
<path d="M18 17h-7a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h4l5 5v7a2 2 0 0 1 -2 2" />
|
|
139
|
+
<path d="M16 17v2a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2" />
|
|
140
|
+
</svg>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LoaderProps, Loader as MantineLoader } from '@mantine/core';
|
|
2
|
+
import { useConversation } from './ConversationContext';
|
|
3
|
+
|
|
4
|
+
export const Loader = (props: LoaderProps) => {
|
|
5
|
+
const { loading } = useConversation();
|
|
6
|
+
|
|
7
|
+
return loading ? <MantineLoader size={28} type="dots" {...props} /> : null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Paper } from '@mantine/core';
|
|
2
|
+
import type { UIMessage } from 'ai';
|
|
3
|
+
import { Streamdown } from 'streamdown';
|
|
4
|
+
import { useConversation } from './ConversationContext';
|
|
5
|
+
import { useChatMessage } from './useChatMessage';
|
|
6
|
+
|
|
7
|
+
export const Message = <T extends UIMessage>({ message }: { message: T }) => {
|
|
8
|
+
const textParts = message?.parts?.filter((i) => i.type === 'text');
|
|
9
|
+
const lastTextPart = textParts?.[textParts.length - 1];
|
|
10
|
+
|
|
11
|
+
const chatMessage = useChatMessage(lastTextPart);
|
|
12
|
+
|
|
13
|
+
const { streaming } = useConversation();
|
|
14
|
+
|
|
15
|
+
return chatMessage && message.role !== 'system' ? (
|
|
16
|
+
<Paper
|
|
17
|
+
radius="md"
|
|
18
|
+
px="md"
|
|
19
|
+
py="sm"
|
|
20
|
+
maw="80%"
|
|
21
|
+
ml={message.role === 'user' ? 'auto' : undefined}
|
|
22
|
+
bg={
|
|
23
|
+
message.role === 'user'
|
|
24
|
+
? 'var(--mantine-color-default-hover)'
|
|
25
|
+
: 'var(--mantine-primary-color-light)'
|
|
26
|
+
}
|
|
27
|
+
fz="sm"
|
|
28
|
+
>
|
|
29
|
+
<Streamdown isAnimating={streaming && message.role === 'assistant'}>
|
|
30
|
+
{chatMessage}
|
|
31
|
+
</Streamdown>
|
|
32
|
+
</Paper>
|
|
33
|
+
) : null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Paper, Stack } from '@mantine/core';
|
|
2
|
+
import { ScrollArea } from '../../../ui/scrollArea';
|
|
3
|
+
import { Provider } from './ConversationProvider';
|
|
4
|
+
import type { ConversationProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const Root = ({
|
|
7
|
+
children,
|
|
8
|
+
loading,
|
|
9
|
+
streaming,
|
|
10
|
+
empty,
|
|
11
|
+
...props
|
|
12
|
+
}: ConversationProps) => {
|
|
13
|
+
return (
|
|
14
|
+
<Provider loading={loading} streaming={streaming} empty={empty}>
|
|
15
|
+
<Paper withBorder radius="md" {...props}>
|
|
16
|
+
<ScrollArea autoScroll scrollToBottomOnInit p="md">
|
|
17
|
+
<Stack>{children}</Stack>
|
|
18
|
+
|
|
19
|
+
<ScrollArea.ScrollButton />
|
|
20
|
+
</ScrollArea>
|
|
21
|
+
</Paper>
|
|
22
|
+
</Provider>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Empty } from './Empty';
|
|
2
|
+
import { File } from './File';
|
|
3
|
+
import { Loader } from './Loader';
|
|
4
|
+
import { Message } from './Message';
|
|
5
|
+
import { Root } from './Root';
|
|
6
|
+
|
|
7
|
+
export type { ConversationProps } from './types';
|
|
8
|
+
export { useChatMessage } from './useChatMessage';
|
|
9
|
+
|
|
10
|
+
export const Conversation = {
|
|
11
|
+
Root,
|
|
12
|
+
Message,
|
|
13
|
+
File,
|
|
14
|
+
Loader,
|
|
15
|
+
Empty,
|
|
16
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { PaperProps } from '@mantine/core';
|
|
2
|
+
|
|
2
3
|
export interface ConversationProps extends PaperProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
streaming: boolean;
|
|
7
|
+
empty: boolean;
|
|
7
8
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TextUIPart } from 'ai';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { parseAiMessagePart } from '../../utils/parseAiMessagePart';
|
|
4
|
+
|
|
5
|
+
export const useChatMessage = (part: TextUIPart) => {
|
|
6
|
+
const [parsedText, setParsedText] = useState('');
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
parseAiMessagePart(part).then((i) => setParsedText(i.text));
|
|
10
|
+
}, [part]);
|
|
11
|
+
|
|
12
|
+
return parsedText;
|
|
13
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ActionIcon,
|
|
3
|
+
FileButton,
|
|
4
|
+
type FileButtonProps,
|
|
5
|
+
Tooltip,
|
|
6
|
+
} from '@mantine/core';
|
|
7
|
+
import { useRef } from 'react';
|
|
8
|
+
import { FileIcon } from './FileIcon';
|
|
9
|
+
import { usePromptInput } from './PromptInputContext';
|
|
10
|
+
|
|
11
|
+
export const File = (props: Omit<FileButtonProps, 'onChange' | 'children'>) => {
|
|
12
|
+
const resetRef = useRef<() => void>(null);
|
|
13
|
+
const { file, setFile, accept, submiting, uploading } = usePromptInput();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<FileButton
|
|
17
|
+
resetRef={resetRef}
|
|
18
|
+
onChange={async (file) => {
|
|
19
|
+
// Проверка для сценария отмены в системном диалоговом окне
|
|
20
|
+
if (file) setFile(file);
|
|
21
|
+
}}
|
|
22
|
+
accept={accept}
|
|
23
|
+
disabled={submiting || uploading}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
{(props) => (
|
|
27
|
+
<ActionIcon.Group>
|
|
28
|
+
<ActionIcon
|
|
29
|
+
size="lg"
|
|
30
|
+
variant="default"
|
|
31
|
+
disabled={submiting}
|
|
32
|
+
loading={uploading}
|
|
33
|
+
classNames={{ root: 'rolder-prompt-input-file-action-action' }}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
<svg
|
|
37
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
38
|
+
width="24"
|
|
39
|
+
height="24"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
fill="none"
|
|
42
|
+
stroke="currentColor"
|
|
43
|
+
strokeWidth="1.5"
|
|
44
|
+
strokeLinecap="round"
|
|
45
|
+
strokeLinejoin="round"
|
|
46
|
+
role="img"
|
|
47
|
+
aria-label="Paperclip"
|
|
48
|
+
>
|
|
49
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
50
|
+
<path d="M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5" />
|
|
51
|
+
</svg>
|
|
52
|
+
</ActionIcon>
|
|
53
|
+
|
|
54
|
+
{file && (
|
|
55
|
+
<>
|
|
56
|
+
<Tooltip label={file.name} openDelay={500}>
|
|
57
|
+
<ActionIcon.GroupSection variant="default" size="lg">
|
|
58
|
+
<FileIcon mimeType={file.type} />
|
|
59
|
+
</ActionIcon.GroupSection>
|
|
60
|
+
</Tooltip>
|
|
61
|
+
|
|
62
|
+
<ActionIcon
|
|
63
|
+
size="lg"
|
|
64
|
+
variant="default"
|
|
65
|
+
classNames={{ root: 'rolder-prompt-input-file-action-action' }}
|
|
66
|
+
onClick={() => {
|
|
67
|
+
resetRef.current?.();
|
|
68
|
+
setFile(undefined);
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<svg
|
|
72
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
73
|
+
width="24"
|
|
74
|
+
height="24"
|
|
75
|
+
viewBox="0 0 24 24"
|
|
76
|
+
fill="none"
|
|
77
|
+
stroke="currentColor"
|
|
78
|
+
strokeWidth="1.5"
|
|
79
|
+
strokeLinecap="round"
|
|
80
|
+
strokeLinejoin="round"
|
|
81
|
+
role="img"
|
|
82
|
+
aria-label="Trash"
|
|
83
|
+
>
|
|
84
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
85
|
+
<path d="M4 7l16 0" />
|
|
86
|
+
<path d="M10 11l0 6" />
|
|
87
|
+
<path d="M14 11l0 6" />
|
|
88
|
+
<path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" />
|
|
89
|
+
<path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" />
|
|
90
|
+
</svg>
|
|
91
|
+
</ActionIcon>
|
|
92
|
+
</>
|
|
93
|
+
)}
|
|
94
|
+
</ActionIcon.Group>
|
|
95
|
+
)}
|
|
96
|
+
</FileButton>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export const FileIcon = ({ mimeType }: { mimeType: string }) => {
|
|
2
|
+
switch (true) {
|
|
3
|
+
case mimeType.includes('image/'):
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
width="24"
|
|
8
|
+
height="24"
|
|
9
|
+
viewBox="0 0 24 24"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke="var(--mantine-color-dimmed)"
|
|
12
|
+
strokeWidth="1.5"
|
|
13
|
+
strokeLinecap="round"
|
|
14
|
+
strokeLinejoin="round"
|
|
15
|
+
role="img"
|
|
16
|
+
aria-label="Image"
|
|
17
|
+
>
|
|
18
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
19
|
+
<path d="M15 8h.01" />
|
|
20
|
+
<path d="M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12" />
|
|
21
|
+
<path d="M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5" />
|
|
22
|
+
<path d="M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3" />
|
|
23
|
+
</svg>
|
|
24
|
+
);
|
|
25
|
+
case mimeType.includes('application/pdf'):
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
width="24"
|
|
30
|
+
height="24"
|
|
31
|
+
viewBox="0 0 24 24"
|
|
32
|
+
fill="none"
|
|
33
|
+
stroke="var(--mantine-color-dimmed)"
|
|
34
|
+
strokeWidth="1.5"
|
|
35
|
+
strokeLinecap="round"
|
|
36
|
+
strokeLinejoin="round"
|
|
37
|
+
role="img"
|
|
38
|
+
aria-label="FilePdf"
|
|
39
|
+
>
|
|
40
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
41
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
42
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
43
|
+
<path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
44
|
+
<path d="M17 18h2" />
|
|
45
|
+
<path d="M20 15h-3v6" />
|
|
46
|
+
<path d="M11 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" />
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
case mimeType.includes(
|
|
50
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
51
|
+
):
|
|
52
|
+
return (
|
|
53
|
+
<svg
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
width="24"
|
|
56
|
+
height="24"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
fill="none"
|
|
59
|
+
stroke="var(--mantine-color-dimmed)"
|
|
60
|
+
strokeWidth="1.5"
|
|
61
|
+
strokeLinecap="round"
|
|
62
|
+
strokeLinejoin="round"
|
|
63
|
+
role="img"
|
|
64
|
+
aria-label="FileDoc"
|
|
65
|
+
>
|
|
66
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
67
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
68
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
69
|
+
<path d="M5 15v6h1a2 2 0 0 0 2 -2v-2a2 2 0 0 0 -2 -2h-1" />
|
|
70
|
+
<path d="M20 16.5a1.5 1.5 0 0 0 -3 0v3a1.5 1.5 0 0 0 3 0" />
|
|
71
|
+
<path d="M12.5 15a1.5 1.5 0 0 1 1.5 1.5v3a1.5 1.5 0 0 1 -3 0v-3a1.5 1.5 0 0 1 1.5 -1.5" />
|
|
72
|
+
</svg>
|
|
73
|
+
);
|
|
74
|
+
case mimeType.includes(
|
|
75
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
76
|
+
):
|
|
77
|
+
return (
|
|
78
|
+
<svg
|
|
79
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
80
|
+
width="24"
|
|
81
|
+
height="24"
|
|
82
|
+
viewBox="0 0 24 24"
|
|
83
|
+
fill="none"
|
|
84
|
+
stroke="var(--mantine-color-dimmed)"
|
|
85
|
+
strokeWidth="1.5"
|
|
86
|
+
strokeLinecap="round"
|
|
87
|
+
strokeLinejoin="round"
|
|
88
|
+
role="img"
|
|
89
|
+
aria-label="FileXls"
|
|
90
|
+
>
|
|
91
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
92
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
93
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
94
|
+
<path d="M4 15l4 6" />
|
|
95
|
+
<path d="M4 21l4 -6" />
|
|
96
|
+
<path d="M17 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75" />
|
|
97
|
+
<path d="M11 15v6h3" />
|
|
98
|
+
</svg>
|
|
99
|
+
);
|
|
100
|
+
case mimeType.includes(
|
|
101
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
102
|
+
):
|
|
103
|
+
return (
|
|
104
|
+
<svg
|
|
105
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
+
width="24"
|
|
107
|
+
height="24"
|
|
108
|
+
viewBox="0 0 24 24"
|
|
109
|
+
fill="none"
|
|
110
|
+
stroke="var(--mantine-color-dimmed)"
|
|
111
|
+
strokeWidth="1.5"
|
|
112
|
+
strokeLinecap="round"
|
|
113
|
+
strokeLinejoin="round"
|
|
114
|
+
role="img"
|
|
115
|
+
aria-label="FilePpt"
|
|
116
|
+
>
|
|
117
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
118
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
119
|
+
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
|
|
120
|
+
<path d="M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
121
|
+
<path d="M11 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6" />
|
|
122
|
+
<path d="M16.5 15h3" />
|
|
123
|
+
<path d="M18 15v6" />
|
|
124
|
+
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
|
|
125
|
+
</svg>
|
|
126
|
+
);
|
|
127
|
+
default:
|
|
128
|
+
return (
|
|
129
|
+
<svg
|
|
130
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
131
|
+
width="24"
|
|
132
|
+
height="24"
|
|
133
|
+
viewBox="0 0 24 24"
|
|
134
|
+
fill="none"
|
|
135
|
+
stroke="var(--mantine-color-dimmed)"
|
|
136
|
+
strokeWidth="1.5"
|
|
137
|
+
strokeLinecap="round"
|
|
138
|
+
strokeLinejoin="round"
|
|
139
|
+
role="img"
|
|
140
|
+
aria-label="File"
|
|
141
|
+
>
|
|
142
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
143
|
+
<path d="M15 3v4a1 1 0 0 0 1 1h4" />
|
|
144
|
+
<path d="M18 17h-7a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h4l5 5v7a2 2 0 0 1 -2 2" />
|
|
145
|
+
<path d="M16 17v2a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2" />
|
|
146
|
+
</svg>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface PromptInputContext {
|
|
4
|
+
text: string;
|
|
5
|
+
setText: (text: string) => void;
|
|
6
|
+
file?: File;
|
|
7
|
+
setFile: (file?: File) => void;
|
|
8
|
+
onSubmit: () => void;
|
|
9
|
+
submiting: boolean;
|
|
10
|
+
uploading: boolean;
|
|
11
|
+
accept?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PromptInputContext = createContext<PromptInputContext | null>(
|
|
15
|
+
null,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export const usePromptInput = () => {
|
|
19
|
+
const context = useContext(PromptInputContext);
|
|
20
|
+
if (!context) {
|
|
21
|
+
throw new Error('usePromptInput must be used within a PromptInputProvider');
|
|
22
|
+
}
|
|
23
|
+
return context;
|
|
24
|
+
};
|