@m4l/core 0.1.34 → 0.1.35

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.
@@ -0,0 +1,54 @@
1
+ import { createContext as E, useState as d, useCallback as y } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import "../EnvironmentContext/index.7045c64f.js";
4
+ import "../FlagsContext/index.5f795859.js";
5
+ import { u as T } from "../../hooks/useHostTools/index.66d9a667.js";
6
+ import "../DomainContext/index.5da377f5.js";
7
+ import "../ModuleDictionaryContext/index.527e0ae1.js";
8
+ import "../ModulePrivilegesContext/index.bcfce88d.js";
9
+ import "../ModuleSkeletonContext/index.4a9100d2.js";
10
+ import "../NetworkContext/index.d1dfbc3a.js";
11
+ import { u as f } from "../../hooks/usePropageteMF/index.c440b829.js";
12
+ import { E as i } from "../../types/index.d9c95d2a.js";
13
+ import { jsx as D } from "react/jsx-runtime";
14
+ const M = E(null);
15
+ function G(n) {
16
+ const {
17
+ children: e,
18
+ isMicroFrontEnd: t,
19
+ id: m,
20
+ currency: s,
21
+ currency_decimal_digits: a,
22
+ decimal_symbol: c,
23
+ thousands_symbol: u
24
+ } = n, {
25
+ events_emit: p
26
+ } = T(), [_, l] = d({
27
+ id: m,
28
+ currency: s,
29
+ currency_decimal_digits: a,
30
+ decimal_symbol: c,
31
+ thousands_symbol: u
32
+ }), r = (o) => {
33
+ l(o);
34
+ };
35
+ f({
36
+ isMicroFrontEnd: t,
37
+ event: i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
38
+ setHandler: r
39
+ });
40
+ const C = y((o) => {
41
+ t || (r(o), p(i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
42
+ }, []);
43
+ return /* @__PURE__ */ D(M.Provider, {
44
+ value: {
45
+ ..._,
46
+ changeDomainCountry: C
47
+ },
48
+ children: e
49
+ });
50
+ }
51
+ export {
52
+ M as D,
53
+ G as a
54
+ };
@@ -4,10 +4,10 @@ import { u as M } from "../../hooks/useEnvironment/index.04dca988.js";
4
4
  import { u as N } from "../../hooks/useFlags/index.a986729d.js";
5
5
  import { u as P } from "../../hooks/useHostTools/index.66d9a667.js";
6
6
  import "../DomainContext/index.5da377f5.js";
7
- import "../ModulePrivilegesContext/index.813909e9.js";
8
- import "../ModuleSkeletonContext/index.28283eb3.js";
7
+ import "../ModulePrivilegesContext/index.bcfce88d.js";
8
+ import "../ModuleSkeletonContext/index.4a9100d2.js";
9
9
  import { u as _ } from "../../hooks/useNetwork/index.acbf28d5.js";
10
- import "../DomainCountryContext/index.f904fe2a.js";
10
+ import "../DomainCountryContext/index.ceb6320d.js";
11
11
  import { C as x } from "../../types/index.d9c95d2a.js";
12
12
  import { jsx as A } from "react/jsx-runtime";
13
13
  const E = y(null);
@@ -4,10 +4,10 @@ import "../EnvironmentContext/index.7045c64f.js";
4
4
  import { u as v } from "../../hooks/useFlags/index.a986729d.js";
5
5
  import { u as E } from "../../hooks/useHostTools/index.66d9a667.js";
6
6
  import "../DomainContext/index.5da377f5.js";
7
- import "../ModuleDictionaryContext/index.3ca2f244.js";
8
- import "../ModuleSkeletonContext/index.28283eb3.js";
7
+ import "../ModuleDictionaryContext/index.527e0ae1.js";
8
+ import "../ModuleSkeletonContext/index.4a9100d2.js";
9
9
  import { u as h } from "../../hooks/useNetwork/index.acbf28d5.js";
10
- import "../DomainCountryContext/index.f904fe2a.js";
10
+ import "../DomainCountryContext/index.ceb6320d.js";
11
11
  import { C as i } from "../../types/index.d9c95d2a.js";
12
12
  import { jsx as L } from "react/jsx-runtime";
13
13
  const C = f(null);
@@ -4,10 +4,10 @@ import "../EnvironmentContext/index.7045c64f.js";
4
4
  import { a as m } from "../../hooks/useFlags/index.a986729d.js";
5
5
  import "../HostToolsContext/index.499db832.js";
6
6
  import "../DomainContext/index.5da377f5.js";
7
- import "../ModuleDictionaryContext/index.3ca2f244.js";
8
- import "../ModulePrivilegesContext/index.813909e9.js";
7
+ import "../ModuleDictionaryContext/index.527e0ae1.js";
8
+ import "../ModulePrivilegesContext/index.bcfce88d.js";
9
9
  import "../NetworkContext/index.d1dfbc3a.js";
10
- import "../DomainCountryContext/index.f904fe2a.js";
10
+ import "../DomainCountryContext/index.ceb6320d.js";
11
11
  import { jsx as n } from "react/jsx-runtime";
12
12
  const p = i(null);
13
13
  function P(o) {
@@ -1,6 +1,6 @@
1
1
  import { useContext as t } from "react";
2
2
  import { D as n } from "../../contexts/DomainContext/index.5da377f5.js";
3
- import { D as e } from "../../contexts/DomainCountryContext/index.f904fe2a.js";
3
+ import { D as e } from "../../contexts/DomainCountryContext/index.ceb6320d.js";
4
4
  const m = () => {
5
5
  const o = t(n);
6
6
  if (!o)
@@ -1,8 +1,8 @@
1
1
  import { useState as a, useEffect as g } from "react";
2
- function S(r, e) {
2
+ function S(o, e) {
3
3
  const [n, s] = a(() => {
4
4
  try {
5
- const t = window.localStorage.getItem(r);
5
+ const t = window.localStorage.getItem(o);
6
6
  return t !== null ? typeof e == "string" ? t : JSON.parse(t) : e;
7
7
  } catch {
8
8
  return e;
@@ -11,44 +11,42 @@ function S(r, e) {
11
11
  return [n, (t) => {
12
12
  try {
13
13
  window.localStorage.setItem(
14
- r,
14
+ o,
15
15
  typeof e == "string" ? String(t) : JSON.stringify(t)
16
16
  ), s(t);
17
17
  } catch {
18
18
  }
19
19
  }];
20
20
  }
21
- function u(r, e) {
21
+ function u(o, e) {
22
22
  const [n, s] = a(() => {
23
23
  try {
24
- const t = localStorage.getItem(r);
25
- return console.log("useLocalStorageWithListener", e), t !== null ? typeof e == "string" ? t : JSON.parse(t) : e;
24
+ const t = localStorage.getItem(o);
25
+ return t !== null ? typeof e == "string" ? t : JSON.parse(t) : e;
26
26
  } catch {
27
27
  return e;
28
28
  }
29
29
  });
30
30
  return g(() => {
31
- const t = (o) => {
32
- if (o.storageArea === localStorage && o.key === r) {
33
- console.log("Se actualiza el storage", o);
31
+ const t = (r) => {
32
+ if (r.storageArea === localStorage && r.key === o)
34
33
  try {
35
- o.newValue && s(
36
- typeof e == "string" ? o.newValue : JSON.parse(o.newValue)
34
+ r.newValue && s(
35
+ typeof e == "string" ? r.newValue : JSON.parse(r.newValue)
37
36
  );
38
37
  } catch {
39
38
  }
40
- }
41
39
  };
42
40
  return window.addEventListener("storage", t), () => {
43
41
  window.removeEventListener("storage", t);
44
42
  };
45
- }, [r, e]), [n, (t) => {
46
- let o;
43
+ }, [o, e]), [n, (t) => {
44
+ let r;
47
45
  if (typeof t == "function")
48
46
  throw Error("Funcions are not allowed in useLocalStorageWithListener");
49
47
  if (typeof t != typeof e)
50
48
  throw Error("Not allowed change type from initial value");
51
- typeof t == "string" ? o = t : o = JSON.stringify(t), localStorage.setItem(r, o), s(t);
49
+ typeof t == "string" ? r = t : r = JSON.stringify(t), localStorage.setItem(o, r), s(t);
52
50
  }];
53
51
  }
54
52
  export {
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { M as e } from "../../contexts/ModuleDictionaryContext/index.3ca2f244.js";
2
+ import { M as e } from "../../contexts/ModuleDictionaryContext/index.527e0ae1.js";
3
3
  const n = () => {
4
4
  const o = t(e);
5
5
  if (!o)
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { M as t } from "../../contexts/ModulePrivilegesContext/index.813909e9.js";
2
+ import { M as t } from "../../contexts/ModulePrivilegesContext/index.bcfce88d.js";
3
3
  const i = () => {
4
4
  const e = o(t);
5
5
  if (!e)
@@ -1,5 +1,5 @@
1
1
  import { useState as n, useContext as s, useEffect as u } from "react";
2
- import { M as r } from "../../contexts/ModuleSkeletonContext/index.28283eb3.js";
2
+ import { M as r } from "../../contexts/ModuleSkeletonContext/index.4a9100d2.js";
3
3
  const S = () => {
4
4
  const [t, o] = n(!0), e = s(r);
5
5
  if (!e)
@@ -0,0 +1,11 @@
1
+ import { useEffect as i } from "react";
2
+ import { u as f } from "../useHostTools/index.66d9a667.js";
3
+ function c(s) {
4
+ const { isMicroFrontEnd: e, event: t, setHandler: o } = s, { events_add_listener: r, events_remove_listener: n } = f();
5
+ i(() => (e && r(t, o), () => {
6
+ e && n(t, o);
7
+ }), []);
8
+ }
9
+ export {
10
+ c as u
11
+ };
package/index.js CHANGED
@@ -4,26 +4,26 @@ import { E as u, a as x } from "./contexts/EnvironmentContext/index.7045c64f.js"
4
4
  import { F as l, a as f } from "./contexts/FlagsContext/index.5f795859.js";
5
5
  import { H as g, a as v } from "./contexts/HostToolsContext/index.499db832.js";
6
6
  import { D as C, a as M } from "./contexts/DomainContext/index.5da377f5.js";
7
- import { M as S, a as c } from "./contexts/ModuleDictionaryContext/index.3ca2f244.js";
8
- import { M as F, a as E } from "./contexts/ModulePrivilegesContext/index.813909e9.js";
9
- import { M as B, a as L } from "./contexts/ModuleSkeletonContext/index.28283eb3.js";
7
+ import { M as S, a as c } from "./contexts/ModuleDictionaryContext/index.527e0ae1.js";
8
+ import { M as F, a as E } from "./contexts/ModulePrivilegesContext/index.bcfce88d.js";
9
+ import { M as B, a as L } from "./contexts/ModuleSkeletonContext/index.4a9100d2.js";
10
10
  import { N, a as w } from "./contexts/NetworkContext/index.d1dfbc3a.js";
11
- import { D as h, a as O } from "./contexts/DomainCountryContext/index.f904fe2a.js";
11
+ import { D as h, a as O } from "./contexts/DomainCountryContext/index.ceb6320d.js";
12
12
  import { u as b } from "./hooks/useBase/index.4375dcef.js";
13
13
  import { u as q } from "./hooks/useEnvironment/index.04dca988.js";
14
14
  import { u as A, a as G } from "./hooks/useFlags/index.a986729d.js";
15
15
  import { u as J } from "./hooks/useHostTools/index.66d9a667.js";
16
- import { u as Q, a as R } from "./hooks/useDomain/index.a3ddf40d.js";
17
- import { u as V, a as X } from "./hooks/useLocalStorage/index.c9f47e01.js";
18
- import { u as Z } from "./hooks/useModuleDictionary/index.55dc31b0.js";
19
- import { u as $ } from "./hooks/useModulePrivileges/index.7f8d29b0.js";
20
- import { u as eo } from "./hooks/useModuleSkeleton/index.50e84d72.js";
16
+ import { u as Q, a as R } from "./hooks/useDomain/index.77c85724.js";
17
+ import { u as V, a as X } from "./hooks/useLocalStorage/index.48b47dca.js";
18
+ import { u as Z } from "./hooks/useModuleDictionary/index.98161356.js";
19
+ import { u as $ } from "./hooks/useModulePrivileges/index.8afb47f4.js";
20
+ import { u as eo } from "./hooks/useModuleSkeleton/index.aa9264ca.js";
21
21
  import { u as ao } from "./hooks/useNetwork/index.acbf28d5.js";
22
22
  import { i as so, u as io } from "./hooks/usePaginate/index.7cb17527.js";
23
- import { u as mo } from "./hooks/usePropageteMF/index.7e7914ad.js";
23
+ import { u as mo } from "./hooks/usePropageteMF/index.c440b829.js";
24
24
  import { C as xo, E as po } from "./types/index.d9c95d2a.js";
25
25
  import { a as fo, g as go, s as vo, v as Po } from "./utils/index.6c53abe1.js";
26
- import { a as Mo } from "./utils/axiosOperation.2b6d10ea.js";
26
+ import { a as Mo } from "./utils/axiosOperation.cc325182.js";
27
27
  import "react/jsx-runtime";
28
28
  import "axios";
29
29
  import "qs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "peerDependencies": {
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Id, ToastContent, ToastOptions } from 'react-toastify';
2
2
  import type { BrowserHistory } from 'history';
3
+ import { ResponseType } from 'axios';
3
4
  export declare type Maybe<T> = T | undefined | null;
4
5
  export declare interface EnvironmentType {
5
6
  isLocalhost: boolean;
@@ -20,6 +21,10 @@ export declare type NetworkProps = {
20
21
  checkUnAuthorized?: boolean;
21
22
  isRemote?: boolean;
22
23
  showSuccesInfo?: boolean;
24
+ onDownloadProgress?: (progressEvent: any) => void;
25
+ isExternalUrl?: boolean;
26
+ responseType?: ResponseType;
27
+ signal?: AbortSignal;
23
28
  };
24
29
  export declare type ToastFunction = (content: ToastContent, options?: ToastOptions) => Id;
25
30
  export declare type EventFunListener = (...args: any[]) => void;
@@ -0,0 +1,56 @@
1
+ import _ from "axios";
2
+ import $ from "qs";
3
+ import { E as y } from "../types/index.d9c95d2a.js";
4
+ function R(e, t, a, i) {
5
+ const { toast: s } = a;
6
+ return i === "json" ? t && t.data && typeof t.data == "object" ? t.data.error && t.data.error?.code && t.data.error?.msg !== void 0 ? Promise.reject({ ...t.data.error, status: t.status }) : (t.data.message && s(t.data.message, { type: "success", autoClose: 1e4 }), t.data) : Promise.reject({
7
+ code: 1,
8
+ msg: `Incorrect endpoint: ${e}`,
9
+ status: t.status
10
+ }) : t.data;
11
+ }
12
+ function j(e, t, a = !0) {
13
+ const { toast: i } = t;
14
+ let s = {
15
+ message: "",
16
+ status: 1,
17
+ code: 0
18
+ };
19
+ return e?.code !== void 0 && s.status !== void 0 && e.message !== void 0 && (s = { ...s, ...e }), e?.response ? e.response.data && typeof e.response.data == "object" && e.response.data.error && e.response.data.error?.code && e.response.data.error?.message !== void 0 ? s = { ...e.response.data.error, status: e.response.status } : (s.message = e.message, s.status = e.response.status, s.code = 0) : e?.request ? (s.message = `${e?.code} ${e.message}`, s.code = -1) : (s.message = `${e?.code} ${e.message}`, s.status = 0, s.code = -2), a && e?.response?.status === 401 && t.events_emit(y.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (s.message = e?.response?.data?.error.message), a && (s.message.indexOf("ERR_CANCELED") > -1 || i(`${s.message} - status: ${s.status} - code: ${s.code}`, { type: "error" })), s;
20
+ }
21
+ const C = async (e, t, a) => {
22
+ const {
23
+ method: i,
24
+ endPoint: s,
25
+ timeout: u = 6e4,
26
+ parms: c = {},
27
+ data: g = {},
28
+ isRemote: n = !0,
29
+ checkUnAuthorized: f = !0,
30
+ headers: p,
31
+ onDownloadProgress: l,
32
+ isExternalUrl: m,
33
+ responseType: r = "json",
34
+ signal: E
35
+ } = e;
36
+ let o;
37
+ return n ? o = t.host_api_remote : o = t.host_api_local, a.startProgress(), _({
38
+ baseURL: m ? void 0 : o,
39
+ withCredentials: n,
40
+ method: i,
41
+ url: m ? s : `/${s}`,
42
+ data: g,
43
+ params: {},
44
+ paramsSerializer: () => $.stringify(c, { encode: !0 }),
45
+ headers: p,
46
+ timeout: u,
47
+ onDownloadProgress: l,
48
+ responseType: r,
49
+ signal: E
50
+ }).then((d) => R(s, d, a, r)).catch((d) => Promise.reject(j(d, a, f))).finally(() => {
51
+ a.stopProgress();
52
+ });
53
+ };
54
+ export {
55
+ C as a
56
+ };
@@ -1,54 +0,0 @@
1
- import { createContext as d, useState as E, useCallback as y } from "react";
2
- import "../BaseContext/index.f9cdc955.js";
3
- import "../EnvironmentContext/index.7045c64f.js";
4
- import "../FlagsContext/index.5f795859.js";
5
- import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
6
- import "../DomainContext/index.5da377f5.js";
7
- import "../ModuleDictionaryContext/index.3ca2f244.js";
8
- import "../ModulePrivilegesContext/index.813909e9.js";
9
- import "../ModuleSkeletonContext/index.28283eb3.js";
10
- import "../NetworkContext/index.d1dfbc3a.js";
11
- import { u as T } from "../../hooks/usePropageteMF/index.7e7914ad.js";
12
- import { E as n } from "../../types/index.d9c95d2a.js";
13
- import { jsx as f } from "react/jsx-runtime";
14
- const M = d(null);
15
- function S(e) {
16
- const {
17
- children: i,
18
- isMicroFrontEnd: t,
19
- id: s,
20
- currency: m,
21
- currency_decimal_digits: a,
22
- decimal_symbol: c,
23
- thousands_symbol: l
24
- } = e, {
25
- events_emit: u
26
- } = D(), [p, _] = E({
27
- id: s,
28
- currency: m,
29
- currency_decimal_digits: a,
30
- decimal_symbol: c,
31
- thousands_symbol: l
32
- }), r = (o) => {
33
- console.log("setLocalDomainCountry", o), _(o);
34
- };
35
- T({
36
- isMicroFrontEnd: t,
37
- event: n.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
38
- setHandler: r
39
- });
40
- const C = y((o) => {
41
- t || (r(o), u(n.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
42
- }, []);
43
- return console.log("Render DomainCountryProvider"), /* @__PURE__ */ f(M.Provider, {
44
- value: {
45
- ...p,
46
- changeDomainCountry: C
47
- },
48
- children: i
49
- });
50
- }
51
- export {
52
- M as D,
53
- S as a
54
- };
@@ -1,11 +0,0 @@
1
- import { useEffect as f } from "react";
2
- import { u as i } from "../useHostTools/index.66d9a667.js";
3
- function a(s) {
4
- const { isMicroFrontEnd: e, event: o, setHandler: t } = s, { events_add_listener: r, events_remove_listener: n } = i();
5
- f(() => (console.log("useEffect usePropageteMF", e), e && r(o, t), () => {
6
- e && n(o, t);
7
- }), []);
8
- }
9
- export {
10
- a as u
11
- };
@@ -1,49 +0,0 @@
1
- import f from "axios";
2
- import p from "qs";
3
- import { E } from "../types/index.d9c95d2a.js";
4
- function l(e, s, a) {
5
- const { toast: d } = a;
6
- return s && s.data && typeof s.data == "object" ? s.data.error && s.data.error?.code && s.data.error?.msg !== void 0 ? Promise.reject({ ...s.data.error, status: s.status }) : (s.data.message && d(s.data.message, { type: "success", autoClose: 1e4 }), s.data) : Promise.reject({
7
- code: 1,
8
- msg: `Incorrect endpoint: ${e}`,
9
- status: s.status
10
- });
11
- }
12
- function _(e, s, a = !0) {
13
- const { toast: d } = s;
14
- let t = {
15
- message: "",
16
- status: 1,
17
- code: 0
18
- };
19
- return e?.code !== void 0 && t.status !== void 0 && e.message !== void 0 && (t = { ...t, ...e }), e?.response ? e.response.data && typeof e.response.data == "object" && e.response.data.error && e.response.data.error?.code && e.response.data.error?.message !== void 0 ? t = { ...e.response.data.error, status: e.response.status } : (t.message = e.message, t.status = e.response.status, t.code = 0) : e?.request ? (t.message = `${e?.code} ${e.message}`, t.code = -1) : (t.message = `${e?.code} ${e.message}`, t.status = 0, t.code = -2), a && e?.response?.status === 401 && s.events_emit(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (t.message = e?.response?.data?.error.message), a && d(`${t.message} - status: ${t.status} - code: ${t.code}`, { type: "error" }), t;
20
- }
21
- const P = async (e, s, a) => {
22
- const {
23
- method: d,
24
- endPoint: t,
25
- timeout: c = 5e3,
26
- parms: u = {},
27
- data: n = {},
28
- isRemote: m = !0,
29
- checkUnAuthorized: r = !0,
30
- headers: g
31
- } = e;
32
- let i;
33
- return m ? i = s.host_api_remote : i = s.host_api_local, a.startProgress(), f({
34
- baseURL: i,
35
- withCredentials: m,
36
- method: d,
37
- url: `/${t}`,
38
- data: n,
39
- params: {},
40
- paramsSerializer: () => p.stringify(u, { encode: !0 }),
41
- headers: g,
42
- timeout: c
43
- }).then((o) => l(t, o, a)).catch((o) => Promise.reject(_(o, a, r))).finally(() => {
44
- a.stopProgress();
45
- });
46
- };
47
- export {
48
- P as a
49
- };