@m4l/core 2.0.0 → 2.0.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.
@@ -0,0 +1,150 @@
1
+ import { createContext as T, useReducer as y, useEffect as m } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import { u as E } from "../../hooks/useEnvironment/index.25f83176.js";
4
+ import "../FlagsContext/index.5b096265.js";
5
+ import "zustand";
6
+ import { u as v } from "../../hooks/useHostTools/index.66d9a667.js";
7
+ import "../DomainContext/index.2ed56159.js";
8
+ import { u as D } from "../../hooks/useLocalStorage/index.91bc0791.js";
9
+ import "../ModuleDictionaryContext/index.a64207d4.js";
10
+ import "../ModulePrivilegesContext/index.79c3cc04.js";
11
+ import "../ModuleSkeletonContext/index.f6150fb9.js";
12
+ import { u as N } from "../../hooks/useNetwork/index.3d79002b.js";
13
+ import "../DomainCountryContext/index.506456a3.js";
14
+ import "../EnvironmentContext/index.b33784cd.js";
15
+ import "../HostToolsContext/index.499db832.js";
16
+ import "../NetworkContext/index.ec7405cd.js";
17
+ import { g as O, s as u } from "../../utils/index.2f5ce5aa.js";
18
+ import "axios";
19
+ import "qs";
20
+ import "camelcase-keys";
21
+ import "snakecase-keys";
22
+ import { E as S } from "../../types/index.42c24946.js";
23
+ import { jsx as U } from "react/jsx-runtime";
24
+ var o = /* @__PURE__ */ ((t) => (t.Initial = "INITIALIZE", t.Login = "LOGIN", t.Logout = "LOGOUT", t))(o || {});
25
+ const w = {
26
+ isAuthenticated: !1,
27
+ isInitialized: !1,
28
+ user: null
29
+ }, _ = (t, e) => {
30
+ switch (e.type) {
31
+ case "INITIALIZE":
32
+ return {
33
+ isAuthenticated: e.payload.isAuthenticated,
34
+ isInitialized: !0,
35
+ user: e.payload.user
36
+ };
37
+ case "LOGIN":
38
+ return {
39
+ ...t,
40
+ isAuthenticated: !0,
41
+ user: e.payload.user
42
+ };
43
+ case "LOGOUT":
44
+ return {
45
+ ...t,
46
+ isAuthenticated: !1,
47
+ user: null
48
+ };
49
+ default:
50
+ return t;
51
+ }
52
+ }, P = T(null);
53
+ function x(t) {
54
+ t({
55
+ type: o.Initial,
56
+ payload: {
57
+ isAuthenticated: !1,
58
+ user: null
59
+ }
60
+ });
61
+ }
62
+ function it(t) {
63
+ const {
64
+ children: e
65
+ } = t, [d, r] = y(_, w), {
66
+ events_add_listener: p
67
+ } = v(), {
68
+ networkOperation: n
69
+ } = N(), {
70
+ domain_token: h
71
+ } = E(), [f, l] = D(
72
+ "vSession",
73
+ new Date().getTime() + ""
74
+ );
75
+ m(() => {
76
+ (async () => {
77
+ n({
78
+ method: "GET",
79
+ endPoint: "auth/login",
80
+ parms: {
81
+ user_data: !0
82
+ },
83
+ checkUnAuthorized: !1
84
+ }).then((a) => {
85
+ r({
86
+ type: o.Initial,
87
+ payload: {
88
+ isAuthenticated: !0,
89
+ user: a.user
90
+ }
91
+ }), O("userData", {
92
+ email: a.user.email,
93
+ remember: !0
94
+ })?.email !== a.user.email && u("userData", {
95
+ email: a.user.email
96
+ }, !0);
97
+ }).catch(() => {
98
+ x(r);
99
+ });
100
+ })();
101
+ }, [f]);
102
+ const I = async (i, a, s) => {
103
+ await n({
104
+ endPoint: "auth/login",
105
+ method: "POST",
106
+ data: {
107
+ email: i,
108
+ password: a,
109
+ domain_token: h
110
+ }
111
+ }).then((L) => {
112
+ const A = L.data;
113
+ s ? u("userData", {
114
+ email: i,
115
+ remember: s
116
+ }) : u("userData", {
117
+ email: "",
118
+ remember: s
119
+ }), r({
120
+ type: o.Login,
121
+ payload: {
122
+ user: A
123
+ }
124
+ }), l(new Date().getTime() + "");
125
+ });
126
+ }, c = async (i) => {
127
+ i && await n({
128
+ endPoint: "auth/logout",
129
+ method: "POST"
130
+ }), r({
131
+ type: o.Logout
132
+ }), l(new Date().getTime() + "");
133
+ }, g = () => {
134
+ c(!1);
135
+ };
136
+ return m(function() {
137
+ p(S.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, g);
138
+ }, []), /* @__PURE__ */ U(P.Provider, {
139
+ value: {
140
+ ...d,
141
+ login: I,
142
+ logout: c
143
+ },
144
+ children: e
145
+ });
146
+ }
147
+ export {
148
+ P as A,
149
+ it as a
150
+ };
@@ -0,0 +1,57 @@
1
+ import { createContext as E, useState as d, useCallback as y } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import "../EnvironmentContext/index.b33784cd.js";
4
+ import "../FlagsContext/index.5b096265.js";
5
+ import "zustand";
6
+ import { u as T } from "../../hooks/useHostTools/index.66d9a667.js";
7
+ import "../DomainContext/index.2ed56159.js";
8
+ import "../ModuleDictionaryContext/index.a64207d4.js";
9
+ import "../ModulePrivilegesContext/index.79c3cc04.js";
10
+ import "../ModuleSkeletonContext/index.f6150fb9.js";
11
+ import "../NetworkContext/index.ec7405cd.js";
12
+ import { u as f } from "../../hooks/usePropageteMF/index.c440b829.js";
13
+ import "../HostToolsContext/index.499db832.js";
14
+ import "../AuthContext/index.db46edbc.js";
15
+ import { E as i } from "../../types/index.42c24946.js";
16
+ import { jsx as D } from "react/jsx-runtime";
17
+ const M = E(null);
18
+ function V(n) {
19
+ const {
20
+ children: m,
21
+ isMicroFrontEnd: t,
22
+ id: e,
23
+ currency: s,
24
+ currency_decimal_digits: a,
25
+ decimal_symbol: c,
26
+ thousands_symbol: p
27
+ } = n, {
28
+ events_emit: u
29
+ } = T(), [_, l] = d({
30
+ id: e,
31
+ currency: s,
32
+ currency_decimal_digits: a,
33
+ decimal_symbol: c,
34
+ thousands_symbol: p
35
+ }), r = (o) => {
36
+ l(o);
37
+ };
38
+ f({
39
+ isMicroFrontEnd: t,
40
+ event: i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
41
+ setHandler: r
42
+ });
43
+ const C = y((o) => {
44
+ t || (r(o), u(i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
45
+ }, []);
46
+ return /* @__PURE__ */ D(M.Provider, {
47
+ value: {
48
+ ..._,
49
+ changeDomainCountry: C
50
+ },
51
+ children: m
52
+ });
53
+ }
54
+ export {
55
+ M as D,
56
+ V as a
57
+ };
@@ -0,0 +1,81 @@
1
+ import { createContext as F, useState as y, useEffect as A, useCallback as m } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import { u as L } from "../../hooks/useEnvironment/index.25f83176.js";
4
+ import { u as M } from "../../hooks/useFlagsStore/index.f7c613ac.js";
5
+ import { u as N } from "../../hooks/useHostTools/index.66d9a667.js";
6
+ import "../DomainContext/index.2ed56159.js";
7
+ import "../ModulePrivilegesContext/index.79c3cc04.js";
8
+ import "../ModuleSkeletonContext/index.f6150fb9.js";
9
+ import { u as P } from "../../hooks/useNetwork/index.3d79002b.js";
10
+ import "../DomainCountryContext/index.506456a3.js";
11
+ import "../EnvironmentContext/index.b33784cd.js";
12
+ import "../HostToolsContext/index.499db832.js";
13
+ import "../NetworkContext/index.ec7405cd.js";
14
+ import "../AuthContext/index.db46edbc.js";
15
+ import "../FlagsContext/index.5b096265.js";
16
+ import { C as _ } from "../../types/index.42c24946.js";
17
+ import { jsx as x } from "react/jsx-runtime";
18
+ const E = F(null);
19
+ function K(u) {
20
+ const {
21
+ children: l,
22
+ componentsDictionary: c,
23
+ moduleId: n,
24
+ moduleNameField: s = "module_name",
25
+ currentLang: d = "en",
26
+ isAuth: a = !0
27
+ } = u, p = M((t) => t.flagsActions.addFlag), [r, f] = y(void 0), {
28
+ domain_token: g
29
+ } = L(), {
30
+ startProgress: D,
31
+ stopProgress: h
32
+ } = N(), {
33
+ networkOperation: v
34
+ } = P();
35
+ A(() => {
36
+ let t = !0;
37
+ return D(), v({
38
+ method: "GET",
39
+ endPoint: a ? `dictionaries/${n}` : `na/dictionaries/${n}`,
40
+ parms: {
41
+ comps: c,
42
+ ...a ? {} : {
43
+ domain_token: g
44
+ }
45
+ }
46
+ }).then((o) => {
47
+ t && (f({
48
+ ...o
49
+ }), p(_.FLAG_DICTIONARY_LOADED));
50
+ }).finally(() => {
51
+ h();
52
+ }), function() {
53
+ t = !1;
54
+ };
55
+ }, [d]);
56
+ const i = m((t) => {
57
+ if (r === void 0)
58
+ return "";
59
+ if (t === "")
60
+ return "No key";
61
+ let o;
62
+ const e = t.split(".");
63
+ try {
64
+ e.length === 1 && (o = r.data[t]), e.length === 2 && (o = r[e[0]][e[1]]);
65
+ } catch {
66
+ }
67
+ return o || `N_D:[${t}]`;
68
+ }, [r]), C = m(() => i(s), [s, i]);
69
+ return /* @__PURE__ */ x(E.Provider, {
70
+ value: {
71
+ moduleDictionary: r,
72
+ getLabel: i,
73
+ getModuleLabel: C
74
+ },
75
+ children: l
76
+ });
77
+ }
78
+ export {
79
+ E as M,
80
+ K as a
81
+ };
@@ -0,0 +1,62 @@
1
+ import { createContext as c, useState as f, useEffect as d, useCallback as P } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import "../EnvironmentContext/index.b33784cd.js";
4
+ import { u as v } from "../../hooks/useFlagsStore/index.f7c613ac.js";
5
+ import { u as E } from "../../hooks/useHostTools/index.66d9a667.js";
6
+ import "../DomainContext/index.2ed56159.js";
7
+ import "../ModuleDictionaryContext/index.a64207d4.js";
8
+ import "../ModuleSkeletonContext/index.f6150fb9.js";
9
+ import { u as h } from "../../hooks/useNetwork/index.3d79002b.js";
10
+ import "../DomainCountryContext/index.506456a3.js";
11
+ import "../HostToolsContext/index.499db832.js";
12
+ import "../NetworkContext/index.ec7405cd.js";
13
+ import "../AuthContext/index.db46edbc.js";
14
+ import "../FlagsContext/index.5b096265.js";
15
+ import { C as s } from "../../types/index.42c24946.js";
16
+ import { jsx as F } from "react/jsx-runtime";
17
+ const L = c(null);
18
+ function b(n) {
19
+ const {
20
+ children: a,
21
+ queryPrivileges: o
22
+ } = n, e = v((t) => t.flagsActions.addFlag), [r, l] = f({}), {
23
+ startProgress: m,
24
+ stopProgress: p
25
+ } = E(), {
26
+ networkOperation: u
27
+ } = h();
28
+ d(() => {
29
+ let t = !0;
30
+ if (o.length === 0) {
31
+ e(s.FLAG_PRIVILEGES_LOADED);
32
+ return;
33
+ }
34
+ return m(), u({
35
+ method: "GET",
36
+ endPoint: "auth/login",
37
+ parms: {
38
+ privileges: o
39
+ }
40
+ }).then((i) => {
41
+ t && (l({
42
+ ...i.data
43
+ }), e(s.FLAG_PRIVILEGES_LOADED));
44
+ }).finally(() => {
45
+ p();
46
+ }), function() {
47
+ t = !1;
48
+ };
49
+ }, []);
50
+ const g = P((t) => t in r, [r]);
51
+ return /* @__PURE__ */ F(L.Provider, {
52
+ value: {
53
+ hasPrivilege: g,
54
+ privileges: r
55
+ },
56
+ children: a
57
+ });
58
+ }
59
+ export {
60
+ L as M,
61
+ b as a
62
+ };
@@ -0,0 +1,30 @@
1
+ import { createContext as i } from "react";
2
+ import "../BaseContext/index.f9cdc955.js";
3
+ import "../EnvironmentContext/index.b33784cd.js";
4
+ import { a as m } from "../../hooks/useFlagsStore/index.f7c613ac.js";
5
+ import "../HostToolsContext/index.499db832.js";
6
+ import "../DomainContext/index.2ed56159.js";
7
+ import "../ModuleDictionaryContext/index.a64207d4.js";
8
+ import "../ModulePrivilegesContext/index.79c3cc04.js";
9
+ import "../NetworkContext/index.ec7405cd.js";
10
+ import "../DomainCountryContext/index.506456a3.js";
11
+ import "../AuthContext/index.db46edbc.js";
12
+ import "../FlagsContext/index.5b096265.js";
13
+ import { jsx as n } from "react/jsx-runtime";
14
+ const p = i(null);
15
+ function g(o) {
16
+ const {
17
+ children: t,
18
+ flags: r
19
+ } = o, e = !m(r);
20
+ return /* @__PURE__ */ n(p.Provider, {
21
+ value: {
22
+ isSkeleton: e
23
+ },
24
+ children: t
25
+ });
26
+ }
27
+ export {
28
+ p as M,
29
+ g as a
30
+ };
@@ -0,0 +1,21 @@
1
+ import { useContext as o } from "react";
2
+ import "../../contexts/BaseContext/index.f9cdc955.js";
3
+ import "../../contexts/EnvironmentContext/index.b33784cd.js";
4
+ import "../../contexts/HostToolsContext/index.499db832.js";
5
+ import "../../contexts/NetworkContext/index.ec7405cd.js";
6
+ import { A as r } from "../../contexts/AuthContext/index.db46edbc.js";
7
+ import "../../contexts/FlagsContext/index.5b096265.js";
8
+ import "../../contexts/DomainContext/index.2ed56159.js";
9
+ import "../../contexts/ModuleDictionaryContext/index.a64207d4.js";
10
+ import "../../contexts/ModulePrivilegesContext/index.79c3cc04.js";
11
+ import "../../contexts/ModuleSkeletonContext/index.f6150fb9.js";
12
+ import "../../contexts/DomainCountryContext/index.506456a3.js";
13
+ const a = () => {
14
+ const t = o(r);
15
+ if (!t)
16
+ throw new Error("Auth context must be use inside AuthProvider");
17
+ return t;
18
+ };
19
+ export {
20
+ a as u
21
+ };
@@ -1,6 +1,6 @@
1
1
  import { useContext as t } from "react";
2
2
  import { D as n } from "../../contexts/DomainContext/index.2ed56159.js";
3
- import { D as e } from "../../contexts/DomainCountryContext/index.3cdf9462.js";
3
+ import { D as e } from "../../contexts/DomainCountryContext/index.506456a3.js";
4
4
  const m = () => {
5
5
  const o = t(n);
6
6
  if (!o)
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { M as e } from "../../contexts/ModuleDictionaryContext/index.44448b0d.js";
2
+ import { M as e } from "../../contexts/ModuleDictionaryContext/index.a64207d4.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.1274092a.js";
2
+ import { M as t } from "../../contexts/ModulePrivilegesContext/index.79c3cc04.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.9267d86a.js";
2
+ import { M as r } from "../../contexts/ModuleSkeletonContext/index.f6150fb9.js";
3
3
  const S = () => {
4
4
  const [t, o] = n(!0), e = s(r);
5
5
  if (!e)
package/index.js CHANGED
@@ -1,33 +1,33 @@
1
- import { C as p, E as l } from "./types/index.42c24946.js";
2
- import { B as d, a as v } from "./contexts/BaseContext/index.f9cdc955.js";
3
- import { E as P, a as C } from "./contexts/EnvironmentContext/index.b33784cd.js";
1
+ import "react";
2
+ import { B as p, a as l } from "./contexts/BaseContext/index.f9cdc955.js";
3
+ import { E as d, a as v } from "./contexts/EnvironmentContext/index.b33784cd.js";
4
+ import { F as P, a as C } from "./contexts/FlagsContext/index.5b096265.js";
5
+ import "zustand";
4
6
  import { H as D, a as S } from "./contexts/HostToolsContext/index.499db832.js";
5
- import { N as y, a as F } from "./contexts/NetworkContext/index.ec7405cd.js";
6
- import { A as k, a as h } from "./contexts/AuthContext/index.c8918b5a.js";
7
- import { F as L, a as A } from "./contexts/FlagsContext/index.5b096265.js";
8
- import { D as N, a as w } from "./contexts/DomainContext/index.2ed56159.js";
9
- import { M as W, a as O } from "./contexts/ModuleDictionaryContext/index.44448b0d.js";
10
- import { M as j, a as q } from "./contexts/ModulePrivilegesContext/index.1274092a.js";
11
- import { M as G, a as I } from "./contexts/ModuleSkeletonContext/index.9267d86a.js";
12
- import { D as K, a as Q } from "./contexts/DomainCountryContext/index.3cdf9462.js";
13
- import { u as U } from "./hooks/useBase/index.4375dcef.js";
14
- import { u as X } from "./hooks/useEnvironment/index.25f83176.js";
15
- import { a as Z, u as _ } from "./hooks/useFlagsStore/index.f7c613ac.js";
16
- import { u as oo } from "./hooks/useHostTools/index.66d9a667.js";
17
- import { u as ro, a as to } from "./hooks/useDomain/index.dd6909f6.js";
18
- import { a as so, u as io } from "./hooks/useLocalStorage/index.91bc0791.js";
19
- import { u as no } from "./hooks/useModuleDictionary/index.eec95f41.js";
20
- import { u as xo } from "./hooks/useModulePrivileges/index.e93abed8.js";
21
- import { u as lo } from "./hooks/useModuleSkeleton/index.a8238d1d.js";
22
- import { u as vo } from "./hooks/useNetwork/index.3d79002b.js";
23
- import { i as Po, u as Co } from "./hooks/usePaginate/index.1306b0de.js";
24
- import { u as Do } from "./hooks/usePropageteMF/index.c440b829.js";
25
- import { u as co } from "./hooks/useAuth/index.bd0fb946.js";
26
- import { e as Fo, g as Eo, a as ko, s as ho, v as Bo } from "./utils/index.f9db04a8.js";
7
+ import { D as y, a as F } from "./contexts/DomainContext/index.2ed56159.js";
8
+ import { M as k, a as h } from "./contexts/ModuleDictionaryContext/index.a64207d4.js";
9
+ import { M as L, a as A } from "./contexts/ModulePrivilegesContext/index.79c3cc04.js";
10
+ import { M as N, a as w } from "./contexts/ModuleSkeletonContext/index.f6150fb9.js";
11
+ import { N as W, a as O } from "./contexts/NetworkContext/index.ec7405cd.js";
12
+ import { D as j, a as q } from "./contexts/DomainCountryContext/index.506456a3.js";
13
+ import { A as G, a as I } from "./contexts/AuthContext/index.db46edbc.js";
14
+ import { u as K } from "./hooks/useBase/index.4375dcef.js";
15
+ import { u as R } from "./hooks/useEnvironment/index.25f83176.js";
16
+ import { a as V, u as X } from "./hooks/useFlagsStore/index.f7c613ac.js";
17
+ import { u as Z } from "./hooks/useHostTools/index.66d9a667.js";
18
+ import { u as $, a as oo } from "./hooks/useDomain/index.be2722d9.js";
19
+ import { a as ro, u as to } from "./hooks/useLocalStorage/index.91bc0791.js";
20
+ import { u as so } from "./hooks/useModuleDictionary/index.9004a259.js";
21
+ import { u as mo } from "./hooks/useModulePrivileges/index.6ebd7c42.js";
22
+ import { u as uo } from "./hooks/useModuleSkeleton/index.1cdf5081.js";
23
+ import { u as po } from "./hooks/useNetwork/index.3d79002b.js";
24
+ import { i as fo, u as vo } from "./hooks/usePaginate/index.1306b0de.js";
25
+ import { u as Po } from "./hooks/usePropageteMF/index.c440b829.js";
26
+ import { u as Mo } from "./hooks/useAuth/index.4154d394.js";
27
+ import { C as So, E as co } from "./types/index.42c24946.js";
28
+ import { e as Fo, g as Eo, a as ko, s as ho, v as Bo } from "./utils/index.2f5ce5aa.js";
27
29
  import { a as Ao } from "./utils/axiosOperation.ac6c8eef.js";
28
- import "react";
29
30
  import "react/jsx-runtime";
30
- import "zustand";
31
31
  import "zustand/middleware";
32
32
  import "./node_modules.04fac7e9.js";
33
33
  import "axios";
@@ -35,51 +35,51 @@ import "qs";
35
35
  import "camelcase-keys";
36
36
  import "snakecase-keys";
37
37
  export {
38
- k as AuthContext,
39
- h as AuthProvider,
40
- d as BaseContext,
41
- v as BaseProvider,
42
- p as CommonFlags,
43
- N as DomainContext,
44
- K as DomainCountryContext,
45
- Q as DomainCountryProvider,
46
- w as DomainProvider,
47
- l as EmitEvents,
48
- P as EnvironmentContext,
49
- C as EnvironmentProvider,
50
- L as FlagsContext,
51
- A as FlagsProvider,
38
+ G as AuthContext,
39
+ I as AuthProvider,
40
+ p as BaseContext,
41
+ l as BaseProvider,
42
+ So as CommonFlags,
43
+ y as DomainContext,
44
+ j as DomainCountryContext,
45
+ q as DomainCountryProvider,
46
+ F as DomainProvider,
47
+ co as EmitEvents,
48
+ d as EnvironmentContext,
49
+ v as EnvironmentProvider,
50
+ P as FlagsContext,
51
+ C as FlagsProvider,
52
52
  D as HostToolsContext,
53
53
  S as HostToolsProvider,
54
- W as ModuleDictionaryContext,
55
- O as ModuleDictionaryProvider,
56
- j as ModulePrivilegesContext,
57
- q as ModulePrivilegesProvider,
58
- G as ModuleSkeletonContext,
59
- I as ModuleSkeletonProvider,
60
- y as NetworkContext,
61
- F as NetworkProvider,
54
+ k as ModuleDictionaryContext,
55
+ h as ModuleDictionaryProvider,
56
+ L as ModulePrivilegesContext,
57
+ A as ModulePrivilegesProvider,
58
+ N as ModuleSkeletonContext,
59
+ w as ModuleSkeletonProvider,
60
+ W as NetworkContext,
61
+ O as NetworkProvider,
62
62
  Ao as axiosOperation,
63
63
  Fo as evaluateWithContext,
64
64
  Eo as getLocalStorage,
65
65
  ko as getPropertyByString,
66
- Po as initialPagerState,
66
+ fo as initialPagerState,
67
67
  ho as setLocalStorage,
68
- co as useAuth,
69
- U as useBase,
70
- ro as useDomain,
71
- to as useDomainCountry,
72
- X as useEnvironment,
73
- Z as useFlagsPresent,
74
- _ as useFlagsStore,
75
- oo as useHostTools,
76
- so as useLocalStorage,
77
- io as useLocalStorageWithListener,
78
- no as useModuleDictionary,
79
- xo as useModulePrivileges,
80
- lo as useModuleSkeleton,
81
- vo as useNetwork,
82
- Co as usePaginate,
83
- Do as usePropageteMF,
68
+ Mo as useAuth,
69
+ K as useBase,
70
+ $ as useDomain,
71
+ oo as useDomainCountry,
72
+ R as useEnvironment,
73
+ V as useFlagsPresent,
74
+ X as useFlagsStore,
75
+ Z as useHostTools,
76
+ ro as useLocalStorage,
77
+ to as useLocalStorageWithListener,
78
+ so as useModuleDictionary,
79
+ mo as useModulePrivileges,
80
+ uo as useModuleSkeleton,
81
+ po as useNetwork,
82
+ vo as usePaginate,
83
+ Po as usePropageteMF,
84
84
  Bo as voidFunction
85
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "private": false,
@@ -1,6 +1,10 @@
1
- function l() {
1
+ import "axios";
2
+ import "qs";
3
+ import "camelcase-keys";
4
+ import "snakecase-keys";
5
+ function y() {
2
6
  }
3
- function u(n, e) {
7
+ function p(n, e) {
4
8
  const r = e.split(".");
5
9
  let t = n;
6
10
  for (const o of r) {
@@ -23,7 +27,7 @@ function u(n, e) {
23
27
  }
24
28
  return t;
25
29
  }
26
- function g(n, e) {
30
+ function d(n, e) {
27
31
  try {
28
32
  const t = new Function(...Object.keys(n), `return \`${e}\``)(...Object.values(n));
29
33
  return String(t).replace(/`/g, "");
@@ -31,7 +35,7 @@ function g(n, e) {
31
35
  return console.error(`Error evaluating expression: ${r}`), "";
32
36
  }
33
37
  }
34
- function f(n, e) {
38
+ function m(n, e) {
35
39
  try {
36
40
  const r = window.localStorage.getItem(n);
37
41
  return r !== null ? typeof e == "string" ? r : JSON.parse(r) : e;
@@ -39,7 +43,7 @@ function f(n, e) {
39
43
  return e;
40
44
  }
41
45
  }
42
- function y(n, e, r = !1) {
46
+ function v(n, e, r = !1) {
43
47
  try {
44
48
  let t = null;
45
49
  if (typeof e == "string") {
@@ -53,9 +57,9 @@ function y(n, e, r = !1) {
53
57
  }
54
58
  }
55
59
  export {
56
- u as a,
57
- g as e,
58
- f as g,
59
- y as s,
60
- l as v
60
+ p as a,
61
+ d as e,
62
+ m as g,
63
+ v as s,
64
+ y as v
61
65
  };
package/vite-env.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /// <reference types="vite/client" />
2
- /// <reference types="vitest" />
3
- /// <reference types="vitest/globals" />
4
- /// <reference types="vitest/importMeta" />
1
+ /// <reference types="vite/client" />
2
+ /// <reference types="vitest" />
3
+ /// <reference types="vitest/globals" />
4
+ /// <reference types="vitest/importMeta" />
@@ -1,135 +0,0 @@
1
- import { createContext as T, useReducer as y, useEffect as d } from "react";
2
- import { E } from "../../types/index.42c24946.js";
3
- import { jsx as v } from "react/jsx-runtime";
4
- import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
5
- import { u as N } from "../../hooks/useNetwork/index.3d79002b.js";
6
- import { u as O } from "../../hooks/useEnvironment/index.25f83176.js";
7
- import { u as S } from "../../hooks/useLocalStorage/index.91bc0791.js";
8
- import { g as U, s as u } from "../../utils/index.f9db04a8.js";
9
- var s = /* @__PURE__ */ ((t) => (t.Initial = "INITIALIZE", t.Login = "LOGIN", t.Logout = "LOGOUT", t))(s || {});
10
- const w = {
11
- isAuthenticated: !1,
12
- isInitialized: !1,
13
- user: null
14
- }, _ = (t, e) => {
15
- switch (e.type) {
16
- case "INITIALIZE":
17
- return {
18
- isAuthenticated: e.payload.isAuthenticated,
19
- isInitialized: !0,
20
- user: e.payload.user
21
- };
22
- case "LOGIN":
23
- return {
24
- ...t,
25
- isAuthenticated: !0,
26
- user: e.payload.user
27
- };
28
- case "LOGOUT":
29
- return {
30
- ...t,
31
- isAuthenticated: !1,
32
- user: null
33
- };
34
- default:
35
- return t;
36
- }
37
- }, P = T(null);
38
- function x(t) {
39
- t({
40
- type: s.Initial,
41
- payload: {
42
- isAuthenticated: !1,
43
- user: null
44
- }
45
- });
46
- }
47
- function M(t) {
48
- const {
49
- children: e
50
- } = t, [m, n] = y(_, w), {
51
- events_add_listener: h
52
- } = D(), {
53
- networkOperation: r
54
- } = N(), {
55
- domain_token: f
56
- } = O(), [I, l] = S(
57
- "vSession",
58
- new Date().getTime() + ""
59
- );
60
- d(() => {
61
- (async () => {
62
- r({
63
- method: "GET",
64
- endPoint: "auth/login",
65
- parms: {
66
- user_data: !0
67
- },
68
- checkUnAuthorized: !1
69
- }).then((i) => {
70
- n({
71
- type: s.Initial,
72
- payload: {
73
- isAuthenticated: !0,
74
- user: i.user
75
- }
76
- }), U("userData", {
77
- email: i.user.email,
78
- remember: !0
79
- })?.email !== i.user.email && u("userData", {
80
- email: i.user.email
81
- }, !0);
82
- }).catch(() => {
83
- x(n);
84
- });
85
- })();
86
- }, [I]);
87
- const g = async (a, i, o) => {
88
- await r({
89
- endPoint: "auth/login",
90
- method: "POST",
91
- data: {
92
- email: a,
93
- password: i,
94
- domain_token: f
95
- }
96
- }).then((L) => {
97
- const A = L.data;
98
- o ? u("userData", {
99
- email: a,
100
- remember: o
101
- }) : u("userData", {
102
- email: "",
103
- remember: o
104
- }), n({
105
- type: s.Login,
106
- payload: {
107
- user: A
108
- }
109
- }), l(new Date().getTime() + "");
110
- });
111
- }, c = async (a) => {
112
- a && await r({
113
- endPoint: "auth/logout",
114
- method: "POST"
115
- }), n({
116
- type: s.Logout
117
- }), l(new Date().getTime() + "");
118
- }, p = () => {
119
- c(!1);
120
- };
121
- return d(function() {
122
- h(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, p);
123
- }, []), /* @__PURE__ */ v(P.Provider, {
124
- value: {
125
- ...m,
126
- login: g,
127
- logout: c
128
- },
129
- children: e
130
- });
131
- }
132
- export {
133
- P as A,
134
- M as a
135
- };
@@ -1,46 +0,0 @@
1
- import { createContext as d, useState as y, useCallback as T } from "react";
2
- import { E as r } from "../../types/index.42c24946.js";
3
- import { jsx as f } from "react/jsx-runtime";
4
- import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
5
- import { u as M } from "../../hooks/usePropageteMF/index.c440b829.js";
6
- const N = d(null);
7
- function A(e) {
8
- const {
9
- children: s,
10
- isMicroFrontEnd: t,
11
- id: i,
12
- currency: a,
13
- currency_decimal_digits: m,
14
- decimal_symbol: c,
15
- thousands_symbol: u
16
- } = e, {
17
- events_emit: _
18
- } = D(), [l, C] = y({
19
- id: i,
20
- currency: a,
21
- currency_decimal_digits: m,
22
- decimal_symbol: c,
23
- thousands_symbol: u
24
- }), n = (o) => {
25
- C(o);
26
- };
27
- M({
28
- isMicroFrontEnd: t,
29
- event: r.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
30
- setHandler: n
31
- });
32
- const E = T((o) => {
33
- t || (n(o), _(r.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
34
- }, []);
35
- return /* @__PURE__ */ f(N.Provider, {
36
- value: {
37
- ...l,
38
- changeDomainCountry: E
39
- },
40
- children: s
41
- });
42
- }
43
- export {
44
- N as D,
45
- A as a
46
- };
@@ -1,71 +0,0 @@
1
- import { createContext as F, useState as y, useEffect as A, useCallback as u } from "react";
2
- import { C as L } from "../../types/index.42c24946.js";
3
- import { jsx as M } from "react/jsx-runtime";
4
- import { u as N } from "../../hooks/useFlagsStore/index.f7c613ac.js";
5
- import { u as P } from "../../hooks/useEnvironment/index.25f83176.js";
6
- import { u as _ } from "../../hooks/useHostTools/index.66d9a667.js";
7
- import { u as x } from "../../hooks/useNetwork/index.3d79002b.js";
8
- const E = F(null);
9
- function S(l) {
10
- const {
11
- children: c,
12
- componentsDictionary: m,
13
- moduleId: s,
14
- moduleNameField: i = "module_name",
15
- currentLang: d = "en",
16
- isAuth: a = !0
17
- } = l, f = N((t) => t.flagsActions.addFlag), [e, p] = y(void 0), {
18
- domain_token: g
19
- } = P(), {
20
- startProgress: D,
21
- stopProgress: h
22
- } = _(), {
23
- networkOperation: v
24
- } = x();
25
- A(() => {
26
- let t = !0;
27
- return D(), v({
28
- method: "GET",
29
- endPoint: a ? `dictionaries/${s}` : `na/dictionaries/${s}`,
30
- parms: {
31
- comps: m,
32
- ...a ? {} : {
33
- domain_token: g
34
- }
35
- }
36
- }).then((o) => {
37
- t && (p({
38
- ...o
39
- }), f(L.FLAG_DICTIONARY_LOADED));
40
- }).finally(() => {
41
- h();
42
- }), function() {
43
- t = !1;
44
- };
45
- }, [d]);
46
- const n = u((t) => {
47
- if (e === void 0)
48
- return "";
49
- if (t === "")
50
- return "No key";
51
- let o;
52
- const r = t.split(".");
53
- try {
54
- r.length === 1 && (o = e.data[t]), r.length === 2 && (o = e[r[0]][r[1]]);
55
- } catch {
56
- }
57
- return o || `N_D:[${t}]`;
58
- }, [e]), C = u(() => n(i), [i, n]);
59
- return /* @__PURE__ */ M(E.Provider, {
60
- value: {
61
- moduleDictionary: e,
62
- getLabel: n,
63
- getModuleLabel: C
64
- },
65
- children: c
66
- });
67
- }
68
- export {
69
- E as M,
70
- S as a
71
- };
@@ -1,52 +0,0 @@
1
- import { createContext as f, useState as d, useEffect as p, useCallback as P } from "react";
2
- import { C as i } from "../../types/index.42c24946.js";
3
- import { jsx as v } from "react/jsx-runtime";
4
- import { u as E } from "../../hooks/useFlagsStore/index.f7c613ac.js";
5
- import { u as h } from "../../hooks/useHostTools/index.66d9a667.js";
6
- import { u as F } from "../../hooks/useNetwork/index.3d79002b.js";
7
- const L = f(null);
8
- function S(n) {
9
- const {
10
- children: a,
11
- queryPrivileges: r
12
- } = n, o = E((e) => e.flagsActions.addFlag), [t, l] = d({}), {
13
- startProgress: u,
14
- stopProgress: m
15
- } = h(), {
16
- networkOperation: g
17
- } = F();
18
- p(() => {
19
- let e = !0;
20
- if (r.length === 0) {
21
- o(i.FLAG_PRIVILEGES_LOADED);
22
- return;
23
- }
24
- return u(), g({
25
- method: "GET",
26
- endPoint: "auth/login",
27
- parms: {
28
- privileges: r
29
- }
30
- }).then((s) => {
31
- e && (l({
32
- ...s.data
33
- }), o(i.FLAG_PRIVILEGES_LOADED));
34
- }).finally(() => {
35
- m();
36
- }), function() {
37
- e = !1;
38
- };
39
- }, []);
40
- const c = P((e) => e in t, [t]);
41
- return /* @__PURE__ */ v(L.Provider, {
42
- value: {
43
- hasPrivilege: c,
44
- privileges: t
45
- },
46
- children: a
47
- });
48
- }
49
- export {
50
- L as M,
51
- S as a
52
- };
@@ -1,20 +0,0 @@
1
- import { createContext as n } from "react";
2
- import { jsx as s } from "react/jsx-runtime";
3
- import { a as l } from "../../hooks/useFlagsStore/index.f7c613ac.js";
4
- const a = n(null);
5
- function m(e) {
6
- const {
7
- children: o,
8
- flags: t
9
- } = e, r = !l(t);
10
- return /* @__PURE__ */ s(a.Provider, {
11
- value: {
12
- isSkeleton: r
13
- },
14
- children: o
15
- });
16
- }
17
- export {
18
- a as M,
19
- m as a
20
- };
@@ -1,11 +0,0 @@
1
- import { useContext as o } from "react";
2
- import { A as e } from "../../contexts/AuthContext/index.c8918b5a.js";
3
- const n = () => {
4
- const t = o(e);
5
- if (!t)
6
- throw new Error("Auth context must be use inside AuthProvider");
7
- return t;
8
- };
9
- export {
10
- n as u
11
- };