@ant-design/agentic-ui 2.0.6 → 2.0.10
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/Bubble/style.js +4 -2
- package/dist/MarkdownEditor/editor/Editor.js +3 -2
- package/dist/MarkdownEditor/editor/components/LazyElement/index.d.ts +32 -0
- package/dist/MarkdownEditor/editor/components/LazyElement/index.js +15 -4
- package/dist/MarkdownEditor/types.d.ts +34 -0
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.d.ts +0 -33
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +15 -16
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.d.ts +4 -45
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +107 -146
- package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/index.js +100 -67
- package/dist/MarkdownInputField/AttachmentButton/index.d.ts +25 -1
- package/dist/MarkdownInputField/AttachmentButton/index.js +28 -11
- package/dist/MarkdownInputField/AttachmentButton/types.d.ts +15 -0
- package/dist/MarkdownInputField/BeforeToolContainer/BeforeToolContainer.js +265 -199
- package/dist/MarkdownInputField/FileMapView/style.js +1 -0
- package/dist/MarkdownInputField/FileUploadManager/index.js +19 -6
- package/dist/MarkdownInputField/MarkdownInputField.js +4 -0
- package/dist/plugins/chart/AreaChart/index.d.ts +95 -0
- package/dist/plugins/chart/AreaChart/index.js +10 -0
- package/dist/plugins/chart/BarChart/index.d.ts +47 -0
- package/dist/plugins/chart/DonutChart/index.d.ts +28 -0
- package/dist/plugins/chart/components/ChartToolBar/ChartToolBar.d.ts +58 -0
- package/dist/plugins/chart/const.d.ts +25 -0
- package/dist/plugins/chart/const.js +10 -0
- package/dist/plugins/chart/index.d.ts +14 -0
- package/dist/plugins/chart/utils.d.ts +197 -32
- package/package.json +1 -1
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
1
21
|
// src/MarkdownInputField/AttachmentButton/AttachmentFileList/index.tsx
|
|
2
22
|
import { X } from "@sofa-design/icons";
|
|
3
23
|
import { ConfigProvider, Image } from "antd";
|
|
@@ -8,45 +28,99 @@ import { ActionIconBox } from "../../../components/ActionIconBox";
|
|
|
8
28
|
import { isImageFile } from "../utils";
|
|
9
29
|
import { AttachmentFileListItem } from "./AttachmentFileListItem";
|
|
10
30
|
import { useStyle } from "./style";
|
|
31
|
+
var ANIMATION_VARIANTS = {
|
|
32
|
+
visible: {
|
|
33
|
+
opacity: 1,
|
|
34
|
+
transition: {
|
|
35
|
+
when: "beforeChildren",
|
|
36
|
+
staggerChildren: 0.1
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
hidden: {
|
|
40
|
+
opacity: 0,
|
|
41
|
+
transition: {
|
|
42
|
+
when: "afterChildren"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var HIDDEN_STYLE = {
|
|
47
|
+
height: 0,
|
|
48
|
+
overflow: "hidden",
|
|
49
|
+
padding: 0
|
|
50
|
+
};
|
|
51
|
+
var CLEAR_BUTTON_STYLE = {
|
|
52
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
53
|
+
};
|
|
54
|
+
var IMAGE_PREVIEW_STYLE = {
|
|
55
|
+
display: "none"
|
|
56
|
+
};
|
|
11
57
|
var AttachmentFileList = (props) => {
|
|
12
|
-
|
|
58
|
+
const { fileMap, onDelete, onPreview, onDownload, onRetry, onClearFileMap } = props;
|
|
13
59
|
const context = useContext(ConfigProvider.ConfigContext);
|
|
14
60
|
const prefix = context == null ? void 0 : context.getPrefixCls("md-editor-attachment-list");
|
|
15
61
|
const { wrapSSR, hashId } = useStyle(prefix);
|
|
16
62
|
const [imgSrc, setImgSrc] = React.useState(void 0);
|
|
63
|
+
const fileList = Array.from((fileMap == null ? void 0 : fileMap.values()) || []);
|
|
64
|
+
const hasFiles = fileList.length > 0;
|
|
65
|
+
const isAnyUploading = fileList.some((file) => file.status === "uploading");
|
|
66
|
+
const handlePreview = (file) => {
|
|
67
|
+
if (onPreview) {
|
|
68
|
+
onPreview(file);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (isImageFile(file)) {
|
|
72
|
+
setImgSrc(file.previewUrl || file.url);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (typeof window === "undefined")
|
|
76
|
+
return;
|
|
77
|
+
window.open(file.previewUrl || file.url, "_blank");
|
|
78
|
+
};
|
|
79
|
+
const handlePreviewClose = (visible) => {
|
|
80
|
+
if (!visible) {
|
|
81
|
+
setImgSrc(void 0);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const getContainerStyle = () => {
|
|
85
|
+
return (fileMap == null ? void 0 : fileMap.size) ? {} : HIDDEN_STYLE;
|
|
86
|
+
};
|
|
87
|
+
const getClearButtonStyle = () => {
|
|
88
|
+
return __spreadProps(__spreadValues({}, CLEAR_BUTTON_STYLE), {
|
|
89
|
+
opacity: (fileMap == null ? void 0 : fileMap.size) ? 1 : 0
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
const renderClearButton = () => {
|
|
93
|
+
if (isAnyUploading)
|
|
94
|
+
return null;
|
|
95
|
+
return /* @__PURE__ */ React.createElement(
|
|
96
|
+
ActionIconBox,
|
|
97
|
+
{
|
|
98
|
+
style: getClearButtonStyle(),
|
|
99
|
+
onClick: onClearFileMap,
|
|
100
|
+
className: classNames(`${prefix}-close-icon`, hashId)
|
|
101
|
+
},
|
|
102
|
+
/* @__PURE__ */ React.createElement(X, null)
|
|
103
|
+
);
|
|
104
|
+
};
|
|
17
105
|
return wrapSSR(
|
|
18
106
|
/* @__PURE__ */ React.createElement(
|
|
19
107
|
"div",
|
|
20
108
|
{
|
|
21
109
|
className: classNames(`${prefix}-container`, hashId, {
|
|
22
|
-
[`${prefix}-container-empty`]:
|
|
110
|
+
[`${prefix}-container-empty`]: !hasFiles
|
|
23
111
|
})
|
|
24
112
|
},
|
|
25
113
|
/* @__PURE__ */ React.createElement(
|
|
26
114
|
motion.div,
|
|
27
115
|
{
|
|
28
|
-
variants:
|
|
29
|
-
visible: {
|
|
30
|
-
opacity: 1,
|
|
31
|
-
transition: {
|
|
32
|
-
when: "beforeChildren",
|
|
33
|
-
staggerChildren: 0.1
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
hidden: {
|
|
37
|
-
opacity: 0,
|
|
38
|
-
transition: {
|
|
39
|
-
when: "afterChildren"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
},
|
|
116
|
+
variants: ANIMATION_VARIANTS,
|
|
43
117
|
whileInView: "visible",
|
|
44
118
|
initial: "hidden",
|
|
45
119
|
animate: "visible",
|
|
46
|
-
style: (
|
|
120
|
+
style: getContainerStyle(),
|
|
47
121
|
className: classNames(prefix, hashId)
|
|
48
122
|
},
|
|
49
|
-
/* @__PURE__ */ React.createElement(AnimatePresence, { initial: false },
|
|
123
|
+
/* @__PURE__ */ React.createElement(AnimatePresence, { initial: false }, fileList.map((file, index) => /* @__PURE__ */ React.createElement(
|
|
50
124
|
AttachmentFileListItem,
|
|
51
125
|
{
|
|
52
126
|
prefixCls: `${prefix}-item`,
|
|
@@ -54,31 +128,10 @@ var AttachmentFileList = (props) => {
|
|
|
54
128
|
className: classNames(hashId, `${prefix}-item`),
|
|
55
129
|
key: (file == null ? void 0 : file.uuid) || (file == null ? void 0 : file.name) || index,
|
|
56
130
|
file,
|
|
57
|
-
onDelete: () =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _a2;
|
|
62
|
-
if (props.onPreview) {
|
|
63
|
-
(_a2 = props.onPreview) == null ? void 0 : _a2.call(props, file);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (isImageFile(file)) {
|
|
67
|
-
setImgSrc(file.previewUrl || file.url);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (typeof window === "undefined")
|
|
71
|
-
return;
|
|
72
|
-
window.open(file.previewUrl || file.url, "_blank");
|
|
73
|
-
},
|
|
74
|
-
onDownload: () => {
|
|
75
|
-
var _a2;
|
|
76
|
-
return (_a2 = props.onDownload) == null ? void 0 : _a2.call(props, file);
|
|
77
|
-
},
|
|
78
|
-
onRetry: () => {
|
|
79
|
-
var _a2;
|
|
80
|
-
return (_a2 = props.onRetry) == null ? void 0 : _a2.call(props, file);
|
|
81
|
-
}
|
|
131
|
+
onDelete: () => onDelete(file),
|
|
132
|
+
onPreview: () => handlePreview(file),
|
|
133
|
+
onDownload: () => onDownload == null ? void 0 : onDownload(file),
|
|
134
|
+
onRetry: () => onRetry == null ? void 0 : onRetry(file)
|
|
82
135
|
}
|
|
83
136
|
))),
|
|
84
137
|
/* @__PURE__ */ React.createElement(
|
|
@@ -87,37 +140,17 @@ var AttachmentFileList = (props) => {
|
|
|
87
140
|
key: "preview",
|
|
88
141
|
src: imgSrc,
|
|
89
142
|
alt: "Preview",
|
|
90
|
-
style:
|
|
143
|
+
style: IMAGE_PREVIEW_STYLE,
|
|
91
144
|
preview: {
|
|
92
145
|
visible: !!imgSrc,
|
|
93
146
|
scaleStep: 1,
|
|
94
147
|
src: imgSrc,
|
|
95
|
-
onVisibleChange:
|
|
96
|
-
if (!value) {
|
|
97
|
-
setImgSrc(void 0);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
148
|
+
onVisibleChange: handlePreviewClose
|
|
100
149
|
}
|
|
101
150
|
}
|
|
102
151
|
)
|
|
103
152
|
),
|
|
104
|
-
|
|
105
|
-
(file) => file.status !== "uploading"
|
|
106
|
-
) ? /* @__PURE__ */ React.createElement(
|
|
107
|
-
ActionIconBox,
|
|
108
|
-
{
|
|
109
|
-
style: {
|
|
110
|
-
opacity: ((_e = props.fileMap) == null ? void 0 : _e.size) ? 1 : 0,
|
|
111
|
-
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
112
|
-
},
|
|
113
|
-
onClick: () => {
|
|
114
|
-
var _a2;
|
|
115
|
-
(_a2 = props.onClearFileMap) == null ? void 0 : _a2.call(props);
|
|
116
|
-
},
|
|
117
|
-
className: classNames(`${`${prefix}`}-close-icon`, hashId)
|
|
118
|
-
},
|
|
119
|
-
/* @__PURE__ */ React.createElement(X, null)
|
|
120
|
-
) : null
|
|
153
|
+
renderClearButton()
|
|
121
154
|
)
|
|
122
155
|
);
|
|
123
156
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { AttachmentButtonPopoverProps } from './AttachmentButtonPopover';
|
|
3
|
-
import { AttachmentFile } from './types';
|
|
3
|
+
import { AttachmentFile, UploadResponse } from './types';
|
|
4
4
|
export * from './AttachmentButtonPopover';
|
|
5
|
+
export type { AttachmentFile, UploadResponse } from './types';
|
|
5
6
|
/**
|
|
6
7
|
* AttachmentButton 组件的属性
|
|
7
8
|
*/
|
|
@@ -17,6 +18,28 @@ export type AttachmentButtonProps = {
|
|
|
17
18
|
* }
|
|
18
19
|
*/
|
|
19
20
|
upload?: (file: AttachmentFile) => Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* 处理文件上传的函数(返回完整响应对象)。返回一个 Promise,解析为 UploadResponse 对象。
|
|
23
|
+
* 优先级高于 upload 接口,返回的完整响应对象会存储在 file.uploadResponse 中。
|
|
24
|
+
* @param file - 要上传的附件文件
|
|
25
|
+
* @param index - 文件在上传队列中的索引
|
|
26
|
+
* @returns 解析为 UploadResponse 对象的 Promise
|
|
27
|
+
* @example
|
|
28
|
+
* const uploadWithResponse = async (file: AttachmentFile, index: number) => {
|
|
29
|
+
* const response = await api.uploadFile(file);
|
|
30
|
+
* return {
|
|
31
|
+
* contentId: null,
|
|
32
|
+
* errorMessage: null,
|
|
33
|
+
* fileId: response.fileId,
|
|
34
|
+
* fileName: response.fileName,
|
|
35
|
+
* fileSize: file.size,
|
|
36
|
+
* fileType: response.fileType,
|
|
37
|
+
* fileUrl: response.fileUrl,
|
|
38
|
+
* uploadStatus: 'SUCCESS'
|
|
39
|
+
* };
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
uploadWithResponse?: (file: AttachmentFile, index: number) => Promise<UploadResponse>;
|
|
20
43
|
/**
|
|
21
44
|
* 存储当前附件文件的 Map,以文件 ID 为键,文件对象为值
|
|
22
45
|
* @example
|
|
@@ -86,6 +109,7 @@ export declare const upLoadFileToServer: (files: ArrayLike<File>, props: {
|
|
|
86
109
|
fileMap?: Map<string, AttachmentFile> | undefined;
|
|
87
110
|
onFileMapChange?: ((files?: Map<string, AttachmentFile>) => void) | undefined;
|
|
88
111
|
upload?: ((file: AttachmentFile, index: number) => Promise<string>) | undefined;
|
|
112
|
+
uploadWithResponse?: ((file: AttachmentFile, index: number) => Promise<UploadResponse>) | undefined;
|
|
89
113
|
maxFileSize?: number | undefined;
|
|
90
114
|
maxFileCount?: number | undefined;
|
|
91
115
|
minFileCount?: number | undefined;
|
|
@@ -46,7 +46,7 @@ var waitTime = (time) => {
|
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
var upLoadFileToServer = (files, props) => __async(void 0, null, function* () {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o
|
|
49
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
50
50
|
const map = props.fileMap || /* @__PURE__ */ new Map();
|
|
51
51
|
const hideLoading = message.loading(
|
|
52
52
|
((_a = props.locale) == null ? void 0 : _a.uploading) || "Uploading..."
|
|
@@ -98,24 +98,41 @@ var upLoadFileToServer = (files, props) => __async(void 0, null, function* () {
|
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
100
|
try {
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
let url;
|
|
102
|
+
let isSuccess = false;
|
|
103
|
+
let errorMsg = null;
|
|
104
|
+
if (props.uploadWithResponse) {
|
|
105
|
+
const uploadResult = yield props.uploadWithResponse(file, index);
|
|
106
|
+
url = uploadResult.fileUrl;
|
|
107
|
+
isSuccess = uploadResult.uploadStatus === "SUCCESS";
|
|
108
|
+
errorMsg = uploadResult.errorMessage || null;
|
|
109
|
+
file.uploadResponse = uploadResult;
|
|
110
|
+
} else if (props.upload) {
|
|
111
|
+
url = yield props.upload(file, index);
|
|
112
|
+
isSuccess = !!url;
|
|
113
|
+
} else {
|
|
114
|
+
url = file.previewUrl;
|
|
115
|
+
isSuccess = !!url;
|
|
116
|
+
}
|
|
117
|
+
if (isSuccess && url) {
|
|
103
118
|
file.status = "done";
|
|
104
119
|
file.url = url;
|
|
105
120
|
map.set(file.uuid || "", file);
|
|
106
|
-
(
|
|
107
|
-
message.success(((
|
|
121
|
+
(_h = props.onFileMapChange) == null ? void 0 : _h.call(props, map);
|
|
122
|
+
message.success(((_i = props.locale) == null ? void 0 : _i.uploadSuccess) || "Upload success");
|
|
108
123
|
} else {
|
|
109
124
|
file.status = "error";
|
|
110
125
|
map.set(file.uuid || "", file);
|
|
111
|
-
(
|
|
112
|
-
|
|
126
|
+
(_j = props.onFileMapChange) == null ? void 0 : _j.call(props, map);
|
|
127
|
+
const failedMsg = errorMsg || ((_k = props.locale) == null ? void 0 : _k.uploadFailed) || "Upload failed";
|
|
128
|
+
message.error(failedMsg);
|
|
113
129
|
}
|
|
114
130
|
} catch (error2) {
|
|
115
131
|
file.status = "error";
|
|
116
132
|
map.set(file.uuid || "", file);
|
|
117
|
-
(
|
|
118
|
-
message
|
|
133
|
+
(_l = props.onFileMapChange) == null ? void 0 : _l.call(props, map);
|
|
134
|
+
const errorMessage = error2 instanceof Error ? error2.message : ((_m = props.locale) == null ? void 0 : _m.uploadFailed) || "Upload failed";
|
|
135
|
+
message.error(errorMessage);
|
|
119
136
|
}
|
|
120
137
|
index++;
|
|
121
138
|
}
|
|
@@ -136,8 +153,8 @@ var upLoadFileToServer = (files, props) => __async(void 0, null, function* () {
|
|
|
136
153
|
map.set(file.uuid || "", file);
|
|
137
154
|
}
|
|
138
155
|
});
|
|
139
|
-
message.error(((
|
|
140
|
-
(
|
|
156
|
+
message.error(((_n = props.locale) == null ? void 0 : _n.uploadFailed) || "Upload failed");
|
|
157
|
+
(_o = props.onFileMapChange) == null ? void 0 : _o.call(props, map);
|
|
141
158
|
} finally {
|
|
142
159
|
hideLoading();
|
|
143
160
|
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 上传响应对象类型
|
|
3
|
+
*/
|
|
4
|
+
export type UploadResponse = {
|
|
5
|
+
contentId?: string | null;
|
|
6
|
+
errorMessage?: string | null;
|
|
7
|
+
fileId: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
fileSize?: number | null;
|
|
10
|
+
fileType: string;
|
|
11
|
+
fileUrl: string;
|
|
12
|
+
uploadStatus: 'SUCCESS' | 'FAIL' | string;
|
|
13
|
+
};
|
|
1
14
|
export type AttachmentFile = File & {
|
|
2
15
|
url?: string;
|
|
3
16
|
status?: 'error' | 'uploading' | 'done';
|
|
4
17
|
uuid?: string;
|
|
5
18
|
previewUrl?: string;
|
|
19
|
+
/** 上传响应数据(使用 uploadWithResponse 时会填充此字段) */
|
|
20
|
+
uploadResponse?: UploadResponse;
|
|
6
21
|
};
|