@cloudbase/weda-ui 3.14.2 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/configs/components/listView.d.ts +11 -0
  2. package/dist/configs/components/listView.js +53 -0
  3. package/dist/configs/components/wd-select-multiple.d.ts +72 -28
  4. package/dist/configs/components/wd-select-multiple.js +233 -19
  5. package/dist/configs/components/wd-select.d.ts +70 -29
  6. package/dist/configs/components/wd-select.js +211 -17
  7. package/dist/configs/index.d.ts +174 -60
  8. package/dist/configs/type-utils/type-form.js +65 -21
  9. package/dist/configs/type-utils/x-runtime-default.d.ts +2 -0
  10. package/dist/configs/type-utils/x-runtime-default.js +4 -0
  11. package/dist/style/index.css +15 -0
  12. package/dist/style/index.scss +1 -1
  13. package/dist/style/weda-ui.min.css +3 -3
  14. package/dist/web/components/form/uploader/uploader.h5.js +9 -10
  15. package/dist/web/components/form/uploader/uploader.pc.js +7 -7
  16. package/dist/web/components/form/uploader/util.js +7 -12
  17. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +29 -37
  18. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +15 -22
  19. package/dist/web/components/listView/index.css +4 -2
  20. package/dist/web/components/listView/index.js +25 -43
  21. package/dist/web/components/richText/index.js +13 -15
  22. package/dist/web/components/statusContent/index.js +1 -1
  23. package/dist/web/components/wd-input/wd-input.js +16 -20
  24. package/dist/web/components/wd-select/contexts/selectContext.d.ts +15 -0
  25. package/dist/web/components/wd-select/contexts/selectContext.js +13 -0
  26. package/dist/web/components/wd-select/hooks/useChooseList.d.ts +19 -0
  27. package/dist/web/components/wd-select/hooks/useChooseList.js +94 -0
  28. package/dist/web/components/wd-select/relationSelect/enumSelect.d.ts +2 -0
  29. package/dist/web/components/wd-select/relationSelect/enumSelect.js +48 -0
  30. package/dist/web/components/wd-select/relationSelect/index.d.ts +2 -0
  31. package/dist/web/components/wd-select/relationSelect/index.js +19 -0
  32. package/dist/web/components/wd-select/relationSelect/queryParams.d.ts +15 -0
  33. package/dist/web/components/wd-select/relationSelect/queryParams.js +15 -0
  34. package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +0 -2
  35. package/dist/web/components/wd-select/relationSelect/relationSelect.js +39 -83
  36. package/dist/web/components/wd-select/select/index.js +1 -1
  37. package/dist/web/components/wd-select/wd-select.css +8 -0
  38. package/dist/web/components/wd-select/wd-select.js +11 -8
  39. package/dist/web/components/wd-select-multiple/wd-select-multiple.js +11 -8
  40. package/dist/web/components/wd-table/components/FieldRender/index.js +3 -3
  41. package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +8 -13
  42. package/dist/web/components/wd-table/components/deleteModal.d.ts +1 -1
  43. package/dist/web/components/wd-table/components/deleteModal.js +47 -30
  44. package/dist/web/utils/getModelParams.d.ts +6 -1
  45. package/dist/web/utils/getModelParams.js +16 -13
  46. package/dist/web/utils/platform.js +9 -13
  47. package/dist/web/utils/tcb.d.ts +4 -0
  48. package/dist/web/utils/tcb.js +11 -9
  49. package/package.json +3 -3
@@ -2,7 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import * as React from 'react';
3
3
  import weui from '../../../utils/weui';
4
4
  import classNames from '../../../utils/classnames';
5
- import { browserEnv } from '../../../utils/platform';
5
+ import { browserEnv, alertErrorMessage } from '../../../utils/platform';
6
6
  import { IMAGE_TYPES, encodeConvert } from './uploader.pc';
7
7
  import { useTempUrl } from '../../../utils/hooks/use-cloud-id-temp-url';
8
8
  import { toBase64Uri } from '../../../utils/file2base64';
@@ -50,34 +50,33 @@ export function ImageUploaderH5(props) {
50
50
  return tempFile.length < maxUploadCount;
51
51
  }, [tempFile, single, maxUploadCount, uploading]);
