@gravity-ui/aikit 0.6.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/components/atoms/ActionButton/__stories__/ActionButton.stories.d.ts +8 -0
  2. package/dist/components/atoms/ActionButton/__stories__/ActionButton.stories.js +48 -0
  3. package/dist/components/atoms/Alert/__stories__/Alert.stories.d.ts +10 -0
  4. package/dist/components/atoms/Alert/__stories__/Alert.stories.js +72 -0
  5. package/dist/components/atoms/ChatDate/__stories__/ChatDate.stories.d.ts +16 -0
  6. package/dist/components/atoms/ChatDate/__stories__/ChatDate.stories.js +83 -0
  7. package/dist/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.d.ts +17 -0
  8. package/dist/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.js +72 -0
  9. package/dist/components/atoms/ContextItem/__stories__/ContextItem.stories.d.ts +8 -0
  10. package/dist/components/atoms/ContextItem/__stories__/ContextItem.stories.js +36 -0
  11. package/dist/components/atoms/DiffStat/__stories__/DiffStat.stories.d.ts +8 -0
  12. package/dist/components/atoms/DiffStat/__stories__/DiffStat.stories.js +45 -0
  13. package/dist/components/atoms/Disclaimer/__stories__/Disclaimer.stories.d.ts +12 -0
  14. package/dist/components/atoms/Disclaimer/__stories__/Disclaimer.stories.js +64 -0
  15. package/dist/components/atoms/Loader/__stories__/Loader.stories.d.ts +8 -0
  16. package/dist/components/atoms/Loader/__stories__/Loader.stories.js +47 -0
  17. package/dist/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.d.ts +6 -0
  18. package/dist/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.js +49 -0
  19. package/dist/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.d.ts +6 -0
  20. package/dist/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.js +32 -0
  21. package/dist/components/atoms/Shimmer/__stories__/Shimmer.stories.d.ts +5 -0
  22. package/dist/components/atoms/Shimmer/__stories__/Shimmer.stories.js +28 -0
  23. package/dist/components/atoms/SubmitButton/__stories__/SubmitButton.stories.d.ts +13 -0
  24. package/dist/components/atoms/SubmitButton/__stories__/SubmitButton.stories.js +98 -0
  25. package/dist/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.d.ts +9 -0
  26. package/dist/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.js +34 -0
  27. package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.d.ts +9 -0
  28. package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.js +77 -0
  29. package/dist/components/molecules/BaseMessage/index.d.ts +1 -1
  30. package/dist/components/molecules/BaseMessage/index.js +51 -20
  31. package/dist/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.d.ts +6 -0
  32. package/dist/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.js +44 -0
  33. package/dist/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.d.ts +11 -0
  34. package/dist/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.js +62 -0
  35. package/dist/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.d.ts +11 -0
  36. package/dist/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.js +96 -0
  37. package/dist/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.d.ts +15 -0
  38. package/dist/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.js +123 -0
  39. package/dist/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.d.ts +8 -0
  40. package/dist/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.js +38 -0
  41. package/dist/components/molecules/Suggestions/__stories__/Suggestions.stories.d.ts +22 -0
  42. package/dist/components/molecules/Suggestions/__stories__/Suggestions.stories.js +182 -0
  43. package/dist/components/molecules/Tabs/__stories__/Tabs.stories.d.ts +9 -0
  44. package/dist/components/molecules/Tabs/__stories__/Tabs.stories.js +103 -0
  45. package/dist/components/molecules/ToolFooter/__stories__/ToolFooter.stories.d.ts +7 -0
  46. package/dist/components/molecules/ToolFooter/__stories__/ToolFooter.stories.js +58 -0
  47. package/dist/components/molecules/ToolFooter/index.js +8 -1
  48. package/dist/components/molecules/ToolHeader/__stories__/ToolHeader.stories.d.ts +8 -0
  49. package/dist/components/molecules/ToolHeader/__stories__/ToolHeader.stories.js +59 -0
  50. package/dist/components/molecules/ToolHeader/index.js +10 -1
  51. package/dist/components/molecules/ToolStatus/__stories__/ToolStatus.stories.d.ts +9 -0
  52. package/dist/components/molecules/ToolStatus/__stories__/ToolStatus.stories.js +44 -0
  53. package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts +13 -0
  54. package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js +151 -0
  55. package/dist/components/organisms/Header/Header.js +16 -17
  56. package/dist/components/organisms/Header/__stories__/Header.stories.d.ts +15 -0
  57. package/dist/components/organisms/Header/__stories__/Header.stories.js +159 -0
  58. package/dist/components/organisms/Header/types.d.ts +2 -3
  59. package/dist/components/organisms/Header/useHeader.d.ts +2 -4
  60. package/dist/components/organisms/Header/useHeader.js +2 -24
  61. package/dist/components/organisms/MessageList/MessageList.js +5 -6
  62. package/dist/components/organisms/MessageList/__stories__/MessageList.stories.d.ts +25 -0
  63. package/dist/components/organisms/MessageList/__stories__/MessageList.stories.js +340 -0
  64. package/dist/components/organisms/PromptInput/__stories__/PromptInput.stories.d.ts +19 -0
  65. package/dist/components/organisms/PromptInput/__stories__/PromptInput.stories.js +304 -0
  66. package/dist/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.d.ts +12 -0
  67. package/dist/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.js +105 -0
  68. package/dist/components/organisms/ToolMessage/__stories__/ToolMessage.stories.d.ts +11 -0
  69. package/dist/components/organisms/ToolMessage/__stories__/ToolMessage.stories.js +70 -0
  70. package/dist/components/organisms/UserMessage/__stories__/UserMessage.stories.d.ts +9 -0
  71. package/dist/components/organisms/UserMessage/__stories__/UserMessage.stories.js +118 -0
  72. package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.d.ts +79 -0
  73. package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.js +1006 -0
  74. package/dist/components/templates/ChatContent/__stories__/ChatContent.stories.d.ts +14 -0
  75. package/dist/components/templates/ChatContent/__stories__/ChatContent.stories.js +315 -0
  76. package/dist/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.d.ts +20 -0
  77. package/dist/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.js +250 -0
  78. package/dist/components/templates/History/ChatItem.d.ts +2 -2
  79. package/dist/components/templates/History/ChatItem.js +2 -5
  80. package/dist/components/templates/History/History.scss +13 -9
  81. package/dist/components/templates/History/HistoryList.d.ts +3 -1
  82. package/dist/components/templates/History/HistoryList.js +9 -5
  83. package/dist/components/templates/History/__stories__/History.stories.d.ts +18 -0
  84. package/dist/components/templates/History/__stories__/History.stories.js +289 -0
  85. package/dist/demo/ContentWrapper/ContentWrapper.d.ts +4 -0
  86. package/dist/demo/ContentWrapper/ContentWrapper.js +9 -0
  87. package/dist/demo/ContentWrapper/index.d.ts +1 -0
  88. package/dist/demo/ContentWrapper/index.js +1 -0
  89. package/dist/demo/Showcase/Showcase.d.ts +9 -0
  90. package/dist/demo/Showcase/Showcase.js +7 -0
  91. package/dist/demo/Showcase/index.d.ts +1 -0
  92. package/dist/demo/Showcase/index.js +1 -0
  93. package/dist/demo/ShowcaseItem/ShowcaseItem.d.ts +8 -0
  94. package/dist/demo/ShowcaseItem/ShowcaseItem.js +7 -0
  95. package/dist/demo/ShowcaseItem/index.d.ts +1 -0
  96. package/dist/demo/ShowcaseItem/index.js +1 -0
  97. package/dist/demo/SwapArea/SwapArea.d.ts +2 -0
  98. package/dist/demo/SwapArea/SwapArea.js +7 -0
  99. package/dist/demo/SwapArea/index.d.ts +1 -0
  100. package/dist/demo/SwapArea/index.js +1 -0
  101. package/dist/hooks/useSmartScroll.d.ts +7 -2
  102. package/dist/hooks/useSmartScroll.js +24 -22
  103. package/dist/types/common.d.ts +13 -5
  104. package/dist/types/messages.d.ts +9 -6
  105. package/dist/utils/actionUtils.d.ts +14 -0
  106. package/dist/utils/actionUtils.js +17 -0
  107. package/dist/utils/messageUtils.d.ts +7 -9
  108. package/dist/utils/messageUtils.js +7 -1
  109. package/package.json +12 -7
