@gravity-ui/aikit 1.7.0 → 1.9.0
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/README.md +0 -2
- package/dist/components/atoms/Alert/Alert.css +28 -0
- package/dist/components/atoms/Alert/index.js +1 -1
- package/dist/components/atoms/ChatDate/ChatDate.css +9 -0
- package/dist/components/atoms/ChatDate/ChatDate.js +1 -1
- package/dist/components/atoms/ContextIndicator/ContextIndicator.css +66 -0
- package/dist/components/atoms/ContextIndicator/index.js +1 -1
- package/dist/components/atoms/DiffStat/DiffStat.css +23 -0
- package/dist/components/atoms/DiffStat/index.js +1 -1
- package/dist/components/atoms/Disclaimer/Disclaimer.css +7 -0
- package/dist/components/atoms/Disclaimer/Disclaimer.js +1 -1
- package/dist/components/atoms/IntersectionContainer/IntersectionContainer.css +3 -0
- package/dist/components/atoms/IntersectionContainer/IntersectionContainer.js +1 -1
- package/dist/components/atoms/Loader/Loader.css +48 -0
- package/dist/components/atoms/Loader/Loader.js +1 -1
- package/dist/components/atoms/MarkdownRenderer/MarkdownRenderer.css +5 -0
- package/dist/components/atoms/MarkdownRenderer/MarkdownRenderer.js +1 -1
- package/dist/components/atoms/MessageBalloon/MessageBalloon.css +7 -0
- package/dist/components/atoms/MessageBalloon/index.js +1 -1
- package/dist/components/atoms/Shimmer/Shimmer.css +18 -0
- package/dist/components/atoms/Shimmer/index.js +1 -1
- package/dist/components/atoms/SubmitButton/SubmitButton.css +20 -0
- package/dist/components/atoms/SubmitButton/SubmitButton.js +1 -1
- package/dist/components/atoms/ToolIndicator/ToolIndicator.css +9 -0
- package/dist/components/atoms/ToolIndicator/index.js +1 -1
- package/dist/components/molecules/BaseMessage/BaseMessage.css +27 -0
- package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.d.ts +1 -0
- package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.js +10 -0
- package/dist/components/molecules/BaseMessage/index.js +22 -14
- package/dist/components/molecules/ButtonGroup/ButtonGroup.css +13 -0
- package/dist/components/molecules/ButtonGroup/index.js +1 -1
- package/dist/components/molecules/PromptInputBody/PromptInputBody.css +15 -0
- package/dist/components/molecules/PromptInputBody/PromptInputBody.js +1 -1
- package/dist/components/molecules/PromptInputFooter/PromptInputFooter.css +18 -0
- package/dist/components/molecules/PromptInputFooter/PromptInputFooter.js +1 -1
- package/dist/components/molecules/PromptInputHeader/PromptInputHeader.css +21 -0
- package/dist/components/molecules/PromptInputHeader/PromptInputHeader.js +1 -1
- package/dist/components/molecules/PromptInputPanel/PromptInputPanel.css +7 -0
- package/dist/components/molecules/PromptInputPanel/PromptInputPanel.js +1 -1
- package/dist/components/molecules/Suggestions/Suggestions.css +71 -0
- package/dist/components/molecules/Suggestions/Suggestions.js +1 -1
- package/dist/components/molecules/Tabs/Tabs.css +35 -0
- package/dist/components/molecules/Tabs/Tabs.js +1 -1
- package/dist/components/molecules/ToolFooter/ToolFooter.css +10 -0
- package/dist/components/molecules/ToolFooter/index.js +1 -1
- package/dist/components/molecules/ToolHeader/ToolHeader.css +18 -0
- package/dist/components/molecules/ToolHeader/index.js +1 -1
- package/dist/components/molecules/ToolStatus/ToolStatus.css +1 -0
- package/dist/components/molecules/ToolStatus/index.js +1 -1
- package/dist/components/organisms/AssistantMessage/AssistantMessage.css +6 -0
- package/dist/components/organisms/AssistantMessage/AssistantMessage.d.ts +2 -2
- package/dist/components/organisms/AssistantMessage/AssistantMessage.js +3 -3
- package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts +1 -0
- package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js +12 -1
- package/dist/components/organisms/Header/Header.css +40 -0
- package/dist/components/organisms/Header/Header.js +1 -1
- package/dist/components/organisms/MessageList/MessageList.css +26 -0
- package/dist/components/organisms/MessageList/MessageList.js +2 -2
- package/dist/components/organisms/MessageList/__stories__/MessageList.stories.d.ts +1 -0
- package/dist/components/organisms/MessageList/__stories__/MessageList.stories.js +54 -4
- package/dist/components/organisms/PromptInput/PromptInput.css +50 -0
- package/dist/components/organisms/PromptInput/PromptInput.js +1 -1
- package/dist/components/organisms/ThinkingMessage/ThinkingMessage.css +20 -0
- package/dist/components/organisms/ThinkingMessage/index.js +1 -1
- package/dist/components/organisms/ToolMessage/ToolMessage.css +13 -0
- package/dist/components/organisms/ToolMessage/index.js +1 -1
- package/dist/components/organisms/UserMessage/UserMessage.css +10 -0
- package/dist/components/organisms/UserMessage/index.js +1 -1
- package/dist/components/pages/ChatContainer/ChatContainer.css +49 -0
- package/dist/components/pages/ChatContainer/ChatContainer.js +1 -1
- package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.d.ts +5 -0
- package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.js +77 -0
- package/dist/components/templates/ChatContent/ChatContent.css +23 -0
- package/dist/components/templates/ChatContent/ChatContent.js +1 -1
- package/dist/components/templates/EmptyContainer/EmptyContainer.css +64 -0
- package/dist/components/templates/EmptyContainer/EmptyContainer.js +1 -1
- package/dist/components/templates/History/History.css +81 -0
- package/dist/components/templates/History/HistoryList.js +1 -1
- package/dist/demo/ContentWrapper/ContentWrapper.css +6 -0
- package/dist/demo/ContentWrapper/ContentWrapper.js +1 -1
- package/dist/demo/DocsDecorator/DocsDecorator.css +87 -0
- package/dist/demo/Showcase/Showcase.css +34 -0
- package/dist/demo/Showcase/Showcase.js +1 -1
- package/dist/demo/ShowcaseItem/ShowcaseItem.css +7 -0
- package/dist/demo/ShowcaseItem/ShowcaseItem.js +1 -1
- package/dist/demo/SwapArea/SwapArea.css +11 -0
- package/dist/demo/SwapArea/SwapArea.js +1 -1
- package/dist/styles/variables.css +1 -0
- package/dist/types/messages.d.ts +3 -0
- package/package.json +6 -5
- package/dist/components/atoms/Alert/Alert.scss +0 -39
- package/dist/components/atoms/ChatDate/ChatDate.scss +0 -15
- package/dist/components/atoms/ContextIndicator/ContextIndicator.scss +0 -93
- package/dist/components/atoms/DiffStat/DiffStat.scss +0 -36
- package/dist/components/atoms/Disclaimer/Disclaimer.scss +0 -13
- package/dist/components/atoms/IntersectionContainer/IntersectionContainer.scss +0 -7
- package/dist/components/atoms/Loader/Loader.scss +0 -72
- package/dist/components/atoms/MarkdownRenderer/MarkdownRenderer.scss +0 -10
- package/dist/components/atoms/MessageBalloon/MessageBalloon.scss +0 -11
- package/dist/components/atoms/Shimmer/Shimmer.scss +0 -32
- package/dist/components/atoms/SubmitButton/SubmitButton.scss +0 -29
- package/dist/components/atoms/ToolIndicator/ToolIndicator.scss +0 -15
- package/dist/components/molecules/BaseMessage/BaseMessage.scss +0 -41
- package/dist/components/molecules/ButtonGroup/ButtonGroup.scss +0 -19
- package/dist/components/molecules/PromptInputBody/PromptInputBody.scss +0 -22
- package/dist/components/molecules/PromptInputFooter/PromptInputFooter.scss +0 -25
- package/dist/components/molecules/PromptInputHeader/PromptInputHeader.scss +0 -27
- package/dist/components/molecules/PromptInputPanel/PromptInputPanel.scss +0 -11
- package/dist/components/molecules/Suggestions/Suggestions.scss +0 -90
- package/dist/components/molecules/Tabs/Tabs.scss +0 -46
- package/dist/components/molecules/ToolFooter/ToolFooter.scss +0 -15
- package/dist/components/molecules/ToolHeader/ToolHeader.scss +0 -24
- package/dist/components/molecules/ToolStatus/ToolStatus.scss +0 -6
- package/dist/components/organisms/AssistantMessage/AssistantMessage.scss +0 -10
- package/dist/components/organisms/Header/Header.scss +0 -51
- package/dist/components/organisms/MessageList/MessageList.scss +0 -35
- package/dist/components/organisms/PromptInput/PromptInput.scss +0 -77
- package/dist/components/organisms/ThinkingMessage/ThinkingMessage.scss +0 -27
- package/dist/components/organisms/ToolMessage/ToolMessage.scss +0 -19
- package/dist/components/organisms/UserMessage/UserMessage.scss +0 -14
- package/dist/components/pages/ChatContainer/ChatContainer.scss +0 -60
- package/dist/components/templates/ChatContent/ChatContent.scss +0 -30
- package/dist/components/templates/EmptyContainer/EmptyContainer.scss +0 -86
- package/dist/components/templates/History/History.scss +0 -103
- package/dist/styles/_functions.scss +0 -5
- package/dist/styles/variables.scss +0 -1
- /package/dist/styles/{styles.scss → styles.css} +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.g-aikit-chat-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
height: 100%;
|
|
5
|
+
width: 100%;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
background: var(--g-aikit-chat-container-background);
|
|
8
|
+
}
|
|
9
|
+
.g-aikit-chat-container__header {
|
|
10
|
+
display: flex;
|
|
11
|
+
padding: var(--g-aikit-layout-base-padding-m);
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
gap: var(--g-spacing-2);
|
|
15
|
+
align-self: stretch;
|
|
16
|
+
background: var(--g-aikit-chat-container-header-background);
|
|
17
|
+
}
|
|
18
|
+
.g-aikit-chat-container__content {
|
|
19
|
+
min-height: 0;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
align-self: stretch;
|
|
24
|
+
background: var(--g-aikit-chat-container-content-background);
|
|
25
|
+
padding: 0 var(--g-aikit-layout-base-padding-m) var(--g-spacing-4) var(--g-aikit-layout-base-padding-m);
|
|
26
|
+
gap: var(--g-spacing-2);
|
|
27
|
+
flex: 1 0 0;
|
|
28
|
+
}
|
|
29
|
+
.g-aikit-chat-container__content_view_empty {
|
|
30
|
+
background: var(--g-aikit-chat-container-content-empty-background);
|
|
31
|
+
}
|
|
32
|
+
.g-aikit-chat-container__content_view_chat {
|
|
33
|
+
background: var(--g-aikit-chat-container-content-chat-background);
|
|
34
|
+
}
|
|
35
|
+
.g-aikit-chat-container__footer {
|
|
36
|
+
display: flex;
|
|
37
|
+
padding: var(--g-aikit-layout-base-padding-m);
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
gap: var(--g-spacing-1);
|
|
41
|
+
align-self: stretch;
|
|
42
|
+
background: var(--g-aikit-chat-container-footer-background);
|
|
43
|
+
}
|
|
44
|
+
.g-aikit-chat-container__footer_view_empty {
|
|
45
|
+
background: var(--g-aikit-chat-container-footer-empty-background);
|
|
46
|
+
}
|
|
47
|
+
.g-aikit-chat-container__footer_view_chat {
|
|
48
|
+
background: var(--g-aikit-chat-container-footer-chat-background);
|
|
49
|
+
}
|
|
@@ -8,7 +8,7 @@ import { ChatContent } from '../../templates/ChatContent';
|
|
|
8
8
|
import { History } from '../../templates/History';
|
|
9
9
|
import { i18n } from './i18n';
|
|
10
10
|
import { useChatContainer } from './useChatContainer';
|
|
11
|
-
import './ChatContainer.
|
|
11
|
+
import './ChatContainer.css';
|
|
12
12
|
const b = block('chat-container');
|
|
13
13
|
/**
|
|
14
14
|
* ChatContainer - fully assembled chat component, the main exportable component of the library.
|
|
@@ -83,3 +83,8 @@ export declare const EmbeddedInPageWithStreaming: Story;
|
|
|
83
83
|
* Demonstrates passing additional actions to Header and custom actions to BaseMessage
|
|
84
84
|
*/
|
|
85
85
|
export declare const WithAdditionalActions: Story;
|
|
86
|
+
/**
|
|
87
|
+
* Like / Unlike actions with local rating state.
|
|
88
|
+
* Only like and unlike actions; rating toggles on repeated click (like → clear, dislike → clear).
|
|
89
|
+
*/
|
|
90
|
+
export declare const WithLikeUnlikeActions: Story;
|
|
@@ -5,6 +5,7 @@ import { Gear, Sparkles, Star } from '@gravity-ui/icons';
|
|
|
5
5
|
import { Icon } from '@gravity-ui/uikit';
|
|
6
6
|
import { ChatContainer } from '..';
|
|
7
7
|
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
8
|
+
import { BaseMessageActionType } from '../../../molecules/BaseMessage';
|
|
8
9
|
import MDXDocs from './Docs.mdx';
|
|
9
10
|
export default {
|
|
10
11
|
title: 'pages/ChatContainer',
|
|
@@ -1110,3 +1111,79 @@ export const WithAdditionalActions = {
|
|
|
1110
1111
|
},
|
|
1111
1112
|
decorators: defaultDecorators,
|
|
1112
1113
|
};
|
|
1114
|
+
/**
|
|
1115
|
+
* Like / Unlike actions with local rating state.
|
|
1116
|
+
* Only like and unlike actions; rating toggles on repeated click (like → clear, dislike → clear).
|
|
1117
|
+
*/
|
|
1118
|
+
export const WithLikeUnlikeActions = {
|
|
1119
|
+
args: {
|
|
1120
|
+
chats: mockChats,
|
|
1121
|
+
activeChat: mockChats[0],
|
|
1122
|
+
showHistory: true,
|
|
1123
|
+
showNewChat: true,
|
|
1124
|
+
showActionsOnHover: true,
|
|
1125
|
+
},
|
|
1126
|
+
render: (args) => {
|
|
1127
|
+
const initialChat = mockChats[0];
|
|
1128
|
+
const [messages, setMessages] = useState(() => mockChatMessages[initialChat.id] || []);
|
|
1129
|
+
const [status, setStatus] = useState('ready');
|
|
1130
|
+
const [activeChat, setActiveChat] = useState(initialChat);
|
|
1131
|
+
const assistantActions = [
|
|
1132
|
+
{
|
|
1133
|
+
type: BaseMessageActionType.Like,
|
|
1134
|
+
onClick: (message) => {
|
|
1135
|
+
setMessages((prev) => prev.map((m) => m.id === message.id
|
|
1136
|
+
? Object.assign(Object.assign({}, m), { userRating: m.userRating === 'like'
|
|
1137
|
+
? undefined
|
|
1138
|
+
: 'like' }) : m));
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
type: BaseMessageActionType.Unlike,
|
|
1143
|
+
onClick: (message) => {
|
|
1144
|
+
setMessages((prev) => prev.map((m) => m.id === message.id
|
|
1145
|
+
? Object.assign(Object.assign({}, m), { userRating: m.userRating === 'dislike'
|
|
1146
|
+
? undefined
|
|
1147
|
+
: 'dislike' }) : m));
|
|
1148
|
+
},
|
|
1149
|
+
},
|
|
1150
|
+
];
|
|
1151
|
+
const handleSendMessage = async (data) => {
|
|
1152
|
+
const timestamp = Date.now();
|
|
1153
|
+
const userMessageId = `user-${timestamp}`;
|
|
1154
|
+
const userMessage = {
|
|
1155
|
+
id: userMessageId,
|
|
1156
|
+
role: 'user',
|
|
1157
|
+
content: data.content,
|
|
1158
|
+
timestamp: new Date().toISOString(),
|
|
1159
|
+
};
|
|
1160
|
+
setMessages((prev) => [...prev, userMessage]);
|
|
1161
|
+
setStatus('streaming');
|
|
1162
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
1163
|
+
const assistantMessageId = `assistant-${timestamp + 1}`;
|
|
1164
|
+
const assistantMessage = {
|
|
1165
|
+
id: assistantMessageId,
|
|
1166
|
+
role: 'assistant',
|
|
1167
|
+
content: `Response to: "${data.content}". Use like/unlike below — they toggle on second click.`,
|
|
1168
|
+
timestamp: new Date().toISOString(),
|
|
1169
|
+
};
|
|
1170
|
+
setMessages((prev) => [...prev, assistantMessage]);
|
|
1171
|
+
setStatus('ready');
|
|
1172
|
+
};
|
|
1173
|
+
const handleSelectChat = (chat) => {
|
|
1174
|
+
setActiveChat(chat);
|
|
1175
|
+
setMessages(mockChatMessages[chat.id] || []);
|
|
1176
|
+
};
|
|
1177
|
+
const handleCreateChat = () => {
|
|
1178
|
+
setActiveChat(null);
|
|
1179
|
+
setMessages([]);
|
|
1180
|
+
};
|
|
1181
|
+
const handleCancel = async () => {
|
|
1182
|
+
setStatus('ready');
|
|
1183
|
+
};
|
|
1184
|
+
return (_jsx(ChatContainer, Object.assign({}, args, { messages: messages, activeChat: activeChat, onSendMessage: handleSendMessage, onCancel: handleCancel, onSelectChat: handleSelectChat, onCreateChat: handleCreateChat, status: status, messageListConfig: {
|
|
1185
|
+
assistantActions,
|
|
1186
|
+
} })));
|
|
1187
|
+
},
|
|
1188
|
+
decorators: defaultDecorators,
|
|
1189
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.g-aikit-chat-content {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
height: 100%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
background: var(--g-aikit-chat-content-background);
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
gap: var(--g-spacing-2);
|
|
9
|
+
flex: 1 0 0;
|
|
10
|
+
align-self: stretch;
|
|
11
|
+
}
|
|
12
|
+
.g-aikit-chat-content__message-list-container {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: flex-start;
|
|
16
|
+
gap: var(--g-spacing-4);
|
|
17
|
+
align-self: stretch;
|
|
18
|
+
flex: 1;
|
|
19
|
+
min-height: 0;
|
|
20
|
+
}
|
|
21
|
+
.g-aikit-chat-content__message-list {
|
|
22
|
+
padding: var(--g-spacing-2) var(--g-spacing-2) 0 var(--g-spacing-2);
|
|
23
|
+
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { block } from '../../../utils/cn';
|
|
3
3
|
import { MessageList } from '../../organisms/MessageList';
|
|
4
4
|
import { EmptyContainer } from '../EmptyContainer';
|
|
5
|
-
import './ChatContent.
|
|
5
|
+
import './ChatContent.css';
|
|
6
6
|
const b = block('chat-content');
|
|
7
7
|
/**
|
|
8
8
|
* ChatContent - main chat content with state switching (EmptyContainer/MessageList).
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.g-aikit-empty-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
height: 100%;
|
|
5
|
+
width: 100%;
|
|
6
|
+
background: var(--g-aikit-empty-container-background);
|
|
7
|
+
}
|
|
8
|
+
.g-aikit-empty-container__content {
|
|
9
|
+
flex: 1;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
align-self: stretch;
|
|
13
|
+
gap: var(--g-aikit-empty-container-content-gap);
|
|
14
|
+
padding: var(--g-aikit-empty-container-padding);
|
|
15
|
+
}
|
|
16
|
+
.g-aikit-empty-container__welcome-section {
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: var(--g-spacing-6);
|
|
20
|
+
}
|
|
21
|
+
.g-aikit-empty-container__text-container {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: var(--g-spacing-3);
|
|
25
|
+
}
|
|
26
|
+
.g-aikit-empty-container__image-container {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex: 1;
|
|
29
|
+
}
|
|
30
|
+
.g-aikit-empty-container__image-container_align_left {
|
|
31
|
+
justify-content: flex-start;
|
|
32
|
+
}
|
|
33
|
+
.g-aikit-empty-container__image-container_align_center {
|
|
34
|
+
justify-content: center;
|
|
35
|
+
}
|
|
36
|
+
.g-aikit-empty-container__image-container_align_right {
|
|
37
|
+
justify-content: flex-end;
|
|
38
|
+
}
|
|
39
|
+
.g-aikit-empty-container__title_align_left, .g-aikit-empty-container__description_align_left {
|
|
40
|
+
text-align: left;
|
|
41
|
+
}
|
|
42
|
+
.g-aikit-empty-container__title_align_center, .g-aikit-empty-container__description_align_center {
|
|
43
|
+
text-align: center;
|
|
44
|
+
}
|
|
45
|
+
.g-aikit-empty-container__title_align_right, .g-aikit-empty-container__description_align_right {
|
|
46
|
+
text-align: right;
|
|
47
|
+
}
|
|
48
|
+
.g-aikit-empty-container__suggestions-section {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: var(--g-spacing-3);
|
|
52
|
+
}
|
|
53
|
+
.g-aikit-empty-container__suggestions-title {
|
|
54
|
+
display: flex;
|
|
55
|
+
padding: 0 var(--g-spacing-2);
|
|
56
|
+
align-items: flex-start;
|
|
57
|
+
gap: var(--g-spacing-2);
|
|
58
|
+
align-self: stretch;
|
|
59
|
+
}
|
|
60
|
+
.g-aikit-empty-container__show-more {
|
|
61
|
+
display: flex;
|
|
62
|
+
justify-content: flex-start;
|
|
63
|
+
padding-top: var(--g-spacing-2);
|
|
64
|
+
}
|
|
@@ -4,7 +4,7 @@ import { Button, Text } from '@gravity-ui/uikit';
|
|
|
4
4
|
import { block } from '../../../utils/cn';
|
|
5
5
|
import { Suggestions } from '../../molecules/Suggestions';
|
|
6
6
|
import { i18n } from './i18n';
|
|
7
|
-
import './EmptyContainer.
|
|
7
|
+
import './EmptyContainer.css';
|
|
8
8
|
const b = block('empty-container');
|
|
9
9
|
/**
|
|
10
10
|
* EmptyContainer component - displays a welcome screen with image, title, description,
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.g-aikit-history__container {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: var(--g-aikit-history-width);
|
|
5
|
+
background: var(--g-color-base-background);
|
|
6
|
+
}
|
|
7
|
+
.g-aikit-history__list-wrapper {
|
|
8
|
+
flex: 1;
|
|
9
|
+
}
|
|
10
|
+
.g-aikit-history__list {
|
|
11
|
+
padding: 0 calc(var(--g-spacing-base) * 2) 0 calc(var(--g-spacing-base) * 2);
|
|
12
|
+
overflow: auto;
|
|
13
|
+
max-height: var(--g-aikit-history-max-height);
|
|
14
|
+
}
|
|
15
|
+
.g-aikit-history__list-item {
|
|
16
|
+
border-radius: 6px;
|
|
17
|
+
}
|
|
18
|
+
.g-aikit-history__filter {
|
|
19
|
+
padding: calc(var(--g-spacing-base) * 2);
|
|
20
|
+
border-bottom: 1px solid var(--g-color-line-generic);
|
|
21
|
+
margin-bottom: 0;
|
|
22
|
+
}
|
|
23
|
+
.g-aikit-history__date-header {
|
|
24
|
+
display: flex;
|
|
25
|
+
padding: var(--g-spacing-3) var(--g-spacing-2) var(--g-spacing-1) var(--g-spacing-2);
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
gap: calc(var(--g-spacing-base) * 3);
|
|
29
|
+
align-self: stretch;
|
|
30
|
+
}
|
|
31
|
+
.g-aikit-history__chat-item {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
display: flex;
|
|
34
|
+
padding: calc(var(--g-spacing-base) * 2) calc(var(--g-spacing-base) * 4);
|
|
35
|
+
align-items: center;
|
|
36
|
+
gap: calc(var(--g-spacing-base) * 4);
|
|
37
|
+
align-self: stretch;
|
|
38
|
+
flex: 1;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
}
|
|
41
|
+
.g-aikit-history__chat-item_active .g-aikit-history__delete-button {
|
|
42
|
+
display: block;
|
|
43
|
+
}
|
|
44
|
+
.g-aikit-history__chat-content {
|
|
45
|
+
height: var(--g-aikit-history-item-height);
|
|
46
|
+
flex: 1;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
}
|
|
52
|
+
.g-aikit-history__chat-content > * {
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
white-space: nowrap;
|
|
56
|
+
min-width: 0;
|
|
57
|
+
}
|
|
58
|
+
.g-aikit-history__icon-button {
|
|
59
|
+
color: var(--g-color-text-secondary);
|
|
60
|
+
}
|
|
61
|
+
.g-aikit-history__delete-button {
|
|
62
|
+
margin-left: calc(var(--g-spacing-base) * 2);
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
.g-aikit-history__empty {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
padding: calc(var(--g-spacing-base) * 8) calc(var(--g-spacing-base) * 4);
|
|
70
|
+
color: var(--g-color-text-secondary);
|
|
71
|
+
font-size: var(--g-text-body-2-font-size);
|
|
72
|
+
text-align: center;
|
|
73
|
+
flex: 1;
|
|
74
|
+
}
|
|
75
|
+
.g-aikit-history__loader-wrapper {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
padding: calc(var(--g-spacing-base) * 8) calc(var(--g-spacing-base) * 4);
|
|
80
|
+
flex: 1;
|
|
81
|
+
}
|
|
@@ -7,7 +7,7 @@ import { Loader } from '../../atoms/Loader';
|
|
|
7
7
|
import { ChatItem } from './ChatItem';
|
|
8
8
|
import { DateHeaderItem } from './DateHeaderItem';
|
|
9
9
|
import { i18n } from './i18n';
|
|
10
|
-
import './History.
|
|
10
|
+
import './History.css';
|
|
11
11
|
const b = block('history');
|
|
12
12
|
/**
|
|
13
13
|
* HistoryList component - displays a list of chats with search, grouping, and actions
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cn } from '../../utils/cn';
|
|
4
|
-
import './ContentWrapper.
|
|
4
|
+
import './ContentWrapper.css';
|
|
5
5
|
const b = cn('content-wrapper');
|
|
6
6
|
export function ContentWrapper(props) {
|
|
7
7
|
const { children } = props, style = __rest(props, ["children"]);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p,
|
|
2
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator li:not([class*=g-aikit-]),
|
|
3
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator a:not([class*=g-aikit-]) {
|
|
4
|
+
font-family: var(--g-text-body-font-family);
|
|
5
|
+
font-weight: var(--g-text-body-font-weight);
|
|
6
|
+
font-size: var(--g-text-body-2-font-size);
|
|
7
|
+
line-height: var(--g-text-body-2-line-height);
|
|
8
|
+
}
|
|
9
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator .sbdocs-wrapper {
|
|
10
|
+
padding: 0 40px;
|
|
11
|
+
}
|
|
12
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator .sbdocs-content {
|
|
13
|
+
max-width: 800px;
|
|
14
|
+
}
|
|
15
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p,
|
|
16
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ul:not([class*=g-aikit-]),
|
|
17
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ol:not([class*=g-aikit-]) {
|
|
18
|
+
margin: 4px 0;
|
|
19
|
+
}
|
|
20
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p + p, .docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p + ul, .docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p + ol,
|
|
21
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ul:not([class*=g-aikit-]) + p,
|
|
22
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ul:not([class*=g-aikit-]) + ul,
|
|
23
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ul:not([class*=g-aikit-]) + ol,
|
|
24
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ol:not([class*=g-aikit-]) + p,
|
|
25
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ol:not([class*=g-aikit-]) + ul,
|
|
26
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ol:not([class*=g-aikit-]) + ol {
|
|
27
|
+
margin-block-start: 8px;
|
|
28
|
+
}
|
|
29
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator li + li:not([class*=g-aikit-]) {
|
|
30
|
+
margin-block-start: 4px;
|
|
31
|
+
}
|
|
32
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ul:not([class*=g-aikit-]),
|
|
33
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator ol:not([class*=g-aikit-]) {
|
|
34
|
+
padding-inline-start: 16px;
|
|
35
|
+
}
|
|
36
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h1 {
|
|
37
|
+
font-family: var(--g-text-display-font-family);
|
|
38
|
+
font-weight: var(--g-text-display-font-weight);
|
|
39
|
+
font-size: var(--g-text-display-3-font-size);
|
|
40
|
+
line-height: var(--g-text-display-3-line-height);
|
|
41
|
+
}
|
|
42
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h2 {
|
|
43
|
+
font-family: var(--g-text-display-font-family);
|
|
44
|
+
font-weight: var(--g-text-display-font-weight);
|
|
45
|
+
font-size: var(--g-text-display-1-font-size);
|
|
46
|
+
line-height: var(--g-text-display-1-line-height);
|
|
47
|
+
border: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
}
|
|
50
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h3 {
|
|
51
|
+
font-family: var(--g-text-header-font-family);
|
|
52
|
+
font-weight: var(--g-text-header-font-weight);
|
|
53
|
+
font-size: var(--g-text-header-2-font-size);
|
|
54
|
+
line-height: var(--g-text-header-2-line-height);
|
|
55
|
+
}
|
|
56
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h1,
|
|
57
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h2,
|
|
58
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator h3 {
|
|
59
|
+
margin-block: 40px 16px;
|
|
60
|
+
}
|
|
61
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator a:not([class*=g-aikit-]) {
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
touch-action: manipulation;
|
|
64
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
color: var(--g-color-text-link);
|
|
67
|
+
}
|
|
68
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator a:not([class*=g-aikit-]):hover {
|
|
69
|
+
color: var(--g-color-text-link-hover);
|
|
70
|
+
}
|
|
71
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator p code,
|
|
72
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator li:not([class*=g-aikit-]) code {
|
|
73
|
+
font-family: var(--g-text-code-font-family);
|
|
74
|
+
font-weight: var(--g-text-code-font-weight);
|
|
75
|
+
font-size: var(--g-text-code-inline-2-font-size);
|
|
76
|
+
line-height: var(--g-text-code-inline-2-line-height);
|
|
77
|
+
line-height: 1;
|
|
78
|
+
padding: 1px 4px;
|
|
79
|
+
background: var(--g-color-base-misc-light);
|
|
80
|
+
color: var(--g-color-text-misc);
|
|
81
|
+
}
|
|
82
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator .docblock-source {
|
|
83
|
+
margin: 16px 0;
|
|
84
|
+
}
|
|
85
|
+
.docs-decorator.docs-decorator.docs-decorator.docs-decorator.docs-decorator .docs-example {
|
|
86
|
+
margin: 16px 0;
|
|
87
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.showcase {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
.showcase + .showcase {
|
|
6
|
+
margin-block-start: var(--g-spacing-9);
|
|
7
|
+
}
|
|
8
|
+
.showcase__title {
|
|
9
|
+
font-family: var(--g-text-display-font-family);
|
|
10
|
+
font-weight: var(--g-text-display-font-weight);
|
|
11
|
+
font-size: var(--g-text-display-2-font-size);
|
|
12
|
+
line-height: var(--g-text-display-2-line-height);
|
|
13
|
+
}
|
|
14
|
+
.showcase__description {
|
|
15
|
+
font-family: var(--g-text-body-font-family);
|
|
16
|
+
font-weight: var(--g-text-body-font-weight);
|
|
17
|
+
font-size: var(--g-text-body-2-font-size);
|
|
18
|
+
line-height: var(--g-text-body-2-line-height);
|
|
19
|
+
margin-block-start: var(--g-spacing-2);
|
|
20
|
+
color: var(--g-color-text-secondary);
|
|
21
|
+
}
|
|
22
|
+
.showcase__content {
|
|
23
|
+
flex-grow: 1;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
gap: var(--g-spacing-6);
|
|
27
|
+
}
|
|
28
|
+
.showcase__content:not(:only-child) {
|
|
29
|
+
margin-block-start: var(--g-spacing-5);
|
|
30
|
+
}
|
|
31
|
+
.showcase_direction_column .showcase__content {
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
-
import './Showcase.
|
|
3
|
+
import './Showcase.css';
|
|
4
4
|
const b = cn('showcase');
|
|
5
5
|
export function Showcase({ title, description, direction = 'row', className, children }) {
|
|
6
6
|
return (_jsxs("div", { className: b({ direction }, className), children: [title && _jsx("div", { className: b('title'), children: title }), description && _jsx("div", { className: b('description'), children: description }), _jsx("div", { className: b('content'), children: children })] }));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
.showcase-item__title {
|
|
2
|
+
font-family: var(--g-text-subheader-font-family);
|
|
3
|
+
font-weight: var(--g-text-subheader-font-weight);
|
|
4
|
+
font-size: var(--g-text-subheader-3-font-size);
|
|
5
|
+
line-height: var(--g-text-subheader-3-line-height);
|
|
6
|
+
margin-block-end: var(--g-spacing-3);
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '../../utils/cn';
|
|
3
|
-
import './ShowcaseItem.
|
|
3
|
+
import './ShowcaseItem.css';
|
|
4
4
|
const b = cn('showcase-item');
|
|
5
5
|
export function ShowcaseItem({ title, children, width }) {
|
|
6
6
|
return (_jsxs("div", { className: b(), style: { width }, children: [_jsx("div", { className: b('title'), children: title }), _jsx("div", { className: b('content'), children: children })] }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.g-aikit-swap-area {
|
|
2
|
+
display: flex;
|
|
3
|
+
padding: 3px 6px;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
align-items: center;
|
|
6
|
+
flex: 1 0 0;
|
|
7
|
+
align-self: stretch;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
border: 1px dashed var(--g-color-line-generic);
|
|
10
|
+
background: var(--g-color-base-generic);
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { block } from '../../utils/cn';
|
|
3
|
-
import './SwapArea.
|
|
3
|
+
import './SwapArea.css';
|
|
4
4
|
const b = block('swap-area');
|
|
5
5
|
export const SwapArea = () => {
|
|
6
6
|
return _jsx("div", { className: b(), children: "Swap Area" });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -8,10 +8,12 @@ export type BaseMessageActionConfig = ActionConfig;
|
|
|
8
8
|
* - React.ReactNode for fully custom content
|
|
9
9
|
*/
|
|
10
10
|
export type BaseMessageAction = BaseMessageActionConfig | React.ReactNode;
|
|
11
|
+
export type UserRating = 'like' | 'dislike';
|
|
11
12
|
export type BaseMessageProps = {
|
|
12
13
|
children: React.ReactNode;
|
|
13
14
|
role: TMessageRole;
|
|
14
15
|
actions?: BaseMessageAction[];
|
|
16
|
+
userRating?: UserRating;
|
|
15
17
|
timestamp?: string;
|
|
16
18
|
showTimestamp?: boolean;
|
|
17
19
|
showActionsOnHover?: boolean;
|
|
@@ -65,5 +67,6 @@ export type TUserMessage<Metadata = TMessageMetadata> = TBaseMessage<Metadata> &
|
|
|
65
67
|
export type TAssistantMessage<TCustomMessageContent extends TMessageContent = never, Metadata = TMessageMetadata> = TBaseMessage<Metadata> & {
|
|
66
68
|
role: 'assistant';
|
|
67
69
|
content: TAssistantMessageContent<TCustomMessageContent>;
|
|
70
|
+
userRating?: UserRating;
|
|
68
71
|
};
|
|
69
72
|
export type TChatMessage<TCustomMessageContent extends TMessageContent = never, Metadata = TMessageMetadata> = TUserMessage<Metadata> | TAssistantMessage<TCustomMessageContent, Metadata>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/aikit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Gravity UI base kit for building ai assistant chats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./styles": "./dist/styles/styles.
|
|
13
|
+
"./styles": "./dist/styles/styles.css",
|
|
14
14
|
"./themes/common": "./dist/themes/common.css",
|
|
15
15
|
"./themes/dark": "./dist/themes/dark.css",
|
|
16
16
|
"./themes/light": "./dist/themes/light.css",
|
|
@@ -55,11 +55,12 @@
|
|
|
55
55
|
"lint:prettier": "prettier --check '**/*.{js,jsx,ts,tsx,css,scss,json,yaml,yml,md,mdx}'",
|
|
56
56
|
"lint:prettier:fix": "prettier --write '**/*.{js,jsx,ts,tsx,css,scss,json,yaml,yml,md,mdx}'",
|
|
57
57
|
"test": "npm run test:unit && npm run test:server:unit",
|
|
58
|
-
"build": "npm run build:clean && npm run build:ts && npm run build:copy && npm run build:server",
|
|
58
|
+
"build": "npm run build:clean && npm run build:ts && npm run build:fix-imports && npm run build:compile:scss && npm run build:copy && npm run build:server",
|
|
59
59
|
"build:clean": "rm -rf dist",
|
|
60
60
|
"build:ts": "tsc",
|
|
61
|
-
"build:
|
|
62
|
-
"build:
|
|
61
|
+
"build:compile:scss": "sass --no-source-map --load-path=src --load-path=node_modules src:dist",
|
|
62
|
+
"build:fix-imports": "find dist -type f -name '*.js' -exec perl -i -pe \"s/\\.scss'/.css'/g; s/\\.scss\\\"/.css\\\"/g\" {} +",
|
|
63
|
+
"build:copy": "npm run build:copy:themes && npm run build:copy:i18n",
|
|
63
64
|
"build:copy:themes": "copyfiles -u 1 'src/themes/**/*.css' dist",
|
|
64
65
|
"build:copy:i18n": "copyfiles -u 1 'src/**/i18n/*.json' dist",
|
|
65
66
|
"build:server": "tsc -p src/server/tsconfig.esm.json && tsc -p src/server/tsconfig.cjs.json",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
@use '../../../styles/variables';
|
|
2
|
-
|
|
3
|
-
$block: '.#{variables.$ns}alert';
|
|
4
|
-
|
|
5
|
-
#{$block} {
|
|
6
|
-
display: flex;
|
|
7
|
-
flex-direction: column;
|
|
8
|
-
gap: var(--g-spacing-2);
|
|
9
|
-
|
|
10
|
-
&__header {
|
|
11
|
-
display: flex;
|
|
12
|
-
align-items: center;
|
|
13
|
-
gap: var(--g-spacing-2);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&__text {
|
|
17
|
-
flex: 1;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&__icon {
|
|
21
|
-
flex-shrink: 0;
|
|
22
|
-
|
|
23
|
-
&_variant_error {
|
|
24
|
-
color: var(--g-color-text-danger);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&_variant_warning {
|
|
28
|
-
color: var(--g-color-text-warning-heavy);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&_variant_info {
|
|
32
|
-
color: var(--g-color-text-info);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&__action {
|
|
37
|
-
margin-left: auto;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
@use '../../../styles/variables';
|
|
2
|
-
|
|
3
|
-
$block: '.#{variables.$ns}chat-date';
|
|
4
|
-
|
|
5
|
-
#{$block} {
|
|
6
|
-
color: var(--g-color-text-secondary);
|
|
7
|
-
|
|
8
|
-
font-family: var(--g-text-body-font-family);
|
|
9
|
-
font-size: var(--g-text-body-1-font-size);
|
|
10
|
-
font-style: normal;
|
|
11
|
-
font-weight: var(--g-text-body-font-weight);
|
|
12
|
-
line-height: var(--g-text-body-1-line-height);
|
|
13
|
-
|
|
14
|
-
display: inline-block;
|
|
15
|
-
}
|