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