@@ -0,0 +1,304 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Xmark } from '@gravity-ui/icons';
4
+ import { Icon } from '@gravity-ui/uikit';
5
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
6
+ import { SwapArea } from '../../../../demo/SwapArea';
7
+ import { ActionButton } from '../../../atoms/ActionButton';
8
+ import { PromptInput } from '../PromptInput';
9
+ import MDXDocs from './Docs.mdx';
10
+ export default {
11
+ title: 'organisms/PromptInput',
12
+ component: PromptInput,
13
+ parameters: {
14
+ docs: {
15
+ page: MDXDocs,
16
+ },
17
+ },
18
+ };
19
+ const defaultDecorators = [
20
+ (Story) => (_jsx(ContentWrapper, { width: "450px", children: _jsx(Story, {}) })),
21
+ ];
22
+ const handleSend = async (data) => {
23
+ // eslint-disable-next-line no-console
24
+ console.log('Sending:', data);
25
+ await new Promise((resolve) => setTimeout(resolve, 1000));
26
+ };
27
+ const handleCancel = async () => {
28
+ // eslint-disable-next-line no-console
29
+ console.log('Cancelling');
30
+ };
31
+ export const Playground = {
32
+ args: {
33
+ view: 'simple',
34
+ onSend: handleSend,
35
+ onCancel: handleCancel,
36
+ bodyProps: {
37
+ placeholder: 'Plan, code, build and test anything',
38
+ },
39
+ footerProps: {
40
+ showAttachment: true,
41
+ showMicrophone: true,
42
+ },
43
+ },
44
+ decorators: defaultDecorators,
45
+ };
46
+ export const FullView = {
47
+ args: {
48
+ view: 'full',
49
+ onSend: handleSend,
50
+ bodyProps: {
51
+ placeholder: 'Plan, code, build and test anything',
52
+ },
53
+ headerProps: {
54
+ showContextIndicator: true,
55
+ contextIndicatorProps: {
56
+ type: 'percent',
57
+ usedContext: 24,
58
+ },
59
+ },
60
+ footerProps: {
61
+ showSettings: true,
62
+ showAttachment: true,
63
+ showMicrophone: true,
64
+ // eslint-disable-next-line no-console
65
+ onSettingsClick: () => console.log('Settings clicked'),
66
+ // eslint-disable-next-line no-console
67
+ onAttachmentClick: () => console.log('Attachment clicked'),
68
+ // eslint-disable-next-line no-console
69
+ onMicrophoneClick: () => console.log('Microphone clicked'),
70
+ },
71
+ },
72
+ decorators: defaultDecorators,
73
+ };
74
+ export const WithSuggestions = {
75
+ args: {
76
+ view: 'simple',
77
+ onSend: handleSend,
78
+ bodyProps: {
79
+ placeholder: 'Plan, code, build and test anything',
80
+ },
81
+ suggestionsProps: {
82
+ showSuggestions: true,
83
+ suggestions: [
84
+ { title: 'Write a Python function', view: 'action' },
85
+ { title: 'Explain this code' },
86
+ ],
87
+ // eslint-disable-next-line no-console
88
+ onSuggestionClick: (suggestion) => console.log('Suggestion clicked:', suggestion),
89
+ },
90
+ },
91
+ decorators: defaultDecorators,
92
+ };
93
+ export const WithSuggestionsAndTitle = {
94
+ args: {
95
+ view: 'simple',
96
+ onSend: handleSend,
97
+ bodyProps: {
98
+ placeholder: 'Plan, code, build and test anything',
99
+ },
100
+ suggestionsProps: {
101
+ showSuggestions: true,
102
+ suggestTitle: 'Try these prompts:',
103
+ suggestions: [
104
+ { title: 'Write a Python function', view: 'action' },
105
+ { title: 'Explain this code' },
106
+ { title: 'Debug my code' },
107
+ ],
108
+ // eslint-disable-next-line no-console
109
+ onSuggestionClick: (suggestion) => console.log('Suggestion clicked:', suggestion),
110
+ },
111
+ },
112
+ decorators: defaultDecorators,
113
+ };
114
+ export const WithContextIndicator = {
115
+ args: {
116
+ view: 'full',
117
+ onSend: handleSend,
118
+ bodyProps: {
119
+ placeholder: 'Plan, code, build and test anything',
120
+ },
121
+ headerProps: {
122
+ showContextIndicator: true,
123
+ contextIndicatorProps: {
124
+ type: 'percent',
125
+ usedContext: 24,
126
+ },
127
+ },
128
+ },
129
+ decorators: defaultDecorators,
130
+ };
131
+ export const WithCustomTopContent = {
132
+ args: {
133
+ view: 'full',
134
+ onSend: handleSend,
135
+ bodyProps: {
136
+ placeholder: 'Plan, code, build and test anything',
137
+ },
138
+ headerProps: {
139
+ topContent: _jsx(SwapArea, {}),
140
+ },
141
+ },
142
+ decorators: defaultDecorators,
143
+ };
144
+ export const WithCustomBottomContent = {
145
+ args: {
146
+ view: 'full',
147
+ onSend: handleSend,
148
+ bodyProps: {
149
+ placeholder: 'Plan, code, build and test anything',
150
+ },
151
+ footerProps: {
152
+ bottomContent: _jsx(SwapArea, {}),
153
+ },
154
+ },
155
+ decorators: defaultDecorators,
156
+ };
157
+ export const WithTopPanel = {
158
+ args: {
159
+ view: 'simple',
160
+ onSend: handleSend,
161
+ bodyProps: {
162
+ placeholder: 'Plan, code, build and test anything',
163
+ },
164
+ topPanel: {
165
+ isOpen: true,
166
+ children: _jsx(SwapArea, {}),
167
+ },
168
+ },
169
+ decorators: defaultDecorators,
170
+ };
171
+ export const WithBottomPanel = {
172
+ args: {
173
+ view: 'simple',
174
+ onSend: handleSend,
175
+ bodyProps: {
176
+ placeholder: 'Plan, code, build and test anything',
177
+ },
178
+ bottomPanel: {
179
+ isOpen: true,
180
+ children: _jsx(SwapArea, {}),
181
+ },
182
+ },
183
+ decorators: defaultDecorators,
184
+ };
185
+ export const WithBothPanels = {
186
+ args: {
187
+ view: 'full',
188
+ onSend: handleSend,
189
+ bodyProps: {
190
+ placeholder: 'Plan, code, build and test anything',
191
+ },
192
+ headerProps: {
193
+ showContextIndicator: true,
194
+ contextIndicatorProps: {
195
+ type: 'percent',
196
+ usedContext: 24,
197
+ },
198
+ },
199
+ topPanel: {
200
+ isOpen: true,
201
+ children: _jsx(SwapArea, {}),
202
+ },
203
+ bottomPanel: {
204
+ isOpen: true,
205
+ children: _jsx(SwapArea, {}),
206
+ },
207
+ },
208
+ decorators: defaultDecorators,
209
+ };
210
+ const PanelExample = ({ onClose }) => {
211
+ return (_jsxs(_Fragment, { children: [_jsx(SwapArea, {}), _jsx(ActionButton, { view: "flat", size: "m", onClick: onClose, children: _jsx(Icon, { data: Xmark, size: 16 }) })] }));
212
+ };
213
+ export const WithPanelToggle = {
214
+ render: () => {
215
+ const [isTopPanelOpen, setIsTopPanelOpen] = useState(false);
216
+ const [isBottomPanelOpen, setIsBottomPanelOpen] = useState(false);
217
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '16px' }, children: [_jsxs("div", { style: { display: 'flex', gap: '8px' }, children: [_jsx(ActionButton, { view: "action", size: "m", onClick: () => setIsTopPanelOpen((prev) => !prev), children: "Toggle Top Panel" }), _jsx(ActionButton, { view: "action", size: "m", onClick: () => setIsBottomPanelOpen((prev) => !prev), children: "Toggle Bottom Panel" })] }), _jsx(PromptInput, { view: "full", onSend: handleSend, bodyProps: {
218
+ placeholder: 'Plan, code, build and test anything',
219
+ }, topPanel: {
220
+ isOpen: isTopPanelOpen,
221
+ children: _jsx(PanelExample, { onClose: () => setIsTopPanelOpen(false) }),
222
+ }, bottomPanel: {
223
+ isOpen: isBottomPanelOpen,
224
+ children: _jsx(PanelExample, { onClose: () => setIsBottomPanelOpen(false) }),
225
+ } })] }));
226
+ },
227
+ decorators: defaultDecorators,
228
+ };
229
+ export const Disabled = {
230
+ args: {
231
+ view: 'simple',
232
+ onSend: handleSend,
233
+ disabled: true,
234
+ bodyProps: {
235
+ placeholder: 'Plan, code, build and test anything',
236
+ },
237
+ },
238
+ decorators: defaultDecorators,
239
+ };
240
+ export const Streaming = {
241
+ render: (args) => {
242
+ const [status, setStatus] = useState('ready');
243
+ const handleSendWithStreaming = async (data) => {
244
+ // eslint-disable-next-line no-console
245
+ console.log('Sending:', data);
246
+ setStatus('streaming');
247
+ await new Promise((resolve) => setTimeout(resolve, 3000));
248
+ setStatus('ready');
249
+ };
250
+ const customHandleCancel = async () => {
251
+ // eslint-disable-next-line no-console
252
+ console.log('Cancelling');
253
+ setStatus('ready');
254
+ };
255
+ return (_jsx(PromptInput, Object.assign({}, args, { view: "full", onSend: handleSendWithStreaming, onCancel: customHandleCancel, status: status, bodyProps: {
256
+ placeholder: 'Plan, code, build and test anything',
257
+ }, footerProps: {
258
+ showSettings: true,
259
+ showAttachment: true,
260
+ showMicrophone: true,
261
+ } })));
262
+ },
263
+ decorators: defaultDecorators,
264
+ };
265
+ export const ComplexExample = {
266
+ render: (args) => {
267
+ const [status, setStatus] = useState('ready');
268
+ const handleSendComplex = async (data) => {
269
+ // eslint-disable-next-line no-console
270
+ console.log('Sending:', data);
271
+ setStatus('streaming');
272
+ await new Promise((resolve) => setTimeout(resolve, 2000));
273
+ setStatus('ready');
274
+ };
275
+ const customHandleCancel = async () => {
276
+ // eslint-disable-next-line no-console
277
+ console.log('Cancelling');
278
+ setStatus('ready');
279
+ };
280
+ return (_jsx(PromptInput, Object.assign({}, args, { view: "full", onSend: handleSendComplex, onCancel: customHandleCancel, status: status, bodyProps: {
281
+ placeholder: 'Plan, code, build and test anything',
282
+ }, headerProps: {
283
+ showContextIndicator: true,
284
+ contextIndicatorProps: {
285
+ type: 'percent',
286
+ usedContext: 24,
287
+ },
288
+ }, footerProps: {
289
+ showSettings: true,
290
+ showAttachment: true,
291
+ showMicrophone: true,
292
+ // eslint-disable-next-line no-console
293
+ onSettingsClick: () => console.log('Settings'),
294
+ // eslint-disable-next-line no-console
295
+ onAttachmentClick: () => console.log('Attachment'),
296
+ // eslint-disable-next-line no-console
297
+ onMicrophoneClick: () => console.log('Microphone'),
298
+ }, suggestionsProps: {
299
+ showSuggestions: status !== 'streaming',
300
+ suggestions: [{ title: 'Yes', view: 'action' }, { title: 'No' }],
301
+ } })));
302
+ },
303
+ decorators: defaultDecorators,
304
+ };
@@ -0,0 +1,12 @@
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
2
+ import { type ThinkingMessageProps } from '..';
3
+ declare const _default: Meta;
4
+ export default _default;
5
+ export declare const Playground: StoryFn<ThinkingMessageProps>;
6
+ export declare const ThinkingState: StoryObj<ThinkingMessageProps>;
7
+ export declare const ThoughtState: StoryObj<ThinkingMessageProps>;
8
+ export declare const SingleContent: StoryObj<ThinkingMessageProps>;
9
+ export declare const Collapsed: StoryObj<ThinkingMessageProps>;
10
+ export declare const WithoutLoader: StoryObj<ThinkingMessageProps>;
11
+ export declare const WithCopyAction: StoryObj<ThinkingMessageProps>;
12
+ export declare const WithCustomStyle: StoryObj<ThinkingMessageProps>;
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ThinkingMessage } from '..';
3
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
4
+ import { Showcase } from '../../../../demo/Showcase';
5
+ import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
6
+ import MDXDocs from './Docs.mdx';
7
+ export default {
8
+ title: 'organisms/ThinkingMessage',
9
+ component: ThinkingMessage,
10
+ parameters: {
11
+ docs: {
12
+ page: MDXDocs,
13
+ },
14
+ },
15
+ argTypes: {
16
+ content: {
17
+ control: 'object',
18
+ description: 'Thinking message content',
19
+ },
20
+ status: {
21
+ control: 'select',
22
+ options: ['thinking', 'thought'],
23
+ description: 'Thinking status',
24
+ },
25
+ defaultExpanded: {
26
+ control: 'boolean',
27
+ description: 'Initial expanded state',
28
+ },
29
+ showStatusIndicator: {
30
+ control: 'boolean',
31
+ description: 'Show loader when status is "thinking"',
32
+ },
33
+ className: {
34
+ control: 'text',
35
+ description: 'Class name',
36
+ },
37
+ qa: {
38
+ control: 'text',
39
+ description: 'QA attribute',
40
+ },
41
+ style: {
42
+ control: 'object',
43
+ description: 'Style',
44
+ },
45
+ onCopyClick: {
46
+ action: 'copy clicked',
47
+ description: 'Copy button click handler',
48
+ },
49
+ },
50
+ };
51
+ const defaultDecorators = [
52
+ (Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
53
+ ];
54
+ const thinkingData = {
55
+ content: [
56
+ 'Lore ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
57
+ 'Lore ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
58
+ ],
59
+ status: 'thinking',
60
+ };
61
+ const thoughtData = {
62
+ content: [
63
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
64
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
65
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
66
+ ],
67
+ status: 'thought',
68
+ };
69
+ export const Playground = (args) => (_jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, args)) }));
70
+ Playground.args = Object.assign(Object.assign({}, thinkingData), { defaultExpanded: true, showStatusIndicator: true });
71
+ export const ThinkingState = {
72
+ render: () => (_jsx(ShowcaseItem, { title: "Thinking State (with loader)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thinkingData, { defaultExpanded: true, showStatusIndicator: true })) }) })),
73
+ decorators: defaultDecorators,
74
+ };
75
+ export const ThoughtState = {
76
+ render: () => (_jsx(ShowcaseItem, { title: "Thought State (completed)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: true, showStatusIndicator: true })) }) })),
77
+ decorators: defaultDecorators,
78
+ };
79
+ export const SingleContent = {
80
+ render: () => (_jsx(ShowcaseItem, { title: "Single Content String", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, { content: "Processing your request and analyzing possible solutions.", status: "thinking", defaultExpanded: true }) }) })),
81
+ decorators: defaultDecorators,
82
+ };
83
+ export const Collapsed = {
84
+ render: () => (_jsx(ShowcaseItem, { title: "Collapsed Initially", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: false })) }) })),
85
+ decorators: defaultDecorators,
86
+ };
87
+ export const WithoutLoader = {
88
+ render: () => (_jsx(ShowcaseItem, { title: "Without Loader (showStatusIndicator=false)", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thinkingData, { defaultExpanded: true, showStatusIndicator: false })) }) })),
89
+ decorators: defaultDecorators,
90
+ };
91
+ export const WithCopyAction = {
92
+ render: () => (_jsx(ShowcaseItem, { title: "With Copy Action", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, thoughtData, { defaultExpanded: true, onCopyClick: () => alert('Content copied to clipboard!') })) }) })),
93
+ decorators: defaultDecorators,
94
+ };
95
+ export const WithCustomStyle = {
96
+ render: (args) => (_jsx(ShowcaseItem, { title: "With Custom Style", children: _jsx(ContentWrapper, { width: "600px", children: _jsx(ThinkingMessage, Object.assign({}, args)) }) })),
97
+ decorators: defaultDecorators,
98
+ };
99
+ WithCustomStyle.args = Object.assign(Object.assign({}, thoughtData), { defaultExpanded: true, style: {
100
+ '--g-color-text-complementary': '#00aa00',
101
+ '--g-color-line-generic': '#ff6b35',
102
+ '--g-text-body-1-font-size': '16px',
103
+ '--g-text-body-font-weight': '500',
104
+ '--g-text-body-1-line-height': '18px',
105
+ }, onCopyClick: undefined });
@@ -0,0 +1,11 @@
1
+ import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
2
+ import type { ToolMessageProps } from '../../../../types/tool';
3
+ declare const _default: Meta;
4
+ export default _default;
5
+ export declare const Playground: StoryFn<ToolMessageProps>;
6
+ export declare const WaitingSubmission: StoryObj<ToolMessageProps>;
7
+ export declare const WaitingConfirmation: StoryObj<ToolMessageProps>;
8
+ export declare const CustomHeaderActions: StoryObj<ToolMessageProps>;
9
+ export declare const CustomFooterActions: StoryObj<ToolMessageProps>;
10
+ export declare const Loading: StoryObj<ToolMessageProps>;
11
+ export declare const Error: StoryObj<ToolMessageProps>;
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Archive, Copy, Pencil } from '@gravity-ui/icons';
3
+ import { Icon, Text } from '@gravity-ui/uikit';
4
+ import { ToolMessage } from '..';
5
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
6
+ import { Showcase } from '../../../../demo/Showcase';
7
+ import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
8
+ import { SwapArea } from '../../../../demo/SwapArea';
9
+ import MDXDocs from './Docs.mdx';
10
+ export default {
11
+ title: 'organisms/ToolMessage',
12
+ component: ToolMessage,
13
+ parameters: {
14
+ docs: {
15
+ page: MDXDocs,
16
+ },
17
+ },
18
+ argTypes: {
19
+ toolName: {
20
+ control: 'text',
21
+ description: 'Name of the tool',
22
+ },
23
+ },
24
+ };
25
+ const defaultDecorators = [
26
+ (Story) => (_jsx(Showcase, { children: _jsx(Story, {}) })),
27
+ ];
28
+ const defaultArgs = {
29
+ toolName: 'Writing',
30
+ toolIcon: _jsx(Icon, { data: Pencil, size: 16 }),
31
+ headerContent: _jsx(Text, { color: "secondary", children: "expectScreenshotFixture.ts" }),
32
+ };
33
+ export const Playground = (args) => (_jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, args)) }));
34
+ Playground.args = Object.assign(Object.assign({}, defaultArgs), { status: 'success', bodyContent: _jsx(SwapArea, {}) });
35
+ export const WaitingSubmission = {
36
+ render: () => (_jsx(ShowcaseItem, { title: "Waiting Submission", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, { toolName: "Creating repository", status: "waitingSubmission", toolIcon: _jsx(Icon, { data: Archive, size: 16 }), bodyContent: _jsx(Text, { children: "Almost done creating your shiny new repository. Take a moment to review the name, visibility, and template. When you're ready, click 'Create repository' to finish!" }) }) }) })),
37
+ decorators: defaultDecorators,
38
+ };
39
+ export const WaitingConfirmation = {
40
+ render: () => (_jsx(ShowcaseItem, { title: "Waiting Confirmation", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "waitingConfirmation", bodyContent: _jsx(SwapArea, {}) })) }) })),
41
+ decorators: defaultDecorators,
42
+ };
43
+ export const CustomHeaderActions = {
44
+ render: () => (_jsx(ShowcaseItem, { title: "With Custom Header Actions", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { headerActions: [
45
+ {
46
+ label: 'Copy',
47
+ onClick: () => alert('Copied'),
48
+ icon: _jsx(Icon, { data: Copy, size: 16 }),
49
+ },
50
+ ] })) }) })),
51
+ decorators: defaultDecorators,
52
+ };
53
+ export const CustomFooterActions = {
54
+ render: () => (_jsx(ShowcaseItem, { title: "With Custom Footer Actions", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "waitingConfirmation", footerActions: [
55
+ {
56
+ label: 'Custom action',
57
+ onClick: () => alert('Custom action'),
58
+ view: 'action',
59
+ },
60
+ ], bodyContent: _jsx(SwapArea, {}), footerContent: "Custom footer content" })) }) })),
61
+ decorators: defaultDecorators,
62
+ };
63
+ export const Loading = {
64
+ render: () => (_jsx(ShowcaseItem, { title: "Loading", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "loading", initialExpanded: true })) }) })),
65
+ decorators: defaultDecorators,
66
+ };
67
+ export const Error = {
68
+ render: () => (_jsx(ShowcaseItem, { title: "Error", children: _jsx(ContentWrapper, { width: "430px", children: _jsx(ToolMessage, Object.assign({}, defaultArgs, { status: "error", bodyContent: _jsx(SwapArea, {}) })) }) })),
69
+ decorators: defaultDecorators,
70
+ };
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryFn } from '@storybook/react-webpack5';
2
+ import { type UserMessageProps } from '..';
3
+ declare const _default: Meta;
4
+ export default _default;
5
+ export declare const Playground: StoryFn<UserMessageProps>;
6
+ export declare const MarkdownFormat: StoryFn<UserMessageProps>;
7
+ export declare const ShowAvatar: StoryFn<UserMessageProps>;
8
+ export declare const ShowTimestamp: StoryFn<UserMessageProps>;
9
+ export declare const PlainTextWithLineBreaks: StoryFn<UserMessageProps>;
@@ -0,0 +1,118 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { UserMessage } from '..';
3
+ import { ContentWrapper } from '../../../../demo/ContentWrapper';
4
+ import MDXDocs from './Docs.mdx';
5
+ export default {
6
+ title: 'organisms/UserMessage',
7
+ component: UserMessage,
8
+ parameters: {
9
+ docs: {
10
+ page: MDXDocs,
11
+ },
12
+ },
13
+ argTypes: {
14
+ data: {
15
+ control: 'text',
16
+ description: 'Message text',
17
+ },
18
+ actions: {
19
+ control: 'object',
20
+ description: 'Actions',
21
+ },
22
+ showActionsOnHover: {
23
+ control: 'boolean',
24
+ description: 'Show actions on hover',
25
+ },
26
+ showTimestamp: {
27
+ control: 'boolean',
28
+ description: 'Show timestamp',
29
+ },
30
+ timestamp: {
31
+ control: 'text',
32
+ description: 'Timestamp',
33
+ },
34
+ withAvatar: {
35
+ control: 'boolean',
36
+ description: 'Show avatar',
37
+ },
38
+ avatarUrl: {
39
+ control: 'text',
40
+ description: 'Avatar URL',
41
+ },
42
+ className: {
43
+ control: 'text',
44
+ description: 'Additional CSS class',
45
+ },
46
+ qa: {
47
+ control: 'text',
48
+ description: 'QA/test identifier',
49
+ },
50
+ },
51
+ };
52
+ const buttons = [
53
+ { actionType: 'copy', onClick: () => ({}) },
54
+ { actionType: 'edit', onClick: () => ({}) },
55
+ ];
56
+ export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(UserMessage, Object.assign({}, args)) }));
57
+ Playground.args = {
58
+ content: 'Analyze the project and suggest a better solution to implement a feature-name',
59
+ actions: buttons,
60
+ };
61
+ export const MarkdownFormat = (args) => (_jsx(ContentWrapper, { width: "480px", children: _jsx(UserMessage, Object.assign({}, args, { format: "markdown" })) }));
62
+ MarkdownFormat.args = {
63
+ content: `
64
+ Explain this code snippet:
65
+
66
+ \`\`\`
67
+ CREATE TABLE log_counter (
68
+ id INT PRIMARY KEY, -- topicpartition table name id
69
+ next_offset BIGINT NOT NULL -- next offset to assign
70
+ );
71
+
72
+ for i in NUM_PARTITIONS:
73
+ CREATE TABLE topicpartition%d (
74
+ id BIGSERIAL PRIMARY KEY,
75
+ -- strictly increasing offset (indexed by UNIQUE)
76
+ c_offset BIGINT UNIQUE NOT NULL,
77
+ payload BYTEA NOT NULL,
78
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
79
+ );
80
+ INSERT INTO log_counter(id, next_offset) VALUES (%d, 1);
81
+
82
+ CREATE TABLE consumer_offsets (
83
+ group_id TEXT NOT NULL, -- consumer group identifier
84
+ -- topic-partition id (matches log_counter.id / topicpartitionN)
85
+ topic_id INT NOT NULL,
86
+ -- next offset the consumer group should claim
87
+ next_offset BIGINT NOT NULL DEFAULT 1,
88
+ PRIMARY KEY (group_id, topic_id)
89
+ );
90
+ \`\`\`
91
+ `,
92
+ actions: buttons,
93
+ };
94
+ export const ShowAvatar = (args) => (_jsx(ContentWrapper, { children: _jsx(UserMessage, Object.assign({}, args, { showAvatar: true })) }));
95
+ ShowAvatar.args = {
96
+ content: 'Analyze the project and suggest a better solution to implement a feature-name',
97
+ actions: buttons,
98
+ };
99
+ export const ShowTimestamp = (args) => (_jsx(ContentWrapper, { children: _jsx(UserMessage, Object.assign({}, args, { showTimestamp: true, timestamp: "1705312234567" })) }));
100
+ ShowTimestamp.args = {
101
+ content: 'Analyze the project and suggest a better solution to implement a feature-name',
102
+ actions: buttons,
103
+ };
104
+ export const PlainTextWithLineBreaks = (args) => (_jsx(ContentWrapper, { width: "480px", children: _jsx(UserMessage, Object.assign({}, args, { format: "plain" })) }));
105
+ PlainTextWithLineBreaks.args = {
106
+ content: `Analyze this code:
107
+
108
+ function calculateTotal(items) {
109
+ let total = 0;
110
+ for (let i = 0; i < items.length; i++) {
111
+ total += items[i].price;
112
+ }
113
+ return total;
114
+ }
115
+
116
+ Can it be improved?`,
117
+ actions: buttons,
118
+ };