@ukpc-lib/react 0.3.4 → 0.3.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.
- package/dist/components/index.cjs +23 -23
- package/dist/components/index.js +39 -40
- package/dist/{index.module-d03675ea.js → index.module-9e206368.js} +12960 -12326
- package/dist/index.module-ad52e7aa.cjs +1092 -0
- package/dist/share/index.cjs +1 -1
- package/dist/share/index.js +23 -22
- package/dist/theme/SaasThemeProvider.d.ts +26 -0
- package/dist/theme/index.d.ts +3 -26
- package/package.json +1 -1
- package/dist/index-2ca7cc99.js +0 -636
- package/dist/index-5840ed79.cjs +0 -1
- package/dist/index.module-28c2f9be.cjs +0 -1092
- package/dist/theme/index.cjs +0 -1
- package/dist/theme/index.js +0 -9
package/dist/share/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../index.module-ad52e7aa.cjs"),d=require("axios"),i=require("react/jsx-runtime"),g=require("react");require("moment");require("@r2wc/react-to-web-component");require("@mui/material");const f=require("react-router-dom");function R({config:n,pushError:o=s.pushError}){const t=d.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=>r(e));async function r(e){var l,h,P,p;console.error("Error 🚨:",e);const a=e.config,u=(h=(l=e.response)==null?void 0:l.data)==null?void 0:h.errorMessage,m=u===s.ERROR_MESSAGE.TOKEN_EXPIRED;return((P=e.response)==null?void 0:P.status)===401?m&&!a._retry?(a._retry=!0,t.post("/authentication/api/v1/auth/refresh-token").then(()=>t(a)).catch(()=>s.login(n.baseURL))):((!u||!m)&&s.login(n.baseURL),Promise.reject("Unauthorized! Please login again.")):(((p=e.response)==null?void 0:p.status)===403?o(s.t("errorMessage.403")):o(s.t(`${u}`)||"Something went wrong!"),Promise.reject(e.response.data))}return t}const T=n=>{const[o,t]=g.useState([]);return g.useEffect(()=>{d.get(`${n}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(r=>t(r.data)).catch(r=>{console.error("Getting user permission error:",r)})},[n]),o},c=n=>(o,t)=>{const r=T(n);return t?o.every(e=>r==null?void 0:r.includes(e)):o.some(e=>r==null?void 0:r.includes(e))},v=({baseUrl:n,accessWith:o,requireAll:t,children:r})=>c(n)(o,t)?i.jsx(i.Fragment,{children:r}):null,j=({accessWith:n,requireAll:o,baseUrl:t,unAuthorizedPath:r,children:e})=>c(t)(n,o)?i.jsx(i.Fragment,{children:e}):i.jsx(f.Navigate,{to:r,replace:!0});exports.AuthProvider=s.AuthProvider;exports.SaasThemeProvider=s.SaasThemeProvider;exports.TranslationProvider=s.TranslationProvider;exports.color=s.color;exports.createCustomTheme=s.createCustomTheme;exports.search=s.search;exports.translate=s.translate;exports.translationConfig=s.translationConfig;exports.useAuth=s.useAuth;exports.useCustomTranslation=s.useCustomTranslation;exports.useTheme=s.useTheme;exports.useTranslation=s.useTranslation$1;exports.HasPermission=v;exports.PermissionRoute=j;exports.getAxiosInstance=R;exports.getUseHasPermission=c;exports.useGetPermission=T;
|
package/dist/share/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { E as l, F as f, p as E, H as R } from "../index.module-9e206368.js";
|
|
2
|
+
import { J as k, V as q, T as F, c as K, R as L, n as b, N as z, M as D, K as J, u as V, U as X, O as $ } from "../index.module-9e206368.js";
|
|
3
3
|
import P from "axios";
|
|
4
4
|
import { jsx as i, Fragment as g } from "react/jsx-runtime";
|
|
5
5
|
import { useState as T, useEffect as v } from "react";
|
|
6
6
|
import "moment";
|
|
7
7
|
import "@r2wc/react-to-web-component";
|
|
8
8
|
import "@mui/material";
|
|
9
|
-
import { Navigate as
|
|
10
|
-
|
|
11
|
-
function H({
|
|
9
|
+
import { Navigate as y } from "react-router-dom";
|
|
10
|
+
function G({
|
|
12
11
|
config: t,
|
|
13
12
|
pushError: n = E
|
|
14
13
|
}) {
|
|
@@ -31,7 +30,7 @@ function H({
|
|
|
31
30
|
}
|
|
32
31
|
return r;
|
|
33
32
|
}
|
|
34
|
-
const
|
|
33
|
+
const x = (t) => {
|
|
35
34
|
const [n, r] = T([]);
|
|
36
35
|
return v(() => {
|
|
37
36
|
P.get(`${t}/user-management/api/v1/users/my-account/permissions`, {
|
|
@@ -41,38 +40,40 @@ const y = (t) => {
|
|
|
41
40
|
});
|
|
42
41
|
}, [t]), n;
|
|
43
42
|
}, d = (t) => (n, r) => {
|
|
44
|
-
const s =
|
|
43
|
+
const s = x(t);
|
|
45
44
|
return r ? n.every(
|
|
46
45
|
(e) => s == null ? void 0 : s.includes(e)
|
|
47
46
|
) : n.some(
|
|
48
47
|
(e) => s == null ? void 0 : s.includes(e)
|
|
49
48
|
);
|
|
50
|
-
},
|
|
49
|
+
}, H = ({
|
|
51
50
|
baseUrl: t,
|
|
52
51
|
accessWith: n,
|
|
53
52
|
requireAll: r,
|
|
54
53
|
children: s
|
|
55
|
-
}) => d(t)(n, r) ? /* @__PURE__ */ i(g, { children: s }) : null,
|
|
54
|
+
}) => d(t)(n, r) ? /* @__PURE__ */ i(g, { children: s }) : null, I = ({
|
|
56
55
|
accessWith: t,
|
|
57
56
|
requireAll: n,
|
|
58
57
|
baseUrl: r,
|
|
59
58
|
unAuthorizedPath: s,
|
|
60
59
|
children: e
|
|
61
|
-
}) => d(r)(t, n) ? /* @__PURE__ */ i(g, { children: e }) : /* @__PURE__ */ i(
|
|
60
|
+
}) => d(r)(t, n) ? /* @__PURE__ */ i(g, { children: e }) : /* @__PURE__ */ i(y, { to: s, replace: !0 });
|
|
62
61
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
k as AuthProvider,
|
|
63
|
+
H as HasPermission,
|
|
64
|
+
I as PermissionRoute,
|
|
65
|
+
q as SaasThemeProvider,
|
|
67
66
|
F as TranslationProvider,
|
|
68
|
-
|
|
67
|
+
K as color,
|
|
68
|
+
L as createCustomTheme,
|
|
69
|
+
G as getAxiosInstance,
|
|
69
70
|
d as getUseHasPermission,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
b as search,
|
|
72
|
+
z as translate,
|
|
73
|
+
D as translationConfig,
|
|
74
|
+
J as useAuth,
|
|
75
|
+
V as useCustomTranslation,
|
|
76
|
+
x as useGetPermission,
|
|
76
77
|
X as useTheme,
|
|
77
|
-
|
|
78
|
+
$ as useTranslation
|
|
78
79
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Theme } from '@mui/material';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { ColorsType } from './Colors';
|
|
4
|
+
type B = {
|
|
5
|
+
url: string;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const useTheme: () => {
|
|
9
|
+
colors: ColorsType;
|
|
10
|
+
theme: Theme;
|
|
11
|
+
logo: any;
|
|
12
|
+
isFetching: boolean;
|
|
13
|
+
};
|
|
14
|
+
type P = {
|
|
15
|
+
brandTheme: B;
|
|
16
|
+
customTheme?: never;
|
|
17
|
+
} | {
|
|
18
|
+
brandTheme?: never;
|
|
19
|
+
customTheme: Partial<Theme>;
|
|
20
|
+
} | {
|
|
21
|
+
brandTheme?: never;
|
|
22
|
+
customTheme?: never;
|
|
23
|
+
};
|
|
24
|
+
export type BrandThemeProps = PropsWithChildren<P>;
|
|
25
|
+
export declare const SaasThemeProvider: (props: BrandThemeProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export {};
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type B = {
|
|
5
|
-
url: string;
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare const useTheme: () => {
|
|
9
|
-
colors: ColorsType;
|
|
10
|
-
theme: Theme;
|
|
11
|
-
logo: any;
|
|
12
|
-
isFetching: boolean;
|
|
13
|
-
};
|
|
14
|
-
type P = {
|
|
15
|
-
brandTheme: B;
|
|
16
|
-
customTheme?: never;
|
|
17
|
-
} | {
|
|
18
|
-
brandTheme?: never;
|
|
19
|
-
customTheme: Partial<Theme>;
|
|
20
|
-
} | {
|
|
21
|
-
brandTheme?: never;
|
|
22
|
-
customTheme?: never;
|
|
23
|
-
};
|
|
24
|
-
type BrandThemeProps = PropsWithChildren<P>;
|
|
25
|
-
export declare const SaasThemeProvider: (props: BrandThemeProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
-
export {};
|
|
1
|
+
export * from './Colors';
|
|
2
|
+
export * from './Theme';
|
|
3
|
+
export * from './SaasThemeProvider';
|