@hw-component/form 0.0.1-bate → 0.0.1-beta
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/es/CheckboxGroup/CheckBox/index.js +24 -16
- package/es/CheckboxGroup/hooks.d.ts +9 -3
- package/es/CheckboxGroup/hooks.js +115 -64
- package/es/CheckboxGroup/index.d.ts +6 -1
- package/es/CheckboxGroup/index.js +117 -56
- package/es/CheckboxGroup/modal.d.ts +9 -8
- package/es/Form/Context/FormConfigProvider.js +64 -19
- package/es/Form/Context/index.d.ts +4 -1
- package/es/Form/Context/index.js +3 -3
- package/es/Form/FormItem/BasicItem.js +80 -42
- package/es/Form/FormItem/Helper.d.ts +1 -1
- package/es/Form/FormItem/Helper.js +17 -9
- package/es/Form/FormItem/RegularFormItem.js +11 -8
- package/es/Form/FormItem/UpFormItem.d.ts +6 -1
- package/es/Form/FormItem/UpFormItem.js +27 -17
- package/es/Form/FormItem/hooks.d.ts +21 -4
- package/es/Form/FormItem/hooks.js +12 -9
- package/es/Form/FormItem/index.js +5 -5
- package/es/Form/HFormConnect.d.ts +9 -1
- package/es/Form/HFormConnect.js +94 -26
- package/es/Form/InitSet.d.ts +1 -1
- package/es/Form/InitSet.js +5 -5
- package/es/Form/Label.d.ts +4 -4
- package/es/Form/Label.js +36 -19
- package/es/Form/config.d.ts +100 -22
- package/es/Form/config.js +19 -19
- package/es/Form/hooks/index.d.ts +12 -5
- package/es/Form/hooks/index.js +65 -49
- package/es/Form/hooks/useHForm.js +233 -95
- package/es/Form/hooks/useInitConfigData.d.ts +4 -1
- package/es/Form/hooks/useInitConfigData.js +143 -61
- package/es/Form/index.d.ts +11 -1
- package/es/Form/index.js +71 -40
- package/es/Form/modal.d.ts +92 -51
- package/es/Input/ButtonInput.js +73 -51
- package/es/Input/InputNumber.js +21 -12
- package/es/Input/SelectInput.d.ts +16 -4
- package/es/Input/SelectInput.js +113 -56
- package/es/Input/defaultConfig.d.ts +3 -3
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.js +7 -7
- package/es/Input/modal.d.ts +15 -11
- package/es/PageHandler/ErrorComponent.js +47 -25
- package/es/PageHandler/LoadingComponent.js +17 -13
- package/es/PageHandler/index.js +7 -7
- package/es/PageHandler/modal.d.ts +4 -4
- package/es/RadioGroup/index.d.ts +12 -5
- package/es/RadioGroup/index.js +46 -33
- package/es/Select/components/AllSelect.d.ts +1 -1
- package/es/Select/components/AllSelect.js +40 -18
- package/es/Select/components/CheckBoxOption.d.ts +6 -3
- package/es/Select/components/CheckBoxOption.js +12 -7
- package/es/Select/components/DropdownComponent.d.ts +4 -4
- package/es/Select/components/DropdownComponent.js +30 -17
- package/es/Select/components/NoFindItem.d.ts +1 -1
- package/es/Select/components/NoFindItem.js +11 -7
- package/es/Select/components/NotFoundContent.d.ts +2 -2
- package/es/Select/components/NotFoundContent.js +49 -27
- package/es/Select/defaultConfig.d.ts +1 -1
- package/es/Select/defaultConfig.js +20 -16
- package/es/Select/hooks/changeHooks.d.ts +2 -2
- package/es/Select/hooks/changeHooks.js +147 -71
- package/es/Select/hooks/norHooks.d.ts +27 -9
- package/es/Select/hooks/norHooks.js +51 -39
- package/es/Select/index.d.ts +22 -1
- package/es/Select/index.js +124 -65
- package/es/Select/modal.d.ts +15 -15
- package/es/Select/utils.js +60 -15
- package/es/Submit/index.d.ts +9 -3
- package/es/Submit/index.js +18 -13
- package/es/Switch/index.d.ts +4 -4
- package/es/Switch/index.js +46 -20
- package/es/TDPicker/RangePicker.d.ts +8 -3
- package/es/TDPicker/RangePicker.js +138 -62
- package/es/TDPicker/TimePicker.d.ts +6 -1
- package/es/TDPicker/TimePicker.js +19 -13
- package/es/TDPicker/hooks.d.ts +42 -22
- package/es/TDPicker/hooks.js +106 -72
- package/es/TDPicker/index.d.ts +7 -1
- package/es/TDPicker/index.js +20 -14
- package/es/TDPicker/modal.d.ts +21 -16
- package/es/Upload/Btn.d.ts +5 -1
- package/es/Upload/Btn.js +35 -19
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/es/Upload/MediaTypeEle/TypeEle.js +31 -23
- package/es/Upload/MediaTypeEle/index.d.ts +5 -1
- package/es/Upload/MediaTypeEle/index.js +21 -18
- package/es/Upload/Preview/index.d.ts +5 -1
- package/es/Upload/Preview/index.js +17 -13
- package/es/Upload/UrlUpload/index.d.ts +7 -1
- package/es/Upload/UrlUpload/index.js +72 -51
- package/es/Upload/enums.d.ts +3 -3
- package/es/Upload/enums.js +3 -3
- package/es/Upload/hooks/change.d.ts +8 -1
- package/es/Upload/hooks/change.js +115 -58
- package/es/Upload/hooks/customRequest.d.ts +5 -1
- package/es/Upload/hooks/customRequest.js +63 -46
- package/es/Upload/hooks/propsMaker.d.ts +5 -1
- package/es/Upload/hooks/propsMaker.js +52 -13
- package/es/Upload/index.d.ts +3 -1
- package/es/Upload/index.js +131 -61
- package/es/Upload/modal.d.ts +17 -15
- package/es/Upload/util.d.ts +8 -2
- package/es/Upload/util.js +15 -7
- package/es/config.js +34 -31
- package/es/hooks/index.d.ts +14 -7
- package/es/hooks/index.js +124 -49
- package/es/index.d.ts +98 -16
- package/es/index.js +22 -5
- package/es/modal.d.ts +6 -6
- package/lib/CheckboxGroup/CheckBox/index.js +26 -18
- package/lib/CheckboxGroup/hooks.d.ts +9 -3
- package/lib/CheckboxGroup/hooks.js +116 -65
- package/lib/CheckboxGroup/index.d.ts +6 -1
- package/lib/CheckboxGroup/index.js +119 -58
- package/lib/CheckboxGroup/modal.d.ts +9 -8
- package/lib/Form/Context/FormConfigProvider.js +66 -21
- package/lib/Form/Context/index.d.ts +4 -1
- package/lib/Form/Context/index.js +4 -4
- package/lib/Form/FormItem/BasicItem.js +82 -44
- package/lib/Form/FormItem/Helper.d.ts +1 -1
- package/lib/Form/FormItem/Helper.js +19 -11
- package/lib/Form/FormItem/RegularFormItem.js +13 -10
- package/lib/Form/FormItem/UpFormItem.d.ts +6 -1
- package/lib/Form/FormItem/UpFormItem.js +29 -19
- package/lib/Form/FormItem/hooks.d.ts +21 -4
- package/lib/Form/FormItem/hooks.js +13 -10
- package/lib/Form/FormItem/index.js +7 -7
- package/lib/Form/HFormConnect.d.ts +9 -1
- package/lib/Form/HFormConnect.js +96 -28
- package/lib/Form/InitSet.d.ts +1 -1
- package/lib/Form/InitSet.js +7 -7
- package/lib/Form/Label.d.ts +4 -4
- package/lib/Form/Label.js +41 -21
- package/lib/Form/config.d.ts +100 -22
- package/lib/Form/config.js +21 -21
- package/lib/Form/hooks/index.d.ts +12 -5
- package/lib/Form/hooks/index.js +66 -50
- package/lib/Form/hooks/useHForm.js +235 -97
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -1
- package/lib/Form/hooks/useInitConfigData.js +144 -63
- package/lib/Form/index.d.ts +11 -1
- package/lib/Form/index.js +73 -42
- package/lib/Form/modal.d.ts +92 -51
- package/lib/Input/ButtonInput.js +75 -53
- package/lib/Input/InputNumber.js +23 -14
- package/lib/Input/SelectInput.d.ts +16 -4
- package/lib/Input/SelectInput.js +125 -60
- package/lib/Input/defaultConfig.d.ts +3 -3
- package/lib/Input/defaultConfig.js +3 -3
- package/lib/Input/index.js +9 -9
- package/lib/Input/modal.d.ts +15 -11
- package/lib/PageHandler/ErrorComponent.js +49 -27
- package/lib/PageHandler/LoadingComponent.js +19 -15
- package/lib/PageHandler/index.js +9 -9
- package/lib/PageHandler/modal.d.ts +4 -4
- package/lib/RadioGroup/index.d.ts +12 -5
- package/lib/RadioGroup/index.js +48 -35
- package/lib/Select/components/AllSelect.d.ts +1 -1
- package/lib/Select/components/AllSelect.js +42 -20
- package/lib/Select/components/CheckBoxOption.d.ts +6 -3
- package/lib/Select/components/CheckBoxOption.js +14 -9
- package/lib/Select/components/DropdownComponent.d.ts +4 -4
- package/lib/Select/components/DropdownComponent.js +32 -19
- package/lib/Select/components/NoFindItem.d.ts +1 -1
- package/lib/Select/components/NoFindItem.js +13 -9
- package/lib/Select/components/NotFoundContent.d.ts +2 -2
- package/lib/Select/components/NotFoundContent.js +51 -29
- package/lib/Select/defaultConfig.d.ts +1 -1
- package/lib/Select/defaultConfig.js +21 -17
- package/lib/Select/hooks/changeHooks.d.ts +2 -2
- package/lib/Select/hooks/changeHooks.js +148 -72
- package/lib/Select/hooks/norHooks.d.ts +27 -9
- package/lib/Select/hooks/norHooks.js +52 -40
- package/lib/Select/index.d.ts +22 -1
- package/lib/Select/index.js +128 -67
- package/lib/Select/modal.d.ts +15 -15
- package/lib/Select/utils.js +61 -16
- package/lib/Submit/index.d.ts +9 -3
- package/lib/Submit/index.js +20 -15
- package/lib/Switch/index.d.ts +4 -4
- package/lib/Switch/index.js +48 -22
- package/lib/TDPicker/RangePicker.d.ts +8 -3
- package/lib/TDPicker/RangePicker.js +136 -64
- package/lib/TDPicker/TimePicker.d.ts +6 -1
- package/lib/TDPicker/TimePicker.js +21 -15
- package/lib/TDPicker/hooks.d.ts +42 -22
- package/lib/TDPicker/hooks.js +98 -72
- package/lib/TDPicker/index.d.ts +7 -1
- package/lib/TDPicker/index.js +22 -16
- package/lib/TDPicker/modal.d.ts +21 -16
- package/lib/Upload/Btn.d.ts +5 -1
- package/lib/Upload/Btn.js +37 -21
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/lib/Upload/MediaTypeEle/TypeEle.js +33 -25
- package/lib/Upload/MediaTypeEle/index.d.ts +5 -1
- package/lib/Upload/MediaTypeEle/index.js +23 -20
- package/lib/Upload/Preview/index.d.ts +5 -1
- package/lib/Upload/Preview/index.js +19 -15
- package/lib/Upload/UrlUpload/index.d.ts +7 -1
- package/lib/Upload/UrlUpload/index.js +74 -53
- package/lib/Upload/enums.d.ts +3 -3
- package/lib/Upload/enums.js +4 -4
- package/lib/Upload/hooks/change.d.ts +8 -1
- package/lib/Upload/hooks/change.js +116 -59
- package/lib/Upload/hooks/customRequest.d.ts +5 -1
- package/lib/Upload/hooks/customRequest.js +64 -47
- package/lib/Upload/hooks/propsMaker.d.ts +5 -1
- package/lib/Upload/hooks/propsMaker.js +55 -15
- package/lib/Upload/index.d.ts +3 -1
- package/lib/Upload/index.js +133 -63
- package/lib/Upload/modal.d.ts +17 -15
- package/lib/Upload/util.d.ts +8 -2
- package/lib/Upload/util.js +16 -8
- package/lib/config.js +35 -32
- package/lib/hooks/index.d.ts +14 -7
- package/lib/hooks/index.js +125 -50
- package/lib/index.d.ts +98 -16
- package/lib/index.js +5 -5
- package/lib/modal.d.ts +6 -6
- package/package.json +2 -2
- package/src/components/CheckboxGroup/index.tsx +2 -2
- package/src/components/Form/FormItem/Helper.tsx +3 -4
- package/src/components/Form/HFormConnect.tsx +6 -2
- package/src/components/Form/hooks/useHForm.ts +59 -10
- package/src/components/Form/modal.ts +12 -8
- package/src/components/TDPicker/RangePicker.tsx +7 -5
- package/src/components/TDPicker/modal.ts +1 -0
- package/src/pages/Form/index.tsx +2 -2
|
@@ -1,111 +1,249 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import _Object$getOwnPropertySymbols from
|
|
3
|
-
import _filterInstanceProperty from
|
|
4
|
-
import _Object$getOwnPropertyDescriptor from
|
|
5
|
-
import _Object$getOwnPropertyDescriptors from
|
|
6
|
-
import _Object$defineProperties from
|
|
7
|
-
import _Object$defineProperty from
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js/object/get-own-property-symbols";
|
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
|
|
5
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptors";
|
|
6
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js/object/define-properties";
|
|
7
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
|
|
8
|
+
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
10
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
11
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js/object/keys";
|
|
12
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
|
|
13
|
+
import _Reflect$deleteProperty from "@babel/runtime-corejs3/core-js/reflect/delete-property";
|
|
14
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
15
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
16
|
+
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
import { Form } from "antd";
|
|
16
19
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
function ownKeys(object, enumerableOnly) {
|
|
21
|
+
var keys = _Object$keys(object);
|
|
22
|
+
if (_Object$getOwnPropertySymbols) {
|
|
23
|
+
var symbols = _Object$getOwnPropertySymbols(object);
|
|
24
|
+
enumerableOnly &&
|
|
25
|
+
(symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
26
|
+
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
27
|
+
})),
|
|
28
|
+
keys.push.apply(keys, symbols);
|
|
29
|
+
}
|
|
30
|
+
return keys;
|
|
31
|
+
}
|
|
32
|
+
function _objectSpread(target) {
|
|
33
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
+
var _context5, _context6;
|
|
35
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
36
|
+
i % 2
|
|
37
|
+
? _forEachInstanceProperty(
|
|
38
|
+
(_context5 = ownKeys(Object(source), !0))
|
|
39
|
+
).call(_context5, function (key) {
|
|
40
|
+
_defineProperty(target, key, source[key]);
|
|
41
|
+
})
|
|
42
|
+
: _Object$getOwnPropertyDescriptors
|
|
43
|
+
? _Object$defineProperties(
|
|
44
|
+
target,
|
|
45
|
+
_Object$getOwnPropertyDescriptors(source)
|
|
46
|
+
)
|
|
47
|
+
: _forEachInstanceProperty((_context6 = ownKeys(Object(source)))).call(
|
|
48
|
+
_context6,
|
|
49
|
+
function (key) {
|
|
50
|
+
_Object$defineProperty(
|
|
51
|
+
target,
|
|
52
|
+
key,
|
|
53
|
+
_Object$getOwnPropertyDescriptor(source, key)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
var useHForm = function () {
|
|
20
61
|
var _Form$useForm = Form.useForm(),
|
|
21
62
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
22
63
|
form = _Form$useForm2[0];
|
|
23
64
|
return useMemo(function () {
|
|
24
65
|
var formatSourceData = {};
|
|
25
66
|
var dispatchSourceData = {};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var inputValue = format.inputValue,
|
|
32
|
-
outputValue = format.outputValue;
|
|
33
|
-
formatSourceData[name] = {
|
|
34
|
-
inputValue: inputValue,
|
|
35
|
-
outputValue: outputValue
|
|
67
|
+
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
68
|
+
if (!name) {
|
|
69
|
+
return {
|
|
70
|
+
keysFn: {},
|
|
71
|
+
defaultFn: [fn],
|
|
36
72
|
};
|
|
37
|
-
},
|
|
38
|
-
formatValues: function formatValues() {
|
|
39
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
40
|
-
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
41
|
-
var valKeys = _Object$keys(value).length;
|
|
42
|
-
if (!valKeys) {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
var newValue = _objectSpread({}, value);
|
|
46
|
-
var keys = _Object$keys(formatSourceData);
|
|
47
|
-
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
48
|
-
var _formatSourceData$key;
|
|
49
|
-
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
50
|
-
if (!format) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
var resultValue = format(value);
|
|
54
|
-
_Reflect$deleteProperty(newValue, key);
|
|
55
|
-
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
56
|
-
});
|
|
57
|
-
return newValue;
|
|
58
|
-
},
|
|
59
|
-
dispatch: function dispatch(key) {
|
|
60
|
-
var items = dispatchSourceData[key];
|
|
61
|
-
if (!items) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
_forEachInstanceProperty(items).call(items, function (fn) {
|
|
65
|
-
fn();
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
addDispatchListener: function addDispatchListener(key, fn) {
|
|
69
|
-
var items = dispatchSourceData[key];
|
|
70
|
-
if (!items) {
|
|
71
|
-
dispatchSourceData[key] = [fn];
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
items.push(fn);
|
|
75
|
-
dispatchSourceData[key] = items;
|
|
76
|
-
},
|
|
77
|
-
removeDispatchListener: function removeDispatchListener(key) {
|
|
78
|
-
if (!key) {
|
|
79
|
-
dispatchSourceData = {};
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
83
|
-
},
|
|
84
|
-
initValues: function initValues() {
|
|
85
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
-
var newValue = this.formatValues(value);
|
|
87
|
-
form.setFieldsValue(newValue);
|
|
88
|
-
},
|
|
89
|
-
outputValues: function outputValues(value) {
|
|
90
|
-
return this.formatValues(value, "outputValue");
|
|
91
73
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
74
|
+
return {
|
|
75
|
+
keysFn: _defineProperty({}, name, fn),
|
|
76
|
+
defaultFn: [],
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
return _objectSpread(
|
|
80
|
+
_objectSpread(
|
|
81
|
+
{
|
|
82
|
+
addFormat: function addFormat(name, format) {
|
|
83
|
+
if (!format) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
var inputValue = format.inputValue,
|
|
87
|
+
outputValue = format.outputValue;
|
|
88
|
+
formatSourceData[name] = {
|
|
89
|
+
inputValue: inputValue,
|
|
90
|
+
outputValue: outputValue,
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
formatValues: function formatValues() {
|
|
94
|
+
var value =
|
|
95
|
+
arguments.length > 0 && arguments[0] !== undefined
|
|
96
|
+
? arguments[0]
|
|
97
|
+
: {};
|
|
98
|
+
var formatKey =
|
|
99
|
+
arguments.length > 1 && arguments[1] !== undefined
|
|
100
|
+
? arguments[1]
|
|
101
|
+
: "inputValue";
|
|
102
|
+
var valKeys = _Object$keys(value).length;
|
|
103
|
+
if (!valKeys) {
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
var newValue = _objectSpread({}, value);
|
|
107
|
+
var keys = _Object$keys(formatSourceData);
|
|
108
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
109
|
+
var _formatSourceData$key;
|
|
110
|
+
var format =
|
|
111
|
+
(_formatSourceData$key = formatSourceData[key]) === null ||
|
|
112
|
+
_formatSourceData$key === void 0
|
|
113
|
+
? void 0
|
|
114
|
+
: _formatSourceData$key[formatKey];
|
|
115
|
+
if (!format) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
var resultValue = format(value);
|
|
119
|
+
_Reflect$deleteProperty(newValue, key);
|
|
120
|
+
newValue = _objectSpread(
|
|
121
|
+
_objectSpread({}, newValue),
|
|
122
|
+
resultValue
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
return newValue;
|
|
126
|
+
},
|
|
127
|
+
dispatch: function dispatch(action) {
|
|
128
|
+
var _context2, _context3, _context4;
|
|
129
|
+
for (
|
|
130
|
+
var _len = arguments.length,
|
|
131
|
+
args = new Array(_len > 1 ? _len - 1 : 0),
|
|
132
|
+
_key = 1;
|
|
133
|
+
_key < _len;
|
|
134
|
+
_key++
|
|
135
|
+
) {
|
|
136
|
+
args[_key - 1] = arguments[_key];
|
|
137
|
+
}
|
|
138
|
+
var key = action.key,
|
|
139
|
+
name = action.name;
|
|
140
|
+
var items = dispatchSourceData[key];
|
|
141
|
+
if (!items) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
var keysFn = items.keysFn,
|
|
145
|
+
defaultFn = items.defaultFn;
|
|
146
|
+
if (name) {
|
|
147
|
+
var _keysFn$name, _context;
|
|
148
|
+
return (_keysFn$name = keysFn[name]) === null ||
|
|
149
|
+
_keysFn$name === void 0
|
|
150
|
+
? void 0
|
|
151
|
+
: _keysFn$name.call.apply(
|
|
152
|
+
_keysFn$name,
|
|
153
|
+
_concatInstanceProperty((_context = [keysFn])).call(
|
|
154
|
+
_context,
|
|
155
|
+
args
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
var fnArrays = _mapInstanceProperty(
|
|
160
|
+
(_context2 = _Object$keys(keysFn))
|
|
161
|
+
).call(_context2, function (itemKey) {
|
|
162
|
+
return keysFn[itemKey];
|
|
163
|
+
});
|
|
164
|
+
_forEachInstanceProperty(
|
|
165
|
+
(_context3 = _concatInstanceProperty((_context4 = [])).call(
|
|
166
|
+
_context4,
|
|
167
|
+
_toConsumableArray(fnArrays),
|
|
168
|
+
_toConsumableArray(defaultFn)
|
|
169
|
+
))
|
|
170
|
+
).call(_context3, function (fn) {
|
|
171
|
+
fn.apply(void 0, args);
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
175
|
+
var key = action.key,
|
|
176
|
+
name = action.name;
|
|
177
|
+
var items = dispatchSourceData[key];
|
|
178
|
+
if (!items) {
|
|
179
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
var keysFn = items.keysFn,
|
|
183
|
+
defaultFn = items.defaultFn;
|
|
184
|
+
if (name) {
|
|
185
|
+
keysFn[name] = fn;
|
|
186
|
+
} else {
|
|
187
|
+
defaultFn.push(fn);
|
|
188
|
+
}
|
|
189
|
+
dispatchSourceData[key] = {
|
|
190
|
+
keysFn: keysFn,
|
|
191
|
+
defaultFn: defaultFn,
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
195
|
+
if (!action) {
|
|
196
|
+
dispatchSourceData = {};
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var key = action.key,
|
|
200
|
+
name = action.name;
|
|
201
|
+
var items = dispatchSourceData[key];
|
|
202
|
+
if (!items) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (name) {
|
|
206
|
+
var keysFn = items.keysFn;
|
|
207
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
208
|
+
items.keysFn = keysFn;
|
|
209
|
+
dispatchSourceData[key] = items;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
213
|
+
},
|
|
214
|
+
initValues: function initValues() {
|
|
215
|
+
var value =
|
|
216
|
+
arguments.length > 0 && arguments[0] !== undefined
|
|
217
|
+
? arguments[0]
|
|
218
|
+
: {};
|
|
219
|
+
var newValue = this.formatValues(value);
|
|
220
|
+
form.setFieldsValue(newValue);
|
|
221
|
+
},
|
|
222
|
+
outputValues: function outputValues(value) {
|
|
223
|
+
return this.formatValues(value, "outputValue");
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
form
|
|
227
|
+
),
|
|
228
|
+
{},
|
|
229
|
+
{
|
|
230
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
231
|
+
var newValue = this.formatValues(values);
|
|
232
|
+
form.setFieldsValue(newValue);
|
|
233
|
+
},
|
|
234
|
+
validateFields: function validateFields(nameList) {
|
|
235
|
+
var _this = this;
|
|
236
|
+
return new _Promise(function (resolve) {
|
|
237
|
+
form.validateFields(nameList).then(function (value) {
|
|
238
|
+
var result = _this.formatValues(value, "outputValue");
|
|
239
|
+
return resolve(result);
|
|
240
|
+
});
|
|
103
241
|
});
|
|
104
|
-
}
|
|
242
|
+
},
|
|
105
243
|
}
|
|
106
|
-
|
|
244
|
+
);
|
|
107
245
|
}, []);
|
|
108
|
-
}
|
|
246
|
+
};
|
|
109
247
|
|
|
110
248
|
export { useHForm as default };
|
|
111
249
|
// powered by hdj
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { FormItemWithRender, HFormProps } from "@/components/Form/modal";
|
|
2
2
|
type InitConfigModal = Required<Pick<HFormProps, "configData" | "form">>;
|
|
3
|
-
declare const _default: ({
|
|
3
|
+
declare const _default: ({
|
|
4
|
+
configData,
|
|
5
|
+
form,
|
|
6
|
+
}: InitConfigModal) => FormItemWithRender[];
|
|
4
7
|
export default _default;
|
|
@@ -1,24 +1,62 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import React, { useMemo } from
|
|
3
|
-
import _Object$keys from
|
|
4
|
-
import _Object$getOwnPropertySymbols from
|
|
5
|
-
import _filterInstanceProperty from
|
|
6
|
-
import _Object$getOwnPropertyDescriptor from
|
|
7
|
-
import _forEachInstanceProperty from
|
|
8
|
-
import _Object$getOwnPropertyDescriptors from
|
|
9
|
-
import _Object$defineProperties from
|
|
10
|
-
import _Object$defineProperty from
|
|
11
|
-
import _extends from
|
|
12
|
-
import _objectWithoutProperties from
|
|
13
|
-
import _defineProperty from
|
|
14
|
-
import _mapInstanceProperty from
|
|
15
|
-
import _indexOfInstanceProperty from
|
|
16
|
-
import FormConfig, { placeholderConfig } from
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js/object/keys";
|
|
4
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js/object/get-own-property-symbols";
|
|
5
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
6
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
|
|
7
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
|
|
8
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptors";
|
|
9
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js/object/define-properties";
|
|
10
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
|
|
11
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
12
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
|
|
13
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
14
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
15
|
+
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js/instance/index-of";
|
|
16
|
+
import FormConfig, { placeholderConfig } from "../config.js";
|
|
17
17
|
|
|
18
18
|
var _excluded = ["render", "type", "itemProps"],
|
|
19
19
|
_excluded2 = ["render"];
|
|
20
|
-
function ownKeys(object, enumerableOnly) {
|
|
21
|
-
|
|
20
|
+
function ownKeys(object, enumerableOnly) {
|
|
21
|
+
var keys = _Object$keys(object);
|
|
22
|
+
if (_Object$getOwnPropertySymbols) {
|
|
23
|
+
var symbols = _Object$getOwnPropertySymbols(object);
|
|
24
|
+
enumerableOnly &&
|
|
25
|
+
(symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
26
|
+
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
27
|
+
})),
|
|
28
|
+
keys.push.apply(keys, symbols);
|
|
29
|
+
}
|
|
30
|
+
return keys;
|
|
31
|
+
}
|
|
32
|
+
function _objectSpread(target) {
|
|
33
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
34
|
+
var _context2, _context3;
|
|
35
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
36
|
+
i % 2
|
|
37
|
+
? _forEachInstanceProperty(
|
|
38
|
+
(_context2 = ownKeys(Object(source), !0))
|
|
39
|
+
).call(_context2, function (key) {
|
|
40
|
+
_defineProperty(target, key, source[key]);
|
|
41
|
+
})
|
|
42
|
+
: _Object$getOwnPropertyDescriptors
|
|
43
|
+
? _Object$defineProperties(
|
|
44
|
+
target,
|
|
45
|
+
_Object$getOwnPropertyDescriptors(source)
|
|
46
|
+
)
|
|
47
|
+
: _forEachInstanceProperty((_context3 = ownKeys(Object(source)))).call(
|
|
48
|
+
_context3,
|
|
49
|
+
function (key) {
|
|
50
|
+
_Object$defineProperty(
|
|
51
|
+
target,
|
|
52
|
+
key,
|
|
53
|
+
_Object$getOwnPropertyDescriptor(source, key)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
22
60
|
var mathRequired = function mathRequired(configItem, form) {
|
|
23
61
|
var required = configItem.required,
|
|
24
62
|
placeholder = configItem.placeholder,
|
|
@@ -27,28 +65,41 @@ var mathRequired = function mathRequired(configItem, form) {
|
|
|
27
65
|
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
28
66
|
var resultRequired = false;
|
|
29
67
|
var dom = FormConfig[type];
|
|
30
|
-
var resultRules =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
var resultRules =
|
|
69
|
+
rules === null || rules === void 0
|
|
70
|
+
? void 0
|
|
71
|
+
: _mapInstanceProperty(rules).call(rules, function (item) {
|
|
72
|
+
var eachItem = item;
|
|
73
|
+
if (typeof item === "function") {
|
|
74
|
+
eachItem = item(form);
|
|
75
|
+
}
|
|
76
|
+
var _eachItem = eachItem,
|
|
77
|
+
itemRequired = _eachItem.required,
|
|
78
|
+
message = _eachItem.message;
|
|
79
|
+
if (itemRequired) {
|
|
80
|
+
resultRequired = itemRequired;
|
|
81
|
+
}
|
|
82
|
+
if (itemRequired && !message) {
|
|
83
|
+
return _objectSpread(
|
|
84
|
+
_objectSpread({}, eachItem),
|
|
85
|
+
{},
|
|
86
|
+
{
|
|
87
|
+
required: itemRequired,
|
|
88
|
+
message: !!(
|
|
89
|
+
dom !== null &&
|
|
90
|
+
dom !== void 0 &&
|
|
91
|
+
dom.requiredErrMsg
|
|
92
|
+
)
|
|
93
|
+
? dom.requiredErrMsg(configItem)
|
|
94
|
+
: placeholder,
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return eachItem;
|
|
99
|
+
});
|
|
49
100
|
return {
|
|
50
101
|
required: typeof required === "boolean" ? required : resultRequired,
|
|
51
|
-
rules: resultRules
|
|
102
|
+
rules: resultRules,
|
|
52
103
|
};
|
|
53
104
|
};
|
|
54
105
|
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
@@ -64,7 +115,12 @@ var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
|
64
115
|
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
65
116
|
return dom.placeholder(props);
|
|
66
117
|
}
|
|
67
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
_indexOfInstanceProperty((_context = placeholderConfig.inputType)).call(
|
|
120
|
+
_context,
|
|
121
|
+
type
|
|
122
|
+
) !== -1
|
|
123
|
+
) {
|
|
68
124
|
return "\u8BF7\u8F93\u5165".concat(label);
|
|
69
125
|
}
|
|
70
126
|
return "\u8BF7\u9009\u62E9".concat(label);
|
|
@@ -78,24 +134,43 @@ var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
|
78
134
|
componentProps = _objectWithoutProperties(props, _excluded);
|
|
79
135
|
var dom = FormConfig[type];
|
|
80
136
|
return function (form) {
|
|
81
|
-
var Component = !!(dom !== null && dom !== void 0 && dom.Component)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
137
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component)
|
|
138
|
+
? dom.Component
|
|
139
|
+
: dom;
|
|
140
|
+
var node =
|
|
141
|
+
Component &&
|
|
142
|
+
/*#__PURE__*/ React.createElement(
|
|
143
|
+
Component,
|
|
144
|
+
_extends({}, componentProps, itemProps, {
|
|
145
|
+
form: form,
|
|
146
|
+
})
|
|
147
|
+
);
|
|
85
148
|
if (render) {
|
|
86
149
|
return render(props, node, form);
|
|
87
150
|
}
|
|
88
151
|
return node;
|
|
89
152
|
};
|
|
90
153
|
};
|
|
91
|
-
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
|
|
154
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
|
|
155
|
+
props
|
|
156
|
+
) {
|
|
92
157
|
var placeholder = matchDefaultPlaceholder(props);
|
|
93
|
-
return _objectSpread(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
158
|
+
return _objectSpread(
|
|
159
|
+
_objectSpread({}, props),
|
|
160
|
+
{},
|
|
161
|
+
{
|
|
162
|
+
placeholder: placeholder,
|
|
163
|
+
render: defaultRenderMaker(
|
|
164
|
+
_objectSpread(
|
|
165
|
+
_objectSpread({}, props),
|
|
166
|
+
{},
|
|
167
|
+
{
|
|
168
|
+
placeholder: placeholder,
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
),
|
|
172
|
+
}
|
|
173
|
+
);
|
|
99
174
|
};
|
|
100
175
|
var itemControl = function itemControl(item, form) {
|
|
101
176
|
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
@@ -104,21 +179,28 @@ var itemControl = function itemControl(item, form) {
|
|
|
104
179
|
var _mathRequired = mathRequired(defaultProps, form),
|
|
105
180
|
rules = _mathRequired.rules,
|
|
106
181
|
required = _mathRequired.required;
|
|
107
|
-
return _objectSpread(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
182
|
+
return _objectSpread(
|
|
183
|
+
_objectSpread({}, defaultProps),
|
|
184
|
+
{},
|
|
185
|
+
{
|
|
186
|
+
required: required,
|
|
187
|
+
rules: rules,
|
|
188
|
+
render: render,
|
|
189
|
+
}
|
|
190
|
+
);
|
|
112
191
|
};
|
|
113
|
-
var useInitConfigData =
|
|
192
|
+
var useInitConfigData = function (_ref) {
|
|
114
193
|
var configData = _ref.configData,
|
|
115
194
|
form = _ref.form;
|
|
116
|
-
return useMemo(
|
|
117
|
-
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
195
|
+
return useMemo(
|
|
196
|
+
function () {
|
|
197
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
198
|
+
return itemControl(item, form);
|
|
199
|
+
});
|
|
200
|
+
},
|
|
201
|
+
[configData]
|
|
202
|
+
);
|
|
203
|
+
};
|
|
122
204
|
|
|
123
205
|
export { useInitConfigData as default };
|
|
124
206
|
// powered by hdj
|
package/es/Form/index.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HFormProps } from "./modal";
|
|
3
|
-
declare const _default: ({
|
|
3
|
+
declare const _default: ({
|
|
4
|
+
configData,
|
|
5
|
+
labelWidth,
|
|
6
|
+
form,
|
|
7
|
+
request,
|
|
8
|
+
onFinish,
|
|
9
|
+
infoRequest,
|
|
10
|
+
valueType,
|
|
11
|
+
initialValues,
|
|
12
|
+
...props
|
|
13
|
+
}: HFormProps) => JSX.Element;
|
|
4
14
|
export default _default;
|