@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.
Files changed (229) hide show
  1. package/es/CheckboxGroup/CheckBox/index.js +24 -16
  2. package/es/CheckboxGroup/hooks.d.ts +9 -3
  3. package/es/CheckboxGroup/hooks.js +115 -64
  4. package/es/CheckboxGroup/index.d.ts +6 -1
  5. package/es/CheckboxGroup/index.js +117 -56
  6. package/es/CheckboxGroup/modal.d.ts +9 -8
  7. package/es/Form/Context/FormConfigProvider.js +64 -19
  8. package/es/Form/Context/index.d.ts +4 -1
  9. package/es/Form/Context/index.js +3 -3
  10. package/es/Form/FormItem/BasicItem.js +80 -42
  11. package/es/Form/FormItem/Helper.d.ts +1 -1
  12. package/es/Form/FormItem/Helper.js +17 -9
  13. package/es/Form/FormItem/RegularFormItem.js +11 -8
  14. package/es/Form/FormItem/UpFormItem.d.ts +6 -1
  15. package/es/Form/FormItem/UpFormItem.js +27 -17
  16. package/es/Form/FormItem/hooks.d.ts +21 -4
  17. package/es/Form/FormItem/hooks.js +12 -9
  18. package/es/Form/FormItem/index.js +5 -5
  19. package/es/Form/HFormConnect.d.ts +9 -1
  20. package/es/Form/HFormConnect.js +94 -26
  21. package/es/Form/InitSet.d.ts +1 -1
  22. package/es/Form/InitSet.js +5 -5
  23. package/es/Form/Label.d.ts +4 -4
  24. package/es/Form/Label.js +36 -19
  25. package/es/Form/config.d.ts +100 -22
  26. package/es/Form/config.js +19 -19
  27. package/es/Form/hooks/index.d.ts +12 -5
  28. package/es/Form/hooks/index.js +65 -49
  29. package/es/Form/hooks/useHForm.js +233 -95
  30. package/es/Form/hooks/useInitConfigData.d.ts +4 -1
  31. package/es/Form/hooks/useInitConfigData.js +143 -61
  32. package/es/Form/index.d.ts +11 -1
  33. package/es/Form/index.js +71 -40
  34. package/es/Form/modal.d.ts +92 -51
  35. package/es/Input/ButtonInput.js +73 -51
  36. package/es/Input/InputNumber.js +21 -12
  37. package/es/Input/SelectInput.d.ts +16 -4
  38. package/es/Input/SelectInput.js +113 -56
  39. package/es/Input/defaultConfig.d.ts +3 -3
  40. package/es/Input/defaultConfig.js +2 -2
  41. package/es/Input/index.js +7 -7
  42. package/es/Input/modal.d.ts +15 -11
  43. package/es/PageHandler/ErrorComponent.js +47 -25
  44. package/es/PageHandler/LoadingComponent.js +17 -13
  45. package/es/PageHandler/index.js +7 -7
  46. package/es/PageHandler/modal.d.ts +4 -4
  47. package/es/RadioGroup/index.d.ts +12 -5
  48. package/es/RadioGroup/index.js +46 -33
  49. package/es/Select/components/AllSelect.d.ts +1 -1
  50. package/es/Select/components/AllSelect.js +40 -18
  51. package/es/Select/components/CheckBoxOption.d.ts +6 -3
  52. package/es/Select/components/CheckBoxOption.js +12 -7
  53. package/es/Select/components/DropdownComponent.d.ts +4 -4
  54. package/es/Select/components/DropdownComponent.js +30 -17
  55. package/es/Select/components/NoFindItem.d.ts +1 -1
  56. package/es/Select/components/NoFindItem.js +11 -7
  57. package/es/Select/components/NotFoundContent.d.ts +2 -2
  58. package/es/Select/components/NotFoundContent.js +49 -27
  59. package/es/Select/defaultConfig.d.ts +1 -1
  60. package/es/Select/defaultConfig.js +20 -16
  61. package/es/Select/hooks/changeHooks.d.ts +2 -2
  62. package/es/Select/hooks/changeHooks.js +147 -71
  63. package/es/Select/hooks/norHooks.d.ts +27 -9
  64. package/es/Select/hooks/norHooks.js +51 -39
  65. package/es/Select/index.d.ts +22 -1
  66. package/es/Select/index.js +124 -65
  67. package/es/Select/modal.d.ts +15 -15
  68. package/es/Select/utils.js +60 -15
  69. package/es/Submit/index.d.ts +9 -3
  70. package/es/Submit/index.js +18 -13
  71. package/es/Switch/index.d.ts +4 -4
  72. package/es/Switch/index.js +46 -20
  73. package/es/TDPicker/RangePicker.d.ts +8 -3
  74. package/es/TDPicker/RangePicker.js +138 -62
  75. package/es/TDPicker/TimePicker.d.ts +6 -1
  76. package/es/TDPicker/TimePicker.js +19 -13
  77. package/es/TDPicker/hooks.d.ts +42 -22
  78. package/es/TDPicker/hooks.js +106 -72
  79. package/es/TDPicker/index.d.ts +7 -1
  80. package/es/TDPicker/index.js +20 -14
  81. package/es/TDPicker/modal.d.ts +21 -16
  82. package/es/Upload/Btn.d.ts +5 -1
  83. package/es/Upload/Btn.js +35 -19
  84. package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
  85. package/es/Upload/MediaTypeEle/TypeEle.js +31 -23
  86. package/es/Upload/MediaTypeEle/index.d.ts +5 -1
  87. package/es/Upload/MediaTypeEle/index.js +21 -18
  88. package/es/Upload/Preview/index.d.ts +5 -1
  89. package/es/Upload/Preview/index.js +17 -13
  90. package/es/Upload/UrlUpload/index.d.ts +7 -1
  91. package/es/Upload/UrlUpload/index.js +72 -51
  92. package/es/Upload/enums.d.ts +3 -3
  93. package/es/Upload/enums.js +3 -3
  94. package/es/Upload/hooks/change.d.ts +8 -1
  95. package/es/Upload/hooks/change.js +115 -58
  96. package/es/Upload/hooks/customRequest.d.ts +5 -1
  97. package/es/Upload/hooks/customRequest.js +63 -46
  98. package/es/Upload/hooks/propsMaker.d.ts +5 -1
  99. package/es/Upload/hooks/propsMaker.js +52 -13
  100. package/es/Upload/index.d.ts +3 -1
  101. package/es/Upload/index.js +131 -61
  102. package/es/Upload/modal.d.ts +17 -15
  103. package/es/Upload/util.d.ts +8 -2
  104. package/es/Upload/util.js +15 -7
  105. package/es/config.js +34 -31
  106. package/es/hooks/index.d.ts +14 -7
  107. package/es/hooks/index.js +124 -49
  108. package/es/index.d.ts +98 -16
  109. package/es/index.js +22 -5
  110. package/es/modal.d.ts +6 -6
  111. package/lib/CheckboxGroup/CheckBox/index.js +26 -18
  112. package/lib/CheckboxGroup/hooks.d.ts +9 -3
  113. package/lib/CheckboxGroup/hooks.js +116 -65
  114. package/lib/CheckboxGroup/index.d.ts +6 -1
  115. package/lib/CheckboxGroup/index.js +119 -58
  116. package/lib/CheckboxGroup/modal.d.ts +9 -8
  117. package/lib/Form/Context/FormConfigProvider.js +66 -21
  118. package/lib/Form/Context/index.d.ts +4 -1
  119. package/lib/Form/Context/index.js +4 -4
  120. package/lib/Form/FormItem/BasicItem.js +82 -44
  121. package/lib/Form/FormItem/Helper.d.ts +1 -1
  122. package/lib/Form/FormItem/Helper.js +19 -11
  123. package/lib/Form/FormItem/RegularFormItem.js +13 -10
  124. package/lib/Form/FormItem/UpFormItem.d.ts +6 -1
  125. package/lib/Form/FormItem/UpFormItem.js +29 -19
  126. package/lib/Form/FormItem/hooks.d.ts +21 -4
  127. package/lib/Form/FormItem/hooks.js +13 -10
  128. package/lib/Form/FormItem/index.js +7 -7
  129. package/lib/Form/HFormConnect.d.ts +9 -1
  130. package/lib/Form/HFormConnect.js +96 -28
  131. package/lib/Form/InitSet.d.ts +1 -1
  132. package/lib/Form/InitSet.js +7 -7
  133. package/lib/Form/Label.d.ts +4 -4
  134. package/lib/Form/Label.js +41 -21
  135. package/lib/Form/config.d.ts +100 -22
  136. package/lib/Form/config.js +21 -21
  137. package/lib/Form/hooks/index.d.ts +12 -5
  138. package/lib/Form/hooks/index.js +66 -50
  139. package/lib/Form/hooks/useHForm.js +235 -97
  140. package/lib/Form/hooks/useInitConfigData.d.ts +4 -1
  141. package/lib/Form/hooks/useInitConfigData.js +144 -63
  142. package/lib/Form/index.d.ts +11 -1
  143. package/lib/Form/index.js +73 -42
  144. package/lib/Form/modal.d.ts +92 -51
  145. package/lib/Input/ButtonInput.js +75 -53
  146. package/lib/Input/InputNumber.js +23 -14
  147. package/lib/Input/SelectInput.d.ts +16 -4
  148. package/lib/Input/SelectInput.js +125 -60
  149. package/lib/Input/defaultConfig.d.ts +3 -3
  150. package/lib/Input/defaultConfig.js +3 -3
  151. package/lib/Input/index.js +9 -9
  152. package/lib/Input/modal.d.ts +15 -11
  153. package/lib/PageHandler/ErrorComponent.js +49 -27
  154. package/lib/PageHandler/LoadingComponent.js +19 -15
  155. package/lib/PageHandler/index.js +9 -9
  156. package/lib/PageHandler/modal.d.ts +4 -4
  157. package/lib/RadioGroup/index.d.ts +12 -5
  158. package/lib/RadioGroup/index.js +48 -35
  159. package/lib/Select/components/AllSelect.d.ts +1 -1
  160. package/lib/Select/components/AllSelect.js +42 -20
  161. package/lib/Select/components/CheckBoxOption.d.ts +6 -3
  162. package/lib/Select/components/CheckBoxOption.js +14 -9
  163. package/lib/Select/components/DropdownComponent.d.ts +4 -4
  164. package/lib/Select/components/DropdownComponent.js +32 -19
  165. package/lib/Select/components/NoFindItem.d.ts +1 -1
  166. package/lib/Select/components/NoFindItem.js +13 -9
  167. package/lib/Select/components/NotFoundContent.d.ts +2 -2
  168. package/lib/Select/components/NotFoundContent.js +51 -29
  169. package/lib/Select/defaultConfig.d.ts +1 -1
  170. package/lib/Select/defaultConfig.js +21 -17
  171. package/lib/Select/hooks/changeHooks.d.ts +2 -2
  172. package/lib/Select/hooks/changeHooks.js +148 -72
  173. package/lib/Select/hooks/norHooks.d.ts +27 -9
  174. package/lib/Select/hooks/norHooks.js +52 -40
  175. package/lib/Select/index.d.ts +22 -1
  176. package/lib/Select/index.js +128 -67
  177. package/lib/Select/modal.d.ts +15 -15
  178. package/lib/Select/utils.js +61 -16
  179. package/lib/Submit/index.d.ts +9 -3
  180. package/lib/Submit/index.js +20 -15
  181. package/lib/Switch/index.d.ts +4 -4
  182. package/lib/Switch/index.js +48 -22
  183. package/lib/TDPicker/RangePicker.d.ts +8 -3
  184. package/lib/TDPicker/RangePicker.js +136 -64
  185. package/lib/TDPicker/TimePicker.d.ts +6 -1
  186. package/lib/TDPicker/TimePicker.js +21 -15
  187. package/lib/TDPicker/hooks.d.ts +42 -22
  188. package/lib/TDPicker/hooks.js +98 -72
  189. package/lib/TDPicker/index.d.ts +7 -1
  190. package/lib/TDPicker/index.js +22 -16
  191. package/lib/TDPicker/modal.d.ts +21 -16
  192. package/lib/Upload/Btn.d.ts +5 -1
  193. package/lib/Upload/Btn.js +37 -21
  194. package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
  195. package/lib/Upload/MediaTypeEle/TypeEle.js +33 -25
  196. package/lib/Upload/MediaTypeEle/index.d.ts +5 -1
  197. package/lib/Upload/MediaTypeEle/index.js +23 -20
  198. package/lib/Upload/Preview/index.d.ts +5 -1
  199. package/lib/Upload/Preview/index.js +19 -15
  200. package/lib/Upload/UrlUpload/index.d.ts +7 -1
  201. package/lib/Upload/UrlUpload/index.js +74 -53
  202. package/lib/Upload/enums.d.ts +3 -3
  203. package/lib/Upload/enums.js +4 -4
  204. package/lib/Upload/hooks/change.d.ts +8 -1
  205. package/lib/Upload/hooks/change.js +116 -59
  206. package/lib/Upload/hooks/customRequest.d.ts +5 -1
  207. package/lib/Upload/hooks/customRequest.js +64 -47
  208. package/lib/Upload/hooks/propsMaker.d.ts +5 -1
  209. package/lib/Upload/hooks/propsMaker.js +55 -15
  210. package/lib/Upload/index.d.ts +3 -1
  211. package/lib/Upload/index.js +133 -63
  212. package/lib/Upload/modal.d.ts +17 -15
  213. package/lib/Upload/util.d.ts +8 -2
  214. package/lib/Upload/util.js +16 -8
  215. package/lib/config.js +35 -32
  216. package/lib/hooks/index.d.ts +14 -7
  217. package/lib/hooks/index.js +125 -50
  218. package/lib/index.d.ts +98 -16
  219. package/lib/index.js +5 -5
  220. package/lib/modal.d.ts +6 -6
  221. package/package.json +2 -2
  222. package/src/components/CheckboxGroup/index.tsx +2 -2
  223. package/src/components/Form/FormItem/Helper.tsx +3 -4
  224. package/src/components/Form/HFormConnect.tsx +6 -2
  225. package/src/components/Form/hooks/useHForm.ts +59 -10
  226. package/src/components/Form/modal.ts +12 -8
  227. package/src/components/TDPicker/RangePicker.tsx +7 -5
  228. package/src/components/TDPicker/modal.ts +1 -0
  229. 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: ({ request, onFinish, form }: ParamsModal) => import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
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
- infoRun: () => Promise<any>;
8
- infoLoading: boolean;
9
- infoErr: Error | undefined;
10
- infoData: any;
14
+ infoRun: () => Promise<any>;
15
+ infoLoading: boolean;
16
+ infoErr: Error | undefined;
17
+ infoData: any;
11
18
  };
