@douyinfe/semi-ui 2.1.4-alpha.0 → 2.2.0-beta.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.
- package/_base/_story/a11y.jsx +1302 -0
- package/_base/_story/a11y.scss +49 -0
- package/_base/_story/index.scss +1 -0
- package/_base/_story/index.stories.js +3 -1
- package/_utils/index.ts +2 -1
- package/button/Button.tsx +1 -0
- package/button/__test__/button.test.js +15 -0
- package/button/_story/button.stories.js +13 -0
- package/button/buttonGroup.tsx +6 -4
- package/cascader/__test__/cascader.test.js +221 -0
- package/cascader/_story/cascader.stories.js +138 -0
- package/cascader/index.tsx +37 -21
- package/cascader/item.tsx +7 -2
- package/checkbox/__test__/checkboxGroup.test.js +37 -5
- package/checkbox/_story/checkbox.stories.js +78 -6
- package/checkbox/checkbox.tsx +3 -0
- package/checkbox/checkboxGroup.tsx +3 -2
- package/datePicker/__test__/datePicker.test.js +67 -2
- package/datePicker/_story/datePicker.stories.js +3 -1
- package/datePicker/_story/v2/YearButton.jsx +17 -0
- package/datePicker/_story/v2/index.js +1 -0
- package/datePicker/monthsGrid.tsx +12 -1
- package/datePicker/navigation.tsx +55 -29
- package/descriptions/__test__/descriptions.test.js +27 -1
- package/descriptions/_story/descriptions.stories.js +52 -2
- package/descriptions/item.tsx +1 -1
- package/dist/css/semi.css +105 -32
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +801 -227
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/_story/form.stories.js +0 -67
- package/form/_story/form.stories.tsx +2 -2
- package/form/hoc/withField.tsx +2 -2
- package/lib/cjs/_base/base.css +2 -2
- package/lib/cjs/_utils/index.d.ts +1 -0
- package/lib/cjs/_utils/index.js +3 -2
- package/lib/cjs/button/Button.d.ts +1 -0
- package/lib/cjs/button/buttonGroup.js +11 -3
- package/lib/cjs/cascader/index.d.ts +7 -0
- package/lib/cjs/cascader/index.js +35 -22
- package/lib/cjs/cascader/item.d.ts +2 -0
- package/lib/cjs/cascader/item.js +9 -2
- package/lib/cjs/checkbox/checkbox.js +4 -1
- package/lib/cjs/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/cjs/checkbox/checkboxGroup.js +3 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +2 -1
- package/lib/cjs/datePicker/monthsGrid.js +6 -0
- package/lib/cjs/datePicker/navigation.js +47 -7
- package/lib/cjs/descriptions/item.js +1 -1
- package/lib/cjs/form/baseForm.d.ts +6 -0
- package/lib/cjs/form/field.d.ts +6 -0
- package/lib/cjs/form/hoc/withField.js +3 -1
- package/lib/cjs/locale/source/es.d.ts +7 -0
- package/lib/cjs/locale/source/es.js +168 -0
- package/lib/cjs/modal/Modal.d.ts +8 -8
- package/lib/cjs/modal/Modal.js +4 -4
- package/lib/cjs/modal/confirm.d.ts +10 -10
- package/lib/cjs/navigation/index.d.ts +2 -2
- package/lib/cjs/pagination/index.js +9 -4
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/radio/radio.js +1 -0
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/rating/item.js +3 -2
- package/lib/cjs/select/index.d.ts +10 -0
- package/lib/cjs/select/index.js +15 -9
- package/lib/cjs/table/Table.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/timeline/item.d.ts +5 -2
- package/lib/cjs/timeline/item.js +13 -7
- package/lib/cjs/tree/treeNode.js +0 -2
- package/lib/cjs/treeSelect/index.js +1 -0
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/fileCard.d.ts +2 -0
- package/lib/cjs/upload/fileCard.js +70 -45
- package/lib/cjs/upload/index.d.ts +34 -4
- package/lib/cjs/upload/index.js +141 -25
- package/lib/cjs/upload/interface.d.ts +3 -0
- package/lib/es/_base/base.css +2 -2
- package/lib/es/_utils/index.d.ts +1 -0
- package/lib/es/_utils/index.js +3 -2
- package/lib/es/button/Button.d.ts +1 -0
- package/lib/es/button/buttonGroup.js +3 -3
- package/lib/es/cascader/index.d.ts +7 -0
- package/lib/es/cascader/index.js +34 -25
- package/lib/es/cascader/item.d.ts +2 -0
- package/lib/es/cascader/item.js +9 -2
- package/lib/es/checkbox/checkbox.js +4 -1
- package/lib/es/checkbox/checkboxGroup.d.ts +1 -0
- package/lib/es/checkbox/checkboxGroup.js +3 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.d.ts +2 -1
- package/lib/es/datePicker/monthsGrid.js +6 -0
- package/lib/es/datePicker/navigation.js +48 -8
- package/lib/es/descriptions/item.js +1 -1
- package/lib/es/form/baseForm.d.ts +6 -0
- package/lib/es/form/field.d.ts +6 -0
- package/lib/es/form/hoc/withField.js +3 -1
- package/lib/es/locale/source/es.d.ts +7 -0
- package/lib/es/locale/source/es.js +157 -0
- package/lib/es/modal/Modal.d.ts +8 -8
- package/lib/es/modal/Modal.js +4 -4
- package/lib/es/modal/confirm.d.ts +10 -10
- package/lib/es/navigation/index.d.ts +2 -2
- package/lib/es/pagination/index.js +8 -4
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/radio/radio.js +1 -0
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/rating/item.js +3 -2
- package/lib/es/select/index.d.ts +10 -0
- package/lib/es/select/index.js +19 -9
- package/lib/es/table/Table.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/timeline/item.d.ts +5 -2
- package/lib/es/timeline/item.js +12 -7
- package/lib/es/tree/treeNode.js +0 -2
- package/lib/es/treeSelect/index.js +1 -0
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/fileCard.d.ts +2 -0
- package/lib/es/upload/fileCard.js +69 -44
- package/lib/es/upload/index.d.ts +34 -4
- package/lib/es/upload/index.js +141 -24
- package/lib/es/upload/interface.d.ts +3 -0
- package/locale/source/es.ts +160 -0
- package/modal/Modal.tsx +6 -6
- package/navigation/__test__/navigation.test.js +4 -4
- package/navigation/_story/AutoOpen/index.js +1 -1
- package/navigation/_story/WithChildren/index.js +1 -1
- package/navigation/_story/navigation.stories.js +1 -1
- package/navigation/_story/navigation.stories.tsx +4 -4
- package/navigation/index.tsx +2 -2
- package/package.json +16 -8
- package/pagination/_story/pagination.stories.js +11 -0
- package/pagination/index.tsx +9 -4
- package/popover/Arrow.tsx +1 -1
- package/radio/__test__/radioGroup.test.jsx +41 -6
- package/radio/_story/radio.stories.js +22 -11
- package/radio/radio.tsx +1 -0
- package/rating/item.tsx +2 -1
- package/select/_story/select.stories.js +39 -14
- package/select/index.tsx +21 -7
- package/table/_story/DynamicFilters/index.js +13 -16
- package/timeline/__test__/timeline.test.js +17 -1
- package/timeline/_story/timeline.stories.js +70 -6
- package/timeline/item.tsx +11 -6
- package/tooltip/_story/tooltip.stories.js +1 -1
- package/tree/_story/tree.stories.js +2 -2
- package/tree/treeNode.tsx +0 -2
- package/treeSelect/index.tsx +3 -2
- package/tsconfig.json +2 -1
- package/upload/__test__/upload.test.js +50 -1
- package/upload/fileCard.tsx +110 -95
- package/upload/index.tsx +155 -54
- package/upload/interface.ts +3 -0
package/upload/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import React, { ReactNode, CSSProperties, RefObject, ChangeEvent, DragEvent } fr
|
|
|
3
3
|
import cls from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { noop } from 'lodash';
|
|
6
|
-
import UploadFoundation, {
|
|
6
|
+
import UploadFoundation, { CustomFile, UploadAdapter, BeforeUploadObjectResult, AfterUploadResult } from '@douyinfe/semi-foundation/upload/foundation';
|
|
7
7
|
import { strings, cssClasses } from '@douyinfe/semi-foundation/upload/constants';
|
|
8
8
|
import FileCard from './fileCard';
|
|
9
9
|
import BaseComponent, { ValidateStatus } from '../_base/baseComponent';
|
|
@@ -64,7 +64,10 @@ export interface UploadProps {
|
|
|
64
64
|
prompt?: ReactNode;
|
|
65
65
|
promptPosition?: PromptPositionType;
|
|
66
66
|
renderFileItem?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
67
|
+
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
68
|
+
renderThumbnail?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
67
69
|
showClear?: boolean;
|
|
70
|
+
showPicInfo?: boolean; // Show pic info in picture wall
|
|
68
71
|
showReplace?: boolean; // Display replacement function
|
|
69
72
|
showRetry?: boolean;
|
|
70
73
|
showUploadList?: boolean;
|
|
@@ -133,7 +136,10 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
133
136
|
prompt: PropTypes.node,
|
|
134
137
|
promptPosition: PropTypes.oneOf<UploadProps['promptPosition']>(strings.PROMPT_POSITION),
|
|
135
138
|
renderFileItem: PropTypes.func,
|
|
139
|
+
renderPicInfo: PropTypes.func,
|
|
140
|
+
renderThumbnail: PropTypes.func,
|
|
136
141
|
showClear: PropTypes.bool,
|
|
142
|
+
showPicInfo: PropTypes.bool,
|
|
137
143
|
showReplace: PropTypes.bool,
|
|
138
144
|
showRetry: PropTypes.bool,
|
|
139
145
|
showUploadList: PropTypes.bool, // whether to show fileList
|
|
@@ -168,6 +174,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
168
174
|
onSuccess: noop,
|
|
169
175
|
promptPosition: 'right' as const,
|
|
170
176
|
showClear: true,
|
|
177
|
+
showPicInfo: false,
|
|
171
178
|
showReplace: false,
|
|
172
179
|
showRetry: true,
|
|
173
180
|
showUploadList: true,
|
|
@@ -193,7 +200,14 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
193
200
|
this.replaceInputRef = React.createRef<HTMLInputElement>();
|
|
194
201
|
}
|
|
195
202
|
|
|
196
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Notes:
|
|
205
|
+
* The input parameter and return value here do not declare the type, otherwise tsc may report an error in form/fields.tsx when wrap after withField
|
|
206
|
+
* `The types of the parameters "props" and "nextProps" are incompatible.
|
|
207
|
+
The attribute "action" is missing in the type "Readonly<any>", but it is required in the type "UploadProps".`
|
|
208
|
+
* which seems to be a bug, remove props type declare here
|
|
209
|
+
*/
|
|
210
|
+
static getDerivedStateFromProps(props) {
|
|
197
211
|
const { fileList } = props;
|
|
198
212
|
if ('fileList' in props) {
|
|
199
213
|
return {
|
|
@@ -290,14 +304,29 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
290
304
|
this.foundation.handleRemove(fileItem);
|
|
291
305
|
};
|
|
292
306
|
|
|
307
|
+
/**
|
|
308
|
+
* ref method
|
|
309
|
+
* insert files at index
|
|
310
|
+
* @param files Array<CustomFile>
|
|
311
|
+
* @param index number
|
|
312
|
+
* @returns
|
|
313
|
+
*/
|
|
314
|
+
insert = (files: Array<CustomFile>, index: number): void => {
|
|
315
|
+
return this.foundation.insertFileToList(files, index);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* ref method
|
|
320
|
+
* manual upload by user
|
|
321
|
+
*/
|
|
293
322
|
upload = (): void => {
|
|
294
323
|
const { fileList } = this.state;
|
|
295
324
|
this.foundation.startUpload(fileList);
|
|
296
325
|
};
|
|
297
326
|
|
|
298
327
|
renderFile = (file: FileItem, index: number, locale: Locale['Upload']): ReactNode => {
|
|
299
|
-
const { name, status, validateMessage, _sizeInvalid } = file;
|
|
300
|
-
const { previewFile, listType, itemStyle, showRetry, renderFileItem, disabled, onPreviewClick, showReplace } = this.props;
|
|
328
|
+
const { name, status, validateMessage, _sizeInvalid, uid } = file;
|
|
329
|
+
const { previewFile, listType, itemStyle, showRetry, showPicInfo, renderPicInfo, renderFileItem, renderThumbnail, disabled, onPreviewClick, showReplace } = this.props;
|
|
301
330
|
const onRemove = (): void => this.remove(file);
|
|
302
331
|
const onRetry = (): void => {
|
|
303
332
|
this.foundation.retry(file);
|
|
@@ -311,10 +340,14 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
311
340
|
listType,
|
|
312
341
|
onRemove,
|
|
313
342
|
onRetry,
|
|
314
|
-
|
|
343
|
+
index,
|
|
344
|
+
key: uid || `${name}${index}`,
|
|
315
345
|
showRetry: typeof file.showRetry !== 'undefined' ? file.showRetry : showRetry,
|
|
316
346
|
style: itemStyle,
|
|
317
347
|
disabled,
|
|
348
|
+
showPicInfo,
|
|
349
|
+
renderPicInfo,
|
|
350
|
+
renderThumbnail,
|
|
318
351
|
showReplace: typeof file.showReplace !== 'undefined' ? file.showReplace : showReplace,
|
|
319
352
|
onReplace,
|
|
320
353
|
onPreviewClick: typeof onPreviewClick !== 'undefined' ? (): void => this.foundation.handlePreviewClick(file) : undefined,
|
|
@@ -336,17 +369,54 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
336
369
|
};
|
|
337
370
|
|
|
338
371
|
renderFileList = (): ReactNode => {
|
|
339
|
-
const {
|
|
340
|
-
|
|
372
|
+
const { listType } = this.props;
|
|
373
|
+
if (listType === strings.FILE_LIST_PIC) {
|
|
374
|
+
return this.renderFileListPic();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (listType === strings.FILE_LIST_DEFAULT) {
|
|
378
|
+
return this.renderFileListDefault();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return null;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
renderFileListPic = () => {
|
|
385
|
+
const { showUploadList, limit, disabled, children, draggable } = this.props;
|
|
386
|
+
const { fileList: stateFileList, dragAreaStatus } = this.state;
|
|
341
387
|
const fileList = this.props.fileList || stateFileList;
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
const uploadAddCls = cls(`${prefixCls
|
|
345
|
-
[`${prefixCls
|
|
346
|
-
[`${prefixCls}-picture-add-disabled`]: disabled
|
|
388
|
+
const showAddTriggerInList = limit ? limit > fileList.length : true;
|
|
389
|
+
const dragAreaBaseCls = `${prefixCls}-drag-area`;
|
|
390
|
+
const uploadAddCls = cls(`${prefixCls}-add`, {
|
|
391
|
+
[`${prefixCls}-picture-add`]: true,
|
|
392
|
+
[`${prefixCls}-picture-add-disabled`]: disabled,
|
|
347
393
|
});
|
|
394
|
+
const fileListCls = cls(`${prefixCls}-file-list`, {
|
|
395
|
+
[`${prefixCls}-picture-file-list`]: true,
|
|
396
|
+
});
|
|
397
|
+
const dragAreaCls = cls({
|
|
398
|
+
[`${dragAreaBaseCls}-legal`]: dragAreaStatus === strings.DRAG_AREA_LEGAL,
|
|
399
|
+
[`${dragAreaBaseCls}-illegal`]: dragAreaStatus === strings.DRAG_AREA_ILLEGAL
|
|
400
|
+
});
|
|
401
|
+
const mainCls = `${prefixCls}-file-list-main`;
|
|
402
|
+
const addContentProps = {
|
|
403
|
+
className: uploadAddCls,
|
|
404
|
+
onClick: this.onClick,
|
|
405
|
+
};
|
|
406
|
+
const containerProps = {
|
|
407
|
+
className: fileListCls
|
|
408
|
+
};
|
|
409
|
+
const draggableProps = {
|
|
410
|
+
onDrop: this.onDrop,
|
|
411
|
+
onDragOver: this.onDragOver,
|
|
412
|
+
onDragLeave: this.onDragLeave,
|
|
413
|
+
onDragEnter: this.onDragEnter,
|
|
414
|
+
};
|
|
415
|
+
if (draggable) {
|
|
416
|
+
Object.assign(addContentProps, draggableProps, { className: cls(uploadAddCls, dragAreaCls) });
|
|
417
|
+
}
|
|
348
418
|
const addContent = (
|
|
349
|
-
<div
|
|
419
|
+
<div {...addContentProps}>
|
|
350
420
|
{children}
|
|
351
421
|
</div>
|
|
352
422
|
);
|
|
@@ -358,23 +428,46 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
358
428
|
return null;
|
|
359
429
|
}
|
|
360
430
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
431
|
+
return (
|
|
432
|
+
<LocaleConsumer componentName="Upload">
|
|
433
|
+
{(locale: Locale['Upload']) => (
|
|
434
|
+
<div {...containerProps}>
|
|
435
|
+
<div className={mainCls}>
|
|
436
|
+
{fileList.map((file, index) => this.renderFile(file, index, locale))}
|
|
437
|
+
{showAddTriggerInList ? addContent : null}
|
|
438
|
+
</div>
|
|
439
|
+
</div>
|
|
440
|
+
)}
|
|
441
|
+
</LocaleConsumer>
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
renderFileListDefault = () => {
|
|
446
|
+
const { showUploadList, limit, disabled } = this.props;
|
|
447
|
+
const { fileList: stateFileList } = this.state;
|
|
448
|
+
const fileList = this.props.fileList || stateFileList;
|
|
449
|
+
const fileListCls = cls(`${prefixCls}-file-list`);
|
|
450
|
+
const titleCls = `${prefixCls}-file-list-title`;
|
|
451
|
+
const mainCls = `${prefixCls}-file-list-main`;
|
|
452
|
+
const showTitle = limit !== 1 && fileList.length;
|
|
367
453
|
const showClear = this.props.showClear && !disabled;
|
|
454
|
+
const containerProps = {
|
|
455
|
+
className: fileListCls
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
if (!showUploadList || !fileList.length) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
368
461
|
|
|
369
462
|
return (
|
|
370
463
|
<LocaleConsumer componentName="Upload">
|
|
371
|
-
{(locale: Locale['Upload'])
|
|
372
|
-
<div
|
|
464
|
+
{(locale: Locale['Upload']) => (
|
|
465
|
+
<div {...containerProps}>
|
|
373
466
|
{showTitle ? (
|
|
374
467
|
<div className={titleCls}>
|
|
375
|
-
<span className={`${titleCls
|
|
468
|
+
<span className={`${titleCls}-choosen`}>{locale.selectedFiles}</span>
|
|
376
469
|
{showClear ? (
|
|
377
|
-
<span onClick={this.clear} className={`${titleCls
|
|
470
|
+
<span onClick={this.clear} className={`${titleCls}-clear`}>
|
|
378
471
|
{locale.clear}
|
|
379
472
|
</span>
|
|
380
473
|
) : null}
|
|
@@ -383,13 +476,12 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
383
476
|
|
|
384
477
|
<div className={mainCls}>
|
|
385
478
|
{fileList.map((file, index) => this.renderFile(file, index, locale))}
|
|
386
|
-
{showAddTriggerInList ? addContent : null}
|
|
387
479
|
</div>
|
|
388
480
|
</div>
|
|
389
481
|
)}
|
|
390
482
|
</LocaleConsumer>
|
|
391
483
|
);
|
|
392
|
-
}
|
|
484
|
+
}
|
|
393
485
|
|
|
394
486
|
onDrop = (e: DragEvent<HTMLDivElement>): void => {
|
|
395
487
|
this.foundation.handleDrop(e);
|
|
@@ -408,14 +500,30 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
408
500
|
this.foundation.handleDragEnter(e);
|
|
409
501
|
};
|
|
410
502
|
|
|
503
|
+
renderAddContent = () => {
|
|
504
|
+
const { draggable, children, listType } = this.props;
|
|
505
|
+
const uploadAddCls = cls(`${prefixCls}-add`);
|
|
506
|
+
if (listType === strings.FILE_LIST_PIC) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
if (draggable) {
|
|
510
|
+
return this.renderDragArea();
|
|
511
|
+
}
|
|
512
|
+
return (
|
|
513
|
+
<div className={uploadAddCls} onClick={this.onClick}>
|
|
514
|
+
{children}
|
|
515
|
+
</div>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
411
519
|
renderDragArea = (): ReactNode => {
|
|
412
520
|
const { dragAreaStatus } = this.state;
|
|
413
521
|
const { children, dragIcon, dragMainText, dragSubText } = this.props;
|
|
414
|
-
const dragAreaBaseCls = `${prefixCls
|
|
522
|
+
const dragAreaBaseCls = `${prefixCls}-drag-area`;
|
|
415
523
|
const dragAreaCls = cls(dragAreaBaseCls, {
|
|
416
|
-
[`${dragAreaBaseCls
|
|
417
|
-
[`${dragAreaBaseCls
|
|
418
|
-
[`${dragAreaBaseCls
|
|
524
|
+
[`${dragAreaBaseCls}-legal`]: dragAreaStatus === strings.DRAG_AREA_LEGAL,
|
|
525
|
+
[`${dragAreaBaseCls}-illegal`]: dragAreaStatus === strings.DRAG_AREA_ILLEGAL,
|
|
526
|
+
[`${dragAreaBaseCls}-custom`]: children,
|
|
419
527
|
});
|
|
420
528
|
|
|
421
529
|
return (
|
|
@@ -433,20 +541,20 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
433
541
|
children
|
|
434
542
|
) : (
|
|
435
543
|
<>
|
|
436
|
-
<div className={`${dragAreaBaseCls
|
|
544
|
+
<div className={`${dragAreaBaseCls}-icon`}>
|
|
437
545
|
{dragIcon || <IconUpload size="extra-large" />}
|
|
438
546
|
</div>
|
|
439
|
-
<div className={`${dragAreaBaseCls
|
|
440
|
-
<div className={`${dragAreaBaseCls
|
|
547
|
+
<div className={`${dragAreaBaseCls}-text`}>
|
|
548
|
+
<div className={`${dragAreaBaseCls}-main-text`}>
|
|
441
549
|
{dragMainText || locale.mainText}
|
|
442
550
|
</div>
|
|
443
|
-
<div className={`${dragAreaBaseCls
|
|
444
|
-
<div className={`${dragAreaBaseCls
|
|
551
|
+
<div className={`${dragAreaBaseCls}-sub-text`}>{dragSubText}</div>
|
|
552
|
+
<div className={`${dragAreaBaseCls}-tips`}>
|
|
445
553
|
{dragAreaStatus === strings.DRAG_AREA_LEGAL && (
|
|
446
|
-
<span className={`${dragAreaBaseCls
|
|
554
|
+
<span className={`${dragAreaBaseCls}-tips-legal`}>{locale.legalTips}</span>
|
|
447
555
|
)}
|
|
448
556
|
{dragAreaStatus === strings.DRAG_AREA_ILLEGAL && (
|
|
449
|
-
<span className={`${dragAreaBaseCls
|
|
557
|
+
<span className={`${dragAreaBaseCls}-tips-illegal`}>
|
|
450
558
|
{locale.illegalTips}
|
|
451
559
|
</span>
|
|
452
560
|
)}
|
|
@@ -478,27 +586,20 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
478
586
|
directory,
|
|
479
587
|
} = this.props;
|
|
480
588
|
const uploadCls = cls(prefixCls, {
|
|
481
|
-
[`${prefixCls
|
|
482
|
-
[`${prefixCls
|
|
483
|
-
[`${prefixCls
|
|
484
|
-
[`${prefixCls
|
|
485
|
-
[`${prefixCls
|
|
486
|
-
[`${prefixCls
|
|
589
|
+
[`${prefixCls}-picture`]: listType === strings.FILE_LIST_PIC,
|
|
590
|
+
[`${prefixCls}-disabled`]: disabled,
|
|
591
|
+
[`${prefixCls}-default`]: validateStatus === 'default',
|
|
592
|
+
[`${prefixCls}-error`]: validateStatus === 'error',
|
|
593
|
+
[`${prefixCls}-warning`]: validateStatus === 'warning',
|
|
594
|
+
[`${prefixCls}-success`]: validateStatus === 'success',
|
|
487
595
|
}, className);
|
|
488
|
-
const
|
|
489
|
-
const
|
|
490
|
-
const
|
|
491
|
-
const
|
|
492
|
-
const validateMsgCls = cls(`${prefixCls }-validate-message`);
|
|
596
|
+
const inputCls = cls(`${prefixCls}-hidden-input`);
|
|
597
|
+
const inputReplaceCls = cls(`${prefixCls}-hidden-input-replace`);
|
|
598
|
+
const promptCls = cls(`${prefixCls}-prompt`);
|
|
599
|
+
const validateMsgCls = cls(`${prefixCls}-validate-message`);
|
|
493
600
|
|
|
494
601
|
const dirProps = directory ? { directory: 'directory', webkitdirectory: 'webkitdirectory' } : {};
|
|
495
602
|
|
|
496
|
-
const addContent =
|
|
497
|
-
listType !== strings.FILE_LIST_PIC ? (
|
|
498
|
-
<div className={uploadAddCls} onClick={this.onClick}>
|
|
499
|
-
{children}
|
|
500
|
-
</div>
|
|
501
|
-
) : null;
|
|
502
603
|
return (
|
|
503
604
|
<div className={uploadCls} style={style} x-prompt-pos={promptPosition}>
|
|
504
605
|
<input
|
|
@@ -525,7 +626,7 @@ class Upload extends BaseComponent<UploadProps, UploadState> {
|
|
|
525
626
|
className={inputReplaceCls}
|
|
526
627
|
ref={this.replaceInputRef}
|
|
527
628
|
/>
|
|
528
|
-
{
|
|
629
|
+
{this.renderAddContent()}
|
|
529
630
|
{prompt ? <div className={promptCls}>{prompt}</div> : null}
|
|
530
631
|
|
|
531
632
|
{validateMessage ? <div className={validateMsgCls}>{validateMessage}</div> : null}
|
package/upload/interface.ts
CHANGED
|
@@ -45,12 +45,15 @@ export interface FileItem extends BaseFileItem {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface RenderFileItemProps extends FileItem {
|
|
48
|
+
index?: number;
|
|
48
49
|
previewFile?: (fileItem: RenderFileItemProps) => ReactNode;
|
|
49
50
|
listType: UploadListType;
|
|
50
51
|
onRemove: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
51
52
|
onRetry: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
52
53
|
onReplace: (props: RenderFileItemProps, e: MouseEvent) => void;
|
|
53
54
|
key: string;
|
|
55
|
+
showPicInfo?: boolean;
|
|
56
|
+
renderPicInfo?: (renderFileItemProps: RenderFileItemProps) => ReactNode;
|
|
54
57
|
showRetry: boolean;
|
|
55
58
|
showReplace: boolean;
|
|
56
59
|
style?: CSSProperties;
|