@hw-component/form 1.10.77 → 1.10.79
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/DrawerForm/index.js +3 -1
- package/es/DialogForm/ModalForm.js +3 -1
- package/es/DialogForm/hooks.d.ts +7 -1
- package/es/DialogForm/hooks.js +46 -28
- package/es/Input/ButtonInput.js +2 -1
- package/lib/DialogForm/DrawerForm/index.js +3 -1
- package/lib/DialogForm/ModalForm.js +3 -1
- package/lib/DialogForm/hooks.d.ts +7 -1
- package/lib/DialogForm/hooks.js +46 -28
- package/lib/Input/ButtonInput.js +2 -1
- package/package.json +1 -1
- package/src/components/DialogForm/DrawerForm/index.tsx +2 -1
- package/src/components/DialogForm/ModalForm.tsx +2 -1
- package/src/components/DialogForm/hooks.tsx +13 -2
- package/src/components/Input/ButtonInput.tsx +1 -1
- package/src/pages/ModalForm/index.tsx +12 -0
|
@@ -72,7 +72,8 @@ var Index = function Index(_ref) {
|
|
|
72
72
|
onFinish: onFinish
|
|
73
73
|
}),
|
|
74
74
|
loading = _useSub.loading,
|
|
75
|
-
run = _useSub.run
|
|
75
|
+
run = _useSub.run,
|
|
76
|
+
setLoading = _useSub.setLoading;
|
|
76
77
|
var finish = /*#__PURE__*/function () {
|
|
77
78
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
78
79
|
var result, close;
|
|
@@ -149,6 +150,7 @@ var Index = function Index(_ref) {
|
|
|
149
150
|
}
|
|
150
151
|
selfAfterClose();
|
|
151
152
|
afterClose === null || afterClose === void 0 || afterClose();
|
|
153
|
+
setLoading(false);
|
|
152
154
|
},
|
|
153
155
|
closable: false,
|
|
154
156
|
destroyOnClose: destroyOnClose,
|
|
@@ -66,7 +66,8 @@ var Index = function Index(_ref) {
|
|
|
66
66
|
onFinish: onFinish
|
|
67
67
|
}),
|
|
68
68
|
loading = _useSub.loading,
|
|
69
|
-
run = _useSub.run
|
|
69
|
+
run = _useSub.run,
|
|
70
|
+
setLoading = _useSub.setLoading;
|
|
70
71
|
var finish = /*#__PURE__*/function () {
|
|
71
72
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
72
73
|
var result, close;
|
|
@@ -134,6 +135,7 @@ var Index = function Index(_ref) {
|
|
|
134
135
|
afterClose: function afterClose() {
|
|
135
136
|
selfAfterClose();
|
|
136
137
|
_afterClose === null || _afterClose === void 0 || _afterClose();
|
|
138
|
+
setLoading(false);
|
|
137
139
|
}
|
|
138
140
|
}, props), {}, {
|
|
139
141
|
onOk: currentForm.submit,
|
package/es/DialogForm/hooks.d.ts
CHANGED
|
@@ -13,7 +13,13 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
|
|
|
13
13
|
};
|
|
14
14
|
export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
|
|
15
15
|
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
|
|
16
|
-
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) =>
|
|
16
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
17
|
+
data: any;
|
|
18
|
+
error: Error | undefined;
|
|
19
|
+
run: (values: any, params: any) => Promise<any>;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
22
|
+
};
|
|
17
23
|
interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
|
|
18
24
|
onOk: VoidFunction;
|
|
19
25
|
}
|
package/es/DialogForm/hooks.js
CHANGED
|
@@ -143,34 +143,52 @@ var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
|
143
143
|
var useSub = function useSub(_ref2) {
|
|
144
144
|
var request = _ref2.request,
|
|
145
145
|
onFinish = _ref2.onFinish;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
var _useState11 = useState(false),
|
|
147
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
148
|
+
loading = _useState12[0],
|
|
149
|
+
setLoading = _useState12[1];
|
|
150
|
+
var _useRequest = useRequest(/*#__PURE__*/function () {
|
|
151
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
|
|
152
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
153
|
+
while (1) switch (_context.prev = _context.next) {
|
|
154
|
+
case 0:
|
|
155
|
+
setLoading(true);
|
|
156
|
+
if (!onFinish) {
|
|
157
|
+
_context.next = 3;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
return _context.abrupt("return", onFinish(values, params));
|
|
161
|
+
case 3:
|
|
162
|
+
if (!request) {
|
|
163
|
+
_context.next = 5;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context.abrupt("return", request(values, params));
|
|
167
|
+
case 5:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee);
|
|
172
|
+
}));
|
|
173
|
+
return function (_x, _x2) {
|
|
174
|
+
return _ref3.apply(this, arguments);
|
|
175
|
+
};
|
|
176
|
+
}(), {
|
|
177
|
+
manual: true,
|
|
178
|
+
onError: function onError() {
|
|
179
|
+
setLoading(false);
|
|
180
|
+
}
|
|
181
|
+
}),
|
|
182
|
+
data = _useRequest.data,
|
|
183
|
+
error = _useRequest.error,
|
|
184
|
+
run = _useRequest.run;
|
|
185
|
+
return {
|
|
186
|
+
data: data,
|
|
187
|
+
error: error,
|
|
188
|
+
run: run,
|
|
189
|
+
loading: loading,
|
|
190
|
+
setLoading: setLoading
|
|
191
|
+
};
|
|
174
192
|
};
|
|
175
193
|
var useFooterRender = function useFooterRender(_ref4) {
|
|
176
194
|
var footer = _ref4.footer,
|
package/es/Input/ButtonInput.js
CHANGED
|
@@ -75,7 +75,8 @@ var Index = function Index(_ref) {
|
|
|
75
75
|
onFinish: onFinish
|
|
76
76
|
}),
|
|
77
77
|
loading = _useSub.loading,
|
|
78
|
-
run = _useSub.run
|
|
78
|
+
run = _useSub.run,
|
|
79
|
+
setLoading = _useSub.setLoading;
|
|
79
80
|
var finish = /*#__PURE__*/function () {
|
|
80
81
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, subParams) {
|
|
81
82
|
var result, close;
|
|
@@ -152,6 +153,7 @@ var Index = function Index(_ref) {
|
|
|
152
153
|
}
|
|
153
154
|
selfAfterClose();
|
|
154
155
|
afterClose === null || afterClose === void 0 || afterClose();
|
|
156
|
+
setLoading(false);
|
|
155
157
|
},
|
|
156
158
|
closable: false,
|
|
157
159
|
destroyOnClose: destroyOnClose,
|
|
@@ -69,7 +69,8 @@ var Index = function Index(_ref) {
|
|
|
69
69
|
onFinish: onFinish
|
|
70
70
|
}),
|
|
71
71
|
loading = _useSub.loading,
|
|
72
|
-
run = _useSub.run
|
|
72
|
+
run = _useSub.run,
|
|
73
|
+
setLoading = _useSub.setLoading;
|
|
73
74
|
var finish = /*#__PURE__*/function () {
|
|
74
75
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, outParams) {
|
|
75
76
|
var result, close;
|
|
@@ -137,6 +138,7 @@ var Index = function Index(_ref) {
|
|
|
137
138
|
afterClose: function afterClose() {
|
|
138
139
|
selfAfterClose();
|
|
139
140
|
_afterClose === null || _afterClose === void 0 || _afterClose();
|
|
141
|
+
setLoading(false);
|
|
140
142
|
}
|
|
141
143
|
}, props), {}, {
|
|
142
144
|
onOk: currentForm.submit,
|
|
@@ -13,7 +13,13 @@ export declare const useModifyProps: ({ visible, configData, initialValues, dial
|
|
|
13
13
|
};
|
|
14
14
|
export declare const useHDialogForm: () => HDialogFormInstance<any, any>;
|
|
15
15
|
export declare const useCurrentForm: (hDialogForm?: HDialogFormInstance) => HDialogFormInstance<any, any>;
|
|
16
|
-
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) =>
|
|
16
|
+
export declare const useSub: ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
17
|
+
data: any;
|
|
18
|
+
error: Error | undefined;
|
|
19
|
+
run: (values: any, params: any) => Promise<any>;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
22
|
+
};
|
|
17
23
|
interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
|
|
18
24
|
onOk: VoidFunction;
|
|
19
25
|
}
|
package/lib/DialogForm/hooks.js
CHANGED
|
@@ -144,34 +144,52 @@ var useCurrentForm = function useCurrentForm(hDialogForm) {
|
|
|
144
144
|
var useSub = function useSub(_ref2) {
|
|
145
145
|
var request = _ref2.request,
|
|
146
146
|
onFinish = _ref2.onFinish;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
147
|
+
var _useState11 = React.useState(false),
|
|
148
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
149
|
+
loading = _useState12[0],
|
|
150
|
+
setLoading = _useState12[1];
|
|
151
|
+
var _useRequest = ahooks.useRequest(/*#__PURE__*/function () {
|
|
152
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
|
|
153
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
154
|
+
while (1) switch (_context.prev = _context.next) {
|
|
155
|
+
case 0:
|
|
156
|
+
setLoading(true);
|
|
157
|
+
if (!onFinish) {
|
|
158
|
+
_context.next = 3;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
return _context.abrupt("return", onFinish(values, params));
|
|
162
|
+
case 3:
|
|
163
|
+
if (!request) {
|
|
164
|
+
_context.next = 5;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
return _context.abrupt("return", request(values, params));
|
|
168
|
+
case 5:
|
|
169
|
+
case "end":
|
|
170
|
+
return _context.stop();
|
|
171
|
+
}
|
|
172
|
+
}, _callee);
|
|
173
|
+
}));
|
|
174
|
+
return function (_x, _x2) {
|
|
175
|
+
return _ref3.apply(this, arguments);
|
|
176
|
+
};
|
|
177
|
+
}(), {
|
|
178
|
+
manual: true,
|
|
179
|
+
onError: function onError() {
|
|
180
|
+
setLoading(false);
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
data = _useRequest.data,
|
|
184
|
+
error = _useRequest.error,
|
|
185
|
+
run = _useRequest.run;
|
|
186
|
+
return {
|
|
187
|
+
data: data,
|
|
188
|
+
error: error,
|
|
189
|
+
run: run,
|
|
190
|
+
loading: loading,
|
|
191
|
+
setLoading: setLoading
|
|
192
|
+
};
|
|
175
193
|
};
|
|
176
194
|
var useFooterRender = function useFooterRender(_ref4) {
|
|
177
195
|
var footer = _ref4.footer,
|
package/lib/Input/ButtonInput.js
CHANGED
package/package.json
CHANGED
|
@@ -65,7 +65,7 @@ const Index: React.FC<DialogFormProps> = ({
|
|
|
65
65
|
}
|
|
66
66
|
setModalVisible(false);
|
|
67
67
|
};
|
|
68
|
-
const { loading, run } = useSub({ request, onFinish });
|
|
68
|
+
const { loading, run,setLoading } = useSub({ request, onFinish });
|
|
69
69
|
const finish = async (values, subParams) => {
|
|
70
70
|
const result = await run(values, subParams);
|
|
71
71
|
const close = onOk?.(result, subParams);
|
|
@@ -121,6 +121,7 @@ const Index: React.FC<DialogFormProps> = ({
|
|
|
121
121
|
}
|
|
122
122
|
selfAfterClose();
|
|
123
123
|
afterClose?.();
|
|
124
|
+
setLoading(false);
|
|
124
125
|
}}
|
|
125
126
|
closable={false}
|
|
126
127
|
destroyOnClose={destroyOnClose}
|
|
@@ -61,7 +61,7 @@ const Index: React.FC<DialogFormProps> = ({
|
|
|
61
61
|
}
|
|
62
62
|
setModalVisible(false);
|
|
63
63
|
};
|
|
64
|
-
const { loading, run } = useSub({ request, onFinish });
|
|
64
|
+
const { loading, run ,setLoading} = useSub({ request, onFinish });
|
|
65
65
|
const finish = async (values, outParams) => {
|
|
66
66
|
const result = await run(values, outParams);
|
|
67
67
|
const close = onOk?.(result, outParams);
|
|
@@ -112,6 +112,7 @@ const Index: React.FC<DialogFormProps> = ({
|
|
|
112
112
|
afterClose={() => {
|
|
113
113
|
selfAfterClose();
|
|
114
114
|
afterClose?.();
|
|
115
|
+
setLoading(false);
|
|
115
116
|
}}
|
|
116
117
|
{...props}
|
|
117
118
|
onOk={currentForm.submit}
|
|
@@ -136,8 +136,10 @@ export const useCurrentForm = (hDialogForm?: HDialogFormInstance) => {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
139
|
-
|
|
139
|
+
const [loading,setLoading]=useState(false);
|
|
140
|
+
const {data,error,run}=useRequest(
|
|
140
141
|
async (values, params) => {
|
|
142
|
+
setLoading(true);
|
|
141
143
|
if (onFinish) {
|
|
142
144
|
return onFinish(values, params);
|
|
143
145
|
}
|
|
@@ -145,8 +147,17 @@ export const useSub = ({ request, onFinish }: Partial<DialogFormProps>) => {
|
|
|
145
147
|
return request(values, params);
|
|
146
148
|
}
|
|
147
149
|
},
|
|
148
|
-
{ manual: true
|
|
150
|
+
{ manual: true ,onError:()=>{
|
|
151
|
+
setLoading(false);
|
|
152
|
+
}}
|
|
149
153
|
);
|
|
154
|
+
return {
|
|
155
|
+
data,
|
|
156
|
+
error,
|
|
157
|
+
run,
|
|
158
|
+
loading,
|
|
159
|
+
setLoading
|
|
160
|
+
}
|
|
150
161
|
};
|
|
151
162
|
interface FooterRenderParamsModal extends Omit<DialogFormProps, "configData"> {
|
|
152
163
|
onOk: VoidFunction;
|
|
@@ -22,6 +22,14 @@ const data = [
|
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
];
|
|
25
|
+
|
|
26
|
+
const time=async ()=>{
|
|
27
|
+
return new Promise((resolve,reject)=>{
|
|
28
|
+
return setTimeout(()=>{
|
|
29
|
+
reject()
|
|
30
|
+
},3000)
|
|
31
|
+
})
|
|
32
|
+
}
|
|
25
33
|
export default () => {
|
|
26
34
|
const modalForm = useHDialogForm();
|
|
27
35
|
return (
|
|
@@ -62,6 +70,10 @@ export default () => {
|
|
|
62
70
|
}}
|
|
63
71
|
labelAlign={"left"}
|
|
64
72
|
dialogForm={modalForm}
|
|
73
|
+
request={async ()=>{
|
|
74
|
+
console.log("fff");
|
|
75
|
+
await time();
|
|
76
|
+
}}
|
|
65
77
|
title="你好"
|
|
66
78
|
/>
|
|
67
79
|
</HFormConfigProvider>
|