52
52
  const uploadChange = async (e) => {
53
- var _a, _b, _c, _d, _e, _f, _g, _h;
54
53
  let files = [...e.target.files];
55
54
  const isAccepted = files.every((i) => checkAcceptedFiles(i, accepts));
56
55
  if (!isAccepted) {
57
- (_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
58
- title: `上传图片类型错误`,
56
+ alertErrorMessage({
57
+ message: `上传图片类型错误`,
59
58
  icon: 'none',
60
59
  });
61
60
  return false;
62
61
  }
63
62
  if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
64
- (_d = (_c = window === null || window === void 0 ? void 0 : window.$w) === null || _c === void 0 ? void 0 : _c.utils) === null || _d === void 0 ? void 0 : _d.showToast({
65
- title: `请上传不超过 ${maxSize}M 的图片`,
63
+ alertErrorMessage({
64
+ message: `请上传不超过 ${maxSize}M 的图片`,
66
65
  icon: 'none',
67
66
  });
68
67
  return false;
69
68
  }
70
69
  if (files.length > finalMaxImgCount) {
71
70
  // 防止一下子选择过多文件
72
- (_f = (_e = window === null || window === void 0 ? void 0 : window.$w) === null || _e === void 0 ? void 0 : _e.utils) === null || _f === void 0 ? void 0 : _f.showToast({
73
- title: `最多只能上传${finalMaxImgCount}张图片,请重新选择`,
71
+ alertErrorMessage({
72
+ message: `最多只能上传${finalMaxImgCount}张图片,请重新选择`,
74
73
  icon: 'none',
75
74
  });
76
75
  return false;
77
76
  }
78
77
  if (tempFile.length + files.length > finalMaxImgCount) {
79
- (_h = (_g = window === null || window === void 0 ? void 0 : window.$w) === null || _g === void 0 ? void 0 : _g.utils) === null || _h === void 0 ? void 0 : _h.showToast({
80
- title: `最多只能上传${finalMaxImgCount}张图片`,
78
+ alertErrorMessage({
79
+ message: `最多只能上传${finalMaxImgCount}张图片`,
81
80
  icon: 'none',
82
81
  });
83
82
  return false;
@@ -5,6 +5,7 @@ import { useTempUrl } from '../../../utils/hooks/use-cloud-id-temp-url';
5
5
  import { toBase64Uri } from '../../../utils/file2base64';
6
6
  import { isNil } from '../../../utils/lodash';
7
7
  import { errorHandler } from '../../../utils/error';
8
+ import { alertErrorMessage } from '../../../utils/platform';
8
9
  import { WdIcon } from '../../wd-icon';
9
10
  import { useUploader } from './useUploadFile';
10
11
  import { ImagePreview } from '../../wd-image/ImagePreview';
@@ -31,7 +32,6 @@ export function UploaderPCInner(props) {
31
32
  };
32
33
  // 方法:上传前,判断图片大小、数量是否满足,取消默认组件的上传事件,用自定义的 tcb 上传方法
33
34
  const beforeHandle = async (file, fileList, isAccepted, error) => {
34
- var _a, _b, _c, _d, _e, _f;
35
35
  const finalMaxImgCount = single ? 1 : maxUploadCount;
36
36
  if (!isAccepted) {
37
37
  try {
@@ -42,8 +42,8 @@ export function UploaderPCInner(props) {
42
42
  if (error.find((item) => (item === null || item === void 0 ? void 0 : item.code) === 'file-too-large')) {
43
43
  errorList.push(`上传图片大小不能超过${maxSize}M`);
44
44
  }
45
- (_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
46
- title: errorList.join(', '),
45
+ alertErrorMessage({
46
+ message: errorList.join(', '),
47
47
  icon: 'error',
48
48
  });
49
49
  }
@@ -60,15 +60,15 @@ export function UploaderPCInner(props) {
60
60
  return Promise.reject(false);
61
61
  if (fileList.length > finalMaxImgCount) {
62
62
  // 防止一下子选择过多文件
63
- (_d = (_c = window === null || window === void 0 ? void 0 : window.$w) === null || _c === void 0 ? void 0 : _c.utils) === null || _d === void 0 ? void 0 : _d.showToast({
64
- title: `最多只能上传${finalMaxImgCount}张图片,请重新选择`,
63
+ alertErrorMessage({
64
+ message: `最多只能上传${finalMaxImgCount}张图片,请重新选择`,
65
65
  icon: 'error',
66
66
  });
67
67
  return Promise.reject(false);
68
68
  }
69
69
  if (tempFile.length + fileList.length > finalMaxImgCount) {
70
- (_f = (_e = window === null || window === void 0 ? void 0 : window.$w) === null || _e === void 0 ? void 0 : _e.utils) === null || _f === void 0 ? void 0 : _f.showToast({
71
- title: `最多只能上传${finalMaxImgCount}张图片`,
70
+ alertErrorMessage({
71
+ message: `最多只能上传${finalMaxImgCount}张图片`,
72
72
  icon: 'error',
73
73
  });
74
74
  return Promise.reject(false);
@@ -1,5 +1,5 @@
1
1
  import { compressImage } from './compress';
2
- import { getCloudInstance } from '../../../utils/tcb';
2
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
3
3
  import { toBase64Uri } from '../../../utils/file2base64';
4
4
  import { randomStr } from '../../../utils/platform';
5
5
  import { errorHandler } from '../../../utils/error';
@@ -19,7 +19,7 @@ export const getBase64 = (files) => {
19
19
  };
20
20
  // 多张上传
21
21
  export const uploadTcbMulti = async (files, props) => {
22
- const { isCompressBeforeUpload, compressedHeight, compressedWidth, compressQuality, } = props;
22
+ const { isCompressBeforeUpload, compressedHeight, compressedWidth, compressQuality } = props;
23
23
  const promiseAll = files.map(async (f) => {
24
24
  if (isCompressBeforeUpload) {
25
25
  const compressed = await compressImage(f.file, {
@@ -36,12 +36,13 @@ export const uploadTcbMulti = async (files, props) => {
36
36
  };
37
37
  export const filenameRegex = /[^a-zA-Z0-9\u4e00-\u9fff-*!_.]/g;
38
38
  const uploadToTcb = async (item, props) => {
39
- var _a, _b;
39
+ var _a;
40
40
  const { onUploadProgress, onUploadFinish, onUploadError } = props;
41
41
  const { file, uploadPath } = item;
42
42
  try {
43
43
  const tcb = await getCloudInstance();
44
- const cloudPath = `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`;
44
+ const _uploadPath = getDefaultUploadPath(uploadPath);
45
+ const cloudPath = `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`;
45
46
  const { fileID } = await tcb.uploadFile({
46
47
  cloudPath,
47
48
  filePath: file,
@@ -77,20 +78,14 @@ const uploadToTcb = async (item, props) => {
77
78
  errorHandler({
78
79
  code: 'WdUploadImage.UploadToTcbError',
79
80
  error: err,
80
- });
81
- (_b = window === null || window === void 0 ? void 0 : window.$w) === null || _b === void 0 ? void 0 : _b.utils.showModal({
82
- title: '上传失败,请重试',
83
- content: err.message,
84
- showCancel: false,
81
+ showTip: true,
85
82
  });
86
83
  onUploadError(err);
87
84
  }
88
85
  };
89
86
  export const checkAcceptedFiles = (file, acceptedFiles) => {
90
87
  if (file && acceptedFiles) {
91
- const acceptedFilesArray = Array.isArray(acceptedFiles)
92
- ? acceptedFiles
93
- : acceptedFiles.split(',');
88
+ const acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
94
89
  if (acceptedFilesArray.length === 0) {
95
90
  return true;
96
91
  }
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import * as React from 'react';
3
3
  import isObjectEqual from '../../../utils/isObjectEqual';
4
- import { ConfigProvider, Button, Text, List, Progress, Tooltip, } from 'tea-component';
5
- import { filterStrList, isCloudFileID, isHttpFileID, transSize, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, } from '../../../utils/platform';
6
- import { getCloudInstance } from '../../../utils/tcb';
4
+ import { ConfigProvider, Button, Text, List, Progress, Tooltip } from 'tea-component';
5
+ import { filterStrList, isCloudFileID, isHttpFileID, transSize, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, alertErrorMessage, } from '../../../utils/platform';
6
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
7
7
  import classNames from '../../../utils/classnames';
8
8
  import { renderDecorator } from '../renderDecorator';
9
9
  import { emptyArray, emptyObject } from '../../../utils/constant';
@@ -95,9 +95,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
95
95
  [className]: className,
96
96
  });
97
97
  const accepts = React.useMemo(() => {
98
- return acceptTypes.includes('*') || acceptTypes.length === 0
99
- ? ['*']
100
- : Array.from(new Set(acceptTypes));
98
+ return acceptTypes.includes('*') || acceptTypes.length === 0 ? ['*'] : Array.from(new Set(acceptTypes));
101
99
  }, [acceptTypes]);
102
100
  // 上传后文件列表 fileIDList 改变事件,'add'|'delete'
103
101
  const handleChange = ({ fileID, uuid, type, size, file }) => {
@@ -137,42 +135,39 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
137
135
  }, children: _jsx("div", { "data-testid": "uploadFileH5", className: cls, id: id, style: style, children: _jsxs("div", { className: classNames(`${CLASS_PREFIX}`), children: [isEdit && (_jsx("div", { className: classNames(`${CLASS_PREFIX}__hd`, layout), children: _jsx("div", { children: btnDisabled ? (readOnly ? null : (_jsx(WdButton, { variant: "outline", className: classNames(`${CLASS_PREFIX}__btn--weak`), disabled: btnDisabled, text: btnTitle }))) : (_jsxs("div", { children: [_jsx("input", { ref: inputRef, id: "uploaderInput", type: "file", "data-testid": "button-up", className: "weui-uploader-mobile__input", accept: accepts.join(','), multiple: !single, onClick: () => {
138
136
  inputRef.current && (inputRef.current.value = '');
139
137
  }, onChange: async (e) => {
140
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
141
138
  let fileList = [...e.target.files];
142
139
  const isAccepted = fileList.every((i) => checkAcceptedFiles(i, accepts));
143
140
  if (!isAccepted) {
144
- (_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
145
- title: `上传图片类型错误`,
141
+ alertErrorMessage({
142
+ message: `上传图片类型错误`,
146
143
  icon: 'none',
147
144
  });
148
145
  return false;
149
146
  }
150
147
  if (single && fileList.length > 1) {
151
- (_d = (_c = window === null || window === void 0 ? void 0 : window.$w) === null || _c === void 0 ? void 0 : _c.utils) === null || _d === void 0 ? void 0 : _d.showToast({
152
- title: `上传文件总数不能超过1个`,
148
+ alertErrorMessage({
149
+ message: `上传文件总数不能超过1个`,
153
150
  icon: 'none',
154
151
  });
155
152
  return false;
156
153
  }
157
- if (fileList.length + fileIDList.length >
158
- maxUploadCount) {
159
- (_f = (_e = window === null || window === void 0 ? void 0 : window.$w) === null || _e === void 0 ? void 0 : _e.utils) === null || _f === void 0 ? void 0 : _f.showToast({
160
- title: `上传文件总数不能超过${maxUploadCount}个`,
154
+ if (fileList.length + fileIDList.length > maxUploadCount) {
155
+ alertErrorMessage({
156
+ message: `上传文件总数不能超过${maxUploadCount}个`,
161
157
  icon: 'none',
162
158
  });
163
159
  return false;
164
160
  }
165
- if (maxSizeLimit &&
166
- fileList.some((f) => f.size > maxSizeLimit * 1024 * 1024)) {
167
- (_h = (_g = window === null || window === void 0 ? void 0 : window.$w) === null || _g === void 0 ? void 0 : _g.utils) === null || _h === void 0 ? void 0 : _h.showToast({
168
- title: `请上传不超过${maxSizeLimit}M的文件`,
161
+ if (maxSizeLimit && fileList.some((f) => f.size > maxSizeLimit * 1024 * 1024)) {
162
+ alertErrorMessage({
163
+ message: `请上传不超过${maxSizeLimit}M的文件`,
169
164
  icon: 'none',
170
165
  });
171
166
  return false;
172
167
  }
173
168
  if (fileList.some((f) => f.size > 1024 * 1024 * 1024)) {
174
- (_k = (_j = window === null || window === void 0 ? void 0 : window.$w) === null || _j === void 0 ? void 0 : _j.utils) === null || _k === void 0 ? void 0 : _k.showToast({
175
- title: `请上传不超过1024M的文件`,
169
+ alertErrorMessage({
170
+ message: `请上传不超过1024M的文件`,
176
171
  icon: 'none',
177
172
  });
178
173
  return false;
@@ -188,8 +183,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
188
183
  if (typeof ret === 'boolean') {
189
184
  shouldUploadToCos = ret;
190
185
  }
191
- else if (Array.isArray(ret) &&
192
- ret.every((item) => item instanceof File)) {
186
+ else if (Array.isArray(ret) && ret.every((item) => item instanceof File)) {
193
187
  fileList = ret;
194
188
  }
195
189
  else if (!isNil(ret)) {
@@ -210,7 +204,7 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
210
204
  }
211
205
  fileList.forEach((f) => (f['_uuid'] = randomStr()));
212
206
  setFileList((list) => [...list, ...fileList]);
213
- } }), _jsx(WdButton, { variant: "outline", className: "wedatea2td-btn wedatea2td-btn--weak", text: btnTitle, size: "sm" }), !single && (_jsx(Text, { className: `${CLASS_PREFIX}__tips`, children: uploadTipText }))] })) }) })), _jsx("div", { className: `${CLASS_PREFIX}__bd`, children: _jsxs(List, { children: [fileIDList.map((d) => (_jsx(List.Item, { children: _jsx(TcbFileEcho, { fileID: d, fileList: fileList, onChange: handleChange, disabled: disabled, deleteVisible: deleteVisible, downloadVisible: downloadVisible, formType: formType }) }, d))), fileList.map((item) => (_jsx(List.Item, { children: _jsx(TcbFileUpload, { id: id, disabled: disabled, file: item, downloadVisible: downloadVisible, deleteVisible: deleteVisible && !disabled, formType: formType }) }, item === null || item === void 0 ? void 0 : item._uuid)))] }) })] }) }) }) }))({
207
+ } }), _jsx(WdButton, { variant: "outline", className: "wedatea2td-btn wedatea2td-btn--weak", text: btnTitle, size: "sm" }), !single && _jsx(Text, { className: `${CLASS_PREFIX}__tips`, children: uploadTipText })] })) }) })), _jsx("div", { className: `${CLASS_PREFIX}__bd`, children: _jsxs(List, { children: [fileIDList.map((d) => (_jsx(List.Item, { children: _jsx(TcbFileEcho, { fileID: d, fileList: fileList, onChange: handleChange, disabled: disabled, deleteVisible: deleteVisible, downloadVisible: downloadVisible, formType: formType }) }, d))), fileList.map((item) => (_jsx(List.Item, { children: _jsx(TcbFileUpload, { id: id, disabled: disabled, file: item, downloadVisible: downloadVisible, deleteVisible: deleteVisible && !disabled, formType: formType }) }, item === null || item === void 0 ? void 0 : item._uuid)))] }) })] }) }) }) }))({
214
208
  id,
215
209
  className: cls,
216
210
  style,
@@ -224,12 +218,12 @@ events = emptyObject, defaultValue, uploadPath = 'weda-uploader', single = true,
224
218
  * 基于 FileID 文件回显组件
225
219
  */
226
220
  const TcbFileEcho = ({ fileID, disabled, formType }) => {
227
- var _a, _b, _c;
221
+ var _a;
228
222
  const { fileSizeObj } = React.useContext(FileContext) || {};
229
223
  const { data: src, error } = useTempUrl(fileID);
230
224
  if (error) {
231
- (_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
232
- title: `cloud id ${fileID} 资源获取错误`,
225
+ alertErrorMessage({
226
+ message: `cloud id ${fileID} 资源获取错误`,
233
227
  icon: 'error',
234
228
  });
235
229
  }
@@ -243,7 +237,7 @@ const TcbFileEcho = ({ fileID, disabled, formType }) => {
243
237
  }
244
238
  }, [fileID]);
245
239
  //上传文件列表展示
246
- return (_jsxs("div", { className: `${CLASS_PREFIX}__item`, children: [_jsx("div", { className: `${CLASS_PREFIX}__item-left`, children: _jsx(UploadFileStatus, { title: label, size: ((_c = fileSizeObj[fileID]) === null || _c === void 0 ? void 0 : _c.size) || '-', formType: formType }) }), _jsx("div", { className: `${CLASS_PREFIX}__btn-group`, children: _jsx(UploadFileAction, { title: label, disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }) })] }));
240
+ return (_jsxs("div", { className: `${CLASS_PREFIX}__item`, children: [_jsx("div", { className: `${CLASS_PREFIX}__item-left`, children: _jsx(UploadFileStatus, { title: label, size: ((_a = fileSizeObj[fileID]) === null || _a === void 0 ? void 0 : _a.size) || '-', formType: formType }) }), _jsx("div", { className: `${CLASS_PREFIX}__btn-group`, children: _jsx(UploadFileAction, { title: label, disabled: disabled, status: "UPLOAD_STATUS_SUCCESS", fileID: fileID, src: src }) })] }));
247
241
  };
248
242
  /**
249
243
  * 基于 File 上传文件过程组件
@@ -269,8 +263,9 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
269
263
  const tcb = await getCloudInstance();
270
264
  try {
271
265
  setStatus('UPLOAD_STATUS_PENDING');
266
+ const _uploadPath = getDefaultUploadPath(uploadPath);
272
267
  const { fileID } = await tcb.uploadFile({
273
- cloudPath: `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
268
+ cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
274
269
  filePath: file,
275
270
  onUploadProgress: (progressEvent) => {
276
271
  let percent = 0;
@@ -279,8 +274,7 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
279
274
  setPercent(percent < 100 ? percent : 100);
280
275
  },
281
276
  });
282
- !cancelRef.current &&
283
- (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
277
+ !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
284
278
  setStatus('UPLOAD_STATUS_SUCCESS');
285
279
  }
286
280
  catch (err) {
@@ -305,12 +299,10 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
305
299
  var _a;
306
300
  const { isEdit } = React.useContext(FileContext) || {};
307
301
  //上传中、待上传状态
308
- if (status == 'UPLOAD_STATUS_LOADING' ||
309
- (status == 'UPLOAD_STATUS_PENDING' && percent)) {
302
+ if (status == 'UPLOAD_STATUS_LOADING' || (status == 'UPLOAD_STATUS_PENDING' && percent)) {
310
303
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: `${CLASS_PREFIX}__file-detail`, children: _jsx(Text, { className: `${CLASS_PREFIX}__file-name`, children: title }) }), _jsx("div", { children: _jsx(Progress, { percent: percent, theme: "default", strokeColor: '#0052D9', className: `${CLASS_PREFIX}__file-progress` }) }), _jsxs("div", { className: `${CLASS_PREFIX}__file-foot`, children: [formType !== 'read' && (_jsxs("div", { children: [_jsxs(Text, { children: [Math.floor(percentSize), "K/"] }), _jsx(Text, { children: size })] })), _jsx(Text, { children: status === 'UPLOAD_STATUS_PENDING' ? '等待上传' : '上传中' })] })] }));
311
304
  }
312
- return (_jsxs(_Fragment, { children: [_jsx("div", { className: `${CLASS_PREFIX}__file-detail`, children: _jsx(Tooltip, { title: title, children: _jsx(Text, { className: `${CLASS_PREFIX}__file-name`, children: title }) }) }), isEdit && (_jsxs("div", { className: `${CLASS_PREFIX}__file-foot`, children: [isEdit && (_jsx("div", { className: `${CLASS_PREFIX}__file-status`, children: _jsx(Text, { className: `${CLASS_PREFIX}__file-status--msg`, children: ((_a = statusMap[status]) === null || _a === void 0 ? void 0 : _a.title) ||
313
- statusMap['UPLOAD_STATUS_PENDING'].title }) })), formType !== 'read' && (_jsx("div", { children: _jsx(Text, { children: size }) }))] }))] }));
305
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: `${CLASS_PREFIX}__file-detail`, children: _jsx(Tooltip, { title: title, children: _jsx(Text, { className: `${CLASS_PREFIX}__file-name`, children: title }) }) }), isEdit && (_jsxs("div", { className: `${CLASS_PREFIX}__file-foot`, children: [isEdit && (_jsx("div", { className: `${CLASS_PREFIX}__file-status`, children: _jsx(Text, { className: `${CLASS_PREFIX}__file-status--msg`, children: ((_a = statusMap[status]) === null || _a === void 0 ? void 0 : _a.title) || statusMap['UPLOAD_STATUS_PENDING'].title }) })), formType !== 'read' && (_jsx("div", { children: _jsx(Text, { children: size }) }))] }))] }));
314
306
  };
315
307
  /**
316
308
  * 操作列组件, onChange 从最外层 UploadFilePc 传进来
@@ -319,7 +311,7 @@ const UploadFileStatus = ({ status = 'UPLOAD_STATUS_SUCCESS', percent = 0, size,
319
311
  const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid = '', src = '', file = null, onReLoad = null, onCancel = null, disabled, title = 'downfile', }) => {
320
312
  const { onChange, downloadVisible, deleteVisible, isEdit } = React.useContext(FileContext) || {};
321
313
  // 操作列按钮-删除
322
- const renderDelete = () => isEdit && (_jsx(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled }));
314
+ const renderDelete = () => isEdit && _jsx(Button, { icon: "delete", onClick: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }), disabled: disabled });
323
315
  // 操作列按钮-取消
324
316
  const renderCancel = () => isEdit && _jsx(Button, { icon: "dismiss", onClick: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) });
325
317
  // 操作列按钮-重新上传
@@ -334,7 +326,7 @@ const UploadFileAction = ({ status = 'UPLOAD_STATUS_PENDING', fileID = '', uuid
334
326
  case 'UPLOAD_STATUS_LOADING':
335
327
  return renderCancel();
336
328
  case 'UPLOAD_STATUS_SUCCESS':
337
- return (_jsxs(_Fragment, { children: [downloadVisible && !isWebInMiniprogram() && renderDownLoad(), ' ', deleteVisible && renderDelete()] }));
329
+ return (_jsxs(_Fragment, { children: [downloadVisible && !isWebInMiniprogram() && renderDownLoad(), " ", deleteVisible && renderDelete()] }));
338
330
  case 'UPLOAD_STATUS_ERROR':
339
331
  return (_jsxs(_Fragment, { children: [renderReLoad(), " ", deleteVisible && renderDelete()] }));
340
332
  default:
@@ -3,8 +3,8 @@ import * as React from 'react';
3
3
  import { Upload, ConfigProvider, Icon, List } from 'tea-component';
4
4
  import { WdButton } from '../../wd-button';
5
5
  import { WdText } from '../../wd-text';
6
- import { filterStrList, isCloudFileID, isHttpFileID, isDataUri, transSize, cutFileTitle, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, } from '../../../utils/platform';
7
- import { getCloudInstance } from '../../../utils/tcb';
6
+ import { filterStrList, isCloudFileID, isHttpFileID, isDataUri, transSize, cutFileTitle, transFileCloudidToName, randomStr, isInIde, isWebInMiniprogram, transFileName, alertErrorMessage, } from '../../../utils/platform';
7
+ import { getCloudInstance, getDefaultUploadPath } from '../../../utils/tcb';
8
8
  import classNames from '../../../utils/classnames';
9
9
  import { renderDecorator } from '../renderDecorator';
10
10
  import isObjectEqual from '../../../utils/isObjectEqual';
@@ -94,10 +94,9 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
94
94
  });
95
95
  // 批量上传文件前置事件
96
96
  const handleBefore = async (file, fileList, isAccepted, error) => {
97
- var _a, _b, _c, _d;
98
97
  if (fileList.length + fileIDList.length > maxUploadCount) {
99
- (_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
100
- title: `上传文件总数不能超过${maxUploadCount}个`,
98
+ alertErrorMessage({
99
+ message: `上传文件总数不能超过${maxUploadCount}个`,
101
100
  icon: 'error',
102
101
  });
103
102
  return Promise.reject(false);
@@ -111,8 +110,8 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
111
110
  if (error.find((item) => (item === null || item === void 0 ? void 0 : item.code) === 'file-too-large')) {
112
111
  errorList.push(`上传文件大小不能超过${maxSizeLimit}M`);
113
112
  }
114
- (_d = (_c = window === null || window === void 0 ? void 0 : window.$w) === null || _c === void 0 ? void 0 : _c.utils) === null || _d === void 0 ? void 0 : _d.showToast({
115
- title: errorList.join(', '),
113
+ alertErrorMessage({
114
+ message: errorList.join(', '),
116
115
  icon: 'error',
117
116
  });
118
117
  }
@@ -140,8 +139,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
140
139
  if (typeof ret === 'boolean') {
141
140
  shouldUploadToCos = ret;
142
141
  }
143
- else if (Array.isArray(ret) &&
144
- ret.every((item) => item instanceof File)) {
142
+ else if (Array.isArray(ret) && ret.every((item) => item instanceof File)) {
145
143
  fileList = ret;
146
144
  }
147
145
  else if (!isNil(ret)) {
@@ -184,9 +182,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
184
182
  };
185
183
  // 上传组件属性
186
184
  const uploadProps = { multiple: !single };
187
- if (!(!(acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.length) ||
188
- (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('*')) ||
189
- (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('')))) {
185
+ if (!(!(acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.length) || (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('*')) || (acceptTypes === null || acceptTypes === void 0 ? void 0 : acceptTypes.includes('')))) {
190
186
  uploadProps['accept'] = Array.from(new Set(acceptTypes));
191
187
  }
192
188
  tips && (uploadProps['title'] = tips);
@@ -208,10 +204,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
208
204
  isEdit,
209
205
  events,
210
206
  fileSizeObj,
211
- }, "data-testid": "button-up", children: _jsxs("div", { className: `${CLASS_PREFIX} ${readOnly ? `${CLASS_PREFIX}__readOnly` : ''}`, "data-testid": "UploadFilePc", children: [isEdit && (_jsx("div", { className: `${CLASS_PREFIX}__input-box`, children: btnDisabled ? (readOnly ? null : (_jsx(WdButton, { disabled: true, text: btnTitle, theme: "secondary", variant: "outline" }))) : (_jsxs(Upload, { ...uploadProps, beforeUpload: handleBefore, "data-testid": "Upload", children: [_jsx(WdButton, { className: `${CLASS_PREFIX}__btn--weak`, text: btnTitle, theme: "secondary", variant: "outline" }), !single && (_jsx(WdText, { text: uploadTipText, className: `${CLASS_PREFIX}__btn-descripe` }))] })) })), _jsxs(List, { split: "divide", children: [_jsx(List.Item, { children: _jsxs("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-header`, children: [_jsx("div", { className: `${CLASS_PREFIX}--item-title ${CLASS_PREFIX}--item-label`, children: "\u6587\u4EF6\u540D" }), formType !== 'read' && (_jsx("div", { className: `${CLASS_PREFIX}--item-size ${CLASS_PREFIX}--item-label`, children: "\u5927\u5C0F" })), _jsx("div", { className: `${CLASS_PREFIX}--item-status ${CLASS_PREFIX}--item-label`, children: "\u72B6\u6001" }), _jsx("div", { className: `${CLASS_PREFIX}--item-action ${CLASS_PREFIX}--item-label`, children: "\u64CD\u4F5C" })] }) }), fileIDList.map((d) => (_jsx(List.Item, { children: _jsx(TcbFileEcho, { disabled: disabled, fileID: d, formType: formType }) }, d))), fileList.map((item) => (_jsx(List.Item, { children: _jsx(TcbFileUpload, { disabled: disabled, file: item, formType: formType, id: id }) }, item === null || item === void 0 ? void 0 : item._uuid))), !readOnly &&
212
- isEdit &&
213
- fileIDList.length === 0 &&
214
- fileList.length === 0 && (_jsx(List.Item, { className: `${CLASS_PREFIX}--item-empty`, children: _jsxs("div", { className: `${CLASS_PREFIX}--item`, children: ["\u70B9\u51FB\u4E0A\u65B9\u201C", btnTitle, "\u201D\u6309\u94AE"] }) }))] })] }) }) }), decorator)({
207
+ }, "data-testid": "button-up", children: _jsxs("div", { className: `${CLASS_PREFIX} ${readOnly ? `${CLASS_PREFIX}__readOnly` : ''}`, "data-testid": "UploadFilePc", children: [isEdit && (_jsx("div", { className: `${CLASS_PREFIX}__input-box`, children: btnDisabled ? (readOnly ? null : (_jsx(WdButton, { disabled: true, text: btnTitle, theme: "secondary", variant: "outline" }))) : (_jsxs(Upload, { ...uploadProps, beforeUpload: handleBefore, "data-testid": "Upload", children: [_jsx(WdButton, { className: `${CLASS_PREFIX}__btn--weak`, text: btnTitle, theme: "secondary", variant: "outline" }), !single && _jsx(WdText, { text: uploadTipText, className: `${CLASS_PREFIX}__btn-descripe` })] })) })), _jsxs(List, { split: "divide", children: [_jsx(List.Item, { children: _jsxs("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-header`, children: [_jsx("div", { className: `${CLASS_PREFIX}--item-title ${CLASS_PREFIX}--item-label`, children: "\u6587\u4EF6\u540D" }), formType !== 'read' && (_jsx("div", { className: `${CLASS_PREFIX}--item-size ${CLASS_PREFIX}--item-label`, children: "\u5927\u5C0F" })), _jsx("div", { className: `${CLASS_PREFIX}--item-status ${CLASS_PREFIX}--item-label`, children: "\u72B6\u6001" }), _jsx("div", { className: `${CLASS_PREFIX}--item-action ${CLASS_PREFIX}--item-label`, children: "\u64CD\u4F5C" })] }) }), fileIDList.map((d) => (_jsx(List.Item, { children: _jsx(TcbFileEcho, { disabled: disabled, fileID: d, formType: formType }) }, d))), fileList.map((item) => (_jsx(List.Item, { children: _jsx(TcbFileUpload, { disabled: disabled, file: item, formType: formType, id: id }) }, item === null || item === void 0 ? void 0 : item._uuid))), !readOnly && isEdit && fileIDList.length === 0 && fileList.length === 0 && (_jsx(List.Item, { className: `${CLASS_PREFIX}--item-empty`, children: _jsxs("div", { className: `${CLASS_PREFIX}--item`, children: ["\u70B9\u51FB\u4E0A\u65B9\u201C", btnTitle, "\u201D\u6309\u94AE"] }) }))] })] }) }) }), decorator)({
215
208
  id,
216
209
  className: cls,
217
210
  style,
@@ -224,7 +217,7 @@ acceptTypes = emptyArray, downloadVisible = true, deleteVisible = true, uploadPa
224
217
  /**
225
218
  * 基于 FileID 回显文件表格行组件
226
219
  */
227
- const TcbFileEcho = ({ fileID, disabled, formType, readOnly, }) => {
220
+ const TcbFileEcho = ({ fileID, disabled, formType, readOnly }) => {
228
221
  var _a;
229
222
  const { fileSizeObj } = React.useContext(FileContext) || {};
230
223
  const { data: src } = useTempUrl(fileID);
@@ -262,8 +255,9 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
262
255
  const tcb = await getCloudInstance();
263
256
  try {
264
257
  setStatus('0');
258
+ const _uploadPath = getDefaultUploadPath(uploadPath);
265
259
  const { fileID } = await tcb.uploadFile({
266
- cloudPath: `${uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
260
+ cloudPath: `${_uploadPath}/${randomStr()}-${(_a = file === null || file === void 0 ? void 0 : file.name) === null || _a === void 0 ? void 0 : _a.replace(filenameRegex, '-')}`,
267
261
  filePath: file,
268
262
  onUploadProgress: (progressEvent) => {
269
263
  let percent = 0;
@@ -272,8 +266,7 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
272
266
  setPercent(percent < 100 ? percent : 100);
273
267
  },
274
268
  });
275
- !cancelRef.current &&
276
- (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
269
+ !cancelRef.current && (onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, type: 'add', uuid, size, file }));
277
270
  setStatus('2');
278
271
  }
279
272
  catch (e) {
@@ -286,7 +279,7 @@ const TcbFileUpload = ({ id, file, disabled, formType }) => {
286
279
  events.error && events.error(e);
287
280
  }
288
281
  };
289
- return (_jsxs("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-body`, children: [_jsx("div", { className: `${CLASS_PREFIX}--item-title ${CLASS_PREFIX}--item-value`, title: title, children: cutFileTitle(title) }), formType !== 'read' && (_jsx("div", { className: `${CLASS_PREFIX}--item-size ${CLASS_PREFIX}--item-value`, children: size })), _jsx("div", { className: `${CLASS_PREFIX}--item-status ${CLASS_PREFIX}--item-value`, children: _jsx(UploadFileStatus, { status: status, percent: percent }) }), _jsx("div", { className: `${CLASS_PREFIX}--item-action ${CLASS_PREFIX}--item-value`, children: _jsx(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
282
+ return (_jsxs("div", { className: `${CLASS_PREFIX}--item ${CLASS_PREFIX}--item-body`, children: [_jsx("div", { className: `${CLASS_PREFIX}--item-title ${CLASS_PREFIX}--item-value`, title: title, children: cutFileTitle(title) }), formType !== 'read' && _jsx("div", { className: `${CLASS_PREFIX}--item-size ${CLASS_PREFIX}--item-value`, children: size }), _jsx("div", { className: `${CLASS_PREFIX}--item-status ${CLASS_PREFIX}--item-value`, children: _jsx(UploadFileStatus, { status: status, percent: percent }) }), _jsx("div", { className: `${CLASS_PREFIX}--item-action ${CLASS_PREFIX}--item-value`, children: _jsx(UploadFileAction, { file: file, uuid: file === null || file === void 0 ? void 0 : file._uuid, status: status, onCancel: (uuid) => {
290
283
  cancelRef.current = uuid;
291
284
  onChange === null || onChange === void 0 ? void 0 : onChange({ type: 'delete', uuid });
292
285
  }, disabled: disabled, onReLoad: handleUpload, readOnly: formType === 'read' }) })] }));
@@ -312,7 +305,7 @@ const UploadFileAction = ({ title = 'downfile', status = '0', fileID = '', uuid
312
305
  deleteVisible &&
313
306
  !readOnly && (_jsx(WdButton, { text: "\u5220\u9664", size: "sm", variant: "link", disabled: disabled, events: { tap: () => onChange === null || onChange === void 0 ? void 0 : onChange({ fileID, uuid, type: 'delete' }) } }));
314
307
  // 操作列按钮-取消
315
- const renderCancel = () => isEdit && (_jsx(WdButton, { events: { tap: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) }, variant: "link", text: "\u53D6\u6D88", size: "sm" }));
308
+ const renderCancel = () => isEdit && _jsx(WdButton, { events: { tap: () => onCancel === null || onCancel === void 0 ? void 0 : onCancel(uuid) }, variant: "link", text: "\u53D6\u6D88", size: "sm" });
316
309
  // 操作列按钮-重新上传
317
310
  const renderReLoad = () => isEdit && (_jsx(WdButton, { text: "\u91CD\u65B0\u4E0A\u4F20", size: "sm", variant: "link", events: {
318
311
  tap: () => {
@@ -53,16 +53,18 @@
53
53
  padding-top: 1px;
54
54
  }
55
55
 
56
- .weda-list-view__container .weda-list-view__more div.weda-list-view__more-text {
56
+ .weda-list-view__container .weda-list-view__more .weda-list-view__more-text {
57
57
  padding-top: 8px;
58
58
  padding-bottom: 8px;
59
59
  font-size: 12px;
60
60
  line-height: 18px;
61
- color: rgba(0, 0, 0, 0.26);
62
61
  text-align: center;
63
62
  box-sizing: border-box;
64
63
  cursor: pointer;
65
64
  }
65
+ .weda-list-view__container .weda-list-view__more-text {
66
+ color: rgba(0, 0, 0, 0.26);
67
+ }
66
68
 
67
69
  .weda-list-view__container .weda-list-view__more .weda-list-view__more-text.h5 {
68
70
  font-size: 14px;