@kne/react-form-antd 2.1.15 → 2.1.18
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 +108 -27
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +117 -36
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useState, useRef, useEffect, useMemo, useCallback, useImperativeHandle } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import ReactForm__default, { preset as preset$
|
|
4
|
+
import ReactForm__default, { preset as preset$2, useSubmit, useReset } from '@kne/react-form';
|
|
5
5
|
export * from '@kne/react-form';
|
|
6
|
-
import { widget, hooks, hoc } from '@kne/react-form-helper';
|
|
6
|
+
import { preset as preset$1, widget, hooks, hoc } from '@kne/react-form-helper';
|
|
7
7
|
export { hooks, utils, widget } from '@kne/react-form-helper';
|
|
8
8
|
import merge from 'lodash/merge';
|
|
9
9
|
import get from 'lodash/get';
|
|
@@ -55,6 +55,9 @@ const globalParams = {
|
|
|
55
55
|
type: 'default',
|
|
56
56
|
size: 'middle',
|
|
57
57
|
rules: {},
|
|
58
|
+
formModal: {},
|
|
59
|
+
resetButton: {},
|
|
60
|
+
submitButton: {},
|
|
58
61
|
field: {
|
|
59
62
|
upload: {
|
|
60
63
|
displayFilename: 'filename',
|
|
@@ -83,7 +86,14 @@ const globalParams = {
|
|
|
83
86
|
};
|
|
84
87
|
var preset = (props => {
|
|
85
88
|
merge(globalParams, props);
|
|
86
|
-
|
|
89
|
+
const defaultProps = {};
|
|
90
|
+
Object.keys(globalParams.field).forEach(name => {
|
|
91
|
+
defaultProps[name] = (globalParams.field[name] || {}).defaultProps;
|
|
92
|
+
});
|
|
93
|
+
preset$1({
|
|
94
|
+
field: defaultProps
|
|
95
|
+
});
|
|
96
|
+
preset$2(globalParams.rules);
|
|
87
97
|
});
|
|
88
98
|
|
|
89
99
|
const _excluded$8 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
@@ -396,6 +406,9 @@ const AvatarInput = props => {
|
|
|
396
406
|
return render(_Avatar);
|
|
397
407
|
};
|
|
398
408
|
|
|
409
|
+
AvatarInput.defaultProps = {
|
|
410
|
+
fieldName: 'avatar'
|
|
411
|
+
};
|
|
399
412
|
AvatarInput.field = _Avatar;
|
|
400
413
|
|
|
401
414
|
const {
|
|
@@ -407,6 +420,10 @@ const Cascader$1 = props => {
|
|
|
407
420
|
return render(Cascader$2);
|
|
408
421
|
};
|
|
409
422
|
|
|
423
|
+
Cascader$1.defaultProps = {
|
|
424
|
+
fieldName: 'cascader'
|
|
425
|
+
};
|
|
426
|
+
|
|
410
427
|
const {
|
|
411
428
|
useOnChange: useOnChange$b,
|
|
412
429
|
useCheckedToValue: useCheckedToValue$1
|
|
@@ -422,6 +439,10 @@ const Checkbox$1 = props => {
|
|
|
422
439
|
return render(WithCheckbox);
|
|
423
440
|
};
|
|
424
441
|
|
|
442
|
+
Checkbox$1.defaultProps = {
|
|
443
|
+
fieldName: 'checkbox'
|
|
444
|
+
};
|
|
445
|
+
|
|
425
446
|
const {
|
|
426
447
|
useOnChange: useOnChange$a
|
|
427
448
|
} = hooks;
|
|
@@ -433,6 +454,9 @@ const CheckboxGroup$1 = props => {
|
|
|
433
454
|
};
|
|
434
455
|
|
|
435
456
|
CheckboxGroup$1.Checkbox = Checkbox$2;
|
|
457
|
+
CheckboxGroup$1.defaultProps = {
|
|
458
|
+
fieldName: 'checkboxGroup'
|
|
459
|
+
};
|
|
436
460
|
|
|
437
461
|
const getPopupContainer = triggerNode => {
|
|
438
462
|
const findAntdPopupContainer = el => {
|
|
@@ -469,6 +493,7 @@ const _DatePicker = props => {
|
|
|
469
493
|
};
|
|
470
494
|
|
|
471
495
|
_DatePicker.defaultProps = {
|
|
496
|
+
fieldName: 'datePicker',
|
|
472
497
|
getPopupContainer
|
|
473
498
|
};
|
|
474
499
|
|
|
@@ -479,17 +504,20 @@ const _MonthPicker = props => {
|
|
|
479
504
|
return render(MonthPicker);
|
|
480
505
|
};
|
|
481
506
|
|
|
507
|
+
_MonthPicker.defaultProps = {
|
|
508
|
+
fieldName: 'monthDatePicker',
|
|
509
|
+
getPopupContainer
|
|
510
|
+
};
|
|
511
|
+
|
|
482
512
|
const _RangePicker$1 = props => {
|
|
483
513
|
const render = useOnChange$9(Object.assign({
|
|
484
514
|
placeholder: ['开始时间', '结束时间']
|
|
485
|
-
}, props));
|
|
486
|
-
// return render(RangePickerToday);
|
|
487
|
-
// }
|
|
488
|
-
|
|
515
|
+
}, props));
|
|
489
516
|
return render(RangePicker$1);
|
|
490
517
|
};
|
|
491
518
|
|
|
492
519
|
_RangePicker$1.defaultProps = {
|
|
520
|
+
fieldName: 'rangeDatePicker',
|
|
493
521
|
getPopupContainer
|
|
494
522
|
};
|
|
495
523
|
|
|
@@ -501,6 +529,7 @@ const _WeekPicker = props => {
|
|
|
501
529
|
};
|
|
502
530
|
|
|
503
531
|
_WeekPicker.defaultProps = {
|
|
532
|
+
fieldName: 'weekDatePicker',
|
|
504
533
|
getPopupContainer
|
|
505
534
|
};
|
|
506
535
|
_DatePicker.MonthPicker = _MonthPicker;
|
|
@@ -605,6 +634,9 @@ const RangePickerToday = props => {
|
|
|
605
634
|
return render(PickerToday);
|
|
606
635
|
};
|
|
607
636
|
|
|
637
|
+
RangePickerToday.defaultProps = {
|
|
638
|
+
fieldName: 'rangePickerToday'
|
|
639
|
+
};
|
|
608
640
|
RangePickerToday.field = PickerToday;
|
|
609
641
|
|
|
610
642
|
const {
|
|
@@ -625,7 +657,12 @@ InputField.Password = props => {
|
|
|
625
657
|
return render(Input$1.Password);
|
|
626
658
|
};
|
|
627
659
|
|
|
628
|
-
InputField.
|
|
660
|
+
InputField.defaultProps = {
|
|
661
|
+
fieldName: 'input',
|
|
662
|
+
autoComplete: 'off'
|
|
663
|
+
};
|
|
664
|
+
InputField.Password.defaultProps = {
|
|
665
|
+
fieldName: 'password',
|
|
629
666
|
autoComplete: 'off'
|
|
630
667
|
};
|
|
631
668
|
|
|
@@ -641,6 +678,7 @@ const InputNumberField = props => {
|
|
|
641
678
|
};
|
|
642
679
|
|
|
643
680
|
InputNumberField.defaultProps = {
|
|
681
|
+
fieldName: 'inputNumber',
|
|
644
682
|
autoComplete: 'off'
|
|
645
683
|
};
|
|
646
684
|
|
|
@@ -668,6 +706,9 @@ const _RadioGroup = props => {
|
|
|
668
706
|
return render(RadioGroup$1);
|
|
669
707
|
};
|
|
670
708
|
|
|
709
|
+
_RadioGroup.defaultProps = {
|
|
710
|
+
fieldName: 'radioGroup'
|
|
711
|
+
};
|
|
671
712
|
_RadioGroup.Radio = Radio;
|
|
672
713
|
|
|
673
714
|
const _excluded$5 = ["data", "setData", "send", "loadMore", "isComplete", "refresh", "reload", "fetchEmitter", "isLoading", "children", "onLoaded", "fetchProps", "requestParams"];
|
|
@@ -771,6 +812,7 @@ _Select.Fetch = withFetch(Select$1);
|
|
|
771
812
|
_Select.Option = Select$1.Option;
|
|
772
813
|
_Select.OptGroup = Select$1.OptGroup;
|
|
773
814
|
_Select.defaultProps = _Select.Fetch.defaultProps = {
|
|
815
|
+
fieldName: 'select',
|
|
774
816
|
getPopupContainer
|
|
775
817
|
};
|
|
776
818
|
|
|
@@ -851,6 +893,7 @@ SelectFetch$1.field = forwardRef((props, ref) => {
|
|
|
851
893
|
}));
|
|
852
894
|
});
|
|
853
895
|
SelectFetch$1.defaultProps = {
|
|
896
|
+
fieldName: 'selectFetch',
|
|
854
897
|
getPopupContainer
|
|
855
898
|
};
|
|
856
899
|
SelectFetch$1.Option = Select$1.Option;
|
|
@@ -871,6 +914,10 @@ const Switch$1 = props => {
|
|
|
871
914
|
return render(WithSwitch);
|
|
872
915
|
};
|
|
873
916
|
|
|
917
|
+
Switch$1.defaultProps = {
|
|
918
|
+
fieldName: 'switch'
|
|
919
|
+
};
|
|
920
|
+
|
|
874
921
|
const {
|
|
875
922
|
useDecorator
|
|
876
923
|
} = hooks;
|
|
@@ -882,6 +929,10 @@ const TextArea$1 = props => {
|
|
|
882
929
|
return render(Input$1.TextArea);
|
|
883
930
|
};
|
|
884
931
|
|
|
932
|
+
TextArea$1.defaultProps = {
|
|
933
|
+
fieldName: 'textArea'
|
|
934
|
+
};
|
|
935
|
+
|
|
885
936
|
const {
|
|
886
937
|
useOnChange: useOnChange$2
|
|
887
938
|
} = hooks;
|
|
@@ -897,6 +948,7 @@ const _TimePicker = props => {
|
|
|
897
948
|
};
|
|
898
949
|
|
|
899
950
|
_TimePicker.defaultProps = {
|
|
951
|
+
fieldName: 'timePicker',
|
|
900
952
|
getPopupContainer
|
|
901
953
|
};
|
|
902
954
|
|
|
@@ -908,6 +960,7 @@ const _RangePicker = props => {
|
|
|
908
960
|
};
|
|
909
961
|
|
|
910
962
|
_RangePicker.defaultProps = {
|
|
963
|
+
fieldName: 'rangeTimePicker',
|
|
911
964
|
getPopupContainer
|
|
912
965
|
};
|
|
913
966
|
_TimePicker.RangePicker = _RangePicker;
|
|
@@ -925,6 +978,7 @@ const _TreeSelect = props => {
|
|
|
925
978
|
|
|
926
979
|
_TreeSelect.Fetch = withFetch(TreeSelect$1);
|
|
927
980
|
_TreeSelect.defaultProps = _TreeSelect.Fetch.defaultProps = {
|
|
981
|
+
fieldName: 'treeSelect',
|
|
928
982
|
getPopupContainer
|
|
929
983
|
};
|
|
930
984
|
_TreeSelect.TreeNode = TreeSelect$1.TreeNode;
|
|
@@ -1092,6 +1146,9 @@ const UploadInput = props => {
|
|
|
1092
1146
|
return render(_Upload);
|
|
1093
1147
|
};
|
|
1094
1148
|
|
|
1149
|
+
UploadInput.defaultProps = {
|
|
1150
|
+
fieldName: 'upload'
|
|
1151
|
+
};
|
|
1095
1152
|
UploadInput.field = _Upload;
|
|
1096
1153
|
|
|
1097
1154
|
const _excluded$2 = ["realTime", "disabled"],
|
|
@@ -1127,12 +1184,35 @@ const ResetButton = props => {
|
|
|
1127
1184
|
return /*#__PURE__*/React.createElement(Button, _extends({}, resetProps, props));
|
|
1128
1185
|
};
|
|
1129
1186
|
|
|
1130
|
-
const _excluded$1 = ["
|
|
1131
|
-
|
|
1187
|
+
const _excluded$1 = ["onClick"];
|
|
1188
|
+
const {
|
|
1189
|
+
useCacheRemove
|
|
1190
|
+
} = hooks;
|
|
1191
|
+
|
|
1192
|
+
const CancelButton = _ref => {
|
|
1193
|
+
let {
|
|
1194
|
+
onClick
|
|
1195
|
+
} = _ref,
|
|
1196
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1197
|
+
|
|
1198
|
+
const remove = useCacheRemove();
|
|
1199
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
1200
|
+
onClick: (...args) => {
|
|
1201
|
+
remove();
|
|
1202
|
+
onClick && onClick(...args);
|
|
1203
|
+
}
|
|
1204
|
+
}));
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
const _excluded = ["className", "formProps", "footer", "children", "close", "isReset", "onCancel"],
|
|
1208
|
+
_excluded2 = ["className", "title", "formProps", "footer", "content", "isReset", "onCancel"];
|
|
1132
1209
|
const FetchForm = withFetch$1(Form);
|
|
1133
1210
|
const CommonModal = forwardRef(({
|
|
1134
1211
|
formProps,
|
|
1135
1212
|
footer,
|
|
1213
|
+
close,
|
|
1214
|
+
onCancel,
|
|
1215
|
+
isReset,
|
|
1136
1216
|
children
|
|
1137
1217
|
}, ref) => {
|
|
1138
1218
|
const TargetForm = formProps.hasOwnProperty('url') ? FetchForm : Form;
|
|
@@ -1142,7 +1222,15 @@ const CommonModal = forwardRef(({
|
|
|
1142
1222
|
className: "ant-modal-body"
|
|
1143
1223
|
}, children), /*#__PURE__*/React.createElement("div", {
|
|
1144
1224
|
className: "ant-modal-footer"
|
|
1145
|
-
}, footer ? footer : /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(ResetButton, null, "\u91CD\u7F6E")
|
|
1225
|
+
}, footer ? footer : /*#__PURE__*/React.createElement(Space, null, isReset ? /*#__PURE__*/React.createElement(ResetButton, null, "\u91CD\u7F6E") : /*#__PURE__*/React.createElement(CancelButton, {
|
|
1226
|
+
onClick: () => {
|
|
1227
|
+
if (typeof onCancel === 'function') {
|
|
1228
|
+
onCancel(close);
|
|
1229
|
+
} else {
|
|
1230
|
+
close && close();
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}, "\u53D6\u6D88"), /*#__PURE__*/React.createElement(SubmitButton, {
|
|
1146
1234
|
type: "primary"
|
|
1147
1235
|
}, "\u786E\u5B9A"))));
|
|
1148
1236
|
});
|
|
@@ -1151,9 +1239,12 @@ const FormModal = forwardRef((_ref, ref) => {
|
|
|
1151
1239
|
className,
|
|
1152
1240
|
formProps = {},
|
|
1153
1241
|
footer,
|
|
1154
|
-
children
|
|
1242
|
+
children,
|
|
1243
|
+
close,
|
|
1244
|
+
isReset,
|
|
1245
|
+
onCancel
|
|
1155
1246
|
} = _ref,
|
|
1156
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded
|
|
1247
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1157
1248
|
|
|
1158
1249
|
return /*#__PURE__*/React.createElement(Modal, _extends({}, props, {
|
|
1159
1250
|
className: classnames(className, 'react-form-modal'),
|
|
@@ -1161,7 +1252,10 @@ const FormModal = forwardRef((_ref, ref) => {
|
|
|
1161
1252
|
}), /*#__PURE__*/React.createElement(CommonModal, {
|
|
1162
1253
|
ref: ref,
|
|
1163
1254
|
formProps: formProps,
|
|
1164
|
-
footer: footer
|
|
1255
|
+
footer: footer,
|
|
1256
|
+
close: close,
|
|
1257
|
+
isReset: isReset,
|
|
1258
|
+
onCancel: onCancel
|
|
1165
1259
|
}, children));
|
|
1166
1260
|
});
|
|
1167
1261
|
|
|
@@ -1171,7 +1265,9 @@ FormModal.modal = _ref2 => {
|
|
|
1171
1265
|
title,
|
|
1172
1266
|
formProps = {},
|
|
1173
1267
|
footer,
|
|
1174
|
-
content
|
|
1268
|
+
content,
|
|
1269
|
+
isReset,
|
|
1270
|
+
onCancel
|
|
1175
1271
|
} = _ref2,
|
|
1176
1272
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
1177
1273
|
|
|
@@ -1184,33 +1280,18 @@ FormModal.modal = _ref2 => {
|
|
|
1184
1280
|
className: classnames(className, 'react-form-modal'),
|
|
1185
1281
|
content: /*#__PURE__*/React.createElement(CommonModal, {
|
|
1186
1282
|
formProps: formProps,
|
|
1187
|
-
footer: footer
|
|
1283
|
+
footer: footer,
|
|
1284
|
+
isReset: isReset,
|
|
1285
|
+
onCancel: onCancel,
|
|
1286
|
+
close: () => {
|
|
1287
|
+
FormModal.modal.destroy();
|
|
1288
|
+
}
|
|
1188
1289
|
}, content),
|
|
1189
1290
|
icon: null,
|
|
1190
1291
|
footer: null
|
|
1191
1292
|
}));
|
|
1192
1293
|
};
|
|
1193
1294
|
|
|
1194
|
-
const _excluded = ["onClick"];
|
|
1195
|
-
const {
|
|
1196
|
-
useCacheRemove
|
|
1197
|
-
} = hooks;
|
|
1198
|
-
|
|
1199
|
-
const CancelButton = _ref => {
|
|
1200
|
-
let {
|
|
1201
|
-
onClick
|
|
1202
|
-
} = _ref,
|
|
1203
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1204
|
-
|
|
1205
|
-
const remove = useCacheRemove();
|
|
1206
|
-
return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
|
|
1207
|
-
onClick: (...args) => {
|
|
1208
|
-
remove();
|
|
1209
|
-
onClick && onClick(...args);
|
|
1210
|
-
}
|
|
1211
|
-
}));
|
|
1212
|
-
};
|
|
1213
|
-
|
|
1214
1295
|
const Avatar = AvatarInput;
|
|
1215
1296
|
const Cascader = Cascader$1;
|
|
1216
1297
|
const Checkbox = Checkbox$1;
|