@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,137 +1,62 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
4
- var _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty");
5
- var _objectWithoutProperties = require("@babel/runtime-corejs3/helpers/objectWithoutProperties");
6
- var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/map");
7
- var _Array$isArray = require("@babel/runtime-corejs3/core-js/array/is-array");
8
- var _concatInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/concat");
9
- var _Object$keys = require("@babel/runtime-corejs3/core-js/object/keys");
10
- var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/for-each");
11
- var _Symbol$toPrimitive = require("@babel/runtime-corejs3/core-js/symbol/to-primitive");
12
- var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js/object/get-own-property-symbols");
13
- var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/filter");
14
- var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
15
- var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptors");
16
- var _Object$defineProperties = require("@babel/runtime-corejs3/core-js/object/define-properties");
17
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
18
- var React = require("react");
19
- var configProvider = require("antd/es/config-provider");
20
- var FormConfigProvider = require("../Form/Context/FormConfigProvider.js");
3
+ var _typeof = require('@babel/runtime-corejs3/helpers/typeof');
4
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
5
+ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
6
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/map');
7
+ var _Array$isArray = require('@babel/runtime-corejs3/core-js/array/is-array');
8
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/concat');
9
+ var _Object$keys = require('@babel/runtime-corejs3/core-js/object/keys');
10
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/for-each');
11
+ var _Symbol$toPrimitive = require('@babel/runtime-corejs3/core-js/symbol/to-primitive');
12
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js/object/get-own-property-symbols');
13
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js/instance/filter');
14
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptor');
15
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js/object/get-own-property-descriptors');
16
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js/object/define-properties');
17
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js/object/define-property');
18
+ var React = require('react');
19
+ var configProvider = require('antd/es/config-provider');
20
+ var FormConfigProvider = require('../Form/Context/FormConfigProvider.js');
21
21
 
