@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.
Files changed (246) hide show
  1. package/es/CheckboxGroup/CheckBox/index.js +16 -24
  2. package/es/CheckboxGroup/hooks.d.ts +3 -9
  3. package/es/CheckboxGroup/hooks.js +64 -115
  4. package/es/CheckboxGroup/index.d.ts +1 -6
  5. package/es/CheckboxGroup/index.js +58 -117
  6. package/es/CheckboxGroup/modal.d.ts +8 -9
  7. package/es/Form/Context/FormConfigProvider.js +19 -64
  8. package/es/Form/Context/index.d.ts +1 -4
  9. package/es/Form/Context/index.js +3 -3
  10. package/es/Form/FormItem/BasicItem.js +42 -80
  11. package/es/Form/FormItem/Helper.d.ts +1 -1
  12. package/es/Form/FormItem/Helper.js +9 -17
  13. package/es/Form/FormItem/RegularFormItem.js +8 -11
  14. package/es/Form/FormItem/UpFormItem.d.ts +1 -6
  15. package/es/Form/FormItem/UpFormItem.js +17 -27
  16. package/es/Form/FormItem/hooks.d.ts +4 -21
  17. package/es/Form/FormItem/hooks.js +9 -12
  18. package/es/Form/FormItem/index.js +5 -5
  19. package/es/Form/HFormConnect.d.ts +1 -9
  20. package/es/Form/HFormConnect.js +30 -90
  21. package/es/Form/InitSet.d.ts +1 -4
  22. package/es/Form/InitSet.js +6 -7
  23. package/es/Form/Label.d.ts +4 -4
  24. package/es/Form/Label.js +19 -36
  25. package/es/Form/config.d.ts +22 -100
  26. package/es/Form/config.js +19 -19
  27. package/es/Form/hooks/index.d.ts +1 -14
  28. package/es/Form/hooks/index.js +32 -80
  29. package/es/Form/hooks/useHForm.js +143 -224
  30. package/es/Form/hooks/useInitConfigData.d.ts +1 -4
  31. package/es/Form/hooks/useInitConfigData.js +61 -143
  32. package/es/Form/index.d.ts +1 -11
  33. package/es/Form/index.js +79 -79
  34. package/es/Form/modal.d.ts +54 -89
  35. package/es/Input/ButtonInput.js +51 -73
  36. package/es/Input/InputNumber.js +12 -21
  37. package/es/Input/SelectInput.d.ts +4 -16
  38. package/es/Input/SelectInput.js +62 -116
  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 +13 -15
  43. package/es/ModalForm/hooks.d.ts +12 -0
  44. package/es/ModalForm/hooks.js +63 -0
  45. package/es/ModalForm/index.d.ts +4 -0
  46. package/es/ModalForm/index.js +72 -0
  47. package/es/ModalForm/modal.d.ts +20 -0
  48. package/es/PageHandler/ErrorComponent.js +25 -47
  49. package/es/PageHandler/LoadingComponent.js +13 -17
  50. package/es/PageHandler/index.js +7 -7
  51. package/es/PageHandler/modal.d.ts +4 -4
  52. package/es/RadioGroup/index.d.ts +5 -12
  53. package/es/RadioGroup/index.js +33 -46
  54. package/es/Select/components/AllSelect.d.ts +1 -1
  55. package/es/Select/components/AllSelect.js +18 -40
  56. package/es/Select/components/CheckBoxOption.d.ts +3 -6
  57. package/es/Select/components/CheckBoxOption.js +7 -12
  58. package/es/Select/components/DropdownComponent.d.ts +4 -4
  59. package/es/Select/components/DropdownComponent.js +17 -30
  60. package/es/Select/components/NoFindItem.d.ts +1 -1
  61. package/es/Select/components/NoFindItem.js +7 -11
  62. package/es/Select/components/NotFoundContent.d.ts +2 -2
  63. package/es/Select/components/NotFoundContent.js +27 -49
  64. package/es/Select/defaultConfig.d.ts +1 -1
  65. package/es/Select/defaultConfig.js +16 -20
  66. package/es/Select/hooks/changeHooks.d.ts +2 -2
  67. package/es/Select/hooks/changeHooks.js +71 -147
  68. package/es/Select/hooks/norHooks.d.ts +9 -27
  69. package/es/Select/hooks/norHooks.js +39 -51
  70. package/es/Select/index.d.ts +1 -22
  71. package/es/Select/index.js +65 -124
  72. package/es/Select/modal.d.ts +15 -15
  73. package/es/Select/utils.js +15 -60
  74. package/es/Submit/index.d.ts +3 -9
  75. package/es/Submit/index.js +13 -18
  76. package/es/Switch/index.d.ts +4 -4
  77. package/es/Switch/index.js +20 -46
  78. package/es/TDPicker/RangePicker.d.ts +3 -8
  79. package/es/TDPicker/RangePicker.js +67 -138
  80. package/es/TDPicker/TimePicker.d.ts +1 -6
  81. package/es/TDPicker/TimePicker.js +13 -19
  82. package/es/TDPicker/hooks.d.ts +22 -42
  83. package/es/TDPicker/hooks.js +72 -106
  84. package/es/TDPicker/index.d.ts +1 -7
  85. package/es/TDPicker/index.js +14 -20
  86. package/es/TDPicker/modal.d.ts +16 -21
  87. package/es/TextArea/index.d.ts +1 -0
  88. package/es/Upload/Btn.d.ts +1 -5
  89. package/es/Upload/Btn.js +19 -35
  90. package/es/Upload/MediaTypeEle/TypeEle.d.ts +5 -10
  91. package/es/Upload/MediaTypeEle/TypeEle.js +23 -31
  92. package/es/Upload/MediaTypeEle/index.d.ts +1 -5
  93. package/es/Upload/MediaTypeEle/index.js +18 -21
  94. package/es/Upload/Preview/index.d.ts +1 -5
  95. package/es/Upload/Preview/index.js +13 -17
  96. package/es/Upload/UrlUpload/index.d.ts +1 -7
  97. package/es/Upload/UrlUpload/index.js +51 -72
  98. package/es/Upload/enums.d.ts +3 -3
  99. package/es/Upload/enums.js +3 -3
  100. package/es/Upload/hooks/change.d.ts +1 -8
  101. package/es/Upload/hooks/change.js +58 -115
  102. package/es/Upload/hooks/customRequest.d.ts +1 -5
  103. package/es/Upload/hooks/customRequest.js +46 -63
  104. package/es/Upload/hooks/propsMaker.d.ts +1 -5
  105. package/es/Upload/hooks/propsMaker.js +13 -52
  106. package/es/Upload/index.d.ts +1 -3
  107. package/es/Upload/index.js +61 -131
  108. package/es/Upload/modal.d.ts +15 -17
  109. package/es/Upload/util.d.ts +2 -8
  110. package/es/Upload/util.js +7 -15
  111. package/es/config.js +31 -34
  112. package/es/hooks/index.d.ts +7 -14
  113. package/es/hooks/index.js +49 -124
  114. package/es/index.d.ts +18 -98
  115. package/es/index.js +8 -22
  116. package/es/modal.d.ts +6 -6
  117. package/lib/CheckboxGroup/CheckBox/index.js +18 -26
  118. package/lib/CheckboxGroup/hooks.d.ts +3 -9
  119. package/lib/CheckboxGroup/hooks.js +65 -116
  120. package/lib/CheckboxGroup/index.d.ts +1 -6
  121. package/lib/CheckboxGroup/index.js +60 -119
  122. package/lib/CheckboxGroup/modal.d.ts +8 -9
  123. package/lib/Form/Context/FormConfigProvider.js +21 -66
  124. package/lib/Form/Context/index.d.ts +1 -4
  125. package/lib/Form/Context/index.js +4 -4
  126. package/lib/Form/FormItem/BasicItem.js +44 -82
  127. package/lib/Form/FormItem/Helper.d.ts +1 -1
  128. package/lib/Form/FormItem/Helper.js +11 -19
  129. package/lib/Form/FormItem/RegularFormItem.js +10 -13
  130. package/lib/Form/FormItem/UpFormItem.d.ts +1 -6
  131. package/lib/Form/FormItem/UpFormItem.js +19 -29
  132. package/lib/Form/FormItem/hooks.d.ts +4 -21
  133. package/lib/Form/FormItem/hooks.js +10 -13
  134. package/lib/Form/FormItem/index.js +7 -7
  135. package/lib/Form/HFormConnect.d.ts +1 -9
  136. package/lib/Form/HFormConnect.js +32 -92
  137. package/lib/Form/InitSet.d.ts +1 -4
  138. package/lib/Form/InitSet.js +8 -9
  139. package/lib/Form/Label.d.ts +4 -4
  140. package/lib/Form/Label.js +21 -41
  141. package/lib/Form/config.d.ts +22 -100
  142. package/lib/Form/config.js +21 -21
  143. package/lib/Form/hooks/index.d.ts +1 -14
  144. package/lib/Form/hooks/index.js +32 -81
  145. package/lib/Form/hooks/useHForm.js +145 -226
  146. package/lib/Form/hooks/useInitConfigData.d.ts +1 -4
  147. package/lib/Form/hooks/useInitConfigData.js +63 -144
  148. package/lib/Form/index.d.ts +1 -11
  149. package/lib/Form/index.js +83 -83
  150. package/lib/Form/modal.d.ts +54 -89
  151. package/lib/Input/ButtonInput.js +53 -75
  152. package/lib/Input/InputNumber.js +14 -23
  153. package/lib/Input/SelectInput.d.ts +4 -16
  154. package/lib/Input/SelectInput.js +66 -128
  155. package/lib/Input/defaultConfig.d.ts +3 -3
  156. package/lib/Input/defaultConfig.js +3 -3
  157. package/lib/Input/index.js +9 -9
  158. package/lib/Input/modal.d.ts +13 -15
  159. package/lib/ModalForm/hooks.d.ts +12 -0
  160. package/lib/ModalForm/hooks.js +66 -0
  161. package/lib/ModalForm/index.d.ts +4 -0
  162. package/lib/ModalForm/index.js +75 -0
  163. package/lib/ModalForm/modal.d.ts +20 -0
  164. package/lib/PageHandler/ErrorComponent.js +27 -49
  165. package/lib/PageHandler/LoadingComponent.js +15 -19
  166. package/lib/PageHandler/index.js +9 -9
  167. package/lib/PageHandler/modal.d.ts +4 -4
  168. package/lib/RadioGroup/index.d.ts +5 -12
  169. package/lib/RadioGroup/index.js +35 -48
  170. package/lib/Select/components/AllSelect.d.ts +1 -1
  171. package/lib/Select/components/AllSelect.js +20 -42
  172. package/lib/Select/components/CheckBoxOption.d.ts +3 -6
  173. package/lib/Select/components/CheckBoxOption.js +9 -14
  174. package/lib/Select/components/DropdownComponent.d.ts +4 -4
  175. package/lib/Select/components/DropdownComponent.js +19 -32
  176. package/lib/Select/components/NoFindItem.d.ts +1 -1
  177. package/lib/Select/components/NoFindItem.js +9 -13
  178. package/lib/Select/components/NotFoundContent.d.ts +2 -2
  179. package/lib/Select/components/NotFoundContent.js +29 -51
  180. package/lib/Select/defaultConfig.d.ts +1 -1
  181. package/lib/Select/defaultConfig.js +17 -21
  182. package/lib/Select/hooks/changeHooks.d.ts +2 -2
  183. package/lib/Select/hooks/changeHooks.js +72 -148
  184. package/lib/Select/hooks/norHooks.d.ts +9 -27
  185. package/lib/Select/hooks/norHooks.js +40 -52
  186. package/lib/Select/index.d.ts +1 -22
  187. package/lib/Select/index.js +67 -128
  188. package/lib/Select/modal.d.ts +15 -15
  189. package/lib/Select/utils.js +16 -61
  190. package/lib/Submit/index.d.ts +3 -9
  191. package/lib/Submit/index.js +15 -20
  192. package/lib/Switch/index.d.ts +4 -4
  193. package/lib/Switch/index.js +22 -48
  194. package/lib/TDPicker/RangePicker.d.ts +3 -8
  195. package/lib/TDPicker/RangePicker.js +69 -136
  196. package/lib/TDPicker/TimePicker.d.ts +1 -6
  197. package/lib/TDPicker/TimePicker.js +15 -21
  198. package/lib/TDPicker/hooks.d.ts +22 -42
  199. package/lib/TDPicker/hooks.js +72 -98
  200. package/lib/TDPicker/index.d.ts +1 -7
  201. package/lib/TDPicker/index.js +16 -22
  202. package/lib/TDPicker/modal.d.ts +16 -21
  203. package/lib/TextArea/index.d.ts +1 -0
  204. package/lib/Upload/Btn.d.ts +1 -5
  205. package/lib/Upload/Btn.js +21 -37
  206. package/lib/Upload/MediaTypeEle/TypeEle.d.ts +5 -10
  207. package/lib/Upload/MediaTypeEle/TypeEle.js +25 -33
  208. package/lib/Upload/MediaTypeEle/index.d.ts +1 -5
  209. package/lib/Upload/MediaTypeEle/index.js +20 -23
  210. package/lib/Upload/Preview/index.d.ts +1 -5
  211. package/lib/Upload/Preview/index.js +15 -19
  212. package/lib/Upload/UrlUpload/index.d.ts +1 -7
  213. package/lib/Upload/UrlUpload/index.js +53 -74
  214. package/lib/Upload/enums.d.ts +3 -3
  215. package/lib/Upload/enums.js +4 -4
  216. package/lib/Upload/hooks/change.d.ts +1 -8
  217. package/lib/Upload/hooks/change.js +59 -116
  218. package/lib/Upload/hooks/customRequest.d.ts +1 -5
  219. package/lib/Upload/hooks/customRequest.js +47 -64
  220. package/lib/Upload/hooks/propsMaker.d.ts +1 -5
  221. package/lib/Upload/hooks/propsMaker.js +15 -55
  222. package/lib/Upload/index.d.ts +1 -3
  223. package/lib/Upload/index.js +63 -133
  224. package/lib/Upload/modal.d.ts +15 -17
  225. package/lib/Upload/util.d.ts +2 -8
  226. package/lib/Upload/util.js +8 -16
  227. package/lib/config.js +32 -35
  228. package/lib/hooks/index.d.ts +7 -14
  229. package/lib/hooks/index.js +50 -125
  230. package/lib/index.d.ts +18 -98
  231. package/lib/index.js +10 -5
  232. package/lib/modal.d.ts +6 -6
  233. package/package.json +1 -1
  234. package/src/components/Form/InitSet.tsx +3 -5
  235. package/src/components/Form/hooks/index.ts +0 -20
  236. package/src/components/Form/hooks/useHForm.ts +8 -4
  237. package/src/components/Form/index.tsx +25 -7
  238. package/src/components/Form/modal.ts +4 -2
  239. package/src/components/Input/SelectInput.tsx +3 -2
  240. package/src/components/Input/modal.ts +2 -0
  241. package/src/components/ModalForm/hooks.ts +45 -0
  242. package/src/components/ModalForm/index.tsx +69 -0
  243. package/src/components/ModalForm/modal.ts +22 -0
  244. package/src/components/index.tsx +4 -0
  245. package/src/pages/ModalForm/index.tsx +127 -0
  246. package/src/routes.tsx +6 -1
