@alifd/chat 0.3.33-beta.0 → 0.3.33-beta.2

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/es/index.js CHANGED
@@ -32,4 +32,4 @@ export { default as CheckboxGroup } from './checkbox-group';
32
32
  export { default as Select } from './select';
33
33
  export { default as Flip } from './flip';
34
34
  export { default as ToolStatus } from './tool-status';
35
- export const version = '0.3.33-beta.0';
35
+ export const version = '0.3.33-beta.2';
@@ -7,13 +7,14 @@
7
7
  import React, { forwardRef } from 'react';
8
8
  import { ConfigProvider } from '@alifd/next';
9
9
  import Icon from '../icon';
10
+ import Button from '../button';
10
11
  import cs from 'classnames';
11
12
  import { PREFIX_DEFAULT } from '../utils';
12
13
  const SUCCESS_ICON = 'success';
13
14
  const ERROR_ICON = 'error';
14
15
  const LOADING_ICON = 'loading';
15
16
  const ToolStatus = forwardRef((props, ref) => {
16
- const { className, selected = false, status, result = '', onToolClick, extra } = props;
17
+ const { useText = '使用', name, className, selected = false, status, onToolClick, authInfo } = props;
17
18
  const handleClick = (event) => {
18
19
  event.stopPropagation();
19
20
  onToolClick === null || onToolClick === void 0 ? void 0 : onToolClick(props);
@@ -22,10 +23,15 @@ const ToolStatus = forwardRef((props, ref) => {
22
23
  return (React.createElement("div", { className: cs(`${PREFIX_DEFAULT}tool-status ${statusClassName} ${status}`, className), ref: ref, onClick: (e) => {
23
24
  handleClick(e);
24
25
  } },
25
- React.createElement("div", { className: 'main-content' },
26
- React.createElement(Icon, { size: 'small', type: status === 'error' ? ERROR_ICON : status === 'success' ? SUCCESS_ICON : LOADING_ICON }),
27
- React.createElement("div", { className: 'content-result' }, result)),
28
- extra && React.createElement("div", { className: 'extra-content' }, extra)));
26
+ React.createElement(Icon, { size: 'small', type: status === 'failed' ? ERROR_ICON : status === 'completed' ? SUCCESS_ICON : LOADING_ICON }),
27
+ authInfo && status === 'auth' && React.createElement("div", { className: 'auth-content' },
28
+ React.createElement(Button, { type: 'primary', text: true, size: 'medium', onClick: (event) => {
29
+ var _a;
30
+ event.stopPropagation();
31
+ (_a = authInfo === null || authInfo === void 0 ? void 0 : authInfo.onAuthClick) === null || _a === void 0 ? void 0 : _a.call(authInfo, props);
32
+ } }, authInfo === null || authInfo === void 0 ? void 0 : authInfo.content)),
33
+ React.createElement("div", { className: 'content-use-tips' }, useText),
34
+ React.createElement("div", { className: 'content-name' }, name)));
29
35
  });
30
36
  export * from './types';
31
37
  export default ConfigProvider.config(ToolStatus);
@@ -4,39 +4,52 @@
4
4
  width: fit-content;
5
5
  transition: width 0.3s ease-in-out;
6
6
  background-color: $color-fill1-1;//$color-brand1-1;
7
- padding: $s-1;
8
- border-radius: $s-2;
7
+ padding: $s-1 $s-3;
8
+ border-radius: $s-4;
9
9
  box-sizing: border-box;
10
10
  border: solid 1px $color-fill1-1;
11
11
  align-items: center;
12
+ display: flex;
13
+ i {
14
+ margin-right: $s-2;
15
+ }
12
16
 
13
17
  &.selected {
14
18
  background-color: $color-fill1-2;
15
19
  }
16
20
 
17
- &.success {
21
+ &.completed {
18
22
  i {
19
23
  color: $color-success-3;
20
24
  }
21
25
  }
22
26
 
23
- &.error {
27
+ &.failed {
24
28
  i {
25
29
  color: $color-error-3;
26
30
  }
27
31
  }
28
32
 
29
- &.loading {
33
+ &.running, &.auth, &.started {
30
34
  i {
31
35
  color: $color-brand1-6;
32
36
  }
33
37
  }
34
-
35
- .main-content {
36
- display: flex;
37
- .content-result {
38
- margin-left: 4px;
38
+
39
+ .auth-content {
40
+ margin-right: $s-1;
41
+ button {
42
+ font-size: $font-size-body-2 !important;
39
43
  }
40
44
  }
41
45
 
46
+ .content-use-tips {
47
+ color: $color-text1-2;
48
+ margin-right: $s-1;
49
+ }
50
+
51
+ .content-name {
52
+ color: $color-text1-4;
53
+ }
54
+
42
55
  }
@@ -1,5 +1,9 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import { type CommonProps } from '@alifd/next';
3
+ export interface ToolStatusAuthProps {
4
+ content: string | ReactNode;
5
+ onAuthClick?: (data: ToolStatusProps) => void;
6
+ }
3
7
  /**
4
8
  * 参考来源属性
5
9
  */
@@ -12,7 +16,7 @@ export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, Comm
12
16
  /**
13
17
  * 工具调用状态
14
18
  */
15
- status?: 'loading' | 'success' | 'error';
19
+ status?: 'started' | 'running' | 'completed' | 'failed' | 'auth';
16
20
  /**
17
21
  * 工具调用结果
18
22
  */
@@ -22,7 +26,15 @@ export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, Comm
22
26
  */
23
27
  onToolClick?: (data: ToolStatusProps) => void;
24
28
  /**
25
- * 额外需要渲染的内容
29
+ * 额外的授权信息
30
+ */
31
+ authInfo?: ToolStatusAuthProps;
32
+ /**
33
+ * 工具名称
34
+ */
35
+ name?: string;
36
+ /**
37
+ * 工具详情链接
26
38
  */
27
- extra?: string | ReactNode;
39
+ useText?: string;
28
40
  }
package/lib/index.js CHANGED
@@ -70,4 +70,4 @@ var flip_1 = require("./flip");
70
70
  Object.defineProperty(exports, "Flip", { enumerable: true, get: function () { return tslib_1.__importDefault(flip_1).default; } });
71
71
  var tool_status_1 = require("./tool-status");
72
72
  Object.defineProperty(exports, "ToolStatus", { enumerable: true, get: function () { return tslib_1.__importDefault(tool_status_1).default; } });
73
- exports.version = '0.3.33-beta.0';
73
+ exports.version = '0.3.33-beta.2';
@@ -10,13 +10,14 @@ const tslib_1 = require("tslib");
10
10
  const react_1 = tslib_1.__importStar(require("react"));
11
11
  const next_1 = require("@alifd/next");
12
12
  const icon_1 = tslib_1.__importDefault(require("../icon"));
13
+ const button_1 = tslib_1.__importDefault(require("../button"));
13
14
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
14
15
  const utils_1 = require("../utils");
15
16
  const SUCCESS_ICON = 'success';
16
17
  const ERROR_ICON = 'error';
17
18
  const LOADING_ICON = 'loading';
18
19
  const ToolStatus = (0, react_1.forwardRef)((props, ref) => {
19
- const { className, selected = false, status, result = '', onToolClick, extra } = props;
20
+ const { useText = '使用', name, className, selected = false, status, onToolClick, authInfo } = props;
20
21
  const handleClick = (event) => {
21
22
  event.stopPropagation();
22
23
  onToolClick === null || onToolClick === void 0 ? void 0 : onToolClick(props);
@@ -25,10 +26,15 @@ const ToolStatus = (0, react_1.forwardRef)((props, ref) => {
25
26
  return (react_1.default.createElement("div", { className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}tool-status ${statusClassName} ${status}`, className), ref: ref, onClick: (e) => {
26
27
  handleClick(e);
27
28
  } },
28
- react_1.default.createElement("div", { className: 'main-content' },
29
- react_1.default.createElement(icon_1.default, { size: 'small', type: status === 'error' ? ERROR_ICON : status === 'success' ? SUCCESS_ICON : LOADING_ICON }),
30
- react_1.default.createElement("div", { className: 'content-result' }, result)),
31
- extra && react_1.default.createElement("div", { className: 'extra-content' }, extra)));
29
+ react_1.default.createElement(icon_1.default, { size: 'small', type: status === 'failed' ? ERROR_ICON : status === 'completed' ? SUCCESS_ICON : LOADING_ICON }),
30
+ authInfo && status === 'auth' && react_1.default.createElement("div", { className: 'auth-content' },
31
+ react_1.default.createElement(button_1.default, { type: 'primary', text: true, size: 'medium', onClick: (event) => {
32
+ var _a;
33
+ event.stopPropagation();
34
+ (_a = authInfo === null || authInfo === void 0 ? void 0 : authInfo.onAuthClick) === null || _a === void 0 ? void 0 : _a.call(authInfo, props);
35
+ } }, authInfo === null || authInfo === void 0 ? void 0 : authInfo.content)),
36
+ react_1.default.createElement("div", { className: 'content-use-tips' }, useText),
37
+ react_1.default.createElement("div", { className: 'content-name' }, name)));
32
38
  });
33
39
  tslib_1.__exportStar(require("./types"), exports);
34
40
  exports.default = next_1.ConfigProvider.config(ToolStatus);
@@ -4,39 +4,52 @@
4
4
  width: fit-content;
5
5
  transition: width 0.3s ease-in-out;
6
6
  background-color: $color-fill1-1;//$color-brand1-1;
7
- padding: $s-1;
8
- border-radius: $s-2;
7
+ padding: $s-1 $s-3;
8
+ border-radius: $s-4;
9
9
  box-sizing: border-box;
10
10
  border: solid 1px $color-fill1-1;
11
11
  align-items: center;
12
+ display: flex;
13
+ i {
14
+ margin-right: $s-2;
15
+ }
12
16
 
13
17
  &.selected {
14
18
  background-color: $color-fill1-2;
15
19
  }
16
20
 
17
- &.success {
21
+ &.completed {
18
22
  i {
19
23
  color: $color-success-3;
20
24
  }
21
25
  }
22
26
 
23
- &.error {
27
+ &.failed {
24
28
  i {
25
29
  color: $color-error-3;
26
30
  }
27
31
  }
28
32
 
29
- &.loading {
33
+ &.running, &.auth, &.started {
30
34
  i {
31
35
  color: $color-brand1-6;
32
36
  }
33
37
  }
34
-
35
- .main-content {
36
- display: flex;
37
- .content-result {
38
- margin-left: 4px;
38
+
39
+ .auth-content {
40
+ margin-right: $s-1;
41
+ button {
42
+ font-size: $font-size-body-2 !important;
39
43
  }
40
44
  }
41
45
 
46
+ .content-use-tips {
47
+ color: $color-text1-2;
48
+ margin-right: $s-1;
49
+ }
50
+
51
+ .content-name {
52
+ color: $color-text1-4;
53
+ }
54
+
42
55
  }
@@ -1,5 +1,9 @@
1
1
  import React, { type ReactNode } from 'react';
2
2
  import { type CommonProps } from '@alifd/next';
3
+ export interface ToolStatusAuthProps {
4
+ content: string | ReactNode;
5
+ onAuthClick?: (data: ToolStatusProps) => void;
6
+ }
3
7
  /**
4
8
  * 参考来源属性
5
9
  */
@@ -12,7 +16,7 @@ export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, Comm
12
16
  /**
13
17
  * 工具调用状态
14
18
  */
15
- status?: 'loading' | 'success' | 'error';
19
+ status?: 'started' | 'running' | 'completed' | 'failed' | 'auth';
16
20
  /**
17
21
  * 工具调用结果
18
22
  */
@@ -22,7 +26,15 @@ export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, Comm
22
26
  */
23
27
  onToolClick?: (data: ToolStatusProps) => void;
24
28
  /**
25
- * 额外需要渲染的内容
29
+ * 额外的授权信息
30
+ */
31
+ authInfo?: ToolStatusAuthProps;
32
+ /**
33
+ * 工具名称
34
+ */
35
+ name?: string;
36
+ /**
37
+ * 工具详情链接
26
38
  */
27
- extra?: string | ReactNode;
39
+ useText?: string;
28
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.33-beta.0",
3
+ "version": "0.3.33-beta.2",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",