12
19
  export {};
@@ -1,9 +1,9 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
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');
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( /*#__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
- });
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( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
49
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
50
- while (1) switch (_context2.prev = _context2.next) {
51
- case 0:
52
- if (!infoRequest) {
53
- _context2.next = 2;
54
- break;
55
- }
56
- return _context2.abrupt("return", infoRequest());
57
- case 2:
58
- return _context2.abrupt("return", initialValues);
59
- case 3:
60
- case "end":
61
- return _context2.stop();
62
- }
63
- }, _callee2);
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
- 'use strict';
1
+ "use strict";
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
4
 
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 _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
- var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
13
- var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
14
- var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
15
- var _Reflect$deleteProperty = require('@babel/runtime-corejs3/core-js/reflect/delete-property');
16
- var _Promise = require('@babel/runtime-corejs3/core-js/promise');
17
- var React = require('react');
18
- var antd = require('antd');
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) { 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; }
21
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
22
- var useHForm = (function () {
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
- return _objectSpread(_objectSpread({
30
- addFormat: function addFormat(name, format) {
31
- if (!format) {
32
- return;
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
- }, form), {}, {
96
- setFieldsValue: function setFieldsValue(values) {
97
- var newValue = this.formatValues(values);
98
- form.setFieldsValue(newValue);
99
- },
100
- validateFields: function validateFields(nameList) {
101
- var _this = this;
102
- return new _Promise(function (resolve) {
103
- form.validateFields(nameList).then(function (value) {
104
- var result = _this.formatValues(value, "outputValue");
105
- return resolve(result);
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: ({ configData, form }: InitConfigModal) => FormItemWithRender[];
3
+ declare const _default: ({
4
+ configData,
5
+ form,
6
+ }: InitConfigModal) => FormItemWithRender[];
4
7
  export default _default;