@@ -1,249 +1,168 @@
1
1
  // welcome to hoo hoo hoo
2
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js/object/get-own-property-symbols";
3
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
4
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
5
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptors";
6
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js/object/define-properties";
7
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
8
- import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
9
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
10
- import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
11
- import _Object$keys from "@babel/runtime-corejs3/core-js/object/keys";
12
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
13
- import _Reflect$deleteProperty from "@babel/runtime-corejs3/core-js/reflect/delete-property";
14
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
15
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
16
- import _Promise from "@babel/runtime-corejs3/core-js/promise";
17
- import { useMemo } from "react";
18
- import { Form } from "antd";
2
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
3
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
4
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
5
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
6
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
7
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
8
+ import _toConsumableArray from '@babel/runtime-corejs3/helpers/toConsumableArray';
9
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
10
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
11
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
12
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
13
+ import _Reflect$deleteProperty from '@babel/runtime-corejs3/core-js/reflect/delete-property';
14
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js/instance/concat';
15
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
16
+ import _Promise from '@babel/runtime-corejs3/core-js/promise';
17
+ import { useMemo } from 'react';
18
+ import { Form } from 'antd';
19
19
 
20
- function ownKeys(object, enumerableOnly) {
21
- var keys = _Object$keys(object);
22
- if (_Object$getOwnPropertySymbols) {
23
- var symbols = _Object$getOwnPropertySymbols(object);
24
- enumerableOnly &&
25
- (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
26
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
27
- })),
28
- keys.push.apply(keys, symbols);
29
- }
30
- return keys;
31
- }
32
- function _objectSpread(target) {
33
- for (var i = 1; i < arguments.length; i++) {
34
- var _context5, _context6;
35
- var source = null != arguments[i] ? arguments[i] : {};
36
- i % 2
37
- ? _forEachInstanceProperty(
38
- (_context5 = ownKeys(Object(source), !0))
39
- ).call(_context5, function (key) {
40
- _defineProperty(target, key, source[key]);
41
- })
42
- : _Object$getOwnPropertyDescriptors
43
- ? _Object$defineProperties(
44
- target,
45
- _Object$getOwnPropertyDescriptors(source)
46
- )
47
- : _forEachInstanceProperty((_context6 = ownKeys(Object(source)))).call(
48
- _context6,
49
- function (key) {
50
- _Object$defineProperty(
51
- target,
52
- key,
53
- _Object$getOwnPropertyDescriptor(source, key)
54
- );
55
- }
56
- );
57
- }
58
- return target;
59
- }
60
- var useHForm = function () {
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 _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; }
22
+ var useHForm = (function () {
61
23
  var _Form$useForm = Form.useForm(),
62
24
  _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
63
25
  form = _Form$useForm2[0];
64
26
  return useMemo(function () {
65
27
  var formatSourceData = {};
66
28
  var dispatchSourceData = {};
29
+ var cacheValues = {};
67
30
  var norAddItemDispatch = function norAddItemDispatch(name, fn) {
68
31
  if (!name) {
69
32
  return {
70
33
  keysFn: {},
71
- defaultFn: [fn],
34
+ defaultFn: [fn]
72
35
  };
73
36
  }
74
37
  return {
75
38
  keysFn: _defineProperty({}, name, fn),
76
- defaultFn: [],
39
+ defaultFn: []
77
40
  };
78
41
  };
79
- return _objectSpread(
80
- _objectSpread(
81
- {
82
- addFormat: function addFormat(name, format) {
83
- if (!format) {
84
- return;
85
- }
86
- var inputValue = format.inputValue,
87
- outputValue = format.outputValue;
88
- formatSourceData[name] = {
89
- inputValue: inputValue,
90
- outputValue: outputValue,
91
- };
92
- },
93
- formatValues: function formatValues() {
94
- var value =
95
- arguments.length > 0 && arguments[0] !== undefined
96
- ? arguments[0]
97
- : {};
98
- var formatKey =
99
- arguments.length > 1 && arguments[1] !== undefined
100
- ? arguments[1]
101
- : "inputValue";
102
- var valKeys = _Object$keys(value).length;
103
- if (!valKeys) {
104
- return {};
105
- }
106
- var newValue = _objectSpread({}, value);
107
- var keys = _Object$keys(formatSourceData);
108
- _forEachInstanceProperty(keys).call(keys, function (key) {
109
- var _formatSourceData$key;
110
- var format =
111
- (_formatSourceData$key = formatSourceData[key]) === null ||
112
- _formatSourceData$key === void 0
113
- ? void 0
114
- : _formatSourceData$key[formatKey];
115
- if (!format) {
116
- return;
117
- }
118
- var resultValue = format(value);
119
- _Reflect$deleteProperty(newValue, key);
120
- newValue = _objectSpread(
121
- _objectSpread({}, newValue),
122
- resultValue
123
- );
124
- });
125
- return newValue;
126
- },
127
- dispatch: function dispatch(action) {
128
- var _context2, _context3, _context4;
129
- for (
130
- var _len = arguments.length,
131
- args = new Array(_len > 1 ? _len - 1 : 0),
132
- _key = 1;
133
- _key < _len;
134
- _key++
135
- ) {
136
- args[_key - 1] = arguments[_key];
137
- }
138
- var key = action.key,
139
- name = action.name;
140
- var items = dispatchSourceData[key];
141
- if (!items) {
142
- return;
143
- }
144
- var keysFn = items.keysFn,
145
- defaultFn = items.defaultFn;
146
- if (name) {
147
- var _keysFn$name, _context;
148
- return (_keysFn$name = keysFn[name]) === null ||
149
- _keysFn$name === void 0
150
- ? void 0
151
- : _keysFn$name.call.apply(
152
- _keysFn$name,
153
- _concatInstanceProperty((_context = [keysFn])).call(
154
- _context,
155
- args
156
- )
157
- );
158
- }
159
- var fnArrays = _mapInstanceProperty(
160
- (_context2 = _Object$keys(keysFn))
161
- ).call(_context2, function (itemKey) {
162
- return keysFn[itemKey];
163
- });
164
- _forEachInstanceProperty(
165
- (_context3 = _concatInstanceProperty((_context4 = [])).call(
166
- _context4,
167
- _toConsumableArray(fnArrays),
168
- _toConsumableArray(defaultFn)
169
- ))
170
- ).call(_context3, function (fn) {
171
- fn.apply(void 0, args);
172
- });
173
- },
174
- addDispatchListener: function addDispatchListener(action, fn) {
175
- var key = action.key,
176
- name = action.name;
177
- var items = dispatchSourceData[key];
178
- if (!items) {
179
- dispatchSourceData[key] = norAddItemDispatch(name, fn);
180
- return;
181
- }
182
- var keysFn = items.keysFn,
183
- defaultFn = items.defaultFn;
184
- if (name) {
185
- keysFn[name] = fn;
186
- } else {
187
- defaultFn.push(fn);
188
- }
189
- dispatchSourceData[key] = {
190
- keysFn: keysFn,
191
- defaultFn: defaultFn,
192
- };
193
- },
194
- removeDispatchListener: function removeDispatchListener(action) {
195
- if (!action) {
196
- dispatchSourceData = {};
197
- return;
198
- }
199
- var key = action.key,
200
- name = action.name;
201
- var items = dispatchSourceData[key];
202
- if (!items) {
203
- return;
204
- }
205
- if (name) {
206
- var keysFn = items.keysFn;
207
- _Reflect$deleteProperty(keysFn, name);
208
- items.keysFn = keysFn;
209
- dispatchSourceData[key] = items;
210
- return;
211
- }
212
- _Reflect$deleteProperty(dispatchSourceData, key);
213
- },
214
- initValues: function initValues() {
215
- var value =
216
- arguments.length > 0 && arguments[0] !== undefined
217
- ? arguments[0]
218
- : {};
219
- var newValue = this.formatValues(value);
220
- form.setFieldsValue(newValue);
221
- },
222
- outputValues: function outputValues(value) {
223
- return this.formatValues(value, "outputValue");
224
- },
225
- },
226
- form
227
- ),
228
- {},
229
- {
230
- setFieldsValue: function setFieldsValue(values) {
231
- var newValue = this.formatValues(values);
42
+ return _objectSpread(_objectSpread({
43
+ initValues: function initValues() {
44
+ if (cacheValues) {
45
+ var newValue = this.formatValues(cacheValues);
232
46
  form.setFieldsValue(newValue);
233
- },
234
- validateFields: function validateFields(nameList) {
235
- var _this = this;
236
- return new _Promise(function (resolve) {
237
- form.validateFields(nameList).then(function (value) {
238
- var result = _this.formatValues(value, "outputValue");
239
- return resolve(result);
240
- });
47
+ }
48
+ },
49
+ addFormat: function addFormat(name, format) {
50
+ if (!format) {
51
+ return;
52
+ }
53
+ var inputValue = format.inputValue,
54
+ outputValue = format.outputValue;
55
+ formatSourceData[name] = {
56
+ inputValue: inputValue,
57
+ outputValue: outputValue
58
+ };
59
+ },
60
+ formatValues: function formatValues() {
61
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
62
+ var formatKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "inputValue";
63
+ var valKeys = _Object$keys(value).length;
64
+ if (!valKeys) {
65
+ return {};
66
+ }
67
+ var newValue = _objectSpread({}, value);
68
+ var keys = _Object$keys(formatSourceData);
69
+ _forEachInstanceProperty(keys).call(keys, function (key) {
70
+ var _formatSourceData$key;
71
+ var format = (_formatSourceData$key = formatSourceData[key]) === null || _formatSourceData$key === void 0 ? void 0 : _formatSourceData$key[formatKey];
72
+ if (!format) {
73
+ return;
74
+ }
75
+ var resultValue = format(value);
76
+ _Reflect$deleteProperty(newValue, key);
77
+ newValue = _objectSpread(_objectSpread({}, newValue), resultValue);
78
+ });
79
+ return newValue;
80
+ },
81
+ dispatch: function dispatch(action) {
82
+ var _context2, _context3, _context4;
83
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
84
+ args[_key - 1] = arguments[_key];
85
+ }
86
+ var key = action.key,
87
+ name = action.name;
88
+ var items = dispatchSourceData[key];
89
+ if (!items) {
90
+ return;
91
+ }
92
+ var keysFn = items.keysFn,
93
+ defaultFn = items.defaultFn;
94
+ if (name) {
95
+ var _keysFn$name, _context;
96
+ return (_keysFn$name = keysFn[name]) === null || _keysFn$name === void 0 ? void 0 : _keysFn$name.call.apply(_keysFn$name, _concatInstanceProperty(_context = [keysFn]).call(_context, args));
97
+ }
98
+ var fnArrays = _mapInstanceProperty(_context2 = _Object$keys(keysFn)).call(_context2, function (itemKey) {
99
+ return keysFn[itemKey];
100
+ });
101
+ _forEachInstanceProperty(_context3 = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(fnArrays), _toConsumableArray(defaultFn))).call(_context3, function (fn) {
102
+ fn.apply(void 0, args);
103
+ });
104
+ },
105
+ addDispatchListener: function addDispatchListener(action, fn) {
106
+ var key = action.key,
107
+ name = action.name;
108
+ var items = dispatchSourceData[key];
109
+ if (!items) {
110
+ dispatchSourceData[key] = norAddItemDispatch(name, fn);
111
+ return;
112
+ }
113
+ var keysFn = items.keysFn,
114
+ defaultFn = items.defaultFn;
115
+ if (name) {
116
+ keysFn[name] = fn;
117
+ } else {
118
+ defaultFn.push(fn);
119
+ }
120
+ dispatchSourceData[key] = {
121
+ keysFn: keysFn,
122
+ defaultFn: defaultFn
123
+ };
124
+ },
125
+ removeDispatchListener: function removeDispatchListener(action) {
126
+ if (!action) {
127
+ dispatchSourceData = {};
128
+ return;
129
+ }
130
+ var key = action.key,
131
+ name = action.name;
132
+ var items = dispatchSourceData[key];
133
+ if (!items) {
134
+ return;
135
+ }
136
+ if (name) {
137
+ var keysFn = items.keysFn;
138
+ _Reflect$deleteProperty(keysFn, name);
139
+ items.keysFn = keysFn;
140
+ dispatchSourceData[key] = items;
141
+ return;
142
+ }
143
+ _Reflect$deleteProperty(dispatchSourceData, key);
144
+ },
145
+ outputValues: function outputValues(value) {
146
+ return this.formatValues(value, "outputValue");
147
+ }
148
+ }, form), {}, {
149
+ setFieldsValue: function setFieldsValue(values) {
150
+ var newValue = this.formatValues(values);
151
+ cacheValues = values;
152
+ form.setFieldsValue(newValue);
153
+ },
154
+ validateFields: function validateFields(nameList) {
155
+ var _this = this;
156
+ return new _Promise(function (resolve) {
157
+ form.validateFields(nameList).then(function (value) {
158
+ var result = _this.formatValues(value, "outputValue");
159
+ return resolve(result);
241
160
  });
242
- },
161
+ });
243
162
  }
244
- );
163
+ });
245
164
  }, []);
246
- };
165
+ });
247
166
 
