@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.
- package/es/CheckboxGroup/CheckBox/index.js +24 -16
- package/es/CheckboxGroup/hooks.d.ts +9 -3
- package/es/CheckboxGroup/hooks.js +115 -64
- package/es/CheckboxGroup/index.d.ts +6 -1
- package/es/CheckboxGroup/index.js +117 -56
- package/es/CheckboxGroup/modal.d.ts +9 -8
- package/es/Form/Context/FormConfigProvider.js +64 -19
- package/es/Form/Context/index.d.ts +4 -1
- package/es/Form/Context/index.js +3 -3
- package/es/Form/FormItem/BasicItem.js +80 -42
- package/es/Form/FormItem/Helper.d.ts +1 -1
- package/es/Form/FormItem/Helper.js +17 -9
- package/es/Form/FormItem/RegularFormItem.js +11 -8
- package/es/Form/FormItem/UpFormItem.d.ts +6 -1
- package/es/Form/FormItem/UpFormItem.js +27 -17
- package/es/Form/FormItem/hooks.d.ts +21 -4
- package/es/Form/FormItem/hooks.js +12 -9
- package/es/Form/FormItem/index.js +5 -5
- package/es/Form/HFormConnect.d.ts +9 -1
- package/es/Form/HFormConnect.js +94 -26
- package/es/Form/InitSet.d.ts +1 -1
- package/es/Form/InitSet.js +5 -5
- package/es/Form/Label.d.ts +4 -4
- package/es/Form/Label.js +36 -19
- package/es/Form/config.d.ts +100 -22
- package/es/Form/config.js +19 -19
- package/es/Form/hooks/index.d.ts +12 -5
- package/es/Form/hooks/index.js +65 -49
- package/es/Form/hooks/useHForm.js +233 -95
- package/es/Form/hooks/useInitConfigData.d.ts +4 -1
- package/es/Form/hooks/useInitConfigData.js +143 -61
- package/es/Form/index.d.ts +11 -1
- package/es/Form/index.js +71 -40
- package/es/Form/modal.d.ts +92 -51
- package/es/Input/ButtonInput.js +73 -51
- package/es/Input/InputNumber.js +21 -12
- package/es/Input/SelectInput.d.ts +16 -4
- package/es/Input/SelectInput.js +113 -56
- package/es/Input/defaultConfig.d.ts +3 -3
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.js +7 -7
- package/es/Input/modal.d.ts +15 -11
- package/es/PageHandler/ErrorComponent.js +47 -25
- package/es/PageHandler/LoadingComponent.js +17 -13
- package/es/PageHandler/index.js +7 -7
- package/es/PageHandler/modal.d.ts +4 -4
- package/es/RadioGroup/index.d.ts +12 -5
- package/es/RadioGroup/index.js +46 -33
- package/es/Select/components/AllSelect.d.ts +1 -1
- package/es/Select/components/AllSelect.js +40 -18
- package/es/Select/components/CheckBoxOption.d.ts +6 -3
- package/es/Select/components/CheckBoxOption.js +12 -7
- package/es/Select/components/DropdownComponent.d.ts +4 -4
- package/es/Select/components/DropdownComponent.js +30 -17
- package/es/Select/components/NoFindItem.d.ts +1 -1
- package/es/Select/components/NoFindItem.js +11 -7
- package/es/Select/components/NotFoundContent.d.ts +2 -2
- package/es/Select/components/NotFoundContent.js +49 -27
- package/es/Select/defaultConfig.d.ts +1 -1
- package/es/Select/defaultConfig.js +20 -16
- package/es/Select/hooks/changeHooks.d.ts +2 -2
- package/es/Select/hooks/changeHooks.js +147 -71
- package/es/Select/hooks/norHooks.d.ts +27 -9
- package/es/Select/hooks/norHooks.js +51 -39
- package/es/Select/index.d.ts +22 -1
- package/es/Select/index.js +124 -65
- package/es/Select/modal.d.ts +15 -15
- package/es/Select/utils.js +60 -15
- package/es/Submit/index.d.ts +9 -3
- package/es/Submit/index.js +18 -13
- package/es/Switch/index.d.ts +4 -4
- package/es/Switch/index.js +46 -20
- package/es/TDPicker/RangePicker.d.ts +8 -3
- package/es/TDPicker/RangePicker.js +138 -62
- package/es/TDPicker/TimePicker.d.ts +6 -1
- package/es/TDPicker/TimePicker.js +19 -13
- package/es/TDPicker/hooks.d.ts +42 -22
- package/es/TDPicker/hooks.js +106 -72
- package/es/TDPicker/index.d.ts +7 -1
- package/es/TDPicker/index.js +20 -14
- package/es/TDPicker/modal.d.ts +21 -16
- package/es/Upload/Btn.d.ts +5 -1
- package/es/Upload/Btn.js +35 -19
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/es/Upload/MediaTypeEle/TypeEle.js +31 -23
- package/es/Upload/MediaTypeEle/index.d.ts +5 -1
- package/es/Upload/MediaTypeEle/index.js +21 -18
- package/es/Upload/Preview/index.d.ts +5 -1
- package/es/Upload/Preview/index.js +17 -13
- package/es/Upload/UrlUpload/index.d.ts +7 -1
- package/es/Upload/UrlUpload/index.js +72 -51
- package/es/Upload/enums.d.ts +3 -3
- package/es/Upload/enums.js +3 -3
- package/es/Upload/hooks/change.d.ts +8 -1
- package/es/Upload/hooks/change.js +115 -58
- package/es/Upload/hooks/customRequest.d.ts +5 -1
- package/es/Upload/hooks/customRequest.js +63 -46
- package/es/Upload/hooks/propsMaker.d.ts +5 -1
- package/es/Upload/hooks/propsMaker.js +52 -13
- package/es/Upload/index.d.ts +3 -1
- package/es/Upload/index.js +131 -61
- package/es/Upload/modal.d.ts +17 -15
- package/es/Upload/util.d.ts +8 -2
- package/es/Upload/util.js +15 -7
- package/es/config.js +34 -31
- package/es/hooks/index.d.ts +14 -7
- package/es/hooks/index.js +124 -49
- package/es/index.d.ts +98 -16
- package/es/index.js +22 -5
- package/es/modal.d.ts +6 -6
- package/lib/CheckboxGroup/CheckBox/index.js +26 -18
- package/lib/CheckboxGroup/hooks.d.ts +9 -3
- package/lib/CheckboxGroup/hooks.js +116 -65
- package/lib/CheckboxGroup/index.d.ts +6 -1
- package/lib/CheckboxGroup/index.js +119 -58
- package/lib/CheckboxGroup/modal.d.ts +9 -8
- package/lib/Form/Context/FormConfigProvider.js +66 -21
- package/lib/Form/Context/index.d.ts +4 -1
- package/lib/Form/Context/index.js +4 -4
- package/lib/Form/FormItem/BasicItem.js +82 -44
- package/lib/Form/FormItem/Helper.d.ts +1 -1
- package/lib/Form/FormItem/Helper.js +19 -11
- package/lib/Form/FormItem/RegularFormItem.js +13 -10
- package/lib/Form/FormItem/UpFormItem.d.ts +6 -1
- package/lib/Form/FormItem/UpFormItem.js +29 -19
- package/lib/Form/FormItem/hooks.d.ts +21 -4
- package/lib/Form/FormItem/hooks.js +13 -10
- package/lib/Form/FormItem/index.js +7 -7
- package/lib/Form/HFormConnect.d.ts +9 -1
- package/lib/Form/HFormConnect.js +96 -28
- package/lib/Form/InitSet.d.ts +1 -1
- package/lib/Form/InitSet.js +7 -7
- package/lib/Form/Label.d.ts +4 -4
- package/lib/Form/Label.js +41 -21
- package/lib/Form/config.d.ts +100 -22
- package/lib/Form/config.js +21 -21
- package/lib/Form/hooks/index.d.ts +12 -5
- package/lib/Form/hooks/index.js +66 -50
- package/lib/Form/hooks/useHForm.js +235 -97
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -1
- package/lib/Form/hooks/useInitConfigData.js +144 -63
- package/lib/Form/index.d.ts +11 -1
- package/lib/Form/index.js +73 -42
- package/lib/Form/modal.d.ts +92 -51
- package/lib/Input/ButtonInput.js +75 -53
- package/lib/Input/InputNumber.js +23 -14
- package/lib/Input/SelectInput.d.ts +16 -4
- package/lib/Input/SelectInput.js +125 -60
- package/lib/Input/defaultConfig.d.ts +3 -3
- package/lib/Input/defaultConfig.js +3 -3
- package/lib/Input/index.js +9 -9
- package/lib/Input/modal.d.ts +15 -11
- package/lib/PageHandler/ErrorComponent.js +49 -27
- package/lib/PageHandler/LoadingComponent.js +19 -15
- package/lib/PageHandler/index.js +9 -9
- package/lib/PageHandler/modal.d.ts +4 -4
- package/lib/RadioGroup/index.d.ts +12 -5
- package/lib/RadioGroup/index.js +48 -35
- package/lib/Select/components/AllSelect.d.ts +1 -1
- package/lib/Select/components/AllSelect.js +42 -20
- package/lib/Select/components/CheckBoxOption.d.ts +6 -3
- package/lib/Select/components/CheckBoxOption.js +14 -9
- package/lib/Select/components/DropdownComponent.d.ts +4 -4
- package/lib/Select/components/DropdownComponent.js +32 -19
- package/lib/Select/components/NoFindItem.d.ts +1 -1
- package/lib/Select/components/NoFindItem.js +13 -9
- package/lib/Select/components/NotFoundContent.d.ts +2 -2
- package/lib/Select/components/NotFoundContent.js +51 -29
- package/lib/Select/defaultConfig.d.ts +1 -1
- package/lib/Select/defaultConfig.js +21 -17
- package/lib/Select/hooks/changeHooks.d.ts +2 -2
- package/lib/Select/hooks/changeHooks.js +148 -72
- package/lib/Select/hooks/norHooks.d.ts +27 -9
- package/lib/Select/hooks/norHooks.js +52 -40
- package/lib/Select/index.d.ts +22 -1
- package/lib/Select/index.js +128 -67
- package/lib/Select/modal.d.ts +15 -15
- package/lib/Select/utils.js +61 -16
- package/lib/Submit/index.d.ts +9 -3
- package/lib/Submit/index.js +20 -15
- package/lib/Switch/index.d.ts +4 -4
- package/lib/Switch/index.js +48 -22
- package/lib/TDPicker/RangePicker.d.ts +8 -3
- package/lib/TDPicker/RangePicker.js +136 -64
- package/lib/TDPicker/TimePicker.d.ts +6 -1
- package/lib/TDPicker/TimePicker.js +21 -15
- package/lib/TDPicker/hooks.d.ts +42 -22
- package/lib/TDPicker/hooks.js +98 -72
- package/lib/TDPicker/index.d.ts +7 -1
- package/lib/TDPicker/index.js +22 -16
- package/lib/TDPicker/modal.d.ts +21 -16
- package/lib/Upload/Btn.d.ts +5 -1
- package/lib/Upload/Btn.js +37 -21
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/lib/Upload/MediaTypeEle/TypeEle.js +33 -25
- package/lib/Upload/MediaTypeEle/index.d.ts +5 -1
- package/lib/Upload/MediaTypeEle/index.js +23 -20
- package/lib/Upload/Preview/index.d.ts +5 -1
- package/lib/Upload/Preview/index.js +19 -15
- package/lib/Upload/UrlUpload/index.d.ts +7 -1
- package/lib/Upload/UrlUpload/index.js +74 -53
- package/lib/Upload/enums.d.ts +3 -3
- package/lib/Upload/enums.js +4 -4
- package/lib/Upload/hooks/change.d.ts +8 -1
- package/lib/Upload/hooks/change.js +116 -59
- package/lib/Upload/hooks/customRequest.d.ts +5 -1
- package/lib/Upload/hooks/customRequest.js +64 -47
- package/lib/Upload/hooks/propsMaker.d.ts +5 -1
- package/lib/Upload/hooks/propsMaker.js +55 -15
- package/lib/Upload/index.d.ts +3 -1
- package/lib/Upload/index.js +133 -63
- package/lib/Upload/modal.d.ts +17 -15
- package/lib/Upload/util.d.ts +8 -2
- package/lib/Upload/util.js +16 -8
- package/lib/config.js +35 -32
- package/lib/hooks/index.d.ts +14 -7
- package/lib/hooks/index.js +125 -50
- package/lib/index.d.ts +98 -16
- package/lib/index.js +5 -5
- package/lib/modal.d.ts +6 -6
- package/package.json +2 -2
- package/src/components/CheckboxGroup/index.tsx +2 -2
- package/src/components/Form/FormItem/Helper.tsx +3 -4
- package/src/components/Form/HFormConnect.tsx +6 -2
- package/src/components/Form/hooks/useHForm.ts +59 -10
- package/src/components/Form/modal.ts +12 -8
- package/src/components/TDPicker/RangePicker.tsx +7 -5
- package/src/components/TDPicker/modal.ts +1 -0
- package/src/pages/Form/index.tsx +2 -2
package/lib/hooks/index.js
CHANGED
|
@@ -1,62 +1,137 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var _typeof = require(
|
|
4
|
-
var _defineProperty = require(
|
|
5
|
-
var _objectWithoutProperties = require(
|
|
6
|
-
var _mapInstanceProperty = require(
|
|
7
|
-
var _Array$isArray = require(
|
|
8
|
-
var _concatInstanceProperty = require(
|
|
9
|
-
var _Object$keys = require(
|
|
10
|
-
var _forEachInstanceProperty = require(
|
|
11
|
-
var _Symbol$toPrimitive = require(
|
|
12
|
-
var _Object$getOwnPropertySymbols = require(
|
|
13
|
-
var _filterInstanceProperty = require(
|
|
14
|
-
var _Object$getOwnPropertyDescriptor = require(
|
|
15
|
-
var _Object$getOwnPropertyDescriptors = require(
|
|
16
|
-
var _Object$defineProperties = require(
|
|
17
|
-
var _Object$defineProperty = require(
|
|
18
|
-
var React = require(
|
|
19
|
-
var configProvider = require(
|
|
20
|
-
var FormConfigProvider = require(
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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: ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var config = require(
|
|
4
|
-
var index$1 = require(
|
|
5
|
-
var index = require(
|
|
6
|
-
var useHForm = require(
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
|
|
8
|
-
|
|
7
|
+
open?: any;
|
|
8
|
+
close?: any;
|
|
9
9
|
}
|
|
10
10
|
type NameProvider = (name: string) => string;
|
|
11
11
|
export interface DateRangePickerValueMapModal {
|
|
12
|
-
|
|
13
|
-
|
|
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-
|
|
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.
|
|
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
|
|
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
|
|
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,
|
|
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(
|
|
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
|
-
|
|
48
|
-
|
|
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(
|
|
79
|
+
addDispatchListener(action, fn) {
|
|
80
|
+
const { key, name } = action;
|
|
52
81
|
const items = dispatchSourceData[key];
|
|
53
82
|
if (!items) {
|
|
54
|
-
dispatchSourceData[key] =
|
|
83
|
+
dispatchSourceData[key] = norAddItemDispatch(name, fn);
|
|
55
84
|
return;
|
|
56
85
|
}
|
|
57
|
-
items
|
|
58
|
-
|
|
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(
|
|
61
|
-
if (!
|
|
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
|
|
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: (
|
|
116
|
+
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
114
117
|
outputValues: (values?: Record<string, any>) => Record<string, any>;
|
|
115
|
-
addDispatchListener: (
|
|
116
|
-
removeDispatchListener: (
|
|
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
|
-
|
|
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;
|
package/src/pages/Form/index.tsx
CHANGED