@agentscope-ai/chat 1.1.52-beta.1772956668643 → 1.1.52
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/components/AgentScopeRuntimeWebUI/core/Chat/Welcome/index.tsx +10 -47
- package/components/Sender/index.tsx +1 -1
- package/components/WelcomePrompts/demo/basic.tsx +17 -0
- package/components/WelcomePrompts/index.en-US.md +19 -0
- package/components/WelcomePrompts/index.tsx +89 -0
- package/components/WelcomePrompts/index.zh-CN.md +19 -0
- package/components/WelcomePrompts/style.ts +62 -0
- package/components/index.ts +5 -0
- package/lib/AgentScopeRuntimeWebUI/core/Chat/Welcome/index.js +9 -60
- package/lib/Sender/index.js +3 -3
- package/lib/WelcomePrompts/index.d.ts +33 -0
- package/lib/WelcomePrompts/index.js +72 -0
- package/lib/WelcomePrompts/style.d.ts +3 -0
- package/lib/WelcomePrompts/style.js +21 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { useProviderContext } from "@agentscope-ai/chat";
|
|
2
1
|
import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
|
|
3
|
-
import
|
|
4
|
-
import Style from './styles';
|
|
5
|
-
import { SparkRightArrowLine } from "@agentscope-ai/icons";
|
|
2
|
+
import WelcomePrompts from '../../../../WelcomePrompts';
|
|
6
3
|
|
|
7
4
|
export default function Welcome(props: { onSubmit: (data: { query: string; fileList?: any[] }) => void }) {
|
|
8
5
|
const welcomeOptions = useChatAnywhereOptions(v => v.welcome);
|
|
9
|
-
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-welcome-default');
|
|
10
6
|
|
|
11
7
|
if (!welcomeOptions) return null;
|
|
12
8
|
|
|
@@ -20,48 +16,15 @@ export default function Welcome(props: { onSubmit: (data: { query: string; fileL
|
|
|
20
16
|
onSubmit: props.onSubmit,
|
|
21
17
|
});
|
|
22
18
|
|
|
23
|
-
|
|
24
19
|
const { greeting, avatar, prompts, description } = otherWelcomeOptions;
|
|
25
20
|
|
|
26
|
-
return
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
description && <div className={`${prefixCls}-description`}>{description}</div>
|
|
37
|
-
}
|
|
38
|
-
{
|
|
39
|
-
prompts?.length > 0 && <div className={`${prefixCls}-prompts`}>
|
|
40
|
-
{
|
|
41
|
-
prompts.map(item => {
|
|
42
|
-
const prompt = typeof item === 'string' ? { label: item, value: item } : {
|
|
43
|
-
...item,
|
|
44
|
-
label: item.label || item.value,
|
|
45
|
-
value: item.value,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return <Prompt key={prompt.value} prompt={prompt} onSubmit={props.onSubmit} />
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
</div>
|
|
52
|
-
}
|
|
53
|
-
</div>
|
|
54
|
-
</>;
|
|
21
|
+
return (
|
|
22
|
+
<WelcomePrompts
|
|
23
|
+
greeting={greeting}
|
|
24
|
+
avatar={avatar}
|
|
25
|
+
description={description}
|
|
26
|
+
prompts={prompts}
|
|
27
|
+
onClick={query => props.onSubmit({ query })}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
55
30
|
}
|
|
56
|
-
|
|
57
|
-
function Prompt(props: { prompt: { label: string; value: string; icon?: React.ReactElement }, onSubmit: (data: { query: string; fileList?: any[] }) => void }) {
|
|
58
|
-
const prefixCls = useProviderContext().getPrefixCls('chat-anywhere-welcome-default');
|
|
59
|
-
|
|
60
|
-
return <div className={`${prefixCls}-prompt`} onClick={() => props.onSubmit({ query: props.prompt.value })}>
|
|
61
|
-
<img className={`${prefixCls}-prompt-icon`} src="https://img.alicdn.com/imgextra/i3/O1CN01822qqr1PVyaK7MYtn_!!6000000001847-2-tps-40-40.png" alt=""></img>
|
|
62
|
-
<span className={`${prefixCls}-prompt-label`}>
|
|
63
|
-
{props.prompt.label}
|
|
64
|
-
</span>
|
|
65
|
-
<SparkRightArrowLine />
|
|
66
|
-
</div>
|
|
67
|
-
}
|
|
@@ -259,7 +259,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
|
|
|
259
259
|
const [zoom, setZoom] = useState(zoomable ? false : undefined);
|
|
260
260
|
const [focus, setFocus] = useState(false);
|
|
261
261
|
const autoSize = React.useMemo(() => {
|
|
262
|
-
return zoom ? { maxRows:
|
|
262
|
+
return zoom ? { maxRows: 5, minRows: 5 } : { maxRows: 5, minRows: initialRows };
|
|
263
263
|
}, [zoomable, zoom]);
|
|
264
264
|
|
|
265
265
|
const { direction, getPrefixCls } = useProviderContext();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WelcomePrompts } from '@agentscope-ai/chat';
|
|
2
|
+
|
|
3
|
+
export default function () {
|
|
4
|
+
return (
|
|
5
|
+
<WelcomePrompts
|
|
6
|
+
avatar="https://gw.alicdn.com/imgextra/i1/O1CN01n7R7cy1MkE5OYeXV9_!!6000000001472-55-tps-24-24.svg"
|
|
7
|
+
greeting="你好,我是 AgentScope 助手"
|
|
8
|
+
description="我可以帮助你解答各种问题,快来试试吧"
|
|
9
|
+
prompts={[
|
|
10
|
+
'如何快速上手 AgentScope?',
|
|
11
|
+
'帮我生成一段 Python 代码',
|
|
12
|
+
{ label: '介绍一下多智能体协作', value: '什么是多智能体协作?它有哪些应用场景?' },
|
|
13
|
+
]}
|
|
14
|
+
onClick={(query) => console.log('clicked:', query)}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 3
|
|
3
|
+
|
|
4
|
+
group:
|
|
5
|
+
title: Display
|
|
6
|
+
order: 1
|
|
7
|
+
title: WelcomePrompts
|
|
8
|
+
description: A welcome component for displaying greetings, descriptions, and prompt shortcuts
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<DemoTitle title="WelcomePrompts" desc="A welcome component for displaying greetings, descriptions, and prompt shortcuts"></DemoTitle>
|
|
12
|
+
|
|
13
|
+
<code src="./demo/basic.tsx">Example</code>
|
|
14
|
+
|
|
15
|
+
<Install>import { WelcomePrompts } from '@agentscope-ai/chat'</Install>
|
|
16
|
+
|
|
17
|
+
#### API
|
|
18
|
+
|
|
19
|
+
<ApiParser source="./index.tsx" id="IWelcomePromptsProps"></ApiParser>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Avatar } from 'antd';
|
|
3
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
4
|
+
import { SparkRightArrowLine } from '@agentscope-ai/icons';
|
|
5
|
+
import Style from './style';
|
|
6
|
+
|
|
7
|
+
export interface IWelcomePromptsProps {
|
|
8
|
+
/**
|
|
9
|
+
* @description 欢迎语
|
|
10
|
+
* @descriptionEn Greeting text
|
|
11
|
+
*/
|
|
12
|
+
greeting?: string | React.ReactElement;
|
|
13
|
+
/**
|
|
14
|
+
* @description 描述信息
|
|
15
|
+
* @descriptionEn Description text
|
|
16
|
+
*/
|
|
17
|
+
description?: string | React.ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* @description 头像
|
|
20
|
+
* @descriptionEn Avatar
|
|
21
|
+
*/
|
|
22
|
+
avatar?: string | React.ReactElement;
|
|
23
|
+
/**
|
|
24
|
+
* @description 提示语列表
|
|
25
|
+
* @descriptionEn Prompt list
|
|
26
|
+
*/
|
|
27
|
+
prompts?: (
|
|
28
|
+
| { label?: string; value: string; icon?: React.ReactElement }
|
|
29
|
+
| string
|
|
30
|
+
)[];
|
|
31
|
+
/**
|
|
32
|
+
* @description 点击提示语时的回调
|
|
33
|
+
* @descriptionEn Callback when a prompt is clicked
|
|
34
|
+
*/
|
|
35
|
+
onClick?: (query: string) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function WelcomePrompts(props: IWelcomePromptsProps) {
|
|
39
|
+
const { greeting, avatar, description, prompts, onClick } = props;
|
|
40
|
+
const prefixCls = useProviderContext().getPrefixCls('welcome-prompts');
|
|
41
|
+
|
|
42
|
+
return <>
|
|
43
|
+
<Style />
|
|
44
|
+
<div className={prefixCls}>
|
|
45
|
+
{avatar && (
|
|
46
|
+
typeof avatar === 'string'
|
|
47
|
+
? <Avatar src={avatar} shape="square" size={64} />
|
|
48
|
+
: avatar
|
|
49
|
+
)}
|
|
50
|
+
{greeting && <div className={`${prefixCls}-greeting`}>{greeting}</div>}
|
|
51
|
+
{description && <div className={`${prefixCls}-description`}>{description}</div>}
|
|
52
|
+
{prompts?.length > 0 && (
|
|
53
|
+
<div className={`${prefixCls}-prompts`}>
|
|
54
|
+
{prompts.map(item => {
|
|
55
|
+
const prompt = typeof item === 'string'
|
|
56
|
+
? { label: item, value: item }
|
|
57
|
+
: { ...item, label: item.label || item.value, value: item.value };
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Prompt key={prompt.value} prompt={prompt} prefixCls={prefixCls} onClick={onClick} />
|
|
61
|
+
);
|
|
62
|
+
})}
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
</>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Prompt(props: {
|
|
70
|
+
prompt: { label: string; value: string; icon?: React.ReactElement };
|
|
71
|
+
prefixCls: string;
|
|
72
|
+
onClick?: (query: string) => void;
|
|
73
|
+
}) {
|
|
74
|
+
const { prefixCls } = props;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className={`${prefixCls}-prompt`} onClick={() => props.onClick?.(props.prompt.value)}>
|
|
78
|
+
<img
|
|
79
|
+
className={`${prefixCls}-prompt-icon`}
|
|
80
|
+
src="https://img.alicdn.com/imgextra/i3/O1CN01822qqr1PVyaK7MYtn_!!6000000001847-2-tps-40-40.png"
|
|
81
|
+
alt=""
|
|
82
|
+
/>
|
|
83
|
+
<span className={`${prefixCls}-prompt-label`}>
|
|
84
|
+
{props.prompt.label}
|
|
85
|
+
</span>
|
|
86
|
+
<SparkRightArrowLine />
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 3
|
|
3
|
+
|
|
4
|
+
group:
|
|
5
|
+
title: 展示
|
|
6
|
+
order: 1
|
|
7
|
+
title: WelcomePrompts 欢迎提示
|
|
8
|
+
description: 欢迎提示组件,用于展示欢迎语、描述和快捷提示列表
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<DemoTitle title="WelcomePrompts 欢迎提示" desc="欢迎提示组件,用于展示欢迎语、描述和快捷提示列表"></DemoTitle>
|
|
12
|
+
|
|
13
|
+
<code src="./demo/basic.tsx">基本用法</code>
|
|
14
|
+
|
|
15
|
+
<Install>import { WelcomePrompts } from '@agentscope-ai/chat'</Install>
|
|
16
|
+
|
|
17
|
+
#### API
|
|
18
|
+
|
|
19
|
+
<ApiParser source="./index.tsx" id="IWelcomePromptsProps"></ApiParser>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createGlobalStyle } from 'antd-style';
|
|
2
|
+
|
|
3
|
+
export default createGlobalStyle`
|
|
4
|
+
.${(p) => p.theme.prefixCls}-welcome-prompts {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 12px;
|
|
9
|
+
width: 100%;
|
|
10
|
+
|
|
11
|
+
&-greeting {
|
|
12
|
+
color: ${({ theme }) => theme.colorText};
|
|
13
|
+
font-size: 16px;
|
|
14
|
+
line-height: 26px;
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-description {
|
|
19
|
+
color: ${({ theme }) => theme.colorTextSecondary};
|
|
20
|
+
font-size: 12px;
|
|
21
|
+
line-height: 18px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&-prompts {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: 10px;
|
|
28
|
+
margin-top: 10px;
|
|
29
|
+
width: 360px;
|
|
30
|
+
margin: 10px auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&-prompt {
|
|
34
|
+
height: 42px;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
background-color: ${({ theme }) => theme.colorFillQuaternary};
|
|
38
|
+
color: ${({ theme }) => theme.colorText};
|
|
39
|
+
font-size: 14px;
|
|
40
|
+
padding: 10px 16px;
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
gap: 12px;
|
|
44
|
+
|
|
45
|
+
&-icon {
|
|
46
|
+
width: 20px;
|
|
47
|
+
height: 20px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&-label {
|
|
51
|
+
flex: 1;
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
text-overflow: ellipsis;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&:hover {
|
|
58
|
+
background-color: ${({ theme }) => theme.colorFillTertiary};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
package/components/index.ts
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
var _excluded = ["render"];
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
-
import { useProviderContext } from "../../../..";
|
|
11
4
|
import { useChatAnywhereOptions } from "../../Context/ChatAnywhereOptionsContext";
|
|
12
|
-
import
|
|
13
|
-
import Style from "./styles";
|
|
14
|
-
import { SparkRightArrowLine } from "@agentscope-ai/icons";
|
|
5
|
+
import WelcomePrompts from "../../../../WelcomePrompts";
|
|
15
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
7
|
export default function Welcome(props) {
|
|
19
8
|
var welcomeOptions = useChatAnywhereOptions(function (v) {
|
|
20
9
|
return v.welcome;
|
|
21
10
|
});
|
|
22
|
-
var prefixCls = useProviderContext().getPrefixCls('chat-anywhere-welcome-default');
|
|
23
11
|
if (!welcomeOptions) return null;
|
|
24
12
|
var render = welcomeOptions.render,
|
|
25
13
|
otherWelcomeOptions = _objectWithoutProperties(welcomeOptions, _excluded);
|
|
@@ -34,54 +22,15 @@ export default function Welcome(props) {
|
|
|
34
22
|
avatar = otherWelcomeOptions.avatar,
|
|
35
23
|
prompts = otherWelcomeOptions.prompts,
|
|
36
24
|
description = otherWelcomeOptions.description;
|
|
37
|
-
return /*#__PURE__*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
size: 64
|
|
44
|
-
}), greeting && /*#__PURE__*/_jsx("div", {
|
|
45
|
-
className: "".concat(prefixCls, "-greeting"),
|
|
46
|
-
children: greeting
|
|
47
|
-
}), description && /*#__PURE__*/_jsx("div", {
|
|
48
|
-
className: "".concat(prefixCls, "-description"),
|
|
49
|
-
children: description
|
|
50
|
-
}), (prompts === null || prompts === void 0 ? void 0 : prompts.length) > 0 && /*#__PURE__*/_jsx("div", {
|
|
51
|
-
className: "".concat(prefixCls, "-prompts"),
|
|
52
|
-
children: prompts.map(function (item) {
|
|
53
|
-
var prompt = typeof item === 'string' ? {
|
|
54
|
-
label: item,
|
|
55
|
-
value: item
|
|
56
|
-
} : _objectSpread(_objectSpread({}, item), {}, {
|
|
57
|
-
label: item.label || item.value,
|
|
58
|
-
value: item.value
|
|
59
|
-
});
|
|
60
|
-
return /*#__PURE__*/_jsx(Prompt, {
|
|
61
|
-
prompt: prompt,
|
|
62
|
-
onSubmit: props.onSubmit
|
|
63
|
-
}, prompt.value);
|
|
64
|
-
})
|
|
65
|
-
})]
|
|
66
|
-
})]
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function Prompt(props) {
|
|
70
|
-
var prefixCls = useProviderContext().getPrefixCls('chat-anywhere-welcome-default');
|
|
71
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
72
|
-
className: "".concat(prefixCls, "-prompt"),
|
|
73
|
-
onClick: function onClick() {
|
|
25
|
+
return /*#__PURE__*/_jsx(WelcomePrompts, {
|
|
26
|
+
greeting: greeting,
|
|
27
|
+
avatar: avatar,
|
|
28
|
+
description: description,
|
|
29
|
+
prompts: prompts,
|
|
30
|
+
onClick: function onClick(query) {
|
|
74
31
|
return props.onSubmit({
|
|
75
|
-
query:
|
|
32
|
+
query: query
|
|
76
33
|
});
|
|
77
|
-
}
|
|
78
|
-
children: [/*#__PURE__*/_jsx("img", {
|
|
79
|
-
className: "".concat(prefixCls, "-prompt-icon"),
|
|
80
|
-
src: "https://img.alicdn.com/imgextra/i3/O1CN01822qqr1PVyaK7MYtn_!!6000000001847-2-tps-40-40.png",
|
|
81
|
-
alt: ""
|
|
82
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
83
|
-
className: "".concat(prefixCls, "-prompt-label"),
|
|
84
|
-
children: props.prompt.label
|
|
85
|
-
}), /*#__PURE__*/_jsx(SparkRightArrowLine, {})]
|
|
34
|
+
}
|
|
86
35
|
});
|
|
87
36
|
}
|
package/lib/Sender/index.js
CHANGED
|
@@ -92,10 +92,10 @@ var ForwardSender = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
92
92
|
setFocus = _useState4[1];
|
|
93
93
|
var autoSize = React.useMemo(function () {
|
|
94
94
|
return zoom ? {
|
|
95
|
-
maxRows:
|
|
96
|
-
minRows:
|
|
95
|
+
maxRows: 5,
|
|
96
|
+
minRows: 5
|
|
97
97
|
} : {
|
|
98
|
-
maxRows:
|
|
98
|
+
maxRows: 5,
|
|
99
99
|
minRows: initialRows
|
|
100
100
|
};
|
|
101
101
|
}, [zoomable, zoom]);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IWelcomePromptsProps {
|
|
3
|
+
/**
|
|
4
|
+
* @description 欢迎语
|
|
5
|
+
* @descriptionEn Greeting text
|
|
6
|
+
*/
|
|
7
|
+
greeting?: string | React.ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* @description 描述信息
|
|
10
|
+
* @descriptionEn Description text
|
|
11
|
+
*/
|
|
12
|
+
description?: string | React.ReactElement;
|
|
13
|
+
/**
|
|
14
|
+
* @description 头像
|
|
15
|
+
* @descriptionEn Avatar
|
|
16
|
+
*/
|
|
17
|
+
avatar?: string | React.ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* @description 提示语列表
|
|
20
|
+
* @descriptionEn Prompt list
|
|
21
|
+
*/
|
|
22
|
+
prompts?: ({
|
|
23
|
+
label?: string;
|
|
24
|
+
value: string;
|
|
25
|
+
icon?: React.ReactElement;
|
|
26
|
+
} | string)[];
|
|
27
|
+
/**
|
|
28
|
+
* @description 点击提示语时的回调
|
|
29
|
+
* @descriptionEn Callback when a prompt is clicked
|
|
30
|
+
*/
|
|
31
|
+
onClick?: (query: string) => void;
|
|
32
|
+
}
|
|
33
|
+
export default function WelcomePrompts(props: IWelcomePromptsProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Avatar } from 'antd';
|
|
9
|
+
import { useProviderContext } from "./..";
|
|
10
|
+
import { SparkRightArrowLine } from '@agentscope-ai/icons';
|
|
11
|
+
import Style from "./style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
+
export default function WelcomePrompts(props) {
|
|
16
|
+
var greeting = props.greeting,
|
|
17
|
+
avatar = props.avatar,
|
|
18
|
+
description = props.description,
|
|
19
|
+
prompts = props.prompts,
|
|
20
|
+
onClick = props.onClick;
|
|
21
|
+
var prefixCls = useProviderContext().getPrefixCls('welcome-prompts');
|
|
22
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
23
|
+
children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsxs("div", {
|
|
24
|
+
className: prefixCls,
|
|
25
|
+
children: [avatar && (typeof avatar === 'string' ? /*#__PURE__*/_jsx(Avatar, {
|
|
26
|
+
src: avatar,
|
|
27
|
+
shape: "square",
|
|
28
|
+
size: 64
|
|
29
|
+
}) : avatar), greeting && /*#__PURE__*/_jsx("div", {
|
|
30
|
+
className: "".concat(prefixCls, "-greeting"),
|
|
31
|
+
children: greeting
|
|
32
|
+
}), description && /*#__PURE__*/_jsx("div", {
|
|
33
|
+
className: "".concat(prefixCls, "-description"),
|
|
34
|
+
children: description
|
|
35
|
+
}), (prompts === null || prompts === void 0 ? void 0 : prompts.length) > 0 && /*#__PURE__*/_jsx("div", {
|
|
36
|
+
className: "".concat(prefixCls, "-prompts"),
|
|
37
|
+
children: prompts.map(function (item) {
|
|
38
|
+
var prompt = typeof item === 'string' ? {
|
|
39
|
+
label: item,
|
|
40
|
+
value: item
|
|
41
|
+
} : _objectSpread(_objectSpread({}, item), {}, {
|
|
42
|
+
label: item.label || item.value,
|
|
43
|
+
value: item.value
|
|
44
|
+
});
|
|
45
|
+
return /*#__PURE__*/_jsx(Prompt, {
|
|
46
|
+
prompt: prompt,
|
|
47
|
+
prefixCls: prefixCls,
|
|
48
|
+
onClick: onClick
|
|
49
|
+
}, prompt.value);
|
|
50
|
+
})
|
|
51
|
+
})]
|
|
52
|
+
})]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function Prompt(props) {
|
|
56
|
+
var prefixCls = props.prefixCls;
|
|
57
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
58
|
+
className: "".concat(prefixCls, "-prompt"),
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
var _props$onClick;
|
|
61
|
+
return (_props$onClick = props.onClick) === null || _props$onClick === void 0 ? void 0 : _props$onClick.call(props, props.prompt.value);
|
|
62
|
+
},
|
|
63
|
+
children: [/*#__PURE__*/_jsx("img", {
|
|
64
|
+
className: "".concat(prefixCls, "-prompt-icon"),
|
|
65
|
+
src: "https://img.alicdn.com/imgextra/i3/O1CN01822qqr1PVyaK7MYtn_!!6000000001847-2-tps-40-40.png",
|
|
66
|
+
alt: ""
|
|
67
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
68
|
+
className: "".concat(prefixCls, "-prompt-label"),
|
|
69
|
+
children: props.prompt.label
|
|
70
|
+
}), /*#__PURE__*/_jsx(SparkRightArrowLine, {})]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createGlobalStyle } from 'antd-style';
|
|
4
|
+
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-welcome-prompts {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 12px;\n width: 100%;\n\n &-greeting {\n color: ", ";\n font-size: 16px;\n line-height: 26px;\n font-weight: 500;\n }\n\n &-description {\n color: ", ";\n font-size: 12px;\n line-height: 18px;\n }\n\n &-prompts {\n display: flex;\n flex-direction: column;\n gap: 10px;\n margin-top: 10px;\n width: 360px;\n margin: 10px auto;\n }\n\n &-prompt {\n height: 42px;\n display: flex;\n align-items: center;\n background-color: ", ";\n color: ", ";\n font-size: 14px;\n padding: 10px 16px;\n border-radius: 8px;\n cursor: pointer;\n gap: 12px;\n\n &-icon {\n width: 20px;\n height: 20px;\n }\n\n &-label {\n flex: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n\n &:hover {\n background-color: ", ";\n }\n }\n}\n"])), function (p) {
|
|
5
|
+
return p.theme.prefixCls;
|
|
6
|
+
}, function (_ref) {
|
|
7
|
+
var theme = _ref.theme;
|
|
8
|
+
return theme.colorText;
|
|
9
|
+
}, function (_ref2) {
|
|
10
|
+
var theme = _ref2.theme;
|
|
11
|
+
return theme.colorTextSecondary;
|
|
12
|
+
}, function (_ref3) {
|
|
13
|
+
var theme = _ref3.theme;
|
|
14
|
+
return theme.colorFillQuaternary;
|
|
15
|
+
}, function (_ref4) {
|
|
16
|
+
var theme = _ref4.theme;
|
|
17
|
+
return theme.colorText;
|
|
18
|
+
}, function (_ref5) {
|
|
19
|
+
var theme = _ref5.theme;
|
|
20
|
+
return theme.colorFillTertiary;
|
|
21
|
+
});
|
package/lib/index.d.ts
CHANGED
|
@@ -28,3 +28,4 @@ export { default as Markdown, type MarkdownProps as IMarkdownProps, type Markdow
|
|
|
28
28
|
export { default as AIGC } from './AIGC';
|
|
29
29
|
export { default as AssetsPreview, type IAssetsPreviewProps, } from './AssetsPreview';
|
|
30
30
|
export { Sandbox as GenerativeUISandbox } from './GenerativeUI';
|
|
31
|
+
export { default as WelcomePrompts, type IWelcomePromptsProps, } from './WelcomePrompts';
|
package/lib/index.js
CHANGED
|
@@ -26,4 +26,5 @@ export { default as Welcome } from "./Welcome";
|
|
|
26
26
|
export { default as Markdown } from "./Markdown";
|
|
27
27
|
export { default as AIGC } from "./AIGC";
|
|
28
28
|
export { default as AssetsPreview } from "./AssetsPreview";
|
|
29
|
-
export { Sandbox as GenerativeUISandbox } from "./GenerativeUI";
|
|
29
|
+
export { Sandbox as GenerativeUISandbox } from "./GenerativeUI";
|
|
30
|
+
export { default as WelcomePrompts } from "./WelcomePrompts";
|
package/package.json
CHANGED