@cloudbase/weda-ui 3.16.0 → 3.17.1
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/configs/components/container.js +0 -3
- package/dist/configs/components/wd-ad.d.ts +10 -1
- package/dist/configs/components/wd-ad.js +31 -1
- package/dist/configs/components/wd-cascader.d.ts +4 -0
- package/dist/configs/components/wd-checkbox.d.ts +4 -0
- package/dist/configs/components/wd-code-editor.d.ts +4 -0
- package/dist/configs/components/wd-date-range.d.ts +4 -0
- package/dist/configs/components/wd-date.d.ts +4 -0
- package/dist/configs/components/wd-department.d.ts +6 -0
- package/dist/configs/components/wd-department.js +1 -1
- package/dist/configs/components/wd-form-arr.d.ts +4 -0
- package/dist/configs/components/wd-form-detail.d.ts +4 -0
- package/dist/configs/components/wd-form-obj.d.ts +4 -0
- package/dist/configs/components/wd-input-email.d.ts +4 -0
- package/dist/configs/components/wd-input-number.d.ts +4 -0
- package/dist/configs/components/wd-input-phone.d.ts +4 -0
- package/dist/configs/components/wd-input-url.d.ts +4 -0
- package/dist/configs/components/wd-input.d.ts +4 -0
- package/dist/configs/components/wd-location.d.ts +4 -0
- package/dist/configs/components/wd-member.d.ts +4 -0
- package/dist/configs/components/wd-radio.d.ts +4 -0
- package/dist/configs/components/wd-rating.d.ts +4 -0
- package/dist/configs/components/wd-region.d.ts +4 -0
- package/dist/configs/components/wd-rich-text.d.ts +4 -0
- package/dist/configs/components/wd-select-multiple.d.ts +4 -0
- package/dist/configs/components/wd-select.d.ts +4 -0
- package/dist/configs/components/wd-switch.d.ts +4 -0
- package/dist/configs/components/wd-table.d.ts +1 -1
- package/dist/configs/components/wd-table.js +1 -1
- package/dist/configs/components/wd-tag-select.d.ts +4 -0
- package/dist/configs/components/wd-tag.d.ts +4 -0
- package/dist/configs/components/wd-textarea.d.ts +4 -0
- package/dist/configs/components/wd-time.d.ts +4 -0
- package/dist/configs/components/wd-upload-file.d.ts +4 -0
- package/dist/configs/components/wd-upload-image.d.ts +207 -15
- package/dist/configs/components/wd-upload-image.js +143 -6
- package/dist/configs/components/web-view.js +1 -1
- package/dist/configs/index.d.ts +522 -8
- package/dist/configs/type-utils/type-form.d.ts +4 -0
- package/dist/configs/type-utils/type-form.js +4 -0
- package/dist/configs/type-utils/x-runtime-default.d.ts +2 -0
- package/dist/configs/type-utils/x-runtime-default.js +2 -0
- package/dist/configs/utils/field.d.ts +1 -0
- package/dist/configs/utils/field.js +95 -0
- package/dist/style/weda-ui.min.css +1 -1
- package/dist/web/components/form/uploader/index.d.ts +1 -0
- package/dist/web/components/form/uploader/index.js +7 -4
- package/dist/web/components/form/uploader/upload/index.d.ts +26 -0
- package/dist/web/components/form/uploader/upload/index.js +200 -0
- package/dist/web/components/form/uploader/uploader.h5.d.ts +6 -1
- package/dist/web/components/form/uploader/uploader.h5.js +26 -94
- package/dist/web/components/form/uploader/uploader.pc.d.ts +1 -1
- package/dist/web/components/form/uploader/uploader.pc.js +30 -100
- package/dist/web/components/form/uploader/util.d.ts +16 -0
- package/dist/web/components/form/uploader/util.js +106 -5
- package/dist/web/components/richText/index.js +3 -1
- package/dist/web/components/uploaderView/index.js +1 -1
- package/dist/web/components/wd-ad/wd-ad.js +2 -4
- package/dist/web/components/wd-form/hooks/use-remote-value.js +18 -18
- package/dist/web/components/wd-modal/wd-modal.js +10 -13
- package/dist/web/components/wd-upload-image/wd-upload-image.js +14 -4
- package/package.json +5 -5
- package/dist/web/components/form/uploader/useUploadFile.d.ts +0 -16
- package/dist/web/components/form/uploader/useUploadFile.js +0 -99
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const CLASS_PREFIX = "weda-uploader-pc";
|
|
2
|
-
export declare const IMAGE_TYPES: string[];
|
|
3
|
-
interface TempFileProps {
|
|
4
|
-
progress?: number;
|
|
5
|
-
loading?: boolean;
|
|
6
|
-
realUrl?: string;
|
|
7
|
-
tempUrl?: string;
|
|
8
|
-
key?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function useUploader(props: any): {
|
|
11
|
-
tempFile: TempFileProps[];
|
|
12
|
-
uploading: boolean;
|
|
13
|
-
upload: (fileList: any) => Promise<any[]>;
|
|
14
|
-
getTempFile: (allFile?: any[]) => any[];
|
|
15
|
-
};
|
|
16
|
-
export {};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { randomStr } from '../../../utils/platform';
|
|
3
|
-
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
4
|
-
import { getBase64, uploadTcbMulti } from './util';
|
|
5
|
-
// 默认组件类前缀
|
|
6
|
-
export const CLASS_PREFIX = 'weda-uploader-pc';
|
|
7
|
-
// 默认图片类型
|
|
8
|
-
export const IMAGE_TYPES = [
|
|
9
|
-
'image/jpg',
|
|
10
|
-
'image/png',
|
|
11
|
-
'image/tif',
|
|
12
|
-
'image/bmp',
|
|
13
|
-
'image/jpeg',
|
|
14
|
-
'image/tiff',
|
|
15
|
-
'image/gif',
|
|
16
|
-
];
|
|
17
|
-
const getInitTempFile = ({ single, value, defaultValue, uploadPath }) => {
|
|
18
|
-
let initialValue = []
|
|
19
|
-
.concat(value ? value : defaultValue)
|
|
20
|
-
.filter((d) => typeof d === 'string' && d !== '');
|
|
21
|
-
if (single) {
|
|
22
|
-
initialValue = initialValue[0] ? [initialValue[0]] : [];
|
|
23
|
-
}
|
|
24
|
-
const tempFile = initialValue.map((i) => ({
|
|
25
|
-
key: randomStr(),
|
|
26
|
-
uploadPath,
|
|
27
|
-
realUrl: i,
|
|
28
|
-
tempUrl: '',
|
|
29
|
-
progress: 100,
|
|
30
|
-
loading: false,
|
|
31
|
-
}));
|
|
32
|
-
return tempFile;
|
|
33
|
-
};
|
|
34
|
-
export function useUploader(props) {
|
|
35
|
-
const { defaultValue, // 需要兼容 cloud:和https: 协议,需要兼容 字符串和字符串数组
|
|
36
|
-
uploadPath = 'weda-uploader', events, single = false, value, // 数据管理后台中,formily使用此字段传默认值
|
|
37
|
-
isCompressBeforeUpload, compressQuality, compressedHeight, compressedWidth, } = props;
|
|
38
|
-
// 上传中
|
|
39
|
-
const [uploading, setUploading] = React.useState(false);
|
|
40
|
-
// 文件列表
|
|
41
|
-
const [tempFile, setTempFile] = React.useState(() => {
|
|
42
|
-
return getInitTempFile(props);
|
|
43
|
-
});
|
|
44
|
-
const defaultValueRef = React.useRef(null);
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
if (isObjectEqual(defaultValueRef.current, defaultValue))
|
|
47
|
-
return;
|
|
48
|
-
const tempFile = getInitTempFile({
|
|
49
|
-
single,
|
|
50
|
-
value,
|
|
51
|
-
defaultValue,
|
|
52
|
-
uploadPath,
|
|
53
|
-
});
|
|
54
|
-
defaultValueRef.current = defaultValue;
|
|
55
|
-
setTempFile(tempFile);
|
|
56
|
-
}, [defaultValue, single, uploadPath, value]);
|
|
57
|
-
// 方法:上传前,判断图片大小、数量是否满足,取消默认组件的上传事件,用自定义的 tcb 上传方法
|
|
58
|
-
const upload = async (fileList) => {
|
|
59
|
-
let tempFiles = fileList.map((i) => ({
|
|
60
|
-
file: i,
|
|
61
|
-
key: randomStr(),
|
|
62
|
-
uploadPath,
|
|
63
|
-
progress: 0,
|
|
64
|
-
loading: true,
|
|
65
|
-
}));
|
|
66
|
-
tempFiles = await getBase64(tempFiles);
|
|
67
|
-
const allTempFile = [...tempFile, ...tempFiles];
|
|
68
|
-
setTempFile(allTempFile);
|
|
69
|
-
setUploading(true);
|
|
70
|
-
const result = await uploadTcbMulti(tempFiles, {
|
|
71
|
-
isCompressBeforeUpload,
|
|
72
|
-
compressedHeight,
|
|
73
|
-
compressedWidth,
|
|
74
|
-
compressQuality,
|
|
75
|
-
onUploadProgress: (item) => {
|
|
76
|
-
setTempFile((allTempFile) => allTempFile.map((i) => (i.key === item.key ? { ...i, ...item } : i)));
|
|
77
|
-
},
|
|
78
|
-
onUploadFinish: (item) => {
|
|
79
|
-
var _a;
|
|
80
|
-
(_a = events === null || events === void 0 ? void 0 : events.success) === null || _a === void 0 ? void 0 : _a.call(events, { value: item.realUrl, file: item.file });
|
|
81
|
-
setUploading(false);
|
|
82
|
-
setTempFile((allTempFile) => allTempFile.map((i) => (i.key === item.key ? { ...i, ...item } : i)));
|
|
83
|
-
},
|
|
84
|
-
onUploadError: (err) => {
|
|
85
|
-
events.error && events.error(err);
|
|
86
|
-
setUploading(false);
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
const allFile = allTempFile.map((i) => result.find((j) => (j === null || j === void 0 ? void 0 : j.key) === (i === null || i === void 0 ? void 0 : i.key)) || i);
|
|
90
|
-
return allFile;
|
|
91
|
-
};
|
|
92
|
-
const getTempFile = (allFile = []) => {
|
|
93
|
-
setTempFile(allFile);
|
|
94
|
-
let value = allFile.map((i) => i === null || i === void 0 ? void 0 : i.realUrl).filter((j) => !!j);
|
|
95
|
-
value = single ? value[0] || '' : value;
|
|
96
|
-
return value;
|
|
97
|
-
};
|
|
98
|
-
return { tempFile, uploading, upload, getTempFile };
|
|
99
|
-
}
|