amis 1.6.5-beta.3 → 1.8.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/lib/Schema.d.ts +3 -2
- package/lib/Schema.js +0 -1
- package/lib/Schema.js.map +2 -2
- package/lib/components/Alert2.js +4 -2
- package/lib/components/Alert2.js.map +2 -2
- package/lib/components/AssociatedSelection.d.ts +84 -84
- package/lib/components/Avatar.d.ts +20 -20
- package/lib/components/Breadcrumb.d.ts +130 -0
- package/lib/components/Breadcrumb.js +161 -0
- package/lib/components/Breadcrumb.js.map +13 -0
- package/lib/components/Card.d.ts +20 -20
- package/lib/components/ChainedSelection.d.ts +84 -84
- package/lib/components/CityArea.js +3 -0
- package/lib/components/CityArea.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/CollapseGroup.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DateRangePicker.d.ts +2 -2
- package/lib/components/DateRangePicker.js +36 -45
- package/lib/components/DateRangePicker.js.map +2 -2
- package/lib/components/GroupedSelection.d.ts +84 -84
- package/lib/components/Layout.d.ts +21 -21
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/PopUp.js +2 -1
- package/lib/components/PopUp.js.map +2 -2
- package/lib/components/Radios.d.ts +21 -21
- package/lib/components/Range.js.map +2 -2
- package/lib/components/Selection.d.ts +84 -84
- package/lib/components/TableSelection.d.ts +84 -84
- package/lib/components/Tabs.d.ts +52 -23
- package/lib/components/Tabs.js +198 -46
- package/lib/components/Tabs.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +21 -20
- package/lib/components/TooltipWrapper.js +2 -2
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +84 -84
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/Calendar.js +5 -0
- package/lib/components/calendar/Calendar.js.map +2 -2
- package/lib/components/calendar/DaysView.js.map +1 -1
- package/lib/components/icons.js +8 -0
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +4 -2
- package/lib/components/index.js.map +2 -2
- package/lib/icons/cloud-upload.js +17 -0
- package/lib/icons/image.js +7 -0
- package/lib/icons/refresh.js +9 -0
- package/lib/icons/trash.js +10 -0
- package/lib/icons/upload.js +3 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/en-US.js +3 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +4 -2
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.d.ts +1 -1
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/Breadcrumb.d.ts +41 -6
- package/lib/renderers/Breadcrumb.js +23 -19
- package/lib/renderers/Breadcrumb.js.map +2 -2
- package/lib/renderers/ButtonGroup.d.ts +2 -2
- package/lib/renderers/ButtonGroup.js.map +1 -1
- package/lib/renderers/Form/ChainedSelect.d.ts +4 -1
- package/lib/renderers/Form/ChainedSelect.js +83 -34
- package/lib/renderers/Form/ChainedSelect.js.map +2 -2
- package/lib/renderers/Form/Checkbox.d.ts +3 -0
- package/lib/renderers/Form/Checkbox.js +38 -1
- package/lib/renderers/Form/Checkbox.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +4 -3
- package/lib/renderers/Form/Combo.js +81 -32
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -1
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputCity.js +4 -1
- package/lib/renderers/Form/InputCity.js.map +2 -2
- package/lib/renderers/Form/InputColor.js +3 -1
- package/lib/renderers/Form/InputColor.js.map +2 -2
- package/lib/renderers/Form/InputDate.js +3 -1
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +3 -1
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputExcel.d.ts +4 -0
- package/lib/renderers/Form/InputExcel.js +33 -6
- package/lib/renderers/Form/InputExcel.js.map +2 -2
- package/lib/renderers/Form/InputFile.d.ts +8 -1
- package/lib/renderers/Form/InputFile.js +71 -42
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.d.ts +4 -1
- package/lib/renderers/Form/InputImage.js +21 -9
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputRange.d.ts +27 -9
- package/lib/renderers/Form/InputRange.js +88 -23
- package/lib/renderers/Form/InputRange.js.map +2 -2
- package/lib/renderers/Form/InputSubForm.js +2 -1
- package/lib/renderers/Form/InputSubForm.js.map +2 -2
- package/lib/renderers/Form/InputTag.js +2 -1
- package/lib/renderers/Form/InputTag.js.map +2 -2
- package/lib/renderers/Form/MatrixCheckboxes.js +2 -1
- package/lib/renderers/Form/MatrixCheckboxes.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +9 -6
- package/lib/renderers/Form/NestedSelect.js +247 -130
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +2 -1
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Radios.js +2 -1
- package/lib/renderers/Form/Radios.js.map +2 -2
- package/lib/renderers/Form/Select.js +6 -3
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/Switch.d.ts +7 -6
- package/lib/renderers/Form/Switch.js +4 -1
- package/lib/renderers/Form/Switch.js.map +2 -2
- package/lib/renderers/Log.js +2 -1
- package/lib/renderers/Log.js.map +2 -2
- package/lib/renderers/PopOver.js +1 -1
- package/lib/renderers/PopOver.js.map +2 -2
- package/lib/renderers/Tabs.d.ts +58 -5
- package/lib/renderers/Tabs.js +170 -58
- package/lib/renderers/Tabs.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +104 -0
- package/lib/renderers/TooltipWrapper.js +59 -0
- package/lib/renderers/TooltipWrapper.js.map +13 -0
- package/lib/renderers/Video.d.ts +6 -0
- package/lib/renderers/Video.js +13 -6
- package/lib/renderers/Video.js.map +2 -2
- package/lib/store/form.js +4 -13
- package/lib/store/form.js.map +2 -2
- package/lib/store/table.js +1 -1
- package/lib/store/table.js.map +2 -2
- package/lib/themes/ang-ie11.css +742 -160
- package/lib/themes/ang.css +793 -163
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +757 -175
- package/lib/themes/antd.css +793 -163
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +1249 -667
- package/lib/themes/cxd.css +970 -321
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +742 -160
- package/lib/themes/dark.css +793 -163
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +1249 -667
- package/lib/themes/default.css +970 -321
- package/lib/themes/default.css.map +1 -1
- package/package.json +1 -1
- package/schema.json +16012 -736
- package/scss/_properties.scss +56 -2
- package/scss/components/_alert.scss +1 -1
- package/scss/components/_breadcrumb.scss +90 -1
- package/scss/components/_button-group.scss +15 -0
- package/scss/components/_city-area.scss +2 -0
- package/scss/components/_popup.scss +13 -3
- package/scss/components/_tabs.scss +629 -132
- package/scss/components/_tooltip.scss +72 -0
- package/scss/components/form/_file.scss +82 -24
- package/scss/components/form/_image.scss +30 -25
- package/scss/components/form/_number.scss +2 -0
- package/scss/components/form/_switch.scss +1 -3
- package/scss/themes/_cxd-colors.scss +47 -47
- package/scss/themes/_cxd-variables.scss +20 -0
- package/sdk/ang-ie11.css +879 -196
- package/sdk/ang.css +931 -200
- package/sdk/antd-ie11.css +951 -268
- package/sdk/antd.css +931 -200
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +1386 -703
- package/sdk/cxd.css +1107 -357
- package/sdk/dark-ie11.css +879 -196
- package/sdk/dark.css +931 -200
- package/sdk/exceljs.js +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +1386 -703
- package/sdk/sdk.css +1107 -357
- package/sdk/sdk.js +1260 -1248
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/Schema.ts +5 -2
- package/src/components/Alert2.tsx +9 -3
- package/src/components/Breadcrumb.tsx +294 -0
- package/src/components/CityArea.tsx +3 -0
- package/src/components/DateRangePicker.tsx +40 -68
- package/src/components/PopUp.tsx +6 -5
- package/src/components/Range.tsx +7 -1
- package/src/components/Tabs.tsx +300 -54
- package/src/components/TooltipWrapper.tsx +4 -1
- package/src/components/calendar/Calendar.tsx +5 -0
- package/src/components/calendar/DaysView.tsx +2 -2
- package/src/components/icons.tsx +8 -0
- package/src/components/index.tsx +2 -0
- package/src/icons/cloud-upload.svg +22 -0
- package/src/icons/image.svg +1 -0
- package/src/icons/refresh.svg +7 -0
- package/src/icons/trash.svg +8 -0
- package/src/icons/upload.svg +4 -9
- package/src/index.tsx +1 -0
- package/src/locale/en-US.ts +3 -1
- package/src/locale/zh-CN.ts +4 -2
- package/src/renderers/Action.tsx +2 -1
- package/src/renderers/Breadcrumb.tsx +89 -45
- package/src/renderers/ButtonGroup.tsx +2 -2
- package/src/renderers/Form/ChainedSelect.tsx +56 -12
- package/src/renderers/Form/Checkbox.tsx +30 -1
- package/src/renderers/Form/Combo.tsx +84 -26
- package/src/renderers/Form/InputCity.tsx +13 -1
- package/src/renderers/Form/InputColor.tsx +2 -0
- package/src/renderers/Form/InputDate.tsx +2 -0
- package/src/renderers/Form/InputDateRange.tsx +2 -0
- package/src/renderers/Form/InputExcel.tsx +27 -5
- package/src/renderers/Form/InputFile.tsx +167 -115
- package/src/renderers/Form/InputImage.tsx +61 -35
- package/src/renderers/Form/InputRange.tsx +95 -40
- package/src/renderers/Form/InputSubForm.tsx +2 -1
- package/src/renderers/Form/InputTag.tsx +3 -1
- package/src/renderers/Form/MatrixCheckboxes.tsx +3 -1
- package/src/renderers/Form/NestedSelect.tsx +75 -26
- package/src/renderers/Form/Options.tsx +3 -1
- package/src/renderers/Form/Radios.tsx +3 -1
- package/src/renderers/Form/Select.tsx +6 -2
- package/src/renderers/Form/Switch.tsx +16 -9
- package/src/renderers/Log.tsx +2 -1
- package/src/renderers/PopOver.tsx +1 -1
- package/src/renderers/Tabs.tsx +254 -93
- package/src/renderers/TooltipWrapper.tsx +219 -0
- package/src/renderers/Video.tsx +21 -6
- package/src/store/form.ts +0 -9
- package/src/store/table.ts +1 -1
@@ -5,7 +5,7 @@ import isPlainObject from 'lodash/isPlainObject';
|
|
5
5
|
// @ts-ignore
|
6
6
|
import mapLimit from 'async/mapLimit';
|
7
7
|
import ImageControl from './InputImage';
|
8
|
-
import {Payload, ApiObject, ApiString} from '../../types';
|
8
|
+
import {Payload, ApiObject, ApiString, Action} from '../../types';
|
9
9
|
import {filter} from '../../utils/tpl';
|
10
10
|
import Alert from '../../components/Alert2';
|
11
11
|
import {qsstringify, createObject, guid, isEmpty} from '../../utils/helper';
|
@@ -17,6 +17,7 @@ import {
|
|
17
17
|
} from '../../utils/api';
|
18
18
|
import Button from '../../components/Button';
|
19
19
|
import {Icon} from '../../components/icons';
|
20
|
+
import TooltipWrapper from '../../components/TooltipWrapper';
|
20
21
|
import DropZone from 'react-dropzone';
|
21
22
|
import {FileRejection} from 'react-dropzone';
|
22
23
|
import {dataMapping} from '../../utils/tpl-builtin';
|
@@ -213,6 +214,11 @@ export interface FileControlSchema extends FormBaseControl {
|
|
213
214
|
uploaded: string;
|
214
215
|
ready: string;
|
215
216
|
};
|
217
|
+
|
218
|
+
/**
|
219
|
+
* 是否为拖拽上传
|
220
|
+
*/
|
221
|
+
drag?: boolean;
|
216
222
|
}
|
217
223
|
|
218
224
|
export interface FileProps
|
@@ -275,6 +281,8 @@ export function getNameFromUrl(url: string) {
|
|
275
281
|
|
276
282
|
return url;
|
277
283
|
}
|
284
|
+
export type InputFileRendererEvent = 'change' | 'success' | 'fail' | 'remove';
|
285
|
+
export type InputFileRendererAction = 'clear';
|
278
286
|
|
279
287
|
export default class FileControl extends React.Component<FileProps, FileState> {
|
280
288
|
static defaultProps: Partial<FileProps> = {
|
@@ -305,7 +313,8 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
305
313
|
uploaded: '已上传',
|
306
314
|
ready: ''
|
307
315
|
},
|
308
|
-
asBase64: false
|
316
|
+
asBase64: false,
|
317
|
+
drag: false
|
309
318
|
};
|
310
319
|
|
311
320
|
state: FileState;
|
@@ -476,13 +485,13 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
476
485
|
|
477
486
|
[].slice.call(files, 0, allowed).forEach((file: FileX) => {
|
478
487
|
if (maxSize && file.size > maxSize) {
|
479
|
-
this.props.env.alert(
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
);
|
488
|
+
// this.props.env.alert(
|
489
|
+
// __('File.maxSize', {
|
490
|
+
// filename: file[nameField as keyof typeof file] || file.name,
|
491
|
+
// actualSize: ImageControl.formatFileSize(file.size),
|
492
|
+
// maxSize: ImageControl.formatFileSize(maxSize)
|
493
|
+
// })
|
494
|
+
// );
|
486
495
|
file.state = 'invalid';
|
487
496
|
} else {
|
488
497
|
file.state = 'pending';
|
@@ -595,7 +604,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
595
604
|
}
|
596
605
|
|
597
606
|
handleSelect() {
|
598
|
-
|
607
|
+
const {disabled, multiple, maxLength} = this.props;
|
608
|
+
!disabled &&
|
609
|
+
!(multiple && maxLength && this.state.files.length >= maxLength) &&
|
610
|
+
this.dropzone.current &&
|
611
|
+
this.dropzone.current.open();
|
599
612
|
}
|
600
613
|
|
601
614
|
startUpload(retry: boolean = false) {
|
@@ -1212,12 +1225,23 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1212
1225
|
);
|
1213
1226
|
}
|
1214
1227
|
|
1228
|
+
// 动作
|
1229
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
1230
|
+
const {onChange} = this.props;
|
1231
|
+
if (action.actionType === 'clear') {
|
1232
|
+
this.setState({files: []}, () => {
|
1233
|
+
onChange('');
|
1234
|
+
});
|
1235
|
+
}
|
1236
|
+
}
|
1237
|
+
|
1215
1238
|
render() {
|
1216
1239
|
const {
|
1217
1240
|
btnLabel,
|
1218
1241
|
accept,
|
1219
1242
|
disabled,
|
1220
1243
|
maxLength,
|
1244
|
+
maxSize,
|
1221
1245
|
multiple,
|
1222
1246
|
autoUpload,
|
1223
1247
|
description,
|
@@ -1230,7 +1254,8 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1230
1254
|
translate: __,
|
1231
1255
|
render,
|
1232
1256
|
downloadUrl,
|
1233
|
-
templateUrl
|
1257
|
+
templateUrl,
|
1258
|
+
drag
|
1234
1259
|
} = this.props;
|
1235
1260
|
let {files, uploading, error} = this.state;
|
1236
1261
|
const nameField = this.props.nameField || 'name';
|
@@ -1278,39 +1303,56 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1278
1303
|
onClick: preventEvent
|
1279
1304
|
})}
|
1280
1305
|
className={cx('FileControl-dropzone', {
|
1281
|
-
disabled
|
1306
|
+
'disabled':
|
1307
|
+
disabled ||
|
1308
|
+
(multiple && !!maxLength && files.length >= maxLength),
|
1282
1309
|
'is-empty': !files.length,
|
1283
1310
|
'is-active': isDragActive
|
1284
1311
|
})}
|
1285
1312
|
>
|
1286
1313
|
<input disabled={disabled} {...getInputProps()} />
|
1287
1314
|
|
1288
|
-
{
|
1289
|
-
<div
|
1290
|
-
{
|
1315
|
+
{drag ? (
|
1316
|
+
<div
|
1317
|
+
className={cx('FileControl-acceptTip')}
|
1318
|
+
onClick={this.handleSelect}
|
1319
|
+
>
|
1320
|
+
<Icon icon="cloud-upload" className="icon" />
|
1321
|
+
<span>{__('File.dragDrop')}</span>
|
1322
|
+
{maxSize ? (
|
1323
|
+
<div className={cx('FileControl-sizeTip')}>
|
1324
|
+
{__('File.sizeLimit', {maxSize})}
|
1325
|
+
</div>
|
1326
|
+
) : null}
|
1291
1327
|
</div>
|
1292
1328
|
) : (
|
1293
1329
|
<>
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1330
|
+
<Button
|
1331
|
+
level="default"
|
1332
|
+
disabled={disabled}
|
1333
|
+
className={cx('FileControl-selectBtn', {
|
1334
|
+
btnClassName,
|
1335
|
+
'is-disabled':
|
1336
|
+
multiple && !!maxLength && files.length >= maxLength
|
1337
|
+
})}
|
1338
|
+
tooltip={
|
1339
|
+
multiple && maxLength && files.length >= maxLength
|
1340
|
+
? __('File.maxLength', {maxLength})
|
1341
|
+
: ''
|
1342
|
+
}
|
1343
|
+
onClick={this.handleSelect}
|
1344
|
+
>
|
1345
|
+
<Icon icon="upload" className="icon" />
|
1346
|
+
<span>
|
1347
|
+
{!multiple && files.length
|
1348
|
+
? __('File.repick')
|
1349
|
+
: multiple && files.length
|
1350
|
+
? __('File.continueAdd')
|
1351
|
+
: btnLabel
|
1352
|
+
? btnLabel
|
1353
|
+
: __('File.upload')}
|
1354
|
+
</span>
|
1355
|
+
</Button>
|
1314
1356
|
|
1315
1357
|
{description
|
1316
1358
|
? render('desc', description!, {
|
@@ -1320,92 +1362,102 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
1320
1362
|
)
|
1321
1363
|
})
|
1322
1364
|
: null}
|
1323
|
-
|
1324
|
-
{Array.isArray(files) ? (
|
1325
|
-
<ul className={cx('FileControl-list')}>
|
1326
|
-
{files.map((file, index) => (
|
1327
|
-
<li key={file.id}>
|
1328
|
-
<div
|
1329
|
-
className={cx('FileControl-itemInfo', {
|
1330
|
-
'is-invalid':
|
1331
|
-
file.state === 'invalid' ||
|
1332
|
-
file.state === 'error'
|
1333
|
-
})}
|
1334
|
-
>
|
1335
|
-
<Icon icon="file" className="icon" />
|
1336
|
-
{(file as FileValue)[urlField] ||
|
1337
|
-
(file as FileValue)[valueField] ||
|
1338
|
-
downloadUrl ? (
|
1339
|
-
<a
|
1340
|
-
className={cx('FileControl-itemInfoText')}
|
1341
|
-
target="_blank"
|
1342
|
-
rel="noopener"
|
1343
|
-
href="#"
|
1344
|
-
onClick={this.handleClickFile.bind(this, file)}
|
1345
|
-
>
|
1346
|
-
{file[nameField as keyof typeof file] ||
|
1347
|
-
(file as FileValue).filename}
|
1348
|
-
</a>
|
1349
|
-
) : (
|
1350
|
-
<span className={cx('FileControl-itemInfoText')}>
|
1351
|
-
{file[nameField as keyof typeof file] ||
|
1352
|
-
(file as FileValue).filename}
|
1353
|
-
</span>
|
1354
|
-
)}
|
1355
|
-
|
1356
|
-
{file.state === 'invalid' ||
|
1357
|
-
file.state === 'error' ? (
|
1358
|
-
<>
|
1359
|
-
<Icon icon="fail" className="icon" />
|
1360
|
-
<span className="text-danger">
|
1361
|
-
{(file as FileValue).error || null}
|
1362
|
-
</span>
|
1363
|
-
</>
|
1364
|
-
) : null}
|
1365
|
-
{!disabled ? (
|
1366
|
-
<a
|
1367
|
-
data-tooltip={__('Select.clear')}
|
1368
|
-
className={cx('FileControl-clear')}
|
1369
|
-
onClick={() => this.removeFile(file, index)}
|
1370
|
-
>
|
1371
|
-
<Icon icon="close" className="icon" />
|
1372
|
-
</a>
|
1373
|
-
) : null}
|
1374
|
-
</div>
|
1375
|
-
{file.state === 'uploading' ||
|
1376
|
-
file.state === 'uploaded' ? (
|
1377
|
-
<div className={cx('FileControl-progressInfo')}>
|
1378
|
-
<div className={cx('FileControl-progress')}>
|
1379
|
-
<span
|
1380
|
-
style={{
|
1381
|
-
width: `${
|
1382
|
-
file.state === 'uploaded'
|
1383
|
-
? 100
|
1384
|
-
: (file.progress || 0) * 100
|
1385
|
-
}%`
|
1386
|
-
}}
|
1387
|
-
/>
|
1388
|
-
</div>
|
1389
|
-
|
1390
|
-
{file.state === 'uploaded' ? (
|
1391
|
-
<Icon icon="success" className="icon" />
|
1392
|
-
) : (
|
1393
|
-
<span>
|
1394
|
-
{Math.round((file.progress || 0) * 100)}%
|
1395
|
-
</span>
|
1396
|
-
)}
|
1397
|
-
</div>
|
1398
|
-
) : null}
|
1399
|
-
</li>
|
1400
|
-
))}
|
1401
|
-
</ul>
|
1402
|
-
) : null}
|
1403
1365
|
</>
|
1404
1366
|
)}
|
1405
1367
|
</div>
|
1406
1368
|
)}
|
1407
1369
|
</DropZone>
|
1408
1370
|
|
1371
|
+
{maxSize && !drag ? (
|
1372
|
+
<div className={cx('FileControl-sizeTip')}>
|
1373
|
+
{__('File.sizeLimit', {maxSize})}
|
1374
|
+
</div>
|
1375
|
+
) : null}
|
1376
|
+
|
1377
|
+
{Array.isArray(files) ? (
|
1378
|
+
<ul className={cx('FileControl-list')}>
|
1379
|
+
{files.map((file, index) => {
|
1380
|
+
const filename =
|
1381
|
+
file[nameField as keyof typeof file] ||
|
1382
|
+
(file as FileValue).filename;
|
1383
|
+
|
1384
|
+
return (
|
1385
|
+
<li key={file.id}>
|
1386
|
+
<TooltipWrapper
|
1387
|
+
placement="bottom"
|
1388
|
+
tooltipClassName={cx('FileControl-list-tooltip')}
|
1389
|
+
tooltip={
|
1390
|
+
file.state === 'invalid' || file.state === 'error'
|
1391
|
+
? (file as FileValue).error ||
|
1392
|
+
(maxSize && file.size > maxSize
|
1393
|
+
? __('File.maxSize', {
|
1394
|
+
filename: file.name,
|
1395
|
+
actualSize: ImageControl.formatFileSize(
|
1396
|
+
file.size
|
1397
|
+
),
|
1398
|
+
maxSize: ImageControl.formatFileSize(maxSize)
|
1399
|
+
})
|
1400
|
+
: '')
|
1401
|
+
: ''
|
1402
|
+
}
|
1403
|
+
>
|
1404
|
+
<div
|
1405
|
+
className={cx('FileControl-itemInfo', {
|
1406
|
+
'is-invalid':
|
1407
|
+
file.state === 'invalid' || file.state === 'error'
|
1408
|
+
})}
|
1409
|
+
>
|
1410
|
+
<span className={cx('FileControl-itemInfoIcon')}>
|
1411
|
+
<Icon icon="file" className="icon" />
|
1412
|
+
</span>
|
1413
|
+
|
1414
|
+
{(file as FileValue)[urlField] ||
|
1415
|
+
(file as FileValue)[valueField] ||
|
1416
|
+
downloadUrl ? (
|
1417
|
+
<a
|
1418
|
+
className={cx('FileControl-itemInfoText')}
|
1419
|
+
target="_blank"
|
1420
|
+
rel="noopener"
|
1421
|
+
href="#"
|
1422
|
+
onClick={this.handleClickFile.bind(this, file)}
|
1423
|
+
>
|
1424
|
+
{filename}
|
1425
|
+
</a>
|
1426
|
+
) : (
|
1427
|
+
<span className={cx('FileControl-itemInfoText')}>
|
1428
|
+
{filename}
|
1429
|
+
</span>
|
1430
|
+
)}
|
1431
|
+
|
1432
|
+
{!disabled ? (
|
1433
|
+
<a
|
1434
|
+
data-tooltip={__('Select.clear')}
|
1435
|
+
data-position="left"
|
1436
|
+
className={cx('FileControl-clear')}
|
1437
|
+
onClick={() => this.removeFile(file, index)}
|
1438
|
+
>
|
1439
|
+
<Icon icon="close" className="icon" />
|
1440
|
+
</a>
|
1441
|
+
) : null}
|
1442
|
+
</div>
|
1443
|
+
</TooltipWrapper>
|
1444
|
+
|
1445
|
+
{file.state === 'uploading' ? (
|
1446
|
+
<div className={cx('FileControl-progressInfo')}>
|
1447
|
+
<div className={cx('FileControl-progress')}>
|
1448
|
+
<span
|
1449
|
+
style={{width: `${(file.progress || 0) * 100}%`}}
|
1450
|
+
/>
|
1451
|
+
</div>
|
1452
|
+
<span>{Math.round((file.progress || 0) * 100)}%</span>
|
1453
|
+
</div>
|
1454
|
+
) : null}
|
1455
|
+
</li>
|
1456
|
+
);
|
1457
|
+
})}
|
1458
|
+
</ul>
|
1459
|
+
) : null}
|
1460
|
+
|
1409
1461
|
{failed ? (
|
1410
1462
|
<div className={cx('FileControl-sum')}>
|
1411
1463
|
{__('File.result', {
|
@@ -6,7 +6,7 @@ import DropZone from 'react-dropzone';
|
|
6
6
|
import {FileRejection} from 'react-dropzone';
|
7
7
|
import 'blueimp-canvastoblob';
|
8
8
|
import find from 'lodash/find';
|
9
|
-
import {Payload} from '../../types';
|
9
|
+
import {Payload, Action} from '../../types';
|
10
10
|
import {buildApi} from '../../utils/api';
|
11
11
|
import {
|
12
12
|
createObject,
|
@@ -244,7 +244,7 @@ export interface ImageControlSchema extends FormBaseControl {
|
|
244
244
|
/**
|
245
245
|
* 初始化时是否把其他字段同步到表单内部。
|
246
246
|
*/
|
247
|
-
initAutoFill?: boolean
|
247
|
+
initAutoFill?: boolean;
|
248
248
|
|
249
249
|
/**
|
250
250
|
* 默认占位图图片地址
|
@@ -314,6 +314,9 @@ export interface FileX extends File {
|
|
314
314
|
[propName: string]: any;
|
315
315
|
}
|
316
316
|
|
317
|
+
export type InputImageRendererEvent = 'change' | 'success' | 'fail' | 'remove';
|
318
|
+
export type InputImageRendererAction = 'clear';
|
319
|
+
|
317
320
|
export default class ImageControl extends React.Component<
|
318
321
|
ImageProps,
|
319
322
|
ImageState
|
@@ -501,8 +504,8 @@ export default class ImageControl extends React.Component<
|
|
501
504
|
this.syncAutoFill
|
502
505
|
);
|
503
506
|
} else if (prevProps.value !== props.value && !this.initAutoFill) {
|
504
|
-
this.initAutoFill = true
|
505
|
-
this.syncAutoFill()
|
507
|
+
this.initAutoFill = true;
|
508
|
+
this.syncAutoFill();
|
506
509
|
}
|
507
510
|
|
508
511
|
if (prevProps.crop !== props.crop) {
|
@@ -1245,10 +1248,19 @@ export default class ImageControl extends React.Component<
|
|
1245
1248
|
|
1246
1249
|
async dispatchEvent(e: string, data?: Record<string, any>) {
|
1247
1250
|
const {dispatchEvent} = this.props;
|
1248
|
-
data = data ? data : this.
|
1251
|
+
data = data ? data : this.files;
|
1249
1252
|
return dispatchEvent(e, createObject(this.props.data, {file: data}));
|
1250
1253
|
}
|
1251
1254
|
|
1255
|
+
// 动作
|
1256
|
+
doAction(action: Action, data: object, throwErrors: boolean) {
|
1257
|
+
const {onChange} = this.props;
|
1258
|
+
if (action.actionType === 'clear') {
|
1259
|
+
this.files = [];
|
1260
|
+
onChange('');
|
1261
|
+
}
|
1262
|
+
}
|
1263
|
+
|
1252
1264
|
render() {
|
1253
1265
|
const {
|
1254
1266
|
className,
|
@@ -1380,37 +1392,51 @@ export default class ImageControl extends React.Component<
|
|
1380
1392
|
>
|
1381
1393
|
{file.state === 'invalid' ||
|
1382
1394
|
file.state === 'error' ? (
|
1383
|
-
|
1384
|
-
<
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1395
|
+
<div className={cx('Image--thumb')}>
|
1396
|
+
<div className={cx('Image-thumbWrap')}>
|
1397
|
+
<div
|
1398
|
+
className={cx(
|
1399
|
+
'Image-thumb',
|
1400
|
+
'ImageControl-filename'
|
1401
|
+
)}
|
1402
|
+
>
|
1403
|
+
<Icon icon="image" className="icon" />
|
1404
|
+
<span
|
1405
|
+
title={
|
1406
|
+
file.name ||
|
1407
|
+
getNameFromUrl(file.value || file.url)
|
1408
|
+
}
|
1409
|
+
>
|
1410
|
+
{file.name ||
|
1411
|
+
getNameFromUrl(file.value || file.url)}
|
1412
|
+
</span>
|
1413
|
+
</div>
|
1396
1414
|
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1415
|
+
<div className={cx('Image-overlay')}>
|
1416
|
+
<a
|
1417
|
+
data-tooltip={__('File.repick')}
|
1418
|
+
data-position="bottom"
|
1419
|
+
onClick={this.handleRetry.bind(this, key)}
|
1420
|
+
>
|
1421
|
+
<Icon icon="refresh" className="icon" />
|
1422
|
+
</a>
|
1423
|
+
|
1424
|
+
{!disabled ? (
|
1425
|
+
<a
|
1426
|
+
data-tooltip={__('Select.clear')}
|
1427
|
+
data-position="bottom"
|
1428
|
+
onClick={this.removeFile.bind(
|
1429
|
+
this,
|
1430
|
+
file,
|
1431
|
+
key
|
1432
|
+
)}
|
1433
|
+
>
|
1434
|
+
<Icon icon="remove" className="icon" />
|
1435
|
+
</a>
|
1436
|
+
) : null}
|
1437
|
+
</div>
|
1438
|
+
</div>
|
1439
|
+
</div>
|
1414
1440
|
) : file.state === 'uploading' ? (
|
1415
1441
|
<>
|
1416
1442
|
<a
|