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