@cloudbase/weda-ui 0.2.10 → 0.2.14
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/CHANGELOG.md +240 -0
- package/package.json +61 -40
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/configs/components/button.json +7 -3
- package/src/configs/components/form/richText.json +1 -1
- package/src/configs/components/form/uploader.json +29 -1
- package/src/configs/components/form/uploaderFile.json +158 -0
- package/src/configs/components/image.json +12 -3
- package/src/configs/components/link.json +3 -3
- package/src/configs/components/richtextview.json +2 -2
- package/src/configs/components/scrollVeiw.json +5 -5
- package/src/configs/components/swiper.json +6 -6
- package/src/configs/components/tabs.json +3 -3
- package/src/configs/components/text.json +39 -4
- package/src/configs/index.js +5 -3
- package/src/mp/.gitignore +10 -0
- package/src/mp/components/button/index.js +1 -0
- package/src/mp/components/button/index.wxss +8 -0
- package/src/mp/components/form/select/index.js +18 -0
- package/src/mp/components/form/uploader/index.js +26 -29
- package/src/mp/components/form/uploaderFile/index.js +233 -0
- package/src/mp/components/form/uploaderFile/index.json +9 -0
- package/src/mp/components/form/uploaderFile/index.wxml +46 -0
- package/src/mp/components/form/uploaderFile/index.wxss +105 -0
- package/src/mp/components/text/index.js +33 -0
- package/src/mp/components/text/index.wxml +1 -1
- package/src/mp/components/text/index.wxss +18 -0
- package/src/mp/index.json +1 -0
- package/src/mp/utils/platform.js +20 -0
- package/src/mp/utils/tcb.js +11 -0
- package/src/web/.DS_Store +0 -0
- package/src/web/actions/showModal/{index.jsx → index.tsx} +53 -3
- package/src/web/components/auth/index.js +2 -2
- package/src/web/components/button/index.css +9 -0
- package/src/web/components/button/{index.jsx → index.tsx} +27 -41
- package/src/web/components/container/{index.jsx → index.tsx} +6 -10
- package/src/web/components/drawer/index.tsx +57 -0
- package/src/web/components/form/checkbox/{index.jsx → index.tsx} +24 -48
- package/src/web/components/form/enumSelect/MultipleSelect.jsx +1 -6
- package/src/web/components/form/enumSelect/{NormalSelect.jsx → NormalSelect.tsx} +3 -14
- package/src/web/components/form/form/index.tsx +48 -0
- package/src/web/components/form/formcell/{index.jsx → index.tsx} +6 -13
- package/src/web/components/form/input/index.css +39 -0
- package/src/web/components/form/input/{index.jsx → index.tsx} +33 -67
- package/src/web/components/form/radio/{index.jsx → index.tsx} +19 -42
- package/src/web/components/form/{renderDecorator.jsx → renderDecorator.tsx} +1 -3
- package/src/web/components/form/select/{h5.jsx → h5.tsx} +18 -62
- package/src/web/components/form/select/{index.jsx → index.tsx} +51 -94
- package/src/web/components/form/select/region/{cities.js → cities.ts} +1 -1
- package/src/web/components/form/select/region/{index.js → index.ts} +3 -3
- package/src/web/components/form/select/region/{provinces.js → provinces.ts} +1 -1
- package/src/web/components/form/select/region/{regions.js → regions.ts} +1 -1
- package/src/web/components/form/select/time.jsx +2 -2
- package/src/web/components/form/switch/{index.jsx → index.tsx} +30 -47
- package/src/web/components/form/textarea/{index.jsx → index.tsx} +22 -55
- package/src/web/components/form/tips/{index.jsx → index.tsx} +8 -22
- package/src/web/components/form/types.d.ts +12 -0
- package/src/web/components/form/uploader/{index.jsx → index.tsx} +16 -14
- package/src/web/components/form/uploader/{uploader.h5.jsx → uploader.h5.tsx} +67 -57
- package/src/web/components/form/uploader/{uploader.pc.jsx → uploader.pc.tsx} +26 -43
- package/src/web/components/form/uploaderFile/fail.svg +12 -0
- package/src/web/components/form/uploaderFile/index.css +423 -0
- package/src/web/components/form/uploaderFile/index.jsx +30 -0
- package/src/web/components/form/uploaderFile/pending.svg +18 -0
- package/src/web/components/form/uploaderFile/success.svg +12 -0
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +578 -0
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +507 -0
- package/src/web/components/image/{image.jsx → image.tsx} +8 -21
- package/src/web/components/image/{index.jsx → index.tsx} +22 -37
- package/src/web/components/index.js +36 -1
- package/src/web/components/link/{index.jsx → index.tsx} +19 -36
- package/src/web/components/modal/{index.jsx → index.tsx} +22 -9
- package/src/web/components/picker/{datePicker.jsx → datePicker.tsx} +11 -12
- package/src/web/components/picker/{picker.jsx → picker.tsx} +7 -10
- package/src/web/components/picker/{timePicker.jsx → timePicker.tsx} +8 -16
- package/src/web/components/richText/{const.js → const.ts} +0 -0
- package/src/web/components/richText/index.jsx +5 -2
- package/src/web/components/richTextView/index.tsx +67 -0
- package/src/web/components/scrollView/{index.jsx → index.tsx} +18 -33
- package/src/web/components/slot/{index.jsx → index.tsx} +8 -9
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/{index.jsx → index.tsx} +73 -78
- package/src/web/components/tabs/index.tsx +33 -0
- package/src/web/components/tabs/{tabs.h5.jsx → tabs.h5.tsx} +4 -33
- package/src/web/components/tabs/{tabs.pc.jsx → tabs.pc.tsx} +5 -39
- package/src/web/components/text/index.css +18 -0
- package/src/web/components/text/index.tsx +69 -0
- package/src/web/components/uploaderFileView/index.css +11 -0
- package/src/web/components/uploaderFileView/index.jsx +75 -0
- package/src/web/components/uploaderView/{index.jsx → index.tsx} +12 -15
- package/src/web/types.d.ts +20 -0
- package/src/web/utils/constant.js +2 -0
- package/src/web/utils/loading-fallback.tsx +2 -0
- package/src/web/utils/platform.js +77 -6
- package/src/web/utils/tcb.js +0 -8
- package/src/web/utils/useSetState.ts +14 -0
- package/src/web/utils/useSyncValue.ts +17 -0
- package/src/web/wedatheme/.git +1 -0
- package/src/web/wedatheme/.gitignore +5 -0
- package/src/web/wedatheme/.npmrc +1 -0
- package/src/web/wedatheme/package-lock.json +14335 -0
- package/src/configs/components/button.svg +0 -18
- package/src/web/components/drawer/index.jsx +0 -64
- package/src/web/components/form/enumSelect/hooks/index.js +0 -49
- package/src/web/components/form/form/index.jsx +0 -76
- package/src/web/components/link/test/__snapshots__/storybook.test.js.snap +0 -754
- package/src/web/components/richTextView/index.jsx +0 -89
- package/src/web/components/tabs/index.jsx +0 -10
- package/src/web/components/text/index.jsx +0 -71
- package/src/web/utils/useSyncValue.js +0 -14
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import * as PropTypes from 'prop-types';
|
|
4
3
|
import { usePlatform } from '../../../utils/platform';
|
|
5
4
|
import { ImageUploaderH5 as UploaderH5 } from './uploader.h5';
|
|
6
5
|
import classNames from '../../../utils/classnames';
|
|
@@ -28,16 +27,19 @@ function UploaderPc(props) {
|
|
|
28
27
|
const cls = classNames({
|
|
29
28
|
'weda-ui': true,
|
|
30
29
|
[className]: className,
|
|
31
|
-
|
|
30
|
+
cloudbase_standard: true,
|
|
32
31
|
});
|
|
33
32
|
return renderDecorator(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
<UploaderPCInner
|
|
34
|
+
{...restProps}
|
|
35
|
+
style={{
|
|
36
|
+
height: '100%',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
}}
|
|
40
|
+
/>,
|
|
41
|
+
decorator
|
|
42
|
+
)({
|
|
41
43
|
id,
|
|
42
44
|
className: cls,
|
|
43
45
|
style,
|
|
@@ -55,9 +57,9 @@ export default function Uploader(props) {
|
|
|
55
57
|
if (props?.showType === 'h5') {
|
|
56
58
|
return <UploaderH5 {...props} />;
|
|
57
59
|
}
|
|
58
|
-
return platform === 'h5' ?
|
|
60
|
+
return platform === 'h5' ? (
|
|
61
|
+
<UploaderH5 {...props} />
|
|
62
|
+
) : (
|
|
63
|
+
<UploaderPc {...props} />
|
|
64
|
+
);
|
|
59
65
|
}
|
|
60
|
-
|
|
61
|
-
Uploader.propTypes = {
|
|
62
|
-
showType: PropTypes.string, // 强制展示某个平台 pc | h5
|
|
63
|
-
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as PropTypes from 'prop-types';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import weui from '../../../utils/weui';
|
|
4
3
|
import classNames from '../../../utils/classnames';
|
|
@@ -7,6 +6,7 @@ import isObjectEqual from '../../../utils/isObjectEqual';
|
|
|
7
6
|
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
8
7
|
import { isCloudFileID } from '../../../utils/platform';
|
|
9
8
|
import { IMAGE_TYPES } from './uploader.pc';
|
|
9
|
+
import { CommonFormPropsType } from '../types';
|
|
10
10
|
|
|
11
11
|
const uploadPath = 'weda-uploader';
|
|
12
12
|
/**
|
|
@@ -23,9 +23,10 @@ export function ImageUploaderH5({
|
|
|
23
23
|
layout,
|
|
24
24
|
defaultValue,
|
|
25
25
|
single = false,
|
|
26
|
+
requiredFlag = false,
|
|
26
27
|
onChange,
|
|
27
28
|
style,
|
|
28
|
-
}) {
|
|
29
|
+
}: H5UploaderProps) {
|
|
29
30
|
const cls = classNames({
|
|
30
31
|
'weda-ui': true,
|
|
31
32
|
'weui-cells': true,
|
|
@@ -39,27 +40,28 @@ export function ImageUploaderH5({
|
|
|
39
40
|
const [progress, setProgress] = React.useState(0);
|
|
40
41
|
const [inputValue, setInputValue] = useSyncValue(defaultValue, isObjectEqual);
|
|
41
42
|
const fileIdList = React.useMemo(() => {
|
|
42
|
-
if(
|
|
43
|
+
if (typeof inputValue === 'string') {
|
|
43
44
|
// single = true 传入的是字符串
|
|
44
|
-
return [inputValue].filter(i => i.length > 0); // 排除空串
|
|
45
|
+
return [inputValue].filter((i) => i.length > 0); // 排除空串
|
|
45
46
|
}
|
|
46
|
-
if(Array.isArray(inputValue)) {
|
|
47
|
+
if (Array.isArray(inputValue)) {
|
|
47
48
|
return inputValue;
|
|
48
49
|
}
|
|
49
50
|
return [];
|
|
50
51
|
}, [inputValue]);
|
|
51
52
|
|
|
52
53
|
const finalMaxImgCount = React.useMemo(() => {
|
|
53
|
-
if(single) return 1;
|
|
54
|
+
if (single) return 1;
|
|
54
55
|
return maxUploadCount;
|
|
55
56
|
}, [single, maxUploadCount]);
|
|
56
|
-
|
|
57
|
+
|
|
57
58
|
const deleteFile = (url) => {
|
|
58
|
-
if(single) {
|
|
59
|
+
if (single) {
|
|
59
60
|
setInputValue('');
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
// @ts-expect-error list should be array in not single mode
|
|
64
|
+
setInputValue((list: string[]) => list.filter((f) => f !== url));
|
|
63
65
|
};
|
|
64
66
|
React.useEffect(() => {
|
|
65
67
|
if (single) {
|
|
@@ -91,8 +93,8 @@ export function ImageUploaderH5({
|
|
|
91
93
|
cloudPath,
|
|
92
94
|
filePath: file,
|
|
93
95
|
onUploadProgress: onProgress,
|
|
94
|
-
|
|
95
96
|
});
|
|
97
|
+
// @ts-expect-error TODO
|
|
96
98
|
fileID && setInputValue((list) => [...list, fileID]);
|
|
97
99
|
fileID && events.success && events.success({ value: fileID, file });
|
|
98
100
|
} catch (err) {
|
|
@@ -114,8 +116,11 @@ export function ImageUploaderH5({
|
|
|
114
116
|
<div className={cls} id={id} style={style}>
|
|
115
117
|
<div className="weui-cell">
|
|
116
118
|
<div className="weui-cell__bd">
|
|
117
|
-
<div className={classNames(
|
|
118
|
-
<div className={classNames(
|
|
119
|
+
<div className={classNames('weui-uploader', layout)}>
|
|
120
|
+
<div className={classNames('weui-uploader__hd', layout)}>
|
|
121
|
+
{requiredFlag && (
|
|
122
|
+
<label className="weda-formcells__flag">*</label>
|
|
123
|
+
)}
|
|
119
124
|
<p className="weui-uploader__title">{title}</p>
|
|
120
125
|
<div className="weui-uploader__info">
|
|
121
126
|
<span id="uploadCount">{fileIdList.length}</span>
|
|
@@ -124,40 +129,45 @@ export function ImageUploaderH5({
|
|
|
124
129
|
</div>
|
|
125
130
|
<div className="weui-uploader__bd">
|
|
126
131
|
<ul className="weui-uploader__files" id="uploaderFiles">
|
|
127
|
-
{(fileIdList ?? []).map(f =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
{(fileIdList ?? []).map((f) => (
|
|
133
|
+
<SingleImage key={f} src={f} deleteBySrc={deleteFile} />
|
|
134
|
+
))}
|
|
135
|
+
{uploading && (
|
|
136
|
+
<li className="weui-uploader__file weui-uploader__file_status">
|
|
137
|
+
<div className="weui-uploader__file-content">
|
|
138
|
+
{progress}%
|
|
139
|
+
</div>
|
|
140
|
+
</li>
|
|
141
|
+
)}
|
|
134
142
|
</ul>
|
|
135
143
|
{(fileIdList.length < maxUploadCount ||
|
|
136
144
|
(single && fileIdList.length < 1)) && ( // single 模式时,仅当数组为空时显示
|
|
137
|
-
|
|
145
|
+
<div className="weui-uploader__input-box">
|
|
138
146
|
<input
|
|
139
147
|
id="uploaderInput"
|
|
140
148
|
className="weui-uploader__input"
|
|
141
149
|
type="file"
|
|
142
150
|
accept={accepts.join(',')}
|
|
143
151
|
multiple
|
|
144
|
-
onChange={e => {
|
|
152
|
+
onChange={(e) => {
|
|
145
153
|
const files = [...e.target.files];
|
|
146
|
-
if (files.some(f => f.size > maxSize * 1024 * 1024)) {
|
|
154
|
+
if (files.some((f) => f.size > maxSize * 1024 * 1024)) {
|
|
147
155
|
weui.alert('请上传不超过10M的图片');
|
|
148
156
|
return false;
|
|
149
157
|
}
|
|
150
|
-
|
|
158
|
+
|
|
151
159
|
if (files.length > finalMaxImgCount) {
|
|
152
160
|
// 防止一下子选择过多文件
|
|
153
|
-
weui.alert(
|
|
161
|
+
weui.alert(
|
|
162
|
+
`最多只能上传${finalMaxImgCount}张图片,请重新选择`
|
|
163
|
+
);
|
|
154
164
|
return false;
|
|
155
165
|
}
|
|
156
166
|
if (fileIdList.length + files.length > finalMaxImgCount) {
|
|
157
167
|
weui.alert(`最多只能上传${finalMaxImgCount}张图片`);
|
|
158
168
|
return false;
|
|
159
169
|
}
|
|
160
|
-
files.forEach(f => uploadToTcb(f));
|
|
170
|
+
files.forEach((f) => uploadToTcb(f));
|
|
161
171
|
}}
|
|
162
172
|
/>
|
|
163
173
|
</div>
|
|
@@ -170,7 +180,12 @@ export function ImageUploaderH5({
|
|
|
170
180
|
);
|
|
171
181
|
}
|
|
172
182
|
|
|
173
|
-
|
|
183
|
+
export interface SingleImageProps {
|
|
184
|
+
src: string;
|
|
185
|
+
deleteBySrc: (url: string) => void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function SingleImage({ src, deleteBySrc }: SingleImageProps) {
|
|
174
189
|
const [error, setError] = React.useState(false);
|
|
175
190
|
const cls = classNames({
|
|
176
191
|
'weui-uploader__file': true,
|
|
@@ -187,51 +202,46 @@ function SingleImage({src, deleteBySrc}) {
|
|
|
187
202
|
console.error('图片加载失败');
|
|
188
203
|
}
|
|
189
204
|
};
|
|
190
|
-
if(isCloudFileID(src)) {
|
|
205
|
+
if (isCloudFileID(src)) {
|
|
191
206
|
getSrc();
|
|
192
207
|
} else {
|
|
193
208
|
setRealSrc(src);
|
|
194
209
|
}
|
|
195
210
|
}, [src]);
|
|
196
211
|
const imgStyle = {
|
|
197
|
-
backgroundImage: `url(${realSrc})
|
|
198
|
-
};
|
|
212
|
+
backgroundImage: `url(${realSrc})`,
|
|
213
|
+
};
|
|
199
214
|
const showGallery = () => {
|
|
200
215
|
const gallery = weui.gallery(realSrc, {
|
|
201
|
-
onDelete: function() {
|
|
216
|
+
onDelete: function () {
|
|
202
217
|
deleteBySrc(src);
|
|
203
218
|
gallery.hide();
|
|
204
|
-
}
|
|
219
|
+
},
|
|
205
220
|
});
|
|
206
221
|
};
|
|
207
|
-
|
|
222
|
+
|
|
208
223
|
return (
|
|
209
224
|
<li className={cls} style={imgStyle} onClick={showGallery}>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
:
|
|
216
|
-
|
|
225
|
+
{error || status ? (
|
|
226
|
+
<div className="weui-uploader__file-content">
|
|
227
|
+
{error ? (
|
|
228
|
+
<i role="img" aria-label="错误" className="weui-icon-warn"></i>
|
|
229
|
+
) : (
|
|
230
|
+
<i className="weui-loading" style={{ width: 30, height: 30 }}></i>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
) : (
|
|
234
|
+
false
|
|
235
|
+
)}
|
|
217
236
|
</li>
|
|
218
237
|
);
|
|
219
238
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
acceptTypes: PropTypes.array,
|
|
230
|
-
maxUploadCount: PropTypes.number, // 【上传图片最大数量】
|
|
231
|
-
events: PropTypes.objectOf(PropTypes.func), // 事件
|
|
232
|
-
style: PropTypes.object,
|
|
233
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
234
|
-
defaultValue: PropTypes.oneOfType([PropTypes.array, PropTypes.string]), // 初始值,该参数需配合 formily 使用
|
|
235
|
-
single: PropTypes.bool, // 单张上传还是多张上传,对应 onChange 参数为字符串还是字符串数组,value 在处理过程统一转为字符串数组
|
|
236
|
-
onChange: PropTypes.objectOf(PropTypes.func), // 值变化,该参数需配合 formily 使用
|
|
237
|
-
};
|
|
239
|
+
export interface H5UploaderProps extends CommonFormPropsType {
|
|
240
|
+
title?: string;
|
|
241
|
+
maxSize?: number;
|
|
242
|
+
acceptTypes?: unknown[];
|
|
243
|
+
maxUploadCount?: number;
|
|
244
|
+
defaultValue?: string[] | string; // 初始值,该参数需配合 formily 使用;
|
|
245
|
+
single?: boolean; // 单张上传还是多张上传,对应 onChange 参数为字符串还是字符串数组,value 在处理过程统一转为字符串数组;
|
|
246
|
+
onChange?: (v: any) => void;
|
|
247
|
+
}
|
|
@@ -13,7 +13,7 @@ import classNames from '../../../utils/classnames';
|
|
|
13
13
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
14
14
|
import { isCloudFileID } from '../../../utils/platform';
|
|
15
15
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
16
|
-
import
|
|
16
|
+
import { H5UploaderProps } from './uploader.h5';
|
|
17
17
|
|
|
18
18
|
// 默认组件类前缀
|
|
19
19
|
export const CLASS_PREFIX = 'weda-uploader-pc';
|
|
@@ -80,30 +80,28 @@ export function UploaderPCInner(props) {
|
|
|
80
80
|
const [progress, setProgress] = React.useState(0);
|
|
81
81
|
// 文件列表
|
|
82
82
|
const [fileIDList, setfileIDList] = React.useState([]);
|
|
83
|
-
const
|
|
83
|
+
const fileRef = React.useRef(fileIDList);
|
|
84
|
+
|
|
84
85
|
React.useEffect(() => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
initialValue = initialValue[0] ? [initialValue[0]] : [];
|
|
91
|
-
}
|
|
92
|
-
setfileIDList(initialValue);
|
|
93
|
-
prevValueRef.current = defaultValue;
|
|
86
|
+
let initialValue = []
|
|
87
|
+
.concat(defaultValue)
|
|
88
|
+
.filter((d) => typeof d === 'string' && d !== '');
|
|
89
|
+
if (single) {
|
|
90
|
+
initialValue = initialValue[0] ? [initialValue[0]] : [];
|
|
94
91
|
}
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
setfileIDList(initialValue);
|
|
93
|
+
}, []);
|
|
97
94
|
|
|
98
95
|
// 值变化事件
|
|
99
96
|
React.useEffect(() => {
|
|
100
97
|
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
101
|
-
events.change && events.change({ value: fileIDList });
|
|
102
98
|
if (single) {
|
|
103
99
|
const file = fileIDList[0] || '';
|
|
104
100
|
file && onChange && onChange(file);
|
|
101
|
+
events.change && events.change({ value: file });
|
|
105
102
|
} else {
|
|
106
103
|
onChange && onChange(fileIDList);
|
|
104
|
+
events.change && events.change({ value: fileIDList });
|
|
107
105
|
}
|
|
108
106
|
fileRef.current = fileIDList;
|
|
109
107
|
}
|
|
@@ -229,10 +227,12 @@ export function UploaderPCInner(props) {
|
|
|
229
227
|
);
|
|
230
228
|
}
|
|
231
229
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
export interface TcbImageProps {
|
|
231
|
+
fileID?: string; // 云存储id
|
|
232
|
+
isZoom?: boolean; // 是否点击放大
|
|
233
|
+
onError?: (e: any) => void; // 图片显示错误事件
|
|
234
|
+
}
|
|
235
|
+
export const TcbImage = (props: TcbImageProps) => {
|
|
236
236
|
const { fileID, isZoom, ...rest } = props;
|
|
237
237
|
const [src, setSrc] = React.useState('');
|
|
238
238
|
const [isError, setIsError] = React.useState(false);
|
|
@@ -258,6 +258,7 @@ export const TcbImage = (props) => {
|
|
|
258
258
|
{...rest}
|
|
259
259
|
src={src}
|
|
260
260
|
previewSrc={src}
|
|
261
|
+
/** @ts-expect-error tea imagepreview onError */
|
|
261
262
|
onError={(e) => {
|
|
262
263
|
setIsError(true);
|
|
263
264
|
props?.onError && props.onError(e);
|
|
@@ -279,28 +280,10 @@ export const TcbImage = (props) => {
|
|
|
279
280
|
) : null;
|
|
280
281
|
};
|
|
281
282
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
acceptTypes: PropTypes.array, // 官方属性:图片类型,TIF | BMP | JPEG | TIFF | PNG
|
|
290
|
-
uploadPath: PropTypes.string, // 上传路径
|
|
291
|
-
uploadFileName: PropTypes.string, // 上传文件名称
|
|
292
|
-
single: PropTypes.bool, // 单张上传还是多张上传,对应 onChange 参数为字符串还是字符串数组,value 在处理过程统一转为字符串数组
|
|
293
|
-
events: PropTypes.objectOf(PropTypes.func), // 事件
|
|
294
|
-
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string]), // 初始值,该参数需配合 formily 使用
|
|
295
|
-
onChange: PropTypes.objectOf(PropTypes.func), // 值变化,该参数需配合 formily 使用
|
|
296
|
-
style: PropTypes.object,
|
|
297
|
-
id: PropTypes.string,
|
|
298
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
299
|
-
disabled: PropTypes.bool,
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
TcbImage.propTypes = {
|
|
303
|
-
fileID: PropTypes.string, // 云存储id
|
|
304
|
-
isZoom: PropTypes.bool, // 是否点击放大
|
|
305
|
-
onError: PropTypes.func, // 图片显示错误事件
|
|
306
|
-
};
|
|
283
|
+
export interface PropsType extends H5UploaderProps {
|
|
284
|
+
tips?: string;
|
|
285
|
+
value: string | string[];
|
|
286
|
+
btnTitle?: string;
|
|
287
|
+
uploadPath?: string;
|
|
288
|
+
uploadFileName?: string;
|
|
289
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="16px" height="16px" viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
3
|
+
<title>1.Bace基础/3.Icon图标/操作/move</title>
|
|
4
|
+
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
5
|
+
<g id="画板" transform="translate(-104.000000, -210.000000)">
|
|
6
|
+
<g id="1.Bace基础/3.Icon图标/操作/move" transform="translate(103.000000, 209.000000)">
|
|
7
|
+
<path d="M0,0 L16,0 L16,16 L0,16 L0,0 Z" id="close-circle-filled-(Background)"></path>
|
|
8
|
+
<path d="M8,1 C4.13400912,1 1,4.13400483 1,8 C1,11.8659916 4.13400483,15 8,15 C11.8659916,15 15,11.8659954 15,8 C15,4.13400912 11.8659954,1 8,1 Z M8.00001192,7.29075146 L10.3291178,4.94753814 L11.0383558,5.65250731 L8.70499325,8 L11.0383472,10.3474894 L10.3291082,11.0524578 L8.00001144,8.70925426 L5.6709156,11.0524578 L4.9616766,10.3474884 L7.29503059,8 L4.96166778,5.65250683 L5.67090654,4.94753814 L8.00001192,7.29075146 Z" id="close-circle-filled" fill="#E34D59"></path>
|
|
9
|
+
</g>
|
|
10
|
+
</g>
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|