@hw-component/form 0.0.1-beta → 0.0.1-beta-v2
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 +16 -24
- package/es/CheckboxGroup/hooks.d.ts +3 -9
- package/es/CheckboxGroup/hooks.js +64 -115
- package/es/CheckboxGroup/index.d.ts +1 -6
- package/es/CheckboxGroup/index.js +58 -117
- package/es/CheckboxGroup/modal.d.ts +8 -9
- package/es/Form/Context/FormConfigProvider.js +19 -64
- package/es/Form/Context/index.d.ts +1 -4
- package/es/Form/Context/index.js +3 -3
- package/es/Form/FormItem/BasicItem.js +42 -80
- package/es/Form/FormItem/Helper.d.ts +1 -1
- package/es/Form/FormItem/Helper.js +9 -17
- package/es/Form/FormItem/RegularFormItem.js +8 -11
- package/es/Form/FormItem/UpFormItem.d.ts +1 -6
- package/es/Form/FormItem/UpFormItem.js +17 -27
- package/es/Form/FormItem/hooks.d.ts +4 -21
- package/es/Form/FormItem/hooks.js +9 -12
- package/es/Form/FormItem/index.js +5 -5
- package/es/Form/HFormConnect.d.ts +1 -9
- package/es/Form/HFormConnect.js +30 -90
- package/es/Form/InitSet.d.ts +1 -4
- package/es/Form/InitSet.js +6 -7
- package/es/Form/Label.d.ts +4 -4
- package/es/Form/Label.js +19 -36
- package/es/Form/config.d.ts +22 -100
- package/es/Form/config.js +19 -19
- package/es/Form/hooks/index.d.ts +1 -14
- package/es/Form/hooks/index.js +32 -80
- package/es/Form/hooks/useHForm.js +143 -224
- package/es/Form/hooks/useInitConfigData.d.ts +1 -4
- package/es/Form/hooks/useInitConfigData.js +61 -143
- package/es/Form/index.d.ts +1 -11
- package/es/Form/index.js +79 -79
- package/es/Form/modal.d.ts +54 -89
- package/es/Input/ButtonInput.js +51 -73
- package/es/Input/InputNumber.js +12 -21
- package/es/Input/SelectInput.d.ts +4 -16
- package/es/Input/SelectInput.js +62 -116
- 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 +13 -15
- package/es/ModalForm/hooks.d.ts +12 -0
- package/es/ModalForm/hooks.js +63 -0
- package/es/ModalForm/index.d.ts +4 -0
- package/es/ModalForm/index.js +72 -0
- package/es/ModalForm/modal.d.ts +20 -0
- package/es/PageHandler/ErrorComponent.js +25 -47
- package/es/PageHandler/LoadingComponent.js +13 -17
- package/es/PageHandler/index.js +7 -7
- package/es/PageHandler/modal.d.ts +4 -4
- package/es/RadioGroup/index.d.ts +5 -12
- package/es/RadioGroup/index.js +33 -46
- package/es/Select/components/AllSelect.d.ts +1 -1
- package/es/Select/components/AllSelect.js +18 -40
- package/es/Select/components/CheckBoxOption.d.ts +3 -6
- package/es/Select/components/CheckBoxOption.js +7 -12
- package/es/Select/components/DropdownComponent.d.ts +4 -4
- package/es/Select/components/DropdownComponent.js +17 -30
- package/es/Select/components/NoFindItem.d.ts +1 -1
- package/es/Select/components/NoFindItem.js +7 -11
- package/es/Select/components/NotFoundContent.d.ts +2 -2
- package/es/Select/components/NotFoundContent.js +27 -49
- package/es/Select/defaultConfig.d.ts +1 -1
- package/es/Select/defaultConfig.js +16 -20
- package/es/Select/hooks/changeHooks.d.ts +2 -2
- package/es/Select/hooks/changeHooks.js +71 -147
- package/es/Select/hooks/norHooks.d.ts +9 -27
- package/es/Select/hooks/norHooks.js +39 -51
- package/es/Select/index.d.ts +1 -22
- package/es/Select/index.js +65 -124
- package/es/Select/modal.d.ts +15 -15
- package/es/Select/utils.js +15 -60
- package/es/Submit/index.d.ts +3 -9
- package/es/Submit/index.js +13 -18
- package/es/Switch/index.d.ts +4 -4
- package/es/Switch/index.js +20 -46
- package/es/TDPicker/RangePicker.d.ts +3 -8
- package/es/TDPicker/RangePicker.js +67 -138
- package/es/TDPicker/TimePicker.d.ts +1 -6
- package/es/TDPicker/TimePicker.js +13 -19
- package/es/TDPicker/hooks.d.ts +22 -42
- package/es/TDPicker/hooks.js +72 -106
- package/es/TDPicker/index.d.ts +1 -7
- package/es/TDPicker/index.js +14 -20
- package/es/TDPicker/modal.d.ts +16 -21
- package/es/TextArea/index.d.ts +1 -0
- package/es/Upload/Btn.d.ts +1 -5
- package/es/Upload/Btn.js +19 -35
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +5 -10
- package/es/Upload/MediaTypeEle/TypeEle.js +23 -31
- package/es/Upload/MediaTypeEle/index.d.ts +1 -5
- package/es/Upload/MediaTypeEle/index.js +18 -21
- package/es/Upload/Preview/index.d.ts +1 -5
- package/es/Upload/Preview/index.js +13 -17
- package/es/Upload/UrlUpload/index.d.ts +1 -7
- package/es/Upload/UrlUpload/index.js +51 -72
- package/es/Upload/enums.d.ts +3 -3
- package/es/Upload/enums.js +3 -3
- package/es/Upload/hooks/change.d.ts +1 -8
- package/es/Upload/hooks/change.js +58 -115
- package/es/Upload/hooks/customRequest.d.ts +1 -5
- package/es/Upload/hooks/customRequest.js +46 -63
- package/es/Upload/hooks/propsMaker.d.ts +1 -5
- package/es/Upload/hooks/propsMaker.js +13 -52
- package/es/Upload/index.d.ts +1 -3
- package/es/Upload/index.js +61 -131
- package/es/Upload/modal.d.ts +15 -17
- package/es/Upload/util.d.ts +2 -8
- package/es/Upload/util.js +7 -15
- package/es/config.js +31 -34
- package/es/hooks/index.d.ts +7 -14
- package/es/hooks/index.js +49 -124
- package/es/index.d.ts +18 -98
- package/es/index.js +8 -22
- package/es/modal.d.ts +6 -6
- package/lib/CheckboxGroup/CheckBox/index.js +18 -26
- package/lib/CheckboxGroup/hooks.d.ts +3 -9
- package/lib/CheckboxGroup/hooks.js +65 -116
- package/lib/CheckboxGroup/index.d.ts +1 -6
- package/lib/CheckboxGroup/index.js +60 -119
- package/lib/CheckboxGroup/modal.d.ts +8 -9
- package/lib/Form/Context/FormConfigProvider.js +21 -66
- package/lib/Form/Context/index.d.ts +1 -4
- package/lib/Form/Context/index.js +4 -4
- package/lib/Form/FormItem/BasicItem.js +44 -82
- package/lib/Form/FormItem/Helper.d.ts +1 -1
- package/lib/Form/FormItem/Helper.js +11 -19
- package/lib/Form/FormItem/RegularFormItem.js +10 -13
- package/lib/Form/FormItem/UpFormItem.d.ts +1 -6
- package/lib/Form/FormItem/UpFormItem.js +19 -29
- package/lib/Form/FormItem/hooks.d.ts +4 -21
- package/lib/Form/FormItem/hooks.js +10 -13
- package/lib/Form/FormItem/index.js +7 -7
- package/lib/Form/HFormConnect.d.ts +1 -9
- package/lib/Form/HFormConnect.js +32 -92
- package/lib/Form/InitSet.d.ts +1 -4
- package/lib/Form/InitSet.js +8 -9
- package/lib/Form/Label.d.ts +4 -4
- package/lib/Form/Label.js +21 -41
- package/lib/Form/config.d.ts +22 -100
- package/lib/Form/config.js +21 -21
- package/lib/Form/hooks/index.d.ts +1 -14
- package/lib/Form/hooks/index.js +32 -81
- package/lib/Form/hooks/useHForm.js +145 -226
- package/lib/Form/hooks/useInitConfigData.d.ts +1 -4
- package/lib/Form/hooks/useInitConfigData.js +63 -144
- package/lib/Form/index.d.ts +1 -11
- package/lib/Form/index.js +83 -83
- package/lib/Form/modal.d.ts +54 -89
- package/lib/Input/ButtonInput.js +53 -75
- package/lib/Input/InputNumber.js +14 -23
- package/lib/Input/SelectInput.d.ts +4 -16
- package/lib/Input/SelectInput.js +66 -128
- 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 +13 -15
- package/lib/ModalForm/hooks.d.ts +12 -0
- package/lib/ModalForm/hooks.js +66 -0
- package/lib/ModalForm/index.d.ts +4 -0
- package/lib/ModalForm/index.js +75 -0
- package/lib/ModalForm/modal.d.ts +20 -0
- package/lib/PageHandler/ErrorComponent.js +27 -49
- package/lib/PageHandler/LoadingComponent.js +15 -19
- package/lib/PageHandler/index.js +9 -9
- package/lib/PageHandler/modal.d.ts +4 -4
- package/lib/RadioGroup/index.d.ts +5 -12
- package/lib/RadioGroup/index.js +35 -48
- package/lib/Select/components/AllSelect.d.ts +1 -1
- package/lib/Select/components/AllSelect.js +20 -42
- package/lib/Select/components/CheckBoxOption.d.ts +3 -6
- package/lib/Select/components/CheckBoxOption.js +9 -14
- package/lib/Select/components/DropdownComponent.d.ts +4 -4
- package/lib/Select/components/DropdownComponent.js +19 -32
- package/lib/Select/components/NoFindItem.d.ts +1 -1
- package/lib/Select/components/NoFindItem.js +9 -13
- package/lib/Select/components/NotFoundContent.d.ts +2 -2
- package/lib/Select/components/NotFoundContent.js +29 -51
- package/lib/Select/defaultConfig.d.ts +1 -1
- package/lib/Select/defaultConfig.js +17 -21
- package/lib/Select/hooks/changeHooks.d.ts +2 -2
- package/lib/Select/hooks/changeHooks.js +72 -148
- package/lib/Select/hooks/norHooks.d.ts +9 -27
- package/lib/Select/hooks/norHooks.js +40 -52
- package/lib/Select/index.d.ts +1 -22
- package/lib/Select/index.js +67 -128
- package/lib/Select/modal.d.ts +15 -15
- package/lib/Select/utils.js +16 -61
- package/lib/Submit/index.d.ts +3 -9
- package/lib/Submit/index.js +15 -20
- package/lib/Switch/index.d.ts +4 -4
- package/lib/Switch/index.js +22 -48
- package/lib/TDPicker/RangePicker.d.ts +3 -8
- package/lib/TDPicker/RangePicker.js +69 -136
- package/lib/TDPicker/TimePicker.d.ts +1 -6
- package/lib/TDPicker/TimePicker.js +15 -21
- package/lib/TDPicker/hooks.d.ts +22 -42
- package/lib/TDPicker/hooks.js +72 -98
- package/lib/TDPicker/index.d.ts +1 -7
- package/lib/TDPicker/index.js +16 -22
- package/lib/TDPicker/modal.d.ts +16 -21
- package/lib/TextArea/index.d.ts +1 -0
- package/lib/Upload/Btn.d.ts +1 -5
- package/lib/Upload/Btn.js +21 -37
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +5 -10
- package/lib/Upload/MediaTypeEle/TypeEle.js +25 -33
- package/lib/Upload/MediaTypeEle/index.d.ts +1 -5
- package/lib/Upload/MediaTypeEle/index.js +20 -23
- package/lib/Upload/Preview/index.d.ts +1 -5
- package/lib/Upload/Preview/index.js +15 -19
- package/lib/Upload/UrlUpload/index.d.ts +1 -7
- package/lib/Upload/UrlUpload/index.js +53 -74
- package/lib/Upload/enums.d.ts +3 -3
- package/lib/Upload/enums.js +4 -4
- package/lib/Upload/hooks/change.d.ts +1 -8
- package/lib/Upload/hooks/change.js +59 -116
- package/lib/Upload/hooks/customRequest.d.ts +1 -5
- package/lib/Upload/hooks/customRequest.js +47 -64
- package/lib/Upload/hooks/propsMaker.d.ts +1 -5
- package/lib/Upload/hooks/propsMaker.js +15 -55
- package/lib/Upload/index.d.ts +1 -3
- package/lib/Upload/index.js +63 -133
- package/lib/Upload/modal.d.ts +15 -17
- package/lib/Upload/util.d.ts +2 -8
- package/lib/Upload/util.js +8 -16
- package/lib/config.js +32 -35
- package/lib/hooks/index.d.ts +7 -14
- package/lib/hooks/index.js +50 -125
- package/lib/index.d.ts +18 -98
- package/lib/index.js +10 -5
- package/lib/modal.d.ts +6 -6
- package/package.json +1 -1
- package/src/components/Form/InitSet.tsx +3 -5
- package/src/components/Form/hooks/index.ts +0 -20
- package/src/components/Form/hooks/useHForm.ts +8 -4
- package/src/components/Form/index.tsx +25 -7
- package/src/components/Form/modal.ts +4 -2
- package/src/components/Input/SelectInput.tsx +3 -2
- package/src/components/Input/modal.ts +2 -0
- package/src/components/ModalForm/hooks.ts +45 -0
- package/src/components/ModalForm/index.tsx +69 -0
- package/src/components/ModalForm/modal.ts +22 -0
- package/src/components/index.tsx +4 -0
- package/src/pages/ModalForm/index.tsx +127 -0
- package/src/routes.tsx +6 -1
|
@@ -1,65 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require(
|
|
6
|
-
var _Object$keys = require(
|
|
7
|
-
var _Object$getOwnPropertySymbols = require(
|
|
8
|
-
var _filterInstanceProperty = require(
|
|
9
|
-
var _Object$getOwnPropertyDescriptor = require(
|
|
10
|
-
var _forEachInstanceProperty = require(
|
|
11
|
-
var _Object$getOwnPropertyDescriptors = require(
|
|
12
|
-
var _Object$defineProperties = require(
|
|
13
|
-
var _Object$defineProperty = require(
|
|
14
|
-
var _extends = require(
|
|
15
|
-
var _objectWithoutProperties = require(
|
|
16
|
-
var _defineProperty = require(
|
|
17
|
-
var _mapInstanceProperty = require(
|
|
18
|
-
var _indexOfInstanceProperty = require(
|
|
19
|
-
var config = require(
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
|
|
7
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
|
|
8
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
|
|
9
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
|
|
10
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
|
|
11
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
|
|
12
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
|
|
13
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
|
|
14
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
15
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
16
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
17
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
18
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/index-of');
|
|
19
|
+
var config = require('../config.js');
|
|
20
20
|
|
|
21
21
|
var _excluded = ["render", "type", "itemProps"],
|
|
22
22
|
_excluded2 = ["render"];
|
|
23
|
-
function ownKeys(object, enumerableOnly) {
|
|
24
|
-
|
|
25
|
-
if (_Object$getOwnPropertySymbols) {
|
|
26
|
-
var symbols = _Object$getOwnPropertySymbols(object);
|
|
27
|
-
enumerableOnly &&
|
|
28
|
-
(symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
29
|
-
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
30
|
-
})),
|
|
31
|
-
keys.push.apply(keys, symbols);
|
|
32
|
-
}
|
|
33
|
-
return keys;
|
|
34
|
-
}
|
|
35
|
-
function _objectSpread(target) {
|
|
36
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
37
|
-
var _context2, _context3;
|
|
38
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
39
|
-
i % 2
|
|
40
|
-
? _forEachInstanceProperty(
|
|
41
|
-
(_context2 = ownKeys(Object(source), !0))
|
|
42
|
-
).call(_context2, function (key) {
|
|
43
|
-
_defineProperty(target, key, source[key]);
|
|
44
|
-
})
|
|
45
|
-
: _Object$getOwnPropertyDescriptors
|
|
46
|
-
? _Object$defineProperties(
|
|
47
|
-
target,
|
|
48
|
-
_Object$getOwnPropertyDescriptors(source)
|
|
49
|
-
)
|
|
50
|
-
: _forEachInstanceProperty((_context3 = ownKeys(Object(source)))).call(
|
|
51
|
-
_context3,
|
|
52
|
-
function (key) {
|
|
53
|
-
_Object$defineProperty(
|
|
54
|
-
target,
|
|
55
|
-
key,
|
|
56
|
-
_Object$getOwnPropertyDescriptor(source, key)
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return target;
|
|
62
|
-
}
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
63
25
|
var mathRequired = function mathRequired(configItem, form) {
|
|
64
26
|
var required = configItem.required,
|
|
65
27
|
placeholder = configItem.placeholder,
|
|
@@ -68,41 +30,28 @@ var mathRequired = function mathRequired(configItem, form) {
|
|
|
68
30
|
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
69
31
|
var resultRequired = false;
|
|
70
32
|
var dom = config.default[type];
|
|
71
|
-
var resultRules =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
required: itemRequired,
|
|
91
|
-
message: !!(
|
|
92
|
-
dom !== null &&
|
|
93
|
-
dom !== void 0 &&
|
|
94
|
-
dom.requiredErrMsg
|
|
95
|
-
)
|
|
96
|
-
? dom.requiredErrMsg(configItem)
|
|
97
|
-
: placeholder,
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return eachItem;
|
|
102
|
-
});
|
|
33
|
+
var resultRules = rules === null || rules === void 0 ? void 0 : _mapInstanceProperty(rules).call(rules, function (item) {
|
|
34
|
+
var eachItem = item;
|
|
35
|
+
if (typeof item === "function") {
|
|
36
|
+
eachItem = item(form);
|
|
37
|
+
}
|
|
38
|
+
var _eachItem = eachItem,
|
|
39
|
+
itemRequired = _eachItem.required,
|
|
40
|
+
message = _eachItem.message;
|
|
41
|
+
if (itemRequired) {
|
|
42
|
+
resultRequired = itemRequired;
|
|
43
|
+
}
|
|
44
|
+
if (itemRequired && !message) {
|
|
45
|
+
return _objectSpread(_objectSpread({}, eachItem), {}, {
|
|
46
|
+
required: itemRequired,
|
|
47
|
+
message: !!(dom !== null && dom !== void 0 && dom.requiredErrMsg) ? dom.requiredErrMsg(configItem) : placeholder
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return eachItem;
|
|
51
|
+
});
|
|
103
52
|
return {
|
|
104
53
|
required: typeof required === "boolean" ? required : resultRequired,
|
|
105
|
-
rules: resultRules
|
|
54
|
+
rules: resultRules
|
|
106
55
|
};
|
|
107
56
|
};
|
|
108
57
|
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
@@ -118,11 +67,7 @@ var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
|
118
67
|
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
119
68
|
return dom.placeholder(props);
|
|
120
69
|
}
|
|
121
|
-
if (
|
|
122
|
-
_indexOfInstanceProperty(
|
|
123
|
-
(_context = config.placeholderConfig.inputType)
|
|
124
|
-
).call(_context, type) !== -1
|
|
125
|
-
) {
|
|
70
|
+
if (_indexOfInstanceProperty(_context = config.placeholderConfig.inputType).call(_context, type) !== -1) {
|
|
126
71
|
return "\u8BF7\u8F93\u5165".concat(label);
|
|
127
72
|
}
|
|
128
73
|
return "\u8BF7\u9009\u62E9".concat(label);
|
|
@@ -136,43 +81,24 @@ var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
|
136
81
|
componentProps = _objectWithoutProperties(props, _excluded);
|
|
137
82
|
var dom = config.default[type];
|
|
138
83
|
return function (form) {
|
|
139
|
-
var Component = !!(dom !== null && dom !== void 0 && dom.Component)
|
|
140
|
-
|
|
141
|
-
:
|
|
142
|
-
|
|
143
|
-
Component &&
|
|
144
|
-
/*#__PURE__*/ React.createElement(
|
|
145
|
-
Component,
|
|
146
|
-
_extends({}, componentProps, itemProps, {
|
|
147
|
-
form: form,
|
|
148
|
-
})
|
|
149
|
-
);
|
|
84
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component) ? dom.Component : dom;
|
|
85
|
+
var node = Component && /*#__PURE__*/React.createElement(Component, _extends({}, componentProps, itemProps, {
|
|
86
|
+
form: form
|
|
87
|
+
}));
|
|
150
88
|
if (render) {
|
|
151
89
|
return render(props, node, form);
|
|
152
90
|
}
|
|
153
91
|
return node;
|
|
154
92
|
};
|
|
155
93
|
};
|
|
156
|
-
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
|
|
157
|
-
props
|
|
158
|
-
) {
|
|
94
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(props) {
|
|
159
95
|
var placeholder = matchDefaultPlaceholder(props);
|
|
160
|
-
return _objectSpread(
|
|
161
|
-
|
|
162
|
-
{},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
_objectSpread(
|
|
167
|
-
_objectSpread({}, props),
|
|
168
|
-
{},
|
|
169
|
-
{
|
|
170
|
-
placeholder: placeholder,
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
),
|
|
174
|
-
}
|
|
175
|
-
);
|
|
96
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
97
|
+
placeholder: placeholder,
|
|
98
|
+
render: defaultRenderMaker(_objectSpread(_objectSpread({}, props), {}, {
|
|
99
|
+
placeholder: placeholder
|
|
100
|
+
}))
|
|
101
|
+
});
|
|
176
102
|
};
|
|
177
103
|
var itemControl = function itemControl(item, form) {
|
|
178
104
|
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
@@ -181,28 +107,21 @@ var itemControl = function itemControl(item, form) {
|
|
|
181
107
|
var _mathRequired = mathRequired(defaultProps, form),
|
|
182
108
|
rules = _mathRequired.rules,
|
|
183
109
|
required = _mathRequired.required;
|
|
184
|
-
return _objectSpread(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
rules: rules,
|
|
190
|
-
render: render,
|
|
191
|
-
}
|
|
192
|
-
);
|
|
110
|
+
return _objectSpread(_objectSpread({}, defaultProps), {}, {
|
|
111
|
+
required: required,
|
|
112
|
+
rules: rules,
|
|
113
|
+
render: render
|
|
114
|
+
});
|
|
193
115
|
};
|
|
194
|
-
var useInitConfigData = function (_ref) {
|
|
116
|
+
var useInitConfigData = (function (_ref) {
|
|
195
117
|
var configData = _ref.configData,
|
|
196
118
|
form = _ref.form;
|
|
197
|
-
return React.useMemo(
|
|
198
|
-
function () {
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
[configData]
|
|
204
|
-
);
|
|
205
|
-
};
|
|
119
|
+
return React.useMemo(function () {
|
|
120
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
121
|
+
return itemControl(item, form);
|
|
122
|
+
});
|
|
123
|
+
}, [configData]);
|
|
124
|
+
});
|
|
206
125
|
|
|
207
126
|
exports.default = useInitConfigData;
|
|
208
127
|
// powered by h
|
package/lib/Form/index.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HFormProps } from "./modal";
|
|
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;
|
|
3
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, ...props }: HFormProps) => JSX.Element;
|
|
14
4
|
export default _default;
|
package/lib/Form/index.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require(
|
|
6
|
-
var _extends = require(
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var index$3 = require(
|
|
13
|
-
var index
|
|
14
|
-
var
|
|
15
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var _extends = require('@babel/runtime-corejs3/helpers/extends');
|
|
7
|
+
var _asyncToGenerator = require('@babel/runtime-corejs3/helpers/asyncToGenerator');
|
|
8
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
9
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
|
|
10
|
+
var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
11
|
+
var antd = require('antd');
|
|
12
|
+
var index$3 = require('./FormItem/index.js');
|
|
13
|
+
var index = require('./hooks/index.js');
|
|
14
|
+
var index$2 = require('./Context/index.js');
|
|
15
|
+
var index$1 = require('../PageHandler/index.js');
|
|
16
|
+
var useInitConfigData = require('./hooks/useInitConfigData.js');
|
|
17
|
+
var ahooks = require('ahooks');
|
|
18
|
+
var InitSet = require('./InitSet.js');
|
|
16
19
|
|
|
17
|
-
var _excluded = [
|
|
18
|
-
|
|
19
|
-
"labelWidth",
|
|
20
|
-
"form",
|
|
21
|
-
"request",
|
|
22
|
-
"onFinish",
|
|
23
|
-
"infoRequest",
|
|
24
|
-
"valueType",
|
|
25
|
-
"initialValues",
|
|
26
|
-
];
|
|
27
|
-
var index = function (_ref) {
|
|
20
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues"];
|
|
21
|
+
var HForm = (function (_ref) {
|
|
28
22
|
var configData = _ref.configData,
|
|
29
23
|
labelWidth = _ref.labelWidth,
|
|
30
24
|
form = _ref.form,
|
|
@@ -35,73 +29,79 @@ var index = function (_ref) {
|
|
|
35
29
|
valueType = _ref$valueType === void 0 ? "float" : _ref$valueType,
|
|
36
30
|
initialValues = _ref.initialValues,
|
|
37
31
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
-
var hForm = index
|
|
32
|
+
var hForm = index.useCurrentForm(form);
|
|
39
33
|
var newConfigData = useInitConfigData.default({
|
|
40
34
|
configData: configData,
|
|
41
|
-
form: hForm
|
|
35
|
+
form: hForm
|
|
42
36
|
});
|
|
43
|
-
var _useSub = index
|
|
37
|
+
var _useSub = index.useSub({
|
|
44
38
|
request: request,
|
|
45
39
|
onFinish: onFinish,
|
|
46
40
|
valueType: valueType,
|
|
47
|
-
form: hForm
|
|
41
|
+
form: hForm
|
|
48
42
|
}),
|
|
49
43
|
run = _useSub.run,
|
|
50
44
|
loading = _useSub.loading;
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
)
|
|
104
|
-
|
|
45
|
+
var _useRequest = ahooks.useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
46
|
+
var setValue;
|
|
47
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48
|
+
while (1) switch (_context.prev = _context.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
setValue = initialValues;
|
|
51
|
+
if (!(!initialValues && !infoRequest)) {
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return _context.abrupt("return", {});
|
|
56
|
+
case 3:
|
|
57
|
+
if (!infoRequest) {
|
|
58
|
+
_context.next = 7;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
_context.next = 6;
|
|
62
|
+
return infoRequest();
|
|
63
|
+
case 6:
|
|
64
|
+
setValue = _context.sent;
|
|
65
|
+
case 7:
|
|
66
|
+
hForm.setFieldsValue(setValue);
|
|
67
|
+
return _context.abrupt("return", setValue);
|
|
68
|
+
case 9:
|
|
69
|
+
case "end":
|
|
70
|
+
return _context.stop();
|
|
71
|
+
}
|
|
72
|
+
}, _callee);
|
|
73
|
+
}))),
|
|
74
|
+
infoRun = _useRequest.run,
|
|
75
|
+
infoLoading = _useRequest.loading,
|
|
76
|
+
infoErr = _useRequest.error,
|
|
77
|
+
infoData = _useRequest.data;
|
|
78
|
+
React.useEffect(function () {
|
|
79
|
+
return function () {
|
|
80
|
+
hForm.removeDispatchListener();
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
return /*#__PURE__*/React.createElement(index$1.default, {
|
|
84
|
+
loading: infoLoading,
|
|
85
|
+
error: infoErr,
|
|
86
|
+
data: infoData,
|
|
87
|
+
reload: infoRun
|
|
88
|
+
}, /*#__PURE__*/React.createElement(index$2.FormContext.Provider, {
|
|
89
|
+
value: {
|
|
90
|
+
loading: loading,
|
|
91
|
+
form: hForm,
|
|
92
|
+
valueType: valueType
|
|
93
|
+
}
|
|
94
|
+
}, /*#__PURE__*/React.createElement(antd.Form, _extends({
|
|
95
|
+
form: hForm,
|
|
96
|
+
onFinish: run
|
|
97
|
+
}, props), _mapInstanceProperty(newConfigData).call(newConfigData, function (itemData, index) {
|
|
98
|
+
var itemLabelWidth = itemData.labelWidth;
|
|
99
|
+
return /*#__PURE__*/React.createElement(index$3.default, _extends({}, itemData, {
|
|
100
|
+
key: index,
|
|
101
|
+
labelWidth: itemLabelWidth || labelWidth
|
|
102
|
+
}));
|
|
103
|
+
}), /*#__PURE__*/React.createElement(InitSet.default, null))));
|
|
104
|
+
});
|
|
105
105
|
|
|
106
|
-
exports.default =
|
|
106
|
+
exports.default = HForm;
|
|
107
107
|
// powered by h
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -1,133 +1,98 @@
|
|
|
1
1
|
import type { FormInstance, FormItemProps, FormProps } from "antd";
|
|
2
2
|
import type { HCheckboxProps } from "@/components/CheckboxGroup/modal";
|
|
3
3
|
import type React from "react";
|
|
4
|
-
import type {
|
|
5
|
-
HButtonProps,
|
|
6
|
-
HInputProps,
|
|
7
|
-
HSelectInputProps,
|
|
8
|
-
} from "@/components/Input/modal";
|
|
4
|
+
import type { HButtonProps, HInputProps, HSelectInputProps } from "@/components/Input/modal";
|
|
9
5
|
import type { HRadioGroupProps } from "@/components/RadioGroup";
|
|
10
6
|
import type { HSelectProps } from "@/components/Select/modal";
|
|
11
7
|
import type { ButtonProps } from "antd/es";
|
|
12
8
|
import type { HSwitchProps } from "@/components/Switch";
|
|
13
|
-
import type {
|
|
14
|
-
HDatePickerProps,
|
|
15
|
-
HRangePickerProps,
|
|
16
|
-
HTimePickerProps,
|
|
17
|
-
} from "@/components/TDPicker/modal";
|
|
9
|
+
import type { HDatePickerProps, HRangePickerProps, HTimePickerProps } from "@/components/TDPicker/modal";
|
|
18
10
|
import type { TextAreaProps } from "antd/es/input";
|
|
19
11
|
import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
20
12
|
import type { SelectProps } from "antd";
|
|
21
13
|
import type { RangePickerProps } from "antd/es/date-picker";
|
|
22
|
-
import type {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ValueSwitchMapModal,
|
|
26
|
-
DateRangePickerValueMapModal,
|
|
27
|
-
} from "../modal";
|
|
28
|
-
type RenderFun = (
|
|
29
|
-
props: HItemProps,
|
|
30
|
-
node: React.ReactNode,
|
|
31
|
-
form: FormInstance
|
|
32
|
-
) => void;
|
|
33
|
-
type ItemPropsType =
|
|
34
|
-
| HCheckboxProps
|
|
35
|
-
| HInputProps
|
|
36
|
-
| HSelectInputProps
|
|
37
|
-
| HButtonProps
|
|
38
|
-
| HRadioGroupProps
|
|
39
|
-
| HSelectProps
|
|
40
|
-
| ButtonProps
|
|
41
|
-
| HSwitchProps
|
|
42
|
-
| HDatePickerProps
|
|
43
|
-
| HRangePickerProps
|
|
44
|
-
| HTimePickerProps
|
|
45
|
-
| TextAreaProps
|
|
46
|
-
| IUpLoadProps;
|
|
14
|
+
import type { PromiseFnResult, ValueCheckMapModal, ValueSwitchMapModal, DateRangePickerValueMapModal } from "../modal";
|
|
15
|
+
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => void;
|
|
16
|
+
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps;
|
|
47
17
|
export interface HoverModal {
|
|
48
|
-
|
|
49
|
-
|
|
18
|
+
text?: string;
|
|
19
|
+
icon?: React.ReactNode;
|
|
50
20
|
}
|
|
51
21
|
type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
52
22
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
23
|
+
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
53
24
|
export interface HItemProps extends Omit<FormItemProps, "name"> {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
25
|
+
type?: string;
|
|
26
|
+
itemProps?: ItemPropsType;
|
|
27
|
+
render?: RenderFun;
|
|
28
|
+
helper?: HelperModal | string;
|
|
29
|
+
hover?: string | HoverModal;
|
|
30
|
+
labelWidth?: number;
|
|
31
|
+
hide?: boolean | HideModal;
|
|
32
|
+
placeholder?: string | string[];
|
|
33
|
+
name?: string;
|
|
63
34
|
}
|
|
64
35
|
export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
36
|
+
configData: HItemProps[];
|
|
37
|
+
labelWidth?: number;
|
|
38
|
+
request?: PromiseFnResult<T, R>;
|
|
39
|
+
infoRequest?: () => Promise<T>;
|
|
40
|
+
valueType?: string;
|
|
41
|
+
form?: HFormInstance;
|
|
71
42
|
}
|
|
72
43
|
export interface HFormItemProps extends HItemProps {
|
|
73
|
-
|
|
44
|
+
required?: boolean;
|
|
74
45
|
}
|
|
75
46
|
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
76
|
-
|
|
47
|
+
render: (form: HFormInstance) => React.ReactNode;
|
|
77
48
|
}
|
|
78
49
|
export type argsFn = (...args: any[]) => void;
|
|
79
50
|
export interface FormContextProps {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
51
|
+
loading?: boolean;
|
|
52
|
+
form: HFormInstance;
|
|
53
|
+
valueType?: string;
|
|
83
54
|
}
|
|
84
55
|
interface ConfigUploadProps {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
exFiles?: string[];
|
|
57
|
+
maxSize?: number;
|
|
58
|
+
request?: PromiseFnResult;
|
|
88
59
|
}
|
|
89
60
|
export interface IFormConfigContextProps {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
62
|
+
valueCheckMap?: ValueCheckMapModal;
|
|
63
|
+
valueSwitchMap?: ValueSwitchMapModal;
|
|
64
|
+
valueRangePickerValueMap?: DateRangePickerValueMapModal;
|
|
65
|
+
dateRanges?: RangePickerProps["ranges"];
|
|
66
|
+
uploadProps?: ConfigUploadProps;
|
|
96
67
|
}
|
|
97
68
|
interface ActionModal {
|
|
98
|
-
|
|
99
|
-
|
|
69
|
+
key: string;
|
|
70
|
+
name?: string;
|
|
100
71
|
}
|
|
101
72
|
export interface HFormInstance extends FormInstance {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
110
|
-
addDispatchListener: (action: ActionModal, fn: argsFn) => void;
|
|
111
|
-
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
73
|
+
addFormat: (name: string, formats?: FormatItemModal) => void;
|
|
74
|
+
initValues: VoidFunction;
|
|
75
|
+
formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
|
|
76
|
+
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
77
|
+
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
78
|
+
addDispatchListener: AddDispatchListenerFn;
|
|
79
|
+
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
112
80
|
}
|
|
113
81
|
export interface ConnectConfigModal {
|
|
114
|
-
|
|
82
|
+
format?: Record<string, addFormatItemModal>;
|
|
115
83
|
}
|
|
116
84
|
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
117
85
|
export interface FormatItemModal {
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
inputValue: ValueFormat;
|
|
87
|
+
outputValue: ValueFormat;
|
|
120
88
|
}
|
|
121
|
-
type addValueFormat = (
|
|
122
|
-
item: HFormItemProps,
|
|
123
|
-
value: Record<string, any>
|
|
124
|
-
) => Record<string, any>;
|
|
89
|
+
type addValueFormat = (item: HFormItemProps, value: Record<string, any>) => Record<string, any>;
|
|
125
90
|
export interface addFormatItemModal {
|
|
126
|
-
|
|
127
|
-
|
|
91
|
+
inputValue: addValueFormat;
|
|
92
|
+
outputValue: addValueFormat;
|
|
128
93
|
}
|
|
129
94
|
export interface ConnectResultProps {
|
|
130
|
-
|
|
131
|
-
|
|
95
|
+
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
96
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
132
97
|
}
|
|
133
98
|
export {};
|