248
167
  export { useHForm as default };
249
168
  // powered by hdj
@@ -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;
@@ -1,62 +1,24 @@
1
1
  // welcome to hoo hoo hoo
2
- import React, { useMemo } from "react";
3
- import _Object$keys from "@babel/runtime-corejs3/core-js/object/keys";
4
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js/object/get-own-property-symbols";
5
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
6
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptor";
7
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js/instance/for-each";
8
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js/object/get-own-property-descriptors";
9
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js/object/define-properties";
10
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js/object/define-property";
11
- import _extends from "@babel/runtime-corejs3/helpers/extends";
12
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
13
- import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
14
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
15
- import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js/instance/index-of";
16
- import FormConfig, { placeholderConfig } from "../config.js";
2
+ import React, { useMemo } from 'react';
3
+ import _Object$keys from '@babel/runtime-corejs3/core-js/object/keys';
4
+ import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js/object/get-own-property-symbols';
5
+ import _filterInstanceProperty from '@babel/runtime-corejs3/core-js/instance/filter';
6
+ import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptor';
7
+ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js/instance/for-each';
8
+ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js/object/get-own-property-descriptors';
9
+ import _Object$defineProperties from '@babel/runtime-corejs3/core-js/object/define-properties';
10
+ import _Object$defineProperty from '@babel/runtime-corejs3/core-js/object/define-property';
11
+ import _extends from '@babel/runtime-corejs3/helpers/extends';
12
+ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
13
+ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
14
+ import _mapInstanceProperty from '@babel/runtime-corejs3/core-js/instance/map';
15
+ import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js/instance/index-of';
16
+ import FormConfig, { placeholderConfig } from '../config.js';
17
17
 
