@ukpc-lib/react 0.1.12 → 0.1.14

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index-b4299ca4.cjs"),R=require("axios"),i=require("react/jsx-runtime"),d=require("react"),f=require("react-router-dom");require("react-dom");require("@mui/material");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))},A=({baseUrl:n,accessWith:r,requireAll:t,children:s})=>u(n)(r,t)?i.jsx(i.Fragment,{children:s}):null,q=({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=A;exports.PermissionRoute=q;exports.getAxiosInstance=j;exports.getUseHasPermission=u;exports.useGetPermission=E;
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;
@@ -1,12 +1,13 @@
1
- import { E as f, i as E, p as R } from "../index-9b2c9629.js";
2
- import { A as D, s as H, u as K } from "../index-9b2c9629.js";
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 y, useEffect as A } from "react";
6
- import { Navigate as j } from "react-router-dom";
5
+ import { useState as j, useEffect as y } from "react";
6
+ import { Navigate as A } from "react-router-dom";
7
7
  import "react-dom";
8
8
  import "@mui/material";
9
- function N({
9
+ import "moment";
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, c, p, m, h;
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 && (((c = e.response) == null ? void 0 : c.data.errorMessage) !== f.TOKEN_EXPIRED || !((p = e.response) != null && p.data.errorMessage)) && E(r.baseURL), e.response.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] = y([]);
38
- return A(() => {
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
- }, O = ({
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, T = ({
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(j, { to: s, replace: !0 });
64
+ }) => g(t)(r, n) ? /* @__PURE__ */ a(d, { children: e }) : /* @__PURE__ */ a(A, { to: s, replace: !0 });
64
65
  export {
65
- D as AuthProvider,
66
- O as HasPermission,
67
- T as PermissionRoute,
68
- N as getAxiosInstance,
66
+ H as AuthProvider,
67
+ T as HasPermission,
68
+ q as PermissionRoute,
69
+ O as getAxiosInstance,
69
70
  g as getUseHasPermission,
70
- H as search,
71
- K as useAuth,
71
+ K as search,
72
+ L as useAuth,
72
73
  v as useGetPermission
73
74
  };
@@ -0,0 +1,2 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ export declare const NoData: FC<PropsWithChildren>;
@@ -0,0 +1,4 @@
1
+ declare const NotFoundPage: ({ rootPath }: {
2
+ rootPath: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default NotFoundPage;
@@ -0,0 +1,8 @@
1
+ import { PopUpBaseProps, usePopUpProps } from './types';
2
+ export declare function PopUpBase(props: PopUpBaseProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function usePopUp(props?: boolean | usePopUpProps): {
4
+ setTrue: () => void;
5
+ open: boolean;
6
+ onClose: () => void;
7
+ onConfirm: (() => void) | undefined;
8
+ };
@@ -0,0 +1,26 @@
1
+ import { SxProps, TypographyProps, Theme, DialogProps, DialogActionsProps } from "@mui/material";
2
+ import { ReactNode } from "react";
3
+ export type PopUpBaseProps = IPopUp & {
4
+ title?: ReactNode;
5
+ subTitle?: ReactNode;
6
+ desc: ReactNode;
7
+ fixOverflow?: boolean;
8
+ minWidthButton?: number;
9
+ subTitleProps?: TypographyProps;
10
+ contentProps?: SxProps<Theme>;
11
+ titleProps?: SxProps<Theme>;
12
+ hideTitle?: boolean;
13
+ };
14
+ export type IPopUp = {
15
+ open: boolean;
16
+ onClose?(): void;
17
+ onConfirm?: () => void;
18
+ dialogProps?: Omit<DialogProps, 'open' | 'onClose'>;
19
+ dialogActionsProps?: DialogActionsProps;
20
+ customActions?: ReactNode;
21
+ hideConfirm?: boolean;
22
+ hideClose?: boolean;
23
+ };
24
+ export type usePopUpProps = {
25
+ onConfirm?(): void;
26
+ };
@@ -0,0 +1,4 @@
1
+ import { SVGProps } from 'react';
2
+ type BlockIconProps = SVGProps<SVGSVGElement>;
3
+ export declare function BlockIcon(props: BlockIconProps): import("react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1,13 @@
1
+ interface DateRangeValue {
2
+ startDate?: Date;
3
+ endDate?: Date;
4
+ }
5
+ type Props = {
6
+ value?: DateRangeValue;
7
+ onChange?(value: DateRangeValue): void;
8
+ initialSettings?: any;
9
+ label?: string;
10
+ dateReset?: DateRangeValue;
11
+ };
12
+ export declare function StyledDateRangePicker(props: Props): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1 @@
1
+ export declare const UnauthorizedPage: () => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,9 @@
1
1
  export * from './Topbar';
2
2
  export * from './GlobalMenu';
3
3
  export * from './Toast';
4
+ export * from './NoData';
5
+ export * from './PopUp';
6
+ export * from './NotFoundPage';
7
+ export * from './UnauthorizedPage';
4
8
  export * from './StyledAutocomplete/index.ts';
9
+ export * from './StyledDateRangePicker';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",
@@ -29,14 +29,14 @@
29
29
  "web-components-bundle"
30
30
  ],
31
31
  "scripts": {
32
- "dev": "vite",
32
+ "dev": "vite --open --port 3000",
33
33
  "build": "npm run build-react && npm run build-wc",
34
34
  "build-react": "tsc && vite build --config vite.config.react.ts",
35
35
  "build-wc": "tsc && vite build --config vite.config.wc.ts --mode production",
36
36
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
37
37
  "preview": "vite preview",
38
38
  "publish": "npm publish --access public",
39
- "build-publish": "npm run build && npm version patch && npm run build && npm run publish"
39
+ "build-publish": "npm run build && npm version patch && npm run build && npm run publish && git push"
40
40
  },
41
41
  "dependencies": {
42
42
  "@emotion/react": "^11.11.3",
@@ -46,8 +46,12 @@
46
46
  "@r2wc/react-to-web-component": "^2.0.3",
47
47
  "@rollup/plugin-replace": "^5.0.5",
48
48
  "axios": "^1.6.5",
49
+ "bootstrap-daterangepicker": "^3.1.0",
49
50
  "cssnano": "^6.0.3",
50
51
  "framer-motion": "^10.18.0",
52
+ "jquery": "^3.7.1",
53
+ "moment": "^2.30.1",
54
+ "react-bootstrap-daterangepicker": "^8.0.0",
51
55
  "react-query": "^3.39.3",
52
56
  "react-router-dom": "^6.21.3",
53
57
  "react-shadow": "^20.4.0",
@@ -56,6 +60,7 @@
56
60
  "react-window": "^1.8.10",
57
61
  "react-window-infinite-loader": "^1.0.9",
58
62
  "simplebar-react": "^3.2.4",
63
+ "usehooks-ts": "^2.15.1",
59
64
  "vite-plugin-css-injected-by-js": "^3.3.1"
60
65
  },
61
66
  "devDependencies": {