22
- function ownKeys(object, enumerableOnly) {
23
- var keys = _Object$keys(object);
24
- if (_Object$getOwnPropertySymbols) {
25
- var symbols = _Object$getOwnPropertySymbols(object);
26
- enumerableOnly &&
27
- (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
28
- return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
29
- })),
30
- keys.push.apply(keys, symbols);
31
- }
32
- return keys;
33
- }
34
- function _objectSpread(target) {
35
- for (var i = 1; i < arguments.length; i++) {
36
- var _context4, _context5;
37
- var source = null != arguments[i] ? arguments[i] : {};
38
- i % 2
39
- ? _forEachInstanceProperty(
40
- (_context4 = ownKeys(Object(source), !0))
41
- ).call(_context4, function (key) {
42
- _defineProperty(target, key, source[key]);
43
- })
44
- : _Object$getOwnPropertyDescriptors
45
- ? _Object$defineProperties(
46
- target,
47
- _Object$getOwnPropertyDescriptors(source)
48
- )
49
- : _forEachInstanceProperty((_context5 = ownKeys(Object(source)))).call(
50
- _context5,
51
- function (key) {
52
- _Object$defineProperty(
53
- target,
54
- key,
55
- _Object$getOwnPropertyDescriptor(source, key)
56
- );
57
- }
58
- );
59
- }
60
- return target;
61
- }
62
- function _toPropertyKey(arg) {
63
- var key = _toPrimitive(arg, "string");
64
- return _typeof(key) === "symbol" ? key : String(key);
65
- }
66
- function _toPrimitive(input, hint) {
67
- if (_typeof(input) !== "object" || input === null) return input;
68
- var prim = input[_Symbol$toPrimitive];
69
- if (prim !== undefined) {
70
- var res = prim.call(input, hint || "default");
71
- if (_typeof(res) !== "object") return res;
72
- throw new TypeError("@@toPrimitive must return a primitive value.");
73
- }
74
- return (hint === "string" ? String : Number)(input);
75
- }
22
+ 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; }
23
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context4, _context5; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(source), !0)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[_Symbol$toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
76
26
  var useChangeOptions = function useChangeOptions(_ref) {
77
27
  var options = _ref.options,
78
28
  _ref$fieldNames = _ref.fieldNames,
79
29
  fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames;
80
- return React.useMemo(
81
- function () {
82
- return options === null || options === void 0
83
- ? void 0
84
- : _mapInstanceProperty(options).call(options, function (item) {
85
- var _context;
86
- var _fieldNames$label = fieldNames.label,
87
- label = _fieldNames$label === void 0 ? "" : _fieldNames$label,
88
- _fieldNames$value = fieldNames.value,
89
- value = _fieldNames$value === void 0 ? "" : _fieldNames$value;
90
- var relLabel = item[label],
91
- relVal = item[value],
92
- oItem = _objectWithoutProperties(
93
- item,
94
- _mapInstanceProperty((_context = [label, value])).call(
95
- _context,
96
- _toPropertyKey
97
- )
98
- );
99
- return _objectSpread(
100
- _objectSpread({}, oItem),
101
- {},
102
- {
103
- label: relLabel,
104
- value: relVal,
105
- }
106
- );
107
- });
108
- },
109
- [options]
110
- );
30
+ return React.useMemo(function () {
31
+ return options === null || options === void 0 ? void 0 : _mapInstanceProperty(options).call(options, function (item) {
32
+ var _context;
33
+ var _fieldNames$label = fieldNames.label,
34
+ label = _fieldNames$label === void 0 ? "" : _fieldNames$label,
35
+ _fieldNames$value = fieldNames.value,
36
+ value = _fieldNames$value === void 0 ? "" : _fieldNames$value;
37
+ var relLabel = item[label],
38
+ relVal = item[value],
39
+ oItem = _objectWithoutProperties(item, _mapInstanceProperty(_context = [label, value]).call(_context, _toPropertyKey));
40
+ return _objectSpread(_objectSpread({}, oItem), {}, {
41
+ label: relLabel,
42
+ value: relVal
43
+ });
44
+ });
45
+ }, [options]);
111
46
  };
112
47
  var useClassName = function useClassName(className) {
113
48
  var config = React.useContext(configProvider.ConfigContext);
114
- return React.useMemo(
115
- function () {
116
- var _context3;
117
- if (_Array$isArray(className)) {
118
- var classNames = _mapInstanceProperty(className).call(
119
- className,
120
- function (item) {
121
- var _context2;
122
- return _concatInstanceProperty(
123
- (_context2 = "".concat(config.getPrefixCls(), "-"))
124
- ).call(_context2, item);
125
- }
126
- );
127
- return classNames.join(" ");
128
- }
129
- return _concatInstanceProperty(
130
- (_context3 = "".concat(config.getPrefixCls(), "-"))
131
- ).call(_context3, className);
132
- },
133
- [className]
134
- );
49
+ return React.useMemo(function () {
50
+ var _context3;
51
+ if (_Array$isArray(className)) {
52
+ var classNames = _mapInstanceProperty(className).call(className, function (item) {
53
+ var _context2;
54
+ return _concatInstanceProperty(_context2 = "".concat(config.getPrefixCls(), "-")).call(_context2, item);
55
+ });
56
+ return classNames.join(" ");
57
+ }
58
+ return _concatInstanceProperty(_context3 = "".concat(config.getPrefixCls(), "-")).call(_context3, className);
59
+ }, [className]);
135
60
  };
136
61
  var useMatchConfigProps = function useMatchConfigProps(matchProps) {
137
62
  var globalConfig = FormConfigProvider.useFormConfigContext();
package/lib/index.d.ts CHANGED
@@ -2,101 +2,21 @@
2
2
  import "./styles/index.less";
3
3
  export { default as HForm } from "./Form";
4
4
  export { default as useHForm } from "./Form/hooks/useHForm";
5
- export declare const HSelect: ({
6
- style,
7
- mode,
8
- options,
9
- modeConfig,
10
- value,
11
- onChange,
12
- fieldNames: propsFieldNames,
13
- request,
14
- manual,
15
- optionLabelProp,
16
- filterProvider,
17
- optionFilterProp,
18
- serviceSearch,
19
- onSearch: propsOnSearch,
20
- filterOption,
21
- showSearch,
22
- labelInValue,
23
- noMatchItemRender,
24
- allSelect,
25
- ...props
26
- }: import("./Select/modal").HSelectProps) => JSX.Element;
27
- export declare const HInput: ({
28
- ...props
29
- }: import("antd").InputProps) => JSX.Element;
30
- export declare const HSelectInput: ({
31
- selectProps,
32
- value,
33
- onChange,
34
- valueName,
35
- ...props
36
- }: import("./Input/modal").HSelectInputProps) => JSX.Element;
37
- export declare const HUpload: import("react").ForwardRefExoticComponent<
38
- import("./Upload/modal").IUpLoadProps &
39
- import("react").RefAttributes<import("./Upload/modal").IUploadRefModal>
40
- >;
41
- export declare const HUrlUpload: ({
42
- placeholder,
43
- value,
44
- onChange,
45
- mediaType,
46
- ...props
47
- }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
48
- export declare const HButtonInput: import("react").FC<
49
- import("./Input/modal").HButtonInputProps
50
- >;
51
- export declare const HCheckBox: import("react").FC<
52
- import("./CheckboxGroup/modal").HCheckboxProps
53
- >;
54
- export declare const HSwitch: import("react").FC<
55
- import("./Switch").HSwitchProps
56
- >;
57
- export declare const HCheckboxGroup: (
58
- props: import("./Form/modal").HFormItemProps
59
- ) => import("react").ReactElement<
60
- import("./Form/modal").ConnectResultProps,
61
- string | import("react").JSXElementConstructor<any>
62
- >;
63
- export declare const HDatePicker: ({
64
- value,
65
- onChange,
66
- showTime,
67
- format,
68
- ...props
69
- }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
70
- export declare const HRangePicker: ({
71
- value,
72
- onChange,
73
- showTime,
74
- format,
75
- valueMap,
76
- ranges,
77
- name,
78
- ...props
79
- }: import("./TDPicker/modal").HRangePickerProps) => JSX.Element;
80
- export declare const HRadioGroup: ({
81
- value,
82
- options,
83
- onChange,
84
- fieldNames: propsFieldNames,
85
- ...props
86
- }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
87
- export declare const HTimePicker: ({
88
- value,
89
- format,
90
- onChange,
91
- ...props
92
- }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
93
- export declare const HInputNumber: ({
94
- style,
95
- ...props
96
- }: import("antd").InputNumberProps<string | number>) => JSX.Element;
97
- export declare const HPageHandler: import("react").FC<
98
- import("./PageHandler/modal").IHPageHandler<any>
99
- >;
100
- export declare const HFormConfigProvider: import("react").FC<
101
- import("./Form/modal").IFormConfigContextProps
102
- >;
5
+ export { useHModalForm } from "./ModalForm/hooks";
6
+ export declare const HSelect: ({ style, mode, options, modeConfig, value, onChange, fieldNames: propsFieldNames, request, manual, optionLabelProp, filterProvider, optionFilterProp, serviceSearch, onSearch: propsOnSearch, filterOption, showSearch, labelInValue, noMatchItemRender, allSelect, ...props }: import("./Select/modal").HSelectProps) => JSX.Element;
7
+ export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
8
+ export declare const HSelectInput: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
9
+ export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Upload/modal").IUpLoadProps & import("react").RefAttributes<import("./Upload/modal").IUploadRefModal>>;
10
+ export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
11
+ export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
12
+ export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
13
+ export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
14
+ export declare const HCheckboxGroup: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
15
+ export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
16
+ export declare const HRangePicker: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
17
+ export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
18
+ export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
19
+ export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
20
+ export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
21
+ export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
22
+ export declare const HModalForm: ({ visible, title, onCancel, configData, infoRequest, request, afterClose, modalForm, initialValues, ...props }: import("./ModalForm/modal").ModalFormProps) => JSX.Element;
package/lib/index.js CHANGED
@@ -1,9 +1,11 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
- var config = require("./Form/config.js");
4
- var index$1 = require("./PageHandler/index.js");
5
- var index = require("./Form/index.js");
6
- var useHForm = require("./Form/hooks/useHForm.js");
3
+ var config = require('./Form/config.js');
4
+ var index$1 = require('./PageHandler/index.js');
5
+ var index = require('./Form/index.js');
6
+ var useHForm = require('./Form/hooks/useHForm.js');
7
+ var hooks = require('./ModalForm/hooks.js');
8
+ var index$2 = require('./ModalForm/index.js');
7
9
 
8
10
  var HSelect = config.default.select;
9
11
  var HInput = config.default.input;
@@ -21,9 +23,11 @@ var HTimePicker = config.default.timePicker;
21
23
  var HInputNumber = config.default.inputNumber;
22
24
  var HPageHandler = index$1.default;
23
25
  var HFormConfigProvider = config.default.formConfigProvider;
26
+ var HModalForm = index$2.default;
24
27
 
25
28
  exports.HForm = index.default;
26
29
  exports.useHForm = useHForm.default;
30
+ exports.useHModalForm = hooks.useHModalForm;
27
31
  exports.HButtonInput = HButtonInput;
28
32
  exports.HCheckBox = HCheckBox;
29
33
  exports.HCheckboxGroup = HCheckboxGroup;
@@ -31,6 +35,7 @@ exports.HDatePicker = HDatePicker;
31
35
  exports.HFormConfigProvider = HFormConfigProvider;
32
36
  exports.HInput = HInput;
33
37
  exports.HInputNumber = HInputNumber;
38
+ exports.HModalForm = HModalForm;
34
39
  exports.HPageHandler = HPageHandler;
35
40
  exports.HRadioGroup = HRadioGroup;
36
41
  exports.HRangePicker = HRangePicker;
package/lib/modal.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  export interface ValueCheckMapModal {
2
- checked?: any;
3
- noChecked?: any;
2
+ checked?: any;
3
+ noChecked?: any;
4
4
  }
5
5
  export type PromiseFnResult<T = any, R = any> = (params: T) => Promise<R>;
6
6
  export interface ValueSwitchMapModal {
7
- open?: any;
8
- close?: any;
7
+ open?: any;
8
+ close?: any;
9
9
  }
10
10
  type NameProvider = (name: string) => string;
11
11
  export interface DateRangePickerValueMapModal {
12
- start?: string | NameProvider;
13
- end?: string | NameProvider;
12
+ start?: string | NameProvider;
13
+ end?: string | NameProvider;
14
14
  }
15
15
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.1-beta",
3
+ "version": "0.0.1-beta-v2",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,12 +1,10 @@
1
1
  import { useFormContext } from "./Context";
2
2
  import { useEffect } from "react";
3
- interface InitSetProps {
4
- initValues?: Record<string, any>;
5
- }
6
- export default ({ initValues }: InitSetProps) => {
3
+
4
+ export default () => {
7
5
  const { form } = useFormContext();
8
6
  useEffect(() => {
9
- form.initValues(initValues);
7
+ form.initValues();
10
8
  }, []);
11
9
  return <></>;
12
10
  };
@@ -20,23 +20,3 @@ export const useSub = ({ request, onFinish, form }: ParamsModal) => {
20
20
  { manual: true }
21
21
  );
22
22
  }; //提交
23
-
24
- export const useInit = ({ infoRequest, initialValues = {} }: ParamsModal) => {
25
- const {
26
- run: infoRun,
27
- loading: infoLoading,
28
- error: infoErr,
29
- data: infoData,
30
- } = useRequest(async () => {
31
- if (infoRequest) {
32
- return infoRequest();
33
- }
34
- return initialValues;
35
- });
36
- return {
37
- infoRun,
38
- infoLoading,
39
- infoErr,
40
- infoData,
41
- };
42
- }; //初始化
@@ -13,6 +13,7 @@ export default () => {
13
13
  return useMemo<HFormInstance>(() => {
14
14
  const formatSourceData: Record<string, FormatItemModal> = {};
15
15
  let dispatchSourceData: Record<string, DispatchItemData> = {};
16
+ let cacheValues: Record<string, any> = {};
16
17
  const norAddItemDispatch = (name, fn) => {
17
18
  if (!name) {
18
19
  return {
@@ -28,6 +29,12 @@ export default () => {
28
29
  };
29
30
  };
30
31
  return {
32
+ initValues() {
33
+ if (cacheValues) {
34
+ const newValue = this.formatValues(cacheValues);
35
+ form.setFieldsValue(newValue);
36
+ }
37
+ },
31
38
  addFormat(name: string, format?: FormatItemModal) {
32
39
  if (!format) {
33
40
  return;
@@ -113,16 +120,13 @@ export default () => {
113
120
  }
114
121
  Reflect.deleteProperty(dispatchSourceData, key);
115
122
  },
116
- initValues(value = {}) {
117
- const newValue = this.formatValues(value);
118
- form.setFieldsValue(newValue);
119
- },
120
123
  outputValues(value) {
121
124
  return this.formatValues(value, "outputValue");
122
125
  },
123
126
  ...form,
124
127
  setFieldsValue(values) {
125
128
  const newValue = this.formatValues(values);
129
+ cacheValues = values;
126
130
  form.setFieldsValue(newValue);
127
131
  },
128
132
  validateFields(nameList) {
@@ -1,11 +1,14 @@
1
1
  import { Form } from "antd";
2
2
  import type { HFormProps } from "./modal";
3
3
  import Item from "./FormItem";
4
- import { useCurrentForm, useInit, useSub } from "./hooks";
4
+ import { useCurrentForm, useSub } from "./hooks";
5
5
  import { FormContext } from "./Context";
6
6
  import PageHandler from "../PageHandler";
7
7
  import useInitConfigData from "./hooks/useInitConfigData";
8
+ import { useEffect } from "react";
9
+ import { useRequest } from "ahooks";
8
10
  import InitSet from "./InitSet";
11
+
9
12
  export default ({
10
13
  configData,
11
14
  labelWidth,
@@ -28,12 +31,27 @@ export default ({
28
31
  valueType,
29
32
  form: hForm,
30
33
  });
31
-
32
- const { infoRun, infoLoading, infoErr, infoData } = useInit({
33
- infoRequest,
34
- initialValues,
34
+ const {
35
+ run: infoRun,
36
+ loading: infoLoading,
37
+ error: infoErr,
38
+ data: infoData,
39
+ } = useRequest(async () => {
40
+ let setValue = initialValues;
41
+ if (!initialValues && !infoRequest) {
42
+ return {};
43
+ }
44
+ if (infoRequest) {
45
+ setValue = await infoRequest();
46
+ }
47
+ hForm.setFieldsValue(setValue);
48
+ return setValue;
35
49
  });
36
-
50
+ useEffect(() => {
51
+ return () => {
52
+ hForm.removeDispatchListener();
53
+ };
54
+ }, []);
37
55
  return (
38
56
  <PageHandler
39
57
  loading={infoLoading}
@@ -53,8 +71,8 @@ export default ({
53
71
  />
54
72
  );
55
73
  })}
74
+ <InitSet />
56
75
  </Form>
57
- <InitSet initValues={infoData} />
58
76
  </FormContext.Provider>
59
77
  </PageHandler>
60
78
  );
@@ -53,6 +53,8 @@ type HelperModal = (form: HFormInstance) => React.ReactNode | string;
53
53
 
54
54
  export type HideModal = (form: HFormInstance) => boolean;
55
55
 
56
+ export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
57
+
56
58
  export interface HItemProps extends Omit<FormItemProps, "name"> {
57
59
  type?: string;
58
60
  itemProps?: ItemPropsType;
@@ -108,14 +110,14 @@ interface ActionModal {
108
110
  }
109
111
  export interface HFormInstance extends FormInstance {
110
112
  addFormat: (name: string, formats?: FormatItemModal) => void;
111
- initValues: (values?: Record<string, any>) => void;
113
+ initValues: VoidFunction;
112
114
  formatValues: (
113
115
  values?: Record<string, any>,
114
116
  formatKey?: string
115
117
  ) => Record<string, any>;
116
118
  dispatch: (action: ActionModal, ...args: any[]) => void;
117
119
  outputValues: (values?: Record<string, any>) => Record<string, any>;
118
- addDispatchListener: (action: ActionModal, fn: argsFn) => void;
120
+ addDispatchListener: AddDispatchListenerFn;
119
121
  removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
120
122
  }
121
123
 
@@ -13,6 +13,7 @@ export const Index = ({
13
13
  onChange,
14
14
  valueName = defaultValueName,
15
15
  addFormat,
16
+ addDispatchListener,
16
17
  ...props
17
18
  }: HSelectInputProps) => {
18
19
  const { input = "", select = "" } = valueName;
@@ -31,7 +32,7 @@ export const Index = ({
31
32
  addFormat?.({
32
33
  float: {
33
34
  inputValue: (item, initValue) => {
34
- const { name } = item;
35
+ const { name = "" } = item;
35
36
  const resultObj = {};
36
37
  Object.values(valueName).forEach((key) => {
37
38
  resultObj[key] = initValue[key];
@@ -41,7 +42,7 @@ export const Index = ({
41
42
  };
42
43
  },
43
44
  outputValue: (item, outputValue) => {
44
- const { name } = item;
45
+ const { name = "" } = item;
45
46
  const { [name]: itemVal = {} } = outputValue;
46
47
  const newItemVal = { [itemVal[select]]: itemVal[input] };
47
48
  return {
@@ -3,6 +3,7 @@ import type { HSelectProps } from "../Select/modal";
3
3
  import type { SelectInputType } from "./SelectInput";
4
4
  import type { PromiseFnResult } from "../modal";
5
5
  import type { addFormatItemModal } from "../Form/modal";
6
+ import type { AddDispatchListenerFn } from "../Form/modal";
6
7
 
7
8
  export type HInputProps = InputProps;
8
9
 
@@ -18,6 +19,7 @@ export interface HSelectInputProps
18
19
  onChange?: (value: Record<string, any>, type: SelectInputType) => void;
19
20
  valueName?: ValueNameModal;
20
21
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
22
+ addDispatchListener?: AddDispatchListenerFn;
21
23
  }
22
24
  export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
23
25
  onClick: (
@@ -0,0 +1,45 @@
1
+ import { useEffect, useMemo, useState } from "react";
2
+ import useHForm from "../Form/hooks/useHForm";
3
+ import type {
4
+ HModalFormInstance,
5
+ ModifyPropsModal,
6
+ } from "@/components/ModalForm/modal";
7
+
8
+ export const useModifyProps = ({
9
+ visible,
10
+ configData,
11
+ initialValues,
12
+ }: ModifyPropsModal) => {
13
+ const [modalVisible, setModalVisible] = useState(visible);
14
+ const [modalFormData, setModalFormData] = useState(configData);
15
+ const [initValue, setInitValue] = useState(initialValues);
16
+ useEffect(() => {
17
+ setModalVisible(visible);
18
+ }, [visible]);
19
+ useEffect(() => {
20
+ setModalFormData(configData);
21
+ }, [configData]);
22
+ return {
23
+ modalFormData,
24
+ modalVisible,
25
+ setModalVisible,
26
+ setModalFormData,
27
+ initValue,
28
+ setInitValue,
29
+ };
30
+ };
31
+ export const useHModalForm = () => {
32
+ const hForm = useHForm();
33
+ return useMemo<HModalFormInstance>(() => {
34
+ return {
35
+ ...hForm,
36
+ show: (params) => {},
37
+ hide: () => {},
38
+ };
39
+ }, []);
40
+ };
41
+
42
+ export const useCurrentForm = (hModalForm?: HModalFormInstance) => {
43
+ const defaultHModalForm = useHModalForm();
44
+ return hModalForm || defaultHModalForm;
45
+ };