@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
|
@@ -2,11 +2,18 @@ import type { HFormProps } from "@/components/Form/modal";
|
|
|
2
2
|
import type { HFormInstance } from "@/components/Form/modal";
|
|
3
3
|
export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
4
4
|
type ParamsModal = Omit<HFormProps, "configData">;
|
|
5
|
-
export declare const useSub: ({
|
|
5
|
+
export declare const useSub: ({
|
|
6
|
+
request,
|
|
7
|
+
onFinish,
|
|
8
|
+
form,
|
|
9
|
+
}: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<
|
|
10
|
+
void,
|
|
11
|
+
[value: any]
|
|
12
|
+
>;
|
|
6
13
|
export declare const useInit: ({ infoRequest, initialValues }: ParamsModal) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
infoRun: () => Promise<any>;
|
|
15
|
+
infoLoading: boolean;
|
|
16
|
+
infoErr: Error | undefined;
|
|
17
|
+
infoData: any;
|
|
11
18
|
};
|
|
12
19
|
export {};
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var _asyncToGenerator = require(
|
|
4
|
-
var _regeneratorRuntime = require(
|
|
5
|
-
var ahooks = require(
|
|
6
|
-
var useHForm = require(
|
|
3
|
+
var _asyncToGenerator = require("@babel/runtime-corejs3/helpers/asyncToGenerator");
|
|
4
|
+
var _regeneratorRuntime = require("@babel/runtime-corejs3/regenerator");
|
|
5
|
+
var ahooks = require("ahooks");
|
|
6
|
+
var useHForm = require("./useHForm.js");
|
|
7
7
|
|
|
8
8
|
var useCurrentForm = function useCurrentForm(form) {
|
|
9
9
|
var selfForm = useHForm.default();
|
|
@@ -13,55 +13,71 @@ var useSub = function useSub(_ref) {
|
|
|
13
13
|
var request = _ref.request,
|
|
14
14
|
onFinish = _ref.onFinish,
|
|
15
15
|
form = _ref.form;
|
|
16
|
-
return ahooks.useRequest(
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
return ahooks.useRequest(
|
|
17
|
+
/*#__PURE__*/ (function () {
|
|
18
|
+
var _ref2 = _asyncToGenerator(
|
|
19
|
+
/*#__PURE__*/ _regeneratorRuntime.mark(function _callee(value) {
|
|
20
|
+
var subVal;
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1)
|
|
23
|
+
switch ((_context.prev = _context.next)) {
|
|
24
|
+
case 0:
|
|
25
|
+
subVal =
|
|
26
|
+
form === null || form === void 0
|
|
27
|
+
? void 0
|
|
28
|
+
: form.outputValues(value);
|
|
29
|
+
if (!request) {
|
|
30
|
+
_context.next = 4;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
_context.next = 4;
|
|
34
|
+
return request(subVal);
|
|
35
|
+
case 4:
|
|
36
|
+
onFinish === null || onFinish === void 0
|
|
37
|
+
? void 0
|
|
38
|
+
: onFinish(subVal);
|
|
39
|
+
case 5:
|
|
40
|
+
case "end":
|
|
41
|
+
return _context.stop();
|
|
42
|
+
}
|
|
43
|
+
}, _callee);
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
return function (_x) {
|
|
47
|
+
return _ref2.apply(this, arguments);
|
|
48
|
+
};
|
|
49
|
+
})(),
|
|
50
|
+
{
|
|
51
|
+
manual: true,
|
|
52
|
+
}
|
|
53
|
+
);
|
|
43
54
|
};
|
|
44
55
|
var useInit = function useInit(_ref3) {
|
|
45
56
|
var infoRequest = _ref3.infoRequest,
|
|
46
57
|
_ref3$initialValues = _ref3.initialValues,
|
|
47
58
|
initialValues = _ref3$initialValues === void 0 ? {} : _ref3$initialValues;
|
|
48
|
-
var _useRequest = ahooks.useRequest(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
_context2.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
var _useRequest = ahooks.useRequest(
|
|
60
|
+
/*#__PURE__*/ _asyncToGenerator(
|
|
61
|
+
/*#__PURE__*/ _regeneratorRuntime.mark(function _callee2() {
|
|
62
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
63
|
+
while (1)
|
|
64
|
+
switch ((_context2.prev = _context2.next)) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (!infoRequest) {
|
|
67
|
+
_context2.next = 2;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context2.abrupt("return", infoRequest());
|
|
71
|
+
case 2:
|
|
72
|
+
return _context2.abrupt("return", initialValues);
|
|
73
|
+
case 3:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context2.stop();
|
|
76
|
+
}
|
|
77
|
+
}, _callee2);
|
|
78
|
+
})
|
|
79
|
+
)
|
|
80
|
+
),
|
|
65
81
|
infoRun = _useRequest.run,
|
|
66
82
|
infoLoading = _useRequest.loading,
|
|
67
83
|
infoErr = _useRequest.error,
|
|
@@ -70,7 +86,7 @@ var useInit = function useInit(_ref3) {
|
|
|
70
86
|
infoRun: infoRun,
|
|
71
87
|
infoLoading: infoLoading,
|
|
72
88
|
infoErr: infoErr,
|
|
73
|
-
infoData: infoData
|
|
89
|
+
infoData: infoData,
|
|
74
90
|
};
|
|
75
91
|
};
|
|
76
92
|
|
|
@@ -1,114 +1,252 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
|
|
5
|
-
var _Object$getOwnPropertySymbols = require(
|
|
6
|
-
var _filterInstanceProperty = require(
|
|
7
|
-
var _Object$getOwnPropertyDescriptor = require(
|
|
8
|
-
var _Object$getOwnPropertyDescriptors = require(
|
|
9
|
-
var _Object$defineProperties = require(
|
|
10
|
-
var _Object$defineProperty = require(
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js/object/get-own-property-symbols");
|
|
6
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/filter");
|
|
7
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptors");
|
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js/object/define-properties");
|
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
11
|
+
var _toConsumableArray = require("@babel/runtime-corejs3/helpers/toConsumableArray");
|
|
12
|
+
var _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty");
|
|
13
|
+
var _slicedToArray = require("@babel/runtime-corejs3/helpers/slicedToArray");
|
|
14
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js/object/keys");
|
|
15
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/for-each");
|
|
16
|
+
var _Reflect$deleteProperty = require("@babel/runtime-corejs3/core-js/reflect/delete-property");
|
|
17
|
+
var _concatInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/concat");
|
|
18
|
+
var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/map");
|
|
19
|
+
var _Promise = require("@babel/runtime-corejs3/core-js/promise");
|
|
20
|
+
var React = require("react");
|
|
21
|
+
var antd = require("antd");
|
|
19
22
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) {
|
|
21
|
-
|
|
22
|
-
|
|
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 _context5, _context6;
|
|
38
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
39
|
+
i % 2
|
|
40
|
+
? _forEachInstanceProperty(
|
|
41
|
+
(_context5 = ownKeys(Object(source), !0))
|
|
42
|
+
).call(_context5, function (key) {
|
|
43
|
+
_defineProperty(target, key, source[key]);
|
|
44
|
+
})
|
|
45
|
+
: _Object$getOwnPropertyDescriptors
|
|
46
|
+
? _Object$defineProperties(
|
|
47
|
+
target,
|
|
48
|
+
_Object$getOwnPropertyDescriptors(source)
|
|
49
|
+
)
|
|
50
|
+
: _forEachInstanceProperty((_context6 = ownKeys(Object(source)))).call(
|
|
51
|
+
_context6,
|
|
52
|
+
function (key) {
|
|
53
|
+
_Object$defineProperty(
|
|
54
|
+
target,
|
|
55
|
+
key,
|
|
56
|
+
_Object$getOwnPropertyDescriptor(source, key)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return target;
|
|
62
|
+
}
|
|
63
|
+
var useHForm = function () {
|
|
23
64
|
var _Form$useForm = antd.Form.useForm(),
|
|
24
65
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
25
66
|
form = _Form$useForm2[0];
|
|
26
67
|
return React.useMemo(function () {
|
|
27
68
|
var formatSourceData = {};
|
|
28
69
|
var dispatchSourceData = {};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var inputValue = format.inputValue,
|
|
35
|
-
outputValue = format.outputValue;
|
|
36
|
-
formatSourceData[name] = {
|
|
37
|
-
inputValue: inputValue,
|
|
38
|
-
outputValue: outputValue
|
|
70
|
+
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
71
|
+
if (!name) {
|
|
72
|
+
return {
|
|
73
|
+
keysFn: {},
|
|
74
|
+
defaultFn: [fn],
|
|
39
75
|
};
|
|
40
|
-
},
|
|
41
|
-
formatValues: function formatValues() {
|
|
42
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
43
|
-
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
44
|
-
var valKeys = _Object$keys(value).length;
|
|
45
|
-
if (!valKeys) {
|
|
46
|
-
return {};
|
|
47
|
-
}
|
|
48
|
-
var newValue = _objectSpread({}, value);
|
|
49
|
-
var keys = _Object$keys(formatSourceData);
|
|
50
|
-
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
51
|
-
var _formatSourceData$key;
|
|
52
|
-
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
53
|
-
if (!format) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var resultValue = format(value);
|
|
57
|
-
_Reflect$deleteProperty(newValue, key);
|
|
58
|
-
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
59
|
-
});
|
|
60
|
-
return newValue;
|
|
61
|
-
},
|
|
62
|
-
dispatch: function dispatch(key) {
|
|
63
|
-
var items = dispatchSourceData[key];
|
|
64
|
-
if (!items) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
_forEachInstanceProperty(items).call(items, function (fn) {
|
|
68
|
-
fn();
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
addDispatchListener: function addDispatchListener(key, fn) {
|
|
72
|
-
var items = dispatchSourceData[key];
|
|
73
|
-
if (!items) {
|
|
74
|
-
dispatchSourceData[key] = [fn];
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
items.push(fn);
|
|
78
|
-
dispatchSourceData[key] = items;
|
|
79
|
-
},
|
|
80
|
-
removeDispatchListener: function removeDispatchListener(key) {
|
|
81
|
-
if (!key) {
|
|
82
|
-
dispatchSourceData = {};
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
86
|
-
},
|
|
87
|
-
initValues: function initValues() {
|
|
88
|
-
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
89
|
-
var newValue = this.formatValues(value);
|
|
90
|
-
form.setFieldsValue(newValue);
|
|
91
|
-
},
|
|
92
|
-
outputValues: function outputValues(value) {
|
|
93
|
-
return this.formatValues(value, "outputValue");
|
|
94
76
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
77
|
+
return {
|
|
78
|
+
keysFn: _defineProperty({}, name, fn),
|
|
79
|
+
defaultFn: [],
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
return _objectSpread(
|
|
83
|
+
_objectSpread(
|
|
84
|
+
{
|
|
85
|
+
addFormat: function addFormat(name, format) {
|
|
86
|
+
if (!format) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
var inputValue = format.inputValue,
|
|
90
|
+
outputValue = format.outputValue;
|
|
91
|
+
formatSourceData[name] = {
|
|
92
|
+
inputValue: inputValue,
|
|
93
|
+
outputValue: outputValue,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
formatValues: function formatValues() {
|
|
97
|
+
var value =
|
|
98
|
+
arguments.length > 0 && arguments[0] !== undefined
|
|
99
|
+
? arguments[0]
|
|
100
|
+
: {};
|
|
101
|
+
var formatKey =
|
|
102
|
+
arguments.length > 1 && arguments[1] !== undefined
|
|
103
|
+
? arguments[1]
|
|
104
|
+
: "inputValue";
|
|
105
|
+
var valKeys = _Object$keys(value).length;
|
|
106
|
+
if (!valKeys) {
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
var newValue = _objectSpread({}, value);
|
|
110
|
+
var keys = _Object$keys(formatSourceData);
|
|
111
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
112
|
+
var _formatSourceData$key;
|
|
113
|
+
var format =
|
|
114
|
+
(_formatSourceData$key = formatSourceData[key]) === null ||
|
|
115
|
+
_formatSourceData$key === void 0
|
|
116
|
+
? void 0
|
|
117
|
+
: _formatSourceData$key[formatKey];
|
|
118
|
+
if (!format) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var resultValue = format(value);
|
|
122
|
+
_Reflect$deleteProperty(newValue, key);
|
|
123
|
+
newValue = _objectSpread(
|
|
124
|
+
_objectSpread({}, newValue),
|
|
125
|
+
resultValue
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
return newValue;
|
|
129
|
+
},
|
|
130
|
+
dispatch: function dispatch(action) {
|
|
131
|
+
var _context2, _context3, _context4;
|
|
132
|
+
for (
|
|
133
|
+
var _len = arguments.length,
|
|
134
|
+
args = new Array(_len > 1 ? _len - 1 : 0),
|
|
135
|
+
_key = 1;
|
|
136
|
+
_key < _len;
|
|
137
|
+
_key++
|
|
138
|
+
) {
|
|
139
|
+
args[_key - 1] = arguments[_key];
|
|
140
|
+
}
|
|
141
|
+
var key = action.key,
|
|
142
|
+
name = action.name;
|
|
143
|
+
var items = dispatchSourceData[key];
|
|
144
|
+
if (!items) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
var keysFn = items.keysFn,
|
|
148
|
+
defaultFn = items.defaultFn;
|
|
149
|
+
if (name) {
|
|
150
|
+
var _keysFn$name, _context;
|
|
151
|
+
return (_keysFn$name = keysFn[name]) === null ||
|
|
152
|
+
_keysFn$name === void 0
|
|
153
|
+
? void 0
|
|
154
|
+
: _keysFn$name.call.apply(
|
|
155
|
+
_keysFn$name,
|
|
156
|
+
_concatInstanceProperty((_context = [keysFn])).call(
|
|
157
|
+
_context,
|
|
158
|
+
args
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
var fnArrays = _mapInstanceProperty(
|
|
163
|
+
(_context2 = _Object$keys(keysFn))
|
|
164
|
+
).call(_context2, function (itemKey) {
|
|
165
|
+
return keysFn[itemKey];
|
|
166
|
+
});
|
|
167
|
+
_forEachInstanceProperty(
|
|
168
|
+
(_context3 = _concatInstanceProperty((_context4 = [])).call(
|
|
169
|
+
_context4,
|
|
170
|
+
_toConsumableArray(fnArrays),
|
|
171
|
+
_toConsumableArray(defaultFn)
|
|
172
|
+
))
|
|
173
|
+
).call(_context3, function (fn) {
|
|
174
|
+
fn.apply(void 0, args);
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
178
|
+
var key = action.key,
|
|
179
|
+
name = action.name;
|
|
180
|
+
var items = dispatchSourceData[key];
|
|
181
|
+
if (!items) {
|
|
182
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
var keysFn = items.keysFn,
|
|
186
|
+
defaultFn = items.defaultFn;
|
|
187
|
+
if (name) {
|
|
188
|
+
keysFn[name] = fn;
|
|
189
|
+
} else {
|
|
190
|
+
defaultFn.push(fn);
|
|
191
|
+
}
|
|
192
|
+
dispatchSourceData[key] = {
|
|
193
|
+
keysFn: keysFn,
|
|
194
|
+
defaultFn: defaultFn,
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
198
|
+
if (!action) {
|
|
199
|
+
dispatchSourceData = {};
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
var key = action.key,
|
|
203
|
+
name = action.name;
|
|
204
|
+
var items = dispatchSourceData[key];
|
|
205
|
+
if (!items) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (name) {
|
|
209
|
+
var keysFn = items.keysFn;
|
|
210
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
211
|
+
items.keysFn = keysFn;
|
|
212
|
+
dispatchSourceData[key] = items;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
216
|
+
},
|
|
217
|
+
initValues: function initValues() {
|
|
218
|
+
var value =
|
|
219
|
+
arguments.length > 0 && arguments[0] !== undefined
|
|
220
|
+
? arguments[0]
|
|
221
|
+
: {};
|
|
222
|
+
var newValue = this.formatValues(value);
|
|
223
|
+
form.setFieldsValue(newValue);
|
|
224
|
+
},
|
|
225
|
+
outputValues: function outputValues(value) {
|
|
226
|
+
return this.formatValues(value, "outputValue");
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
form
|
|
230
|
+
),
|
|
231
|
+
{},
|
|
232
|
+
{
|
|
233
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
234
|
+
var newValue = this.formatValues(values);
|
|
235
|
+
form.setFieldsValue(newValue);
|
|
236
|
+
},
|
|
237
|
+
validateFields: function validateFields(nameList) {
|
|
238
|
+
var _this = this;
|
|
239
|
+
return new _Promise(function (resolve) {
|
|
240
|
+
form.validateFields(nameList).then(function (value) {
|
|
241
|
+
var result = _this.formatValues(value, "outputValue");
|
|
242
|
+
return resolve(result);
|
|
243
|
+
});
|
|
106
244
|
});
|
|
107
|
-
}
|
|
245
|
+
},
|
|
108
246
|
}
|
|
109
|
-
|
|
247
|
+
);
|
|
110
248
|
}, []);
|
|
111
|
-
}
|
|
249
|
+
};
|
|
112
250
|
|
|
113
251
|
exports.default = useHForm;
|
|
114
252
|
// powered by h
|
|
@@ -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;
|