@ukpc-lib/react 0.1.20 → 0.1.21
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/GlobalMenu/components/Dropdown.d.ts +8 -0
- package/dist/components/GlobalMenu/components/MenuItem.d.ts +15 -0
- package/dist/components/GlobalMenu/helpers/index.d.ts +0 -0
- package/dist/components/GlobalMenu/icons/IconCollapsed.d.ts +2 -0
- package/dist/components/GlobalMenu/icons/IconDown.d.ts +3 -0
- package/dist/components/GlobalMenu/icons/IconExpand.d.ts +2 -0
- package/dist/components/GlobalMenu/icons/IconLogout.d.ts +2 -0
- package/dist/components/GlobalMenu/index.d.ts +7 -0
- package/dist/components/GlobalMenu/models/MenuItemDto.d.ts +8 -0
- package/dist/components/GlobalMenu/models/index.d.ts +1 -0
- package/dist/components/LanguageSwitcher/index.d.ts +1 -0
- package/dist/components/LogoutConfirmModal/index.d.ts +7 -0
- package/dist/components/NoData/index.d.ts +2 -0
- package/dist/components/NotFoundPage/index.d.ts +4 -0
- package/dist/components/PopUp/index.d.ts +8 -0
- package/dist/components/PopUp/types.d.ts +26 -0
- package/dist/components/ShadownDom/index.d.ts +8 -0
- package/dist/components/StyledAutocomplete/AutocompleteOption.d.ts +11 -0
- package/dist/components/StyledAutocomplete/StyledAutocomplete.d.ts +29 -0
- package/dist/components/StyledAutocomplete/helpers.d.ts +1 -0
- package/dist/components/StyledAutocomplete/index.d.ts +3 -0
- package/dist/components/StyledAutocomplete/types.d.ts +46 -0
- package/dist/components/StyledAutocomplete/useStyledAutocomplete.d.ts +28 -0
- package/dist/components/StyledDateRangePicker/BlockIcon.d.ts +4 -0
- package/dist/components/StyledDateRangePicker/index.d.ts +13 -0
- package/dist/components/Toast/ToastConfig.d.ts +2 -0
- package/dist/components/Toast/icons/ErrorIcon.d.ts +1 -0
- package/dist/components/Toast/icons/SuccessIcon.d.ts +1 -0
- package/dist/components/Toast/icons/WarningIcon.d.ts +1 -0
- package/dist/components/Toast/index.d.ts +5 -0
- package/dist/components/Topbar/icons/MessageIcon.d.ts +4 -0
- package/dist/components/Topbar/icons/NotificationIcon.d.ts +3 -0
- package/dist/components/Topbar/index.d.ts +29 -0
- package/dist/components/UnauthorizedPage/index.d.ts +1 -0
- package/dist/components/index.cjs +65 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +10047 -0
- package/dist/index.css +1 -0
- package/dist/index.es-52d1ebeb.cjs +173 -0
- package/dist/index.es-da1b88a3.js +19562 -0
- package/dist/share/AuthProvider/index.d.ts +20 -0
- package/dist/share/helpers/index.d.ts +1 -0
- package/dist/share/hooks/index.d.ts +1 -0
- package/dist/share/hooks/useGetPermission.d.ts +1 -0
- package/dist/share/index.cjs +1 -0
- package/dist/share/index.d.ts +5 -0
- package/dist/share/index.js +70 -0
- package/dist/share/interceptor/index.d.ts +7 -0
- package/dist/share/interceptor/interceptor.const.d.ts +6 -0
- package/dist/share/permissions/HasPermission.d.ts +9 -0
- package/dist/share/permissions/PermissionRoute.d.ts +9 -0
- package/dist/share/permissions/index.d.ts +2 -0
- package/package.json +1 -1
- package/web-components-bundle/global-menu/index.cjs +91 -0
- package/web-components-bundle/global-menu/index.js +18098 -0
- package/web-components-bundle/global-topbar/index.cjs +3 -0
- package/web-components-bundle/global-topbar/index.js +228 -0
- package/web-components-bundle/index-3a3447c8.cjs +69 -0
- package/web-components-bundle/index-688657b9.js +9352 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { UseQueryResult } from 'react-query';
|
|
3
|
+
type User = {
|
|
4
|
+
firstName: string;
|
|
5
|
+
lastName: string;
|
|
6
|
+
countryCode?: string;
|
|
7
|
+
status?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
avatarUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const AuthProvider: FC<PropsWithChildren & {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
userData: UseQueryResult;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const useAuth: () => {
|
|
16
|
+
login: () => void;
|
|
17
|
+
logout: () => void;
|
|
18
|
+
user: User;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function search<T>(option: T, searchText: string, fields: Array<keyof T>): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useGetPermission';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useGetPermission: (baseUrl: string) => string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.es-52d1ebeb.cjs"),l=require("axios"),i=require("react/jsx-runtime"),g=require("react"),R=require("react-router-dom");require("react-dom");require("@mui/material");require("moment");function E({config:t,pushError:n=o.pushError}){const r=l.create(t);r.interceptors.request.use(async e=>(e.headers={Accept:"application/json","Content-Type":"application/json"},e),e=>Promise.reject(e)),r.interceptors.response.use(e=>e,async e=>s(e));async function s(e){var h,p,P;console.error("Error 🚨:",e);const a=e.config,u=(p=(h=e.response)==null?void 0:h.data)==null?void 0:p.errorMessage,m=u===o.ERROR_MESSAGE.TOKEN_EXPIRED;return((P=e.response)==null?void 0:P.status)===401?m&&!a._retry?(a._retry=!0,r.post("/authentication/api/v1/auth/refresh-token").then(()=>r(a)).catch(()=>o.login(t.baseURL))):((!u||!m)&&o.login(t.baseURL),Promise.reject("Unauthorized! Please login again.")):(n(u||"Something went wrong!"),Promise.reject(e.response.data))}return r}const d=t=>{const[n,r]=g.useState([]);return g.useEffect(()=>{l.get(`${t}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(s=>r(s.data)).catch(s=>{console.error("Getting user permission error:",s)})},[t]),n},c=t=>(n,r)=>{const s=d(t);return r?n.every(e=>s==null?void 0:s.includes(e)):n.some(e=>s==null?void 0:s.includes(e))},f=({baseUrl:t,accessWith:n,requireAll:r,children:s})=>c(t)(n,r)?i.jsx(i.Fragment,{children:s}):null,j=({accessWith:t,requireAll:n,baseUrl:r,unAuthorizedPath:s,children:e})=>c(r)(t,n)?i.jsx(i.Fragment,{children:e}):i.jsx(R.Navigate,{to:s,replace:!0});exports.AuthProvider=o.AuthProvider;exports.search=o.search;exports.useAuth=o.useAuth;exports.HasPermission=f;exports.PermissionRoute=j;exports.getAxiosInstance=E;exports.getUseHasPermission=c;exports.useGetPermission=d;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { j as h, p as E, E as g } from "../index.es-da1b88a3.js";
|
|
2
|
+
import { A as C, s as H, u as L } from "../index.es-da1b88a3.js";
|
|
3
|
+
import f from "axios";
|
|
4
|
+
import { jsx as a, Fragment as P } from "react/jsx-runtime";
|
|
5
|
+
import { useState as d, useEffect as R } from "react";
|
|
6
|
+
import { Navigate as y } from "react-router-dom";
|
|
7
|
+
import "react-dom";
|
|
8
|
+
import "@mui/material";
|
|
9
|
+
import "moment";
|
|
10
|
+
function M({
|
|
11
|
+
config: t,
|
|
12
|
+
pushError: n = E
|
|
13
|
+
}) {
|
|
14
|
+
const s = f.create(t);
|
|
15
|
+
s.interceptors.request.use(
|
|
16
|
+
async (e) => (e.headers = {
|
|
17
|
+
Accept: "application/json",
|
|
18
|
+
"Content-Type": "application/json"
|
|
19
|
+
}, e),
|
|
20
|
+
(e) => Promise.reject(e)
|
|
21
|
+
), s.interceptors.response.use(
|
|
22
|
+
(e) => e,
|
|
23
|
+
async (e) => r(e)
|
|
24
|
+
);
|
|
25
|
+
async function r(e) {
|
|
26
|
+
var c, p, m;
|
|
27
|
+
console.error("Error 🚨:", e);
|
|
28
|
+
const o = e.config, i = (p = (c = e.response) == null ? void 0 : c.data) == null ? void 0 : p.errorMessage, u = i === g.TOKEN_EXPIRED;
|
|
29
|
+
return ((m = e.response) == null ? void 0 : m.status) === 401 ? u && !o._retry ? (o._retry = !0, s.post("/authentication/api/v1/auth/refresh-token").then(() => s(o)).catch(() => h(t.baseURL))) : ((!i || !u) && h(t.baseURL), Promise.reject("Unauthorized! Please login again.")) : (n(i || "Something went wrong!"), Promise.reject(e.response.data));
|
|
30
|
+
}
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
const j = (t) => {
|
|
34
|
+
const [n, s] = d([]);
|
|
35
|
+
return R(() => {
|
|
36
|
+
f.get(`${t}/user-management/api/v1/users/my-account/permissions`, {
|
|
37
|
+
withCredentials: !0
|
|
38
|
+
}).then((r) => s(r.data)).catch((r) => {
|
|
39
|
+
console.error("Getting user permission error:", r);
|
|
40
|
+
});
|
|
41
|
+
}, [t]), n;
|
|
42
|
+
}, l = (t) => (n, s) => {
|
|
43
|
+
const r = j(t);
|
|
44
|
+
return s ? n.every(
|
|
45
|
+
(e) => r == null ? void 0 : r.includes(e)
|
|
46
|
+
) : n.some(
|
|
47
|
+
(e) => r == null ? void 0 : r.includes(e)
|
|
48
|
+
);
|
|
49
|
+
}, T = ({
|
|
50
|
+
baseUrl: t,
|
|
51
|
+
accessWith: n,
|
|
52
|
+
requireAll: s,
|
|
53
|
+
children: r
|
|
54
|
+
}) => l(t)(n, s) ? /* @__PURE__ */ a(P, { children: r }) : null, U = ({
|
|
55
|
+
accessWith: t,
|
|
56
|
+
requireAll: n,
|
|
57
|
+
baseUrl: s,
|
|
58
|
+
unAuthorizedPath: r,
|
|
59
|
+
children: e
|
|
60
|
+
}) => l(s)(t, n) ? /* @__PURE__ */ a(P, { children: e }) : /* @__PURE__ */ a(y, { to: r, replace: !0 });
|
|
61
|
+
export {
|
|
62
|
+
C as AuthProvider,
|
|
63
|
+
T as HasPermission,
|
|
64
|
+
U as PermissionRoute,
|
|
65
|
+
M as getAxiosInstance,
|
|
66
|
+
l as getUseHasPermission,
|
|
67
|
+
H as search,
|
|
68
|
+
L as useAuth,
|
|
69
|
+
j as useGetPermission
|
|
70
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
type TgetAxiosInstanceParams = {
|
|
3
|
+
config: AxiosRequestConfig;
|
|
4
|
+
pushError?: (message: string) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function getAxiosInstance({ config, pushError, }: TgetAxiosInstanceParams): import("axios").AxiosInstance;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
export declare const getUseHasPermission: (baseUrl: string) => (accessWith: string[], requireAll?: boolean) => boolean;
|
|
3
|
+
type HasPermissionProps = {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
accessWith: string[];
|
|
6
|
+
requireAll?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const HasPermission: ({ baseUrl, accessWith, requireAll, children, }: PropsWithChildren<HasPermissionProps>) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
type PermissionRouteProps = {
|
|
3
|
+
accessWith: string[];
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
requireAll?: boolean;
|
|
6
|
+
unAuthorizedPath: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const PermissionRoute: ({ accessWith, requireAll, baseUrl, unAuthorizedPath, children, }: PropsWithChildren<PermissionRouteProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|