18
18
  var _excluded = ["render", "type", "itemProps"],
19
19
  _excluded2 = ["render"];
20
- function ownKeys(object, enumerableOnly) {
21
- var keys = _Object$keys(object);
22
- if (_Object$getOwnPropertySymbols) {
23
- var symbols = _Object$getOwnPropertySymbols(object);
24
- enumerableOnly &&
25
- (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
26
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
27
- })),
28
- keys.push.apply(keys, symbols);
29
- }
30
- return keys;
31
- }
32
- function _objectSpread(target) {
33
- for (var i = 1; i < arguments.length; i++) {
34
- var _context2, _context3;
35
- var source = null != arguments[i] ? arguments[i] : {};
36
- i % 2
37
- ? _forEachInstanceProperty(
38
- (_context2 = ownKeys(Object(source), !0))
39
- ).call(_context2, function (key) {
40
- _defineProperty(target, key, source[key]);
41
- })
42
- : _Object$getOwnPropertyDescriptors
43
- ? _Object$defineProperties(
44
- target,
45
- _Object$getOwnPropertyDescriptors(source)
46
- )
47
- : _forEachInstanceProperty((_context3 = ownKeys(Object(source)))).call(
48
- _context3,
49
- function (key) {
50
- _Object$defineProperty(
51
- target,
52
- key,
53
- _Object$getOwnPropertyDescriptor(source, key)
54
- );
55
- }
56
- );
57
- }
58
- return target;
59
- }
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 _context2, _context3; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context2 = ownKeys(Object(source), !0)).call(_context2, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context3 = ownKeys(Object(source))).call(_context3, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
60
22
  var mathRequired = function mathRequired(configItem, form) {
61
23
  var required = configItem.required,
62
24
  placeholder = configItem.placeholder,
@@ -65,41 +27,28 @@ var mathRequired = function mathRequired(configItem, form) {
65
27
  type = _configItem$type === void 0 ? "input" : _configItem$type;
66
28
  var resultRequired = false;
67
29
  var dom = FormConfig[type];
68
- var resultRules =
69
- rules === null || rules === void 0
70
- ? void 0
71
- : _mapInstanceProperty(rules).call(rules, function (item) {
72
- var eachItem = item;
73
- if (typeof item === "function") {
74
- eachItem = item(form);
75
- }
76
- var _eachItem = eachItem,
77
- itemRequired = _eachItem.required,
78
- message = _eachItem.message;
79
- if (itemRequired) {
80
- resultRequired = itemRequired;
81
- }
82
- if (itemRequired && !message) {
83
- return _objectSpread(
84
- _objectSpread({}, eachItem),
85
- {},
86
- {
87
- required: itemRequired,
88
- message: !!(
89
- dom !== null &&
90
- dom !== void 0 &&
91
- dom.requiredErrMsg
92
- )
93
- ? dom.requiredErrMsg(configItem)
94
- : placeholder,
95
- }
96
- );
97
- }
98
- return eachItem;
99
- });
30
+ var resultRules = rules === null || rules === void 0 ? void 0 : _mapInstanceProperty(rules).call(rules, function (item) {
31
+ var eachItem = item;
32
+ if (typeof item === "function") {
33
+ eachItem = item(form);
34
+ }
35
+ var _eachItem = eachItem,
36
+ itemRequired = _eachItem.required,
37
+ message = _eachItem.message;
38
+ if (itemRequired) {
39
+ resultRequired = itemRequired;
40
+ }
41
+ if (itemRequired && !message) {
42
+ return _objectSpread(_objectSpread({}, eachItem), {}, {
43
+ required: itemRequired,
44
+ message: !!(dom !== null && dom !== void 0 && dom.requiredErrMsg) ? dom.requiredErrMsg(configItem) : placeholder
45
+ });
46
+ }
47
+ return eachItem;
48
+ });
100
49
  return {
101
50
  required: typeof required === "boolean" ? required : resultRequired,
102
- rules: resultRules,
51
+ rules: resultRules
103
52
  };
104
53
  };
105
54
  var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
@@ -115,12 +64,7 @@ var matchDefaultPlaceholder = function matchDefaultPlaceholder(props) {
115
64
  if (dom !== null && dom !== void 0 && dom.placeholder) {
116
65
  return dom.placeholder(props);
117
66
  }
118
- if (
119
- _indexOfInstanceProperty((_context = placeholderConfig.inputType)).call(
120
- _context,
121
- type
122
- ) !== -1
123
- ) {
67
+ if (_indexOfInstanceProperty(_context = placeholderConfig.inputType).call(_context, type) !== -1) {
124
68
  return "\u8BF7\u8F93\u5165".concat(label);
125
69
  }
126
70
  return "\u8BF7\u9009\u62E9".concat(label);
@@ -134,43 +78,24 @@ var defaultRenderMaker = function defaultRenderMaker(props) {
134
78
  componentProps = _objectWithoutProperties(props, _excluded);
135
79
  var dom = FormConfig[type];
136
80
  return function (form) {
137
- var Component = !!(dom !== null && dom !== void 0 && dom.Component)
138
- ? dom.Component
139
- : dom;
140
- var node =
141
- Component &&
142
- /*#__PURE__*/ React.createElement(
143
- Component,
144
- _extends({}, componentProps, itemProps, {
145
- form: form,
146
- })
147
- );
81
+ var Component = !!(dom !== null && dom !== void 0 && dom.Component) ? dom.Component : dom;
82
+ var node = Component && /*#__PURE__*/React.createElement(Component, _extends({}, componentProps, itemProps, {
83
+ form: form
84
+ }));
148
85
  if (render) {
149
86
  return render(props, node, form);
150
87
  }
151
88
  return node;
152
89
  };
153
90
  };
154
- var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(
155
- props
156
- ) {
91
+ var defaultPlaceholderPropsMaker = function defaultPlaceholderPropsMaker(props) {
157
92
  var placeholder = matchDefaultPlaceholder(props);
158
- return _objectSpread(
159
- _objectSpread({}, props),
160
- {},
161
- {
162
- placeholder: placeholder,
163
- render: defaultRenderMaker(
164
- _objectSpread(
165
- _objectSpread({}, props),
166
- {},
167
- {
168
- placeholder: placeholder,
169
- }
170
- )
171
- ),
172
- }
173
- );
93
+ return _objectSpread(_objectSpread({}, props), {}, {
94
+ placeholder: placeholder,
95
+ render: defaultRenderMaker(_objectSpread(_objectSpread({}, props), {}, {
96
+ placeholder: placeholder
97
+ }))
98
+ });
174
99
  };
175
100
  var itemControl = function itemControl(item, form) {
176
101
  var _defaultPlaceholderPr = defaultPlaceholderPropsMaker(item),
@@ -179,28 +104,21 @@ var itemControl = function itemControl(item, form) {
179
104
  var _mathRequired = mathRequired(defaultProps, form),
180
105
  rules = _mathRequired.rules,
181
106
  required = _mathRequired.required;
182
- return _objectSpread(
183
- _objectSpread({}, defaultProps),
184
- {},
185
- {
186
- required: required,
187
- rules: rules,
188
- render: render,
189
- }
190
- );
107
+ return _objectSpread(_objectSpread({}, defaultProps), {}, {
108
+ required: required,
109
+ rules: rules,
110
+ render: render
111
+ });
191
112
  };
192
- var useInitConfigData = function (_ref) {
113
+ var useInitConfigData = (function (_ref) {
193
114
  var configData = _ref.configData,
194
115
  form = _ref.form;
195
- return useMemo(
196
- function () {
197
- return _mapInstanceProperty(configData).call(configData, function (item) {
198
- return itemControl(item, form);
199
- });
200
- },
201
- [configData]
202
- );
203
- };
116
+ return useMemo(function () {
117
+ return _mapInstanceProperty(configData).call(configData, function (item) {
118
+ return itemControl(item, form);
119
+ });
120
+ }, [configData]);
121
+ });
204
122
 
205
123
  export { useInitConfigData as default };
206
124
  // powered by hdj
@@ -1,14 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { HFormProps } from "./modal";
3
- declare const _default: ({
4
- configData,
5
- labelWidth,
6
- form,
7
- request,
8
- onFinish,
9
- infoRequest,
10
- valueType,
11
- initialValues,
12
- ...props
13
- }: HFormProps) => JSX.Element;
3
+ declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, ...props }: HFormProps) => JSX.Element;
14
4
  export default _default;