@hw-component/form 0.0.8-beta-v9 → 0.0.9-beta-v1
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 +10 -5
- package/es/Form/hooks/useHForm.js +1 -0
- package/lib/DialogForm/hooks.js +10 -5
- package/lib/Form/hooks/useHForm.js +1 -0
- package/package.json +1 -1
- package/src/components/DialogForm/hooks.ts +10 -5
- package/src/components/Form/hooks/useHForm.ts +1 -0
- package/src/pages/DrawerForm/index.tsx +3 -3
- package/src/pages/ModalForm/index.tsx +0 -5
package/es/DialogForm/hooks.js
CHANGED
|
@@ -46,12 +46,16 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
46
46
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
47
47
|
modalTitle = _useState10[0],
|
|
48
48
|
setModalTitle = _useState10[1];
|
|
49
|
+
var saveOldParamsObj = useMemo(function () {
|
|
50
|
+
return {
|
|
51
|
+
old: {}
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
49
54
|
var onAfterClose = function onAfterClose() {
|
|
50
55
|
onCancel === null || onCancel === void 0 || onCancel();
|
|
56
|
+
saveOldParamsObj.old = dialogForm.outputValues();
|
|
51
57
|
setTimeout(function () {
|
|
52
|
-
|
|
53
|
-
dialogForm.clear();
|
|
54
|
-
}
|
|
58
|
+
dialogForm.clear();
|
|
55
59
|
afterClose === null || afterClose === void 0 || afterClose();
|
|
56
60
|
}, 100);
|
|
57
61
|
};
|
|
@@ -86,14 +90,15 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
86
90
|
if (!!changeTitle) {
|
|
87
91
|
setModalTitle(changeTitle);
|
|
88
92
|
}
|
|
89
|
-
|
|
93
|
+
var relChangeInitVal = autoClear ? changeInitialValues : _objectSpread(_objectSpread({}, saveOldParamsObj.old), changeInitialValues);
|
|
94
|
+
setInitValue(relChangeInitVal);
|
|
90
95
|
setModalVisible(true);
|
|
91
96
|
};
|
|
92
97
|
dialogForm.hide = function () {
|
|
93
98
|
setModalVisible(false);
|
|
94
99
|
onAfterClose();
|
|
95
100
|
};
|
|
96
|
-
}, [afterClose]);
|
|
101
|
+
}, [afterClose, autoClear]);
|
|
97
102
|
return {
|
|
98
103
|
modalFormData: modalFormData,
|
|
99
104
|
modalVisible: modalVisible,
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -47,12 +47,16 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
47
47
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
48
48
|
modalTitle = _useState10[0],
|
|
49
49
|
setModalTitle = _useState10[1];
|
|
50
|
+
var saveOldParamsObj = React.useMemo(function () {
|
|
51
|
+
return {
|
|
52
|
+
old: {}
|
|
53
|
+
};
|
|
54
|
+
}, []);
|
|
50
55
|
var onAfterClose = function onAfterClose() {
|
|
51
56
|
onCancel === null || onCancel === void 0 || onCancel();
|
|
57
|
+
saveOldParamsObj.old = dialogForm.outputValues();
|
|
52
58
|
setTimeout(function () {
|
|
53
|
-
|
|
54
|
-
dialogForm.clear();
|
|
55
|
-
}
|
|
59
|
+
dialogForm.clear();
|
|
56
60
|
afterClose === null || afterClose === void 0 || afterClose();
|
|
57
61
|
}, 100);
|
|
58
62
|
};
|
|
@@ -87,14 +91,15 @@ var useModifyProps = function useModifyProps(_ref) {
|
|
|
87
91
|
if (!!changeTitle) {
|
|
88
92
|
setModalTitle(changeTitle);
|
|
89
93
|
}
|
|
90
|
-
|
|
94
|
+
var relChangeInitVal = autoClear ? changeInitialValues : _objectSpread(_objectSpread({}, saveOldParamsObj.old), changeInitialValues);
|
|
95
|
+
setInitValue(relChangeInitVal);
|
|
91
96
|
setModalVisible(true);
|
|
92
97
|
};
|
|
93
98
|
dialogForm.hide = function () {
|
|
94
99
|
setModalVisible(false);
|
|
95
100
|
onAfterClose();
|
|
96
101
|
};
|
|
97
|
-
}, [afterClose]);
|
|
102
|
+
}, [afterClose, autoClear]);
|
|
98
103
|
return {
|
|
99
104
|
modalFormData: modalFormData,
|
|
100
105
|
modalVisible: modalVisible,
|
package/package.json
CHANGED
|
@@ -23,12 +23,16 @@ export const useModifyProps = ({
|
|
|
23
23
|
const [initValue, setInitValue] = useState(initialValues);
|
|
24
24
|
const [formParams, setFormParams] = useState(params);
|
|
25
25
|
const [modalTitle, setModalTitle] = useState(title);
|
|
26
|
+
const saveOldParamsObj=useMemo(()=>{
|
|
27
|
+
return {
|
|
28
|
+
old:{}
|
|
29
|
+
}
|
|
30
|
+
},[]);
|
|
26
31
|
const onAfterClose = () => {
|
|
27
32
|
onCancel?.();
|
|
33
|
+
saveOldParamsObj.old=dialogForm.outputValues();
|
|
28
34
|
setTimeout(() => {
|
|
29
|
-
|
|
30
|
-
dialogForm.clear();
|
|
31
|
-
}
|
|
35
|
+
dialogForm.clear();
|
|
32
36
|
afterClose?.();
|
|
33
37
|
}, 100);
|
|
34
38
|
};
|
|
@@ -64,14 +68,15 @@ export const useModifyProps = ({
|
|
|
64
68
|
if (!!changeTitle) {
|
|
65
69
|
setModalTitle(changeTitle);
|
|
66
70
|
}
|
|
67
|
-
|
|
71
|
+
const relChangeInitVal=autoClear?changeInitialValues:{...saveOldParamsObj.old,...changeInitialValues};
|
|
72
|
+
setInitValue(relChangeInitVal);
|
|
68
73
|
setModalVisible(true);
|
|
69
74
|
};
|
|
70
75
|
dialogForm.hide = () => {
|
|
71
76
|
setModalVisible(false);
|
|
72
77
|
onAfterClose();
|
|
73
78
|
};
|
|
74
|
-
}, [afterClose]);
|
|
79
|
+
}, [afterClose,autoClear]);
|
|
75
80
|
return {
|
|
76
81
|
modalFormData,
|
|
77
82
|
modalVisible,
|
|
@@ -107,19 +107,19 @@ const data = [
|
|
|
107
107
|
},
|
|
108
108
|
},
|
|
109
109
|
];
|
|
110
|
+
let num=0
|
|
110
111
|
export default () => {
|
|
111
112
|
const modalForm = useHDialogForm();
|
|
112
113
|
return (
|
|
113
114
|
<>
|
|
114
115
|
<Button
|
|
115
116
|
onClick={() => {
|
|
117
|
+
num++
|
|
116
118
|
modalForm.show({
|
|
117
119
|
initialValues: {
|
|
118
120
|
check1: 1,
|
|
119
|
-
testStart: "1694747960",
|
|
120
|
-
testEnd: "1693538359",
|
|
121
121
|
op: 1,
|
|
122
|
-
opInput:
|
|
122
|
+
opInput:num,
|
|
123
123
|
},
|
|
124
124
|
});
|
|
125
125
|
}}
|
|
@@ -165,7 +165,6 @@ export default () => {
|
|
|
165
165
|
<HFormConfigProvider
|
|
166
166
|
uploadProps={{
|
|
167
167
|
request: () => {
|
|
168
|
-
console.log("request,request,request,request");
|
|
169
168
|
return Promise.resolve({
|
|
170
169
|
url: "https://gw.alicdn.com/imgextra/i2/O1CN01MYuwJQ1GXVBWryCFJ_!!6000000000632-2-tps-1125-570.png_468x468q75.jpg_.webp",
|
|
171
170
|
});
|
|
@@ -175,7 +174,6 @@ export default () => {
|
|
|
175
174
|
<HModalForm
|
|
176
175
|
configData={data}
|
|
177
176
|
labelWidth={88}
|
|
178
|
-
autoClear={false}
|
|
179
177
|
contentRender={(node, form) => {
|
|
180
178
|
return (
|
|
181
179
|
<div>
|
|
@@ -184,9 +182,6 @@ export default () => {
|
|
|
184
182
|
</div>
|
|
185
183
|
);
|
|
186
184
|
}}
|
|
187
|
-
request={(val, params) => {
|
|
188
|
-
console.log(val, params);
|
|
189
|
-
}}
|
|
190
185
|
dialogForm={modalForm}
|
|
191
186
|
title="测试"
|
|
192
187
|
/>
|