@ukpc-lib/react 0.13.1-dev.8 → 0.13.1-dev.9

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.
@@ -19,4 +19,5 @@ export * from './Notification';
19
19
  export * from './MultiProvider';
20
20
  export * from './PageNotFound';
21
21
  export * from './GlobalMenu/components/MenuIconComponent.tsx';
22
+ export * from './PopUp/types.ts';
22
23
  export * from './BaseBreadcrumb';
@@ -1,2 +1,3 @@
1
1
  export * from './useGetPermission';
2
2
  export * from './useSyncRouter';
3
+ export * from './useSyncBackdrop';
@@ -0,0 +1,4 @@
1
+ export declare function useSyncBackdrop({ open, disabled, }: {
2
+ open: boolean;
3
+ disabled?: boolean;
4
+ }): void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.esm2017-C3w5APcd.cjs"),d=require("axios"),c=require("react"),l=require("react-router-dom"),u=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");const g=n=>{const[r,s]=c.useState([]);return c.useEffect(()=>{d.get(`${n}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(o=>s(o.data)).catch(o=>{console.error("Getting user permission error:",o)})},[n]),r},P=n=>{const r=l.useNavigate(),s=l.useLocation();console.log(" useSyncRouter.tsx ~ location1:",s,window.location.pathname);const o=(t=s)=>(n||"")+t.pathname+t.search+t.hash;if(c.useEffect(()=>{const t={changeRoute:i=>{const a=o();if(typeof i=="string"&&a!==i){console.log(" useSyncRouter.tsx ~ location2:",a,i);const h=n&&i.startsWith(n)?i.substring(n.length):i;r(h)}}};window.MicrofeBridge=t},[r,s]),c.useEffect(()=>{var i,a;const t=o();console.log("fullPath1",window.location.pathname,t),(a=(i=window.parent)==null?void 0:i.HostBridge)==null||a.childRouteChange(t)},[s]),window.self===window.top){console.log("useSyncRouter: Navigate to /app path"),window.location.href=window.location.href.replace(window.origin,`${window.origin}/app`);return}},m=n=>(r,s)=>{const o=g(n);return s?r.every(t=>o==null?void 0:o.includes(t)):r.some(t=>o==null?void 0:o.includes(t))},f=({baseUrl:n,accessWith:r,requireAll:s,children:o})=>m(n)(r,s)?u.jsx(u.Fragment,{children:o}):null,w=({accessWith:n,requireAll:r,baseUrl:s,unAuthorizedPath:o,children:t})=>m(s)(n,r)?u.jsx(u.Fragment,{children:t}):u.jsx(l.Navigate,{to:o,replace:!0});exports.AuthContext=e.AuthContext;exports.AuthProvider=e.AuthProvider;exports.ERROR_MESSAGE=e.ERROR_MESSAGE;exports.SaasThemeProvider=e.SaasThemeProvider;exports.TranslationProvider=e.TranslationProvider;exports.axiosInstance=e.axiosInstance;exports.color=e.color;exports.createCustomTheme=e.createCustomTheme;exports.handleErrorAxios=e.handleErrorAxios;exports.login=e.login;exports.logout=e.logout;exports.responseInterceptor=e.responseInterceptor;exports.search=e.search;exports.setFavicon=e.setFavicon;exports.translate=e.translate;exports.translationConfig=e.translationConfig;exports.useAuth=e.useAuth;exports.useCustomTranslation=e.useCustomTranslation;exports.useTheme=e.useTheme;exports.useTranslation=e.useTranslation$1;exports.HasPermission=f;exports.PermissionRoute=w;exports.getUseHasPermission=m;exports.useGetPermission=g;exports.useSyncRouter=P;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.esm2017-C3w5APcd.cjs"),h=require("axios"),c=require("react"),l=require("react-router-dom"),u=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");const d=n=>{const[s,r]=c.useState([]);return c.useEffect(()=>{h.get(`${n}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(e=>r(e.data)).catch(e=>{console.error("Getting user permission error:",e)})},[n]),s},f=n=>{const s=l.useNavigate(),r=l.useLocation();console.log(" useSyncRouter.tsx ~ location1:",r,window.location.pathname);const e=(t=r)=>(n||"")+t.pathname+t.search+t.hash;if(c.useEffect(()=>{const t={changeRoute:i=>{const a=e();if(typeof i=="string"&&a!==i){console.log(" useSyncRouter.tsx ~ location2:",a,i);const g=n&&i.startsWith(n)?i.substring(n.length):i;s(g)}}};window.MicrofeBridge=t},[s,r]),c.useEffect(()=>{var i,a;const t=e();console.log("fullPath1",window.location.pathname,t),(a=(i=window.parent)==null?void 0:i.HostBridge)==null||a.childRouteChange(t)},[r]),window.self===window.top){console.log("useSyncRouter: Navigate to /app path"),window.location.href=window.location.href.replace(window.origin,`${window.origin}/app`);return}};function w({open:n,disabled:s}){c.useMemo(()=>{var r,e,t,i;s||(n?(e=(r=window.top)==null?void 0:r.HostBridge)==null||e.openBackdrop(!0):(i=(t=window.top)==null?void 0:t.HostBridge)==null||i.openBackdrop(!1))},[n,s])}const m=n=>(s,r)=>{const e=d(n);return r?s.every(t=>e==null?void 0:e.includes(t)):s.some(t=>e==null?void 0:e.includes(t))},P=({baseUrl:n,accessWith:s,requireAll:r,children:e})=>m(n)(s,r)?u.jsx(u.Fragment,{children:e}):null,p=({accessWith:n,requireAll:s,baseUrl:r,unAuthorizedPath:e,children:t})=>m(r)(n,s)?u.jsx(u.Fragment,{children:t}):u.jsx(l.Navigate,{to:e,replace:!0});exports.AuthContext=o.AuthContext;exports.AuthProvider=o.AuthProvider;exports.ERROR_MESSAGE=o.ERROR_MESSAGE;exports.SaasThemeProvider=o.SaasThemeProvider;exports.TranslationProvider=o.TranslationProvider;exports.axiosInstance=o.axiosInstance;exports.color=o.color;exports.createCustomTheme=o.createCustomTheme;exports.handleErrorAxios=o.handleErrorAxios;exports.login=o.login;exports.logout=o.logout;exports.responseInterceptor=o.responseInterceptor;exports.search=o.search;exports.setFavicon=o.setFavicon;exports.translate=o.translate;exports.translationConfig=o.translationConfig;exports.useAuth=o.useAuth;exports.useCustomTranslation=o.useCustomTranslation;exports.useTheme=o.useTheme;exports.useTranslation=o.useTranslation$1;exports.HasPermission=P;exports.PermissionRoute=p;exports.getUseHasPermission=m;exports.useGetPermission=d;exports.useSyncBackdrop=w;exports.useSyncRouter=f;
@@ -1,93 +1,104 @@
1
- import { M, N, O as B, a0 as G, Y as H, a as $, c as I, Z as O, U as j, R as z, T as L, V as U, v as V, $ as W, t as X, W as Y, b as Z, u as _, g as k, X as q } from "../index.esm2017-DJ5XZpWt.js";
1
+ import { M as F, N, O as k, a0 as G, Y as $, a as I, c as O, Z as j, U as z, R as L, T as U, V, v as W, $ as X, t as Y, W as Z, b as _, u as q, g as D, X as J } from "../index.esm2017-DJ5XZpWt.js";
2
2
  import g from "axios";
3
- import { useState as h, useEffect as i } from "react";
4
- import { useNavigate as d, useLocation as f, Navigate as w } from "react-router-dom";
3
+ import { useState as d, useEffect as a, useMemo as f } from "react";
4
+ import { useNavigate as h, useLocation as w, Navigate as p } from "react-router-dom";
5
5
  import { jsx as u, Fragment as c } from "react/jsx-runtime";
6
6
  import "@r2wc/react-to-web-component";
7
7
  import "@mui/material";
8
- const P = (s) => {
9
- const [n, t] = h([]);
10
- return i(() => {
11
- g.get(`${s}/user-management/api/v1/users/my-account/permissions`, {
8
+ const P = (t) => {
9
+ const [n, s] = d([]);
10
+ return a(() => {
11
+ g.get(`${t}/user-management/api/v1/users/my-account/permissions`, {
12
12
  withCredentials: !0
13
- }).then((o) => t(o.data)).catch((o) => {
13
+ }).then((o) => s(o.data)).catch((o) => {
14
14
  console.error("Getting user permission error:", o);
15
15
  });
16
- }, [s]), n;
17
- }, T = (s) => {
18
- const n = d(), t = f();
16
+ }, [t]), n;
17
+ }, T = (t) => {
18
+ const n = h(), s = w();
19
19
  console.log(
20
20
  " useSyncRouter.tsx ~ location1:",
21
- t,
21
+ s,
22
22
  window.location.pathname
23
23
  );
24
- const o = (e = t) => (s || "") + e.pathname + e.search + e.hash;
25
- if (i(() => {
24
+ const o = (e = s) => (t || "") + e.pathname + e.search + e.hash;
25
+ if (a(() => {
26
26
  const e = {
27
27
  changeRoute: (r) => {
28
- const a = o();
29
- if (typeof r == "string" && a !== r) {
30
- console.log(" useSyncRouter.tsx ~ location2:", a, r);
31
- const m = s && r.startsWith(s) ? r.substring(s.length) : r;
28
+ const i = o();
29
+ if (typeof r == "string" && i !== r) {
30
+ console.log(" useSyncRouter.tsx ~ location2:", i, r);
31
+ const m = t && r.startsWith(t) ? r.substring(t.length) : r;
32
32
  n(m);
33
33
  }
34
34
  }
35
35
  };
36
36
  window.MicrofeBridge = e;
37
- }, [n, t]), i(() => {
38
- var r, a;
37
+ }, [n, s]), a(() => {
38
+ var r, i;
39
39
  const e = o();
40
- console.log("fullPath1", window.location.pathname, e), (a = (r = window.parent) == null ? void 0 : r.HostBridge) == null || a.childRouteChange(e);
41
- }, [t]), window.self === window.top) {
40
+ console.log("fullPath1", window.location.pathname, e), (i = (r = window.parent) == null ? void 0 : r.HostBridge) == null || i.childRouteChange(e);
41
+ }, [s]), window.self === window.top) {
42
42
  console.log("useSyncRouter: Navigate to /app path"), window.location.href = window.location.href.replace(
43
43
  window.origin,
44
44
  `${window.origin}/app`
45
45
  );
46
46
  return;
47
47
  }
48
- }, l = (s) => (n, t) => {
49
- const o = P(s);
50
- return t ? n.every(
48
+ };
49
+ function C({
50
+ open: t,
51
+ disabled: n
52
+ }) {
53
+ f(() => {
54
+ var s, o, e, r;
55
+ n || (t ? (o = (s = window.top) == null ? void 0 : s.HostBridge) == null || o.openBackdrop(!0) : (r = (e = window.top) == null ? void 0 : e.HostBridge) == null || r.openBackdrop(!1));
56
+ }, [t, n]);
57
+ }
58
+ const l = (t) => (n, s) => {
59
+ const o = P(t);
60
+ return s ? n.every(
51
61
  (e) => o == null ? void 0 : o.includes(e)
52
62
  ) : n.some(
53
63
  (e) => o == null ? void 0 : o.includes(e)
54
64
  );
55
- }, C = ({
56
- baseUrl: s,
65
+ }, A = ({
66
+ baseUrl: t,
57
67
  accessWith: n,
58
- requireAll: t,
68
+ requireAll: s,
59
69
  children: o
60
- }) => l(s)(n, t) ? /* @__PURE__ */ u(c, { children: o }) : null, A = ({
61
- accessWith: s,
70
+ }) => l(t)(n, s) ? /* @__PURE__ */ u(c, { children: o }) : null, E = ({
71
+ accessWith: t,
62
72
  requireAll: n,
63
- baseUrl: t,
73
+ baseUrl: s,
64
74
  unAuthorizedPath: o,
65
75
  children: e
66
- }) => l(t)(s, n) ? /* @__PURE__ */ u(c, { children: e }) : /* @__PURE__ */ u(w, { to: o, replace: !0 });
76
+ }) => l(s)(t, n) ? /* @__PURE__ */ u(c, { children: e }) : /* @__PURE__ */ u(p, { to: o, replace: !0 });
67
77
  export {
68
- M as AuthContext,
78
+ F as AuthContext,
69
79
  N as AuthProvider,
70
- B as ERROR_MESSAGE,
71
- C as HasPermission,
72
- A as PermissionRoute,
80
+ k as ERROR_MESSAGE,
81
+ A as HasPermission,
82
+ E as PermissionRoute,
73
83
  G as SaasThemeProvider,
74
- H as TranslationProvider,
75
- $ as axiosInstance,
76
- I as color,
77
- O as createCustomTheme,
84
+ $ as TranslationProvider,
85
+ I as axiosInstance,
86
+ O as color,
87
+ j as createCustomTheme,
78
88
  l as getUseHasPermission,
79
- j as handleErrorAxios,
80
- z as login,
81
- L as logout,
82
- U as responseInterceptor,
83
- V as search,
84
- W as setFavicon,
85
- X as translate,
86
- Y as translationConfig,
87
- Z as useAuth,
88
- _ as useCustomTranslation,
89
+ z as handleErrorAxios,
90
+ L as login,
91
+ U as logout,
92
+ V as responseInterceptor,
93
+ W as search,
94
+ X as setFavicon,
95
+ Y as translate,
96
+ Z as translationConfig,
97
+ _ as useAuth,
98
+ q as useCustomTranslation,
89
99
  P as useGetPermission,
100
+ C as useSyncBackdrop,
90
101
  T as useSyncRouter,
91
- k as useTheme,
92
- q as useTranslation
102
+ D as useTheme,
103
+ J as useTranslation
93
104
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.13.1-dev.8",
4
+ "version": "0.13.1-dev.9",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",