@bluemarble/bm-components 0.1.4 → 0.1.5
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 +5 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3989,7 +3989,6 @@ var ApiHelper = class _ApiHelper {
|
|
|
3989
3989
|
};
|
|
3990
3990
|
|
|
3991
3991
|
// src/hooks/useFormHelper.ts
|
|
3992
|
-
var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
|
|
3993
3992
|
|
|
3994
3993
|
|
|
3995
3994
|
// src/hooks/useAlert.ts
|
|
@@ -4093,7 +4092,7 @@ function useFormHelper() {
|
|
|
4093
4092
|
const { api, formatErrorMessage } = _react.useContext.call(void 0, FormHelperContext);
|
|
4094
4093
|
const { createAlert } = alertProps;
|
|
4095
4094
|
const { setLoading } = loadingProps;
|
|
4096
|
-
const sourceRef = _react.useRef.call(void 0, );
|
|
4095
|
+
const sourceRef = _react.useRef.call(void 0, new AbortController());
|
|
4097
4096
|
function onSubmitWrapper(fn, { name }) {
|
|
4098
4097
|
return (fields, methods) => __async(this, null, function* () {
|
|
4099
4098
|
const LOADING_NAME = name;
|
|
@@ -4109,20 +4108,16 @@ function useFormHelper() {
|
|
|
4109
4108
|
}
|
|
4110
4109
|
function onRequestWrapper(fn, { name }) {
|
|
4111
4110
|
return (...params) => __async(this, null, function* () {
|
|
4112
|
-
if (name.includes("get:"))
|
|
4113
|
-
sourceRef.current = _axios2.default.CancelToken.source();
|
|
4114
4111
|
const LOADING_NAME = name;
|
|
4115
4112
|
setLoading(LOADING_NAME);
|
|
4116
4113
|
api.interceptors.request.use(
|
|
4117
4114
|
(config) => {
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
config.cancelToken = (_a = sourceRef.current) == null ? void 0 : _a.token;
|
|
4115
|
+
if (!config.signal && sourceRef.current && config.method === "get") {
|
|
4116
|
+
config.signal = sourceRef.current.signal;
|
|
4121
4117
|
}
|
|
4122
4118
|
return config;
|
|
4123
4119
|
},
|
|
4124
4120
|
(error) => {
|
|
4125
|
-
console.log("[middleware]");
|
|
4126
4121
|
return Promise.reject(error);
|
|
4127
4122
|
}
|
|
4128
4123
|
);
|
|
@@ -4153,8 +4148,8 @@ function useFormHelper() {
|
|
|
4153
4148
|
}
|
|
4154
4149
|
_react.useEffect.call(void 0, () => {
|
|
4155
4150
|
return () => {
|
|
4156
|
-
|
|
4157
|
-
|
|
4151
|
+
sourceRef.current.abort();
|
|
4152
|
+
sourceRef.current = new AbortController();
|
|
4158
4153
|
};
|
|
4159
4154
|
}, []);
|
|
4160
4155
|
return __spreadProps(__spreadValues(__spreadValues({}, alertProps), loadingProps), {
|