@alifd/chat 0.3.35 → 0.3.36
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/core/variables.scss +4 -0
- package/es/drawer/index.js +3 -3
- package/es/drawer/main.scss +8 -2
- package/es/html-render/index.js +3 -3
- package/es/html-render/main.scss +2 -2
- package/es/icon/index.d.ts +1 -1
- package/es/icon/index.js +4 -1
- package/es/image-preview/index.js +48 -8
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/reference/main.scss +5 -5
- package/es/step/main.scss +1 -1
- package/es/tool-status/index.d.ts +11 -0
- package/es/tool-status/index.js +37 -0
- package/es/tool-status/main.scss +75 -0
- package/es/tool-status/style.d.ts +2 -0
- package/es/tool-status/style.js +2 -0
- package/es/tool-status/types.d.ts +44 -0
- package/es/tool-status/types.js +1 -0
- package/lib/core/variables.scss +4 -0
- package/lib/drawer/index.js +3 -3
- package/lib/drawer/main.scss +8 -2
- package/lib/html-render/index.js +3 -3
- package/lib/html-render/main.scss +2 -2
- package/lib/icon/index.d.ts +1 -1
- package/lib/icon/index.js +4 -1
- package/lib/image-preview/index.js +47 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -2
- package/lib/reference/main.scss +5 -5
- package/lib/step/main.scss +1 -1
- package/lib/tool-status/index.d.ts +11 -0
- package/lib/tool-status/index.js +40 -0
- package/lib/tool-status/main.scss +75 -0
- package/lib/tool-status/style.d.ts +2 -0
- package/lib/tool-status/style.js +4 -0
- package/lib/tool-status/types.d.ts +44 -0
- package/lib/tool-status/types.js +2 -0
- package/package.json +13 -1
package/es/core/variables.scss
CHANGED
|
@@ -95,3 +95,7 @@ $color-data1-10: var(--color-data1-10, #6f9200) !default; // ?
|
|
|
95
95
|
|
|
96
96
|
$color-bg-1: var(--color-bg-1, #ffffff) !default; // ?
|
|
97
97
|
|
|
98
|
+
|
|
99
|
+
$color-error-3: var(--color-error-3, rgb(255, 82, 25)) !default;
|
|
100
|
+
|
|
101
|
+
$color-success-3: var(--color-success-3, #00b042) !default;
|
package/es/drawer/index.js
CHANGED
|
@@ -11,13 +11,13 @@ import { Drawer as NextDrawer, ConfigProvider } from '@alifd/next';
|
|
|
11
11
|
import cs from 'classnames';
|
|
12
12
|
import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
|
|
13
13
|
const Drawer = forwardRef((_a, ref) => {
|
|
14
|
-
var { className, headerStyle, children, footer, footerClassName } = _a, props = __rest(_a, ["className", "headerStyle", "children", "footer", "footerClassName"]);
|
|
14
|
+
var { className, headerStyle, children, footer, footerClassName, placement } = _a, props = __rest(_a, ["className", "headerStyle", "children", "footer", "footerClassName", "placement"]);
|
|
15
15
|
// 对齐小蜜现有的底部
|
|
16
16
|
const defaultHeaderStyle = {
|
|
17
17
|
"border-bottom:": "1px solid var(--40gmM)"
|
|
18
18
|
};
|
|
19
|
-
return (React.createElement(NextDrawer, Object.assign({}, props, { v2: true, ref: ref, headerStyle: Object.assign(Object.assign({}, defaultHeaderStyle), headerStyle), className: cs(`${PREFIX_DEFAULT}drawer`, className) }),
|
|
20
|
-
|
|
19
|
+
return (React.createElement(NextDrawer, Object.assign({}, props, { v2: true, ref: ref, placement: placement, headerStyle: Object.assign(Object.assign({}, defaultHeaderStyle), headerStyle), className: cs(`${PREFIX_DEFAULT}drawer ${placement}`, className) }),
|
|
20
|
+
children,
|
|
21
21
|
footer && footer.length && React.createElement("div", { className: cs('draw-footer', footerClassName) }, footer)));
|
|
22
22
|
});
|
|
23
23
|
const DrawerWithSub = assignSubComponent(Drawer, {
|
package/es/drawer/main.scss
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
.#{$prefix}drawer {
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
&.bottom {
|
|
6
|
+
border-top-left-radius: 16px;
|
|
7
|
+
border-top-right-radius: 16px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&.right {
|
|
11
|
+
border-top-right-radius: 8px;
|
|
12
|
+
}
|
|
7
13
|
|
|
8
14
|
.draw-footer {
|
|
9
15
|
width: calc(100% - 40px);
|
package/es/html-render/index.js
CHANGED
|
@@ -103,7 +103,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
|
|
|
103
103
|
const parserOptions = {
|
|
104
104
|
// @ts-ignore
|
|
105
105
|
replace: domNode => {
|
|
106
|
-
var _a, _b, _c, _d, _e, _f;
|
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
107
107
|
// 处理文本节点
|
|
108
108
|
if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
|
|
109
109
|
return processTextNode(domNode);
|
|
@@ -131,7 +131,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
|
|
|
131
131
|
return (React.createElement(Balloon, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['hover'], trigger: React.createElement("span", { className: "link-reference-index", onClick: handleUrlClick }, (_c = spanElement === null || spanElement === void 0 ? void 0 : spanElement.props) === null || _c === void 0 ? void 0 : _c.children) },
|
|
132
132
|
React.createElement("div", { className: "link-reference-content" },
|
|
133
133
|
React.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
|
|
134
|
-
React.createElement("a", { className: "link-reference-title", onClick: handleUrlClick
|
|
134
|
+
React.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
|
|
135
135
|
}
|
|
136
136
|
if (name === 'a') {
|
|
137
137
|
const element = (domToReact([domNode]));
|
|
@@ -185,7 +185,7 @@ const HTMLRenderer = memo(function HTMLRenderer({ className, children, imagePrev
|
|
|
185
185
|
return renderImage(element.props);
|
|
186
186
|
}
|
|
187
187
|
// 换成统一的图片渲染
|
|
188
|
-
return React.createElement(Img, Object.assign({}, element.props, { imageClassName: (
|
|
188
|
+
return React.createElement(Img, Object.assign({}, element.props, { imageClassName: (_g = element.props) === null || _g === void 0 ? void 0 : _g.className, enablePreview: imagePreview, onImageClick: () => {
|
|
189
189
|
handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
|
|
190
190
|
} }));
|
|
191
191
|
}
|
package/es/html-render/main.scss
CHANGED
|
@@ -178,14 +178,14 @@
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
a {
|
|
181
|
-
color: $color-link-
|
|
181
|
+
color: $color-link-1;
|
|
182
182
|
text-decoration: none;
|
|
183
183
|
&:hover {
|
|
184
184
|
color: $color-link-2;
|
|
185
185
|
text-decoration: none;
|
|
186
186
|
}
|
|
187
187
|
&:focus, &:visited {
|
|
188
|
-
color: $color-link-
|
|
188
|
+
color: $color-link-3;
|
|
189
189
|
text-decoration: none;
|
|
190
190
|
}
|
|
191
191
|
}
|
package/es/icon/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ import type { IconProps } from '@alifd/next/types/icon';
|
|
|
10
10
|
export * from './types';
|
|
11
11
|
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<IconProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<IconProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/icon/icon").default>>, keyof IconProps | "key"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<IconProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/icon/icon").default>, {}>;
|
|
12
12
|
export default _default;
|
|
13
|
-
export declare function renderCommonIcon(icon: any, size?: number | 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit'): React.JSX.Element;
|
|
13
|
+
export declare function renderCommonIcon(icon: any, size?: number | 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit'): React.JSX.Element | null;
|
package/es/icon/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
|
|
|
14
14
|
const CustomIcon = NextIcon.createFromIconfontCN({
|
|
15
15
|
scriptUrl: '//at.alicdn.com/t/c/font_3504203_7pbik9jgwl8.js',
|
|
16
16
|
});
|
|
17
|
-
const CustomIconList = ['icon-xiangxiaxianxing', 'icon-xiangxiaxianxing-copy', 'icon-cross', 'icon-fuzhi2'];
|
|
17
|
+
const CustomIconList = ['icon-check', 'icon-xiangxiaxianxing', 'icon-xiangxiaxianxing-copy', 'icon-cross', 'icon-cross1', 'icon-fuzhi2'];
|
|
18
18
|
const TypeMap = {
|
|
19
19
|
'arrow-up': 'icon-xiangxiaxianxing-copy',
|
|
20
20
|
'arrow-down': 'icon-xiangxiaxianxing',
|
|
@@ -41,6 +41,9 @@ export default ConfigProvider.config(IconWithSub);
|
|
|
41
41
|
export function renderCommonIcon(icon, size) {
|
|
42
42
|
let dom = null;
|
|
43
43
|
let iconType = '';
|
|
44
|
+
if (!icon) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
44
47
|
if (React.isValidElement(icon)) {
|
|
45
48
|
dom = icon;
|
|
46
49
|
iconType = 'node';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @when 需要展示图片并提供预览功能时使用。 - Use when you need to display images and provide preview functionality.
|
|
7
7
|
|
|
8
8
|
*/
|
|
9
|
-
import React, { forwardRef } from 'react';
|
|
9
|
+
import React, { forwardRef, useRef } from 'react';
|
|
10
10
|
import classnames from 'classnames';
|
|
11
11
|
import { PhotoProvider, PhotoView } from 'react-photo-view';
|
|
12
12
|
import { findAncestor } from '../utils';
|
|
@@ -34,26 +34,66 @@ function isInsideLink(e) {
|
|
|
34
34
|
return !!findAncestor(e.target, (t) => t.tagName === 'A' && !!t.href);
|
|
35
35
|
}
|
|
36
36
|
const ImagePreview = forwardRef(({ className, src, children, width, height }, ref) => {
|
|
37
|
+
const touchStartRef = useRef({ x: 0, y: 0, time: 0 });
|
|
38
|
+
const hasMoved = useRef(false);
|
|
37
39
|
let child;
|
|
38
40
|
try {
|
|
39
41
|
child = React.Children.only(children);
|
|
40
42
|
}
|
|
41
43
|
catch (e) { }
|
|
44
|
+
const handleTouchStart = (e) => {
|
|
45
|
+
const touch = e.touches[0];
|
|
46
|
+
touchStartRef.current = {
|
|
47
|
+
x: touch.clientX,
|
|
48
|
+
y: touch.clientY,
|
|
49
|
+
time: Date.now()
|
|
50
|
+
};
|
|
51
|
+
hasMoved.current = false;
|
|
52
|
+
};
|
|
53
|
+
const handleTouchMove = (e) => {
|
|
54
|
+
if (!touchStartRef.current)
|
|
55
|
+
return;
|
|
56
|
+
const touch = e.touches[0];
|
|
57
|
+
const deltaX = Math.abs(touch.clientX - touchStartRef.current.x);
|
|
58
|
+
const deltaY = Math.abs(touch.clientY - touchStartRef.current.y);
|
|
59
|
+
// 如果移动距离超过阈值,认为是滚动操作
|
|
60
|
+
if (deltaX > 10 || deltaY > 10) {
|
|
61
|
+
hasMoved.current = true;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const handleTouchEnd = (e, originalHandler) => {
|
|
65
|
+
// 如果检测到滚动,就不触发图片预览
|
|
66
|
+
if (!hasMoved.current) {
|
|
67
|
+
if (isInsideLink(e)) {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
handleClick(e, src);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
originalHandler === null || originalHandler === void 0 ? void 0 : originalHandler(e);
|
|
75
|
+
};
|
|
42
76
|
if (child && child.props) {
|
|
43
|
-
const { onClick, onTouchEnd } = child.props;
|
|
77
|
+
const { onClick, onTouchEnd, onTouchStart, onTouchMove } = child.props;
|
|
44
78
|
child = React.cloneElement(child, {
|
|
79
|
+
onTouchStart: (e) => {
|
|
80
|
+
handleTouchStart(e);
|
|
81
|
+
onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e);
|
|
82
|
+
},
|
|
83
|
+
onTouchMove: (e) => {
|
|
84
|
+
handleTouchMove(e);
|
|
85
|
+
onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(e);
|
|
86
|
+
},
|
|
45
87
|
onTouchEnd: (e) => {
|
|
46
|
-
|
|
47
|
-
e.stopPropagation();
|
|
48
|
-
}
|
|
49
|
-
handleClick(e, src);
|
|
50
|
-
onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
|
|
88
|
+
handleTouchEnd(e, onTouchEnd);
|
|
51
89
|
},
|
|
52
90
|
onClick: (e) => {
|
|
53
91
|
if (isInsideLink(e)) {
|
|
54
92
|
e.stopPropagation();
|
|
55
93
|
}
|
|
56
|
-
|
|
94
|
+
else {
|
|
95
|
+
handleClick(e, src);
|
|
96
|
+
}
|
|
57
97
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
58
98
|
}
|
|
59
99
|
});
|
package/es/index.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export { default as RadioGroup } from './radio-group';
|
|
|
31
31
|
export { default as CheckboxGroup } from './checkbox-group';
|
|
32
32
|
export { default as Select } from './select';
|
|
33
33
|
export { default as Flip } from './flip';
|
|
34
|
+
export { default as ToolStatus } from './tool-status';
|
|
34
35
|
export declare const version: string;
|
package/es/index.js
CHANGED
|
@@ -31,4 +31,5 @@ export { default as RadioGroup } from './radio-group';
|
|
|
31
31
|
export { default as CheckboxGroup } from './checkbox-group';
|
|
32
32
|
export { default as Select } from './select';
|
|
33
33
|
export { default as Flip } from './flip';
|
|
34
|
-
export
|
|
34
|
+
export { default as ToolStatus } from './tool-status';
|
|
35
|
+
export const version = '0.3.36';
|
package/es/reference/main.scss
CHANGED
|
@@ -15,7 +15,7 @@ $detail-header-height: $s-12;
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&.detail {
|
|
18
|
-
background-color: $color-fill1-1;
|
|
18
|
+
// background-color: $color-fill1-1;
|
|
19
19
|
padding: 0px;
|
|
20
20
|
height: 100%;
|
|
21
21
|
overflow: hidden;
|
|
@@ -111,7 +111,7 @@ $detail-header-height: $s-12;
|
|
|
111
111
|
.reference-name {
|
|
112
112
|
// margin-bottom: $s-2;
|
|
113
113
|
line-height: $font-lineheight-2;
|
|
114
|
-
color: $color-link-
|
|
114
|
+
color: $color-link-1;
|
|
115
115
|
font-size: $font-size-body-2;
|
|
116
116
|
overflow: hidden; /* 隐藏超出部分 */
|
|
117
117
|
display: -webkit-box; /* 使其成为弹性盒子 */
|
|
@@ -126,7 +126,7 @@ $detail-header-height: $s-12;
|
|
|
126
126
|
color: $color-link-2;
|
|
127
127
|
}
|
|
128
128
|
&:focus, &:visited {
|
|
129
|
-
color: $color-link-
|
|
129
|
+
color: $color-link-3;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -185,7 +185,7 @@ $detail-header-height: $s-12;
|
|
|
185
185
|
|
|
186
186
|
.reference-text {
|
|
187
187
|
font-size: $font-size-caption;
|
|
188
|
-
color: $color-link-
|
|
188
|
+
color: $color-link-1;
|
|
189
189
|
white-space: nowrap; /* 禁止换行 */
|
|
190
190
|
overflow: hidden; /* 超出部分隐藏 */
|
|
191
191
|
text-overflow: ellipsis; /* 以省略号显示溢出文本 */
|
|
@@ -195,7 +195,7 @@ $detail-header-height: $s-12;
|
|
|
195
195
|
color: $color-link-2;
|
|
196
196
|
}
|
|
197
197
|
&:visited, &:focus {
|
|
198
|
-
color: $color-link-
|
|
198
|
+
color: $color-link-3;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
package/es/step/main.scss
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component ToolStatus
|
|
3
|
+
* @en ToolStatus
|
|
4
|
+
* @type 通用 - ToolStatus
|
|
5
|
+
* @when ToolStatus
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ToolStatusProps } from './types';
|
|
9
|
+
export * from './types';
|
|
10
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<ToolStatusProps & React.RefAttributes<HTMLDivElement>, "key" | keyof ToolStatusProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, HTMLDivElement, {}>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component ToolStatus
|
|
3
|
+
* @en ToolStatus
|
|
4
|
+
* @type 通用 - ToolStatus
|
|
5
|
+
* @when ToolStatus
|
|
6
|
+
*/
|
|
7
|
+
import React, { forwardRef } from 'react';
|
|
8
|
+
import { ConfigProvider } from '@alifd/next';
|
|
9
|
+
import Icon from '../icon';
|
|
10
|
+
import cs from 'classnames';
|
|
11
|
+
import { PREFIX_DEFAULT } from '../utils';
|
|
12
|
+
const SUCCESS_ICON = 'icon-check'; //'success'
|
|
13
|
+
const ERROR_ICON = 'icon-cross1'; //'error'
|
|
14
|
+
const LOADING_ICON = 'loading';
|
|
15
|
+
const ToolStatus = forwardRef((props, ref) => {
|
|
16
|
+
const { useText = '使用', name, className, selected = false, status, onToolClick, authInfo, fullWidth } = props;
|
|
17
|
+
const handleClick = (event) => {
|
|
18
|
+
event.stopPropagation();
|
|
19
|
+
onToolClick === null || onToolClick === void 0 ? void 0 : onToolClick(props);
|
|
20
|
+
};
|
|
21
|
+
let csName = selected ? 'selected' : '';
|
|
22
|
+
csName = fullWidth ? `${csName} full-width` : `${csName}`;
|
|
23
|
+
csName = onToolClick ? `${csName} enable-click` : `${csName}`;
|
|
24
|
+
return (React.createElement("div", { className: cs(`${PREFIX_DEFAULT}tool-status ${csName} ${status}`, className), ref: ref, onClick: (e) => {
|
|
25
|
+
handleClick(e);
|
|
26
|
+
} },
|
|
27
|
+
React.createElement(Icon, { size: 'xs', type: status === 'failed' ? ERROR_ICON : status === 'completed' ? SUCCESS_ICON : LOADING_ICON }),
|
|
28
|
+
authInfo && status === 'auth' && React.createElement("div", { className: 'next-btn-text next-btn-primary', 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)));
|
|
35
|
+
});
|
|
36
|
+
export * from './types';
|
|
37
|
+
export default ConfigProvider.config(ToolStatus);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import "../core/variables.scss";
|
|
2
|
+
|
|
3
|
+
.#{$prefix}tool-status {
|
|
4
|
+
width: fit-content;
|
|
5
|
+
transition: width 0.3s ease-in-out;
|
|
6
|
+
padding: $s-1 $s-3;
|
|
7
|
+
border-radius: $s-4;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
border: solid 1px $color-line1-2;
|
|
10
|
+
align-items: center;
|
|
11
|
+
display: flex;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
font-size: $font-size-caption;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
|
|
16
|
+
i {
|
|
17
|
+
margin-right: $s-1;
|
|
18
|
+
}
|
|
19
|
+
.next-icon.next-small:before {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.full-width {
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
&.enable-click {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.selected {
|
|
31
|
+
background-color: $color-fill1-2;
|
|
32
|
+
border: solid 1px transparent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.completed {
|
|
36
|
+
i {
|
|
37
|
+
color: $color-success-3;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.failed {
|
|
42
|
+
i {
|
|
43
|
+
color: $color-error-3;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.running, &.auth, &.started {
|
|
48
|
+
i {
|
|
49
|
+
color: $color-brand1-6;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.next-btn-text.next-btn-primary{
|
|
54
|
+
line-height: $s-4;
|
|
55
|
+
font-size: $font-size-caption;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
margin-right: $s-1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.content-use-tips {
|
|
61
|
+
color: $color-text1-3;
|
|
62
|
+
margin-right: $s-1;
|
|
63
|
+
line-height: $s-4;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.content-name {
|
|
67
|
+
color: $color-text1-4;
|
|
68
|
+
line-height: $s-4;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
flex: 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type CommonProps } from '@alifd/next';
|
|
3
|
+
export interface ToolStatusAuthProps {
|
|
4
|
+
content: string | ReactNode;
|
|
5
|
+
onAuthClick?: (data: ToolStatusProps) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 参考来源属性
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, CommonProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 是否被选中
|
|
14
|
+
*/
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 工具调用状态
|
|
18
|
+
*/
|
|
19
|
+
status?: 'started' | 'running' | 'completed' | 'failed' | 'auth';
|
|
20
|
+
/**
|
|
21
|
+
* 工具调用结果
|
|
22
|
+
*/
|
|
23
|
+
result?: string | ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* 工具点击
|
|
26
|
+
*/
|
|
27
|
+
onToolClick?: (data: ToolStatusProps) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 额外的授权信息
|
|
30
|
+
*/
|
|
31
|
+
authInfo?: ToolStatusAuthProps;
|
|
32
|
+
/**
|
|
33
|
+
* 工具名称
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 工具详情链接
|
|
38
|
+
*/
|
|
39
|
+
useText?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 是否100%的宽度
|
|
42
|
+
*/
|
|
43
|
+
fullWidth?: boolean;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/core/variables.scss
CHANGED
|
@@ -95,3 +95,7 @@ $color-data1-10: var(--color-data1-10, #6f9200) !default; // ?
|
|
|
95
95
|
|
|
96
96
|
$color-bg-1: var(--color-bg-1, #ffffff) !default; // ?
|
|
97
97
|
|
|
98
|
+
|
|
99
|
+
$color-error-3: var(--color-error-3, rgb(255, 82, 25)) !default;
|
|
100
|
+
|
|
101
|
+
$color-success-3: var(--color-success-3, #00b042) !default;
|
package/lib/drawer/index.js
CHANGED
|
@@ -13,13 +13,13 @@ const next_1 = require("@alifd/next");
|
|
|
13
13
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
14
|
const utils_1 = require("../utils");
|
|
15
15
|
const Drawer = (0, react_1.forwardRef)((_a, ref) => {
|
|
16
|
-
var { className, headerStyle, children, footer, footerClassName } = _a, props = tslib_1.__rest(_a, ["className", "headerStyle", "children", "footer", "footerClassName"]);
|
|
16
|
+
var { className, headerStyle, children, footer, footerClassName, placement } = _a, props = tslib_1.__rest(_a, ["className", "headerStyle", "children", "footer", "footerClassName", "placement"]);
|
|
17
17
|
// 对齐小蜜现有的底部
|
|
18
18
|
const defaultHeaderStyle = {
|
|
19
19
|
"border-bottom:": "1px solid var(--40gmM)"
|
|
20
20
|
};
|
|
21
|
-
return (react_1.default.createElement(next_1.Drawer, Object.assign({}, props, { v2: true, ref: ref, headerStyle: Object.assign(Object.assign({}, defaultHeaderStyle), headerStyle), className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}drawer`, className) }),
|
|
22
|
-
|
|
21
|
+
return (react_1.default.createElement(next_1.Drawer, Object.assign({}, props, { v2: true, ref: ref, placement: placement, headerStyle: Object.assign(Object.assign({}, defaultHeaderStyle), headerStyle), className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}drawer ${placement}`, className) }),
|
|
22
|
+
children,
|
|
23
23
|
footer && footer.length && react_1.default.createElement("div", { className: (0, classnames_1.default)('draw-footer', footerClassName) }, footer)));
|
|
24
24
|
});
|
|
25
25
|
const DrawerWithSub = (0, utils_1.assignSubComponent)(Drawer, {
|
package/lib/drawer/main.scss
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
.#{$prefix}drawer {
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
&.bottom {
|
|
6
|
+
border-top-left-radius: 16px;
|
|
7
|
+
border-top-right-radius: 16px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&.right {
|
|
11
|
+
border-top-right-radius: 8px;
|
|
12
|
+
}
|
|
7
13
|
|
|
8
14
|
.draw-footer {
|
|
9
15
|
width: calc(100% - 40px);
|
package/lib/html-render/index.js
CHANGED
|
@@ -106,7 +106,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
|
|
|
106
106
|
const parserOptions = {
|
|
107
107
|
// @ts-ignore
|
|
108
108
|
replace: domNode => {
|
|
109
|
-
var _a, _b, _c, _d, _e, _f;
|
|
109
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
110
110
|
// 处理文本节点
|
|
111
111
|
if ((domNode.type === 'text' || domNode.nodeType === 3) && typewriterEffect) {
|
|
112
112
|
return processTextNode(domNode);
|
|
@@ -134,7 +134,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
|
|
|
134
134
|
return (react_1.default.createElement(balloon_1.default, { v2: true, align: "b", className: "link-reference-balloon", closable: false, offset: [0, -8], triggerType: ['hover'], trigger: react_1.default.createElement("span", { className: "link-reference-index", onClick: handleUrlClick }, (_c = spanElement === null || spanElement === void 0 ? void 0 : spanElement.props) === null || _c === void 0 ? void 0 : _c.children) },
|
|
135
135
|
react_1.default.createElement("div", { className: "link-reference-content" },
|
|
136
136
|
react_1.default.createElement("img", { className: "link-reference-source-icon", src: ((_d = element.props) === null || _d === void 0 ? void 0 : _d['data-source-icon']) || '' }),
|
|
137
|
-
react_1.default.createElement("a", { className: "link-reference-title", onClick: handleUrlClick
|
|
137
|
+
react_1.default.createElement("a", { className: "link-reference-title", onClick: handleUrlClick, title: ((_e = element.props) === null || _e === void 0 ? void 0 : _e['data-title']) || '' }, ((_f = element.props) === null || _f === void 0 ? void 0 : _f['data-title']) || ''))));
|
|
138
138
|
}
|
|
139
139
|
if (name === 'a') {
|
|
140
140
|
const element = ((0, html_react_parser_1.domToReact)([domNode]));
|
|
@@ -188,7 +188,7 @@ const HTMLRenderer = (0, react_1.memo)(function HTMLRenderer({ className, childr
|
|
|
188
188
|
return renderImage(element.props);
|
|
189
189
|
}
|
|
190
190
|
// 换成统一的图片渲染
|
|
191
|
-
return react_1.default.createElement(img_1.default, Object.assign({}, element.props, { imageClassName: (
|
|
191
|
+
return react_1.default.createElement(img_1.default, Object.assign({}, element.props, { imageClassName: (_g = element.props) === null || _g === void 0 ? void 0 : _g.className, enablePreview: imagePreview, onImageClick: () => {
|
|
192
192
|
handleImageClick === null || handleImageClick === void 0 ? void 0 : handleImageClick(element.props.src);
|
|
193
193
|
} }));
|
|
194
194
|
}
|
|
@@ -178,14 +178,14 @@
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
a {
|
|
181
|
-
color: $color-link-
|
|
181
|
+
color: $color-link-1;
|
|
182
182
|
text-decoration: none;
|
|
183
183
|
&:hover {
|
|
184
184
|
color: $color-link-2;
|
|
185
185
|
text-decoration: none;
|
|
186
186
|
}
|
|
187
187
|
&:focus, &:visited {
|
|
188
|
-
color: $color-link-
|
|
188
|
+
color: $color-link-3;
|
|
189
189
|
text-decoration: none;
|
|
190
190
|
}
|
|
191
191
|
}
|
package/lib/icon/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ import type { IconProps } from '@alifd/next/types/icon';
|
|
|
10
10
|
export * from './types';
|
|
11
11
|
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<IconProps & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<IconProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/icon/icon").default>>, keyof IconProps | "key"> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<IconProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/icon/icon").default>, {}>;
|
|
12
12
|
export default _default;
|
|
13
|
-
export declare function renderCommonIcon(icon: any, size?: number | 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit'): React.JSX.Element;
|
|
13
|
+
export declare function renderCommonIcon(icon: any, size?: number | 'xxs' | 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'inherit'): React.JSX.Element | null;
|
package/lib/icon/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const utils_1 = require("../utils");
|
|
|
17
17
|
const CustomIcon = next_1.Icon.createFromIconfontCN({
|
|
18
18
|
scriptUrl: '//at.alicdn.com/t/c/font_3504203_7pbik9jgwl8.js',
|
|
19
19
|
});
|
|
20
|
-
const CustomIconList = ['icon-xiangxiaxianxing', 'icon-xiangxiaxianxing-copy', 'icon-cross', 'icon-fuzhi2'];
|
|
20
|
+
const CustomIconList = ['icon-check', 'icon-xiangxiaxianxing', 'icon-xiangxiaxianxing-copy', 'icon-cross', 'icon-cross1', 'icon-fuzhi2'];
|
|
21
21
|
const TypeMap = {
|
|
22
22
|
'arrow-up': 'icon-xiangxiaxianxing-copy',
|
|
23
23
|
'arrow-down': 'icon-xiangxiaxianxing',
|
|
@@ -44,6 +44,9 @@ exports.default = next_1.ConfigProvider.config(IconWithSub);
|
|
|
44
44
|
function renderCommonIcon(icon, size) {
|
|
45
45
|
let dom = null;
|
|
46
46
|
let iconType = '';
|
|
47
|
+
if (!icon) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
47
50
|
if (react_1.default.isValidElement(icon)) {
|
|
48
51
|
dom = icon;
|
|
49
52
|
iconType = 'node';
|
|
@@ -37,26 +37,66 @@ function isInsideLink(e) {
|
|
|
37
37
|
return !!(0, utils_1.findAncestor)(e.target, (t) => t.tagName === 'A' && !!t.href);
|
|
38
38
|
}
|
|
39
39
|
const ImagePreview = (0, react_1.forwardRef)(({ className, src, children, width, height }, ref) => {
|
|
40
|
+
const touchStartRef = (0, react_1.useRef)({ x: 0, y: 0, time: 0 });
|
|
41
|
+
const hasMoved = (0, react_1.useRef)(false);
|
|
40
42
|
let child;
|
|
41
43
|
try {
|
|
42
44
|
child = react_1.default.Children.only(children);
|
|
43
45
|
}
|
|
44
46
|
catch (e) { }
|
|
47
|
+
const handleTouchStart = (e) => {
|
|
48
|
+
const touch = e.touches[0];
|
|
49
|
+
touchStartRef.current = {
|
|
50
|
+
x: touch.clientX,
|
|
51
|
+
y: touch.clientY,
|
|
52
|
+
time: Date.now()
|
|
53
|
+
};
|
|
54
|
+
hasMoved.current = false;
|
|
55
|
+
};
|
|
56
|
+
const handleTouchMove = (e) => {
|
|
57
|
+
if (!touchStartRef.current)
|
|
58
|
+
return;
|
|
59
|
+
const touch = e.touches[0];
|
|
60
|
+
const deltaX = Math.abs(touch.clientX - touchStartRef.current.x);
|
|
61
|
+
const deltaY = Math.abs(touch.clientY - touchStartRef.current.y);
|
|
62
|
+
// 如果移动距离超过阈值,认为是滚动操作
|
|
63
|
+
if (deltaX > 10 || deltaY > 10) {
|
|
64
|
+
hasMoved.current = true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleTouchEnd = (e, originalHandler) => {
|
|
68
|
+
// 如果检测到滚动,就不触发图片预览
|
|
69
|
+
if (!hasMoved.current) {
|
|
70
|
+
if (isInsideLink(e)) {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
handleClick(e, src);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
originalHandler === null || originalHandler === void 0 ? void 0 : originalHandler(e);
|
|
78
|
+
};
|
|
45
79
|
if (child && child.props) {
|
|
46
|
-
const { onClick, onTouchEnd } = child.props;
|
|
80
|
+
const { onClick, onTouchEnd, onTouchStart, onTouchMove } = child.props;
|
|
47
81
|
child = react_1.default.cloneElement(child, {
|
|
82
|
+
onTouchStart: (e) => {
|
|
83
|
+
handleTouchStart(e);
|
|
84
|
+
onTouchStart === null || onTouchStart === void 0 ? void 0 : onTouchStart(e);
|
|
85
|
+
},
|
|
86
|
+
onTouchMove: (e) => {
|
|
87
|
+
handleTouchMove(e);
|
|
88
|
+
onTouchMove === null || onTouchMove === void 0 ? void 0 : onTouchMove(e);
|
|
89
|
+
},
|
|
48
90
|
onTouchEnd: (e) => {
|
|
49
|
-
|
|
50
|
-
e.stopPropagation();
|
|
51
|
-
}
|
|
52
|
-
handleClick(e, src);
|
|
53
|
-
onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
|
|
91
|
+
handleTouchEnd(e, onTouchEnd);
|
|
54
92
|
},
|
|
55
93
|
onClick: (e) => {
|
|
56
94
|
if (isInsideLink(e)) {
|
|
57
95
|
e.stopPropagation();
|
|
58
96
|
}
|
|
59
|
-
|
|
97
|
+
else {
|
|
98
|
+
handleClick(e, src);
|
|
99
|
+
}
|
|
60
100
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
61
101
|
}
|
|
62
102
|
});
|
package/lib/index.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export { default as RadioGroup } from './radio-group';
|
|
|
31
31
|
export { default as CheckboxGroup } from './checkbox-group';
|
|
32
32
|
export { default as Select } from './select';
|
|
33
33
|
export { default as Flip } from './flip';
|
|
34
|
+
export { default as ToolStatus } from './tool-status';
|
|
34
35
|
export declare const version: string;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.version = exports.Flip = exports.Select = exports.CheckboxGroup = exports.RadioGroup = exports.Img = exports.AILoading = exports.RichTextInput = exports.Recommend = exports.Reference = exports.StopGenerate = exports.Step = exports.Drawer = exports.Loading = exports.Origin = exports.CardLoading = exports.Markdown = exports.HtmlRender = exports.ImagePreview = exports.List = exports.Balloon = exports.Icon = exports.Message = exports.PersonPicker = exports.TimePicker = exports.DatePicker = exports.Input = exports.Tab = exports.Tag = exports.Text = exports.FloatButton = exports.Feedback = exports.Card = exports.Button = void 0;
|
|
3
|
+
exports.version = exports.ToolStatus = exports.Flip = exports.Select = exports.CheckboxGroup = exports.RadioGroup = exports.Img = exports.AILoading = exports.RichTextInput = exports.Recommend = exports.Reference = exports.StopGenerate = exports.Step = exports.Drawer = exports.Loading = exports.Origin = exports.CardLoading = exports.Markdown = exports.HtmlRender = exports.ImagePreview = exports.List = exports.Balloon = exports.Icon = exports.Message = exports.PersonPicker = exports.TimePicker = exports.DatePicker = exports.Input = exports.Tab = exports.Tag = exports.Text = exports.FloatButton = exports.Feedback = exports.Card = exports.Button = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var button_1 = require("./button");
|
|
6
6
|
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return tslib_1.__importDefault(button_1).default; } });
|
|
@@ -68,4 +68,6 @@ var select_1 = require("./select");
|
|
|
68
68
|
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return tslib_1.__importDefault(select_1).default; } });
|
|
69
69
|
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
|
+
Object.defineProperty(exports, "ToolStatus", { enumerable: true, get: function () { return tslib_1.__importDefault(tool_status_1).default; } });
|
|
73
|
+
exports.version = '0.3.36';
|
package/lib/reference/main.scss
CHANGED
|
@@ -15,7 +15,7 @@ $detail-header-height: $s-12;
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&.detail {
|
|
18
|
-
background-color: $color-fill1-1;
|
|
18
|
+
// background-color: $color-fill1-1;
|
|
19
19
|
padding: 0px;
|
|
20
20
|
height: 100%;
|
|
21
21
|
overflow: hidden;
|
|
@@ -111,7 +111,7 @@ $detail-header-height: $s-12;
|
|
|
111
111
|
.reference-name {
|
|
112
112
|
// margin-bottom: $s-2;
|
|
113
113
|
line-height: $font-lineheight-2;
|
|
114
|
-
color: $color-link-
|
|
114
|
+
color: $color-link-1;
|
|
115
115
|
font-size: $font-size-body-2;
|
|
116
116
|
overflow: hidden; /* 隐藏超出部分 */
|
|
117
117
|
display: -webkit-box; /* 使其成为弹性盒子 */
|
|
@@ -126,7 +126,7 @@ $detail-header-height: $s-12;
|
|
|
126
126
|
color: $color-link-2;
|
|
127
127
|
}
|
|
128
128
|
&:focus, &:visited {
|
|
129
|
-
color: $color-link-
|
|
129
|
+
color: $color-link-3;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -185,7 +185,7 @@ $detail-header-height: $s-12;
|
|
|
185
185
|
|
|
186
186
|
.reference-text {
|
|
187
187
|
font-size: $font-size-caption;
|
|
188
|
-
color: $color-link-
|
|
188
|
+
color: $color-link-1;
|
|
189
189
|
white-space: nowrap; /* 禁止换行 */
|
|
190
190
|
overflow: hidden; /* 超出部分隐藏 */
|
|
191
191
|
text-overflow: ellipsis; /* 以省略号显示溢出文本 */
|
|
@@ -195,7 +195,7 @@ $detail-header-height: $s-12;
|
|
|
195
195
|
color: $color-link-2;
|
|
196
196
|
}
|
|
197
197
|
&:visited, &:focus {
|
|
198
|
-
color: $color-link-
|
|
198
|
+
color: $color-link-3;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
package/lib/step/main.scss
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component ToolStatus
|
|
3
|
+
* @en ToolStatus
|
|
4
|
+
* @type 通用 - ToolStatus
|
|
5
|
+
* @when ToolStatus
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ToolStatusProps } from './types';
|
|
9
|
+
export * from './types';
|
|
10
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<ToolStatusProps & React.RefAttributes<HTMLDivElement>, "key" | keyof ToolStatusProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, HTMLDivElement, {}>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @component ToolStatus
|
|
4
|
+
* @en ToolStatus
|
|
5
|
+
* @type 通用 - ToolStatus
|
|
6
|
+
* @when ToolStatus
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
11
|
+
const next_1 = require("@alifd/next");
|
|
12
|
+
const icon_1 = tslib_1.__importDefault(require("../icon"));
|
|
13
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
14
|
+
const utils_1 = require("../utils");
|
|
15
|
+
const SUCCESS_ICON = 'icon-check'; //'success'
|
|
16
|
+
const ERROR_ICON = 'icon-cross1'; //'error'
|
|
17
|
+
const LOADING_ICON = 'loading';
|
|
18
|
+
const ToolStatus = (0, react_1.forwardRef)((props, ref) => {
|
|
19
|
+
const { useText = '使用', name, className, selected = false, status, onToolClick, authInfo, fullWidth } = props;
|
|
20
|
+
const handleClick = (event) => {
|
|
21
|
+
event.stopPropagation();
|
|
22
|
+
onToolClick === null || onToolClick === void 0 ? void 0 : onToolClick(props);
|
|
23
|
+
};
|
|
24
|
+
let csName = selected ? 'selected' : '';
|
|
25
|
+
csName = fullWidth ? `${csName} full-width` : `${csName}`;
|
|
26
|
+
csName = onToolClick ? `${csName} enable-click` : `${csName}`;
|
|
27
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}tool-status ${csName} ${status}`, className), ref: ref, onClick: (e) => {
|
|
28
|
+
handleClick(e);
|
|
29
|
+
} },
|
|
30
|
+
react_1.default.createElement(icon_1.default, { size: 'xs', type: status === 'failed' ? ERROR_ICON : status === 'completed' ? SUCCESS_ICON : LOADING_ICON }),
|
|
31
|
+
authInfo && status === 'auth' && react_1.default.createElement("div", { className: 'next-btn-text next-btn-primary', 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)));
|
|
38
|
+
});
|
|
39
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
40
|
+
exports.default = next_1.ConfigProvider.config(ToolStatus);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import "../core/variables.scss";
|
|
2
|
+
|
|
3
|
+
.#{$prefix}tool-status {
|
|
4
|
+
width: fit-content;
|
|
5
|
+
transition: width 0.3s ease-in-out;
|
|
6
|
+
padding: $s-1 $s-3;
|
|
7
|
+
border-radius: $s-4;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
border: solid 1px $color-line1-2;
|
|
10
|
+
align-items: center;
|
|
11
|
+
display: flex;
|
|
12
|
+
background-color: transparent;
|
|
13
|
+
font-size: $font-size-caption;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
|
|
16
|
+
i {
|
|
17
|
+
margin-right: $s-1;
|
|
18
|
+
}
|
|
19
|
+
.next-icon.next-small:before {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.full-width {
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
&.enable-click {
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&.selected {
|
|
31
|
+
background-color: $color-fill1-2;
|
|
32
|
+
border: solid 1px transparent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.completed {
|
|
36
|
+
i {
|
|
37
|
+
color: $color-success-3;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.failed {
|
|
42
|
+
i {
|
|
43
|
+
color: $color-error-3;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.running, &.auth, &.started {
|
|
48
|
+
i {
|
|
49
|
+
color: $color-brand1-6;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.next-btn-text.next-btn-primary{
|
|
54
|
+
line-height: $s-4;
|
|
55
|
+
font-size: $font-size-caption;
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
margin-right: $s-1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.content-use-tips {
|
|
61
|
+
color: $color-text1-3;
|
|
62
|
+
margin-right: $s-1;
|
|
63
|
+
line-height: $s-4;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.content-name {
|
|
67
|
+
color: $color-text1-4;
|
|
68
|
+
line-height: $s-4;
|
|
69
|
+
overflow: hidden;
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
text-overflow: ellipsis;
|
|
72
|
+
flex: 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import { type CommonProps } from '@alifd/next';
|
|
3
|
+
export interface ToolStatusAuthProps {
|
|
4
|
+
content: string | ReactNode;
|
|
5
|
+
onAuthClick?: (data: ToolStatusProps) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 参考来源属性
|
|
9
|
+
*/
|
|
10
|
+
export interface ToolStatusProps extends React.HTMLAttributes<HTMLElement>, CommonProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 是否被选中
|
|
14
|
+
*/
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 工具调用状态
|
|
18
|
+
*/
|
|
19
|
+
status?: 'started' | 'running' | 'completed' | 'failed' | 'auth';
|
|
20
|
+
/**
|
|
21
|
+
* 工具调用结果
|
|
22
|
+
*/
|
|
23
|
+
result?: string | ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* 工具点击
|
|
26
|
+
*/
|
|
27
|
+
onToolClick?: (data: ToolStatusProps) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 额外的授权信息
|
|
30
|
+
*/
|
|
31
|
+
authInfo?: ToolStatusAuthProps;
|
|
32
|
+
/**
|
|
33
|
+
* 工具名称
|
|
34
|
+
*/
|
|
35
|
+
name?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 工具详情链接
|
|
38
|
+
*/
|
|
39
|
+
useText?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 是否100%的宽度
|
|
42
|
+
*/
|
|
43
|
+
fullWidth?: boolean;
|
|
44
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alifd/chat",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.36",
|
|
4
4
|
"description": "A configurable component library for chat built on React.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -453,6 +453,18 @@
|
|
|
453
453
|
"./flip/style.js": {
|
|
454
454
|
"import": "./es/flip/style.js",
|
|
455
455
|
"require": "./lib/flip/style.js"
|
|
456
|
+
},
|
|
457
|
+
"./tool-status": {
|
|
458
|
+
"import": "./es/tool-status/index.js",
|
|
459
|
+
"require": "./lib/tool-status/index.js"
|
|
460
|
+
},
|
|
461
|
+
"./tool-status/style": {
|
|
462
|
+
"import": "./es/tool-status/style.js",
|
|
463
|
+
"require": "./lib/tool-status/style.js"
|
|
464
|
+
},
|
|
465
|
+
"./tool-status/style.js": {
|
|
466
|
+
"import": "./es/tool-status/style.js",
|
|
467
|
+
"require": "./lib/tool-status/style.js"
|
|
456
468
|
}
|
|
457
469
|
},
|
|
458
470
|
"files": [
|