@m4l/core 1.0.1 → 1.1.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.
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { AuthProviderProps, SessionContextType } from './types';
3
+ declare const AuthContext: React.Context<SessionContextType | null>;
4
+ declare function AuthProvider(props: AuthProviderProps): React.JSX.Element;
5
+ export { AuthContext, AuthProvider };
@@ -0,0 +1,135 @@
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.7dbb3411.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
+ };
@@ -0,0 +1,2 @@
1
+ export * from './AuthContext';
2
+ export * from './types';
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DomainCountry } from '../DomainCountryContext/types';
3
+ import type { Maybe } from '../../types';
4
+ export declare enum EnumTypes {
5
+ Initial = "INITIALIZE",
6
+ Login = "LOGIN",
7
+ Logout = "LOGOUT"
8
+ }
9
+ export declare type AuthProviderProps = {
10
+ children: ReactNode;
11
+ };
12
+ export declare type ActionMap<M extends {
13
+ [index: string]: any;
14
+ }> = {
15
+ [Key in keyof M]: M[Key] extends undefined ? {
16
+ type: Key;
17
+ } : {
18
+ type: Key;
19
+ payload: M[Key];
20
+ };
21
+ };
22
+ export declare type SessionAuthPayload = {
23
+ [EnumTypes.Initial]: {
24
+ isAuthenticated: boolean;
25
+ user: AuthUser;
26
+ };
27
+ [EnumTypes.Login]: {
28
+ user: AuthUser;
29
+ };
30
+ [EnumTypes.Logout]: undefined;
31
+ };
32
+ export declare type SessionActions = ActionMap<SessionAuthPayload>[keyof ActionMap<SessionAuthPayload>];
33
+ export interface User {
34
+ email: string;
35
+ id: number;
36
+ first_name: string;
37
+ last_name: string;
38
+ account_id: number;
39
+ domain_country: DomainCountry;
40
+ avatar_url?: Maybe<string>;
41
+ user_type_id?: number;
42
+ }
43
+ export declare type AuthUser = Maybe<User>;
44
+ export declare type AuthState = {
45
+ isAuthenticated: boolean;
46
+ isInitialized: boolean;
47
+ user: AuthUser;
48
+ };
49
+ export interface SessionContextType extends AuthState {
50
+ login: (email: string, password: string, remember: boolean) => object | undefined;
51
+ logout: (isAuthenticated: boolean) => Promise<void>;
52
+ }
@@ -0,0 +1,46 @@
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
+ };
@@ -0,0 +1,71 @@
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
+ };
@@ -0,0 +1,52 @@
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
+ };
@@ -0,0 +1,20 @@
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
+ };
@@ -2,6 +2,7 @@ export { BaseContext, BaseProvider } from './BaseContext';
2
2
  export { EnvironmentContext, EnvironmentProvider } from './EnvironmentContext';
3
3
  export { HostToolsContext, HostToolsProvider } from './HostToolsContext';
4
4
  export { NetworkContext, NetworkProvider } from './NetworkContext';
5
+ export { AuthContext, AuthProvider } from './AuthContext';
5
6
  export { FlagsContext, FlagsProvider } from './FlagsContext';
6
7
  export { DomainContext, DomainProvider } from './DomainContext';
7
8
  export { ModuleDictionaryContext, ModuleDictionaryProvider } from './ModuleDictionaryContext';
package/hooks/index.d.ts CHANGED
@@ -12,5 +12,6 @@ export { useNetwork } from './useNetwork';
12
12
  export { usePaginate } from './usePaginate';
13
13
  export { usePropageteMF } from './usePropageteMF';
14
14
  export { useDomainCountry } from './useDomainCountry';
15
+ export { useAuth } from './useAuth';
15
16
  export type { PagerState } from './usePaginate/types';
16
17
  export { initialPagerState } from './usePaginate/types';
@@ -0,0 +1,11 @@
1
+ import { useContext as o } from "react";
2
+ import { A as e } from "../../contexts/AuthContext/index.717a8c86.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
+ };
@@ -0,0 +1 @@
1
+ export { useAuth } from './useAuth';
@@ -0,0 +1,2 @@
1
+ export declare const useAuth: () => import("../../contexts/AuthContext").SessionContextType;
2
+ export default useAuth;
@@ -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.e7a82641.js";
3
+ import { D as e } from "../../contexts/DomainCountryContext/index.3cdf9462.js";
4
4
  const m = () => {
5
5
  const o = t(n);
6
6
  if (!o)
@@ -50,6 +50,6 @@ function u(o, e) {
50
50
  }];
