@m4l/core 2.0.3 → 2.0.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.
@@ -0,0 +1,5 @@
1
+ export declare enum EnumTypes {
2
+ Initial = "INITIALIZE",
3
+ Login = "LOGIN",
4
+ Logout = "LOGOUT"
5
+ }
@@ -1,59 +1,59 @@
1
- import { createContext as T, useReducer as y, useEffect as d } from "react";
1
+ import { createContext as A, useReducer as y, useEffect as d } from "react";
2
2
  import { E } from "../../types/index-TbOJOhBX.js";
3
3
  import { jsx as v } from "react/jsx-runtime";
4
4
  import { u as D } from "../../hooks/useHostTools/index-CL3d7qFm.js";
5
5
  import { u as N } from "../../hooks/useNetwork/index--IzMsMJ2.js";
6
6
  import { u as O } from "../../hooks/useEnvironment/index-D1xRKaoe.js";
7
7
  import { u as S } from "../../hooks/useLocalStorage/index-CsLmjbAr.js";
8
- import { g as U, s as u } from "../../utils/index-BNOjc4WT.js";
9
- var s = /* @__PURE__ */ ((t) => (t.Initial = "INITIALIZE", t.Login = "LOGIN", t.Logout = "LOGOUT", t))(s || {});
8
+ import { g as U, s as u } from "../../utils/index-C67J5HEa.js";
9
+ var i = /* @__PURE__ */ ((e) => (e.Initial = "INITIALIZE", e.Login = "LOGIN", e.Logout = "LOGOUT", e))(i || {});
10
10
  const w = {
11
11
  isAuthenticated: !1,
12
12
  isInitialized: !1,
13
13
  user: null
14
- }, _ = (t, e) => {
15
- switch (e.type) {
14
+ }, _ = (e, t) => {
15
+ switch (t.type) {
16
16
  case "INITIALIZE":
17
17
  return {
18
- isAuthenticated: e.payload.isAuthenticated,
18
+ isAuthenticated: t.payload.isAuthenticated,
19
19
  isInitialized: !0,
20
- user: e.payload.user
20
+ user: t.payload.user
21
21
  };
22
22
  case "LOGIN":
23
23
  return {
24
- ...t,
24
+ ...e,
25
25
  isAuthenticated: !0,
26
- user: e.payload.user
26
+ user: t.payload.user
27
27
  };
28
28
  case "LOGOUT":
29
29
  return {
30
- ...t,
30
+ ...e,
31
31
  isAuthenticated: !1,
32
32
  user: null
33
33
  };
34
34
  default:
35
- return t;
35
+ return e;
36
36
  }
37
- }, P = T(null);
38
- function x(t) {
39
- t({
40
- type: s.Initial,
37
+ }, C = A(null);
38
+ function P(e) {
39
+ e({
40
+ type: i.Initial,
41
41
  payload: {
42
42
  isAuthenticated: !1,
43
43
  user: null
44
44
  }
45
45
  });
46
46
  }
47
- function M(t) {
47
+ function M(e) {
48
48
  const {
49
- children: e
50
- } = t, [m, n] = y(_, w), {
49
+ children: t
50
+ } = e, [m, o] = y(_, w), {
51
51
  events_add_listener: h
52
52
  } = D(), {
53
53
  networkOperation: r
54
54
  } = N(), {
55
55
  domain_token: f
56
- } = O(), [I, l] = S(
56
+ } = O(), [p, l] = S(
57
57
  // Variable para saber si ha cambiado la session en otro navegador
58
58
  "vSession",
59
59
  (/* @__PURE__ */ new Date()).getTime() + ""
@@ -66,46 +66,48 @@ function M(t) {
66
66
  parms: {
67
67
  user_data: !0
68
68
  },
69
- checkUnAuthorized: !1
70
- }).then((i) => {
71
- n({
72
- type: s.Initial,
69
+ checkUnAuthorized: !1,
70
+ responseToCamelCase: !0
71
+ }).then((s) => {
72
+ o({
73
+ type: i.Initial,
73
74
  payload: {
74
75
  isAuthenticated: !0,
75
- user: i.user
76
+ user: s.user
76
77
  }
77
78
  }), U("userData", {
78
- email: i.user.email,
79
+ email: s.user.email,
79
80
  remember: !0
80
- })?.email !== i.user.email && u("userData", {
81
- email: i.user.email
81
+ })?.email !== s.user.email && u("userData", {
82
+ email: s.user.email
82
83
  }, !0);
83
84
  }).catch(() => {
84
- x(n);
85
+ P(o);
85
86
  });
86
87
  })();
87
- }, [I]);
88
- const g = async (a, i, o) => {
88
+ }, [p]);
89
+ const I = async (a, s, n) => {
89
90
  await r({
90
91
  endPoint: "auth/login",
91
92
  method: "POST",
92
93
  data: {
93
94
  email: a,
94
- password: i,
95
+ password: s,
95
96
  domain_token: f
96
- }
97
- }).then((L) => {
98
- const A = L.data;
99
- o ? u("userData", {
97
+ },
98
+ responseToCamelCase: !0
99
+ }).then((T) => {
100
+ const L = T.data;
101
+ n ? u("userData", {
100
102
  email: a,
101
- remember: o
103
+ remember: n
102
104
  }) : u("userData", {
103
105
  email: "",
104
- remember: o
105
- }), n({
106
- type: s.Login,
106
+ remember: n
107
+ }), o({
108
+ type: i.Login,
107
109
  payload: {
108
- user: A
110
+ user: L
109
111
  }
110
112
  }), l((/* @__PURE__ */ new Date()).getTime() + "");
111
113
  });
@@ -113,24 +115,24 @@ function M(t) {
113
115
  a && await r({
114
116
  endPoint: "auth/logout",
115
117
  method: "POST"
116
- }), n({
117
- type: s.Logout
118
+ }), o({
119
+ type: i.Logout
118
120
  }), l((/* @__PURE__ */ new Date()).getTime() + "");
119
- }, p = () => {
121
+ }, g = () => {
120
122
  c(!1);
121
123
  };
122
124
  return d(function() {
123
- h(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, p);
124
- }, []), /* @__PURE__ */ v(P.Provider, {
125
+ h(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, g);
126
+ }, []), /* @__PURE__ */ v(C.Provider, {
125
127
  value: {
126
128
  ...m,
127
- login: g,
129
+ login: I,
128
130
  logout: c
129
131
  },
130
- children: e
132
+ children: t
131
133
  });
132
134
  }
133
135
  export {
134
- P as A,
136
+ C as A,
135
137
  M as a
136
138
  };
@@ -1,2 +1,2 @@
1
1
  export * from './AuthContext';
2
- export * from './types';
2
+ export type { UserAuth, AuthState } from './types';
@@ -1,11 +1,21 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { DomainCountry } from '../DomainCountryContext/types';
3
3
  import type { Maybe } from '../../types';
4
- export declare enum EnumTypes {
5
- Initial = "INITIALIZE",
6
- Login = "LOGIN",
7
- Logout = "LOGOUT"
4
+ import { EnumTypes } from './constants';
5
+ export interface UserAuth {
6
+ email: string;
7
+ id: number;
8
+ firstName: string;
9
+ lastName: string;
10
+ accountId: number;
11
+ domainCountry: DomainCountry;
12
+ avatarUrl?: Maybe<string>;
13
+ userTypeId?: number;
14
+ preferences?: {
15
+ deviceLabel?: string;
16
+ };
8
17
  }
18
+ export declare type AuthUserType = Maybe<UserAuth>;
9
19
  export declare type AuthProviderProps = {
10
20
  children: ReactNode;
11
21
  };
@@ -22,29 +32,18 @@ export declare type ActionMap<M extends {
22
32
  export declare type SessionAuthPayload = {
23
33
  [EnumTypes.Initial]: {
24
34
  isAuthenticated: boolean;
25
- user: AuthUser;
35
+ user: AuthUserType;
26
36
  };
27
37
  [EnumTypes.Login]: {
28
- user: AuthUser;
38
+ user: AuthUserType;
29
39
  };
30
40
  [EnumTypes.Logout]: undefined;
31
41
  };
32
42
  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
43
  export declare type AuthState = {
45
44
  isAuthenticated: boolean;
46
45
  isInitialized: boolean;
47
- user: AuthUser;
46
+ user: Maybe<UserAuth>;
48
47
  };
49
48
  export interface SessionContextType extends AuthState {
50
49
  login: (email: string, password: string, remember: boolean) => object | undefined;
@@ -0,0 +1,74 @@
1
+ import { createContext as y, useState as L, useEffect as M, useCallback as c } from "react";
2
+ import { C as N } from "../../types/index-TbOJOhBX.js";
3
+ import { jsx as P } from "react/jsx-runtime";
4
+ import { u as _ } from "../../hooks/useFlagsStore/index-EagkUnqK.js";
5
+ import { u as $ } from "../../hooks/useEnvironment/index-D1xRKaoe.js";
6
+ import { u as x } from "../../hooks/useHostTools/index-CL3d7qFm.js";
7
+ import { u as E } from "../../hooks/useNetwork/index--IzMsMJ2.js";
8
+ const b = y(null);
9
+ function j(m) {
10
+ const {
11
+ children: d,
12
+ componentsDictionary: f,
13
+ moduleId: a,
14
+ moduleNameField: l = "module_name",
15
+ currentLang: p = "en",
16
+ isAuth: u = !0
17
+ } = m, g = _((t) => t.flagsActions.addFlag), [r, h] = L(void 0), {
18
+ domain_token: D
19
+ } = $(), {
20
+ startProgress: v,
21
+ stopProgress: A
22
+ } = x(), {
23
+ networkOperation: C
24
+ } = E();
25
+ M(() => {
26
+ let t = !0;
27
+ return v(), C({
28
+ method: "GET",
29
+ endPoint: u ? `dictionaries/${a}` : `na/dictionaries/${a}`,
30
+ parms: {
31
+ comps: f,
32
+ // lang: 'en',
33
+ ...u ? {} : {
34
+ domain_token: D
35
+ }
36
+ }
37
+ // isRemote: false
38
+ }).then((e) => {
39
+ t && (h({
40
+ ...e
41
+ }), g(N.FLAG_DICTIONARY_LOADED));
42
+ }).finally(() => {
43
+ A();
44
+ }), function() {
45
+ t = !1;
46
+ };
47
+ }, [p]);
48
+ const s = c((t, ...e) => {
49
+ if (r === void 0) return "";
50
+ if (t === "") return "No key";
51
+ let o;
52
+ const i = t.split(".");
53
+ try {
54
+ i.length === 1 && (o = r.data[t]), i.length === 2 && (o = r[i[0]][i[1]]);
55
+ } catch {
56
+ }
57
+ if (e.length > 0 && o)
58
+ for (let n = 0; n < e.length; n++)
59
+ o = o?.replaceAll(`$${n + 1}`, e[n]);
60
+ return o || `N_D:[${t}]`;
61
+ }, [r]), F = c(() => s(l), [l, s]);
62
+ return /* @__PURE__ */ P(b.Provider, {
63
+ value: {
64
+ moduleDictionary: r,
65
+ getLabel: s,
66
+ getModuleLabel: F
67
+ },
68
+ children: d
69
+ });
70
+ }
71
+ export {
72
+ b as M,
73
+ j as a
74
+ };
@@ -2,7 +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
+ export * from './AuthContext';
6
6
  export { FlagsContext, FlagsProvider } from './FlagsContext';
7
7
  export { DomainContext, DomainProvider } from './DomainContext';
8
8
  export { ModuleDictionaryContext, ModuleDictionaryProvider } from './ModuleDictionaryContext';
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { A as e } from "../../contexts/AuthContext/index-cvUlEja1.js";
2
+ import { A as e } from "../../contexts/AuthContext/index-Bd4E4lyt.js";
3
3
  const n = () => {
4
4
  const t = o(e);
5
5
  if (!t) throw new Error("Auth context must be use inside AuthProvider");
@@ -1,2 +1,2 @@
1
- export declare const useAuth: () => import("../../contexts/AuthContext").SessionContextType;
1
+ export declare const useAuth: () => import("../../contexts/AuthContext/types").SessionContextType;
2
2
  export default useAuth;
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { M as e } from "../../contexts/ModuleDictionaryContext/index-kBzBlTUI.js";
2
+ import { M as e } from "../../contexts/ModuleDictionaryContext/index-BuBvxAsC.js";
3
3
  const n = () => {
4
4
  const o = t(e);
5
5
  if (!o)
@@ -14,16 +14,16 @@ const s = {
14
14
  // Propiedad para permitir que un cambio en los parametros de la consulta dispare la recarga de la red
15
15
  fireOnFirstLoad: C = !0,
16
16
  // propiedad que evita que se cargue la red la en el primer render del hook
17
- rowsPerPage: c = s.rowsPerPage,
17
+ rowsPerPage: u = s.rowsPerPage,
18
18
  startProgress: d,
19
19
  stopProgress: S,
20
20
  isRemote: k = !0,
21
21
  bodyToSnakeCase: y = !1,
22
22
  responseToCamelCase: T = !1,
23
23
  initialRows: E = [],
24
- externalCondition: u = !0,
24
+ externalCondition: c = !0,
25
25
  onNetworkError: f
26
- } = w, [p, g] = n(i ? 1 : 0), [O, o] = n(E), [b, a] = n({ ...s, rowsPerPage: c }), t = H({ ...s, rowsPerPage: c }), [x, F] = n(C), { startProgress: N, stopProgress: Q } = U(), { networkOperation: q } = j(), l = L(() => {
26
+ } = w, [p, g] = n(i ? 1 : 0), [O, a] = n(E), [b, o] = n({ ...s, rowsPerPage: u }), t = H({ ...s, rowsPerPage: u }), [x, F] = n(C), { startProgress: N, stopProgress: Q } = U(), { networkOperation: q } = j(), l = L(() => {
27
27
  g((r) => r + 1);
28
28
  }, []);
29
29
  return m(() => {
@@ -34,7 +34,7 @@ const s = {
34
34
  i && l();
35
35
  }, [P]), m(() => {
36
36
  let r = !0;
37
- if (!(!u || p === 0))
37
+ if (!(!c || p === 0))
38
38
  return q({
39
39
  method: "GET",
40
40
  endPoint: h,
@@ -52,24 +52,24 @@ const s = {
52
52
  },
53
53
  isRemote: k
54
54
  }).then((e) => {
55
- r && (o(e.data), t.current.page = e.pager.page, a((G) => ({
55
+ r && (a(e.data), t.current.page = e.pager.page, o((G) => ({
56
56
  ...G,
57
57
  page: e.pager.page,
58
58
  // rowsPerPage: response.pager.limit,
59
59
  totalRecords: e.pager.total
60
60
  })));
61
- }).catch(() => {
62
- o([]), a(s), f && f();
61
+ }).catch((e) => {
62
+ a([]), o(s), f && f(e.status);
63
63
  }), function() {
64
64
  r = !1;
65
65
  };
66
- }, [p, u]), { onPageChange: (r) => {
66
+ }, [p, c]), { onPageChange: (r) => {
67
67
  t.current.page = r, g((e) => e + 1);
68
68
  }, onRowsPerPageChange: (r) => {
69
- t.current.rowsPerPage = r, a((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
69
+ t.current.rowsPerPage = r, o((e) => ({ ...e, rowsPerPage: r })), g((e) => e + 1);
70
70
  }, pagerState: b, rows: O, clearRows: () => {
71
- o([]), a(s);
72
- }, Refresh: l, setRows: o };
71
+ a([]), o(s);
72
+ }, Refresh: l, setRows: a };
73
73
  };
74
74
  export {
75
75
  s as i,
@@ -13,5 +13,5 @@ export interface UsePaginateProps<TRow> extends Pick<NetworkProps, 'endPoint' |
13
13
  rowsPerPage?: number;
14
14
  initialRows?: TRow[];
15
15
  externalCondition?: boolean;
16
- onNetworkError?: () => void;
16
+ onNetworkError?: (code: number) => void;
17
17
  }
package/index.js CHANGED
@@ -3,51 +3,51 @@ import { B as s, a as i } from "./contexts/BaseContext/index-BZehLjuv.js";
3
3
  import { E as u, a as x } from "./contexts/EnvironmentContext/index-CQz-FvKh.js";
4
4
  import { H as p, a as l } from "./contexts/HostToolsContext/index-DikGcxz8.js";
5
5
  import { N as d, a as v } from "./contexts/NetworkContext/index-C8wX3ESG.js";
6
- import { A as P, a as C } from "./contexts/AuthContext/index-cvUlEja1.js";
7
- import { F as D, a as S } from "./contexts/FlagsContext/index-DcIX8FKd.js";
8
- import { D as y, a as F } from "./contexts/DomainContext/index-D24R5afH.js";
9
- import { M as k, a as h } from "./contexts/ModuleDictionaryContext/index-kBzBlTUI.js";
10
- import { M as L, a as A } from "./contexts/ModulePrivilegesContext/index-DsoWo0kK.js";
11
- import { M as N, a as w } from "./contexts/ModuleSkeletonContext/index-CkhzuYKp.js";
12
- import { D as W, a as O } from "./contexts/DomainCountryContext/index-Gjy6Za6i.js";
6
+ import { F as P, a as C } from "./contexts/FlagsContext/index-DcIX8FKd.js";
7
+ import { D, a as S } from "./contexts/DomainContext/index-D24R5afH.js";
8
+ import { M as y, a as F } from "./contexts/ModuleDictionaryContext/index-BuBvxAsC.js";
9
+ import { M as k, a as h } from "./contexts/ModulePrivilegesContext/index-DsoWo0kK.js";
10
+ import { M as L, a as A } from "./contexts/ModuleSkeletonContext/index-CkhzuYKp.js";
11
+ import { D as N, a as w } from "./contexts/DomainCountryContext/index-Gjy6Za6i.js";
12
+ import { A as W, a as O } from "./contexts/AuthContext/index-Bd4E4lyt.js";
13
13
  import { u as j } from "./hooks/useBase/index-gThCdRe-.js";
14
14
  import { u as z } from "./hooks/useEnvironment/index-D1xRKaoe.js";
15
15
  import { a as I, u as J } from "./hooks/useFlagsStore/index-EagkUnqK.js";
16
16
  import { u as Q } from "./hooks/useHostTools/index-CL3d7qFm.js";
17
17
  import { u as U, a as V } from "./hooks/useDomain/index-Bct5KNcv.js";
18
18
  import { a as Y, u as Z } from "./hooks/useLocalStorage/index-CsLmjbAr.js";
19
- import { u as $ } from "./hooks/useModuleDictionary/index-C1BKVxpe.js";
19
+ import { u as $ } from "./hooks/useModuleDictionary/index-BwDDx_UA.js";
20
20
  import { u as eo } from "./hooks/useModulePrivileges/index-D14YH0TD.js";
21
21
  import { u as ao } from "./hooks/useModuleSkeleton/index-CBPHGKDR.js";
22
22
  import { u as so } from "./hooks/useNetwork/index--IzMsMJ2.js";
23
- import { i as no, u as uo } from "./hooks/usePaginate/index-DOOXkJPW.js";
23
+ import { i as no, u as uo } from "./hooks/usePaginate/index-ClzxgF1V.js";
24
24
  import { u as mo } from "./hooks/usePropageteMF/index-DEVKsg4w.js";
25
- import { u as lo } from "./hooks/useAuth/index-BmbX0ftD.js";
26
- import { e as vo, g as go, a as Po, s as Co, v as Mo } from "./utils/index-BNOjc4WT.js";
25
+ import { u as lo } from "./hooks/useAuth/index-BWmLJhfH.js";
26
+ import { e as vo, g as go, a as Po, s as Co, v as Mo } from "./utils/index-C67J5HEa.js";
27
27
  import { a as So } from "./utils/axiosOperation-CEky_K0E.js";
28
28
  export {
29
- P as AuthContext,
30
- C as AuthProvider,
29
+ W as AuthContext,
30
+ O as AuthProvider,
31
31
  s as BaseContext,
32
32
  i as BaseProvider,
33
33
  r as CommonFlags,
34
- y as DomainContext,
35
- W as DomainCountryContext,
36
- O as DomainCountryProvider,
37
- F as DomainProvider,
34
+ D as DomainContext,
35
+ N as DomainCountryContext,
36
+ w as DomainCountryProvider,
37
+ S as DomainProvider,
38
38
  a as EmitEvents,
39
39
  u as EnvironmentContext,
40
40
  x as EnvironmentProvider,
41
- D as FlagsContext,
42
- S as FlagsProvider,
41
+ P as FlagsContext,
42
+ C as FlagsProvider,
43
43
  p as HostToolsContext,
44
44
  l as HostToolsProvider,
45
- k as ModuleDictionaryContext,
46
- h as ModuleDictionaryProvider,
47
- L as ModulePrivilegesContext,
48
- A as ModulePrivilegesProvider,
49
- N as ModuleSkeletonContext,
50
- w as ModuleSkeletonProvider,
45
+ y as ModuleDictionaryContext,
46
+ F as ModuleDictionaryProvider,
47
+ k as ModulePrivilegesContext,
48
+ h as ModulePrivilegesProvider,
49
+ L as ModuleSkeletonContext,
50
+ A as ModuleSkeletonProvider,
51
51
  d as NetworkContext,
52
52
  v as NetworkProvider,
53
53
  So as axiosOperation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "private": false,
@@ -1,4 +1,4 @@
1
- export declare type GetLabelType = (key: string) => string;
1
+ export declare type GetLabelType = (key: string, ...args: string[]) => string;
2
2
  export interface ComponentDictionary {
3
3
  [key: string]: string;
4
4
  }
package/types/index.d.ts CHANGED
@@ -33,6 +33,7 @@ export declare type EnvironmentType = {
33
33
  host_api_local: string;
34
34
  host_static_assets: string;
35
35
  environment_assets: string;
36
+ host_api_icons?: string;
36
37
  };
37
38
  export declare type NetworkProps = {
38
39
  method: any;
@@ -1 +1,3 @@
1
- export declare function getPropertyByString(object: any, key: string): string | undefined | any[] | Record<any, any>;
1
+ declare type PropertyType = string | undefined | any[] | Record<any, any>;
2
+ export declare function getPropertyByString<T extends PropertyType = PropertyType>(object: any, key: string, defaultValue?: T): T;
3
+ export {};
@@ -0,0 +1,61 @@
1
+ function u() {
2
+ }
3
+ function g(n, r, e) {
4
+ const o = r.split(".");
5
+ let t = n;
6
+ for (const a of o) {
7
+ const c = a.match(/^(\w+)\[(\w+)\]$/);
8
+ if (c) {
9
+ const s = c[1], i = c[2];
10
+ if (t[s] && Array.isArray(t[s])) {
11
+ if (i === "lastIndex")
12
+ return t[s][t[s].length - 1];
13
+ {
14
+ const l = parseInt(i);
15
+ return t[s][l];
16
+ }
17
+ } else
18
+ return e;
19
+ } else if (t[a] !== void 0)
20
+ t = t[a];
21
+ else
22
+ return e;
23
+ }
24
+ return t;
25
+ }
26
+ function f(n, r) {
27
+ try {
28
+ const o = new Function(...Object.keys(n), `return \`${r}\``)(...Object.values(n));
29
+ return String(o).replace(/`/g, "");
30
+ } catch (e) {
31
+ return console.error(`Error evaluating expression: ${e}`), "";
32
+ }
33
+ }
34
+ function y(n, r) {
35
+ try {
36
+ const e = window.localStorage.getItem(n);
37
+ return e !== null ? typeof r == "string" ? e : JSON.parse(e) : r;
38
+ } catch {
39
+ return r;
40
+ }
41
+ }
42
+ function S(n, r, e = !1) {
43
+ try {
44
+ let o = null;
45
+ if (typeof r == "string") {
46
+ window.localStorage.setItem(n, r);
47
+ return;
48
+ }
49
+ e && (o = window.localStorage.getItem(n));
50
+ let t = o !== null ? JSON.parse(o) : {};
51
+ t = { ...t, ...r }, window.localStorage.setItem(n, JSON.stringify(t));
52
+ } catch {
53
+ }
54
+ }
55
+ export {
56
+ g as a,
57
+ f as e,
58
+ y as g,
59
+ S as s,
60
+ u as v
61
+ };
@@ -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-TbOJOhBX.js";
3
- import { jsx as M } from "react/jsx-runtime";
4
- import { u as N } from "../../hooks/useFlagsStore/index-EagkUnqK.js";
5
- import { u as P } from "../../hooks/useEnvironment/index-D1xRKaoe.js";
6
- import { u as _ } from "../../hooks/useHostTools/index-CL3d7qFm.js";
7
- import { u as x } from "../../hooks/useNetwork/index--IzMsMJ2.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
- // lang: 'en',
33
- ...a ? {} : {
34
- domain_token: g
35
- }
36
- }
37
- // isRemote: false
38
- }).then((o) => {
39
- t && (p({
40
- ...o
41
- }), f(L.FLAG_DICTIONARY_LOADED));
42
- }).finally(() => {
43
- h();
44
- }), function() {
45
- t = !1;
46
- };
47
- }, [d]);
48
- const n = u((t) => {
49
- if (e === void 0) return "";
50
- if (t === "") 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,61 +0,0 @@
1
- function l() {
2
- }
3
- function u(n, e) {
4
- const r = e.split(".");
5
- let t = n;
6
- for (const o of r) {
7
- const a = o.match(/^(\w+)\[(\w+)\]$/);
8
- if (a) {
9
- const s = a[1], c = a[2];
10
- if (t[s] && Array.isArray(t[s])) {
11
- if (c === "lastIndex")
12
- return t[s][t[s].length - 1];
13
- {
14
- const i = parseInt(c);
15
- return t[s][i];
16
- }
17
- } else
18
- return;
19
- } else if (t[o] !== void 0)
20
- t = t[o];
21
- else
22
- return;
23
- }
24
- return t;
25
- }
26
- function g(n, e) {
27
- try {
28
- const t = new Function(...Object.keys(n), `return \`${e}\``)(...Object.values(n));
29
- return String(t).replace(/`/g, "");
30
- } catch (r) {
31
- return console.error(`Error evaluating expression: ${r}`), "";
32
- }
33
- }
34
- function f(n, e) {
35
- try {
36
- const r = window.localStorage.getItem(n);
37
- return r !== null ? typeof e == "string" ? r : JSON.parse(r) : e;
38
- } catch {
39
- return e;
40
- }
41
- }
42
- function y(n, e, r = !1) {
43
- try {
44
- let t = null;
45
- if (typeof e == "string") {
46
- window.localStorage.setItem(n, e);
47
- return;
48
- }
49
- r && (t = window.localStorage.getItem(n));
50
- let o = t !== null ? JSON.parse(t) : {};
51
- o = { ...o, ...e }, window.localStorage.setItem(n, JSON.stringify(o));
52
- } catch {
53
- }
54
- }
55
- export {
56
- u as a,
57
- g as e,
58
- f as g,
59
- y as s,
60
- l as v
61
- };