@liveblocks/react-ui 2.25.0-aiprivatebeta4 → 2.25.0-aiprivatebeta6
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 +4 -0
- package/dist/_private/index.cjs.map +1 -1
- package/dist/_private/index.d.cts +31 -94
- package/dist/_private/index.d.ts +31 -94
- package/dist/_private/index.js +2 -0
- package/dist/_private/index.js.map +1 -1
- package/dist/components/AiChat.cjs +217 -0
- package/dist/components/AiChat.cjs.map +1 -0
- package/dist/components/AiChat.js +215 -0
- package/dist/components/AiChat.js.map +1 -0
- package/dist/components/Comment.cjs +2 -2
- package/dist/components/Comment.cjs.map +1 -1
- package/dist/components/Comment.js +1 -1
- 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/internal/AiChatAssistantMessage.cjs +83 -124
- package/dist/components/internal/AiChatAssistantMessage.cjs.map +1 -1
- package/dist/components/internal/AiChatAssistantMessage.js +81 -122
- package/dist/components/internal/AiChatAssistantMessage.js.map +1 -1
- package/dist/components/internal/AiChatComposer.cjs +30 -266
- package/dist/components/internal/AiChatComposer.cjs.map +1 -1
- package/dist/components/internal/AiChatComposer.js +35 -267
- package/dist/components/internal/AiChatComposer.js.map +1 -1
- package/dist/components/internal/AiChatUserMessage.cjs +18 -168
- package/dist/components/internal/AiChatUserMessage.cjs.map +1 -1
- package/dist/components/internal/AiChatUserMessage.js +20 -170
- package/dist/components/internal/AiChatUserMessage.js.map +1 -1
- 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 +4 -0
- package/dist/icon.cjs.map +1 -1
- package/dist/icon.js +2 -0
- package/dist/icon.js.map +1 -1
- 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 +4 -0
- package/dist/icons/index.cjs.map +1 -1
- package/dist/icons/index.js +2 -0
- package/dist/icons/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -43
- package/dist/index.d.ts +32 -43
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/overrides.cjs +10 -10
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.js +10 -10
- package/dist/overrides.js.map +1 -1
- package/dist/primitives/AiChatComposer/index.cjs +203 -0
- package/dist/primitives/AiChatComposer/index.cjs.map +1 -0
- package/dist/primitives/AiChatComposer/index.js +196 -0
- package/dist/primitives/AiChatComposer/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/index.cjs +2 -5
- package/dist/primitives/index.cjs.map +1 -1
- package/dist/primitives/index.d.cts +33 -62
- package/dist/primitives/index.d.ts +33 -62
- package/dist/primitives/index.js +6 -5
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/internal/{Collapsible.cjs → Collapsible/index.cjs} +23 -17
- package/dist/primitives/internal/Collapsible/index.cjs.map +1 -0
- package/dist/primitives/internal/{Collapsible.js → Collapsible/index.js} +23 -17
- package/dist/primitives/internal/Collapsible/index.js.map +1 -0
- 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/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/src/styles/index.css +120 -133
- package/src/styles/utils.css +7 -2
- 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/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.map +0 -1
- package/dist/primitives/internal/Collapsible.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.cjs
CHANGED
|
@@ -28,6 +28,7 @@ var ChevronRight = require('../icons/ChevronRight.cjs');
|
|
|
28
28
|
var ChevronUp = require('../icons/ChevronUp.cjs');
|
|
29
29
|
var Code = require('../icons/Code.cjs');
|
|
30
30
|
var Comment = require('../icons/Comment.cjs');
|
|
31
|
+
var Copy = require('../icons/Copy.cjs');
|
|
31
32
|
var Cross = require('../icons/Cross.cjs');
|
|
32
33
|
var Delete = require('../icons/Delete.cjs');
|
|
33
34
|
var Edit = require('../icons/Edit.cjs');
|
|
@@ -47,6 +48,7 @@ var Redo = require('../icons/Redo.cjs');
|
|
|
47
48
|
var Resolve = require('../icons/Resolve.cjs');
|
|
48
49
|
var Resolved = require('../icons/Resolved.cjs');
|
|
49
50
|
var Restore = require('../icons/Restore.cjs');
|
|
51
|
+
var Retry = require('../icons/Retry.cjs');
|
|
50
52
|
var Search = require('../icons/Search.cjs');
|
|
51
53
|
var Send = require('../icons/Send.cjs');
|
|
52
54
|
var Shorten = require('../icons/Shorten.cjs');
|
|
@@ -95,6 +97,7 @@ exports.ChevronRightIcon = ChevronRight.ChevronRightIcon;
|
|
|
95
97
|
exports.ChevronUpIcon = ChevronUp.ChevronUpIcon;
|
|
96
98
|
exports.CodeIcon = Code.CodeIcon;
|
|
97
99
|
exports.CommentIcon = Comment.CommentIcon;
|
|
100
|
+
exports.CopyIcon = Copy.CopyIcon;
|
|
98
101
|
exports.CrossIcon = Cross.CrossIcon;
|
|
99
102
|
exports.DeleteIcon = Delete.DeleteIcon;
|
|
100
103
|
exports.EditIcon = Edit.EditIcon;
|
|
@@ -114,6 +117,7 @@ exports.RedoIcon = Redo.RedoIcon;
|
|
|
114
117
|
exports.ResolveIcon = Resolve.ResolveIcon;
|
|
115
118
|
exports.ResolvedIcon = Resolved.ResolvedIcon;
|
|
116
119
|
exports.RestoreIcon = Restore.RestoreIcon;
|
|
120
|
+
exports.RetryIcon = Retry.RetryIcon;
|
|
117
121
|
exports.SearchIcon = Search.SearchIcon;
|
|
118
122
|
exports.SendIcon = Send.SendIcon;
|
|
119
123
|
exports.ShortenIcon = Shorten.ShortenIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ElementType, ComponentPropsWithoutRef, ReactNode,
|
|
3
|
-
import { UiAssistantMessage, CopilotId,
|
|
2
|
+
import { ElementType, ComponentPropsWithoutRef, ReactNode, ComponentProps, FormEvent, Ref, RefCallback } from 'react';
|
|
3
|
+
import { UiAssistantMessage, CopilotId, UiUserMessage } from '@liveblocks/core';
|
|
4
4
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
5
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -26,21 +26,21 @@ interface GlobalOverrides {
|
|
|
26
26
|
ATTACHMENT_TOO_LARGE: (maxSize?: string) => string;
|
|
27
27
|
ATTACHMENT_ERROR: (error: Error) => string;
|
|
28
28
|
}
|
|
29
|
-
interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
interface AiChatComposerOverrides {
|
|
30
|
+
AI_CHAT_COMPOSER_PLACEHOLDER: string;
|
|
31
|
+
AI_CHAT_COMPOSER_SEND: string;
|
|
32
|
+
AI_CHAT_COMPOSER_ATTACH_FILES: string;
|
|
33
|
+
AI_CHAT_COMPOSER_REMOVE_ATTACHMENT: string;
|
|
34
|
+
AI_CHAT_COMPOSER_ABORT: string;
|
|
35
35
|
}
|
|
36
|
-
interface
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
interface AiChatMessageOverrides {
|
|
37
|
+
AI_CHAT_MESSAGE_DELETED: string;
|
|
38
|
+
AI_CHAT_MESSAGE_THINKING: string;
|
|
39
|
+
AI_CHAT_MESSAGE_COPY: string;
|
|
40
|
+
AI_CHAT_MESSAGE_TRY_AGAIN: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
interface AiChatAssistantMessageProps extends ComponentProps<"div"> {
|
|
44
44
|
/**
|
|
45
45
|
* The message to display.
|
|
46
46
|
*/
|
|
@@ -48,35 +48,11 @@ type AiChatAssistantMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
48
48
|
/**
|
|
49
49
|
* Override the component's strings.
|
|
50
50
|
*/
|
|
51
|
-
overrides?: Partial<GlobalOverrides &
|
|
52
|
-
}
|
|
53
|
-
declare const AiChatAssistantMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<
|
|
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>>>;
|
|
51
|
+
overrides?: Partial<GlobalOverrides & AiChatMessageOverrides>;
|
|
52
|
+
}
|
|
53
|
+
declare const AiChatAssistantMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<AiChatAssistantMessageProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
78
54
|
|
|
79
|
-
|
|
55
|
+
interface AiChatComposerProps extends ComponentProps<"form"> {
|
|
80
56
|
/**
|
|
81
57
|
* The composer's initial value.
|
|
82
58
|
*/
|
|
@@ -95,40 +71,13 @@ type AiChatComposerProps = FormHTMLAttributes<HTMLFormElement> & {
|
|
|
95
71
|
*/
|
|
96
72
|
disabled?: boolean;
|
|
97
73
|
/**
|
|
98
|
-
*
|
|
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.
|
|
74
|
+
* Whether to focus the editor on mount.
|
|
117
75
|
*/
|
|
118
|
-
|
|
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;
|
|
76
|
+
autoFocus?: boolean;
|
|
128
77
|
/**
|
|
129
78
|
* Override the component's strings.
|
|
130
79
|
*/
|
|
131
|
-
overrides?: Partial<GlobalOverrides &
|
|
80
|
+
overrides?: Partial<GlobalOverrides & AiChatComposerOverrides>;
|
|
132
81
|
/**
|
|
133
82
|
* The id of the chat the composer belongs to.
|
|
134
83
|
*/
|
|
@@ -137,17 +86,10 @@ declare const AiChatComposer: react.ForwardRefExoticComponent<FormHTMLAttributes
|
|
|
137
86
|
* The id of the copilot to use to send the message.
|
|
138
87
|
*/
|
|
139
88
|
copilotId?: CopilotId;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*/
|
|
143
|
-
branchId?: MessageId;
|
|
144
|
-
/**
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
stream?: boolean;
|
|
148
|
-
} & react.RefAttributes<HTMLFormElement>>;
|
|
89
|
+
}
|
|
90
|
+
declare const AiChatComposer: react.ForwardRefExoticComponent<Omit<AiChatComposerProps, "ref"> & react.RefAttributes<HTMLFormElement>>;
|
|
149
91
|
|
|
150
|
-
|
|
92
|
+
interface AiChatUserMessageProps extends ComponentProps<"div"> {
|
|
151
93
|
/**
|
|
152
94
|
* The message to display.
|
|
153
95
|
*/
|
|
@@ -156,17 +98,8 @@ type AiChatUserMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
156
98
|
* Override the component's strings.
|
|
157
99
|
*/
|
|
158
100
|
overrides?: Partial<GlobalOverrides>;
|
|
159
|
-
}
|
|
160
|
-
declare const AiChatUserMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<
|
|
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>>>;
|
|
101
|
+
}
|
|
102
|
+
declare const AiChatUserMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<AiChatUserMessageProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
170
103
|
|
|
171
104
|
interface ButtonProps extends ComponentProps<"button"> {
|
|
172
105
|
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary";
|
|
@@ -239,6 +172,8 @@ declare function CodeIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.E
|
|
|
239
172
|
|
|
240
173
|
declare function CommentIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
241
174
|
|
|
175
|
+
declare function CopyIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
176
|
+
|
|
242
177
|
declare function CrossIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
243
178
|
|
|
244
179
|
declare function DeleteIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -277,6 +212,8 @@ declare function ResolvedIcon(props: ComponentProps<"svg">): react_jsx_runtime.J
|
|
|
277
212
|
|
|
278
213
|
declare function RestoreIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
279
214
|
|
|
215
|
+
declare function RetryIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
216
|
+
|
|
280
217
|
declare function SearchIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
281
218
|
|
|
282
219
|
declare function SendIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -315,4 +252,4 @@ declare function useInitial<T>(value: T | (() => T)): T;
|
|
|
315
252
|
|
|
316
253
|
declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
|
|
317
254
|
|
|
318
|
-
export { AiChatAssistantMessage, AiChatAssistantMessageProps, AiChatComposer, AiChatComposerProps, AiChatUserMessage, AiChatUserMessageProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, CommentIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, MentionIcon, QuestionMarkIcon, RedoIcon, ResolveIcon, ResolvedIcon, RestoreIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, WarningIcon, capitalize, useInitial, useRefs };
|
|
255
|
+
export { AiChatAssistantMessage, AiChatAssistantMessageProps, AiChatComposer, AiChatComposerProps, AiChatUserMessage, AiChatUserMessageProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, CommentIcon, CopyIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, MentionIcon, QuestionMarkIcon, RedoIcon, ResolveIcon, ResolvedIcon, 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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ElementType, ComponentPropsWithoutRef, ReactNode,
|
|
3
|
-
import { UiAssistantMessage, CopilotId,
|
|
2
|
+
import { ElementType, ComponentPropsWithoutRef, ReactNode, ComponentProps, FormEvent, Ref, RefCallback } from 'react';
|
|
3
|
+
import { UiAssistantMessage, CopilotId, UiUserMessage } from '@liveblocks/core';
|
|
4
4
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
5
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -26,21 +26,21 @@ interface GlobalOverrides {
|
|
|
26
26
|
ATTACHMENT_TOO_LARGE: (maxSize?: string) => string;
|
|
27
27
|
ATTACHMENT_ERROR: (error: Error) => string;
|
|
28
28
|
}
|
|
29
|
-
interface
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
interface AiChatComposerOverrides {
|
|
30
|
+
AI_CHAT_COMPOSER_PLACEHOLDER: string;
|
|
31
|
+
AI_CHAT_COMPOSER_SEND: string;
|
|
32
|
+
AI_CHAT_COMPOSER_ATTACH_FILES: string;
|
|
33
|
+
AI_CHAT_COMPOSER_REMOVE_ATTACHMENT: string;
|
|
34
|
+
AI_CHAT_COMPOSER_ABORT: string;
|
|
35
35
|
}
|
|
36
|
-
interface
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
interface AiChatMessageOverrides {
|
|
37
|
+
AI_CHAT_MESSAGE_DELETED: string;
|
|
38
|
+
AI_CHAT_MESSAGE_THINKING: string;
|
|
39
|
+
AI_CHAT_MESSAGE_COPY: string;
|
|
40
|
+
AI_CHAT_MESSAGE_TRY_AGAIN: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
interface AiChatAssistantMessageProps extends ComponentProps<"div"> {
|
|
44
44
|
/**
|
|
45
45
|
* The message to display.
|
|
46
46
|
*/
|
|
@@ -48,35 +48,11 @@ type AiChatAssistantMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
48
48
|
/**
|
|
49
49
|
* Override the component's strings.
|
|
50
50
|
*/
|
|
51
|
-
overrides?: Partial<GlobalOverrides &
|
|
52
|
-
}
|
|
53
|
-
declare const AiChatAssistantMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<
|
|
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>>>;
|
|
51
|
+
overrides?: Partial<GlobalOverrides & AiChatMessageOverrides>;
|
|
52
|
+
}
|
|
53
|
+
declare const AiChatAssistantMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<AiChatAssistantMessageProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
78
54
|
|
|
79
|
-
|
|
55
|
+
interface AiChatComposerProps extends ComponentProps<"form"> {
|
|
80
56
|
/**
|
|
81
57
|
* The composer's initial value.
|
|
82
58
|
*/
|
|
@@ -95,40 +71,13 @@ type AiChatComposerProps = FormHTMLAttributes<HTMLFormElement> & {
|
|
|
95
71
|
*/
|
|
96
72
|
disabled?: boolean;
|
|
97
73
|
/**
|
|
98
|
-
*
|
|
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.
|
|
74
|
+
* Whether to focus the editor on mount.
|
|
117
75
|
*/
|
|
118
|
-
|
|
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;
|
|
76
|
+
autoFocus?: boolean;
|
|
128
77
|
/**
|
|
129
78
|
* Override the component's strings.
|
|
130
79
|
*/
|
|
131
|
-
overrides?: Partial<GlobalOverrides &
|
|
80
|
+
overrides?: Partial<GlobalOverrides & AiChatComposerOverrides>;
|
|
132
81
|
/**
|
|
133
82
|
* The id of the chat the composer belongs to.
|
|
134
83
|
*/
|
|
@@ -137,17 +86,10 @@ declare const AiChatComposer: react.ForwardRefExoticComponent<FormHTMLAttributes
|
|
|
137
86
|
* The id of the copilot to use to send the message.
|
|
138
87
|
*/
|
|
139
88
|
copilotId?: CopilotId;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
*/
|
|
143
|
-
branchId?: MessageId;
|
|
144
|
-
/**
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
stream?: boolean;
|
|
148
|
-
} & react.RefAttributes<HTMLFormElement>>;
|
|
89
|
+
}
|
|
90
|
+
declare const AiChatComposer: react.ForwardRefExoticComponent<Omit<AiChatComposerProps, "ref"> & react.RefAttributes<HTMLFormElement>>;
|
|
149
91
|
|
|
150
|
-
|
|
92
|
+
interface AiChatUserMessageProps extends ComponentProps<"div"> {
|
|
151
93
|
/**
|
|
152
94
|
* The message to display.
|
|
153
95
|
*/
|
|
@@ -156,17 +98,8 @@ type AiChatUserMessageProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
156
98
|
* Override the component's strings.
|
|
157
99
|
*/
|
|
158
100
|
overrides?: Partial<GlobalOverrides>;
|
|
159
|
-
}
|
|
160
|
-
declare const AiChatUserMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<
|
|
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>>>;
|
|
101
|
+
}
|
|
102
|
+
declare const AiChatUserMessage: react.MemoExoticComponent<react.ForwardRefExoticComponent<Omit<AiChatUserMessageProps, "ref"> & react.RefAttributes<HTMLDivElement>>>;
|
|
170
103
|
|
|
171
104
|
interface ButtonProps extends ComponentProps<"button"> {
|
|
172
105
|
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary";
|
|
@@ -239,6 +172,8 @@ declare function CodeIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.E
|
|
|
239
172
|
|
|
240
173
|
declare function CommentIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
241
174
|
|
|
175
|
+
declare function CopyIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
176
|
+
|
|
242
177
|
declare function CrossIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
243
178
|
|
|
244
179
|
declare function DeleteIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -277,6 +212,8 @@ declare function ResolvedIcon(props: ComponentProps<"svg">): react_jsx_runtime.J
|
|
|
277
212
|
|
|
278
213
|
declare function RestoreIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
279
214
|
|
|
215
|
+
declare function RetryIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
216
|
+
|
|
280
217
|
declare function SearchIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
281
218
|
|
|
282
219
|
declare function SendIcon(props: ComponentProps<"svg">): react_jsx_runtime.JSX.Element;
|
|
@@ -315,4 +252,4 @@ declare function useInitial<T>(value: T | (() => T)): T;
|
|
|
315
252
|
|
|
316
253
|
declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
|
|
317
254
|
|
|
318
|
-
export { AiChatAssistantMessage, AiChatAssistantMessageProps, AiChatComposer, AiChatComposerProps, AiChatUserMessage, AiChatUserMessageProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, CommentIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, MentionIcon, QuestionMarkIcon, RedoIcon, ResolveIcon, ResolvedIcon, RestoreIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, WarningIcon, capitalize, useInitial, useRefs };
|
|
255
|
+
export { AiChatAssistantMessage, AiChatAssistantMessageProps, AiChatComposer, AiChatComposerProps, AiChatUserMessage, AiChatUserMessageProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, CommentIcon, CopyIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, MentionIcon, QuestionMarkIcon, RedoIcon, ResolveIcon, ResolvedIcon, 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
|
@@ -26,6 +26,7 @@ export { ChevronRightIcon } from '../icons/ChevronRight.js';
|
|
|
26
26
|
export { ChevronUpIcon } from '../icons/ChevronUp.js';
|
|
27
27
|
export { CodeIcon } from '../icons/Code.js';
|
|
28
28
|
export { CommentIcon } from '../icons/Comment.js';
|
|
29
|
+
export { CopyIcon } from '../icons/Copy.js';
|
|
29
30
|
export { CrossIcon } from '../icons/Cross.js';
|
|
30
31
|
export { DeleteIcon } from '../icons/Delete.js';
|
|
31
32
|
export { EditIcon } from '../icons/Edit.js';
|
|
@@ -45,6 +46,7 @@ export { RedoIcon } from '../icons/Redo.js';
|
|
|
45
46
|
export { ResolveIcon } from '../icons/Resolve.js';
|
|
46
47
|
export { ResolvedIcon } from '../icons/Resolved.js';
|
|
47
48
|
export { RestoreIcon } from '../icons/Restore.js';
|
|
49
|
+
export { RetryIcon } from '../icons/Retry.js';
|
|
48
50
|
export { SearchIcon } from '../icons/Search.js';
|
|
49
51
|
export { SendIcon } from '../icons/Send.js';
|
|
50
52
|
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,217 @@
|
|
|
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 AiChatAssistantMessage = require('./internal/AiChatAssistantMessage.cjs');
|
|
13
|
+
var AiChatComposer = require('./internal/AiChatComposer.cjs');
|
|
14
|
+
var AiChatUserMessage = require('./internal/AiChatUserMessage.cjs');
|
|
15
|
+
|
|
16
|
+
const MIN_DISTANCE_TO_BOTTOM = 50;
|
|
17
|
+
const AiChat = react.forwardRef(
|
|
18
|
+
({
|
|
19
|
+
chatId,
|
|
20
|
+
copilotId,
|
|
21
|
+
autoFocus,
|
|
22
|
+
overrides: overrides$1,
|
|
23
|
+
knowledgeSources = [],
|
|
24
|
+
tools = {},
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}, forwardedRef) => {
|
|
28
|
+
const { messages, isLoading, error } = react$1.useAiChatMessages(chatId);
|
|
29
|
+
const $ = overrides.useOverrides(overrides$1);
|
|
30
|
+
const containerRef = react.useRef(null);
|
|
31
|
+
const [distanceToBottom, setDistanceToBottom] = react.useState(
|
|
32
|
+
null
|
|
33
|
+
);
|
|
34
|
+
const client = react$1.useClient();
|
|
35
|
+
react.useImperativeHandle(
|
|
36
|
+
forwardedRef,
|
|
37
|
+
() => containerRef.current,
|
|
38
|
+
[]
|
|
39
|
+
);
|
|
40
|
+
react.useEffect(() => {
|
|
41
|
+
const unregister = knowledgeSources.map(
|
|
42
|
+
(source) => client[core.kInternal].ai.registerKnowledgeSource(chatId, source)
|
|
43
|
+
);
|
|
44
|
+
return () => {
|
|
45
|
+
unregister.forEach((unregister2) => unregister2());
|
|
46
|
+
};
|
|
47
|
+
}, [client, chatId, knowledgeSources]);
|
|
48
|
+
react.useEffect(() => {
|
|
49
|
+
Object.entries(tools).map(
|
|
50
|
+
([key, value]) => client[core.kInternal].ai.registerChatTool(chatId, key, value)
|
|
51
|
+
);
|
|
52
|
+
return () => {
|
|
53
|
+
Object.entries(tools).map(
|
|
54
|
+
([key]) => client[core.kInternal].ai.unregisterChatTool(chatId, key)
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
}, [client, chatId, tools]);
|
|
58
|
+
react.useEffect(() => {
|
|
59
|
+
const container = containerRef.current;
|
|
60
|
+
if (container === null)
|
|
61
|
+
return;
|
|
62
|
+
function handleScrollChange() {
|
|
63
|
+
const container2 = containerRef.current;
|
|
64
|
+
if (container2 === null)
|
|
65
|
+
return;
|
|
66
|
+
setDistanceToBottom(
|
|
67
|
+
container2.scrollHeight - container2.clientHeight - container2.scrollTop
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
container.addEventListener("scroll", handleScrollChange);
|
|
71
|
+
return () => {
|
|
72
|
+
container.removeEventListener("scroll", handleScrollChange);
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
75
|
+
react.useEffect(() => {
|
|
76
|
+
const container = containerRef.current;
|
|
77
|
+
if (container === null)
|
|
78
|
+
return;
|
|
79
|
+
setDistanceToBottom(
|
|
80
|
+
container.scrollHeight - container.clientHeight - container.scrollTop
|
|
81
|
+
);
|
|
82
|
+
}, [messages]);
|
|
83
|
+
react.useEffect(() => {
|
|
84
|
+
const container = containerRef.current;
|
|
85
|
+
if (container === null)
|
|
86
|
+
return;
|
|
87
|
+
if (messages === void 0)
|
|
88
|
+
return;
|
|
89
|
+
const lastMessage = messages[messages.length - 1];
|
|
90
|
+
if (lastMessage !== void 0 && lastMessage.role === "user") {
|
|
91
|
+
container.scrollTo({
|
|
92
|
+
top: container.scrollHeight,
|
|
93
|
+
behavior: "smooth"
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}, [messages]);
|
|
97
|
+
react.useEffect(() => {
|
|
98
|
+
const container = containerRef.current;
|
|
99
|
+
if (container === null)
|
|
100
|
+
return;
|
|
101
|
+
const observer = new ResizeObserver(() => {
|
|
102
|
+
const container2 = containerRef.current;
|
|
103
|
+
if (container2 === null)
|
|
104
|
+
return;
|
|
105
|
+
setDistanceToBottom(
|
|
106
|
+
container2.scrollHeight - container2.clientHeight - container2.scrollTop
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
observer.observe(container);
|
|
110
|
+
return () => {
|
|
111
|
+
observer.disconnect();
|
|
112
|
+
};
|
|
113
|
+
}, []);
|
|
114
|
+
const scrollToBottomCallbackRef = react.useRef(void 0);
|
|
115
|
+
if (scrollToBottomCallbackRef.current === void 0) {
|
|
116
|
+
scrollToBottomCallbackRef.current = function() {
|
|
117
|
+
const container = containerRef.current;
|
|
118
|
+
if (container === null)
|
|
119
|
+
return;
|
|
120
|
+
container.scrollTo({
|
|
121
|
+
top: container.scrollHeight,
|
|
122
|
+
behavior: "instant"
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
const isScrollIndicatorVisible = distanceToBottom !== null && distanceToBottom > MIN_DISTANCE_TO_BOTTOM;
|
|
127
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
128
|
+
ref: containerRef,
|
|
129
|
+
...props,
|
|
130
|
+
className: classNames.classNames("lb-root lb-ai-chat", className),
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
133
|
+
className: "lb-ai-chat-content",
|
|
134
|
+
children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
135
|
+
className: "lb-loading lb-ai-chat-loading",
|
|
136
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Spinner.SpinnerIcon, {})
|
|
137
|
+
}) : error !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
138
|
+
className: "lb-error lb-ai-chat-error",
|
|
139
|
+
children: $.AI_CHAT_MESSAGES_ERROR(error)
|
|
140
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
141
|
+
className: "lb-ai-chat-messages",
|
|
142
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Messages, {
|
|
143
|
+
messages,
|
|
144
|
+
overrides: $,
|
|
145
|
+
onDistanceToBottomChange: scrollToBottomCallbackRef.current
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", {
|
|
150
|
+
className: "lb-ai-chat-footer",
|
|
151
|
+
children: [
|
|
152
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
153
|
+
className: "lb-ai-chat-footer-actions",
|
|
154
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", {
|
|
155
|
+
className: "lb-elevation lb-ai-chat-scroll-indicator",
|
|
156
|
+
"data-visible": isScrollIndicatorVisible ? "" : void 0,
|
|
157
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("button", {
|
|
158
|
+
className: "lb-ai-chat-scroll-indicator-button",
|
|
159
|
+
tabIndex: isScrollIndicatorVisible ? 0 : -1,
|
|
160
|
+
"aria-hidden": !isScrollIndicatorVisible,
|
|
161
|
+
disabled: !isScrollIndicatorVisible,
|
|
162
|
+
onClick: () => {
|
|
163
|
+
const container = containerRef.current;
|
|
164
|
+
if (container === null)
|
|
165
|
+
return;
|
|
166
|
+
container.scrollTo({
|
|
167
|
+
top: container.scrollHeight,
|
|
168
|
+
behavior: "smooth"
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
172
|
+
className: "lb-icon-container",
|
|
173
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDownIcon, {})
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx(AiChatComposer.AiChatComposer, {
|
|
179
|
+
chatId,
|
|
180
|
+
copilotId,
|
|
181
|
+
overrides: $,
|
|
182
|
+
autoFocus
|
|
183
|
+
}, chatId)
|
|
184
|
+
]
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
function Messages({
|
|
191
|
+
messages,
|
|
192
|
+
overrides: overrides$1,
|
|
193
|
+
onDistanceToBottomChange
|
|
194
|
+
}) {
|
|
195
|
+
const $ = overrides.useOverrides(overrides$1);
|
|
196
|
+
_private.useLayoutEffect(() => {
|
|
197
|
+
onDistanceToBottomChange();
|
|
198
|
+
}, [onDistanceToBottomChange]);
|
|
199
|
+
return messages.map((message) => {
|
|
200
|
+
if (message.role === "user") {
|
|
201
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiChatUserMessage.AiChatUserMessage, {
|
|
202
|
+
message,
|
|
203
|
+
overrides: $
|
|
204
|
+
}, message.id);
|
|
205
|
+
} else if (message.role === "assistant") {
|
|
206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiChatAssistantMessage.AiChatAssistantMessage, {
|
|
207
|
+
message,
|
|
208
|
+
overrides: $
|
|
209
|
+
}, message.id);
|
|
210
|
+
} else {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
exports.AiChat = AiChat;
|
|
217
|
+
//# sourceMappingURL=AiChat.cjs.map
|