51
51
  }
52
52
  export {
53
- u as a,
54
- S as u
53
+ S as a,
54
+ u
55
55
  };
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { M as e } from "../../contexts/ModuleDictionaryContext/index.011db031.js";
2
+ import { M as e } from "../../contexts/ModuleDictionaryContext/index.44448b0d.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.a45d4cf7.js";
2
+ import { M as t } from "../../contexts/ModulePrivilegesContext/index.1274092a.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.2cd78f14.js";
2
+ import { M as r } from "../../contexts/ModuleSkeletonContext/index.9267d86a.js";
3
3
  const S = () => {
4
4
  const [t, o] = n(!0), e = s(r);
5
5
  if (!e)
package/index.js CHANGED
@@ -1,31 +1,33 @@
1
- import "react";
2
- import { B as x, 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";
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";
6
4
  import { H as D, a as S } from "./contexts/HostToolsContext/index.499db832.js";
7
- import { D as y, a as F } from "./contexts/DomainContext/index.2ed56159.js";
8
- import { M as k, a as B } from "./contexts/ModuleDictionaryContext/index.011db031.js";
9
- import { M as H, a as N } from "./contexts/ModulePrivilegesContext/index.a45d4cf7.js";
10
- import { M as T, a as h } from "./contexts/ModuleSkeletonContext/index.2cd78f14.js";
11
- import { N as O, a as b } from "./contexts/NetworkContext/index.ec7405cd.js";
12
- import { D as q, a as z } from "./contexts/DomainCountryContext/index.e7a82641.js";
13
- import { u as G } from "./hooks/useBase/index.4375dcef.js";
14
- import { u as J } from "./hooks/useEnvironment/index.25f83176.js";
15
- import { a as Q, u as R } from "./hooks/useFlagsStore/index.f7c613ac.js";
16
- import { u as V } from "./hooks/useHostTools/index.66d9a667.js";
17
- import { u as Y, a as Z } from "./hooks/useDomain/index.b743be01.js";
18
- import { u as $, a as oo } from "./hooks/useLocalStorage/index.48b47dca.js";
19
- import { u as ro } from "./hooks/useModuleDictionary/index.0a0998b6.js";
20
- import { u as ao } from "./hooks/useModulePrivileges/index.24c10523.js";
21
- import { u as io } from "./hooks/useModuleSkeleton/index.12ff3650.js";
22
- import { u as no } from "./hooks/useNetwork/index.3d79002b.js";
23
- import { i as po, u as xo } from "./hooks/usePaginate/index.1306b0de.js";
24
- import { u as fo } from "./hooks/usePropageteMF/index.c440b829.js";
25
- import { C as go, E as Po } from "./types/index.42c24946.js";
26
- import { e as Mo, a as Do, g as So, s as co, v as yo } from "./utils/index.6d56ba04.js";
27
- import { a as Eo } from "./utils/axiosOperation.ce4250d4.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.717a8c86.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.7dbb3411.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.5356a5e9.js";
26
+ import { e as Fo, g as Eo, a as ko, s as ho, v as Bo } from "./utils/index.f9db04a8.js";
27
+ import { a as Ao } from "./utils/axiosOperation.ce4250d4.js";
28
+ import "react";
28
29
  import "react/jsx-runtime";
30
+ import "zustand";
29
31
  import "zustand/middleware";
30
32
  import "./node_modules.04fac7e9.js";
31
33
  import "axios";
@@ -33,48 +35,51 @@ import "qs";
33
35
  import "camelcase-keys";
34
36
  import "snakecase-keys";
35
37
  export {
36
- x as BaseContext,
37
- l as BaseProvider,
38
- go as CommonFlags,
39
- y as DomainContext,
40
- q as DomainCountryContext,
41
- z as DomainCountryProvider,
42
- F as DomainProvider,
43
- Po as EmitEvents,
44
- d as EnvironmentContext,
45
- v as EnvironmentProvider,
46
- P as FlagsContext,
47
- C as FlagsProvider,
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,
48
52
  D as HostToolsContext,
49
53
  S as HostToolsProvider,
50
- k as ModuleDictionaryContext,
51
- B as ModuleDictionaryProvider,
52
- H as ModulePrivilegesContext,
53
- N as ModulePrivilegesProvider,
54
- T as ModuleSkeletonContext,
55
- h as ModuleSkeletonProvider,
56
- O as NetworkContext,
57
- b as NetworkProvider,
58
- Eo as axiosOperation,
59
- Mo as evaluateWithContext,
60
- Do as getLocalStorage,
61
- So as getPropertyByString,
62
- po as initialPagerState,
63
- co as setLocalStorage,
64
- G as useBase,
65
- Y as useDomain,
66
- Z as useDomainCountry,
67
- J as useEnvironment,
68
- Q as useFlagsPresent,
69
- R as useFlagsStore,
70
- V as useHostTools,
71
- $ as useLocalStorage,
72
- oo as useLocalStorageWithListener,
73
- ro as useModuleDictionary,
74
- ao as useModulePrivileges,
75
- io as useModuleSkeleton,
76
- no as useNetwork,
77
- xo as usePaginate,
78
- fo as usePropageteMF,
79
- yo as voidFunction
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,
62
+ Ao as axiosOperation,
63
+ Fo as evaluateWithContext,
64
+ Eo as getLocalStorage,
65
+ ko as getPropertyByString,
66
+ Po as initialPagerState,
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,
84
+ Bo as voidFunction
80
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "private": false,
@@ -1,10 +1,6 @@
1
- import "axios";
2
- import "qs";
3
- import "camelcase-keys";
4
- import "snakecase-keys";
5
- function y() {
1
+ function l() {
6
2
  }
7
- function p(n, e) {
3
+ function u(n, e) {
8
4
  const r = e.split(".");
9
5
  let t = n;
10
6
  for (const o of r) {
@@ -27,7 +23,7 @@ function p(n, e) {
27
23
  }
28
24
  return t;
29
25
  }
30
- function d(n, e) {
26
+ function g(n, e) {
31
27
  try {
32
28
  const t = new Function(...Object.keys(n), `return \`${e}\``)(...Object.values(n));
33
29
  return String(t).replace(/`/g, "");
@@ -35,7 +31,7 @@ function d(n, e) {
35
31
  return console.error(`Error evaluating expression: ${r}`), "";
36
32
  }
37
33
  }
38
- function m(n, e) {
34
+ function f(n, e) {
39
35
  try {
40
36
  const r = window.localStorage.getItem(n);
41
37
  return r !== null ? typeof e == "string" ? r : JSON.parse(r) : e;
@@ -43,7 +39,7 @@ function m(n, e) {
43
39
  return e;
44
40
  }
45
41
  }
46
- function v(n, e, r = !1) {
42
+ function y(n, e, r = !1) {
47
43
  try {
48
44
  let t = null;
49
45
  if (typeof e == "string") {
@@ -57,9 +53,9 @@ function v(n, e, r = !1) {
57
53
  }
58
54
  }
59
55
  export {
60
- m as a,
61
- d as e,
62
- p as g,
63
- v as s,
64
- y as v
56
+ u as a,
57
+ g as e,
58
+ f as g,
59
+ y as s,
60
+ l as v
65
61
  };
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,55 +0,0 @@
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.011db031.js";
9
- import "../ModulePrivilegesContext/index.a45d4cf7.js";
10
- import "../ModuleSkeletonContext/index.2cd78f14.js";
11
- import "../NetworkContext/index.ec7405cd.js";
12
- import { u as f } from "../../hooks/usePropageteMF/index.c440b829.js";
13
- import { E as i } from "../../types/index.42c24946.js";
14
- import { jsx as D } from "react/jsx-runtime";
15
- const M = E(null);
16
- function R(n) {
17
- const {
18
- children: e,
19
- isMicroFrontEnd: t,
20
- id: m,
21
- currency: s,
22
- currency_decimal_digits: a,
23
- decimal_symbol: c,
24
- thousands_symbol: u
25
- } = n, {
26
- events_emit: p
27
- } = T(), [_, l] = d({
28
- id: m,
29
- currency: s,
30
- currency_decimal_digits: a,
31
- decimal_symbol: c,
32
- thousands_symbol: u
33
- }), r = (o) => {
34
- l(o);
35
- };
36
- f({
37
- isMicroFrontEnd: t,
38
- event: i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE,
39
- setHandler: r
40
- });
41
- const C = y((o) => {
42
- t || (r(o), p(i.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
43
- }, []);
44
- return /* @__PURE__ */ D(M.Provider, {
45
- value: {
46
- ..._,
47
- changeDomainCountry: C
48
- },
49
- children: e
50
- });
51
- }
52
- export {
53
- M as D,
54
- R as a
55
- };
@@ -1,76 +0,0 @@
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.a45d4cf7.js";
8
- import "../ModuleSkeletonContext/index.2cd78f14.js";
9
- import { u as P } from "../../hooks/useNetwork/index.3d79002b.js";
10
- import "../DomainCountryContext/index.e7a82641.js";
11
- import { C as _ } from "../../types/index.42c24946.js";
12
- import { jsx as x } from "react/jsx-runtime";
13
- const E = F(null);
14
- function Y(u) {
15
- const {
16
- children: l,
17
- componentsDictionary: c,
18
- moduleId: i,
19
- moduleNameField: s = "module_name",
20
- currentLang: d = "en",
21
- isAuth: a = !0
22
- } = u, p = M((t) => t.flagsActions.addFlag), [r, f] = y(void 0), {
23
- domain_token: g
24
- } = L(), {
25
- startProgress: D,
26
- stopProgress: h
27
- } = N(), {
28
- networkOperation: v
29
- } = P();
30
- A(() => {
31
- let t = !0;
32
- return D(), v({
33
- method: "GET",
34
- endPoint: a ? `dictionaries/${i}` : `na/dictionaries/${i}`,
35
- parms: {
36
- comps: c,
37
- ...a ? {} : {
38
- domain_token: g
39
- }
40
- }
41
- }).then((o) => {
42
- t && (f({
43
- ...o
44
- }), p(_.FLAG_DICTIONARY_LOADED));
45
- }).finally(() => {
46
- h();
47
- }), function() {
48
- t = !1;
49
- };
50
- }, [d]);
51
- const n = m((t) => {
52
- if (r === void 0)
53
- return "";
54
- if (t === "")
55
- return "No key";
56
- let o;
57
- const e = t.split(".");
58
- try {
59
- e.length === 1 && (o = r.data[t]), e.length === 2 && (o = r[e[0]][e[1]]);
60
- } catch {
61
- }
62
- return o || `N_D:[${t}]`;
63
- }, [r]), C = m(() => n(s), [s, n]);
64
- return /* @__PURE__ */ x(E.Provider, {
65
- value: {
66
- moduleDictionary: r,
67
- getLabel: n,
68
- getModuleLabel: C
69
- },
70
- children: l
71
- });
72
- }
73
- export {
74
- E as M,
75
- Y as a
76
- };
@@ -1,58 +0,0 @@
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.011db031.js";
8
- import "../ModuleSkeletonContext/index.2cd78f14.js";
9
- import { u as h } from "../../hooks/useNetwork/index.3d79002b.js";
10
- import "../DomainCountryContext/index.e7a82641.js";
11
- import { C as i } from "../../types/index.42c24946.js";
12
- import { jsx as F } from "react/jsx-runtime";
13
- const L = c(null);
14
- function y(n) {
15
- const {
16
- children: a,
17
- queryPrivileges: r
18
- } = n, o = v((e) => e.flagsActions.addFlag), [t, l] = f({}), {
19
- startProgress: m,
20
- stopProgress: u
21
- } = E(), {
22
- networkOperation: p
23
- } = h();
24
- d(() => {
25
- let e = !0;
26
- if (r.length === 0) {
27
- o(i.FLAG_PRIVILEGES_LOADED);
28
- return;
29
- }
30
- return m(), p({
31
- method: "GET",
32
- endPoint: "auth/login",
33
- parms: {
34
- privileges: r
35
- }
36
- }).then((s) => {
37
- e && (l({
38
- ...s.data
39
- }), o(i.FLAG_PRIVILEGES_LOADED));
40
- }).finally(() => {
41
- u();
42
- }), function() {
43
- e = !1;
44
- };
45
- }, []);
46
- const g = P((e) => e in t, [t]);
47
- return /* @__PURE__ */ F(L.Provider, {
48
- value: {
49
- hasPrivilege: g,
50
- privileges: t
51
- },
52
- children: a
53
- });
54
- }
55
- export {
56
- L as M,
57
- y as a
58
- };
@@ -1,28 +0,0 @@
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.011db031.js";
8
- import "../ModulePrivilegesContext/index.a45d4cf7.js";
9
- import "../NetworkContext/index.ec7405cd.js";
10
- import "../DomainCountryContext/index.e7a82641.js";
11
- import { jsx as n } from "react/jsx-runtime";
12
- const p = i(null);
13
- function P(o) {
14
- const {
15
- children: t,
16
- flags: r
17
- } = o, e = !m(r);
18
- return /* @__PURE__ */ n(p.Provider, {
19
- value: {
20
- isSkeleton: e
21
- },
22
- children: t
23
- });
24
- }
25
- export {
26
- p as M,
27
- P as a
28
- };