@ukpc-lib/react 0.1.15 → 0.1.16
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/dist/components/index.cjs +26 -22
- package/dist/components/index.js +7366 -2281
- package/dist/index.es-4032ffe1.js +19562 -0
- package/dist/index.es-6cb46e89.cjs +173 -0
- package/dist/share/index.cjs +1 -1
- package/dist/share/index.js +19 -18
- package/package.json +1 -1
- package/web-components-bundle/global-menu/index.cjs +24 -24
- package/web-components-bundle/global-menu/index.js +5553 -5554
- package/dist/index.es-088789c7.cjs +0 -177
- package/dist/index.es-bb5fb95c.js +0 -24653
package/dist/share/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.es-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.es-6cb46e89.cjs"),R=require("axios"),i=require("react/jsx-runtime"),d=require("react"),f=require("react-router-dom");require("react-dom");require("@mui/material");require("moment");function j({config:n,pushError:r=o.pushError}){const t=R.create(n);t.interceptors.request.use(async e=>(e.headers={Accept:"application/json","Content-Type":"application/json"},e),e=>Promise.reject(e)),t.interceptors.response.use(e=>e,async e=>s(e));function s(e){var c,p,m,h,P,g;console.error("Error 🚨:",e);const a=e==null?void 0:e.config;if(((c=e.response)==null?void 0:c.status)===401&&e.response.data.errorMessage===o.ERROR_MESSAGE.TOKEN_EXPIRED&&!a._retry&&(a._retry=!0,t.post("/authentication/api/v1/auth/refresh-token").then(()=>t(a)).catch(()=>o.login(n.baseURL))),((p=e.response)==null?void 0:p.status)===401&&(((m=e.response)==null?void 0:m.data.errorMessage)!==o.ERROR_MESSAGE.TOKEN_EXPIRED||!((h=e.response)!=null&&h.data.errorMessage))&&o.login(n.baseURL),e.response.status!==401){const l=((P=e.response)==null?void 0:P.data)&&((g=e.response.data)==null?void 0:g.errorMessage)||"Something went wrong!";return r(l),Promise.reject(e.response.data)}return Promise.reject(e)}return t}const E=n=>{const[r,t]=d.useState([]);return d.useEffect(()=>{R.get(`${n}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(s=>t(s.data)).catch(s=>{console.error("Getting user permission error:",s)})},[n]),r},u=n=>(r,t)=>{const s=E(n);return t?r.every(e=>s==null?void 0:s.includes(e)):r.some(e=>s==null?void 0:s.includes(e))},q=({baseUrl:n,accessWith:r,requireAll:t,children:s})=>u(n)(r,t)?i.jsx(i.Fragment,{children:s}):null,A=({accessWith:n,requireAll:r,baseUrl:t,unAuthorizedPath:s,children:e})=>u(t)(n,r)?i.jsx(i.Fragment,{children:e}):i.jsx(f.Navigate,{to:s,replace:!0});exports.AuthProvider=o.AuthProvider;exports.search=o.search;exports.useAuth=o.useAuth;exports.HasPermission=q;exports.PermissionRoute=A;exports.getAxiosInstance=j;exports.getUseHasPermission=u;exports.useGetPermission=E;
|
package/dist/share/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { E as f,
|
|
2
|
-
import { A as
|
|
1
|
+
import { E as f, j as E, p as R } from "../index.es-4032ffe1.js";
|
|
2
|
+
import { A as H, s as K, u as L } from "../index.es-4032ffe1.js";
|
|
3
3
|
import P from "axios";
|
|
4
4
|
import { jsx as a, Fragment as d } from "react/jsx-runtime";
|
|
5
|
-
import { useState as
|
|
5
|
+
import { useState as j, useEffect as y } from "react";
|
|
6
|
+
import { Navigate as A } from "react-router-dom";
|
|
7
|
+
import "react-dom";
|
|
6
8
|
import "@mui/material";
|
|
7
|
-
import { Navigate as j } from "react-router-dom";
|
|
8
9
|
import "moment";
|
|
9
|
-
function
|
|
10
|
+
function O({
|
|
10
11
|
config: r,
|
|
11
12
|
pushError: n = R
|
|
12
13
|
}) {
|
|
@@ -22,10 +23,10 @@ function N({
|
|
|
22
23
|
async (e) => s(e)
|
|
23
24
|
);
|
|
24
25
|
function s(e) {
|
|
25
|
-
var i, u,
|
|
26
|
+
var i, u, p, c, m, h;
|
|
26
27
|
console.error("Error 🚨:", e);
|
|
27
28
|
const o = e == null ? void 0 : e.config;
|
|
28
|
-
if (((i = e.response) == null ? void 0 : i.status) === 401 && e.response.data.errorMessage === f.TOKEN_EXPIRED && !o._retry && (o._retry = !0, t.post("/authentication/api/v1/auth/refresh-token").then(() => t(o)).catch(() => E(r.baseURL))), ((u = e.response) == null ? void 0 : u.status) === 401 && (((
|
|
29
|
+
if (((i = e.response) == null ? void 0 : i.status) === 401 && e.response.data.errorMessage === f.TOKEN_EXPIRED && !o._retry && (o._retry = !0, t.post("/authentication/api/v1/auth/refresh-token").then(() => t(o)).catch(() => E(r.baseURL))), ((u = e.response) == null ? void 0 : u.status) === 401 && (((p = e.response) == null ? void 0 : p.data.errorMessage) !== f.TOKEN_EXPIRED || !((c = e.response) != null && c.data.errorMessage)) && E(r.baseURL), e.response.status !== 401) {
|
|
29
30
|
const l = ((m = e.response) == null ? void 0 : m.data) && ((h = e.response.data) == null ? void 0 : h.errorMessage) || "Something went wrong!";
|
|
30
31
|
return n(l), Promise.reject(e.response.data);
|
|
31
32
|
}
|
|
@@ -34,8 +35,8 @@ function N({
|
|
|
34
35
|
return t;
|
|
35
36
|
}
|
|
36
37
|
const v = (r) => {
|
|
37
|
-
const [n, t] =
|
|
38
|
-
return
|
|
38
|
+
const [n, t] = j([]);
|
|
39
|
+
return y(() => {
|
|
39
40
|
P.get(`${r}/user-management/api/v1/users/my-account/permissions`, {
|
|
40
41
|
withCredentials: !0
|
|
41
42
|
}).then((s) => t(s.data)).catch((s) => {
|
|
@@ -49,25 +50,25 @@ const v = (r) => {
|
|
|
49
50
|
) : n.some(
|
|
50
51
|
(e) => s == null ? void 0 : s.includes(e)
|
|
51
52
|
);
|
|
52
|
-
},
|
|
53
|
+
}, T = ({
|
|
53
54
|
baseUrl: r,
|
|
54
55
|
accessWith: n,
|
|
55
56
|
requireAll: t,
|
|
56
57
|
children: s
|
|
57
|
-
}) => g(r)(n, t) ? /* @__PURE__ */ a(d, { children: s }) : null,
|
|
58
|
+
}) => g(r)(n, t) ? /* @__PURE__ */ a(d, { children: s }) : null, q = ({
|
|
58
59
|
accessWith: r,
|
|
59
60
|
requireAll: n,
|
|
60
61
|
baseUrl: t,
|
|
61
62
|
unAuthorizedPath: s,
|
|
62
63
|
children: e
|
|
63
|
-
}) => g(t)(r, n) ? /* @__PURE__ */ a(d, { children: e }) : /* @__PURE__ */ a(
|
|
64
|
+
}) => g(t)(r, n) ? /* @__PURE__ */ a(d, { children: e }) : /* @__PURE__ */ a(A, { to: s, replace: !0 });
|
|
64
65
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
H as AuthProvider,
|
|
67
|
+
T as HasPermission,
|
|
68
|
+
q as PermissionRoute,
|
|
69
|
+
O as getAxiosInstance,
|
|
69
70
|
g as getUseHasPermission,
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
K as search,
|
|
72
|
+
L as useAuth,
|
|
72
73
|
v as useGetPermission
|
|
73
74
|
};
|