@kne/react-form-antd 2.0.23 → 2.0.26
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/dist/index.js +162 -37
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +154 -39
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -12,8 +12,8 @@ import { LoadingOutlined, PlusOutlined, UploadOutlined } from '@ant-design/icons
|
|
|
12
12
|
import AvatarEditor from 'react-avatar-editor';
|
|
13
13
|
import moment from 'moment';
|
|
14
14
|
import useControlValue from '@kne/use-control-value';
|
|
15
|
-
import { withFetch } from '@kne/react-fetch';
|
|
16
15
|
import useEvent from '@kne/use-event';
|
|
16
|
+
import { withFetch as withFetch$1 } from '@kne/react-fetch';
|
|
17
17
|
import groupBy from 'lodash/groupBy';
|
|
18
18
|
import uniqueId from 'lodash/uniqueId';
|
|
19
19
|
|
|
@@ -50,7 +50,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
50
50
|
return target;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const _excluded$
|
|
53
|
+
const _excluded$8 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
54
54
|
const {
|
|
55
55
|
ScrollToError,
|
|
56
56
|
EnterSubmit,
|
|
@@ -69,7 +69,7 @@ const Form = forwardRef((_ref, ref) => {
|
|
|
69
69
|
size,
|
|
70
70
|
children
|
|
71
71
|
} = _ref,
|
|
72
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
72
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
73
73
|
|
|
74
74
|
let computedClass = 'react-form';
|
|
75
75
|
|
|
@@ -156,7 +156,7 @@ var preset = (props => {
|
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
const {
|
|
159
|
-
useOnChange: useOnChange$
|
|
159
|
+
useOnChange: useOnChange$d
|
|
160
160
|
} = hooks;
|
|
161
161
|
const avatarParams = globalParams.field.avatar;
|
|
162
162
|
|
|
@@ -382,23 +382,23 @@ _Avatar.defaultProps = {
|
|
|
382
382
|
};
|
|
383
383
|
|
|
384
384
|
const AvatarInput = props => {
|
|
385
|
-
const render = useOnChange$
|
|
385
|
+
const render = useOnChange$d(props);
|
|
386
386
|
return render(_Avatar);
|
|
387
387
|
};
|
|
388
388
|
|
|
389
389
|
AvatarInput.field = _Avatar;
|
|
390
390
|
|
|
391
391
|
const {
|
|
392
|
-
useOnChange: useOnChange$
|
|
392
|
+
useOnChange: useOnChange$c
|
|
393
393
|
} = hooks;
|
|
394
394
|
|
|
395
395
|
const Cascader$1 = props => {
|
|
396
|
-
const render = useOnChange$
|
|
396
|
+
const render = useOnChange$c(props);
|
|
397
397
|
return render(Cascader$2);
|
|
398
398
|
};
|
|
399
399
|
|
|
400
400
|
const {
|
|
401
|
-
useOnChange: useOnChange$
|
|
401
|
+
useOnChange: useOnChange$b,
|
|
402
402
|
useCheckedToValue: useCheckedToValue$1
|
|
403
403
|
} = hooks;
|
|
404
404
|
const {
|
|
@@ -408,24 +408,42 @@ const WithCheckbox = withChecked$1(Checkbox$2);
|
|
|
408
408
|
|
|
409
409
|
const Checkbox$1 = props => {
|
|
410
410
|
const checkedProps = useCheckedToValue$1(props);
|
|
411
|
-
const render = useOnChange$
|
|
411
|
+
const render = useOnChange$b(checkedProps);
|
|
412
412
|
return render(WithCheckbox);
|
|
413
413
|
};
|
|
414
414
|
|
|
415
415
|
const {
|
|
416
|
-
useOnChange: useOnChange$
|
|
416
|
+
useOnChange: useOnChange$a
|
|
417
417
|
} = hooks;
|
|
418
418
|
const _CheckboxGroup = Checkbox$2.Group;
|
|
419
419
|
|
|
420
420
|
const CheckboxGroup$1 = props => {
|
|
421
|
-
const render = useOnChange$
|
|
421
|
+
const render = useOnChange$a(props);
|
|
422
422
|
return render(_CheckboxGroup);
|
|
423
423
|
};
|
|
424
424
|
|
|
425
425
|
CheckboxGroup$1.Checkbox = Checkbox$2;
|
|
426
426
|
|
|
427
|
+
const getPopupContainer = triggerNode => {
|
|
428
|
+
const findAntdPopupContainer = el => {
|
|
429
|
+
if (el === document.body || !el.parentElement) {
|
|
430
|
+
return document.body;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const targetEl = [].slice.call(el.classList, 0).find(className => ['ant-modal-content', 'ant-popover-content'].indexOf(className) > -1);
|
|
434
|
+
|
|
435
|
+
if (targetEl) {
|
|
436
|
+
return el;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return findAntdPopupContainer(el.parentElement);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
return findAntdPopupContainer(triggerNode);
|
|
443
|
+
};
|
|
444
|
+
|
|
427
445
|
const {
|
|
428
|
-
useOnChange: useOnChange$
|
|
446
|
+
useOnChange: useOnChange$9
|
|
429
447
|
} = hooks;
|
|
430
448
|
const {
|
|
431
449
|
MonthPicker,
|
|
@@ -434,22 +452,26 @@ const {
|
|
|
434
452
|
} = DatePicker$1;
|
|
435
453
|
|
|
436
454
|
const _DatePicker = props => {
|
|
437
|
-
const render = useOnChange$
|
|
438
|
-
placeholder:
|
|
455
|
+
const render = useOnChange$9(Object.assign({
|
|
456
|
+
placeholder: ['开始时间', '结束时间']
|
|
439
457
|
}, props));
|
|
440
458
|
return render(DatePicker$1);
|
|
441
459
|
};
|
|
442
460
|
|
|
461
|
+
_DatePicker.defaultProps = {
|
|
462
|
+
getPopupContainer
|
|
463
|
+
};
|
|
464
|
+
|
|
443
465
|
const _MonthPicker = props => {
|
|
444
|
-
const render = useOnChange$
|
|
445
|
-
placeholder:
|
|
466
|
+
const render = useOnChange$9(Object.assign({
|
|
467
|
+
placeholder: ['开始时间', '结束时间']
|
|
446
468
|
}, props));
|
|
447
469
|
return render(MonthPicker);
|
|
448
470
|
};
|
|
449
471
|
|
|
450
472
|
const _RangePicker$1 = props => {
|
|
451
|
-
const render = useOnChange$
|
|
452
|
-
placeholder:
|
|
473
|
+
const render = useOnChange$9(Object.assign({
|
|
474
|
+
placeholder: ['开始时间', '结束时间']
|
|
453
475
|
}, props)); // if(props.selectToday){
|
|
454
476
|
// return render(RangePickerToday);
|
|
455
477
|
// }
|
|
@@ -457,27 +479,34 @@ const _RangePicker$1 = props => {
|
|
|
457
479
|
return render(RangePicker$1);
|
|
458
480
|
};
|
|
459
481
|
|
|
482
|
+
_RangePicker$1.defaultProps = {
|
|
483
|
+
getPopupContainer
|
|
484
|
+
};
|
|
485
|
+
|
|
460
486
|
const _WeekPicker = props => {
|
|
461
|
-
const render = useOnChange$
|
|
462
|
-
placeholder:
|
|
487
|
+
const render = useOnChange$9(Object.assign({
|
|
488
|
+
placeholder: ['开始时间', '结束时间']
|
|
463
489
|
}, props));
|
|
464
490
|
return render(WeekPicker);
|
|
465
491
|
};
|
|
466
492
|
|
|
493
|
+
_WeekPicker.defaultProps = {
|
|
494
|
+
getPopupContainer
|
|
495
|
+
};
|
|
467
496
|
_DatePicker.MonthPicker = _MonthPicker;
|
|
468
497
|
_DatePicker.RangePicker = _RangePicker$1;
|
|
469
498
|
_DatePicker.WeekPicker = _WeekPicker;
|
|
470
499
|
|
|
471
|
-
const _excluded$
|
|
500
|
+
const _excluded$7 = ["soFarText"];
|
|
472
501
|
const {
|
|
473
|
-
useOnChange: useOnChange$
|
|
502
|
+
useOnChange: useOnChange$8
|
|
474
503
|
} = hooks;
|
|
475
504
|
|
|
476
505
|
const PickerToday = _ref => {
|
|
477
506
|
let {
|
|
478
507
|
soFarText
|
|
479
508
|
} = _ref,
|
|
480
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
509
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
481
510
|
|
|
482
511
|
const [data, onChange] = useControlValue(props);
|
|
483
512
|
const ref_d = useRef();
|
|
@@ -562,7 +591,7 @@ const PickerToday = _ref => {
|
|
|
562
591
|
};
|
|
563
592
|
|
|
564
593
|
const RangePickerToday = props => {
|
|
565
|
-
const render = useOnChange$
|
|
594
|
+
const render = useOnChange$8(props);
|
|
566
595
|
return render(PickerToday);
|
|
567
596
|
};
|
|
568
597
|
|
|
@@ -579,10 +608,6 @@ const InputField = props => {
|
|
|
579
608
|
return render(Input$1);
|
|
580
609
|
};
|
|
581
610
|
|
|
582
|
-
InputField.defaultProps = {
|
|
583
|
-
autoComplete: 'off'
|
|
584
|
-
};
|
|
585
|
-
|
|
586
611
|
InputField.Password = props => {
|
|
587
612
|
const render = useDecorator$2(Object.assign({
|
|
588
613
|
placeholder: `请输入${props.label}`
|
|
@@ -590,6 +615,10 @@ InputField.Password = props => {
|
|
|
590
615
|
return render(Input$1.Password);
|
|
591
616
|
};
|
|
592
617
|
|
|
618
|
+
InputField.Password.defaultProps = InputField.defaultProps = {
|
|
619
|
+
autoComplete: 'off'
|
|
620
|
+
};
|
|
621
|
+
|
|
593
622
|
const {
|
|
594
623
|
useDecorator: useDecorator$1
|
|
595
624
|
} = hooks;
|
|
@@ -605,16 +634,16 @@ InputNumberField.defaultProps = {
|
|
|
605
634
|
autoComplete: 'off'
|
|
606
635
|
};
|
|
607
636
|
|
|
608
|
-
const _excluded$
|
|
637
|
+
const _excluded$6 = ["onChange"];
|
|
609
638
|
const {
|
|
610
|
-
useOnChange: useOnChange$
|
|
639
|
+
useOnChange: useOnChange$7
|
|
611
640
|
} = hooks;
|
|
612
641
|
|
|
613
642
|
const RadioGroup$1 = _ref => {
|
|
614
643
|
let {
|
|
615
644
|
onChange
|
|
616
645
|
} = _ref,
|
|
617
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
646
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
618
647
|
|
|
619
648
|
const handler = useCallback(e => {
|
|
620
649
|
onChange && onChange(e.target.value);
|
|
@@ -625,32 +654,103 @@ const RadioGroup$1 = _ref => {
|
|
|
625
654
|
};
|
|
626
655
|
|
|
627
656
|
const _RadioGroup = props => {
|
|
628
|
-
const render = useOnChange$
|
|
657
|
+
const render = useOnChange$7(props);
|
|
629
658
|
return render(RadioGroup$1);
|
|
630
659
|
};
|
|
631
660
|
|
|
632
661
|
_RadioGroup.Radio = Radio;
|
|
633
662
|
|
|
663
|
+
const _excluded$5 = ["data", "setData", "refresh", "reload", "fetchEmitter", "isLoading", "children", "onLoaded", "fetchProps"];
|
|
664
|
+
const {
|
|
665
|
+
useOnChange: useOnChange$6
|
|
666
|
+
} = hooks;
|
|
667
|
+
|
|
668
|
+
const withFetch = WrappedComponent => {
|
|
669
|
+
const FieldInner = withFetch$1(_ref => {
|
|
670
|
+
let {
|
|
671
|
+
data,
|
|
672
|
+
setData,
|
|
673
|
+
refresh,
|
|
674
|
+
reload,
|
|
675
|
+
fetchEmitter,
|
|
676
|
+
isLoading,
|
|
677
|
+
children,
|
|
678
|
+
onLoaded,
|
|
679
|
+
fetchProps
|
|
680
|
+
} = _ref,
|
|
681
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
682
|
+
|
|
683
|
+
const refreshRef = useRef(refresh);
|
|
684
|
+
refreshRef.current = refresh;
|
|
685
|
+
const reloadRef = useRef(reload);
|
|
686
|
+
reloadRef.current = reload;
|
|
687
|
+
const setDataRef = useRef(setData);
|
|
688
|
+
setDataRef.current = setData;
|
|
689
|
+
const dataRef = useRef(data);
|
|
690
|
+
useEffect(() => {
|
|
691
|
+
const token1 = fetchEmitter.addListener('select-fetch-refresh', () => refreshRef.current());
|
|
692
|
+
const token2 = fetchEmitter.addListener('select-fetch-reload', () => reloadRef.current());
|
|
693
|
+
const token3 = fetchEmitter.addListener('select-fetch-set-data', () => setDataRef.current());
|
|
694
|
+
return () => {
|
|
695
|
+
token1 && token1.remove();
|
|
696
|
+
token2 && token2.remove();
|
|
697
|
+
token3 && token3.remove();
|
|
698
|
+
};
|
|
699
|
+
}, [fetchEmitter]);
|
|
700
|
+
useEffect(() => {
|
|
701
|
+
onLoaded && onLoaded(dataRef.current);
|
|
702
|
+
}, []);
|
|
703
|
+
return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, children({
|
|
704
|
+
data,
|
|
705
|
+
fetchProps,
|
|
706
|
+
refresh,
|
|
707
|
+
isLoading,
|
|
708
|
+
setData
|
|
709
|
+
})));
|
|
710
|
+
});
|
|
711
|
+
const Fetch = forwardRef((props, ref) => {
|
|
712
|
+
const emitter = useEvent();
|
|
713
|
+
useImperativeHandle(ref, () => {
|
|
714
|
+
return {
|
|
715
|
+
refresh: () => emitter.emit('select-fetch-refresh'),
|
|
716
|
+
reload: () => emitter.emit('select-fetch-reload'),
|
|
717
|
+
setData: data => emitter.emit('select-fetch-set-data', data)
|
|
718
|
+
};
|
|
719
|
+
}, [emitter]);
|
|
720
|
+
const render = useOnChange$6(Object.assign({
|
|
721
|
+
placeholder: `请选择${props.label}`
|
|
722
|
+
}, props, {
|
|
723
|
+
fetchEmitter: emitter
|
|
724
|
+
}));
|
|
725
|
+
return render(FieldInner);
|
|
726
|
+
});
|
|
727
|
+
return Fetch;
|
|
728
|
+
};
|
|
729
|
+
|
|
634
730
|
const {
|
|
635
731
|
useOnChange: useOnChange$5
|
|
636
732
|
} = hooks;
|
|
637
733
|
|
|
638
734
|
const _Select = props => {
|
|
639
735
|
const render = useOnChange$5(Object.assign({
|
|
640
|
-
placeholder: `请选择${props.label}`
|
|
736
|
+
placeholder: `请选择${props.label || ''}`
|
|
641
737
|
}, props));
|
|
642
738
|
return render(Select$1);
|
|
643
739
|
};
|
|
644
740
|
|
|
741
|
+
_Select.Fetch = withFetch(Select$1);
|
|
645
742
|
_Select.Option = Select$1.Option;
|
|
646
743
|
_Select.OptGroup = Select$1.OptGroup;
|
|
744
|
+
_Select.defaultProps = _Select.Fetch.defaultProps = {
|
|
745
|
+
getPopupContainer
|
|
746
|
+
};
|
|
647
747
|
|
|
648
|
-
const _excluded$4 = ["data", "setData", "refresh", "reload", "emitter", "isLoading", "children", "onLoaded"];
|
|
748
|
+
const _excluded$4 = ["data", "setData", "refresh", "reload", "emitter", "isLoading", "children", "onLoaded", "fetchProps"];
|
|
649
749
|
const {
|
|
650
750
|
useOnChange: useOnChange$4
|
|
651
751
|
} = hooks;
|
|
652
752
|
|
|
653
|
-
const _SelectFetch = withFetch(_ref => {
|
|
753
|
+
const _SelectFetch = withFetch$1(_ref => {
|
|
654
754
|
let {
|
|
655
755
|
data,
|
|
656
756
|
setData,
|
|
@@ -671,6 +771,7 @@ const _SelectFetch = withFetch(_ref => {
|
|
|
671
771
|
setDataRef.current = setData;
|
|
672
772
|
const dataRef = useRef(data);
|
|
673
773
|
useEffect(() => {
|
|
774
|
+
console.warn('请使用Select.Fetch替代该组件,该组件会在未来某个版本被移除');
|
|
674
775
|
const token1 = emitter.addListener('select-fetch-refresh', () => refreshRef.current());
|
|
675
776
|
const token2 = emitter.addListener('select-fetch-reload', () => reloadRef.current());
|
|
676
777
|
const token3 = emitter.addListener('select-fetch-set-data', () => setDataRef.current());
|
|
@@ -720,6 +821,9 @@ SelectFetch$1.field = forwardRef((props, ref) => {
|
|
|
720
821
|
emitter: emitter
|
|
721
822
|
}));
|
|
722
823
|
});
|
|
824
|
+
SelectFetch$1.defaultProps = {
|
|
825
|
+
getPopupContainer
|
|
826
|
+
};
|
|
723
827
|
SelectFetch$1.Option = Select$1.Option;
|
|
724
828
|
SelectFetch$1.OptGroup = Select$1.OptGroup;
|
|
725
829
|
|
|
@@ -758,18 +862,25 @@ const {
|
|
|
758
862
|
|
|
759
863
|
const _TimePicker = props => {
|
|
760
864
|
const render = useOnChange$2(Object.assign({
|
|
761
|
-
placeholder: `请选择${props.label}`
|
|
865
|
+
placeholder: `请选择${props.label || ''}`
|
|
762
866
|
}, props));
|
|
763
867
|
return render(TimePicker$1);
|
|
764
868
|
};
|
|
765
869
|
|
|
870
|
+
_TimePicker.defaultProps = {
|
|
871
|
+
getPopupContainer
|
|
872
|
+
};
|
|
873
|
+
|
|
766
874
|
const _RangePicker = props => {
|
|
767
875
|
const render = useOnChange$2(Object.assign({
|
|
768
|
-
placeholder: `请选择${props.label}`
|
|
876
|
+
placeholder: `请选择${props.label || ''}`
|
|
769
877
|
}, props));
|
|
770
878
|
return render(RangePicker);
|
|
771
879
|
};
|
|
772
880
|
|
|
881
|
+
_RangePicker.defaultProps = {
|
|
882
|
+
getPopupContainer
|
|
883
|
+
};
|
|
773
884
|
_TimePicker.RangePicker = _RangePicker;
|
|
774
885
|
|
|
775
886
|
const {
|
|
@@ -778,11 +889,15 @@ const {
|
|
|
778
889
|
|
|
779
890
|
const _TreeSelect = props => {
|
|
780
891
|
const render = useOnChange$1(Object.assign({
|
|
781
|
-
placeholder: `请选择${props.label}`
|
|
892
|
+
placeholder: `请选择${props.label || ''}`
|
|
782
893
|
}, props));
|
|
783
894
|
return render(TreeSelect$1);
|
|
784
895
|
};
|
|
785
896
|
|
|
897
|
+
_TreeSelect.Fetch = withFetch(Select$1);
|
|
898
|
+
_TreeSelect.defaultProps = _TreeSelect.Fetch.defaultProps = {
|
|
899
|
+
getPopupContainer
|
|
900
|
+
};
|
|
786
901
|
_TreeSelect.TreeNode = TreeSelect$1.TreeNode;
|
|
787
902
|
|
|
788
903
|
const _excluded$3 = ["action", "value", "onChange", "drag", "children", "displayFilename", "accept", "fileSize", "onError", "onUploadComplete", "onBeforeUpload", "maxLength", "transformResponse"];
|
|
@@ -979,7 +1094,7 @@ const ResetButton = props => {
|
|
|
979
1094
|
|
|
980
1095
|
const _excluded$1 = ["className", "formProps", "footer", "children"],
|
|
981
1096
|
_excluded2 = ["className", "title", "formProps", "footer", "content"];
|
|
982
|
-
const FetchForm = withFetch(Form);
|
|
1097
|
+
const FetchForm = withFetch$1(Form);
|
|
983
1098
|
|
|
984
1099
|
const CommonModal = ({
|
|
985
1100
|
formProps,
|