@m4l/core 2.0.14 → 2.0.16-beta.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.
@@ -1,73 +1,76 @@
1
- import { jsx as _ } from "react/jsx-runtime";
2
- import { createContext as y, useState as L, useEffect as M, useCallback as c } from "react";
3
- import { u as N } from "../../hooks/useEnvironment/index.js";
4
- import { u as P } from "../../hooks/useFlagsStore/index.js";
5
- import { u as $ } from "../../hooks/useHostTools/index.js";
6
- import { u as x } from "../../hooks/useNetwork/index.js";
7
- import { C as E } from "../../types/index.js";
8
- const b = y(null);
9
- function j(m) {
1
+ import { jsx as E } from "react/jsx-runtime";
2
+ import { createContext as I, useState as f, useEffect as O, useCallback as p } from "react";
3
+ import { u as P } from "../../hooks/useEnvironment/index.js";
4
+ import { u as $ } from "../../hooks/useFlagsStore/index.js";
5
+ import { u as x } from "../../hooks/useHostTools/index.js";
6
+ import { u as S } from "../../hooks/useNetwork/index.js";
7
+ import { C as D } from "../../types/index.js";
8
+ const T = I(null);
9
+ function H(g) {
10
10
  const {
11
- children: d,
12
- componentsDictionary: f,
13
- moduleId: a,
11
+ children: L,
12
+ componentsDictionary: h,
13
+ moduleId: s,
14
14
  moduleNameField: l = "module_name",
15
- currentLang: p = "en",
16
- isAuth: u = !0
17
- } = m, g = P((t) => t.flagsActions.addFlag), [r, h] = L(void 0), { domain_token: D } = N(), { startProgress: v, stopProgress: A } = $(), { networkOperation: C } = x();
18
- M(() => {
15
+ currentLang: A = "en",
16
+ isAuth: d = !0,
17
+ moduleDictionaryLoaded: v
18
+ } = g, u = $((t) => t.flagsActions.addFlag), [n, c] = f(void 0), { domain_token: y } = P(), { startProgress: _, stopProgress: C } = x(), { networkOperation: F } = S(), [m, M] = f(v);
19
+ O(() => {
19
20
  let t = !0;
20
- return v(), C({
21
+ return m ? (c({
22
+ ...m
23
+ }), M(void 0), u(D.FLAG_DICTIONARY_LOADED)) : (_(), F({
21
24
  method: "GET",
22
- endPoint: u ? `dictionaries/${a}` : `na/dictionaries/${a}`,
25
+ endPoint: d ? `dictionaries/${s}` : `na/dictionaries/${s}`,
23
26
  parms: {
24
- comps: f,
27
+ comps: h,
25
28
  // lang: 'en',
26
- ...u ? {} : { domain_token: D }
29
+ ...d ? {} : { domain_token: y }
27
30
  }
28
31
  // isRemote: false
29
32
  }).then((e) => {
30
- t && (h({
33
+ t && (c({
31
34
  ...e
32
- }), g(E.FLAG_DICTIONARY_LOADED));
35
+ }), u(D.FLAG_DICTIONARY_LOADED));
33
36
  }).finally(() => {
34
- A();
35
- }), function() {
37
+ C();
38
+ })), function() {
36
39
  t = !1;
37
40
  };
38
- }, [p]);
39
- const s = c(
41
+ }, [A]);
42
+ const a = p(
40
43
  (t, ...e) => {
41
- if (r === void 0)
44
+ if (n === void 0)
42
45
  return "";
43
46
  if (t === "")
44
47
  return "No key";
45
48
  let o;
46
49
  const i = t.split(".");
47
50
  try {
48
- i.length === 1 && (o = r.data[t]), i.length === 2 && (o = r[i[0]][i[1]]);
51
+ i.length === 1 && (o = n.data[t]), i.length === 2 && (o = n[i[0]][i[1]]);
49
52
  } catch {
50
53
  }
51
54
  if (e.length > 0 && o)
52
- for (let n = 0; n < e.length; n++)
53
- o = o?.replaceAll(`$${n + 1}`, e[n]);
55
+ for (let r = 0; r < e.length; r++)
56
+ o = o?.replaceAll(`$${r + 1}`, e[r]);
54
57
  return o || `N_D:[${t}]`;
55
58
  },
56
- [r]
57
- ), F = c(() => s(l), [l, s]);
58
- return /* @__PURE__ */ _(
59
- b.Provider,
59
+ [n]
60
+ ), N = p(() => a(l), [l, a]);
61
+ return /* @__PURE__ */ E(
62
+ T.Provider,
60
63
  {
61
64
  value: {
62
- moduleDictionary: r,
63
- getLabel: s,
64
- getModuleLabel: F
65
+ moduleDictionary: n,
66
+ getLabel: a,
67
+ getModuleLabel: N
65
68
  },
66
- children: d
69
+ children: L
67
70
  }
68
71
  );
69
72
  }
70
73
  export {
71
- b as M,
72
- j as a
74
+ T as M,
75
+ H as a
73
76
  };
@@ -7,6 +7,7 @@ export interface ModuleDictionaryProviderProps {
7
7
  moduleNameField?: string;
8
8
  componentsDictionary: string[];
9
9
  children: ReactNode;
10
+ moduleDictionaryLoaded?: ModuleDictionary;
10
11
  }
11
12
  export interface ModuleDictionaryContextProps {
12
13
  moduleDictionary?: ModuleDictionary;
@@ -1,51 +1,55 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { createContext as d, useState as p, useEffect as P, useCallback as v } from "react";
1
+ import { jsx as P } from "react/jsx-runtime";
2
+ import { createContext as v, useState as a, useEffect as E, useCallback as h } from "react";
3
3
  import { C as i } from "../../types/index.js";
4
- import { u as E } from "../../hooks/useFlagsStore/index.js";
5
- import { u as h } from "../../hooks/useHostTools/index.js";
6
- import { u as F } from "../../hooks/useNetwork/index.js";
7
- const L = d(null);
8
- function S(n) {
9
- const { children: a, queryPrivileges: r } = n, o = E((e) => e.flagsActions.addFlag), [t, l] = p({}), { startProgress: u, stopProgress: m } = h(), { networkOperation: g } = F();
10
- P(() => {
4
+ import { u as D } from "../../hooks/useFlagsStore/index.js";
5
+ import { u as F } from "../../hooks/useHostTools/index.js";
6
+ import { u as L } from "../../hooks/useNetwork/index.js";
7
+ const A = v(null);
8
+ function k(n) {
9
+ const { children: l, queryPrivileges: s } = n, o = D((e) => e.flagsActions.addFlag), [t, u] = a({}), [m, c] = a({}), { startProgress: g, stopProgress: f } = F(), { networkOperation: d } = L();
10
+ E(() => {
11
11
  let e = !0;
12
- if (r.length === 0) {
12
+ if (s.length === 0) {
13
13
  o(i.FLAG_PRIVILEGES_LOADED);
14
14
  return;
15
15
  }
16
- return u(), g({
16
+ return g(), d({
17
17
  method: "GET",
18
18
  endPoint: "auth/login",
19
19
  parms: {
20
- privileges: r
20
+ privileges: s,
21
+ user_data: !0
21
22
  }
22
23
  // isRemote: false
23
- }).then((s) => {
24
- e && (l({
25
- ...s.data
24
+ }).then((r) => {
25
+ e && (u({
26
+ ...r.data
27
+ }), c({
28
+ ...r.user
26
29
  }), o(i.FLAG_PRIVILEGES_LOADED));
27
30
  }).finally(() => {
28
- m();
31
+ f();
29
32
  }), function() {
30
33
  e = !1;
31
34
  };
32
35
  }, []);
33
- const c = v(
36
+ const p = h(
34
37
  (e) => e in t,
35
38
  [t]
36
39
  );
37
- return /* @__PURE__ */ f(
38
- L.Provider,
40
+ return /* @__PURE__ */ P(
41
+ A.Provider,
39
42
  {
40
43
  value: {
41
- hasPrivilege: c,
42
- privileges: t
44
+ hasPrivilege: p,
45
+ privileges: t,
46
+ userData: m
43
47
  },
44
- children: a
48
+ children: l
45
49
  }
46
50
  );
47
51
  }
48
52
  export {
49
- L as M,
50
- S as a
53
+ A as M,
54
+ k as a
51
55
  };
@@ -6,4 +6,5 @@ export interface ModulePrivilegesProviderProps {
6
6
  export interface ModulePrivilegesContextProps {
7
7
  privileges: Record<string, boolean>;
8
8
  hasPrivilege: (id: string) => boolean;
9
+ userData: Record<string, any>;
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "2.0.14",
3
+ "version": "2.0.16-beta.0",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "publishConfig": {