@rolder/kit 3.0.0-alpha.3 → 3.0.0-alpha.31

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 (114) 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 → chat}/Empty.js +4 -3
  4. package/dist/ai/ui/chat/File.d.ts +3 -0
  5. package/dist/ai/ui/{conversation → chat}/File.js +10 -8
  6. package/dist/ai/ui/chat/FileIcon.js +43 -0
  7. package/dist/ai/ui/{conversation → chat}/Loader.js +4 -3
  8. package/dist/ai/ui/chat/Message.d.ts +3 -0
  9. package/dist/ai/ui/chat/Message.js +24 -0
  10. package/dist/ai/ui/chat/Messages.d.ts +2 -0
  11. package/dist/ai/ui/chat/Messages.js +12 -0
  12. package/dist/ai/ui/chat/Root.d.ts +8 -0
  13. package/dist/ai/ui/chat/Root.js +22 -0
  14. package/dist/ai/ui/chat/chatInput/File.js +72 -0
  15. package/dist/ai/ui/chat/chatInput/FileIcon.js +43 -0
  16. package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.js +4 -1
  17. package/dist/ai/ui/chat/chatInput/Root.d.ts +9 -0
  18. package/dist/ai/ui/chat/chatInput/Root.js +25 -0
  19. package/dist/ai/ui/chat/chatInput/Submit.js +24 -0
  20. package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.js +10 -8
  21. package/dist/ai/ui/{promptInput → chat/chatInput}/index.d.ts +2 -3
  22. package/dist/ai/ui/{promptInput → chat/chatInput}/index.js +2 -2
  23. package/dist/ai/ui/chat/chatInput/store.d.ts +13 -0
  24. package/dist/ai/ui/chat/chatInput/store.js +40 -0
  25. package/dist/ai/ui/chat/index.d.ts +13 -0
  26. package/dist/ai/ui/{conversation → chat}/index.js +5 -3
  27. package/dist/ai/ui/chat/store/index.d.ts +2 -0
  28. package/dist/ai/ui/chat/store/index.js +2 -0
  29. package/dist/ai/ui/chat/store/messages.d.ts +17 -0
  30. package/dist/ai/ui/chat/store/messages.js +78 -0
  31. package/dist/ai/ui/chat/store/states.d.ts +11 -0
  32. package/dist/ai/ui/chat/store/states.js +17 -0
  33. package/dist/ai/ui/index.d.ts +1 -0
  34. package/dist/ai/ui/index.js +1 -0
  35. package/dist/ai/utils/index.d.ts +2 -0
  36. package/dist/ai/utils/index.js +2 -0
  37. package/dist/app/defaultTheme.d.ts +1 -1
  38. package/dist/app/index.d.ts +1 -0
  39. package/dist/app/index.js +1 -0
  40. package/dist/functions/index.d.ts +3 -1
  41. package/dist/functions/index.js +4 -1
  42. package/dist/index.d.ts +1 -5
  43. package/dist/index.js +1 -6
  44. package/dist/styles.css +3 -3
  45. package/dist/ui/AnimatedChevron.d.ts +2 -2
  46. package/dist/ui/AnimatedChevron.js +7 -25
  47. package/dist/ui/editor/Toolbar.js +4 -22
  48. package/dist/ui/error/index.d.ts +4 -4
  49. package/dist/ui/error/index.js +5 -4
  50. package/dist/ui/form/buttons/CancelButton.js +4 -26
  51. package/dist/ui/form/buttons/SubmitButton.js +4 -29
  52. package/dist/ui/form/fields/TextPassowrdField.js +4 -26
  53. package/dist/ui/form/index.d.ts +2 -2
  54. package/dist/ui/form/index.js +3 -3
  55. package/dist/ui/hoverPaper/index.d.ts +2 -2
  56. package/dist/ui/hoverPaper/index.js +3 -2
  57. package/dist/ui/scrollArea/ScrollArea.d.ts +1 -1
  58. package/dist/ui/scrollArea/ScrollAreaButton.d.ts +1 -1
  59. package/dist/ui/scrollArea/ScrollAreaButton.js +7 -28
  60. package/package.json +29 -22
  61. package/dist/ai/ui/conversation/ConversationContext.d.ts +0 -7
  62. package/dist/ai/ui/conversation/ConversationContext.js +0 -8
  63. package/dist/ai/ui/conversation/ConversationProvider.d.ts +0 -2
  64. package/dist/ai/ui/conversation/ConversationProvider.js +0 -14
  65. package/dist/ai/ui/conversation/File.d.ts +0 -4
  66. package/dist/ai/ui/conversation/FileIcon.js +0 -225
  67. package/dist/ai/ui/conversation/Message.d.ts +0 -4
  68. package/dist/ai/ui/conversation/Message.js +0 -25
  69. package/dist/ai/ui/conversation/Root.d.ts +0 -2
  70. package/dist/ai/ui/conversation/Root.js +0 -26
  71. package/dist/ai/ui/conversation/index.d.ts +0 -13
  72. package/dist/ai/ui/conversation/types.d.ts +0 -7
  73. package/dist/ai/ui/conversation/types.js +0 -0
  74. package/dist/ai/ui/conversation/useChatMessage.d.ts +0 -2
  75. package/dist/ai/ui/conversation/useChatMessage.js +0 -12
  76. package/dist/ai/ui/promptInput/File.js +0 -117
  77. package/dist/ai/ui/promptInput/FileIcon.js +0 -225
  78. package/dist/ai/ui/promptInput/PromptInputContext.d.ts +0 -12
  79. package/dist/ai/ui/promptInput/PromptInputContext.js +0 -8
  80. package/dist/ai/ui/promptInput/PromptInputProvider.d.ts +0 -2
  81. package/dist/ai/ui/promptInput/PromptInputProvider.js +0 -50
  82. package/dist/ai/ui/promptInput/Root.d.ts +0 -3
  83. package/dist/ai/ui/promptInput/Root.js +0 -17
  84. package/dist/ai/ui/promptInput/Submit.js +0 -40
  85. package/dist/ai/ui/promptInput/types.d.ts +0 -11
  86. package/dist/ai/ui/promptInput/types.js +0 -0
  87. package/dist/functions/cookies/index.d.ts +0 -3
  88. package/dist/functions/cookies/index.js +0 -3
  89. package/dist/surreal/connection.d.ts +0 -9
  90. package/dist/surreal/connection.js +0 -49
  91. package/dist/surreal/deafaultCrud.d.ts +0 -2
  92. package/dist/surreal/deafaultCrud.js +0 -18
  93. package/dist/surreal/deserialize.d.ts +0 -17
  94. package/dist/surreal/deserialize.js +0 -46
  95. package/dist/surreal/encryption.d.ts +0 -6
  96. package/dist/surreal/encryption.js +0 -30
  97. package/dist/surreal/index.d.ts +0 -4
  98. package/dist/surreal/index.js +0 -5
  99. package/dist/ui/editor/styles.module.js +0 -7
  100. package/dist/ui/editor/styles_module.css +0 -16
  101. /package/dist/ai/ui/{conversation → chat}/Empty.d.ts +0 -0
  102. /package/dist/ai/ui/{conversation → chat}/FileIcon.d.ts +0 -0
  103. /package/dist/ai/ui/{conversation → chat}/Loader.d.ts +0 -0
  104. /package/dist/ai/ui/{promptInput → chat/chatInput}/File.d.ts +0 -0
  105. /package/dist/ai/ui/{promptInput → chat/chatInput}/FileIcon.d.ts +0 -0
  106. /package/dist/ai/ui/{promptInput → chat/chatInput}/Footer.d.ts +0 -0
  107. /package/dist/ai/ui/{promptInput → chat/chatInput}/Submit.d.ts +0 -0
  108. /package/dist/ai/ui/{promptInput → chat/chatInput}/Textarea.d.ts +0 -0
  109. /package/dist/functions/{cookies/getCookie.d.ts → getCookie.d.ts} +0 -0
  110. /package/dist/functions/{cookies/getCookie.js → getCookie.js} +0 -0
  111. /package/dist/functions/{cookies/setCookie.d.ts → setCookie.d.ts} +0 -0
  112. /package/dist/functions/{cookies/setCookie.js → setCookie.js} +0 -0
  113. /package/dist/functions/{cookies/setCookies.d.ts → setCookies.d.ts} +0 -0
  114. /package/dist/functions/{cookies/setCookies.js → setCookies.js} +0 -0
