@gravity-ui/aikit 0.6.0 → 1.0.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/dist/components/atoms/ActionButton/__stories__/ActionButton.stories.d.ts +8 -0
- package/dist/components/atoms/ActionButton/__stories__/ActionButton.stories.js +48 -0
- package/dist/components/atoms/Alert/__stories__/Alert.stories.d.ts +10 -0
- package/dist/components/atoms/Alert/__stories__/Alert.stories.js +72 -0
- package/dist/components/atoms/ChatDate/__stories__/ChatDate.stories.d.ts +16 -0
- package/dist/components/atoms/ChatDate/__stories__/ChatDate.stories.js +83 -0
- package/dist/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.d.ts +17 -0
- package/dist/components/atoms/ContextIndicator/__stories__/ContextIndicator.stories.js +72 -0
- package/dist/components/atoms/ContextItem/__stories__/ContextItem.stories.d.ts +8 -0
- package/dist/components/atoms/ContextItem/__stories__/ContextItem.stories.js +36 -0
- package/dist/components/atoms/DiffStat/__stories__/DiffStat.stories.d.ts +8 -0
- package/dist/components/atoms/DiffStat/__stories__/DiffStat.stories.js +45 -0
- package/dist/components/atoms/Disclaimer/__stories__/Disclaimer.stories.d.ts +12 -0
- package/dist/components/atoms/Disclaimer/__stories__/Disclaimer.stories.js +64 -0
- package/dist/components/atoms/Loader/__stories__/Loader.stories.d.ts +8 -0
- package/dist/components/atoms/Loader/__stories__/Loader.stories.js +47 -0
- package/dist/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.d.ts +6 -0
- package/dist/components/atoms/MarkdownRenderer/__stories__/MarkdownRenderer.stories.js +49 -0
- package/dist/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.d.ts +6 -0
- package/dist/components/atoms/MessageBalloon/__stories__/MessageBalloon.stories.js +32 -0
- package/dist/components/atoms/Shimmer/__stories__/Shimmer.stories.d.ts +5 -0
- package/dist/components/atoms/Shimmer/__stories__/Shimmer.stories.js +28 -0
- package/dist/components/atoms/SubmitButton/__stories__/SubmitButton.stories.d.ts +13 -0
- package/dist/components/atoms/SubmitButton/__stories__/SubmitButton.stories.js +98 -0
- package/dist/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.d.ts +9 -0
- package/dist/components/atoms/ToolIndicator/__stories__/ToolIndicator.stories.js +34 -0
- package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.d.ts +9 -0
- package/dist/components/molecules/BaseMessage/__stories__/BaseMessage.stories.js +77 -0
- package/dist/components/molecules/BaseMessage/index.d.ts +1 -1
- package/dist/components/molecules/BaseMessage/index.js +51 -20
- package/dist/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.d.ts +6 -0
- package/dist/components/molecules/ButtonGroup/__stories__/ButtonGroup.stories.js +44 -0
- package/dist/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.d.ts +11 -0
- package/dist/components/molecules/PromptInputBody/__stories__/PromptInputBody.stories.js +62 -0
- package/dist/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.d.ts +11 -0
- package/dist/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.js +96 -0
- package/dist/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.d.ts +15 -0
- package/dist/components/molecules/PromptInputHeader/__stories__/PromptInputHeader.stories.js +123 -0
- package/dist/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.d.ts +8 -0
- package/dist/components/molecules/PromptInputPanel/__stories__/PromptInputPanel.stories.js +38 -0
- package/dist/components/molecules/Suggestions/__stories__/Suggestions.stories.d.ts +22 -0
- package/dist/components/molecules/Suggestions/__stories__/Suggestions.stories.js +182 -0
- package/dist/components/molecules/Tabs/__stories__/Tabs.stories.d.ts +9 -0
- package/dist/components/molecules/Tabs/__stories__/Tabs.stories.js +103 -0
- package/dist/components/molecules/ToolFooter/__stories__/ToolFooter.stories.d.ts +7 -0
- package/dist/components/molecules/ToolFooter/__stories__/ToolFooter.stories.js +58 -0
- package/dist/components/molecules/ToolFooter/index.js +8 -1
- package/dist/components/molecules/ToolHeader/__stories__/ToolHeader.stories.d.ts +8 -0
- package/dist/components/molecules/ToolHeader/__stories__/ToolHeader.stories.js +59 -0
- package/dist/components/molecules/ToolHeader/index.js +10 -1
- package/dist/components/molecules/ToolStatus/__stories__/ToolStatus.stories.d.ts +9 -0
- package/dist/components/molecules/ToolStatus/__stories__/ToolStatus.stories.js +44 -0
- package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.d.ts +13 -0
- package/dist/components/organisms/AssistantMessage/__stories__/AssistantMessage.stories.js +151 -0
- package/dist/components/organisms/Header/Header.js +16 -17
- package/dist/components/organisms/Header/__stories__/Header.stories.d.ts +15 -0
- package/dist/components/organisms/Header/__stories__/Header.stories.js +159 -0
- package/dist/components/organisms/Header/types.d.ts +2 -3
- package/dist/components/organisms/Header/useHeader.d.ts +2 -4
- package/dist/components/organisms/Header/useHeader.js +2 -24
- package/dist/components/organisms/MessageList/__stories__/MessageList.stories.d.ts +25 -0
- package/dist/components/organisms/MessageList/__stories__/MessageList.stories.js +340 -0
- package/dist/components/organisms/PromptInput/__stories__/PromptInput.stories.d.ts +19 -0
- package/dist/components/organisms/PromptInput/__stories__/PromptInput.stories.js +304 -0
- package/dist/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.d.ts +12 -0
- package/dist/components/organisms/ThinkingMessage/__stories__/ThinkingMessage.stories.js +105 -0
- package/dist/components/organisms/ToolMessage/__stories__/ToolMessage.stories.d.ts +11 -0
- package/dist/components/organisms/ToolMessage/__stories__/ToolMessage.stories.js +70 -0
- package/dist/components/organisms/UserMessage/__stories__/UserMessage.stories.d.ts +9 -0
- package/dist/components/organisms/UserMessage/__stories__/UserMessage.stories.js +118 -0
- package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.d.ts +79 -0
- package/dist/components/pages/ChatContainer/__stories__/ChatContainer.stories.js +1006 -0
- package/dist/components/templates/ChatContent/__stories__/ChatContent.stories.d.ts +14 -0
- package/dist/components/templates/ChatContent/__stories__/ChatContent.stories.js +315 -0
- package/dist/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.d.ts +20 -0
- package/dist/components/templates/EmptyContainer/__stories__/EmptyContainer.stories.js +250 -0
- package/dist/components/templates/History/ChatItem.d.ts +2 -2
- package/dist/components/templates/History/ChatItem.js +2 -5
- package/dist/components/templates/History/History.scss +13 -9
- package/dist/components/templates/History/HistoryList.d.ts +3 -1
- package/dist/components/templates/History/HistoryList.js +9 -5
- package/dist/components/templates/History/__stories__/History.stories.d.ts +18 -0
- package/dist/components/templates/History/__stories__/History.stories.js +289 -0
- package/dist/demo/ContentWrapper/ContentWrapper.d.ts +4 -0
- package/dist/demo/ContentWrapper/ContentWrapper.js +9 -0
- package/dist/demo/ContentWrapper/index.d.ts +1 -0
- package/dist/demo/ContentWrapper/index.js +1 -0
- package/dist/demo/Showcase/Showcase.d.ts +9 -0
- package/dist/demo/Showcase/Showcase.js +7 -0
- package/dist/demo/Showcase/index.d.ts +1 -0
- package/dist/demo/Showcase/index.js +1 -0
- package/dist/demo/ShowcaseItem/ShowcaseItem.d.ts +8 -0
- package/dist/demo/ShowcaseItem/ShowcaseItem.js +7 -0
- package/dist/demo/ShowcaseItem/index.d.ts +1 -0
- package/dist/demo/ShowcaseItem/index.js +1 -0
- package/dist/demo/SwapArea/SwapArea.d.ts +2 -0
- package/dist/demo/SwapArea/SwapArea.js +7 -0
- package/dist/demo/SwapArea/index.d.ts +1 -0
- package/dist/demo/SwapArea/index.js +1 -0
- package/dist/types/common.d.ts +13 -5
- package/dist/types/messages.d.ts +9 -6
- package/dist/utils/actionUtils.d.ts +14 -0
- package/dist/utils/actionUtils.js +17 -0
- package/dist/utils/messageUtils.d.ts +7 -9
- package/dist/utils/messageUtils.js +7 -1
- package/package.json +12 -7
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react-webpack5';
|
|
2
|
+
import { type MessageBalloonProps } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<MessageBalloonProps>;
|
|
6
|
+
export declare const User: StoryFn<MessageBalloonProps>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MessageBalloon } from '..';
|
|
3
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
4
|
+
import MDXDocs from './Docs.mdx';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'atoms/MessageBalloon',
|
|
7
|
+
component: MessageBalloon,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
page: MDXDocs,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
children: {
|
|
15
|
+
control: 'text',
|
|
16
|
+
description: 'Content of message',
|
|
17
|
+
},
|
|
18
|
+
className: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Additional CSS class',
|
|
21
|
+
},
|
|
22
|
+
qa: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'QA/test identifier',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(MessageBalloon, Object.assign({}, args)) }));
|
|
29
|
+
Playground.args = {
|
|
30
|
+
children: 'User question',
|
|
31
|
+
};
|
|
32
|
+
export const User = (args) => (_jsx(ContentWrapper, { children: _jsx(MessageBalloon, Object.assign({}, args, { children: "User question" })) }));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Shimmer } from '..';
|
|
3
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
4
|
+
import MDXDocs from './Docs.mdx';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'atoms/Shimmer',
|
|
7
|
+
component: Shimmer,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
page: MDXDocs,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
children: {
|
|
15
|
+
control: 'text',
|
|
16
|
+
description: 'Content to apply shimmer to',
|
|
17
|
+
},
|
|
18
|
+
className: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Additional CSS class',
|
|
21
|
+
},
|
|
22
|
+
qa: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'QA/test identifier',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(Shimmer, Object.assign({}, args, { children: _jsx("span", { children: "Awaiting confirmation" }) })) }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { SubmitButtonProps } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<SubmitButtonProps>;
|
|
6
|
+
export declare const Enabled: StoryFn<SubmitButtonProps>;
|
|
7
|
+
export declare const Disabled: StoryFn<SubmitButtonProps>;
|
|
8
|
+
export declare const Loading: StoryFn<SubmitButtonProps>;
|
|
9
|
+
export declare const Cancelable: StoryFn<SubmitButtonProps>;
|
|
10
|
+
export declare const CancelableWithText: StoryFn<SubmitButtonProps>;
|
|
11
|
+
export declare const Size: StoryObj<SubmitButtonProps>;
|
|
12
|
+
export declare const States: StoryObj<SubmitButtonProps>;
|
|
13
|
+
export declare const Interactive: StoryFn<SubmitButtonProps>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { SubmitButton } from '..';
|
|
4
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
5
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
6
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
7
|
+
import MDXDocs from './Docs.mdx';
|
|
8
|
+
export default {
|
|
9
|
+
title: 'atoms/SubmitButton',
|
|
10
|
+
component: SubmitButton,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
page: MDXDocs,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
size: {
|
|
18
|
+
control: 'radio',
|
|
19
|
+
options: ['s', 'm', 'l'],
|
|
20
|
+
description: 'Button size',
|
|
21
|
+
},
|
|
22
|
+
state: {
|
|
23
|
+
control: 'radio',
|
|
24
|
+
options: ['enabled', 'disabled', 'loading', 'cancelable'],
|
|
25
|
+
description: 'Button state',
|
|
26
|
+
},
|
|
27
|
+
className: {
|
|
28
|
+
control: 'text',
|
|
29
|
+
description: 'Additional CSS class',
|
|
30
|
+
},
|
|
31
|
+
qa: {
|
|
32
|
+
control: 'text',
|
|
33
|
+
description: 'QA/test identifier',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const defaultDecorators = [
|
|
38
|
+
(Story) => (_jsx(ContentWrapper, { children: _jsx(Showcase, { children: _jsx(Story, {}) }) })),
|
|
39
|
+
];
|
|
40
|
+
// Mock function for demonstration
|
|
41
|
+
const mockOnClick = async () => {
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('Button clicked');
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.log('Action completed');
|
|
47
|
+
};
|
|
48
|
+
export const Playground = (args) => {
|
|
49
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick })) }));
|
|
50
|
+
};
|
|
51
|
+
Playground.args = {
|
|
52
|
+
size: 'm',
|
|
53
|
+
state: 'enabled',
|
|
54
|
+
};
|
|
55
|
+
export const Enabled = (args) => {
|
|
56
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "enabled" })) }));
|
|
57
|
+
};
|
|
58
|
+
export const Disabled = (args) => {
|
|
59
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "disabled" })) }));
|
|
60
|
+
};
|
|
61
|
+
export const Loading = (args) => {
|
|
62
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "loading" })) }));
|
|
63
|
+
};
|
|
64
|
+
export const Cancelable = (args) => {
|
|
65
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "cancelable" })) }));
|
|
66
|
+
};
|
|
67
|
+
export const CancelableWithText = (args) => {
|
|
68
|
+
return (_jsx(ContentWrapper, { children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "cancelable", cancelableText: "Stop" })) }));
|
|
69
|
+
};
|
|
70
|
+
export const Size = {
|
|
71
|
+
render: (args) => {
|
|
72
|
+
return (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "Size s", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, size: "s" })) }), _jsx(ShowcaseItem, { title: "Size m", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, size: "m" })) }), _jsx(ShowcaseItem, { title: "Size l", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, size: "l" })) })] }));
|
|
73
|
+
},
|
|
74
|
+
decorators: defaultDecorators,
|
|
75
|
+
};
|
|
76
|
+
export const States = {
|
|
77
|
+
render: (args) => {
|
|
78
|
+
return (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "Enabled", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "enabled" })) }), _jsx(ShowcaseItem, { title: "Disabled", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "disabled" })) }), _jsx(ShowcaseItem, { title: "Loading", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "loading" })) }), _jsx(ShowcaseItem, { title: "Cancelable", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: mockOnClick, state: "cancelable" })) })] }));
|
|
79
|
+
},
|
|
80
|
+
decorators: defaultDecorators,
|
|
81
|
+
};
|
|
82
|
+
// Interactive story to demonstrate loading and cancelable states
|
|
83
|
+
export const Interactive = (args) => {
|
|
84
|
+
const [state, setState] = useState('enabled');
|
|
85
|
+
const handleClick = async () => {
|
|
86
|
+
if (state === 'enabled') {
|
|
87
|
+
setState('loading');
|
|
88
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
89
|
+
setState('cancelable');
|
|
90
|
+
}
|
|
91
|
+
else if (state === 'cancelable') {
|
|
92
|
+
// eslint-disable-next-line no-console
|
|
93
|
+
console.log('Cancelled');
|
|
94
|
+
setState('enabled');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return (_jsx(ContentWrapper, { children: _jsx(Showcase, { children: _jsx(ShowcaseItem, { title: "Click the button to see loading and cancelable states", children: _jsx(SubmitButton, Object.assign({}, args, { onClick: handleClick, state: state })) }) }) }));
|
|
98
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react-webpack5';
|
|
2
|
+
import { ToolIndicatorProps } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ToolIndicatorProps>;
|
|
6
|
+
export declare const Success: StoryFn<ToolIndicatorProps>;
|
|
7
|
+
export declare const Error: StoryFn<ToolIndicatorProps>;
|
|
8
|
+
export declare const Info: StoryFn<ToolIndicatorProps>;
|
|
9
|
+
export declare const Loading: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ToolIndicator } from '..';
|
|
3
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
4
|
+
import MDXDocs from './Docs.mdx';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'atoms/ToolIndicator',
|
|
7
|
+
component: ToolIndicator,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
page: MDXDocs,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
status: {
|
|
15
|
+
control: 'radio',
|
|
16
|
+
options: ['success', 'error', 'info', 'loading'],
|
|
17
|
+
description: 'Current status of the tool execution',
|
|
18
|
+
},
|
|
19
|
+
className: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
description: 'Additional CSS class',
|
|
22
|
+
},
|
|
23
|
+
qa: {
|
|
24
|
+
control: 'text',
|
|
25
|
+
description: 'QA/test identifier',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(ToolIndicator, Object.assign({}, args)) }));
|
|
30
|
+
Playground.args = { status: 'success' };
|
|
31
|
+
export const Success = (args) => (_jsx(ContentWrapper, { children: _jsx(ToolIndicator, Object.assign({}, args, { status: "success" })) }));
|
|
32
|
+
export const Error = (args) => (_jsx(ContentWrapper, { children: _jsx(ToolIndicator, Object.assign({}, args, { status: "error" })) }));
|
|
33
|
+
export const Info = (args) => (_jsx(ContentWrapper, { children: _jsx(ToolIndicator, Object.assign({}, args, { status: "info" })) }));
|
|
34
|
+
export const Loading = () => (_jsx(ContentWrapper, { children: _jsx(ToolIndicator, { status: "loading" }) }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import type { BaseMessageProps } from '../../../../types/messages';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<BaseMessageProps>;
|
|
6
|
+
export declare const Variant: StoryObj<BaseMessageProps>;
|
|
7
|
+
export declare const ShowActionsOnHover: StoryFn<BaseMessageProps>;
|
|
8
|
+
export declare const ShowTimestamp: StoryObj<BaseMessageProps>;
|
|
9
|
+
export declare const WithCustomAction: StoryFn<BaseMessageProps>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@gravity-ui/uikit';
|
|
3
|
+
import { BaseMessage } from '..';
|
|
4
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
5
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
6
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
7
|
+
import MDXDocs from './Docs.mdx';
|
|
8
|
+
export default {
|
|
9
|
+
title: 'molecules/BaseMessage',
|
|
10
|
+
component: BaseMessage,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
page: MDXDocs,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
variant: {
|
|
18
|
+
control: 'radio',
|
|
19
|
+
options: ['user', 'assistant', 'system'],
|
|
20
|
+
description: 'Type of message',
|
|
21
|
+
},
|
|
22
|
+
showActionsOnHover: {
|
|
23
|
+
control: 'boolean',
|
|
24
|
+
description: 'Show actions on hover',
|
|
25
|
+
},
|
|
26
|
+
className: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'Additional CSS class',
|
|
29
|
+
},
|
|
30
|
+
qa: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'QA/test identifier',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
const defaultDecorators = [
|
|
37
|
+
(Story) => (_jsx(ContentWrapper, { children: _jsx(Showcase, { children: _jsx(Story, {}) }) })),
|
|
38
|
+
];
|
|
39
|
+
const buttons = [
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
{ actionType: 'copy', onClick: () => console.log('copy') },
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
{ actionType: 'edit', onClick: () => console.log('edit') },
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
{ actionType: 'delete', onClick: () => console.log('delete') },
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
{ actionType: 'custom', onClick: () => console.log('custom') },
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
{ actionType: 'like', onClick: () => console.log('like') },
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
{ actionType: 'unlike', onClick: () => console.log('unlike') },
|
|
52
|
+
];
|
|
53
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(BaseMessage, Object.assign({}, args)) }));
|
|
54
|
+
Playground.args = {
|
|
55
|
+
children: 'My message',
|
|
56
|
+
actions: buttons,
|
|
57
|
+
role: 'assistant',
|
|
58
|
+
};
|
|
59
|
+
export const Variant = {
|
|
60
|
+
render: (args) => (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "User", width: "300px", children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "user", children: 'My message' })) }), _jsx(ShowcaseItem, { title: "Assistant", width: "300px", children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "assistant", children: 'My message' })) }), _jsx(ShowcaseItem, { title: "System", width: "300px", children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "system", children: 'My message' })) })] })),
|
|
61
|
+
decorators: defaultDecorators,
|
|
62
|
+
};
|
|
63
|
+
export const ShowActionsOnHover = (args) => (_jsx(ContentWrapper, { children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "assistant", showActionsOnHover: true, children: 'My message' })) }));
|
|
64
|
+
export const ShowTimestamp = {
|
|
65
|
+
render: (args) => (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "User", width: "350px", children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "user", showTimestamp: true, timestamp: "1705312234567", children: 'My message' })) }), _jsx(ShowcaseItem, { title: "Assistant", width: "350px", children: _jsx(BaseMessage, Object.assign({}, args, { actions: buttons, role: "assistant", showTimestamp: true, timestamp: "1705312234567", children: 'My message' })) })] })),
|
|
66
|
+
decorators: defaultDecorators,
|
|
67
|
+
};
|
|
68
|
+
export const WithCustomAction = (args) => (_jsx(ContentWrapper, { children: _jsx(BaseMessage, Object.assign({}, args, { actions: [
|
|
69
|
+
// eslint-disable-next-line no-console
|
|
70
|
+
{ actionType: 'copy', onClick: () => console.log('copy') },
|
|
71
|
+
// eslint-disable-next-line no-console
|
|
72
|
+
{ actionType: 'edit', onClick: () => console.log('edit') },
|
|
73
|
+
// Custom ReactNode action
|
|
74
|
+
_jsx(Button, { view: "outlined-info", size: "s",
|
|
75
|
+
// eslint-disable-next-line no-console
|
|
76
|
+
onClick: () => console.log('custom'), children: "Custom" }, "custom"),
|
|
77
|
+
], role: "assistant", children: 'Message with custom action button' })) }));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { ArrowRotateLeft, Copy as CopyIcon, Pencil, ThumbsDown, ThumbsUp, TrashBin, } from '@gravity-ui/icons';
|
|
3
4
|
import { Icon } from '@gravity-ui/uikit';
|
|
5
|
+
import { isActionConfig } from '../../../utils/actionUtils';
|
|
4
6
|
import { block } from '../../../utils/cn';
|
|
5
7
|
import { ActionButton } from '../../atoms';
|
|
6
8
|
import { ChatDate } from '../../atoms/ChatDate';
|
|
@@ -8,27 +10,30 @@ import { ButtonGroup } from '../ButtonGroup';
|
|
|
8
10
|
import { i18n } from './i18n';
|
|
9
11
|
import './BaseMessage.scss';
|
|
10
12
|
const b = block('base-message');
|
|
11
|
-
export var
|
|
12
|
-
(function (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})(
|
|
13
|
+
export var BaseMessageActionType;
|
|
14
|
+
(function (BaseMessageActionType) {
|
|
15
|
+
BaseMessageActionType["Copy"] = "copy";
|
|
16
|
+
BaseMessageActionType["Edit"] = "edit";
|
|
17
|
+
BaseMessageActionType["Retry"] = "retry";
|
|
18
|
+
BaseMessageActionType["Like"] = "like";
|
|
19
|
+
BaseMessageActionType["Unlike"] = "unlike";
|
|
20
|
+
BaseMessageActionType["Delete"] = "delete";
|
|
21
|
+
})(BaseMessageActionType || (BaseMessageActionType = {}));
|
|
20
22
|
const BaseMessageActionIcons = {
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
23
|
+
[BaseMessageActionType.Copy]: CopyIcon,
|
|
24
|
+
[BaseMessageActionType.Edit]: Pencil,
|
|
25
|
+
[BaseMessageActionType.Retry]: ArrowRotateLeft,
|
|
26
|
+
[BaseMessageActionType.Like]: ThumbsUp,
|
|
27
|
+
[BaseMessageActionType.Unlike]: ThumbsDown,
|
|
28
|
+
[BaseMessageActionType.Delete]: TrashBin,
|
|
27
29
|
};
|
|
28
30
|
export const BaseMessage = (props) => {
|
|
29
31
|
const { className, qa, showActionsOnHover, actions, children, role: variant, showTimestamp, timestamp = '', } = props;
|
|
30
32
|
// Get tooltip text for action
|
|
31
33
|
const getTooltipText = (actionType) => {
|
|
34
|
+
if (!actionType) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
32
37
|
const tooltipKey = `action-tooltip-${actionType}`;
|
|
33
38
|
// Check if tooltip exists in i18n, otherwise return empty string
|
|
34
39
|
try {
|
|
@@ -39,10 +44,36 @@ export const BaseMessage = (props) => {
|
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
const hasActions = actions && actions.length > 0;
|
|
42
|
-
return (_jsxs("div", { className: b({ variant, 'btn-hover': showActionsOnHover }, className), "data-qa": qa, children: [children, hasActions && (_jsxs("div", { className: b('actions', { reverse: variant !== 'user' }), children: [showTimestamp ? _jsx(ChatDate, { date: timestamp, format: "HH:mm", showTime: true }) : null, _jsx(ButtonGroup, { children: actions === null || actions === void 0 ? void 0 : actions.map((action) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
return (_jsxs("div", { className: b({ variant, 'btn-hover': showActionsOnHover }, className), "data-qa": qa, children: [children, hasActions && (_jsxs("div", { className: b('actions', { reverse: variant !== 'user' }), children: [showTimestamp ? _jsx(ChatDate, { date: timestamp, format: "HH:mm", showTime: true }) : null, _jsx(ButtonGroup, { children: actions === null || actions === void 0 ? void 0 : actions.map((action, index) => {
|
|
48
|
+
if (!isActionConfig(action)) {
|
|
49
|
+
return _jsx(React.Fragment, { children: action }, index);
|
|
50
|
+
}
|
|
51
|
+
const tooltipText = getTooltipText(action.actionType);
|
|
52
|
+
const defaultIcon = action.actionType
|
|
53
|
+
? BaseMessageActionIcons[action.actionType]
|
|
54
|
+
: undefined;
|
|
55
|
+
// Determine tooltip title
|
|
56
|
+
let tooltipTitle;
|
|
57
|
+
if (action.label) {
|
|
58
|
+
tooltipTitle = action.label;
|
|
59
|
+
}
|
|
60
|
+
else if (tooltipText && action.actionType !== 'custom') {
|
|
61
|
+
tooltipTitle = tooltipText;
|
|
62
|
+
}
|
|
63
|
+
// Determine button content
|
|
64
|
+
let buttonContent;
|
|
65
|
+
if (action.icon) {
|
|
66
|
+
buttonContent = action.icon;
|
|
67
|
+
}
|
|
68
|
+
else if (defaultIcon) {
|
|
69
|
+
buttonContent = _jsx(Icon, { size: 16, data: defaultIcon });
|
|
70
|
+
}
|
|
71
|
+
else if (action.label) {
|
|
72
|
+
buttonContent = action.label;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
buttonContent = action.actionType;
|
|
76
|
+
}
|
|
77
|
+
return (_jsx(ActionButton, Object.assign({}, action, { tooltipTitle: tooltipTitle, view: action.view || 'flat-secondary', children: buttonContent }), action.actionType || index));
|
|
47
78
|
}) })] }))] }));
|
|
48
79
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { type ButtonGroupProps } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Playground: StoryFn<ButtonGroupProps>;
|
|
6
|
+
export declare const Orientation: StoryObj<ButtonGroupProps>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '@gravity-ui/uikit';
|
|
3
|
+
import { ButtonGroup } from '..';
|
|
4
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
5
|
+
import { Showcase } from '../../../../demo/Showcase';
|
|
6
|
+
import { ShowcaseItem } from '../../../../demo/ShowcaseItem';
|
|
7
|
+
import MDXDocs from './Docs.mdx';
|
|
8
|
+
export default {
|
|
9
|
+
title: 'molecules/ButtonGroup',
|
|
10
|
+
component: ButtonGroup,
|
|
11
|
+
parameters: {
|
|
12
|
+
docs: {
|
|
13
|
+
page: MDXDocs,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
argTypes: {
|
|
17
|
+
orientation: {
|
|
18
|
+
control: 'radio',
|
|
19
|
+
options: ['horizontal', 'vertical'],
|
|
20
|
+
description: 'Orientation of buttons',
|
|
21
|
+
},
|
|
22
|
+
className: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'Additional CSS class',
|
|
25
|
+
},
|
|
26
|
+
qa: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'QA/test identifier',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const defaultDecorators = [
|
|
33
|
+
(Story) => (_jsx(ContentWrapper, { children: _jsx(Showcase, { children: _jsx(Story, {}) }) })),
|
|
34
|
+
];
|
|
35
|
+
const buttonChildren = (_jsxs(_Fragment, { children: [_jsx(Button, { children: "Button 1" }), _jsx(Button, { children: "Button 2" }), _jsx(Button, { children: "Button 3" })] }));
|
|
36
|
+
export const Playground = (args) => (_jsx(ContentWrapper, { children: _jsx(ButtonGroup, Object.assign({}, args)) }));
|
|
37
|
+
Playground.args = {
|
|
38
|
+
children: buttonChildren,
|
|
39
|
+
orientation: 'horizontal',
|
|
40
|
+
};
|
|
41
|
+
export const Orientation = {
|
|
42
|
+
render: (args) => (_jsxs(_Fragment, { children: [_jsx(ShowcaseItem, { title: "Horizontal", children: _jsx(ButtonGroup, Object.assign({}, args, { orientation: "horizontal", children: buttonChildren })) }), _jsx(ShowcaseItem, { title: "Vertical", children: _jsx(ButtonGroup, Object.assign({}, args, { orientation: "vertical", children: buttonChildren })) })] })),
|
|
43
|
+
decorators: defaultDecorators,
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { PromptInputBody } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
type Story = StoryObj<typeof PromptInputBody>;
|
|
6
|
+
export declare const Playground: Story;
|
|
7
|
+
export declare const WithValue: Story;
|
|
8
|
+
export declare const MultiLine: Story;
|
|
9
|
+
export declare const WithMaxLength: Story;
|
|
10
|
+
export declare const WithCustomContent: Story;
|
|
11
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { PromptInputBody } from '..';
|
|
4
|
+
import { ContentWrapper } from '../../../../demo/ContentWrapper';
|
|
5
|
+
import { SwapArea } from '../../../../demo/SwapArea';
|
|
6
|
+
import MDXDocs from './Docs.mdx';
|
|
7
|
+
export default {
|
|
8
|
+
title: 'molecules/PromptInputBody',
|
|
9
|
+
component: PromptInputBody,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: MDXDocs,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const defaultDecorators = [
|
|
17
|
+
(Story) => (_jsx(ContentWrapper, { width: "450px", children: _jsx(Story, {}) })),
|
|
18
|
+
];
|
|
19
|
+
export const Playground = {
|
|
20
|
+
args: {
|
|
21
|
+
placeholder: 'Plan, code, build and test anything',
|
|
22
|
+
},
|
|
23
|
+
decorators: defaultDecorators,
|
|
24
|
+
};
|
|
25
|
+
export const WithValue = {
|
|
26
|
+
render: (args) => {
|
|
27
|
+
const [value, setValue] = useState('Hello, this is a test message!');
|
|
28
|
+
return (_jsx(PromptInputBody, Object.assign({}, args, { value: value, onChange: setValue, placeholder: "Plan, code, build and test anything" })));
|
|
29
|
+
},
|
|
30
|
+
decorators: defaultDecorators,
|
|
31
|
+
};
|
|
32
|
+
export const MultiLine = {
|
|
33
|
+
render: (args) => {
|
|
34
|
+
const [value, setValue] = useState('This is a multi-line\ntext input\nwith several lines\nof content');
|
|
35
|
+
return (_jsx(PromptInputBody, Object.assign({}, args, { value: value, onChange: setValue, placeholder: "Plan, code, build and test anything", minRows: 3, maxRows: 10 })));
|
|
36
|
+
},
|
|
37
|
+
decorators: defaultDecorators,
|
|
38
|
+
};
|
|
39
|
+
export const WithMaxLength = {
|
|
40
|
+
render: (args) => {
|
|
41
|
+
const [value, setValue] = useState('');
|
|
42
|
+
return (_jsxs(_Fragment, { children: [_jsx(PromptInputBody, Object.assign({}, args, { value: value, onChange: setValue, placeholder: "Maximum 100 characters", maxLength: 100 })), _jsxs("div", { style: {
|
|
43
|
+
marginTop: '8px',
|
|
44
|
+
fontSize: '12px',
|
|
45
|
+
color: 'var(--g-color-text-secondary)',
|
|
46
|
+
}, children: [value.length, " / 100 characters"] })] }));
|
|
47
|
+
},
|
|
48
|
+
decorators: defaultDecorators,
|
|
49
|
+
};
|
|
50
|
+
export const WithCustomContent = {
|
|
51
|
+
args: {
|
|
52
|
+
children: _jsx(SwapArea, {}),
|
|
53
|
+
},
|
|
54
|
+
decorators: defaultDecorators,
|
|
55
|
+
};
|
|
56
|
+
export const Disabled = {
|
|
57
|
+
render: (args) => {
|
|
58
|
+
const [value, setValue] = useState('This input is disabled');
|
|
59
|
+
return (_jsx(PromptInputBody, Object.assign({}, args, { value: value, onChange: setValue, placeholder: "Plan, code, build and test anything", disabledInput: true })));
|
|
60
|
+
},
|
|
61
|
+
decorators: defaultDecorators,
|
|
62
|
+
};
|
package/dist/components/molecules/PromptInputFooter/__stories__/PromptInputFooter.stories.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
+
import { PromptInputFooter } from '..';
|
|
3
|
+
declare const _default: Meta;
|
|
4
|
+
export default _default;
|
|
5
|
+
type Story = StoryObj<typeof PromptInputFooter>;
|
|
6
|
+
export declare const Playground: Story;
|
|
7
|
+
export declare const WithAllIcons: Story;
|
|
8
|
+
export declare const DisabledButton: Story;
|
|
9
|
+
export declare const LoadingButton: Story;
|
|
10
|
+
export declare const CancelableButton: Story;
|
|
11
|
+
export declare const WithCustomContent: Story;
|