@liveblocks/react-ui 2.25.0-aiprivatebeta1 → 2.25.0-aiprivatebeta10
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/_private/index.cjs +18 -10
- package/dist/_private/index.cjs.map +1 -1
- package/dist/_private/index.d.cts +204 -172
- package/dist/_private/index.d.ts +204 -172
- package/dist/_private/index.js +12 -5
- package/dist/_private/index.js.map +1 -1
- package/dist/components/AiChat.cjs +185 -0
- package/dist/components/AiChat.cjs.map +1 -0
- package/dist/components/AiChat.js +183 -0
- package/dist/components/AiChat.js.map +1 -0
- package/dist/components/AiTool.cjs +164 -0
- package/dist/components/AiTool.cjs.map +1 -0
- package/dist/components/AiTool.js +162 -0
- package/dist/components/AiTool.js.map +1 -0
- package/dist/components/Comment.cjs +7 -5
- package/dist/components/Comment.cjs.map +1 -1
- package/dist/components/Comment.js +7 -5
- package/dist/components/Comment.js.map +1 -1
- package/dist/components/Composer.cjs +1 -2
- package/dist/components/Composer.cjs.map +1 -1
- package/dist/components/Composer.js +1 -2
- package/dist/components/Composer.js.map +1 -1
- package/dist/components/InboxNotificationList.cjs +11 -3
- package/dist/components/InboxNotificationList.cjs.map +1 -1
- package/dist/components/InboxNotificationList.js +12 -4
- package/dist/components/InboxNotificationList.js.map +1 -1
- package/dist/components/Thread.cjs +3 -3
- package/dist/components/Thread.cjs.map +1 -1
- package/dist/components/Thread.js +3 -3
- package/dist/components/Thread.js.map +1 -1
- package/dist/components/internal/AiChatAssistantMessage.cjs +74 -291
- package/dist/components/internal/AiChatAssistantMessage.cjs.map +1 -1
- package/dist/components/internal/AiChatAssistantMessage.js +76 -293
- package/dist/components/internal/AiChatAssistantMessage.js.map +1 -1
- package/dist/components/internal/AiChatComposer.cjs +58 -282
- package/dist/components/internal/AiChatComposer.cjs.map +1 -1
- package/dist/components/internal/AiChatComposer.js +63 -283
- package/dist/components/internal/AiChatComposer.js.map +1 -1
- package/dist/components/internal/AiChatUserMessage.cjs +26 -169
- package/dist/components/internal/AiChatUserMessage.cjs.map +1 -1
- package/dist/components/internal/AiChatUserMessage.js +28 -171
- package/dist/components/internal/AiChatUserMessage.js.map +1 -1
- package/dist/components/internal/Button.cjs.map +1 -1
- package/dist/components/internal/Button.js.map +1 -1
- package/dist/components/internal/CodeBlock.cjs +72 -0
- package/dist/components/internal/CodeBlock.cjs.map +1 -0
- package/dist/components/internal/CodeBlock.js +70 -0
- package/dist/components/internal/CodeBlock.js.map +1 -0
- package/dist/components/internal/Emoji.cjs +12 -4
- package/dist/components/internal/Emoji.cjs.map +1 -1
- package/dist/components/internal/Emoji.js +12 -4
- package/dist/components/internal/Emoji.js.map +1 -1
- package/dist/components/internal/Prose.cjs +37 -0
- package/dist/components/internal/Prose.cjs.map +1 -0
- package/dist/components/internal/Prose.js +35 -0
- package/dist/components/internal/Prose.js.map +1 -0
- package/dist/constants.cjs +2 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.js +2 -1
- package/dist/constants.js.map +1 -1
- package/dist/icon.cjs +6 -0
- package/dist/icon.cjs.map +1 -1
- package/dist/icon.js +3 -0
- package/dist/icon.js.map +1 -1
- package/dist/icons/{Resolve.cjs → CheckCircle.cjs} +3 -3
- package/dist/icons/CheckCircle.cjs.map +1 -0
- package/dist/icons/{Resolve.js → CheckCircle.js} +3 -3
- package/dist/icons/CheckCircle.js.map +1 -0
- package/dist/icons/{Resolved.cjs → CheckCircleFill.cjs} +3 -3
- package/dist/icons/CheckCircleFill.cjs.map +1 -0
- package/dist/icons/{Resolved.js → CheckCircleFill.js} +3 -3
- package/dist/icons/CheckCircleFill.js.map +1 -0
- package/dist/icons/Copy.cjs +8 -9
- package/dist/icons/Copy.cjs.map +1 -1
- package/dist/icons/Copy.js +8 -9
- package/dist/icons/Copy.js.map +1 -1
- package/dist/icons/Retry.cjs +21 -0
- package/dist/icons/Retry.cjs.map +1 -0
- package/dist/icons/Retry.js +19 -0
- package/dist/icons/Retry.js.map +1 -0
- package/dist/icons/index.cjs +8 -4
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.js +4 -2
- package/dist/icons/index.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -43
- package/dist/index.d.ts +102 -43
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/overrides.cjs +6 -12
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.js +6 -12
- package/dist/overrides.js.map +1 -1
- package/dist/primitives/AiChatComposer/index.cjs +202 -0
- package/dist/primitives/AiChatComposer/index.cjs.map +1 -0
- package/dist/primitives/AiChatComposer/index.js +195 -0
- package/dist/primitives/AiChatComposer/index.js.map +1 -0
- package/dist/primitives/AiMessage/contexts.cjs +18 -0
- package/dist/primitives/AiMessage/contexts.cjs.map +1 -0
- package/dist/primitives/AiMessage/contexts.js +15 -0
- package/dist/primitives/AiMessage/contexts.js.map +1 -0
- package/dist/primitives/AiMessage/index.cjs +134 -0
- package/dist/primitives/AiMessage/index.cjs.map +1 -0
- package/dist/primitives/AiMessage/index.js +132 -0
- package/dist/primitives/AiMessage/index.js.map +1 -0
- package/dist/primitives/Collapsible/index.cjs +127 -0
- package/dist/primitives/Collapsible/index.cjs.map +1 -0
- package/dist/primitives/Collapsible/index.js +123 -0
- package/dist/primitives/Collapsible/index.js.map +1 -0
- package/dist/primitives/Comment/index.cjs +2 -2
- package/dist/primitives/Comment/index.cjs.map +1 -1
- package/dist/primitives/Comment/index.js +1 -1
- package/dist/primitives/Comment/index.js.map +1 -1
- package/dist/primitives/Composer/index.cjs +19 -14
- package/dist/primitives/Composer/index.cjs.map +1 -1
- package/dist/primitives/Composer/index.js +18 -13
- package/dist/primitives/Composer/index.js.map +1 -1
- package/dist/{slate → primitives/Composer/slate}/plugins/auto-formatting.cjs +3 -3
- package/dist/primitives/Composer/slate/plugins/auto-formatting.cjs.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/auto-formatting.js +3 -3
- package/dist/primitives/Composer/slate/plugins/auto-formatting.js.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/auto-links.cjs +7 -2
- package/dist/primitives/Composer/slate/plugins/auto-links.cjs.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/auto-links.js +8 -3
- package/dist/primitives/Composer/slate/plugins/auto-links.js.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/custom-links.cjs +8 -3
- package/dist/primitives/Composer/slate/plugins/custom-links.cjs.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/custom-links.js +9 -4
- package/dist/primitives/Composer/slate/plugins/custom-links.js.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/mentions.cjs +9 -10
- package/dist/primitives/Composer/slate/plugins/mentions.cjs.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/mentions.js +6 -6
- package/dist/primitives/Composer/slate/plugins/mentions.js.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/paste.cjs +1 -1
- package/dist/primitives/Composer/slate/plugins/paste.cjs.map +1 -0
- package/dist/{slate → primitives/Composer/slate}/plugins/paste.js +1 -1
- package/dist/primitives/Composer/slate/plugins/paste.js.map +1 -0
- package/dist/primitives/Composer/utils.cjs +4 -4
- package/dist/primitives/Composer/utils.cjs.map +1 -1
- package/dist/primitives/Composer/utils.js +4 -4
- package/dist/primitives/Composer/utils.js.map +1 -1
- package/dist/primitives/{internal/Markdown.cjs → Markdown.cjs} +150 -83
- package/dist/primitives/Markdown.cjs.map +1 -0
- package/dist/primitives/{internal/Markdown.js → Markdown.js} +151 -83
- package/dist/primitives/Markdown.js.map +1 -0
- package/dist/primitives/index.cjs +4 -9
- package/dist/primitives/index.cjs.map +1 -1
- package/dist/primitives/index.d.cts +4 -110
- package/dist/primitives/index.d.ts +4 -110
- package/dist/primitives/index.js +0 -1
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/slate/plugins/empty-clear-formatting.cjs.map +1 -0
- package/dist/primitives/slate/plugins/empty-clear-formatting.js.map +1 -0
- package/dist/{slate → primitives/slate}/plugins/normalize.cjs +0 -5
- package/dist/primitives/slate/plugins/normalize.cjs.map +1 -0
- package/dist/{slate → primitives/slate}/plugins/normalize.js +0 -5
- package/dist/primitives/slate/plugins/normalize.js.map +1 -0
- package/dist/primitives/slate/utils/get-character.cjs.map +1 -0
- package/dist/primitives/slate/utils/get-character.js.map +1 -0
- package/dist/primitives/slate/utils/get-dom-range.cjs.map +1 -0
- package/dist/primitives/slate/utils/get-dom-range.js.map +1 -0
- package/dist/primitives/slate/utils/get-match-range.cjs.map +1 -0
- package/dist/primitives/slate/utils/get-match-range.js.map +1 -0
- package/dist/primitives/slate/utils/is-empty-string.cjs.map +1 -0
- package/dist/primitives/slate/utils/is-empty-string.js.map +1 -0
- package/dist/primitives/slate/utils/is-empty.cjs.map +1 -0
- package/dist/primitives/slate/utils/is-empty.js.map +1 -0
- package/dist/primitives/slate/utils/is-text.cjs.map +1 -0
- package/dist/primitives/slate/utils/is-text.js.map +1 -0
- package/dist/primitives/slate/utils/is-whitespace-character.cjs.map +1 -0
- package/dist/primitives/slate/utils/is-whitespace-character.js.map +1 -0
- package/dist/{slate → primitives/slate}/utils/marks.cjs +9 -9
- package/dist/primitives/slate/utils/marks.cjs.map +1 -0
- package/dist/{slate → primitives/slate}/utils/marks.js +9 -9
- package/dist/primitives/slate/utils/marks.js.map +1 -0
- package/dist/primitives/slate/utils/selection-contains-inlines.cjs.map +1 -0
- package/dist/primitives/slate/utils/selection-contains-inlines.js.map +1 -0
- package/dist/utils/ErrorBoundary.cjs +48 -0
- package/dist/utils/ErrorBoundary.cjs.map +1 -0
- package/dist/utils/ErrorBoundary.js +45 -0
- package/dist/utils/ErrorBoundary.js.map +1 -0
- package/dist/utils/use-visible.cjs +63 -45
- package/dist/utils/use-visible.cjs.map +1 -1
- package/dist/utils/use-visible.js +64 -46
- package/dist/utils/use-visible.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +18 -6
- package/src/styles/constants.css +1 -1
- package/src/styles/dark/index.css +7 -3
- package/src/styles/index.css +640 -307
- package/src/styles/utils.css +8 -3
- package/styles/dark/attributes.css +1 -1
- package/styles/dark/attributes.css.map +1 -1
- package/styles/dark/media-query.css +1 -1
- package/styles/dark/media-query.css.map +1 -1
- package/styles.css +1 -1
- package/styles.css.map +1 -1
- package/dist/components/AiChat/AiChat.cjs +0 -211
- package/dist/components/AiChat/AiChat.cjs.map +0 -1
- package/dist/components/AiChat/AiChat.js +0 -209
- package/dist/components/AiChat/AiChat.js.map +0 -1
- package/dist/icons/Resolve.cjs.map +0 -1
- package/dist/icons/Resolve.js.map +0 -1
- package/dist/icons/Resolved.cjs.map +0 -1
- package/dist/icons/Resolved.js.map +0 -1
- package/dist/primitives/Chat/Composer/index.cjs +0 -323
- package/dist/primitives/Chat/Composer/index.cjs.map +0 -1
- package/dist/primitives/Chat/Composer/index.js +0 -315
- package/dist/primitives/Chat/Composer/index.js.map +0 -1
- package/dist/primitives/internal/Collapsible.cjs +0 -99
- package/dist/primitives/internal/Collapsible.cjs.map +0 -1
- package/dist/primitives/internal/Collapsible.js +0 -95
- package/dist/primitives/internal/Collapsible.js.map +0 -1
- package/dist/primitives/internal/Emoji.cjs +0 -32
- package/dist/primitives/internal/Emoji.cjs.map +0 -1
- package/dist/primitives/internal/Emoji.js +0 -30
- package/dist/primitives/internal/Emoji.js.map +0 -1
- package/dist/primitives/internal/Markdown.cjs.map +0 -1
- package/dist/primitives/internal/Markdown.js.map +0 -1
- package/dist/slate/plugins/auto-formatting.cjs.map +0 -1
- package/dist/slate/plugins/auto-formatting.js.map +0 -1
- package/dist/slate/plugins/auto-links.cjs.map +0 -1
- package/dist/slate/plugins/auto-links.js.map +0 -1
- package/dist/slate/plugins/custom-links.cjs.map +0 -1
- package/dist/slate/plugins/custom-links.js.map +0 -1
- package/dist/slate/plugins/empty-clear-formatting.cjs.map +0 -1
- package/dist/slate/plugins/empty-clear-formatting.js.map +0 -1
- package/dist/slate/plugins/mentions.cjs.map +0 -1
- package/dist/slate/plugins/mentions.js.map +0 -1
- package/dist/slate/plugins/normalize.cjs.map +0 -1
- package/dist/slate/plugins/normalize.js.map +0 -1
- package/dist/slate/plugins/paste.cjs.map +0 -1
- package/dist/slate/plugins/paste.js.map +0 -1
- package/dist/slate/utils/get-character.cjs.map +0 -1
- package/dist/slate/utils/get-character.js.map +0 -1
- package/dist/slate/utils/get-dom-range.cjs.map +0 -1
- package/dist/slate/utils/get-dom-range.js.map +0 -1
- package/dist/slate/utils/get-match-range.cjs.map +0 -1
- package/dist/slate/utils/get-match-range.js.map +0 -1
- package/dist/slate/utils/is-empty-string.cjs.map +0 -1
- package/dist/slate/utils/is-empty-string.js.map +0 -1
- package/dist/slate/utils/is-empty.cjs.map +0 -1
- package/dist/slate/utils/is-empty.js.map +0 -1
- package/dist/slate/utils/is-text.cjs.map +0 -1
- package/dist/slate/utils/is-text.js.map +0 -1
- package/dist/slate/utils/is-whitespace-character.cjs.map +0 -1
- package/dist/slate/utils/is-whitespace-character.js.map +0 -1
- package/dist/slate/utils/marks.cjs.map +0 -1
- package/dist/slate/utils/marks.js.map +0 -1
- package/dist/slate/utils/selection-contains-inlines.cjs.map +0 -1
- package/dist/slate/utils/selection-contains-inlines.js.map +0 -1
- /package/dist/{slate → primitives/slate}/plugins/empty-clear-formatting.cjs +0 -0
- /package/dist/{slate → primitives/slate}/plugins/empty-clear-formatting.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-character.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-character.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-dom-range.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-dom-range.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-match-range.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/get-match-range.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-empty-string.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-empty-string.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-empty.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-empty.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-text.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-text.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-whitespace-character.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/is-whitespace-character.js +0 -0
- /package/dist/{slate → primitives/slate}/utils/selection-contains-inlines.cjs +0 -0
- /package/dist/{slate → primitives/slate}/utils/selection-contains-inlines.js +0 -0
package/dist/_private/index.d.ts
CHANGED
|
@@ -1,175 +1,12 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { ComponentProps, ReactNode, ElementType, ComponentPropsWithoutRef, Ref, RefCallback, FormEvent, ComponentType } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
5
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
type SlotProp = {
|
|
9
|
-
/**
|
|
10
|
-
* Replace the rendered element by the one passed as a child.
|
|
11
|
-
*/
|
|
12
|
-
asChild?: boolean;
|
|
13
|
-
};
|
|
14
|
-
type ComponentPropsWithSlot<TElement extends ElementType<any>> = ComponentPropsWithoutRef<TElement> & SlotProp;
|
|
15
|
-
|
|
16
|
-
interface GlobalOverrides {
|
|
17
|
-
USER_SELF: string;
|
|
18
|
-
USER_UNKNOWN: string;
|
|
19
|
-
LIST_REMAINING: (count: number) => string;
|
|
20
|
-
LIST_REMAINING_USERS: (count: number) => string;
|
|
21
|
-
LIST_REMAINING_COMMENTS: (count: number) => string;
|
|
22
|
-
EMOJI_PICKER_SEARCH_PLACEHOLDER: string;
|
|
23
|
-
EMOJI_PICKER_EMPTY: ReactNode;
|
|
24
|
-
EMOJI_PICKER_ERROR: (error: Error) => ReactNode;
|
|
25
|
-
EMOJI_PICKER_CHANGE_SKIN_TONE: string;
|
|
26
|
-
ATTACHMENT_TOO_LARGE: (maxSize?: string) => string;
|
|
27
|
-
ATTACHMENT_ERROR: (error: Error) => string;
|
|
28
|
-
}
|
|
29
|
-
interface ChatComposerOverrides {
|
|
30
|
-
CHAT_COMPOSER_PLACEHOLDER: string;
|
|
31
|
-
CHAT_COMPOSER_SEND: string;
|
|
32
|
-
CHAT_COMPOSER_ATTACH_FILES: string;
|
|
33
|
-
CHAT_COMPOSER_REMOVE_ATTACHMENT: string;
|
|
34
|
-
CHAT_COMPOSER_ABORT: string;
|
|
35
|
-
}
|
|
36
|
-
interface ChatMessageOverrides {
|
|
37
|
-
CHAT_MESSAGE_DELETED: string;
|
|
38
|
-
CHAT_MESSAGE_THINKING: string;
|
|
39
|
-
CHAT_MESSAGE_COPY: string;
|
|
40
|
-
CHAT_MESSAGE_TRY_AGAIN: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
type AiChatAssistantMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
44
|
-
/**
|
|
45
|
-
* The message to display.
|
|
46
|
-
*/
|
|
47
|
-
message: UiAssistantMessage;
|
|
48
|
-
/**
|
|
49
|
-
* Override the component's strings.
|
|
50
|
-
*/
|
|
51
|
-
overrides?: Partial<GlobalOverrides & ChatMessageOverrides>;
|
|
52
|
-
};
|
|
53
|
-
declare const AiChatAssistantMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
54
|
-
/**
|
|
55
|
-
* The message to display.
|
|
56
|
-
*/
|
|
57
|
-
message: UiAssistantMessage;
|
|
58
|
-
/**
|
|
59
|
-
* Whether to show or hide message actions.
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
showActions?: boolean | "hover";
|
|
63
|
-
/**
|
|
64
|
-
* Override the component's strings.
|
|
65
|
-
*/
|
|
66
|
-
overrides?: Partial<GlobalOverrides & ChatMessageOverrides>;
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
* Whether to show or hide the regenerate button.
|
|
70
|
-
*/
|
|
71
|
-
showRegenerate?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* @internal
|
|
74
|
-
* The id of the copilot to use to regenerate the message. Only used if `showRegenerate` is true.
|
|
75
|
-
*/
|
|
76
|
-
copilotId?: CopilotId;
|
|
77
|
-
} & react.RefAttributes<HTMLDivElement>>>;
|
|
78
|
-
|
|
79
|
-
type AiChatComposerProps = FormHTMLAttributes<HTMLFormElement> & {
|
|
80
|
-
/**
|
|
81
|
-
* The composer's initial value.
|
|
82
|
-
*/
|
|
83
|
-
defaultValue?: string;
|
|
84
|
-
/**
|
|
85
|
-
* The event handler called when a chat message is submitted.
|
|
86
|
-
*/
|
|
87
|
-
onComposerSubmit?: (message: {
|
|
88
|
-
/**
|
|
89
|
-
* The submitted message text.
|
|
90
|
-
*/
|
|
91
|
-
text: string;
|
|
92
|
-
}, event: FormEvent<HTMLFormElement>) => void;
|
|
93
|
-
/**
|
|
94
|
-
* Whether the composer is disabled.
|
|
95
|
-
*/
|
|
96
|
-
disabled?: boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Override the component's strings.
|
|
99
|
-
*/
|
|
100
|
-
overrides?: Partial<GlobalOverrides & ChatComposerOverrides>;
|
|
101
|
-
/**
|
|
102
|
-
* The id of the chat the composer belongs to.
|
|
103
|
-
*/
|
|
104
|
-
chatId: string;
|
|
105
|
-
/**
|
|
106
|
-
* The id of the copilot to use to send the message.
|
|
107
|
-
*/
|
|
108
|
-
copilotId?: CopilotId;
|
|
109
|
-
};
|
|
110
|
-
declare const AiChatComposer: react.ForwardRefExoticComponent<FormHTMLAttributes<HTMLFormElement> & {
|
|
111
|
-
/**
|
|
112
|
-
* The composer's initial value.
|
|
113
|
-
*/
|
|
114
|
-
defaultValue?: string;
|
|
115
|
-
/**
|
|
116
|
-
* The event handler called when a chat message is submitted.
|
|
117
|
-
*/
|
|
118
|
-
onComposerSubmit?: (message: {
|
|
119
|
-
/**
|
|
120
|
-
* The submitted message text.
|
|
121
|
-
*/
|
|
122
|
-
text: string;
|
|
123
|
-
}, event: FormEvent<HTMLFormElement>) => void;
|
|
124
|
-
/**
|
|
125
|
-
* Whether the composer is disabled.
|
|
126
|
-
*/
|
|
127
|
-
disabled?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Override the component's strings.
|
|
130
|
-
*/
|
|
131
|
-
overrides?: Partial<GlobalOverrides & ChatComposerOverrides>;
|
|
132
|
-
/**
|
|
133
|
-
* The id of the chat the composer belongs to.
|
|
134
|
-
*/
|
|
135
|
-
chatId: string;
|
|
136
|
-
/**
|
|
137
|
-
* The id of the copilot to use to send the message.
|
|
138
|
-
*/
|
|
139
|
-
copilotId?: CopilotId;
|
|
140
|
-
/**
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
branchId?: MessageId;
|
|
144
|
-
/**
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
stream?: boolean;
|
|
148
|
-
} & react.RefAttributes<HTMLFormElement>>;
|
|
149
|
-
|
|
150
|
-
type AiChatUserMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
151
|
-
/**
|
|
152
|
-
* The message to display.
|
|
153
|
-
*/
|
|
154
|
-
message: UiUserMessage;
|
|
155
|
-
/**
|
|
156
|
-
* Override the component's strings.
|
|
157
|
-
*/
|
|
158
|
-
overrides?: Partial<GlobalOverrides>;
|
|
159
|
-
};
|
|
160
|
-
declare const AiChatUserMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
161
|
-
/**
|
|
162
|
-
* The message to display.
|
|
163
|
-
*/
|
|
164
|
-
message: UiUserMessage;
|
|
165
|
-
/**
|
|
166
|
-
* Override the component's strings.
|
|
167
|
-
*/
|
|
168
|
-
overrides?: Partial<GlobalOverrides>;
|
|
169
|
-
} & react.RefAttributes<HTMLDivElement>>>;
|
|
6
|
+
import { AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
|
|
170
7
|
|
|
171
8
|
interface ButtonProps extends ComponentProps<"button"> {
|
|
172
|
-
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary";
|
|
9
|
+
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary" | "destructive";
|
|
173
10
|
size?: "default" | "large";
|
|
174
11
|
disableable?: boolean;
|
|
175
12
|
icon?: ReactNode;
|
|
@@ -177,6 +14,14 @@ interface ButtonProps extends ComponentProps<"button"> {
|
|
|
177
14
|
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
178
15
|
declare const SelectButton: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
179
16
|
|
|
17
|
+
type SlotProp = {
|
|
18
|
+
/**
|
|
19
|
+
* Replace the rendered element by the one passed as a child.
|
|
20
|
+
*/
|
|
21
|
+
asChild?: boolean;
|
|
22
|
+
};
|
|
23
|
+
type ComponentPropsWithSlot<TElement extends ElementType<any>> = ComponentPropsWithoutRef<TElement> & SlotProp;
|
|
24
|
+
|
|
180
25
|
interface ListProps extends ComponentPropsWithSlot<"span"> {
|
|
181
26
|
values: ReactNode[];
|
|
182
27
|
formatRemaining?: (amount: number) => string;
|
|
@@ -185,6 +30,15 @@ interface ListProps extends ComponentPropsWithSlot<"span"> {
|
|
|
185
30
|
}
|
|
186
31
|
declare const List: react.ForwardRefExoticComponent<ListProps & react.RefAttributes<HTMLSpanElement>>;
|
|
187
32
|
|
|
33
|
+
interface ProseProps extends ComponentProps<"div"> {
|
|
34
|
+
content: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* This component renders Markdown content with `lb-prose`
|
|
38
|
+
* styles and custom components (code blocks, etc)
|
|
39
|
+
*/
|
|
40
|
+
declare function Prose({ content, className, ...props }: ProseProps): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
188
42
|
interface TooltipProps extends Pick<TooltipPrimitive.TooltipTriggerProps, "children">, Omit<TooltipPrimitive.TooltipContentProps, "content"> {
|
|
189
43
|
content: ReactNode;
|
|
190
44
|
multiline?: boolean;
|
|
@@ -227,6 +81,10 @@ declare function BoldIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.E
|
|
|
227
81
|
|
|
228
82
|
declare function CheckIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
229
83
|
|
|
84
|
+
declare function CheckCircleIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
85
|
+
|
|
86
|
+
declare function CheckCircleFillIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
230
88
|
declare function ChevronDownIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
231
89
|
|
|
232
90
|
declare function ChevronLeftIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -239,6 +97,8 @@ declare function CodeIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.E
|
|
|
239
97
|
|
|
240
98
|
declare function CommentIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
241
99
|
|
|
100
|
+
declare function CopyIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
101
|
+
|
|
242
102
|
declare function CrossIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
243
103
|
|
|
244
104
|
declare function DeleteIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -271,12 +131,10 @@ declare function QuestionMarkIcon(props: ComponentProps<"svg">): react_jsx_runti
|
|
|
271
131
|
|
|
272
132
|
declare function RedoIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
273
133
|
|
|
274
|
-
declare function ResolveIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
275
|
-
|
|
276
|
-
declare function ResolvedIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
277
|
-
|
|
278
134
|
declare function RestoreIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
279
135
|
|
|
136
|
+
declare function RetryIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
137
|
+
|
|
280
138
|
declare function SearchIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
281
139
|
|
|
282
140
|
declare function SendIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -315,4 +173,178 @@ declare function useInitial<T>(value: T | (() => T)): T;
|
|
|
315
173
|
|
|
316
174
|
declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
|
|
317
175
|
|
|
318
|
-
|
|
176
|
+
interface AiChatComposerFormProps extends ComponentPropsWithSlot<"form"> {
|
|
177
|
+
/**
|
|
178
|
+
* The event handler called when a chat message is submitted.
|
|
179
|
+
*/
|
|
180
|
+
onComposerSubmit?: (message: {
|
|
181
|
+
/**
|
|
182
|
+
* The submitted message text.
|
|
183
|
+
*/
|
|
184
|
+
text: string;
|
|
185
|
+
}, event: FormEvent<HTMLFormElement>) => void;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the composer is disabled.
|
|
188
|
+
*/
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
}
|
|
191
|
+
interface AiChatComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "children"> {
|
|
192
|
+
/**
|
|
193
|
+
* The editor's initial value.
|
|
194
|
+
*/
|
|
195
|
+
defaultValue?: string;
|
|
196
|
+
/**
|
|
197
|
+
* The text to display when the editor is empty.
|
|
198
|
+
*/
|
|
199
|
+
placeholder?: string;
|
|
200
|
+
/**
|
|
201
|
+
* Whether the editor is disabled.
|
|
202
|
+
*/
|
|
203
|
+
disabled?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Whether to focus the editor on mount.
|
|
206
|
+
*/
|
|
207
|
+
autoFocus?: boolean;
|
|
208
|
+
}
|
|
209
|
+
type AiChatComposerSubmitProps = ComponentPropsWithSlot<"button">;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Surrounds the chat composer's content and handles submissions.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* <AiChatComposer.Form onComposerSubmit={({ text }) => {}}>
|
|
216
|
+
* <AiChatComposer.Editor />
|
|
217
|
+
* <AiChatComposer.Submit />
|
|
218
|
+
* </AiChatComposer.Form>
|
|
219
|
+
*/
|
|
220
|
+
declare const AiChatComposerForm: react.ForwardRefExoticComponent<AiChatComposerFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
221
|
+
/**
|
|
222
|
+
* Displays the chat composer's editor.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* <AiChatComposer.Editor placeholder="Write a message…" />
|
|
226
|
+
*/
|
|
227
|
+
declare const AiChatComposerEditor: react.ForwardRefExoticComponent<AiChatComposerEditorProps & react.RefAttributes<HTMLDivElement>>;
|
|
228
|
+
/**
|
|
229
|
+
* A button to submit a chat message.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* <AiChatComposer.Submit>Send</AiChatComposer.Submit>
|
|
233
|
+
*/
|
|
234
|
+
declare const AiChatComposerSubmit: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
235
|
+
|
|
236
|
+
declare const index$2_AiChatComposerEditor: typeof AiChatComposerEditor;
|
|
237
|
+
declare const index$2_AiChatComposerForm: typeof AiChatComposerForm;
|
|
238
|
+
declare const index$2_AiChatComposerSubmit: typeof AiChatComposerSubmit;
|
|
239
|
+
declare namespace index$2 {
|
|
240
|
+
export {
|
|
241
|
+
index$2_AiChatComposerEditor as AiChatComposerEditor,
|
|
242
|
+
index$2_AiChatComposerForm as AiChatComposerForm,
|
|
243
|
+
index$2_AiChatComposerSubmit as AiChatComposerSubmit,
|
|
244
|
+
AiChatComposerEditor as Editor,
|
|
245
|
+
AiChatComposerForm as Form,
|
|
246
|
+
AiChatComposerSubmit as Submit,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
type AiMessageContentTextPartProps = {
|
|
251
|
+
part: AiTextPart;
|
|
252
|
+
};
|
|
253
|
+
type AiMessageContentReasoningPartProps = {
|
|
254
|
+
part: AiReasoningPart;
|
|
255
|
+
};
|
|
256
|
+
interface AiMessageContentComponents {
|
|
257
|
+
/**
|
|
258
|
+
* The component used to display text parts.
|
|
259
|
+
*/
|
|
260
|
+
TextPart: ComponentType<AiMessageContentTextPartProps>;
|
|
261
|
+
/**
|
|
262
|
+
* The component used to display reasoning parts.
|
|
263
|
+
*/
|
|
264
|
+
ReasoningPart: ComponentType<AiMessageContentReasoningPartProps>;
|
|
265
|
+
}
|
|
266
|
+
interface AiMessageContentProps extends ComponentPropsWithSlot<"div"> {
|
|
267
|
+
/**
|
|
268
|
+
* The message contents to display.
|
|
269
|
+
*/
|
|
270
|
+
message: AiChatMessage;
|
|
271
|
+
/**
|
|
272
|
+
* Optional overrides for the default components to render each part within
|
|
273
|
+
* the message content.
|
|
274
|
+
*/
|
|
275
|
+
components?: Partial<AiMessageContentComponents>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* --------------------------------------------------------------------------
|
|
280
|
+
* @private The API for this component is not yet stable.
|
|
281
|
+
* --------------------------------------------------------------------------
|
|
282
|
+
*
|
|
283
|
+
* Primitive to help display an user or assistant message’s content, which is
|
|
284
|
+
* an array of parts.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* <AiMessage.Content message={message} components={{ TextPart }} />
|
|
288
|
+
*/
|
|
289
|
+
declare const AiMessageContent: react.ForwardRefExoticComponent<AiMessageContentProps & react.RefAttributes<HTMLDivElement>>;
|
|
290
|
+
|
|
291
|
+
declare namespace index$1 {
|
|
292
|
+
export {
|
|
293
|
+
AiMessageContent as Content,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface RootProps extends ComponentPropsWithSlot<"div"> {
|
|
298
|
+
defaultOpen?: boolean;
|
|
299
|
+
open?: boolean;
|
|
300
|
+
onOpenChange?: (open: boolean) => void;
|
|
301
|
+
disabled?: boolean;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
declare const CollapsibleRoot: react.ForwardRefExoticComponent<RootProps & react.RefAttributes<HTMLDivElement>>;
|
|
305
|
+
declare const CollapsibleTrigger: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
306
|
+
declare const CollapsibleContent: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & SlotProp & react.RefAttributes<HTMLDivElement>>;
|
|
307
|
+
|
|
308
|
+
declare namespace index {
|
|
309
|
+
export {
|
|
310
|
+
CollapsibleContent as Content,
|
|
311
|
+
CollapsibleRoot as Root,
|
|
312
|
+
CollapsibleTrigger as Trigger,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
type MarkdownComponents = {
|
|
317
|
+
CodeBlock: ComponentType<MarkdownComponentsCodeBlockProps>;
|
|
318
|
+
Link: ComponentType<MarkdownComponentsLinkProps>;
|
|
319
|
+
Heading: ComponentType<MarkdownComponentsHeadingProps>;
|
|
320
|
+
Image: ComponentType<MarkdownComponentsImageProps>;
|
|
321
|
+
Blockquote: ComponentType<MarkdownComponentsBlockquoteProps>;
|
|
322
|
+
};
|
|
323
|
+
interface MarkdownComponentsBlockquoteProps {
|
|
324
|
+
children: ReactNode;
|
|
325
|
+
}
|
|
326
|
+
interface MarkdownComponentsImageProps {
|
|
327
|
+
src: string;
|
|
328
|
+
alt: string;
|
|
329
|
+
title?: string;
|
|
330
|
+
}
|
|
331
|
+
interface MarkdownComponentsHeadingProps {
|
|
332
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
333
|
+
children: ReactNode;
|
|
334
|
+
}
|
|
335
|
+
interface MarkdownComponentsLinkProps {
|
|
336
|
+
href: string;
|
|
337
|
+
title?: string;
|
|
338
|
+
children: ReactNode;
|
|
339
|
+
}
|
|
340
|
+
interface MarkdownComponentsCodeBlockProps {
|
|
341
|
+
code: string;
|
|
342
|
+
language?: string;
|
|
343
|
+
}
|
|
344
|
+
interface MarkdownProps extends ComponentPropsWithSlot<"div"> {
|
|
345
|
+
content: string;
|
|
346
|
+
components?: Partial<MarkdownComponents>;
|
|
347
|
+
}
|
|
348
|
+
declare const Markdown: react.ForwardRefExoticComponent<MarkdownProps & react.RefAttributes<HTMLDivElement>>;
|
|
349
|
+
|
|
350
|
+
export { index$2 as AiChatComposer, AiChatComposerEditorProps, AiChatComposerFormProps, AiChatComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsLinkProps, MarkdownProps, MentionIcon, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, WarningIcon, capitalize, useInitial, useRefs };
|
package/dist/_private/index.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
export { AiChatAssistantMessage } from '../components/internal/AiChatAssistantMessage.js';
|
|
2
|
-
export { AiChatComposer } from '../components/internal/AiChatComposer.js';
|
|
3
|
-
export { AiChatUserMessage } from '../components/internal/AiChatUserMessage.js';
|
|
4
1
|
export { Button, SelectButton } from '../components/internal/Button.js';
|
|
5
2
|
export { List } from '../components/internal/List.js';
|
|
3
|
+
export { Prose } from '../components/internal/Prose.js';
|
|
6
4
|
export { ShortcutTooltip, Tooltip } from '../components/internal/Tooltip.js';
|
|
7
5
|
export { User } from '../components/internal/User.js';
|
|
8
6
|
import '../icons/index.js';
|
|
9
7
|
export { capitalize } from '../utils/capitalize.js';
|
|
10
8
|
export { useInitial } from '../utils/use-initial.js';
|
|
11
9
|
export { useRefs } from '../utils/use-refs.js';
|
|
10
|
+
import * as index from '../primitives/AiChatComposer/index.js';
|
|
11
|
+
export { index as AiChatComposer };
|
|
12
|
+
import * as index$1 from '../primitives/AiMessage/index.js';
|
|
13
|
+
export { index$1 as AiMessage };
|
|
14
|
+
import * as index$2 from '../primitives/Collapsible/index.js';
|
|
15
|
+
export { index$2 as Collapsible };
|
|
16
|
+
export { Markdown } from '../primitives/Markdown.js';
|
|
12
17
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
13
18
|
export { ArrowCornerDownRightIcon } from '../icons/ArrowCornerDownRight.js';
|
|
14
19
|
export { ArrowCornerUpRightIcon } from '../icons/ArrowCornerUpRight.js';
|
|
@@ -20,12 +25,15 @@ export { BellCrossedIcon } from '../icons/BellCrossed.js';
|
|
|
20
25
|
export { BlockquoteIcon } from '../icons/Blockquote.js';
|
|
21
26
|
export { BoldIcon } from '../icons/Bold.js';
|
|
22
27
|
export { CheckIcon } from '../icons/Check.js';
|
|
28
|
+
export { CheckCircleIcon } from '../icons/CheckCircle.js';
|
|
29
|
+
export { CheckCircleFillIcon } from '../icons/CheckCircleFill.js';
|
|
23
30
|
export { ChevronDownIcon } from '../icons/ChevronDown.js';
|
|
24
31
|
export { ChevronLeftIcon } from '../icons/ChevronLeft.js';
|
|
25
32
|
export { ChevronRightIcon } from '../icons/ChevronRight.js';
|
|
26
33
|
export { ChevronUpIcon } from '../icons/ChevronUp.js';
|
|
27
34
|
export { CodeIcon } from '../icons/Code.js';
|
|
28
35
|
export { CommentIcon } from '../icons/Comment.js';
|
|
36
|
+
export { CopyIcon } from '../icons/Copy.js';
|
|
29
37
|
export { CrossIcon } from '../icons/Cross.js';
|
|
30
38
|
export { DeleteIcon } from '../icons/Delete.js';
|
|
31
39
|
export { EditIcon } from '../icons/Edit.js';
|
|
@@ -42,9 +50,8 @@ export { ListUnorderedIcon } from '../icons/ListUnordered.js';
|
|
|
42
50
|
export { MentionIcon } from '../icons/Mention.js';
|
|
43
51
|
export { QuestionMarkIcon } from '../icons/QuestionMark.js';
|
|
44
52
|
export { RedoIcon } from '../icons/Redo.js';
|
|
45
|
-
export { ResolveIcon } from '../icons/Resolve.js';
|
|
46
|
-
export { ResolvedIcon } from '../icons/Resolved.js';
|
|
47
53
|
export { RestoreIcon } from '../icons/Restore.js';
|
|
54
|
+
export { RetryIcon } from '../icons/Retry.js';
|
|
48
55
|
export { SearchIcon } from '../icons/Search.js';
|
|
49
56
|
export { SendIcon } from '../icons/Send.js';
|
|
50
57
|
export { ShortenIcon } from '../icons/Shorten.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var core = require('@liveblocks/core');
|
|
5
|
+
var react$1 = require('@liveblocks/react');
|
|
6
|
+
var _private = require('@liveblocks/react/_private');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var ArrowDown = require('../icons/ArrowDown.cjs');
|
|
9
|
+
var Spinner = require('../icons/Spinner.cjs');
|
|
10
|
+
var overrides = require('../overrides.cjs');
|
|
11
|
+
var classNames = require('../utils/class-names.cjs');
|
|
12
|
+
var useVisible = require('../utils/use-visible.cjs');
|
|
13
|
+
var AiChatAssistantMessage = require('./internal/AiChatAssistantMessage.cjs');
|
|
14
|
+
var AiChatComposer = require('./internal/AiChatComposer.cjs');
|
|
15
|
+
var AiChatUserMessage = require('./internal/AiChatUserMessage.cjs');
|
|
16
|
+
|
|
17
|
+
const MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 50;
|
|
18
|
+
const defaultComponents = {
|
|
19
|
+
Empty: () => null,
|
|
20
|
+
Loading: () => /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
21
|
+
className: "lb-loading lb-ai-chat-loading",
|
|
22
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Spinner.SpinnerIcon, {})
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
const AiChat = react.forwardRef(
|
|
26
|
+
({
|
|
27
|
+
chatId,
|
|
28
|
+
copilotId,
|
|
29
|
+
autoFocus,
|
|
30
|
+
overrides: overrides$1,
|
|
31
|
+
knowledge,
|
|
32
|
+
tools = {},
|
|
33
|
+
layout = "inset",
|
|
34
|
+
components,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
}, forwardedRef) => {
|
|
38
|
+
const { messages, isLoading, error } = react$1.useAiChatMessages(chatId);
|
|
39
|
+
const $ = overrides.useOverrides(overrides$1);
|
|
40
|
+
const Empty = components?.Empty ?? defaultComponents.Empty;
|
|
41
|
+
const Loading = components?.Loading ?? defaultComponents.Loading;
|
|
42
|
+
const containerRef = react.useRef(null);
|
|
43
|
+
const containerBottomRef = react.useRef(null);
|
|
44
|
+
const isScrollAtBottom = useVisible.useVisible(containerBottomRef, {
|
|
45
|
+
enabled: !isLoading && !error,
|
|
46
|
+
root: containerRef,
|
|
47
|
+
rootMargin: MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR
|
|
48
|
+
});
|
|
49
|
+
const isScrollIndicatorVisible = isLoading || error ? false : !isScrollAtBottom;
|
|
50
|
+
const client = react$1.useClient();
|
|
51
|
+
const ai = client[core.kInternal].ai;
|
|
52
|
+
const [lastSentMessageId, setLastSentMessageId] = react.useState(null);
|
|
53
|
+
react.useImperativeHandle(
|
|
54
|
+
forwardedRef,
|
|
55
|
+
() => containerRef.current,
|
|
56
|
+
[]
|
|
57
|
+
);
|
|
58
|
+
react.useEffect(() => {
|
|
59
|
+
Object.entries(tools).map(
|
|
60
|
+
([key, value]) => ai.registerChatTool(chatId, key, value)
|
|
61
|
+
);
|
|
62
|
+
return () => {
|
|
63
|
+
Object.entries(tools).map(
|
|
64
|
+
([key]) => ai.unregisterChatTool(chatId, key)
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
}, [ai, chatId, tools]);
|
|
68
|
+
const scrollToBottomCallbackRef = react.useRef(void 0);
|
|
69
|
+
if (scrollToBottomCallbackRef.current === void 0) {
|
|
70
|
+
scrollToBottomCallbackRef.current = function(behavior) {
|
|
71
|
+
const container = containerRef.current;
|
|
72
|
+
if (container === null)
|
|
73
|
+
return;
|
|
74
|
+
container.scrollTo({
|
|
75
|
+
top: container.scrollHeight,
|
|
76
|
+
behavior
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const scrollToBottom = scrollToBottomCallbackRef.current;
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
82
|
+
ref: containerRef,
|
|
83
|
+
...props,
|
|
84
|
+
className: classNames.classNames(
|
|
85
|
+
"lb-root lb-ai-chat",
|
|
86
|
+
layout === "compact" ? "lb-ai-chat:layout-compact" : "lb-ai-chat:layout-inset",
|
|
87
|
+
className
|
|
88
|
+
),
|
|
89
|
+
children: [
|
|
90
|
+
knowledge ? knowledge.map((source, index) => /* @__PURE__ */ jsxRuntime.jsx(react$1.RegisterAiKnowledge, {
|
|
91
|
+
description: source.description,
|
|
92
|
+
value: source.value
|
|
93
|
+
}, index)) : null,
|
|
94
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
95
|
+
className: "lb-ai-chat-content",
|
|
96
|
+
children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(Loading, {}) : error !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
97
|
+
className: "lb-error lb-ai-chat-error",
|
|
98
|
+
children: $.AI_CHAT_MESSAGES_ERROR(error)
|
|
99
|
+
}) : messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(Empty, {
|
|
100
|
+
chatId,
|
|
101
|
+
copilotId
|
|
102
|
+
}) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
103
|
+
children: [
|
|
104
|
+
/* @__PURE__ */ jsxRuntime.jsx(AutoScrollHandler, {
|
|
105
|
+
lastSentMessageId,
|
|
106
|
+
scrollToBottom
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
109
|
+
className: "lb-ai-chat-messages",
|
|
110
|
+
children: messages.map((message) => {
|
|
111
|
+
if (message.role === "user") {
|
|
112
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiChatUserMessage.AiChatUserMessage, {
|
|
113
|
+
message,
|
|
114
|
+
overrides: overrides$1
|
|
115
|
+
}, message.id);
|
|
116
|
+
} else if (message.role === "assistant") {
|
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiChatAssistantMessage.AiChatAssistantMessage, {
|
|
118
|
+
message,
|
|
119
|
+
overrides: overrides$1,
|
|
120
|
+
components
|
|
121
|
+
}, message.id);
|
|
122
|
+
} else {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
131
|
+
className: "lb-ai-chat-footer",
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
134
|
+
className: "lb-ai-chat-footer-actions",
|
|
135
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
136
|
+
className: "lb-root lb-elevation lb-elevation-moderate lb-ai-chat-scroll-indicator",
|
|
137
|
+
"data-visible": isScrollIndicatorVisible ? "" : void 0,
|
|
138
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
139
|
+
className: "lb-ai-chat-scroll-indicator-button",
|
|
140
|
+
tabIndex: isScrollIndicatorVisible ? 0 : -1,
|
|
141
|
+
"aria-hidden": !isScrollIndicatorVisible,
|
|
142
|
+
disabled: !isScrollIndicatorVisible,
|
|
143
|
+
onClick: () => scrollToBottom("smooth"),
|
|
144
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
145
|
+
className: "lb-icon-container",
|
|
146
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDownIcon, {})
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(AiChatComposer.AiChatComposer, {
|
|
152
|
+
chatId,
|
|
153
|
+
copilotId,
|
|
154
|
+
overrides: $,
|
|
155
|
+
autoFocus,
|
|
156
|
+
onUserMessageCreate: ({ id }) => setLastSentMessageId(id),
|
|
157
|
+
className: layout === "inset" ? "lb-elevation lb-elevation-moderate" : void 0
|
|
158
|
+
}, chatId)
|
|
159
|
+
]
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
162
|
+
ref: containerBottomRef,
|
|
163
|
+
style: { position: "sticky", height: 0 },
|
|
164
|
+
"aria-hidden": true,
|
|
165
|
+
"data-scroll-at-bottom": isScrollAtBottom ? "" : void 0
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
function AutoScrollHandler({
|
|
172
|
+
lastSentMessageId,
|
|
173
|
+
scrollToBottom
|
|
174
|
+
}) {
|
|
175
|
+
_private.useLayoutEffect(() => {
|
|
176
|
+
scrollToBottom("instant");
|
|
177
|
+
}, [scrollToBottom]);
|
|
178
|
+
react.useEffect(() => {
|
|
179
|
+
scrollToBottom("smooth");
|
|
180
|
+
}, [lastSentMessageId, scrollToBottom]);
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
exports.AiChat = AiChat;
|
|
185
|
+
//# sourceMappingURL=AiChat.cjs.map
|