@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
@@ -1,62 +1,137 @@
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) { 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); }
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
+ }
26
76
  var useChangeOptions = function useChangeOptions(_ref) {
27
77
  var options = _ref.options,
28
78
  _ref$fieldNames = _ref.fieldNames,
29
79
  fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames;
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]);
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
+ );
46
111
  };
47
112
  var useClassName = function useClassName(className) {
48
113
  var config = React.useContext(configProvider.ConfigContext);
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]);
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
+ );
60
135
  };
61
136
  var useMatchConfigProps = function useMatchConfigProps(matchProps) {
62
137
  var globalConfig = FormConfigProvider.useFormConfigContext();
package/lib/index.d.ts CHANGED
@@ -2,19 +2,101 @@
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: ({ 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;
6
- export declare const HInput: ({ ...props }: import("antd").InputProps) => JSX.Element;
7
- export declare const HSelectInput: ({ selectProps, value, onChange, valueName, ...props }: import("./Input/modal").HSelectInputProps) => JSX.Element;
8
- export declare const HUpload: import("react").ForwardRefExoticComponent<import("./Upload/modal").IUpLoadProps & import("react").RefAttributes<import("./Upload/modal").IUploadRefModal>>;
9
- export declare const HUrlUpload: ({ placeholder, value, onChange, mediaType, ...props }: import("./Upload/modal").IUrlUploadProps) => JSX.Element;
10
- export declare const HButtonInput: import("react").FC<import("./Input/modal").HButtonInputProps>;
11
- export declare const HCheckBox: import("react").FC<import("./CheckboxGroup/modal").HCheckboxProps>;
12
- export declare const HSwitch: import("react").FC<import("./Switch").HSwitchProps>;
13
- export declare const HCheckboxGroup: (props: import("./Form/modal").HFormItemProps) => import("react").ReactElement<import("./Form/modal").ConnectResultProps, string | import("react").JSXElementConstructor<any>>;
14
- export declare const HDatePicker: ({ value, onChange, showTime, format, ...props }: import("./TDPicker/modal").HDatePickerProps) => JSX.Element;
15
- export declare const HRangePicker: ({ value, onChange, showTime, format, valueMap, ranges, name, ...props }: import("./TDPicker/modal").HRangePickerProps) => JSX.Element;
16
- export declare const HRadioGroup: ({ value, options, onChange, fieldNames: propsFieldNames, ...props }: import("./RadioGroup").HRadioGroupProps) => JSX.Element;
17
- export declare const HTimePicker: ({ value, format, onChange, ...props }: import("./TDPicker/modal").HTimePickerProps) => JSX.Element;
18
- export declare const HInputNumber: ({ style, ...props }: import("antd").InputNumberProps<string | number>) => JSX.Element;
19
- export declare const HPageHandler: import("react").FC<import("./PageHandler/modal").IHPageHandler<any>>;
20
- export declare const HFormConfigProvider: import("react").FC<import("./Form/modal").IFormConfigContextProps>;
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
+ >;
package/lib/index.js CHANGED
@@ -1,9 +1,9 @@
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
7
 
8
8
  var HSelect = config.default.select;
9
9
  var HInput = config.default.input;
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-bate",
3
+ "version": "0.0.1-beta",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@ant-design/icons": "4.6.2",
31
31
  "ahooks": "2.10.9",
32
- "antd": "4.20.0",
32
+ "antd": "4.20.7",
33
33
  "react": "16.14.0",
34
34
  "react-dom": "17.0.2",
35
35
  "react-router-dom": "^6.11.2"
@@ -32,7 +32,7 @@ const Index = ({
32
32
  addFormat?.({
33
33
  float: {
34
34
  inputValue: (item, initValue) => {
35
- const { name } = item;
35
+ const { name = "" } = item;
36
36
  const keys = checkOptions?.map((optItem) => {
37
37
  return optItem.value;
38
38
  });
@@ -45,7 +45,7 @@ const Index = ({
45
45
  };
46
46
  },
47
47
  outputValue: (item, outputValue) => {
48
- const { name } = item;
48
+ const { name = "" } = item;
49
49
  const { [name]: itemVal = {} } = outputValue;
50
50
  return {
51
51
  ...itemVal,
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
- import type { HItemProps } from "@/components/Form/modal";
3
- import type { FormInstance } from "antd";
4
- import { Typography, Row } from "antd";
2
+ import type { HItemProps, HFormInstance } from "@/components/Form/modal";
3
+ import { Typography } from "antd";
5
4
  import { useFormContext } from "../Context";
6
5
 
7
6
  interface HelperProps {
@@ -16,7 +15,7 @@ const Index: React.FC<HelperProps> = ({ helper }) => {
16
15
  if (typeof helper === "function") {
17
16
  return (
18
17
  <Typography.Text type={"secondary"}>
19
- {helper(form as FormInstance)}
18
+ {helper(form as HFormInstance)}
20
19
  </Typography.Text>
21
20
  );
22
21
  }
@@ -4,6 +4,7 @@ import React, { useEffect } from "react";
4
4
  import type { ConnectConfigModal } from "@/components/Form/modal";
5
5
  import type { addFormatItemModal } from "@/components/Form/modal";
6
6
  import type { ConnectResultProps } from "@/components/Form/modal";
7
+ import type { argsFn } from "@/components/Form/modal";
7
8
 
8
9
  const formatMaker = (
9
10
  itemProps: HFormItemProps,
@@ -29,7 +30,7 @@ export default (
29
30
  ) => {
30
31
  const { format = {} } = config;
31
32
  return (props: HFormItemProps) => {
32
- const { name } = props;
33
+ const { name = "" } = props;
33
34
 
34
35
  const { form, valueType = "float" } = useFormContext();
35
36
 
@@ -40,10 +41,13 @@ export default (
40
41
  const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
41
42
  form?.addFormat(name, formatMaker(props, aFormat[valueType]));
42
43
  };
43
-
44
+ const addDispatchListener = (key: string, fn: argsFn) => {
45
+ form?.addDispatchListener({ key, name }, fn);
46
+ };
44
47
  return React.createElement<ConnectResultProps>(Component, {
45
48
  ...props,
46
49
  addFormat,
50
+ addDispatchListener,
47
51
  });
48
52
  };
49
53
  };
@@ -1,12 +1,32 @@
1
1
  import { useMemo } from "react";
2
2
  import { Form } from "antd";
3
3
  import type { FormatItemModal, HFormInstance } from "../modal";
4
+ import type { argsFn } from "../modal";
5
+
6
+ interface DispatchItemData {
7
+ keysFn: Record<string, argsFn>;
8
+ defaultFn: argsFn[];
9
+ }
4
10
 
5
11
  export default () => {
6
12
  const [form] = Form.useForm();
7
13
  return useMemo<HFormInstance>(() => {
8
14
  const formatSourceData: Record<string, FormatItemModal> = {};
9
- let dispatchSourceData: Record<string, VoidFunction[]> = {};
15
+ let dispatchSourceData: Record<string, DispatchItemData> = {};
16
+ const norAddItemDispatch = (name, fn) => {
17
+ if (!name) {
18
+ return {
19
+ keysFn: {},
20
+ defaultFn: [fn],
21
+ };
22
+ }
23
+ return {
24
+ keysFn: {
25
+ [name]: fn,
26
+ },
27
+ defaultFn: [],
28
+ };
29
+ };
10
30
  return {
11
31
  addFormat(name: string, format?: FormatItemModal) {
12
32
  if (!format) {
@@ -39,29 +59,58 @@ export default () => {
39
59
  });
40
60
  return newValue;
41
61
  }, //转化方法
42
- dispatch(key) {
62
+ dispatch(action, ...args) {
63
+ const { key, name } = action;
43
64
  const items = dispatchSourceData[key];
44
65
  if (!items) {
45
66
  return;
46
67
  }
47
- items.forEach((fn) => {
48
- fn();
68
+ const { keysFn, defaultFn } = items;
69
+ if (name) {
70
+ return keysFn[name]?.(...args);
71
+ }
72
+ const fnArrays = Object.keys(keysFn).map((itemKey) => {
73
+ return keysFn[itemKey];
74
+ }); //不存在name就合并
75
+ [...fnArrays, ...defaultFn].forEach((fn) => {
76
+ fn(...args);
49
77
  });
50
78
  },
51
- addDispatchListener(key, fn) {
79
+ addDispatchListener(action, fn) {
80
+ const { key, name } = action;
52
81
  const items = dispatchSourceData[key];
53
82
  if (!items) {
54
- dispatchSourceData[key] = [fn];
83
+ dispatchSourceData[key] = norAddItemDispatch(name, fn);
55
84
  return;
56
85
  }
57
- items.push(fn);
58
- dispatchSourceData[key] = items;
86
+ const { keysFn, defaultFn } = items;
87
+ if (name) {
88
+ keysFn[name] = fn;
89
+ } else {
90
+ defaultFn.push(fn);
91
+ }
92
+ dispatchSourceData[key] = {
93
+ keysFn,
94
+ defaultFn,
95
+ };
59
96
  },
60
- removeDispatchListener(key) {
61
- if (!key) {
97
+ removeDispatchListener(action) {
98
+ if (!action) {
62
99
  dispatchSourceData = {};
63
100
  return;
64
101
  }
102
+ const { key, name } = action;
103
+ const items = dispatchSourceData[key];
104
+ if (!items) {
105
+ return;
106
+ }
107
+ if (name) {
108
+ const { keysFn } = items;
109
+ Reflect.deleteProperty(keysFn, name);
110
+ items.keysFn = keysFn;
111
+ dispatchSourceData[key] = items;
112
+ return;
113
+ }
65
114
  Reflect.deleteProperty(dispatchSourceData, key);
66
115
  },
67
116
  initValues(value = {}) {
@@ -57,14 +57,14 @@ export interface HItemProps extends Omit<FormItemProps, "name"> {
57
57
  type?: string;
58
58
  itemProps?: ItemPropsType;
59
59
  render?: RenderFun;
60
- helper?: HelperModal;
60
+ helper?: HelperModal | string;
61
61
  hover?: string | HoverModal;
62
62
  // formItems?: HItemProps[]; 保留感觉没必要
63
63
  labelWidth?: number;
64
64
  hide?: boolean | HideModal;
65
65
  placeholder?: string | string[];
66
- formatKeys?: string[];
67
- name: string;
66
+ // formatKeys?: string[];
67
+ name?: string;
68
68
  }
69
69
 
70
70
  export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form"> {
@@ -82,7 +82,7 @@ export interface HFormItemProps extends HItemProps {
82
82
  export interface FormItemWithRender extends Omit<HFormItemProps, "render"> {
83
83
  render: (form: HFormInstance) => React.ReactNode;
84
84
  }
85
-
85
+ export type argsFn = (...args: any[]) => void;
86
86
  export interface FormContextProps {
87
87
  loading?: boolean;
88
88
  form: HFormInstance;
@@ -102,7 +102,10 @@ export interface IFormConfigContextProps {
102
102
  dateRanges?: RangePickerProps["ranges"];
103
103
  uploadProps?: ConfigUploadProps;
104
104
  }
105
-
105
+ interface ActionModal {
106
+ key: string;
107
+ name?: string;
108
+ }
106
109
  export interface HFormInstance extends FormInstance {
107
110
  addFormat: (name: string, formats?: FormatItemModal) => void;
108
111
  initValues: (values?: Record<string, any>) => void;
@@ -110,10 +113,10 @@ export interface HFormInstance extends FormInstance {
110
113
  values?: Record<string, any>,
111
114
  formatKey?: string
112
115
  ) => Record<string, any>;
113
- dispatch: (key: string) => void;
116
+ dispatch: (action: ActionModal, ...args: any[]) => void;
114
117
  outputValues: (values?: Record<string, any>) => Record<string, any>;
115
- addDispatchListener: (key: string, fn: VoidFunction) => void;
116
- removeDispatchListener: (key?: string) => void;
118
+ addDispatchListener: (action: ActionModal, fn: argsFn) => void;
119
+ removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
117
120
  }
118
121
 
119
122
  export interface ConnectConfigModal {
@@ -139,4 +142,5 @@ export interface addFormatItemModal {
139
142
 
140
143
  export interface ConnectResultProps {
141
144
  addFormat?: (format: Record<string, addFormatItemModal>) => void;
145
+ addDispatchListener?: (key: string, fn: argsFn) => void;
142
146
  }
@@ -47,21 +47,23 @@ const HRangePicker: React.FC<HRangePickerProps> = ({
47
47
  }
48
48
  return ranges;
49
49
  }, [ranges]); //默认
50
-
51
50
  addFormat?.({
52
51
  float: {
53
52
  inputValue: (item, initValue) => {
54
- const { name: valueName } = item;
53
+ const { name: valueName = "" } = item;
55
54
  const resultObj = {};
56
55
  Object.values(dateMapKeys).forEach((key) => {
57
- resultObj[key] = initValue[key];
56
+ if (initValue[key]) {
57
+ resultObj[key] = initValue[key];
58
+ }
58
59
  });
60
+ const hasKeys = Object.keys(resultObj).length !== 0;
59
61
  return {
60
- [valueName]: resultObj,
62
+ [valueName]: hasKeys ? resultObj : null,
61
63
  };
62
64
  },
63
65
  outputValue: (item, outputValue) => {
64
- const { name: valueName } = item;
66
+ const { name: valueName = "" } = item;
65
67
  const { [valueName]: itemVal = {} } = outputValue;
66
68
  return {
67
69
  ...itemVal,
@@ -6,6 +6,7 @@ import type { TimePickerProps } from "antd";
6
6
  import type { DurationInputArg2 } from "moment";
7
7
  import type { DateRangePickerValueMapModal } from "../modal";
8
8
  import type { addFormatItemModal } from "@/components/Form/modal";
9
+ import type { argsFn } from "@/components/Form/modal";
9
10
  export interface HDatePickerProps
10
11
  extends Omit<DatePickerProps, "onChange" | "format" | "ranges"> {
11
12
  onChange?: (time?: Moment | string | number) => void;
@@ -124,8 +124,8 @@ export default () => {
124
124
  setTimeout(() => {
125
125
  resolve({
126
126
  check1: 1,
127
- // testStart: "1694747960",
128
- // testEnd: "1693538359",
127
+ testStart: "1694747960",
128
+ testEnd: "1693538359",
129
129
  op: 1,
130
130
  opInput: "12121",
131
131
  });