@bluemarble/bm-components 0.1.4 → 0.2.0

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.mjs CHANGED
@@ -3924,7 +3924,9 @@ var HttpError = class extends Error {
3924
3924
 
3925
3925
  // src/helpers/apiHelper/index.ts
3926
3926
  var ApiHelper = class _ApiHelper {
3927
- onFinally() {
3927
+ onFinally(req) {
3928
+ return __async(this, null, function* () {
3929
+ });
3928
3930
  }
3929
3931
  constructor(props) {
3930
3932
  this.middlewares = (props == null ? void 0 : props.middlewares.reverse()) || [];
@@ -3958,7 +3960,7 @@ var ApiHelper = class _ApiHelper {
3958
3960
  });
3959
3961
  throw new Error(error);
3960
3962
  } finally {
3961
- this.onFinally();
3963
+ yield this.onFinally(req);
3962
3964
  }
3963
3965
  });
3964
3966
  }
@@ -3989,7 +3991,6 @@ var ApiHelper = class _ApiHelper {
3989
3991
  };
3990
3992
 
3991
3993
  // src/hooks/useFormHelper.ts
3992
- import axios from "axios";
3993
3994
  import { useContext as useContext3, useEffect as useEffect5, useRef as useRef4 } from "react";
3994
3995
 
3995
3996
  // src/hooks/useAlert.ts
@@ -4093,7 +4094,7 @@ function useFormHelper() {
4093
4094
  const { api, formatErrorMessage } = useContext3(FormHelperContext);
4094
4095
  const { createAlert } = alertProps;
4095
4096
  const { setLoading } = loadingProps;
4096
- const sourceRef = useRef4();
4097
+ const sourceRef = useRef4(new AbortController());
4097
4098
  function onSubmitWrapper(fn, { name }) {
4098
4099
  return (fields, methods) => __async(this, null, function* () {
4099
4100
  const LOADING_NAME = name;
@@ -4109,20 +4110,16 @@ function useFormHelper() {
4109
4110
  }
4110
4111
  function onRequestWrapper(fn, { name }) {
4111
4112
  return (...params) => __async(this, null, function* () {
4112
- if (name.includes("get:"))
4113
- sourceRef.current = axios.CancelToken.source();
4114
4113
  const LOADING_NAME = name;
4115
4114
  setLoading(LOADING_NAME);
4116
4115
  api.interceptors.request.use(
4117
4116
  (config) => {
4118
- var _a;
4119
- if (!config.cancelToken && sourceRef.current && config.method === "get") {
4120
- config.cancelToken = (_a = sourceRef.current) == null ? void 0 : _a.token;
4117
+ if (!config.signal && sourceRef.current && config.method === "get") {
4118
+ config.signal = sourceRef.current.signal;
4121
4119
  }
4122
4120
  return config;
4123
4121
  },
4124
4122
  (error) => {
4125
- console.log("[middleware]");
4126
4123
  return Promise.reject(error);
4127
4124
  }
4128
4125
  );
@@ -4153,8 +4150,8 @@ function useFormHelper() {
4153
4150
  }
4154
4151
  useEffect5(() => {
4155
4152
  return () => {
4156
- var _a;
4157
- (_a = sourceRef.current) == null ? void 0 : _a.cancel("cancel.navigation");
4153
+ sourceRef.current.abort();
4154
+ sourceRef.current = new AbortController();
4158
4155
  };
4159
4156
  }, []);
4160
4157
  return __spreadProps(__spreadValues(__spreadValues({}, alertProps), loadingProps), {