@hw-component/form 0.0.6-beta-v2 → 0.0.6-beta-v4
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/DialogForm/hooks.js +5 -5
- package/es/Form/hooks/index.js +8 -7
- package/es/Form/hooks/useHForm.js +4 -0
- package/lib/DialogForm/hooks.js +5 -5
- package/lib/Form/hooks/index.js +8 -7
- package/lib/Form/hooks/useHForm.js +4 -0
- package/package.json +8 -8
- package/scripts/rollup.config.js +14 -11
- package/src/components/DialogForm/hooks.ts +3 -5
- package/src/components/Form/hooks/index.ts +1 -0
- package/src/components/Form/hooks/useHForm.ts +4 -0
- package/src/components/Input/ColorInput/index.tsx +12 -4
- package/src/components/Input/modal.ts +1 -1
- package/src/components/config.ts +2 -2
- package/src/pages/DrawerForm/index.tsx +10 -2
- package/src/pages/Form/index.tsx +11 -13
- package/src/pages/ModalForm/index.tsx +14 -1
package/es/DialogForm/hooks.js
CHANGED
|
@@ -66,15 +66,15 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
66
66
|
dialogForm.show = function () {
|
|
67
67
|
var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
68
|
var changeConfigData = showParams.configData,
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
_showParams$initialVa = showParams.initialValues,
|
|
70
|
+
changeInitialValues = _showParams$initialVa === void 0 ? {} : _showParams$initialVa,
|
|
71
|
+
_showParams$params = showParams.params,
|
|
72
|
+
changeParams = _showParams$params === void 0 ? {} : _showParams$params,
|
|
71
73
|
changeTitle = showParams.title;
|
|
72
74
|
if (!!changeConfigData) {
|
|
73
75
|
setModalFormData(changeConfigData);
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
setFormParams(changeParams);
|
|
77
|
-
}
|
|
77
|
+
setFormParams(changeParams);
|
|
78
78
|
if (!!changeTitle) {
|
|
79
79
|
setModalTitle(changeTitle);
|
|
80
80
|
}
|
package/es/Form/hooks/index.js
CHANGED
|
@@ -72,23 +72,24 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
72
72
|
setValue = initialValues;
|
|
73
73
|
reqData.params = reqParams;
|
|
74
74
|
if (!(!initialValues && !infoRequest)) {
|
|
75
|
-
_context2.next =
|
|
75
|
+
_context2.next = 6;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
|
+
form === null || form === void 0 || form.setFieldsValue({});
|
|
78
79
|
return _context2.abrupt("return", {});
|
|
79
|
-
case
|
|
80
|
+
case 6:
|
|
80
81
|
if (!infoRequest) {
|
|
81
|
-
_context2.next =
|
|
82
|
+
_context2.next = 10;
|
|
82
83
|
break;
|
|
83
84
|
}
|
|
84
|
-
_context2.next =
|
|
85
|
+
_context2.next = 9;
|
|
85
86
|
return infoRequest(reqParams);
|
|
86
|
-
case 8:
|
|
87
|
-
setValue = _context2.sent;
|
|
88
87
|
case 9:
|
|
88
|
+
setValue = _context2.sent;
|
|
89
|
+
case 10:
|
|
89
90
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
90
91
|
return _context2.abrupt("return", setValue || {});
|
|
91
|
-
case
|
|
92
|
+
case 12:
|
|
92
93
|
case "end":
|
|
93
94
|
return _context2.stop();
|
|
94
95
|
}
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -67,15 +67,15 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
67
67
|
dialogForm.show = function () {
|
|
68
68
|
var showParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
69
69
|
var changeConfigData = showParams.configData,
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
_showParams$initialVa = showParams.initialValues,
|
|
71
|
+
changeInitialValues = _showParams$initialVa === void 0 ? {} : _showParams$initialVa,
|
|
72
|
+
_showParams$params = showParams.params,
|
|
73
|
+
changeParams = _showParams$params === void 0 ? {} : _showParams$params,
|
|
72
74
|
changeTitle = showParams.title;
|
|
73
75
|
if (!!changeConfigData) {
|
|
74
76
|
setModalFormData(changeConfigData);
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
setFormParams(changeParams);
|
|
78
|
-
}
|
|
78
|
+
setFormParams(changeParams);
|
|
79
79
|
if (!!changeTitle) {
|
|
80
80
|
setModalTitle(changeTitle);
|
|
81
81
|
}
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -73,23 +73,24 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
73
73
|
setValue = initialValues;
|
|
74
74
|
reqData.params = reqParams;
|
|
75
75
|
if (!(!initialValues && !infoRequest)) {
|
|
76
|
-
_context2.next =
|
|
76
|
+
_context2.next = 6;
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
|
+
form === null || form === void 0 || form.setFieldsValue({});
|
|
79
80
|
return _context2.abrupt("return", {});
|
|
80
|
-
case
|
|
81
|
+
case 6:
|
|
81
82
|
if (!infoRequest) {
|
|
82
|
-
_context2.next =
|
|
83
|
+
_context2.next = 10;
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
|
-
_context2.next =
|
|
86
|
+
_context2.next = 9;
|
|
86
87
|
return infoRequest(reqParams);
|
|
87
|
-
case 8:
|
|
88
|
-
setValue = _context2.sent;
|
|
89
88
|
case 9:
|
|
89
|
+
setValue = _context2.sent;
|
|
90
|
+
case 10:
|
|
90
91
|
form === null || form === void 0 || form.setFieldsValue(setValue);
|
|
91
92
|
return _context2.abrupt("return", setValue || {});
|
|
92
|
-
case
|
|
93
|
+
case 12:
|
|
93
94
|
case "end":
|
|
94
95
|
return _context2.stop();
|
|
95
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "0.0.6-beta-
|
|
3
|
+
"version": "0.0.6-beta-v4",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,6 +26,12 @@
|
|
|
26
26
|
"prettier --write"
|
|
27
27
|
]
|
|
28
28
|
},
|
|
29
|
+
"browserslist": [
|
|
30
|
+
"> 0.5%",
|
|
31
|
+
"last 2 versions",
|
|
32
|
+
"Firefox ESR",
|
|
33
|
+
"not dead"
|
|
34
|
+
],
|
|
29
35
|
"dependencies": {
|
|
30
36
|
"@ant-design/icons": "4.6.2",
|
|
31
37
|
"@types/react-color": "^3.0.9",
|
|
@@ -80,11 +86,5 @@
|
|
|
80
86
|
"webpack-dev-server": "^4.15.0",
|
|
81
87
|
"webpackbar": "^5.0.2"
|
|
82
88
|
},
|
|
83
|
-
"cssPrefix": "hw"
|
|
84
|
-
"browserslist": [
|
|
85
|
-
"> 0.5%",
|
|
86
|
-
"last 2 versions",
|
|
87
|
-
"Firefox ESR",
|
|
88
|
-
"not dead"
|
|
89
|
-
]
|
|
89
|
+
"cssPrefix": "hw"
|
|
90
90
|
}
|
package/scripts/rollup.config.js
CHANGED
|
@@ -61,17 +61,20 @@ module.exports = {
|
|
|
61
61
|
exclude: "node_modules/**",
|
|
62
62
|
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
63
63
|
babelHelpers: "runtime",
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
presets: [
|
|
65
|
+
[
|
|
66
|
+
"@babel/preset-env",
|
|
67
|
+
{
|
|
68
|
+
targets: {
|
|
69
|
+
chrome: "58",
|
|
70
|
+
ie: "11",
|
|
71
|
+
ios: "11",
|
|
72
|
+
},
|
|
73
|
+
useBuiltIns: "usage",
|
|
74
|
+
corejs: 3,
|
|
75
|
+
modules: false,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
75
78
|
],
|
|
76
79
|
}),
|
|
77
80
|
inject({
|
|
@@ -45,16 +45,14 @@ export const useModifyProps = ({
|
|
|
45
45
|
dialogForm.show = (showParams = {}) => {
|
|
46
46
|
const {
|
|
47
47
|
configData: changeConfigData,
|
|
48
|
-
initialValues: changeInitialValues,
|
|
49
|
-
params: changeParams,
|
|
48
|
+
initialValues: changeInitialValues={},
|
|
49
|
+
params: changeParams={},
|
|
50
50
|
title: changeTitle,
|
|
51
51
|
} = showParams;
|
|
52
52
|
if (!!changeConfigData) {
|
|
53
53
|
setModalFormData(changeConfigData);
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
setFormParams(changeParams);
|
|
57
|
-
}
|
|
55
|
+
setFormParams(changeParams);
|
|
58
56
|
if (!!changeTitle) {
|
|
59
57
|
setModalTitle(changeTitle);
|
|
60
58
|
}
|
|
@@ -3,11 +3,16 @@ import { Input, Popover } from "antd";
|
|
|
3
3
|
import Picker from "./Picker";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useClassName } from "../../hooks";
|
|
6
|
-
export default ({
|
|
6
|
+
export default ({
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
defaultColor = "rgba(0,0,0,1)",
|
|
10
|
+
...props
|
|
11
|
+
}: HInputProps) => {
|
|
7
12
|
const classname = useClassName("hw-color-box");
|
|
8
|
-
const inputVal=value?.trim();
|
|
13
|
+
const inputVal = value?.trim();
|
|
9
14
|
const pickerValue = useMemo(() => {
|
|
10
|
-
const
|
|
15
|
+
const matchVal = inputVal || defaultColor;
|
|
11
16
|
if (typeof matchVal === "string") {
|
|
12
17
|
if (matchVal.startsWith("#")) {
|
|
13
18
|
return matchVal;
|
|
@@ -42,7 +47,10 @@ export default ({ value, onChange,defaultColor="rgba(0,0,0,1)", ...props }: HInp
|
|
|
42
47
|
content={<Picker value={pickerValue} onChange={colorChange} />}
|
|
43
48
|
placement="topLeft"
|
|
44
49
|
>
|
|
45
|
-
<div
|
|
50
|
+
<div
|
|
51
|
+
style={{ backgroundColor: inputVal || defaultColor }}
|
|
52
|
+
className={classname}
|
|
53
|
+
/>
|
|
46
54
|
</Popover>
|
|
47
55
|
}
|
|
48
56
|
/>
|
package/src/components/config.ts
CHANGED
|
@@ -114,12 +114,20 @@ export default () => {
|
|
|
114
114
|
});
|
|
115
115
|
}}
|
|
116
116
|
>
|
|
117
|
-
|
|
117
|
+
显示
|
|
118
|
+
</Button>
|
|
119
|
+
<Button
|
|
120
|
+
onClick={() => {
|
|
121
|
+
modalForm.show();
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
打开
|
|
118
125
|
</Button>
|
|
119
126
|
<HDrawerForm
|
|
127
|
+
|
|
120
128
|
configData={data}
|
|
121
129
|
labelWidth={88}
|
|
122
|
-
|
|
130
|
+
dialogForm={modalForm}
|
|
123
131
|
title="测试"
|
|
124
132
|
/>
|
|
125
133
|
</>
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -150,7 +150,9 @@ export default () => {
|
|
|
150
150
|
configData={formData(options)}
|
|
151
151
|
labelWidth={200}
|
|
152
152
|
form={form}
|
|
153
|
-
initialValues={{
|
|
153
|
+
initialValues={{
|
|
154
|
+
name:'fff'
|
|
155
|
+
}}
|
|
154
156
|
onFinish={(value) => {
|
|
155
157
|
console.log(value);
|
|
156
158
|
}}
|
|
@@ -182,22 +184,18 @@ export default () => {
|
|
|
182
184
|
</HFormConfigProvider>
|
|
183
185
|
<div
|
|
184
186
|
onClick={() => {
|
|
185
|
-
form.
|
|
186
|
-
{
|
|
187
|
-
name: "select",
|
|
188
|
-
key: "reload",
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
params: {
|
|
192
|
-
label: "更新",
|
|
193
|
-
value: 2,
|
|
194
|
-
},
|
|
195
|
-
}
|
|
196
|
-
);
|
|
187
|
+
form.setFieldsValue({name:"123"})
|
|
197
188
|
}}
|
|
198
189
|
>
|
|
199
190
|
点我
|
|
200
191
|
</div>
|
|
192
|
+
<div
|
|
193
|
+
onClick={() => {
|
|
194
|
+
form.resetFields();
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
重置
|
|
198
|
+
</div>
|
|
201
199
|
</div>
|
|
202
200
|
);
|
|
203
201
|
};
|
|
@@ -107,7 +107,6 @@ const data = [
|
|
|
107
107
|
},
|
|
108
108
|
itemProps: {
|
|
109
109
|
request: (params = {}, values) => {
|
|
110
|
-
console.log(values, "paramsparamsparams");
|
|
111
110
|
const { label = "123", value = 1 } = params;
|
|
112
111
|
return Promise.resolve([{ label, value }]);
|
|
113
112
|
},
|
|
@@ -133,6 +132,20 @@ export default () => {
|
|
|
133
132
|
>
|
|
134
133
|
打开
|
|
135
134
|
</Button>
|
|
135
|
+
<Button
|
|
136
|
+
onClick={() => {
|
|
137
|
+
modalForm.show({
|
|
138
|
+
params: {
|
|
139
|
+
name: num,
|
|
140
|
+
},
|
|
141
|
+
initialValues:{
|
|
142
|
+
name:"name"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
宣誓
|
|
148
|
+
</Button>
|
|
136
149
|
<HModalForm
|
|
137
150
|
configData={data}
|
|
138
151
|
labelWidth={88}
|