@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
|
@@ -2,18 +2,5 @@ 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: ({
|
|
6
|
-
request,
|
|
7
|
-
onFinish,
|
|
8
|
-
form,
|
|
9
|
-
}: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<
|
|
10
|
-
void,
|
|
11
|
-
[value: any]
|
|
12
|
-
>;
|
|
13
|
-
export declare const useInit: ({ infoRequest, initialValues }: ParamsModal) => {
|
|
14
|
-
infoRun: () => Promise<any>;
|
|
15
|
-
infoLoading: boolean;
|
|
16
|
-
infoErr: Error | undefined;
|
|
17
|
-
infoData: any;
|
|
18
|
-
};
|
|
5
|
+
export declare const useSub: ({ request, onFinish, form }: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
19
6
|
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,84 +13,35 @@ 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
|
-
/*#__PURE__*/
|
|
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
|
-
|
|
43
|
-
}, _callee);
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
return function (_x) {
|
|
47
|
-
return _ref2.apply(this, arguments);
|
|
48
|
-
};
|
|
49
|
-
})(),
|
|
50
|
-
{
|
|
51
|
-
manual: true,
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
var useInit = function useInit(_ref3) {
|
|
56
|
-
var infoRequest = _ref3.infoRequest,
|
|
57
|
-
_ref3$initialValues = _ref3.initialValues,
|
|
58
|
-
initialValues = _ref3$initialValues === void 0 ? {} : _ref3$initialValues;
|
|
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
|
-
),
|
|
81
|
-
infoRun = _useRequest.run,
|
|
82
|
-
infoLoading = _useRequest.loading,
|
|
83
|
-
infoErr = _useRequest.error,
|
|
84
|
-
infoData = _useRequest.data;
|
|
85
|
-
return {
|
|
86
|
-
infoRun: infoRun,
|
|
87
|
-
infoLoading: infoLoading,
|
|
88
|
-
infoErr: infoErr,
|
|
89
|
-
infoData: infoData,
|
|
90
|
-
};
|
|
16
|
+
return ahooks.useRequest( /*#__PURE__*/function () {
|
|
17
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(value) {
|
|
18
|
+
var subVal;
|
|
19
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
23
|
+
if (!request) {
|
|
24
|
+
_context.next = 4;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
_context.next = 4;
|
|
28
|
+
return request(subVal);
|
|
29
|
+
case 4:
|
|
30
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish(subVal);
|
|
31
|
+
case 5:
|
|
32
|
+
case "end":
|
|
33
|
+
return _context.stop();
|
|
34
|
+
}
|
|
35
|
+
}, _callee);
|
|
36
|
+
}));
|
|
37
|
+
return function (_x) {
|
|
38
|
+
return _ref2.apply(this, arguments);
|
|
39
|
+
};
|
|
40
|
+
}(), {
|
|
41
|
+
manual: true
|
|
42
|
+
});
|
|
91
43
|
};
|
|
92
44
|
|
|
93
45
|
exports.useCurrentForm = useCurrentForm;
|
|
94
|
-
exports.useInit = useInit;
|
|
95
46
|
exports.useSub = useSub;
|
|
96
47
|
// powered by h
|
|
@@ -1,252 +1,171 @@
|
|
|
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 _toConsumableArray = require(
|
|
12
|
-
var _defineProperty = require(
|
|
13
|
-
var _slicedToArray = require(
|
|
14
|
-
var _Object$keys = require(
|
|
15
|
-
var _forEachInstanceProperty = require(
|
|
16
|
-
var _Reflect$deleteProperty = require(
|
|
17
|
-
var _concatInstanceProperty = require(
|
|
18
|
-
var _mapInstanceProperty = require(
|
|
19
|
-
var _Promise = require(
|
|
20
|
-
var React = require(
|
|
21
|
-
var antd = require(
|
|
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');
|
|
22
22
|
|
|
23
|
-
function ownKeys(object, enumerableOnly) {
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
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 _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
var useHForm = (function () {
|
|
64
26
|
var _Form$useForm = antd.Form.useForm(),
|
|
65
27
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
66
28
|
form = _Form$useForm2[0];
|
|
67
29
|
return React.useMemo(function () {
|
|
68
30
|
var formatSourceData = {};
|
|
69
31
|
var dispatchSourceData = {};
|
|
32
|
+
var cacheValues = {};
|
|
70
33
|
var norAddItemDispatch = function norAddItemDispatch(name, fn) {
|
|
71
34
|
if (!name) {
|
|
72
35
|
return {
|
|
73
36
|
keysFn: {},
|
|
74
|
-
defaultFn: [fn]
|
|
37
|
+
defaultFn: [fn]
|
|
75
38
|
};
|
|
76
39
|
}
|
|
77
40
|
return {
|
|
78
41
|
keysFn: _defineProperty({}, name, fn),
|
|
79
|
-
defaultFn: []
|
|
42
|
+
defaultFn: []
|
|
80
43
|
};
|
|
81
44
|
};
|
|
82
|
-
return _objectSpread(
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
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);
|
|
45
|
+
return _objectSpread(_objectSpread({
|
|
46
|
+
initValues: function initValues() {
|
|
47
|
+
if (cacheValues) {
|
|
48
|
+
var newValue = this.formatValues(cacheValues);
|
|
235
49
|
form.setFieldsValue(newValue);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
addFormat: function addFormat(name, format) {
|
|
53
|
+
if (!format) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
var inputValue = format.inputValue,
|
|
57
|
+
outputValue = format.outputValue;
|
|
58
|
+
formatSourceData[name] = {
|
|
59
|
+
inputValue: inputValue,
|
|
60
|
+
outputValue: outputValue
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
formatValues: function formatValues() {
|
|
64
|
+
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
+
var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
|
|
66
|
+
var valKeys = _Object$keys(value).length;
|
|
67
|
+
if (!valKeys) {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
var newValue = _objectSpread({}, value);
|
|
71
|
+
var keys = _Object$keys(formatSourceData);
|
|
72
|
+
_forEachInstanceProperty(keys).call(keys, function (key) {
|
|
73
|
+
var _formatSourceData$key;
|
|
74
|
+
var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
|
|
75
|
+
if (!format) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
var resultValue = format(value);
|
|
79
|
+
_Reflect$deleteProperty(newValue, key);
|
|
80
|
+
newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
|
|
81
|
+
});
|
|
82
|
+
return newValue;
|
|
83
|
+
},
|
|
84
|
+
dispatch: function dispatch(action) {
|
|
85
|
+
var _context2, _context3, _context4;
|
|
86
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
87
|
+
args[_key - 1] = arguments[_key];
|
|
88
|
+
}
|
|
89
|
+
var key = action.key,
|
|
90
|
+
name = action.name;
|
|
91
|
+
var items = dispatchSourceData[key];
|
|
92
|
+
if (!items) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var keysFn = items.keysFn,
|
|
96
|
+
defaultFn = items.defaultFn;
|
|
97
|
+
if (name) {
|
|
98
|
+
var _keysFn$name, _context;
|
|
99
|
+
return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, _concatInstanceProperty(_context = [keysFn]).call(_context, args));
|
|
100
|
+
}
|
|
101
|
+
var fnArrays = _mapInstanceProperty(_context2 = _Object$keys(keysFn)).call(_context2, function (itemKey) {
|
|
102
|
+
return keysFn[itemKey];
|
|
103
|
+
});
|
|
104
|
+
_forEachInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(fnArrays), _toConsumableArray(defaultFn))).call(_context3, function (fn) {
|
|
105
|
+
fn.apply(void 0, args);
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
addDispatchListener: function addDispatchListener(action, fn) {
|
|
109
|
+
var key = action.key,
|
|
110
|
+
name = action.name;
|
|
111
|
+
var items = dispatchSourceData[key];
|
|
112
|
+
if (!items) {
|
|
113
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
var keysFn = items.keysFn,
|
|
117
|
+
defaultFn = items.defaultFn;
|
|
118
|
+
if (name) {
|
|
119
|
+
keysFn[name] = fn;
|
|
120
|
+
} else {
|
|
121
|
+
defaultFn.push(fn);
|
|
122
|
+
}
|
|
123
|
+
dispatchSourceData[key] = {
|
|
124
|
+
keysFn: keysFn,
|
|
125
|
+
defaultFn: defaultFn
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
removeDispatchListener: function removeDispatchListener(action) {
|
|
129
|
+
if (!action) {
|
|
130
|
+
dispatchSourceData = {};
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
var key = action.key,
|
|
134
|
+
name = action.name;
|
|
135
|
+
var items = dispatchSourceData[key];
|
|
136
|
+
if (!items) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (name) {
|
|
140
|
+
var keysFn = items.keysFn;
|
|
141
|
+
_Reflect$deleteProperty(keysFn, name);
|
|
142
|
+
items.keysFn = keysFn;
|
|
143
|
+
dispatchSourceData[key] = items;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
_Reflect$deleteProperty(dispatchSourceData, key);
|
|
147
|
+
},
|
|
148
|
+
outputValues: function outputValues(value) {
|
|
149
|
+
return this.formatValues(value, "outputValue");
|
|
150
|
+
}
|
|
151
|
+
}, form), {}, {
|
|
152
|
+
setFieldsValue: function setFieldsValue(values) {
|
|
153
|
+
var newValue = this.formatValues(values);
|
|
154
|
+
cacheValues = values;
|
|
155
|
+
form.setFieldsValue(newValue);
|
|
156
|
+
},
|
|
157
|
+
validateFields: function validateFields(nameList) {
|
|
158
|
+
var _this = this;
|
|
159
|
+
return new _Promise(function (resolve) {
|
|
160
|
+
form.validateFields(nameList).then(function (value) {
|
|
161
|
+
var result = _this.formatValues(value, "outputValue");
|
|
162
|
+
return resolve(result);
|
|
244
163
|
});
|
|
245
|
-
}
|
|
164
|
+
});
|
|
246
165
|
}
|
|
247
|
-
);
|
|
166
|
+
});
|
|
248
167
|
}, []);
|
|
249
|
-
};
|
|
168
|
+
});
|
|
250
169
|
|
|
251
170
|
exports.default = useHForm;
|
|
252
171
|
// powered by h
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { FormItemWithRender, HFormProps } from "@/components/Form/modal";
|
|
2
2
|
type InitConfigModal = Required<Pick<HFormProps, "configData" | "form">>;
|
|
3
|
-
declare const _default: ({
|
|
4
|
-
configData,
|
|
5
|
-
form,
|
|
6
|
-
}: InitConfigModal) => FormItemWithRender[];
|
|
3
|
+
declare const _default: ({ configData, form }: InitConfigModal) => FormItemWithRender[];
|
|
7
4
|
export default _default;
|