@bluemarble/bm-components 1.9.1 → 1.9.2
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/dist/index.js +42 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4209,44 +4209,50 @@ function useFormHelper() {
|
|
|
4209
4209
|
const { createAlert } = alertProps;
|
|
4210
4210
|
const { setLoading } = loadingProps;
|
|
4211
4211
|
const sourceRef = _react.useRef.call(void 0, new AbortController());
|
|
4212
|
-
const onSubmitWrapper = (
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4212
|
+
const onSubmitWrapper = _react.useCallback.call(void 0,
|
|
4213
|
+
(fn, { name }) => {
|
|
4214
|
+
return (fields, methods) => __async(this, null, function* () {
|
|
4215
|
+
const LOADING_NAME = name;
|
|
4216
|
+
setLoading(LOADING_NAME);
|
|
4217
|
+
try {
|
|
4218
|
+
yield fn(fields, methods);
|
|
4219
|
+
} catch (error) {
|
|
4220
|
+
errorHandler(error, methods.setErrors);
|
|
4221
|
+
} finally {
|
|
4222
|
+
setLoading(LOADING_NAME, true);
|
|
4223
|
+
}
|
|
4224
|
+
});
|
|
4225
|
+
},
|
|
4226
|
+
[setLoading]
|
|
4227
|
+
);
|
|
4228
|
+
const onRequestWrapper = _react.useCallback.call(void 0,
|
|
4229
|
+
(fn, { name }) => {
|
|
4230
|
+
return (...params) => __async(this, null, function* () {
|
|
4231
|
+
const LOADING_NAME = name;
|
|
4232
|
+
setLoading(LOADING_NAME);
|
|
4233
|
+
api.interceptors.request.use(
|
|
4234
|
+
(config) => {
|
|
4235
|
+
if (!config.signal && sourceRef.current && config.method === "get") {
|
|
4236
|
+
config.signal = sourceRef.current.signal;
|
|
4237
|
+
}
|
|
4238
|
+
return config;
|
|
4239
|
+
},
|
|
4240
|
+
(error) => {
|
|
4241
|
+
return Promise.reject(error);
|
|
4233
4242
|
}
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
return
|
|
4243
|
+
);
|
|
4244
|
+
try {
|
|
4245
|
+
const response = yield fn(...params);
|
|
4246
|
+
return response;
|
|
4247
|
+
} catch (error) {
|
|
4248
|
+
errorHandler(error);
|
|
4249
|
+
} finally {
|
|
4250
|
+
setLoading(LOADING_NAME, true);
|
|
4238
4251
|
}
|
|
4239
|
-
);
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
} catch (error) {
|
|
4244
|
-
errorHandler(error);
|
|
4245
|
-
} finally {
|
|
4246
|
-
setLoading(LOADING_NAME, true);
|
|
4247
|
-
}
|
|
4248
|
-
});
|
|
4249
|
-
};
|
|
4252
|
+
});
|
|
4253
|
+
},
|
|
4254
|
+
[setLoading, api]
|
|
4255
|
+
);
|
|
4250
4256
|
const errorHandler = _react.useCallback.call(void 0,
|
|
4251
4257
|
(error, callback) => {
|
|
4252
4258
|
if ((error == null ? void 0 : error.message) === "cancel.navigation")
|