@m4l/core 0.1.23 → 0.1.25
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.
- package/contexts/DomainContext/index.d09ee435.js +45 -0
- package/contexts/DomainCountryContext/index.38c27388.js +42 -0
- package/contexts/EnvironmentContext/index.7045c64f.js +17 -0
- package/contexts/FlagsContext/index.5f795859.js +24 -0
- package/contexts/HostToolsContext/index.499db832.js +17 -0
- package/contexts/ModuleDictionaryContext/index.c7e01648.js +78 -0
- package/contexts/ModulePrivilegesContext/index.91ed5843.js +59 -0
- package/contexts/ModuleSkeletonContext/index.73a5f745.js +27 -0
- package/contexts/NetworkContext/index.d1dfbc3a.js +21 -0
- package/hooks/useDomain/index.7117ac32.js +18 -0
- package/hooks/useEnvironment/index.04dca988.js +11 -0
- package/hooks/useFlags/index.a986729d.js +21 -0
- package/hooks/useHostTools/index.66d9a667.js +11 -0
- package/hooks/useLocalStorage/index.281b7ae8.js +48 -0
- package/hooks/useModuleDictionary/index.5cabf2a3.js +11 -0
- package/hooks/useModulePrivileges/index.93343e3e.js +11 -0
- package/hooks/useModuleSkeleton/index.7df262f4.js +13 -0
- package/hooks/useNetwork/index.acbf28d5.js +11 -0
- package/hooks/usePaginate/index.7cb17527.js +58 -0
- package/index.js +67 -4
- package/package.json +1 -1
- package/types/index.5f1b0c45.js +5 -0
- package/utils/axiosOperation.6118a64a.js +49 -0
- package/utils/index.4b6999c8.js +34 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createContext as l, useState as u, useEffect as c } from "react";
|
|
2
|
+
import { u as f } from "../../hooks/useFlags/index.a986729d.js";
|
|
3
|
+
import { u as d } from "../../hooks/useEnvironment/index.04dca988.js";
|
|
4
|
+
import { u as p } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
5
|
+
import { C as _ } from "../../types/index.5f1b0c45.js";
|
|
6
|
+
import { jsx as D } from "react/jsx-runtime";
|
|
7
|
+
const g = l(null);
|
|
8
|
+
function k(t) {
|
|
9
|
+
const {
|
|
10
|
+
children: e
|
|
11
|
+
} = t, {
|
|
12
|
+
domain_token: a
|
|
13
|
+
} = d(), {
|
|
14
|
+
addFlag: r
|
|
15
|
+
} = f(), [m, s] = u({
|
|
16
|
+
company_logo_small_url: "",
|
|
17
|
+
company_logo_normal_url: "",
|
|
18
|
+
name: ""
|
|
19
|
+
}), {
|
|
20
|
+
networkOperation: i
|
|
21
|
+
} = p();
|
|
22
|
+
return c(() => {
|
|
23
|
+
let o = !0;
|
|
24
|
+
return i({
|
|
25
|
+
method: "GET",
|
|
26
|
+
endPoint: `na/info/${a}`
|
|
27
|
+
}).then((n) => {
|
|
28
|
+
o && (s({
|
|
29
|
+
...n.data
|
|
30
|
+
}), r(_.FLAG_DOMAIN_LOADED));
|
|
31
|
+
}).finally(() => {
|
|
32
|
+
}), function() {
|
|
33
|
+
o = !1;
|
|
34
|
+
};
|
|
35
|
+
}, []), /* @__PURE__ */ D(g.Provider, {
|
|
36
|
+
value: {
|
|
37
|
+
...m
|
|
38
|
+
},
|
|
39
|
+
children: e
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
g as D,
|
|
44
|
+
k as a
|
|
45
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createContext as p, useState as T, useCallback as i, useEffect as d } from "react";
|
|
2
|
+
import "../EnvironmentContext/index.7045c64f.js";
|
|
3
|
+
import "../FlagsContext/index.5f795859.js";
|
|
4
|
+
import { u as N } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
|
+
import "../DomainContext/index.d09ee435.js";
|
|
6
|
+
import "../ModuleDictionaryContext/index.c7e01648.js";
|
|
7
|
+
import "../ModulePrivilegesContext/index.91ed5843.js";
|
|
8
|
+
import "../ModuleSkeletonContext/index.73a5f745.js";
|
|
9
|
+
import "../NetworkContext/index.d1dfbc3a.js";
|
|
10
|
+
import { E as n } from "../../types/index.5f1b0c45.js";
|
|
11
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
12
|
+
const l = p(null);
|
|
13
|
+
function G(m) {
|
|
14
|
+
const {
|
|
15
|
+
children: s,
|
|
16
|
+
isMicroFrontEnd: t,
|
|
17
|
+
domainCountryId: a
|
|
18
|
+
} = m, {
|
|
19
|
+
events_add_listener: _,
|
|
20
|
+
events_remove_listener: u,
|
|
21
|
+
events_emit: E
|
|
22
|
+
} = N(), [C, r] = T(a), e = i((o) => {
|
|
23
|
+
r(o);
|
|
24
|
+
}, []);
|
|
25
|
+
d(() => (t && _(n.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, e), () => {
|
|
26
|
+
t && u(n.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, e);
|
|
27
|
+
}), []);
|
|
28
|
+
const c = i((o) => {
|
|
29
|
+
t || (r(o), E(n.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE, o));
|
|
30
|
+
}, []);
|
|
31
|
+
return /* @__PURE__ */ f(l.Provider, {
|
|
32
|
+
value: {
|
|
33
|
+
domainCountryId: C,
|
|
34
|
+
changeDomainCountryId: c
|
|
35
|
+
},
|
|
36
|
+
children: s
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
l as D,
|
|
41
|
+
G as a
|
|
42
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext as e, useState as i } from "react";
|
|
2
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
3
|
+
const m = e(null);
|
|
4
|
+
function v(n) {
|
|
5
|
+
const {
|
|
6
|
+
children: t,
|
|
7
|
+
...o
|
|
8
|
+
} = n, [r] = i(o);
|
|
9
|
+
return /* @__PURE__ */ a(m.Provider, {
|
|
10
|
+
value: r,
|
|
11
|
+
children: t
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
m as E,
|
|
16
|
+
v as a
|
|
17
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext as i, useState as l, useCallback as a } from "react";
|
|
2
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
3
|
+
const x = i(null);
|
|
4
|
+
function g({
|
|
5
|
+
children: n
|
|
6
|
+
}) {
|
|
7
|
+
const [s, r] = l([]), o = a(() => {
|
|
8
|
+
r([]);
|
|
9
|
+
}, []), c = a((e) => {
|
|
10
|
+
r((t) => t.findIndex((u) => u === e) < 0 ? [...t, e] : [...t]);
|
|
11
|
+
}, []);
|
|
12
|
+
return /* @__PURE__ */ f(x.Provider, {
|
|
13
|
+
value: {
|
|
14
|
+
flags: s,
|
|
15
|
+
addFlag: c,
|
|
16
|
+
clearFlags: o
|
|
17
|
+
},
|
|
18
|
+
children: n
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
x as F,
|
|
23
|
+
g as a
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext as e, useState as n } from "react";
|
|
2
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
3
|
+
const a = e(null);
|
|
4
|
+
function u(o) {
|
|
5
|
+
const {
|
|
6
|
+
children: t,
|
|
7
|
+
...s
|
|
8
|
+
} = o, [r] = n(s);
|
|
9
|
+
return /* @__PURE__ */ l(a.Provider, {
|
|
10
|
+
value: r,
|
|
11
|
+
children: t
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
a as H,
|
|
16
|
+
u as a
|
|
17
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createContext as y, useState as L, useEffect as M, useCallback as m } from "react";
|
|
2
|
+
import { u as N } from "../../hooks/useEnvironment/index.04dca988.js";
|
|
3
|
+
import { u as P } from "../../hooks/useFlags/index.a986729d.js";
|
|
4
|
+
import { u as _ } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
|
+
import "../DomainContext/index.d09ee435.js";
|
|
6
|
+
import "../ModulePrivilegesContext/index.91ed5843.js";
|
|
7
|
+
import "../ModuleSkeletonContext/index.73a5f745.js";
|
|
8
|
+
import { u as x } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
9
|
+
import "../DomainCountryContext/index.38c27388.js";
|
|
10
|
+
import { C as A } from "../../types/index.5f1b0c45.js";
|
|
11
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
12
|
+
const F = y(null);
|
|
13
|
+
function U(l) {
|
|
14
|
+
const {
|
|
15
|
+
children: c,
|
|
16
|
+
componentsDictionary: d,
|
|
17
|
+
moduleId: i,
|
|
18
|
+
moduleName: s = "module_name",
|
|
19
|
+
currentLang: a = "en",
|
|
20
|
+
isAuth: u = !0
|
|
21
|
+
} = l, {
|
|
22
|
+
addFlag: p
|
|
23
|
+
} = P(), [r, f] = L(void 0), {
|
|
24
|
+
domain_token: g
|
|
25
|
+
} = N(), {
|
|
26
|
+
startProgress: D,
|
|
27
|
+
stopProgress: h
|
|
28
|
+
} = _(), {
|
|
29
|
+
networkOperation: v
|
|
30
|
+
} = x();
|
|
31
|
+
M(() => {
|
|
32
|
+
let t = !0;
|
|
33
|
+
return D(), v({
|
|
34
|
+
method: "GET",
|
|
35
|
+
endPoint: u ? `dictionaries/${i}` : `na/dictionaries/${i}`,
|
|
36
|
+
parms: {
|
|
37
|
+
comps: d,
|
|
38
|
+
...u ? {} : {
|
|
39
|
+
domain_token: g,
|
|
40
|
+
lang: a
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}).then((o) => {
|
|
44
|
+
t && (f({
|
|
45
|
+
...o
|
|
46
|
+
}), p(A.FLAG_DICTIONARY_LOADED));
|
|
47
|
+
}).finally(() => {
|
|
48
|
+
h();
|
|
49
|
+
}), function() {
|
|
50
|
+
t = !1;
|
|
51
|
+
};
|
|
52
|
+
}, [a]);
|
|
53
|
+
const n = m((t) => {
|
|
54
|
+
if (r === void 0)
|
|
55
|
+
return "";
|
|
56
|
+
if (t === "")
|
|
57
|
+
return "No key";
|
|
58
|
+
let o;
|
|
59
|
+
const e = t.split(".");
|
|
60
|
+
try {
|
|
61
|
+
e.length === 1 && (o = r.data[t]), e.length === 2 && (o = r[e[0]][e[1]]);
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return o || `N_D:[${t}]`;
|
|
65
|
+
}, [r]), C = m(() => n(s), [s, n]);
|
|
66
|
+
return /* @__PURE__ */ E(F.Provider, {
|
|
67
|
+
value: {
|
|
68
|
+
moduleDictionary: r,
|
|
69
|
+
getLabel: n,
|
|
70
|
+
getModuleLabel: C
|
|
71
|
+
},
|
|
72
|
+
children: c
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
F as M,
|
|
77
|
+
U as a
|
|
78
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createContext as f, useState as g, useEffect as P, useCallback as d } from "react";
|
|
2
|
+
import "../EnvironmentContext/index.7045c64f.js";
|
|
3
|
+
import { u as v } from "../../hooks/useFlags/index.a986729d.js";
|
|
4
|
+
import { u as E } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
|
+
import "../DomainContext/index.d09ee435.js";
|
|
6
|
+
import "../ModuleDictionaryContext/index.c7e01648.js";
|
|
7
|
+
import "../ModuleSkeletonContext/index.73a5f745.js";
|
|
8
|
+
import { u as h } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
9
|
+
import "../DomainCountryContext/index.38c27388.js";
|
|
10
|
+
import { C as i } from "../../types/index.5f1b0c45.js";
|
|
11
|
+
import { jsx as L } from "react/jsx-runtime";
|
|
12
|
+
const C = f(null);
|
|
13
|
+
function w(n) {
|
|
14
|
+
const {
|
|
15
|
+
children: a,
|
|
16
|
+
queryPrivileges: t
|
|
17
|
+
} = n, {
|
|
18
|
+
addFlag: o
|
|
19
|
+
} = v(), [r, l] = g({}), {
|
|
20
|
+
startProgress: u,
|
|
21
|
+
stopProgress: m
|
|
22
|
+
} = E(), {
|
|
23
|
+
networkOperation: p
|
|
24
|
+
} = h();
|
|
25
|
+
P(() => {
|
|
26
|
+
let e = !0;
|
|
27
|
+
if (t.length === 0) {
|
|
28
|
+
o(i.FLAG_PRIVILEGES_LOADED);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
return u(), p({
|
|
32
|
+
method: "GET",
|
|
33
|
+
endPoint: "auth/login",
|
|
34
|
+
parms: {
|
|
35
|
+
privileges: t
|
|
36
|
+
}
|
|
37
|
+
}).then((s) => {
|
|
38
|
+
e && (l({
|
|
39
|
+
...s.data
|
|
40
|
+
}), o(i.FLAG_PRIVILEGES_LOADED));
|
|
41
|
+
}).finally(() => {
|
|
42
|
+
m();
|
|
43
|
+
}), function() {
|
|
44
|
+
e = !1;
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
const c = d((e) => e in r, [r]);
|
|
48
|
+
return /* @__PURE__ */ L(C.Provider, {
|
|
49
|
+
value: {
|
|
50
|
+
hasPrivilege: c,
|
|
51
|
+
privileges: r
|
|
52
|
+
},
|
|
53
|
+
children: a
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
C as M,
|
|
58
|
+
w as a
|
|
59
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext as i } from "react";
|
|
2
|
+
import "../EnvironmentContext/index.7045c64f.js";
|
|
3
|
+
import { a as n } from "../../hooks/useFlags/index.a986729d.js";
|
|
4
|
+
import "../HostToolsContext/index.499db832.js";
|
|
5
|
+
import "../DomainContext/index.d09ee435.js";
|
|
6
|
+
import "../ModuleDictionaryContext/index.c7e01648.js";
|
|
7
|
+
import "../ModulePrivilegesContext/index.91ed5843.js";
|
|
8
|
+
import "../NetworkContext/index.d1dfbc3a.js";
|
|
9
|
+
import "../DomainCountryContext/index.38c27388.js";
|
|
10
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
11
|
+
const s = i(null);
|
|
12
|
+
function M(o) {
|
|
13
|
+
const {
|
|
14
|
+
children: t,
|
|
15
|
+
flags: r
|
|
16
|
+
} = o, e = !n(r);
|
|
17
|
+
return /* @__PURE__ */ m(s.Provider, {
|
|
18
|
+
value: {
|
|
19
|
+
isSkeleton: e
|
|
20
|
+
},
|
|
21
|
+
children: t
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
s as M,
|
|
26
|
+
M as a
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext as i, useCallback as c } from "react";
|
|
2
|
+
import { u as m } from "../../hooks/useEnvironment/index.04dca988.js";
|
|
3
|
+
import { u } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
4
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
5
|
+
const p = i(null);
|
|
6
|
+
function d(t) {
|
|
7
|
+
const {
|
|
8
|
+
children: r,
|
|
9
|
+
axiosOperation: o
|
|
10
|
+
} = t, n = m(), e = u(), s = c(async (a) => o(a, n, e), [o]);
|
|
11
|
+
return /* @__PURE__ */ l(p.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
networkOperation: s
|
|
14
|
+
},
|
|
15
|
+
children: r
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
p as N,
|
|
20
|
+
d as a
|
|
21
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { D as n } from "../../contexts/DomainContext/index.d09ee435.js";
|
|
3
|
+
import { D as e } from "../../contexts/DomainCountryContext/index.38c27388.js";
|
|
4
|
+
const m = () => {
|
|
5
|
+
const o = t(n);
|
|
6
|
+
if (!o)
|
|
7
|
+
throw new Error("useDomain context must be use inside DomainContext");
|
|
8
|
+
return o;
|
|
9
|
+
}, u = () => {
|
|
10
|
+
const o = t(e);
|
|
11
|
+
if (!o)
|
|
12
|
+
throw new Error("useDomainCountry context must be use inside DomainCountryContext");
|
|
13
|
+
return o;
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
u as a,
|
|
17
|
+
m as u
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { E as e } from "../../contexts/EnvironmentContext/index.7045c64f.js";
|
|
3
|
+
const s = () => {
|
|
4
|
+
const n = t(e);
|
|
5
|
+
if (!n)
|
|
6
|
+
throw new Error("useEnvironment context must be use inside EnvironmentContext");
|
|
7
|
+
return n;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
s as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext as f, useState as i, useEffect as u } from "react";
|
|
2
|
+
import { F as l } from "../../contexts/FlagsContext/index.5f795859.js";
|
|
3
|
+
const a = () => {
|
|
4
|
+
const t = f(l);
|
|
5
|
+
if (!t)
|
|
6
|
+
throw new Error("useFlags context must be use inside FlagsProvider");
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
function r(t, e) {
|
|
10
|
+
return t.filter((s) => e.findIndex((o) => o === s) !== -1).length === t.length;
|
|
11
|
+
}
|
|
12
|
+
const x = (t) => {
|
|
13
|
+
const e = a(), [n, s] = i(r(t, e.flags));
|
|
14
|
+
return u(() => {
|
|
15
|
+
r(t, e.flags) && s(!0);
|
|
16
|
+
}, [e.flags, t]), n;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
x as a,
|
|
20
|
+
a as u
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { H as s } from "../../contexts/HostToolsContext/index.499db832.js";
|
|
3
|
+
const n = () => {
|
|
4
|
+
const o = t(s);
|
|
5
|
+
if (!o)
|
|
6
|
+
throw new Error("useHostTools context must be use inside HostToolsContext");
|
|
7
|
+
return o;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
n as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useState as c, useEffect as u } from "react";
|
|
2
|
+
function i(e, o) {
|
|
3
|
+
const [n, a] = c(() => {
|
|
4
|
+
try {
|
|
5
|
+
const t = window.localStorage.getItem(e);
|
|
6
|
+
return t !== null ? JSON.parse(t) : o;
|
|
7
|
+
} catch {
|
|
8
|
+
return o;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return [n, (t) => {
|
|
12
|
+
try {
|
|
13
|
+
window.localStorage.setItem(e, JSON.stringify(t)), a(t);
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
16
|
+
}];
|
|
17
|
+
}
|
|
18
|
+
function S(e, o) {
|
|
19
|
+
const [n, a] = c(() => {
|
|
20
|
+
try {
|
|
21
|
+
const t = localStorage.getItem(e);
|
|
22
|
+
return t === null ? o : JSON.parse(t);
|
|
23
|
+
} catch {
|
|
24
|
+
return o;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return u(() => {
|
|
28
|
+
const t = (r) => {
|
|
29
|
+
if (r.storageArea === localStorage && r.key === e)
|
|
30
|
+
try {
|
|
31
|
+
r.newValue && a(JSON.parse(r.newValue));
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return window.addEventListener("storage", t), () => {
|
|
36
|
+
window.removeEventListener("storage", t);
|
|
37
|
+
};
|
|
38
|
+
}, [e, o]), [n, (t) => {
|
|
39
|
+
a((r) => {
|
|
40
|
+
const s = typeof t == "function" ? t(r) : t;
|
|
41
|
+
return localStorage.setItem(e, JSON.stringify(s)), s;
|
|
42
|
+
});
|
|
43
|
+
}];
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
S as a,
|
|
47
|
+
i as u
|
|
48
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as t } from "react";
|
|
2
|
+
import { M as e } from "../../contexts/ModuleDictionaryContext/index.c7e01648.js";
|
|
3
|
+
const n = () => {
|
|
4
|
+
const o = t(e);
|
|
5
|
+
if (!o)
|
|
6
|
+
throw new Error("useModuleDictionary context must be use inside ModuleDictionaryProvider");
|
|
7
|
+
return o;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
n as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as o } from "react";
|
|
2
|
+
import { M as t } from "../../contexts/ModulePrivilegesContext/index.91ed5843.js";
|
|
3
|
+
const i = () => {
|
|
4
|
+
const e = o(t);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("useModulePrivileges context must be use inside ModulePrivilegesContext");
|
|
7
|
+
return e;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
i as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useState as n, useContext as s, useEffect as u } from "react";
|
|
2
|
+
import { M as r } from "../../contexts/ModuleSkeletonContext/index.73a5f745.js";
|
|
3
|
+
const S = () => {
|
|
4
|
+
const [t, o] = n(!0), e = s(r);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("useModuleSkeleton context must be use inside ModuleSkeletonContext");
|
|
7
|
+
return u(() => {
|
|
8
|
+
t !== e.isSkeleton && o(e.isSkeleton);
|
|
9
|
+
}, [e.isSkeleton]), t;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
S as u
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useContext as e } from "react";
|
|
2
|
+
import { N as o } from "../../contexts/NetworkContext/index.d1dfbc3a.js";
|
|
3
|
+
const s = () => {
|
|
4
|
+
const t = e(o);
|
|
5
|
+
if (!t)
|
|
6
|
+
throw new Error("useNetwork context must be use inside NetworkContext");
|
|
7
|
+
return t;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
s as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useState as a, useRef as O, useCallback as Q, useEffect as l } from "react";
|
|
2
|
+
import { u as T } from "../useHostTools/index.66d9a667.js";
|
|
3
|
+
import { u as b } from "../useNetwork/index.acbf28d5.js";
|
|
4
|
+
const s = {
|
|
5
|
+
page: 0,
|
|
6
|
+
rowsPerPage: 25,
|
|
7
|
+
totalRecords: 0
|
|
8
|
+
}, U = (m) => {
|
|
9
|
+
const {
|
|
10
|
+
endPoint: w,
|
|
11
|
+
timeout: h = 5e3,
|
|
12
|
+
queryParams: g,
|
|
13
|
+
fireOnChangeParms: c,
|
|
14
|
+
rowsPerPage: u = s.rowsPerPage
|
|
15
|
+
} = m, [P, o] = a(c ? 1 : 0), [R, i] = a([]), [d, n] = a({ ...s, rowsPerPage: u }), t = O({ ...s, rowsPerPage: u }), [C, S] = a(!0), { startProgress: y, stopProgress: f } = T(), { networkOperation: k } = b(), p = Q(() => {
|
|
16
|
+
o((r) => r + 1);
|
|
17
|
+
}, []);
|
|
18
|
+
return l(() => {
|
|
19
|
+
if (C) {
|
|
20
|
+
S(!1);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
c && p();
|
|
24
|
+
}, [g]), l(() => {
|
|
25
|
+
let r = !0;
|
|
26
|
+
if (P !== 0)
|
|
27
|
+
return y(), k({
|
|
28
|
+
method: "GET",
|
|
29
|
+
endPoint: w,
|
|
30
|
+
timeout: h,
|
|
31
|
+
parms: {
|
|
32
|
+
...g,
|
|
33
|
+
page: t.current.page,
|
|
34
|
+
limit: t.current.rowsPerPage
|
|
35
|
+
}
|
|
36
|
+
}).then((e) => {
|
|
37
|
+
r && (i(e.data), t.current.page = e.pager.page, n((E) => ({
|
|
38
|
+
...E,
|
|
39
|
+
page: e.pager.page,
|
|
40
|
+
totalRecords: e.pager.total
|
|
41
|
+
})));
|
|
42
|
+
}).finally(() => {
|
|
43
|
+
r && f();
|
|
44
|
+
}), function() {
|
|
45
|
+
f(), r = !1;
|
|
46
|
+
};
|
|
47
|
+
}, [P]), { onPageChange: (r) => {
|
|
48
|
+
t.current.page = r, o((e) => e + 1);
|
|
49
|
+
}, onRowsPerPageChange: (r) => {
|
|
50
|
+
t.current.rowsPerPage = r, n((e) => ({ ...e, rowsPerPage: r })), o((e) => e + 1);
|
|
51
|
+
}, pagerState: d, rows: R, clearRows: () => {
|
|
52
|
+
i([]), n(s);
|
|
53
|
+
}, Refresh: p };
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
s as i,
|
|
57
|
+
U as u
|
|
58
|
+
};
|
package/index.js
CHANGED
|
@@ -1,4 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import "react";
|
|
2
|
+
import { E as i, a as n } from "./contexts/EnvironmentContext/index.7045c64f.js";
|
|
3
|
+
import { F as u, a as x } from "./contexts/FlagsContext/index.5f795859.js";
|
|
4
|
+
import { H as p, a as f } from "./contexts/HostToolsContext/index.499db832.js";
|
|
5
|
+
import { D as g, a as v } from "./contexts/DomainContext/index.d09ee435.js";
|
|
6
|
+
import { M as C, a as M } from "./contexts/ModuleDictionaryContext/index.c7e01648.js";
|
|
7
|
+
import { M as S, a as c } from "./contexts/ModulePrivilegesContext/index.91ed5843.js";
|
|
8
|
+
import { M as E, a as F } from "./contexts/ModuleSkeletonContext/index.73a5f745.js";
|
|
9
|
+
import { N as L, a as H } from "./contexts/NetworkContext/index.d1dfbc3a.js";
|
|
10
|
+
import { D as w, a as T } from "./contexts/DomainCountryContext/index.38c27388.js";
|
|
11
|
+
import { u as B } from "./hooks/useEnvironment/index.04dca988.js";
|
|
12
|
+
import { u as W, a as b } from "./hooks/useFlags/index.a986729d.js";
|
|
13
|
+
import { u as q } from "./hooks/useHostTools/index.66d9a667.js";
|
|
14
|
+
import { u as A, a as G } from "./hooks/useDomain/index.7117ac32.js";
|
|
15
|
+
import { u as J, a as K } from "./hooks/useLocalStorage/index.281b7ae8.js";
|
|
16
|
+
import { u as R } from "./hooks/useModuleDictionary/index.5cabf2a3.js";
|
|
17
|
+
import { u as V } from "./hooks/useModulePrivileges/index.93343e3e.js";
|
|
18
|
+
import { u as Y } from "./hooks/useModuleSkeleton/index.7df262f4.js";
|
|
19
|
+
import { u as _ } from "./hooks/useNetwork/index.acbf28d5.js";
|
|
20
|
+
import { i as oo, u as eo } from "./hooks/usePaginate/index.7cb17527.js";
|
|
21
|
+
import { C as ao, E as to } from "./types/index.5f1b0c45.js";
|
|
22
|
+
import { a as io, g as no, s as mo, v as uo } from "./utils/index.4b6999c8.js";
|
|
23
|
+
import { a as lo } from "./utils/axiosOperation.6118a64a.js";
|
|
24
|
+
import "react/jsx-runtime";
|
|
25
|
+
import "axios";
|
|
26
|
+
import "qs";
|
|
27
|
+
export {
|
|
28
|
+
ao as CommonFlags,
|
|
29
|
+
g as DomainContext,
|
|
30
|
+
w as DomainCountryContext,
|
|
31
|
+
T as DomainCountryProvider,
|
|
32
|
+
v as DomainProvider,
|
|
33
|
+
to as EmitEvents,
|
|
34
|
+
i as EnvironmentContext,
|
|
35
|
+
n as EnvironmentProvider,
|
|
36
|
+
u as FlagsContext,
|
|
37
|
+
x as FlagsProvider,
|
|
38
|
+
p as HostToolsContext,
|
|
39
|
+
f as HostToolsProvider,
|
|
40
|
+
C as ModuleDictionaryContext,
|
|
41
|
+
M as ModuleDictionaryProvider,
|
|
42
|
+
S as ModulePrivilegesContext,
|
|
43
|
+
c as ModulePrivilegesProvider,
|
|
44
|
+
E as ModuleSkeletonContext,
|
|
45
|
+
F as ModuleSkeletonProvider,
|
|
46
|
+
L as NetworkContext,
|
|
47
|
+
H as NetworkProvider,
|
|
48
|
+
lo as axiosOperation,
|
|
49
|
+
io as getLocalStorage,
|
|
50
|
+
no as getPropertyByString,
|
|
51
|
+
oo as initialPagerState,
|
|
52
|
+
mo as setLocalStorage,
|
|
53
|
+
A as useDomain,
|
|
54
|
+
G as useDomainCountry,
|
|
55
|
+
B as useEnvironment,
|
|
56
|
+
W as useFlags,
|
|
57
|
+
b as useFlagsPresent,
|
|
58
|
+
q as useHostTools,
|
|
59
|
+
J as useLocalStorage,
|
|
60
|
+
K as useLocalStorageWithListener,
|
|
61
|
+
R as useModuleDictionary,
|
|
62
|
+
V as useModulePrivileges,
|
|
63
|
+
Y as useModuleSkeleton,
|
|
64
|
+
_ as useNetwork,
|
|
65
|
+
eo as usePaginate,
|
|
66
|
+
uo as voidFunction
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var E = /* @__PURE__ */ ((_) => (_.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized", _.EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change", _.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE = "domain_country_change", _))(E || {}), e = /* @__PURE__ */ ((_) => (_.FLAG_PRIVILEGES_LOADED = "privileges_loaded", _.FLAG_DICTIONARY_LOADED = "dictionary_loaded", _.FLAG_DOMAIN_LOADED = "domain_loaded", _))(e || {});
|
|
2
|
+
export {
|
|
3
|
+
e as C,
|
|
4
|
+
E
|
|
5
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import f from "axios";
|
|
2
|
+
import p from "qs";
|
|
3
|
+
import { E } from "../types/index.5f1b0c45.js";
|
|
4
|
+
function l(e, s, a) {
|
|
5
|
+
const { toast: d } = a;
|
|
6
|
+
return s && s.data && typeof s.data == "object" ? s.data.error && s.data.error?.code && s.data.error?.msg !== void 0 ? Promise.reject({ ...s.data.error, status: s.status }) : (s.data.message && d(s.data.message, { type: "success", autoClose: 1e4 }), s.data) : Promise.reject({
|
|
7
|
+
code: 1,
|
|
8
|
+
msg: `Incorrect endpoint: ${e}`,
|
|
9
|
+
status: s.status
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function _(e, s, a = !0) {
|
|
13
|
+
const { toast: d } = s;
|
|
14
|
+
let t = {
|
|
15
|
+
message: "",
|
|
16
|
+
status: 1,
|
|
17
|
+
code: 0
|
|
18
|
+
};
|
|
19
|
+
return e?.code !== void 0 && t.status !== void 0 && e.message !== void 0 && (t = { ...t, ...e }), e?.response ? e.response.data && typeof e.response.data == "object" && e.response.data.error && e.response.data.error?.code && e.response.data.error?.message !== void 0 ? t = { ...e.response.data.error, status: e.response.status } : (t.message = e.message, t.status = e.response.status, t.code = 0) : e?.request ? (t.message = `${e?.code} ${e.message}`, t.code = -1) : (t.message = `${e?.code} ${e.message}`, t.status = 0, t.code = -2), a && e?.response?.status === 401 && s.events_emit(E.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (t.message = e?.response?.data?.error.message), a && d(`${t.message} - status: ${t.status} - code: ${t.code}`, { type: "error" }), t;
|
|
20
|
+
}
|
|
21
|
+
const P = async (e, s, a) => {
|
|
22
|
+
const {
|
|
23
|
+
method: d,
|
|
24
|
+
endPoint: t,
|
|
25
|
+
timeout: c = 5e3,
|
|
26
|
+
parms: u = {},
|
|
27
|
+
data: n = {},
|
|
28
|
+
isRemote: m = !0,
|
|
29
|
+
checkUnAuthorized: r = !0,
|
|
30
|
+
headers: g
|
|
31
|
+
} = e;
|
|
32
|
+
let i;
|
|
33
|
+
return m ? i = s.host_api_remote : i = s.host_api_local, a.startProgress(), f({
|
|
34
|
+
baseURL: i,
|
|
35
|
+
withCredentials: m,
|
|
36
|
+
method: d,
|
|
37
|
+
url: `/${t}`,
|
|
38
|
+
data: n,
|
|
39
|
+
params: {},
|
|
40
|
+
paramsSerializer: () => p.stringify(u, { encode: !0 }),
|
|
41
|
+
headers: g,
|
|
42
|
+
timeout: c
|
|
43
|
+
}).then((o) => l(t, o, a)).catch((o) => Promise.reject(_(o, a, r))).finally(() => {
|
|
44
|
+
a.stopProgress();
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
P as a
|
|
49
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "axios";
|
|
2
|
+
import "qs";
|
|
3
|
+
function i() {
|
|
4
|
+
}
|
|
5
|
+
function c(r, n) {
|
|
6
|
+
let t = r;
|
|
7
|
+
const e = n.split(".");
|
|
8
|
+
for (let o = 0; o < e.length && t[e[o]] !== void 0; o += 1)
|
|
9
|
+
t = t[e[o]];
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
function s(r, n) {
|
|
13
|
+
try {
|
|
14
|
+
const t = window.localStorage.getItem(r);
|
|
15
|
+
return t !== null ? JSON.parse(t) : n;
|
|
16
|
+
} catch {
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function g(r, n, t = !1) {
|
|
21
|
+
try {
|
|
22
|
+
let e = null;
|
|
23
|
+
t && (e = window.localStorage.getItem(r));
|
|
24
|
+
let o = e !== null ? JSON.parse(e) : {};
|
|
25
|
+
o = { ...o, ...n }, window.localStorage.setItem(r, JSON.stringify(o));
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
s as a,
|
|
31
|
+
c as g,
|
|
32
|
+
g as s,
|
|
33
|
+
i as v
|
|
34
|
+
};
|