@kne/react-form-antd 2.1.38 → 2.1.40
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/LICENSE +21 -21
- package/README.md +35 -35
- package/dist/index.js +128 -260
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +96 -216
- package/dist/index.modern.js.map +1 -1
- package/package.json +91 -91
package/dist/index.modern.js
CHANGED
|
@@ -24,31 +24,26 @@ function _extends() {
|
|
|
24
24
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
25
25
|
for (var i = 1; i < arguments.length; i++) {
|
|
26
26
|
var source = arguments[i];
|
|
27
|
-
|
|
28
27
|
for (var key in source) {
|
|
29
28
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
30
29
|
target[key] = source[key];
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
return target;
|
|
36
34
|
};
|
|
37
35
|
return _extends.apply(this, arguments);
|
|
38
36
|
}
|
|
39
|
-
|
|
40
37
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
41
38
|
if (source == null) return {};
|
|
42
39
|
var target = {};
|
|
43
40
|
var sourceKeys = Object.keys(source);
|
|
44
41
|
var key, i;
|
|
45
|
-
|
|
46
42
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
47
43
|
key = sourceKeys[i];
|
|
48
44
|
if (excluded.indexOf(key) >= 0) continue;
|
|
49
45
|
target[key] = source[key];
|
|
50
46
|
}
|
|
51
|
-
|
|
52
47
|
return target;
|
|
53
48
|
}
|
|
54
49
|
|
|
@@ -107,15 +102,14 @@ const {
|
|
|
107
102
|
} = widget;
|
|
108
103
|
const Form = forwardRef((originProps, ref) => {
|
|
109
104
|
const {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
105
|
+
className,
|
|
106
|
+
cache,
|
|
107
|
+
enterSubmit,
|
|
108
|
+
scrollToError,
|
|
109
|
+
scrollProps,
|
|
110
|
+
children
|
|
111
|
+
} = originProps,
|
|
112
|
+
props = _objectWithoutPropertiesLoose(originProps, _excluded$9);
|
|
119
113
|
const baseClass = 'react-form';
|
|
120
114
|
let computedClass = baseClass;
|
|
121
115
|
const {
|
|
@@ -125,15 +119,12 @@ const Form = forwardRef((originProps, ref) => {
|
|
|
125
119
|
type: 'default',
|
|
126
120
|
size: 'middle'
|
|
127
121
|
}, globalParams, originProps);
|
|
128
|
-
|
|
129
122
|
if (type !== 'default') {
|
|
130
123
|
computedClass += `--${type}`;
|
|
131
124
|
}
|
|
132
|
-
|
|
133
125
|
if (size !== 'middle') {
|
|
134
126
|
computedClass += `--${size}`;
|
|
135
127
|
}
|
|
136
|
-
|
|
137
128
|
const maxLabel = /*#__PURE__*/React__default.createElement(MaxLabelProvider, null, children);
|
|
138
129
|
return /*#__PURE__*/React__default.createElement("form", {
|
|
139
130
|
className: classnames(baseClass, computedClass, className),
|
|
@@ -228,16 +219,12 @@ const getPopupContainer = triggerNode => {
|
|
|
228
219
|
if (el === document.body || !el.parentElement) {
|
|
229
220
|
return document.body;
|
|
230
221
|
}
|
|
231
|
-
|
|
232
222
|
const targetEl = [].slice.call(el.classList, 0).find(className => ['ant-modal-body', 'ant-modal-content', 'ant-popover-content'].indexOf(className) > -1);
|
|
233
|
-
|
|
234
223
|
if (targetEl) {
|
|
235
224
|
return el;
|
|
236
225
|
}
|
|
237
|
-
|
|
238
226
|
return findAntdPopupContainer(el.parentElement);
|
|
239
227
|
};
|
|
240
|
-
|
|
241
228
|
return findAntdPopupContainer(triggerNode);
|
|
242
229
|
};
|
|
243
230
|
|
|
@@ -248,23 +235,22 @@ const {
|
|
|
248
235
|
const avatarParams = globalParams.field.avatar;
|
|
249
236
|
const createAvatarEditor = withLayer(_ref => {
|
|
250
237
|
let {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
238
|
+
close,
|
|
239
|
+
file,
|
|
240
|
+
editor,
|
|
241
|
+
onComplete
|
|
242
|
+
} = _ref,
|
|
243
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
258
244
|
const editorRef = useRef(null);
|
|
259
245
|
const [rotate, setRotate] = useState(0);
|
|
260
246
|
const [scale, setScale] = useState(() => {
|
|
261
247
|
if (editor.width === editor.height) {
|
|
262
248
|
return 1;
|
|
263
249
|
}
|
|
264
|
-
|
|
265
250
|
return 0.35;
|
|
266
251
|
});
|
|
267
252
|
return /*#__PURE__*/React__default.createElement(Modal, _extends({}, props, {
|
|
253
|
+
className: editor.className,
|
|
268
254
|
centered: true,
|
|
269
255
|
onOk: () => {
|
|
270
256
|
onComplete && onComplete(editorRef.current.getImage().toDataURL());
|
|
@@ -331,7 +317,6 @@ const createAvatarEditor = withLayer(_ref => {
|
|
|
331
317
|
onChange: setScale
|
|
332
318
|
})))));
|
|
333
319
|
});
|
|
334
|
-
|
|
335
320
|
const _Avatar = ({
|
|
336
321
|
className,
|
|
337
322
|
value: imageUrl,
|
|
@@ -370,33 +355,27 @@ const _Avatar = ({
|
|
|
370
355
|
useEffect(() => {
|
|
371
356
|
setImageUrl(imageUrl);
|
|
372
357
|
}, [imageUrl]);
|
|
373
|
-
/* base64转blob */
|
|
374
358
|
|
|
359
|
+
/* base64转blob */
|
|
375
360
|
const dataURLtoBlob = dataurl => {
|
|
376
|
-
let arr = dataurl.split(",");
|
|
377
|
-
|
|
361
|
+
let arr = dataurl.split(",");
|
|
362
|
+
// 注意base64的最后面中括号和引号是不转译的
|
|
378
363
|
let _arr = arr[1].substring(0, arr[1].length - 2);
|
|
379
|
-
|
|
380
364
|
let mime = arr[0].match(/:(.*?);/)[1],
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
365
|
+
bstr = atob(_arr),
|
|
366
|
+
n = bstr.length,
|
|
367
|
+
u8arr = new Uint8Array(n);
|
|
385
368
|
while (n--) {
|
|
386
369
|
u8arr[n] = bstr.charCodeAt(n);
|
|
387
370
|
}
|
|
388
|
-
|
|
389
371
|
return new Blob([u8arr], {
|
|
390
372
|
type: mime
|
|
391
373
|
});
|
|
392
374
|
};
|
|
393
|
-
|
|
394
375
|
const uploadButton = /*#__PURE__*/React__default.createElement("div", null, loading ? /*#__PURE__*/React__default.createElement(LoadingOutlined, null) : /*#__PURE__*/React__default.createElement(PlusOutlined, null), children);
|
|
395
|
-
|
|
396
376
|
const beforeUpload = async file => {
|
|
397
377
|
return new Promise((resolve, reject) => {
|
|
398
378
|
const isJpgOrPng = imageType.indexOf(file.type) > -1;
|
|
399
|
-
|
|
400
379
|
if (!isJpgOrPng) {
|
|
401
380
|
onError(`只支持${imageType.map(str => str.replace("image/", "")).join("/")}格式图片!`, "typeError", {
|
|
402
381
|
type: imageType,
|
|
@@ -405,9 +384,7 @@ const _Avatar = ({
|
|
|
405
384
|
reject();
|
|
406
385
|
return false;
|
|
407
386
|
}
|
|
408
|
-
|
|
409
387
|
const isLt = file.size / 1024 / 1024 < size;
|
|
410
|
-
|
|
411
388
|
if (!isLt) {
|
|
412
389
|
onError(`图片不能超过${size}MB!`, "sizeError", {
|
|
413
390
|
size,
|
|
@@ -416,10 +393,9 @@ const _Avatar = ({
|
|
|
416
393
|
reject();
|
|
417
394
|
return false;
|
|
418
395
|
}
|
|
396
|
+
|
|
419
397
|
/*剪切图像*/
|
|
420
398
|
// editor:{open:false,width:250,height:250,borderRadius:0-100,text:'剪切'}
|
|
421
|
-
|
|
422
|
-
|
|
423
399
|
if (editor.open) {
|
|
424
400
|
createAvatarEditor({
|
|
425
401
|
editor,
|
|
@@ -445,17 +421,14 @@ const _Avatar = ({
|
|
|
445
421
|
}
|
|
446
422
|
});
|
|
447
423
|
};
|
|
448
|
-
|
|
449
424
|
const onChange = info => {
|
|
450
425
|
if (info.file.status === "uploading") {
|
|
451
426
|
setLoading(true);
|
|
452
427
|
return;
|
|
453
428
|
}
|
|
454
|
-
|
|
455
429
|
if (info.file.status === "done") {
|
|
456
430
|
setLoading(false);
|
|
457
431
|
const response = (transformResponse || avatarParams.transformResponse)(info.file.response);
|
|
458
|
-
|
|
459
432
|
if (response.code === 200) {
|
|
460
433
|
propsChange(response.results);
|
|
461
434
|
} else {
|
|
@@ -463,13 +436,10 @@ const _Avatar = ({
|
|
|
463
436
|
}
|
|
464
437
|
}
|
|
465
438
|
};
|
|
466
|
-
|
|
467
439
|
const headers = Object.assign({}, avatarParams.headers);
|
|
468
|
-
|
|
469
440
|
if (typeof avatarParams.getHeaders === 'function') {
|
|
470
441
|
Object.assign(headers, avatarParams.getHeaders());
|
|
471
442
|
}
|
|
472
|
-
|
|
473
443
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Upload$1, _extends({}, omit(avatarParams, ['action', 'transformResponse', 'headers', 'getHeaders']), {
|
|
474
444
|
headers: headers,
|
|
475
445
|
className: classnames(className, "react-form-avatar"),
|
|
@@ -487,7 +457,6 @@ const _Avatar = ({
|
|
|
487
457
|
alt: "avatar"
|
|
488
458
|
})) : uploadButton, extraRender ? extraRender(showImageUrl) : '')));
|
|
489
459
|
};
|
|
490
|
-
|
|
491
460
|
_Avatar.defaultProps = {
|
|
492
461
|
imageType: ["image/jpeg", "image/png"],
|
|
493
462
|
fileSize: 2,
|
|
@@ -501,12 +470,10 @@ _Avatar.defaultProps = {
|
|
|
501
470
|
previewRender: null,
|
|
502
471
|
openEditor: false
|
|
503
472
|
};
|
|
504
|
-
|
|
505
473
|
const AvatarInput = props => {
|
|
506
474
|
const render = useOnChange$d(props);
|
|
507
475
|
return render(_Avatar);
|
|
508
476
|
};
|
|
509
|
-
|
|
510
477
|
AvatarInput.defaultProps = {
|
|
511
478
|
fieldName: 'avatar'
|
|
512
479
|
};
|
|
@@ -515,12 +482,10 @@ AvatarInput.field = _Avatar;
|
|
|
515
482
|
const {
|
|
516
483
|
useOnChange: useOnChange$c
|
|
517
484
|
} = hooks;
|
|
518
|
-
|
|
519
485
|
const Cascader$1 = props => {
|
|
520
486
|
const render = useOnChange$c(props);
|
|
521
487
|
return render(Cascader$2);
|
|
522
488
|
};
|
|
523
|
-
|
|
524
489
|
Cascader$1.defaultProps = {
|
|
525
490
|
fieldName: 'cascader'
|
|
526
491
|
};
|
|
@@ -533,13 +498,11 @@ const {
|
|
|
533
498
|
withChecked: withChecked$1
|
|
534
499
|
} = hoc;
|
|
535
500
|
const WithCheckbox = withChecked$1(Checkbox$2);
|
|
536
|
-
|
|
537
501
|
const Checkbox$1 = props => {
|
|
538
502
|
const checkedProps = useCheckedToValue$1(props);
|
|
539
503
|
const render = useOnChange$b(checkedProps);
|
|
540
504
|
return render(WithCheckbox);
|
|
541
505
|
};
|
|
542
|
-
|
|
543
506
|
Checkbox$1.defaultProps = {
|
|
544
507
|
fieldName: 'checkbox'
|
|
545
508
|
};
|
|
@@ -548,12 +511,10 @@ const {
|
|
|
548
511
|
useOnChange: useOnChange$a
|
|
549
512
|
} = hooks;
|
|
550
513
|
const _CheckboxGroup = Checkbox$2.Group;
|
|
551
|
-
|
|
552
514
|
const CheckboxGroup$1 = props => {
|
|
553
515
|
const render = useOnChange$a(props);
|
|
554
516
|
return render(_CheckboxGroup);
|
|
555
517
|
};
|
|
556
|
-
|
|
557
518
|
CheckboxGroup$1.Checkbox = Checkbox$2;
|
|
558
519
|
CheckboxGroup$1.defaultProps = {
|
|
559
520
|
fieldName: 'checkboxGroup'
|
|
@@ -567,50 +528,42 @@ const {
|
|
|
567
528
|
RangePicker: RangePicker$1,
|
|
568
529
|
WeekPicker
|
|
569
530
|
} = DatePicker$1;
|
|
570
|
-
|
|
571
531
|
const _DatePicker = props => {
|
|
572
532
|
const render = useOnChange$9(Object.assign({
|
|
573
533
|
placeholder: `请选择${props.label || ''}`
|
|
574
534
|
}, props));
|
|
575
535
|
return render(DatePicker$1);
|
|
576
536
|
};
|
|
577
|
-
|
|
578
537
|
_DatePicker.defaultProps = {
|
|
579
538
|
fieldName: 'datePicker',
|
|
580
539
|
getPopupContainer
|
|
581
540
|
};
|
|
582
|
-
|
|
583
541
|
const _MonthPicker = props => {
|
|
584
542
|
const render = useOnChange$9(Object.assign({
|
|
585
543
|
placeholder: ['开始时间', '结束时间']
|
|
586
544
|
}, props));
|
|
587
545
|
return render(MonthPicker);
|
|
588
546
|
};
|
|
589
|
-
|
|
590
547
|
_MonthPicker.defaultProps = {
|
|
591
548
|
fieldName: 'monthDatePicker',
|
|
592
549
|
getPopupContainer
|
|
593
550
|
};
|
|
594
|
-
|
|
595
551
|
const _RangePicker$1 = props => {
|
|
596
552
|
const render = useOnChange$9(Object.assign({
|
|
597
553
|
placeholder: ['开始时间', '结束时间']
|
|
598
554
|
}, props));
|
|
599
555
|
return render(RangePicker$1);
|
|
600
556
|
};
|
|
601
|
-
|
|
602
557
|
_RangePicker$1.defaultProps = {
|
|
603
558
|
fieldName: 'rangeDatePicker',
|
|
604
559
|
getPopupContainer
|
|
605
560
|
};
|
|
606
|
-
|
|
607
561
|
const _WeekPicker = props => {
|
|
608
562
|
const render = useOnChange$9(Object.assign({
|
|
609
563
|
placeholder: ['开始时间', '结束时间']
|
|
610
564
|
}, props));
|
|
611
565
|
return render(WeekPicker);
|
|
612
566
|
};
|
|
613
|
-
|
|
614
567
|
_WeekPicker.defaultProps = {
|
|
615
568
|
fieldName: 'weekDatePicker',
|
|
616
569
|
getPopupContainer
|
|
@@ -623,13 +576,11 @@ const _excluded$7 = ["soFarText"];
|
|
|
623
576
|
const {
|
|
624
577
|
useOnChange: useOnChange$8
|
|
625
578
|
} = hooks;
|
|
626
|
-
|
|
627
579
|
const PickerToday = _ref => {
|
|
628
580
|
let {
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
581
|
+
soFarText
|
|
582
|
+
} = _ref,
|
|
583
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
633
584
|
const [data, onChange] = useControlValue(props);
|
|
634
585
|
const ref_d = useRef();
|
|
635
586
|
const newData = useMemo(() => {
|
|
@@ -644,26 +595,21 @@ const PickerToday = _ref => {
|
|
|
644
595
|
placeholder: p
|
|
645
596
|
};
|
|
646
597
|
}, [data]);
|
|
647
|
-
|
|
648
598
|
const startChange = v => {
|
|
649
599
|
// 比较日期大小
|
|
650
600
|
if (!newData.showZj && newData.end && v && newData.end.isBefore(v)) {
|
|
651
601
|
onChange([newData.end, v]);
|
|
652
602
|
return;
|
|
653
603
|
}
|
|
654
|
-
|
|
655
604
|
onChange([v || '', newData.showZj ? '至今' : newData.end]);
|
|
656
605
|
};
|
|
657
|
-
|
|
658
606
|
const endChange = v => {
|
|
659
607
|
if (newData.start && v && v.isBefore(newData.start)) {
|
|
660
608
|
onChange([v, newData.start]);
|
|
661
609
|
return;
|
|
662
610
|
}
|
|
663
|
-
|
|
664
611
|
onChange([newData.start, v || '']);
|
|
665
612
|
};
|
|
666
|
-
|
|
667
613
|
const foot = () => {
|
|
668
614
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
669
615
|
type: newData.showZj ? 'primary' : 'default',
|
|
@@ -673,7 +619,6 @@ const PickerToday = _ref => {
|
|
|
673
619
|
}
|
|
674
620
|
}, soFarText || '至今');
|
|
675
621
|
};
|
|
676
|
-
|
|
677
622
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
678
623
|
style: {
|
|
679
624
|
display: 'flex'
|
|
@@ -712,12 +657,10 @@ const PickerToday = _ref => {
|
|
|
712
657
|
renderExtraFooter: foot
|
|
713
658
|
}))));
|
|
714
659
|
};
|
|
715
|
-
|
|
716
660
|
const RangePickerToday = props => {
|
|
717
661
|
const render = useOnChange$8(props);
|
|
718
662
|
return render(PickerToday);
|
|
719
663
|
};
|
|
720
|
-
|
|
721
664
|
RangePickerToday.defaultProps = {
|
|
722
665
|
fieldName: 'rangePickerToday'
|
|
723
666
|
};
|
|
@@ -726,21 +669,18 @@ RangePickerToday.field = PickerToday;
|
|
|
726
669
|
const {
|
|
727
670
|
useDecorator: useDecorator$2
|
|
728
671
|
} = hooks;
|
|
729
|
-
|
|
730
672
|
const InputField = props => {
|
|
731
673
|
const render = useDecorator$2(Object.assign({
|
|
732
674
|
placeholder: `请输入${props.label}`
|
|
733
675
|
}, props));
|
|
734
676
|
return render(Input$1);
|
|
735
677
|
};
|
|
736
|
-
|
|
737
678
|
InputField.Password = props => {
|
|
738
679
|
const render = useDecorator$2(Object.assign({
|
|
739
680
|
placeholder: `请输入${props.label}`
|
|
740
681
|
}, props));
|
|
741
682
|
return render(Input$1.Password);
|
|
742
683
|
};
|
|
743
|
-
|
|
744
684
|
InputField.defaultProps = {
|
|
745
685
|
fieldName: 'input',
|
|
746
686
|
autoComplete: 'off'
|
|
@@ -753,14 +693,12 @@ InputField.Password.defaultProps = {
|
|
|
753
693
|
const {
|
|
754
694
|
useDecorator: useDecorator$1
|
|
755
695
|
} = hooks;
|
|
756
|
-
|
|
757
696
|
const InputNumberField = props => {
|
|
758
697
|
const render = useDecorator$1(Object.assign({
|
|
759
698
|
placeholder: `请输入${props.label}`
|
|
760
699
|
}, props));
|
|
761
700
|
return render(InputNumber$1);
|
|
762
701
|
};
|
|
763
|
-
|
|
764
702
|
InputNumberField.defaultProps = {
|
|
765
703
|
fieldName: 'inputNumber',
|
|
766
704
|
autoComplete: 'off'
|
|
@@ -770,13 +708,11 @@ const _excluded$6 = ["onChange"];
|
|
|
770
708
|
const {
|
|
771
709
|
useOnChange: useOnChange$7
|
|
772
710
|
} = hooks;
|
|
773
|
-
|
|
774
711
|
const RadioGroup$1 = _ref => {
|
|
775
712
|
let {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
713
|
+
onChange
|
|
714
|
+
} = _ref,
|
|
715
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
780
716
|
const handler = useCallback(e => {
|
|
781
717
|
onChange && onChange(e.target.value);
|
|
782
718
|
}, [onChange]);
|
|
@@ -784,12 +720,10 @@ const RadioGroup$1 = _ref => {
|
|
|
784
720
|
onChange: handler
|
|
785
721
|
}));
|
|
786
722
|
};
|
|
787
|
-
|
|
788
723
|
const _RadioGroup = props => {
|
|
789
724
|
const render = useOnChange$7(props);
|
|
790
725
|
return render(RadioGroup$1);
|
|
791
726
|
};
|
|
792
|
-
|
|
793
727
|
_RadioGroup.defaultProps = {
|
|
794
728
|
fieldName: 'radioGroup'
|
|
795
729
|
};
|
|
@@ -799,25 +733,23 @@ const _excluded$5 = ["data", "setData", "send", "loadMore", "isComplete", "refre
|
|
|
799
733
|
const {
|
|
800
734
|
useOnChange: useOnChange$6
|
|
801
735
|
} = hooks;
|
|
802
|
-
|
|
803
736
|
const withFetch = WrappedComponent => {
|
|
804
737
|
const FieldInner = withFetch$1(_ref => {
|
|
805
738
|
let {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
739
|
+
data,
|
|
740
|
+
setData,
|
|
741
|
+
send,
|
|
742
|
+
loadMore,
|
|
743
|
+
isComplete,
|
|
744
|
+
refresh,
|
|
745
|
+
reload,
|
|
746
|
+
fetchEmitter,
|
|
747
|
+
isLoading,
|
|
748
|
+
children,
|
|
749
|
+
onLoaded,
|
|
750
|
+
fetchProps
|
|
751
|
+
} = _ref,
|
|
752
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
821
753
|
const refreshRef = useRef(refresh);
|
|
822
754
|
refreshRef.current = refresh;
|
|
823
755
|
const reloadRef = useRef(reload);
|
|
@@ -850,7 +782,6 @@ const withFetch = WrappedComponent => {
|
|
|
850
782
|
setData
|
|
851
783
|
})));
|
|
852
784
|
});
|
|
853
|
-
|
|
854
785
|
const useFetchEmitter = ref => {
|
|
855
786
|
const emitter = useEvent();
|
|
856
787
|
useImperativeHandle(ref, () => {
|
|
@@ -862,7 +793,6 @@ const withFetch = WrappedComponent => {
|
|
|
862
793
|
}, [emitter]);
|
|
863
794
|
return emitter;
|
|
864
795
|
};
|
|
865
|
-
|
|
866
796
|
const Fetch = forwardRef((props, ref) => {
|
|
867
797
|
const emitter = useFetchEmitter(ref);
|
|
868
798
|
const render = useOnChange$6(Object.assign({
|
|
@@ -884,14 +814,12 @@ const withFetch = WrappedComponent => {
|
|
|
884
814
|
const {
|
|
885
815
|
useOnChange: useOnChange$5
|
|
886
816
|
} = hooks;
|
|
887
|
-
|
|
888
817
|
const _Select = props => {
|
|
889
818
|
const render = useOnChange$5(Object.assign({
|
|
890
819
|
placeholder: `请选择${props.label || ''}`
|
|
891
820
|
}, props));
|
|
892
821
|
return render(Select$1);
|
|
893
822
|
};
|
|
894
|
-
|
|
895
823
|
_Select.Fetch = withFetch(Select$1);
|
|
896
824
|
_Select.Option = Select$1.Option;
|
|
897
825
|
_Select.OptGroup = Select$1.OptGroup;
|
|
@@ -904,20 +832,18 @@ const _excluded$4 = ["data", "setData", "refresh", "reload", "emitter", "isLoadi
|
|
|
904
832
|
const {
|
|
905
833
|
useOnChange: useOnChange$4
|
|
906
834
|
} = hooks;
|
|
907
|
-
|
|
908
835
|
const _SelectFetch = withFetch$1(_ref => {
|
|
909
836
|
let {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
837
|
+
data,
|
|
838
|
+
setData,
|
|
839
|
+
refresh,
|
|
840
|
+
reload,
|
|
841
|
+
emitter,
|
|
842
|
+
isLoading,
|
|
843
|
+
children,
|
|
844
|
+
onLoaded
|
|
845
|
+
} = _ref,
|
|
846
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
921
847
|
const refreshRef = useRef(refresh);
|
|
922
848
|
refreshRef.current = refresh;
|
|
923
849
|
const reloadRef = useRef(reload);
|
|
@@ -946,7 +872,6 @@ const _SelectFetch = withFetch$1(_ref => {
|
|
|
946
872
|
setData
|
|
947
873
|
}));
|
|
948
874
|
});
|
|
949
|
-
|
|
950
875
|
const SelectFetch$1 = forwardRef((props, ref) => {
|
|
951
876
|
const emitter = useEvent();
|
|
952
877
|
useImperativeHandle(ref, () => {
|
|
@@ -991,13 +916,11 @@ const {
|
|
|
991
916
|
withChecked
|
|
992
917
|
} = hoc;
|
|
993
918
|
const WithSwitch = withChecked(Switch$2);
|
|
994
|
-
|
|
995
919
|
const Switch$1 = props => {
|
|
996
920
|
const checkedProps = useCheckedToValue(props);
|
|
997
921
|
const render = useOnChange$3(checkedProps);
|
|
998
922
|
return render(WithSwitch);
|
|
999
923
|
};
|
|
1000
|
-
|
|
1001
924
|
Switch$1.defaultProps = {
|
|
1002
925
|
fieldName: 'switch'
|
|
1003
926
|
};
|
|
@@ -1005,14 +928,12 @@ Switch$1.defaultProps = {
|
|
|
1005
928
|
const {
|
|
1006
929
|
useDecorator
|
|
1007
930
|
} = hooks;
|
|
1008
|
-
|
|
1009
931
|
const TextArea$1 = props => {
|
|
1010
932
|
const render = useDecorator(Object.assign({
|
|
1011
933
|
placeholder: `请输入${props.label}`
|
|
1012
934
|
}, props));
|
|
1013
935
|
return render(Input$1.TextArea);
|
|
1014
936
|
};
|
|
1015
|
-
|
|
1016
937
|
TextArea$1.defaultProps = {
|
|
1017
938
|
fieldName: 'textArea'
|
|
1018
939
|
};
|
|
@@ -1023,26 +944,22 @@ const {
|
|
|
1023
944
|
const {
|
|
1024
945
|
RangePicker
|
|
1025
946
|
} = TimePicker$1;
|
|
1026
|
-
|
|
1027
947
|
const _TimePicker = props => {
|
|
1028
948
|
const render = useOnChange$2(Object.assign({
|
|
1029
949
|
placeholder: `请选择${props.label || ''}`
|
|
1030
950
|
}, props));
|
|
1031
951
|
return render(TimePicker$1);
|
|
1032
952
|
};
|
|
1033
|
-
|
|
1034
953
|
_TimePicker.defaultProps = {
|
|
1035
954
|
fieldName: 'timePicker',
|
|
1036
955
|
getPopupContainer
|
|
1037
956
|
};
|
|
1038
|
-
|
|
1039
957
|
const _RangePicker = props => {
|
|
1040
958
|
const render = useOnChange$2(Object.assign({
|
|
1041
959
|
placeholder: `请选择${props.label || ''}`
|
|
1042
960
|
}, props));
|
|
1043
961
|
return render(RangePicker);
|
|
1044
962
|
};
|
|
1045
|
-
|
|
1046
963
|
_RangePicker.defaultProps = {
|
|
1047
964
|
fieldName: 'rangeTimePicker',
|
|
1048
965
|
getPopupContainer
|
|
@@ -1052,14 +969,12 @@ _TimePicker.RangePicker = _RangePicker;
|
|
|
1052
969
|
const {
|
|
1053
970
|
useOnChange: useOnChange$1
|
|
1054
971
|
} = hooks;
|
|
1055
|
-
|
|
1056
972
|
const _TreeSelect = props => {
|
|
1057
973
|
const render = useOnChange$1(Object.assign({
|
|
1058
974
|
placeholder: `请选择${props.label || ''}`
|
|
1059
975
|
}, props));
|
|
1060
976
|
return render(TreeSelect$1);
|
|
1061
977
|
};
|
|
1062
|
-
|
|
1063
978
|
_TreeSelect.Fetch = withFetch(TreeSelect$1);
|
|
1064
979
|
_TreeSelect.defaultProps = _TreeSelect.Fetch.defaultProps = {
|
|
1065
980
|
fieldName: 'treeSelect',
|
|
@@ -1075,30 +990,24 @@ const {
|
|
|
1075
990
|
Dragger
|
|
1076
991
|
} = Upload$1;
|
|
1077
992
|
const uploadParams = globalParams.field.upload;
|
|
1078
|
-
|
|
1079
993
|
const computedFilename = (path, displayFilename = 'filename') => {
|
|
1080
994
|
const strArray = path.split('?');
|
|
1081
|
-
|
|
1082
995
|
if (strArray[1]) {
|
|
1083
996
|
const query = {};
|
|
1084
997
|
strArray[1].split('&').forEach(str => {
|
|
1085
998
|
const [key, value] = str.split('=');
|
|
1086
999
|
query[key] = value;
|
|
1087
1000
|
});
|
|
1088
|
-
|
|
1089
1001
|
if (query[displayFilename]) {
|
|
1090
1002
|
return decodeURIComponent(query[displayFilename]);
|
|
1091
1003
|
}
|
|
1092
1004
|
}
|
|
1093
|
-
|
|
1094
1005
|
return path;
|
|
1095
1006
|
};
|
|
1096
|
-
|
|
1097
1007
|
const valueToList = (value, displayFilename) => {
|
|
1098
1008
|
if (!value) {
|
|
1099
1009
|
return [];
|
|
1100
1010
|
}
|
|
1101
|
-
|
|
1102
1011
|
return value.map(item => {
|
|
1103
1012
|
return {
|
|
1104
1013
|
uid: uniqueId(),
|
|
@@ -1111,7 +1020,6 @@ const valueToList = (value, displayFilename) => {
|
|
|
1111
1020
|
};
|
|
1112
1021
|
});
|
|
1113
1022
|
};
|
|
1114
|
-
|
|
1115
1023
|
const listToValue = value => {
|
|
1116
1024
|
return (value || []).slice(0).filter(({
|
|
1117
1025
|
status
|
|
@@ -1119,25 +1027,23 @@ const listToValue = value => {
|
|
|
1119
1027
|
response
|
|
1120
1028
|
}) => response.results);
|
|
1121
1029
|
};
|
|
1122
|
-
|
|
1123
1030
|
const _Upload = _ref => {
|
|
1124
1031
|
let {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1032
|
+
action,
|
|
1033
|
+
value,
|
|
1034
|
+
onChange,
|
|
1035
|
+
drag,
|
|
1036
|
+
children,
|
|
1037
|
+
displayFilename,
|
|
1038
|
+
accept,
|
|
1039
|
+
fileSize: size,
|
|
1040
|
+
onError,
|
|
1041
|
+
onUploadComplete,
|
|
1042
|
+
onBeforeUpload,
|
|
1043
|
+
maxLength,
|
|
1044
|
+
transformResponse
|
|
1045
|
+
} = _ref,
|
|
1046
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
1141
1047
|
displayFilename = displayFilename || uploadParams.displayFilename;
|
|
1142
1048
|
value = value || [];
|
|
1143
1049
|
const [list, setList] = useState([]);
|
|
@@ -1146,22 +1052,18 @@ const _Upload = _ref => {
|
|
|
1146
1052
|
return !list.find(file => get(file, 'response.results') === url);
|
|
1147
1053
|
}), displayFilename).concat(list);
|
|
1148
1054
|
}, [list, value, displayFilename]);
|
|
1149
|
-
|
|
1150
1055
|
const changeHandler = info => {
|
|
1151
1056
|
if (['uploading', 'done', 'error', 'removed'].indexOf(info.file.status) === -1) {
|
|
1152
1057
|
return;
|
|
1153
1058
|
}
|
|
1154
|
-
|
|
1155
1059
|
if (info.fileList.length > maxLength) {
|
|
1156
1060
|
onError(`上传文件不能超过最大允许数量${maxLength}`, 'lengthError', maxLength);
|
|
1157
1061
|
return;
|
|
1158
1062
|
}
|
|
1159
|
-
|
|
1160
1063
|
if (info.file.status === 'done' && info.fileList.find(({
|
|
1161
1064
|
uid
|
|
1162
1065
|
}) => uid === info.file.uid)) {
|
|
1163
1066
|
info.file.response = (transformResponse || uploadParams.transformResponse)(info.file.response);
|
|
1164
|
-
|
|
1165
1067
|
if (info.file.response.code === 200) {
|
|
1166
1068
|
info.file.name = computedFilename(info.file.response.results.substr(info.file.response.results.lastIndexOf('/') + 1), displayFilename);
|
|
1167
1069
|
onUploadComplete(info);
|
|
@@ -1170,21 +1072,16 @@ const _Upload = _ref => {
|
|
|
1170
1072
|
onError(info.file.response.msg, 'xhrError', info.file.response);
|
|
1171
1073
|
}
|
|
1172
1074
|
}
|
|
1173
|
-
|
|
1174
1075
|
const {
|
|
1175
1076
|
done
|
|
1176
1077
|
} = groupBy(info.fileList, file => file.status === 'done' ? 'done' : 'uploading');
|
|
1177
|
-
|
|
1178
1078
|
if (['done', 'removed'].indexOf(info.file.status) > -1) {
|
|
1179
1079
|
onChange(listToValue(done));
|
|
1180
1080
|
}
|
|
1181
|
-
|
|
1182
1081
|
setList(info.fileList);
|
|
1183
1082
|
};
|
|
1184
|
-
|
|
1185
1083
|
const beforeUploadHandler = file => {
|
|
1186
1084
|
const isLt = file.size / 1024 / 1024 < size;
|
|
1187
|
-
|
|
1188
1085
|
if (!isLt) {
|
|
1189
1086
|
onError(`文件不能超过${size}MB!`, 'sizeError', {
|
|
1190
1087
|
size,
|
|
@@ -1192,21 +1089,16 @@ const _Upload = _ref => {
|
|
|
1192
1089
|
});
|
|
1193
1090
|
return false;
|
|
1194
1091
|
}
|
|
1195
|
-
|
|
1196
1092
|
if (maxLength === 1) {
|
|
1197
1093
|
onChange([]);
|
|
1198
1094
|
setList([]);
|
|
1199
1095
|
}
|
|
1200
|
-
|
|
1201
1096
|
return onBeforeUpload && onBeforeUpload(file);
|
|
1202
1097
|
};
|
|
1203
|
-
|
|
1204
1098
|
const headers = Object.assign({}, uploadParams.headers);
|
|
1205
|
-
|
|
1206
1099
|
if (typeof uploadParams.getHeaders === 'function') {
|
|
1207
1100
|
Object.assign(headers, uploadParams.getHeaders());
|
|
1208
1101
|
}
|
|
1209
|
-
|
|
1210
1102
|
const UploadComponent = drag ? Dragger : Upload$1;
|
|
1211
1103
|
return /*#__PURE__*/React__default.createElement(UploadComponent, _extends({}, omit(uploadParams, ['action', 'transformResponse']), {
|
|
1212
1104
|
headers: headers,
|
|
@@ -1219,7 +1111,6 @@ const _Upload = _ref => {
|
|
|
1219
1111
|
size: props.size
|
|
1220
1112
|
}) : children);
|
|
1221
1113
|
};
|
|
1222
|
-
|
|
1223
1114
|
_Upload.defaultProps = {
|
|
1224
1115
|
value: [],
|
|
1225
1116
|
accept: [],
|
|
@@ -1233,40 +1124,34 @@ _Upload.defaultProps = {
|
|
|
1233
1124
|
onError: info => message.error(info),
|
|
1234
1125
|
onUploadComplete: () => {}
|
|
1235
1126
|
};
|
|
1236
|
-
|
|
1237
1127
|
const UploadInput = props => {
|
|
1238
1128
|
const render = useOnChange(props);
|
|
1239
1129
|
return render(_Upload);
|
|
1240
1130
|
};
|
|
1241
|
-
|
|
1242
1131
|
UploadInput.defaultProps = {
|
|
1243
1132
|
fieldName: 'upload'
|
|
1244
1133
|
};
|
|
1245
1134
|
UploadInput.field = _Upload;
|
|
1246
1135
|
|
|
1247
1136
|
const _excluded$2 = ["realTime", "disabled"],
|
|
1248
|
-
|
|
1249
|
-
|
|
1137
|
+
_excluded2$1 = ["isPass", "isLoading"];
|
|
1250
1138
|
const SubmitButton = _ref => {
|
|
1251
1139
|
let {
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1140
|
+
realTime,
|
|
1141
|
+
disabled
|
|
1142
|
+
} = _ref,
|
|
1143
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
1257
1144
|
const _useSubmit = useSubmit(props),
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1145
|
+
{
|
|
1146
|
+
isPass,
|
|
1147
|
+
isLoading
|
|
1148
|
+
} = _useSubmit,
|
|
1149
|
+
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2$1);
|
|
1264
1150
|
return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
1265
1151
|
loading: isLoading,
|
|
1266
1152
|
disabled: disabled || (realTime ? !isPass : false)
|
|
1267
1153
|
}, submitProps, props));
|
|
1268
1154
|
};
|
|
1269
|
-
|
|
1270
1155
|
SubmitButton.defaultProps = {
|
|
1271
1156
|
type: 'primary',
|
|
1272
1157
|
disabled: false
|
|
@@ -1281,13 +1166,11 @@ const _excluded$1 = ["onClick"];
|
|
|
1281
1166
|
const {
|
|
1282
1167
|
useCacheRemove
|
|
1283
1168
|
} = hooks;
|
|
1284
|
-
|
|
1285
1169
|
const CancelButton = _ref => {
|
|
1286
1170
|
let {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1171
|
+
onClick
|
|
1172
|
+
} = _ref,
|
|
1173
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1291
1174
|
const remove = useCacheRemove();
|
|
1292
1175
|
return /*#__PURE__*/React__default.createElement(Button, _extends({}, props, {
|
|
1293
1176
|
onClick: (...args) => {
|
|
@@ -1298,7 +1181,7 @@ const CancelButton = _ref => {
|
|
|
1298
1181
|
};
|
|
1299
1182
|
|
|
1300
1183
|
const _excluded = ["className", "formProps", "footer", "children", "isReset"],
|
|
1301
|
-
|
|
1184
|
+
_excluded2 = ["className", "title", "formProps", "footer", "content", "isReset"];
|
|
1302
1185
|
const FetchForm = withFetch$1(Form);
|
|
1303
1186
|
const CommonModal = forwardRef(({
|
|
1304
1187
|
formProps,
|
|
@@ -1325,14 +1208,13 @@ const CommonModal = forwardRef(({
|
|
|
1325
1208
|
});
|
|
1326
1209
|
const FormModal = forwardRef((_ref, ref) => {
|
|
1327
1210
|
let {
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1211
|
+
className,
|
|
1212
|
+
formProps = {},
|
|
1213
|
+
footer,
|
|
1214
|
+
children,
|
|
1215
|
+
isReset
|
|
1216
|
+
} = _ref,
|
|
1217
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1336
1218
|
return /*#__PURE__*/React__default.createElement(Modal, _extends({}, props, {
|
|
1337
1219
|
className: classnames(className, 'react-form-modal'),
|
|
1338
1220
|
footer: null
|
|
@@ -1344,18 +1226,16 @@ const FormModal = forwardRef((_ref, ref) => {
|
|
|
1344
1226
|
onCancel: props.onCancel
|
|
1345
1227
|
}, children));
|
|
1346
1228
|
});
|
|
1347
|
-
|
|
1348
1229
|
FormModal.modal = _ref2 => {
|
|
1349
1230
|
let {
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1231
|
+
className,
|
|
1232
|
+
title,
|
|
1233
|
+
formProps = {},
|
|
1234
|
+
footer,
|
|
1235
|
+
content,
|
|
1236
|
+
isReset
|
|
1237
|
+
} = _ref2,
|
|
1238
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1359
1239
|
return Modal.info(_extends({}, props, {
|
|
1360
1240
|
title: title ? /*#__PURE__*/React__default.createElement("div", {
|
|
1361
1241
|
className: "ant-modal-header"
|