@@ -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";
@@ -1,9 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Stack, Text } from "@mantine/core";
3
- import { useConversation } from "./ConversationContext.js";
3
+ import { useIsEmpty } from "./store/index.js";
4
4
  const Empty = ()=>{
5
- const { empty } = useConversation();
6
- return empty ? null : /*#__PURE__*/ jsxs(Stack, {
5
+ const isEmpty = useIsEmpty();
6
+ console.log('Empty render');
7
+ return isEmpty ? null : /*#__PURE__*/ jsxs(Stack, {
7
8
  align: "center",
8
9
  gap: 0,
9
10
  children: [
@@ -0,0 +1,3 @@
1
+ export declare const File: ({ messageId }: {
2
+ messageId: string;
3
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,10 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Image, Paper } from "@mantine/core";
3
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];
4
+ import { useChatMessagePart } from "./store/index.js";
5
+ const File = ({ messageId })=>{
6
+ const part = useChatMessagePart(messageId, 'file');
7
+ const textFileType = messageId.split('-')[1];
8
+ console.log('File render');
8
9
  const FileComponent = ()=>{
9
10
  switch(textFileType){
10
11
  case 'excel':
@@ -20,17 +21,18 @@ const File = ({ message })=>{
20
21
  mimeType: "powerpoint"
21
22
  });
22
23
  }
23
- if (lastFilePart.mediaType.includes('image/')) return /*#__PURE__*/ jsx(Image, {
24
+ if (!part) return null;
25
+ if (part.mediaType.includes('image/')) return /*#__PURE__*/ jsx(Image, {
24
26
  radius: "md",
25
27
  h: 128,
26
- src: lastFilePart.url,
28
+ src: part.url,
27
29
  alt: "Image Preview"
28
30
  });
29
31
  return /*#__PURE__*/ jsx(FileIcon, {
30
- mimeType: lastFilePart.mediaType
32
+ mimeType: part.mediaType
31
33
  });
32
34
  };
33
- return textFileType || lastFilePart ? /*#__PURE__*/ jsx(Paper, {
35
+ return textFileType || part ? /*#__PURE__*/ jsx(Paper, {
34
36
  radius: "md",
35
37
  px: "md",
36
38
  py: "sm",
@@ -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 };
@@ -1,9 +1,10 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Loader } from "@mantine/core";
3
- import { useConversation } from "./ConversationContext.js";
3
+ import { useIsLoading } from "./store/index.js";
4
4
  const Loader_Loader = (props)=>{
5
- const { loading } = useConversation();
6
- return loading ? /*#__PURE__*/ jsx(Loader, {
5
+ const isLoading = useIsLoading();
6
+ console.log('Loader render');
7
+ return isLoading ? /*#__PURE__*/ jsx(Loader, {
7
8
  size: 28,
8
9
  type: "dots",
9
10
  ...props
@@ -0,0 +1,3 @@
1
+ export declare const Message: ({ messageId }: {
2
+ messageId: string;
3
+ }) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,24 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import { Streamdown } from "streamdown";
4
+ import { useChatMessage, useChatMessagePart, useIsStreaming } from "./store/index.js";
5
+ const Message = ({ messageId })=>{
6
+ const message = useChatMessage(messageId);
7
+ const part = useChatMessagePart(messageId, 'text');
8
+ const isStreaming = useIsStreaming();
9
+ console.log('Message render');
10
+ return part ? /*#__PURE__*/ jsx(Paper, {
11
+ radius: "md",
12
+ px: "md",
13
+ py: "sm",
14
+ maw: "80%",
15
+ ml: 'user' === message.role ? 'auto' : void 0,
16
+ bg: 'user' === message.role ? 'var(--mantine-color-default-hover)' : 'var(--mantine-primary-color-light)',
17
+ fz: "sm",
18
+ children: /*#__PURE__*/ jsx(Streamdown, {
19
+ isAnimating: isStreaming && 'assistant' === message.role,
20
+ children: part?.text
21
+ })
22
+ }) : null;
23
+ };
24
+ export { Message };
@@ -0,0 +1,2 @@
1
+ import { type StackProps } from '@mantine/core';
2
+ export declare const Messages: ({ children, ...props }: StackProps) => import("react/jsx-runtime").JSX.Element[];
@@ -0,0 +1,12 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Stack } from "@mantine/core";
3
+ import { useChatMessageIds } from "./store/index.js";
4
+ const Messages = ({ children, ...props })=>{
5
+ const messageIds = useChatMessageIds();
6
+ console.log('Messages render');
7
+ return messageIds.map((messageId)=>/*#__PURE__*/ jsx(Stack, {
8
+ ...props,
9
+ children: children
10
+ }, messageId));
11
+ };
12
+ export { Messages };
@@ -0,0 +1,8 @@
1
+ import { type PaperProps } from '@mantine/core';
2
+ import { type ScrollAreaProps } from '../../../ui';
3
+ export interface ConversationRootProps extends PaperProps {
4
+ children?: React.ReactNode;
5
+ scrollAreaProps?: ScrollAreaProps;
6
+ withScrollButton?: boolean;
7
+ }
8
+ export declare const Root: ({ children, scrollAreaProps, withScrollButton, ...props }: ConversationRootProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import { ScrollArea } from "../../../ui/index.js";
4
+ const Root = ({ children, scrollAreaProps, withScrollButton = true, ...props })=>{
5
+ console.log('Root render');
6
+ return /*#__PURE__*/ jsx(Paper, {
7
+ withBorder: true,
8
+ radius: "md",
9
+ ...props,
10
+ children: /*#__PURE__*/ jsxs(ScrollArea, {
11
+ autoScroll: true,
12
+ scrollToBottomOnInit: true,
13
+ p: "md",
14
+ ...scrollAreaProps,
15
+ children: [
16
+ children,
17
+ withScrollButton && /*#__PURE__*/ jsx(ScrollArea.ScrollButton, {})
18
+ ]
19
+ })
20
+ });
21
+ };
22
+ export { Root };
@@ -0,0 +1,72 @@
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 { useIsLoading } from "../store/index.js";
6
+ import { FileIcon } from "./FileIcon.js";
7
+ import { getAccept, setFile, useFile, useIsUploading } from "./store.js";
8
+ const File = (props)=>{
9
+ const resetRef = useRef(null);
10
+ const isLoading = useIsLoading();
11
+ const isUploading = useIsUploading();
12
+ const file = useFile();
13
+ console.log('Input File render');
14
+ return /*#__PURE__*/ jsx(FileButton, {
15
+ resetRef: resetRef,
16
+ onChange: async (file)=>{
17
+ if (file) setFile(file);
18
+ },
19
+ accept: getAccept(),
20
+ disabled: isLoading || isUploading,
21
+ ...props,
22
+ children: (props)=>/*#__PURE__*/ jsxs(ActionIcon.Group, {
23
+ children: [
24
+ /*#__PURE__*/ jsx(ActionIcon, {
25
+ size: "lg",
26
+ variant: "default",
27
+ disabled: isLoading,
28
+ loading: isUploading,
29
+ classNames: {
30
+ root: 'rolder-chat-input-file-action-action'
31
+ },
32
+ ...props,
33
+ children: /*#__PURE__*/ jsx(IconPaperclip, {
34
+ size: 24,
35
+ stroke: 1.5
36
+ })
37
+ }),
38
+ file && /*#__PURE__*/ jsxs(Fragment, {
39
+ children: [
40
+ /*#__PURE__*/ jsx(Tooltip, {
41
+ label: file.name,
42
+ openDelay: 500,
43
+ children: /*#__PURE__*/ jsx(ActionIcon.GroupSection, {
44
+ variant: "default",
45
+ size: "lg",
46
+ children: /*#__PURE__*/ jsx(FileIcon, {
47
+ mimeType: file.type
48
+ })
49
+ })
50
+ }),
51
+ /*#__PURE__*/ jsx(ActionIcon, {
52
+ size: "lg",
53
+ variant: "default",
54
+ classNames: {
55
+ root: 'rolder-chat-input-file-action-action'
56
+ },
57
+ onClick: ()=>{
58
+ resetRef.current?.();
59
+ setFile(null);
60
+ },
61
+ children: /*#__PURE__*/ jsx(IconTrash, {
62
+ size: 24,
63
+ stroke: 1.5
64
+ })
65
+ })
66
+ ]
67
+ })
68
+ ]
69
+ })
70
+ });
71
+ };
72
+ 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 };
@@ -1,8 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Group } from "@mantine/core";
3
- const Footer = (props)=>/*#__PURE__*/ jsx(Group, {
3
+ const Footer = (props)=>{
4
+ console.log('Input Footer render');
5
+ return /*#__PURE__*/ jsx(Group, {
4
6
  justify: "space-between",
5
7
  p: "xs",
6
8
  ...props
7
9
  });
10
+ };
8
11
  export { Footer };
@@ -0,0 +1,9 @@
1
+ import { type PaperProps } from '@mantine/core';
2
+ import { type Accept } from './store';
3
+ export interface ChatInputRootProps extends PaperProps {
4
+ children?: React.ReactNode;
5
+ onSubmit?: () => void;
6
+ isUploading?: boolean;
7
+ accept?: Accept;
8
+ }
9
+ export declare const Root: ({ children, className, onSubmit, isUploading, accept, ...props }: ChatInputRootProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Paper } from "@mantine/core";
3
+ import clsx from "clsx";
4
+ import { useEffect } from "react";
5
+ import { setAccept, setIsUploading, setOnSubmit } from "./store.js";
6
+ const Root = ({ children, className, onSubmit, isUploading, accept, ...props })=>{
7
+ useEffect(()=>{
8
+ if (onSubmit) setOnSubmit(onSubmit);
9
+ setIsUploading(isUploading || false);
10
+ if (accept) setAccept(accept);
11
+ }, [
12
+ onSubmit,
13
+ isUploading,
14
+ accept
15
+ ]);
16
+ console.log('Input root render');
17
+ return /*#__PURE__*/ jsx(Paper, {
18
+ radius: "md",
19
+ withBorder: true,
20
+ className: clsx('rolder-chat-input-root', className),
21
+ ...props,
22
+ children: children
23
+ });
24
+ };
25
+ export { Root };
@@ -0,0 +1,24 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ActionIcon } from "@mantine/core";
3
+ import { IconArrowBigUp } from "@tabler/icons-react";
4
+ import { useIsLoading } from "../store/index.js";
5
+ import { getOnSubmit, useIsUploading } from "./store.js";
6
+ const Submit = ({ children, ...props })=>{
7
+ const Icon = /*#__PURE__*/ jsx(IconArrowBigUp, {
8
+ strokeWidth: 1.5
9
+ });
10
+ const isLoading = useIsLoading();
11
+ const isUploading = useIsUploading();
12
+ console.log('Input submit render');
13
+ return /*#__PURE__*/ jsx(ActionIcon, {
14
+ "aria-label": "Submit",
15
+ variant: "light",
16
+ size: "lg",
17
+ onClick: getOnSubmit(),
18
+ disabled: isUploading,
19
+ loading: isLoading,
20
+ ...props,
21
+ children: children ?? Icon
22
+ });
23
+ };
24
+ export { Submit };
@@ -1,16 +1,18 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { Textarea } from "@mantine/core";
3
- import { useState } from "react";
4
- import { usePromptInput } from "./PromptInputContext.js";
3
+ import { useIsLoading } from "../store/index.js";
4
+ import { getIsComposing, getOnSubmit, setIsComposing, setText, useIsUploading, useText } from "./store.js";
5
5
  const Textarea_Textarea = (props)=>{
6
- const { text, setText, onSubmit, submiting, uploading } = usePromptInput();
7
- const [isComposing, setIsComposing] = useState(false);
6
+ const text = useText();
7
+ const isLoading = useIsLoading();
8
+ const isUploading = useIsUploading();
9
+ console.log('Input textarea render');
8
10
  const handleKeyDown = (e)=>{
9
11
  if ('Enter' === e.key) {
10
- if (isComposing || e.nativeEvent.isComposing) return;
12
+ if (getIsComposing() || e.nativeEvent.isComposing) return;
11
13
  if (e.shiftKey) return;
12
14
  e.preventDefault();
13
- onSubmit();
15
+ getOnSubmit()();
14
16
  }
15
17
  };
16
18
  return /*#__PURE__*/ jsx(Textarea, {
@@ -18,7 +20,7 @@ const Textarea_Textarea = (props)=>{
18
20
  size: "md",
19
21
  rows: 3,
20
22
  classNames: {
21
- input: 'rolder-prompt-input-textarea'
23
+ input: 'rolder-chat-input-textarea'
22
24
  },
23
25
  placeholder: "Напишите сообщение",
24
26
  onCompositionEnd: ()=>setIsComposing(false),
@@ -26,7 +28,7 @@ const Textarea_Textarea = (props)=>{
26
28
  onKeyDown: handleKeyDown,
27
29
  value: text,
28
30
  onChange: (e)=>setText(e.target.value),
29
- disabled: submiting || uploading,
31
+ disabled: isLoading || isUploading,
30
32
  ...props
31
33
  });
32
34
  };
@@ -1,6 +1,5 @@
1
- export type { Accept, PromptInputProps } 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;
1
+ export declare const ChatInput: {
2
+ Root: ({ children, className, onSubmit, isUploading, accept, ...props }: import("./Root").ChatInputRootProps) => import("react/jsx-runtime").JSX.Element;
4
3
  Textarea: (props: import("@mantine/core").TextareaProps) => import("react/jsx-runtime").JSX.Element;
5
4
  Footer: (props: import("@mantine/core").GroupProps) => import("react/jsx-runtime").JSX.Element;
6
5
  Submit: ({ children, ...props }: import("@mantine/core").ActionIconProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,11 +3,11 @@ import { Footer } from "./Footer.js";
3
3
  import { Root } from "./Root.js";
4
4
  import { Submit } from "./Submit.js";
5
5
  import { Textarea } from "./Textarea.js";
6
- const PromptInput = {
6
+ const ChatInput = {
7
7
  Root: Root,
8
8
  Textarea: Textarea,
9
9
  Footer: Footer,
10
10
  Submit: Submit,
11
11
  File: File
12
12
  };
13
- export { PromptInput };
13
+ export { ChatInput };
@@ -0,0 +1,13 @@
1
+ export declare const setText: (text: string) => void;
2
+ export declare const useText: () => string;
3
+ export declare const getIsComposing: () => boolean;
4
+ export declare const setIsComposing: (isComposing: boolean) => void;
5
+ export declare const useIsUploading: () => boolean;
6
+ export declare const setIsUploading: (isUploading: boolean) => void;
7
+ export declare const useFile: () => File | null;
8
+ export declare const setFile: (file: File | null) => void;
9
+ export declare const getOnSubmit: () => () => void;
10
+ export declare const setOnSubmit: (onSubmit: () => void) => void;
11
+ export type Accept = ('text' | 'image' | 'pdf' | 'word' | 'excel')[];
12
+ export declare const getAccept: () => string;
13
+ export declare const setAccept: (accept: Accept) => void;
@@ -0,0 +1,40 @@
1
+ import { useStore } from "@nanostores/react";
2
+ import { atom } from "nanostores";
3
+ const $text = atom('');
4
+ const setText = (text)=>$text.set(text);
5
+ const useText = ()=>useStore($text);
6
+ const $isComposing = atom(false);
7
+ const getIsComposing = ()=>$isComposing.get();
8
+ const setIsComposing = (isComposing)=>$isComposing.set(isComposing);
9
+ const $isUploading = atom(false);
10
+ const useIsUploading = ()=>useStore($isUploading);
11
+ const setIsUploading = (isUploading)=>$isUploading.set(isUploading);
12
+ const $file = atom(null);
13
+ const useFile = ()=>useStore($file);
14
+ const setFile = (file)=>$file.set(file);
15
+ const $onSubmit = atom(()=>()=>{});
16
+ const getOnSubmit = ()=>$onSubmit.get();
17
+ const setOnSubmit = (onSubmit)=>$onSubmit.set(onSubmit);
18
+ const $accept = atom([
19
+ 'text',
20
+ 'image',
21
+ 'pdf'
22
+ ]);
23
+ const getAccept = ()=>$accept.get().map((type)=>{
24
+ switch(type){
25
+ case 'text':
26
+ return 'text/plain';
27
+ case 'image':
28
+ return 'image/*';
29
+ case 'pdf':
30
+ return 'application/pdf';
31
+ case 'excel':
32
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
33
+ case 'word':
34
+ return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
35
+ default:
36
+ return type;
37
+ }
38
+ }).join(',');
39
+ const setAccept = (accept)=>$accept.set(accept);
40
+ export { getAccept, getIsComposing, getOnSubmit, setAccept, setFile, setIsComposing, setIsUploading, setOnSubmit, setText, useFile, useIsUploading, useText };
@@ -0,0 +1,13 @@
1
+ export declare const Chat: {
2
+ Root: ({ children, scrollAreaProps, withScrollButton, ...props }: import("./Root").ConversationRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ Messages: ({ children, ...props }: import("@mantine/core").StackProps) => import("react/jsx-runtime").JSX.Element[];
4
+ Message: ({ messageId }: {
5
+ messageId: string;
6
+ }) => import("react/jsx-runtime").JSX.Element | null;
7
+ File: ({ messageId }: {
8
+ messageId: string;
9
+ }) => import("react/jsx-runtime").JSX.Element | null;
10
+ Loader: (props: import("@mantine/core").LoaderProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ Empty: () => import("react/jsx-runtime").JSX.Element | null;
12
+ };
13
+ export { ChatInput } from './chatInput';
@@ -2,13 +2,15 @@ import { Empty } from "./Empty.js";
2
2
  import { File } from "./File.js";
3
3
  import { Loader } from "./Loader.js";
4
4
  import { Message } from "./Message.js";
5
+ import { Messages } from "./Messages.js";
5
6
  import { Root } from "./Root.js";
6
- import { useChatMessage } from "./useChatMessage.js";
7
- const Conversation = {
7
+ import { ChatInput } from "./chatInput/index.js";
8
+ const Chat = {
8
9
  Root: Root,
10
+ Messages: Messages,
9
11
  Message: Message,
10
12
  File: File,
11
13
  Loader: Loader,
12
14
  Empty: Empty
13
15
  };
14
- export { Conversation, useChatMessage };
16
+ export { Chat, ChatInput };
@@ -0,0 +1,2 @@
1
+ export * from './messages';
2
+ export * from './states';
@@ -0,0 +1,2 @@
1
+ export * from "./messages.js";
2
+ export * from "./states.js";
@@ -0,0 +1,17 @@
1
+ import { type UseChatOptions } from '@ai-sdk/react';
2
+ import type { ChatInit, FileUIPart, UIDataTypes, UIMessage, UIMessagePart, UITools } from 'ai';
3
+ export declare const $chatMessageIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
4
+ export declare const $chatMessages: import("nanostores").PreinitializedMapStore<Record<string, UIMessage<unknown, UIDataTypes, UITools>>> & object;
5
+ export declare const getChatMessage: (messageId: string) => UIMessage<unknown, UIDataTypes, UITools>;
6
+ export declare const getChatMessages: <T extends UIMessage>() => T[];
7
+ export declare const setChatMessages: <T extends UIMessage>(messages: T[]) => void;
8
+ export declare const getIsEmpty: () => boolean;
9
+ export declare const useIsEmpty: () => boolean;
10
+ export declare const useChatMessageIds: <T extends UIMessage>(props?: UseChatOptions<T> & ChatInit<T>) => string[];
11
+ export declare const useChatMessage: <T extends UIMessage>(messageId: string) => T;
12
+ export declare const useChatMessagePart: <M extends UIMessage, T extends UIMessagePart<UIDataTypes, UITools>>(messageId: string, type?: T["type"]) => T | undefined;
13
+ export type SendMessage = ({ text, file }: {
14
+ text: string;
15
+ file?: FileUIPart;
16
+ }, data?: Record<string, unknown>) => Promise<void>;
17
+ export declare const sendMessage: SendMessage;