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