@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.
@@ -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,
@@ -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>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
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
  }
@@ -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
- return useRequest(/*#__PURE__*/function () {
147
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
148
- return _regeneratorRuntime.wrap(function _callee$(_context) {
149
- while (1) switch (_context.prev = _context.next) {
150
- case 0:
151
- if (!onFinish) {
152
- _context.next = 2;
153
- break;
154
- }
155
- return _context.abrupt("return", onFinish(values, params));
156
- case 2:
157
- if (!request) {
158
- _context.next = 4;
159
- break;
160
- }
161
- return _context.abrupt("return", request(values, params));
162
- case 4:
163
- case "end":
164
- return _context.stop();
165
- }
166
- }, _callee);
167
- }));
168
- return function (_x, _x2) {
169
- return _ref3.apply(this, arguments);
170
- };
171
- }(), {
172
- manual: true
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,
@@ -82,7 +82,8 @@ var Index = function Index(_ref) {
82
82
  }
83
83
  return jsxs("div", {
84
84
  style: {
85
- display: "flex"
85
+ display: "flex",
86
+ width: "100%"
86
87
  },
87
88
  children: [jsx(Input, _objectSpread(_objectSpread({}, props), {}, {
88
89
  style: {
@@ -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>) => import("@ahooksjs/use-request/lib/types").BaseResult<any, [values: any, params: any]>;
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
  }
@@ -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
- return ahooks.useRequest(/*#__PURE__*/function () {
148
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(values, params) {
149
- return _regeneratorRuntime.wrap(function _callee$(_context) {
150
- while (1) switch (_context.prev = _context.next) {
151
- case 0:
152
- if (!onFinish) {
153
- _context.next = 2;
154
- break;
155
- }
156
- return _context.abrupt("return", onFinish(values, params));
157
- case 2:
158
- if (!request) {
159
- _context.next = 4;
160
- break;
161
- }
162
- return _context.abrupt("return", request(values, params));
163
- case 4:
164
- case "end":
165
- return _context.stop();
166
- }
167
- }, _callee);
168
- }));
169
- return function (_x, _x2) {
170
- return _ref3.apply(this, arguments);
171
- };
172
- }(), {
173
- manual: true
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,
@@ -85,7 +85,8 @@ var Index = function Index(_ref) {
85
85
  }
86
86
  return jsxRuntime.jsxs("div", {
87
87
  style: {
88
- display: "flex"
88
+ display: "flex",
89
+ width: "100%"
89
90
  },
90
91
  children: [jsxRuntime.jsx(antd.Input, _objectSpread(_objectSpread({}, props), {}, {
91
92
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.10.77",
3
+ "version": "1.10.79",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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
- return useRequest(
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;
@@ -58,7 +58,7 @@ const Index: React.FC<HButtonInputProps> = ({
58
58
  );
59
59
  }
60
60
  return (
61
- <div style={{ display: "flex" }}>
61
+ <div style={{ display: "flex",width: "100%" }}>
62
62
  <Input {...props} style={{ flex: 1 }} value={value} onChange={change} />
63
63
  <Btn
64
64
  type={btnType}
@@ -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>