@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,27 +1,65 @@
|
|
|
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
|
-
|
|
23
|
+
function ownKeys(object, enumerableOnly) {
|
|
24
|
+
var keys = _Object$keys(object);
|
|
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
|
+
}
|
|
25
63
|
var mathRequired = function mathRequired(configItem, form) {
|
|
26
64
|
var required = configItem.required,
|
|
27
65
|
placeholder = configItem.placeholder,
|
|
@@ -30,28 +68,41 @@ var mathRequired = function mathRequired(configItem, form) {
|
|
|
30
68
|
type = _configItem$type === void 0 ? "input" : _configItem$type;
|
|
31
69
|
var resultRequired = false;
|
|
32
70
|
var dom = config.default[type];
|
|
33
|
-
var resultRules =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
71
|
+
var resultRules =
|
|
72
|
+
rules === null || rules === void 0
|
|
73
|
+
? void 0
|
|
74
|
+
: _mapInstanceProperty(rules).call(rules, function (item) {
|
|
75
|
+
var eachItem = item;
|
|
76
|
+
if (typeof item === "function") {
|
|
77
|
+
eachItem = item(form);
|
|
78
|
+
}
|
|
79
|
+
var _eachItem = eachItem,
|
|
80
|
+
itemRequired = _eachItem.required,
|
|
81
|
+
message = _eachItem.message;
|
|
82
|
+
if (itemRequired) {
|
|
83
|
+
resultRequired = itemRequired;
|
|
84
|
+
}
|
|
85
|
+
if (itemRequired && !message) {
|
|
86
|
+
return _objectSpread(
|
|
87
|
+
_objectSpread({}, eachItem),
|
|
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
|
+
});
|
|
52
103
|
return {
|
|
53
104
|
required: typeof required === "boolean" ? required : resultRequired,
|
|
54
|
-
rules: resultRules
|
|
105
|
+
rules: resultRules,
|
|
55
106
|
};
|
|
56
107
|
};
|
|
57
108
|
var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
@@ -67,7 +118,11 @@ var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
|
|
|
67
118
|
if (dom !== null && dom !== void 0 && dom.placeholder) {
|
|
68
119
|
return dom.placeholder(props);
|
|
69
120
|
}
|
|
70
|
-
if (
|
|
121
|
+
if (
|
|
122
|
+
_indexOfInstanceProperty(
|
|
123
|
+
(_context = config.placeholderConfig.inputType)
|
|
124
|
+
).call(_context, type) !== -1
|
|
125
|
+
) {
|
|
71
126
|
return "\u8BF7\u8F93\u5165".concat(label);
|
|
72
127
|
}
|
|
73
128
|
return "\u8BF7\u9009\u62E9".concat(label);
|
|
@@ -81,24 +136,43 @@ var defaultRenderMaker = function defaultRenderMaker(props) {
|
|
|
81
136
|
componentProps = _objectWithoutProperties(props, _excluded);
|
|
82
137
|
var dom = config.default[type];
|
|
83
138
|
return function (form) {
|
|
84
|
-
var Component = !!(dom !== null && dom !== void 0 && dom.Component)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
139
|
+
var Component = !!(dom !== null && dom !== void 0 && dom.Component)
|
|
140
|
+
? dom.Component
|
|
141
|
+
: dom;
|
|
142
|
+
var node =
|
|
143
|
+
Component &&
|
|
144
|
+
/*#__PURE__*/ React.createElement(
|
|
145
|
+
Component,
|
|
146
|
+
_extends({}, componentProps, itemProps, {
|
|
147
|
+
form: form,
|
|
148
|
+
})
|
|
149
|
+
);
|
|
88
150
|
if (render) {
|
|
89
151
|
return render(props, node, form);
|
|
90
152
|
}
|
|
91
153
|
return node;
|
|
92
154
|
};
|
|
93
155
|
};
|
|
94
|
-
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
|
|
156
|
+
var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
|
|
157
|
+
props
|
|
158
|
+
) {
|
|
95
159
|
var placeholder = matchDefaultPlaceholder(props);
|
|
96
|
-
return _objectSpread(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
160
|
+
return _objectSpread(
|
|
161
|
+
_objectSpread({}, props),
|
|
162
|
+
{},
|
|
163
|
+
{
|
|
164
|
+
placeholder: placeholder,
|
|
165
|
+
render: defaultRenderMaker(
|
|
166
|
+
_objectSpread(
|
|
167
|
+
_objectSpread({}, props),
|
|
168
|
+
{},
|
|
169
|
+
{
|
|
170
|
+
placeholder: placeholder,
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
),
|
|
174
|
+
}
|
|
175
|
+
);
|
|
102
176
|
};
|
|
103
177
|
var itemControl = function itemControl(item, form) {
|
|
104
178
|
var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
|
|
@@ -107,21 +181,28 @@ var itemControl = function itemControl(item, form) {
|
|
|
107
181
|
var _mathRequired = mathRequired(defaultProps, form),
|
|
108
182
|
rules = _mathRequired.rules,
|
|
109
183
|
required = _mathRequired.required;
|
|
110
|
-
return _objectSpread(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
184
|
+
return _objectSpread(
|
|
185
|
+
_objectSpread({}, defaultProps),
|
|
186
|
+
{},
|
|
187
|
+
{
|
|
188
|
+
required: required,
|
|
189
|
+
rules: rules,
|
|
190
|
+
render: render,
|
|
191
|
+
}
|
|
192
|
+
);
|
|
115
193
|
};
|
|
116
|
-
var useInitConfigData =
|
|
194
|
+
var useInitConfigData = function (_ref) {
|
|
117
195
|
var configData = _ref.configData,
|
|
118
196
|
form = _ref.form;
|
|
119
|
-
return React.useMemo(
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
197
|
+
return React.useMemo(
|
|
198
|
+
function () {
|
|
199
|
+
return _mapInstanceProperty(configData).call(configData, function (item) {
|
|
200
|
+
return itemControl(item, form);
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
[configData]
|
|
204
|
+
);
|
|
205
|
+
};
|
|
125
206
|
|
|
126
207
|
exports.default = useInitConfigData;
|
|
127
208
|
// powered by h
|
package/lib/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;
|
package/lib/Form/index.js
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
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 _objectWithoutProperties = require(
|
|
8
|
-
var _mapInstanceProperty = require(
|
|
9
|
-
var antd = require(
|
|
10
|
-
var index$4 = require(
|
|
11
|
-
var index$1 = require(
|
|
12
|
-
var index$3 = require(
|
|
13
|
-
var index$2 = require(
|
|
14
|
-
var useInitConfigData = require(
|
|
15
|
-
var InitSet = require(
|
|
5
|
+
var React = require("react");
|
|
6
|
+
var _extends = require("@babel/runtime-corejs3/helpers/extends");
|
|
7
|
+
var _objectWithoutProperties = require("@babel/runtime-corejs3/helpers/objectWithoutProperties");
|
|
8
|
+
var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/map");
|
|
9
|
+
var antd = require("antd");
|
|
10
|
+
var index$4 = require("./FormItem/index.js");
|
|
11
|
+
var index$1 = require("./hooks/index.js");
|
|
12
|
+
var index$3 = require("./Context/index.js");
|
|
13
|
+
var index$2 = require("../PageHandler/index.js");
|
|
14
|
+
var useInitConfigData = require("./hooks/useInitConfigData.js");
|
|
15
|
+
var InitSet = require("./InitSet.js");
|
|
16
16
|
|
|
17
|
-
var _excluded = [
|
|
18
|
-
|
|
17
|
+
var _excluded = [
|
|
18
|
+
"configData",
|
|
19
|
+
"labelWidth",
|
|
20
|
+
"form",
|
|
21
|
+
"request",
|
|
22
|
+
"onFinish",
|
|
23
|
+
"infoRequest",
|
|
24
|
+
"valueType",
|
|
25
|
+
"initialValues",
|
|
26
|
+
];
|
|
27
|
+
var index = function (_ref) {
|
|
19
28
|
var configData = _ref.configData,
|
|
20
29
|
labelWidth = _ref.labelWidth,
|
|
21
30
|
form = _ref.form,
|
|
@@ -29,48 +38,70 @@ var index = (function (_ref) {
|
|
|
29
38
|
var hForm = index$1.useCurrentForm(form);
|
|
30
39
|
var newConfigData = useInitConfigData.default({
|
|
31
40
|
configData: configData,
|
|
32
|
-
form: hForm
|
|
41
|
+
form: hForm,
|
|
33
42
|
});
|
|
34
43
|
var _useSub = index$1.useSub({
|
|
35
44
|
request: request,
|
|
36
45
|
onFinish: onFinish,
|
|
37
46
|
valueType: valueType,
|
|
38
|
-
form: hForm
|
|
47
|
+
form: hForm,
|
|
39
48
|
}),
|
|
40
49
|
run = _useSub.run,
|
|
41
50
|
loading = _useSub.loading;
|
|
42
51
|
var _useInit = index$1.useInit({
|
|
43
52
|
infoRequest: infoRequest,
|
|
44
|
-
initialValues: initialValues
|
|
53
|
+
initialValues: initialValues,
|
|
45
54
|
}),
|
|
46
55
|
infoRun = _useInit.infoRun,
|
|
47
56
|
infoLoading = _useInit.infoLoading,
|
|
48
57
|
infoErr = _useInit.infoErr,
|
|
49
58
|
infoData = _useInit.infoData;
|
|
50
|
-
return /*#__PURE__*/React.createElement(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
59
|
+
return /*#__PURE__*/ React.createElement(
|
|
60
|
+
index$2.default,
|
|
61
|
+
{
|
|
62
|
+
loading: infoLoading,
|
|
63
|
+
error: infoErr,
|
|
64
|
+
data: infoData,
|
|
65
|
+
reload: infoRun,
|
|
66
|
+
},
|
|
67
|
+
/*#__PURE__*/ React.createElement(
|
|
68
|
+
index$3.FormContext.Provider,
|
|
69
|
+
{
|
|
70
|
+
value: {
|
|
71
|
+
loading: loading,
|
|
72
|
+
form: hForm,
|
|
73
|
+
valueType: valueType,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
/*#__PURE__*/ React.createElement(
|
|
77
|
+
antd.Form,
|
|
78
|
+
_extends(
|
|
79
|
+
{
|
|
80
|
+
form: hForm,
|
|
81
|
+
onFinish: run,
|
|
82
|
+
},
|
|
83
|
+
props
|
|
84
|
+
),
|
|
85
|
+
_mapInstanceProperty(newConfigData).call(
|
|
86
|
+
newConfigData,
|
|
87
|
+
function (itemData, index) {
|
|
88
|
+
var itemLabelWidth = itemData.labelWidth;
|
|
89
|
+
return /*#__PURE__*/ React.createElement(
|
|
90
|
+
index$4.default,
|
|
91
|
+
_extends({}, itemData, {
|
|
92
|
+
key: index,
|
|
93
|
+
labelWidth: itemLabelWidth || labelWidth,
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
),
|
|
99
|
+
/*#__PURE__*/ React.createElement(InitSet.default, {
|
|
100
|
+
initValues: infoData,
|
|
101
|
+
})
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
};
|
|
74
105
|
|
|
75
106
|
exports.default = index;
|
|
76
107
|
// powered by h
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -1,92 +1,133 @@
|
|
|
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 {
|
|
4
|
+
import type {
|
|
5
|
+
HButtonProps,
|
|
6
|
+
HInputProps,
|
|
7
|
+
HSelectInputProps,
|
|
8
|
+
} from "@/components/Input/modal";
|
|
5
9
|
import type { HRadioGroupProps } from "@/components/RadioGroup";
|
|
6
10
|
import type { HSelectProps } from "@/components/Select/modal";
|
|
7
11
|
import type { ButtonProps } from "antd/es";
|
|
8
12
|
import type { HSwitchProps } from "@/components/Switch";
|
|
9
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
HDatePickerProps,
|
|
15
|
+
HRangePickerProps,
|
|
16
|
+
HTimePickerProps,
|
|
17
|
+
} from "@/components/TDPicker/modal";
|
|
10
18
|
import type { TextAreaProps } from "antd/es/input";
|
|
11
19
|
import type { IUpLoadProps } from "@/components/Upload/modal";
|
|
12
20
|
import type { SelectProps } from "antd";
|
|
13
21
|
import type { RangePickerProps } from "antd/es/date-picker";
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
import type {
|
|
23
|
+
PromiseFnResult,
|
|
24
|
+
ValueCheckMapModal,
|
|
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;
|
|
17
47
|
export interface HoverModal {
|
|
18
|
-
|
|
19
|
-
|
|
48
|
+
text?: string;
|
|
49
|
+
icon?: React.ReactNode;
|
|
20
50
|
}
|
|
21
51
|
type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
22
52
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
23
53
|
export interface HItemProps extends Omit<FormItemProps, "name"> {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
name: string;
|
|
54
|
+
type?: string;
|
|
55
|
+
itemProps?: ItemPropsType;
|
|
56
|
+
render?: RenderFun;
|
|
57
|
+
helper?: HelperModal | string;
|
|
58
|
+
hover?: string | HoverModal;
|
|
59
|
+
labelWidth?: number;
|
|
60
|
+
hide?: boolean | HideModal;
|
|
61
|
+
placeholder?: string | string[];
|
|
62
|
+
name?: string;
|
|
34
63
|
}
|
|
35
64
|
export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
65
|
+
configData: HItemProps[];
|
|
66
|
+
labelWidth?: number;
|
|
67
|
+
request?: PromiseFnResult<T, R>;
|
|
68
|
+
infoRequest?: () => Promise<T>;
|
|
69
|
+
valueType?: string;
|
|
70
|
+
form?: HFormInstance;
|
|
42
71
|
}
|
|
43
72
|
export interface HFormItemProps extends HItemProps {
|
|
44
|
-
|
|
73
|
+
required?: boolean;
|
|
45
74
|
}
|
|
46
75
|
export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
|
|
47
|
-
|
|
76
|
+
render: (form: HFormInstance) => React.ReactNode;
|
|
48
77
|
}
|
|
78
|
+
export type argsFn = (...args: any[]) => void;
|
|
49
79
|
export interface FormContextProps {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
loading?: boolean;
|
|
81
|
+
form: HFormInstance;
|
|
82
|
+
valueType?: string;
|
|
53
83
|
}
|
|
54
84
|
interface ConfigUploadProps {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
exFiles?: string[];
|
|
86
|
+
maxSize?: number;
|
|
87
|
+
request?: PromiseFnResult;
|
|
58
88
|
}
|
|
59
89
|
export interface IFormConfigContextProps {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
90
|
+
fieldNames?: SelectProps["fieldNames"];
|
|
91
|
+
valueCheckMap?: ValueCheckMapModal;
|
|
92
|
+
valueSwitchMap?: ValueSwitchMapModal;
|
|
93
|
+
valueRangePickerValueMap?: DateRangePickerValueMapModal;
|
|
94
|
+
dateRanges?: RangePickerProps["ranges"];
|
|
95
|
+
uploadProps?: ConfigUploadProps;
|
|
96
|
+
}
|
|
97
|
+
interface ActionModal {
|
|
98
|
+
key: string;
|
|
99
|
+
name?: string;
|
|
66
100
|
}
|
|
67
101
|
export interface HFormInstance extends FormInstance {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
addFormat: (name: string, formats?: FormatItemModal) => void;
|
|
103
|
+
initValues: (values?: Record<string, any>) => void;
|
|
104
|
+
formatValues: (
|
|
105
|
+
values?: Record<string, any>,
|
|
106
|
+
formatKey?: string
|
|
107
|
+
) => Record<string, any>;
|
|
108
|
+
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
109
|
+
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
110
|
+
addDispatchListener: (action: ActionModal, fn: argsFn) => void;
|
|
111
|
+
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
75
112
|
}
|
|
76
113
|
export interface ConnectConfigModal {
|
|
77
|
-
|
|
114
|
+
format?: Record<string, addFormatItemModal>;
|
|
78
115
|
}
|
|
79
116
|
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
80
117
|
export interface FormatItemModal {
|
|
81
|
-
|
|
82
|
-
|
|
118
|
+
inputValue: ValueFormat;
|
|
119
|
+
outputValue: ValueFormat;
|
|
83
120
|
}
|
|
84
|
-
type addValueFormat = (
|
|
121
|
+
type addValueFormat = (
|
|
122
|
+
item: HFormItemProps,
|
|
123
|
+
value: Record<string, any>
|
|
124
|
+
) => Record<string, any>;
|
|
85
125
|
export interface addFormatItemModal {
|
|
86
|
-
|
|
87
|
-
|
|
126
|
+
inputValue: addValueFormat;
|
|
127
|
+
outputValue: addValueFormat;
|
|
88
128
|
}
|
|
89
129
|
export interface ConnectResultProps {
|
|
90
|
-
|
|
130
|
+
addFormat?: (format: Record<string, addFormatItemModal>) => void;
|
|
131
|
+
addDispatchListener?: (key: string, fn: argsFn) => void;
|
|
91
132
|
}
|
|
92
133
|
export {};
|