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