@ukpc-lib/react 0.13.1-dev.2 → 0.13.1-dev.3

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 r=require("../index.esm2017-D_jfQoO6.cjs"),h=require("axios"),a=require("react"),u=require("react-router-dom"),i=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");const l=o=>{const[s,t]=a.useState([]);return a.useEffect(()=>{h.get(`${o}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(e=>t(e.data)).catch(e=>{console.error("Getting user permission error:",e)})},[o]),s},m=()=>{const o=u.useNavigate(),s=u.useLocation();if(a.useEffect(()=>{const t={changeRoute:e=>{typeof e=="string"&&s.pathname+s.search+s.hash!==e&&o(e)}};window.MicrofeBridge=t},[o,s]),a.useEffect(()=>{var e,n;const t=s.pathname+s.search+s.hash;(n=(e=window.parent)==null?void 0:e.HostBridge)==null||n.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}},c=o=>(s,t)=>{const e=l(o);return t?s.every(n=>e==null?void 0:e.includes(n)):s.some(n=>e==null?void 0:e.includes(n))},g=({baseUrl:o,accessWith:s,requireAll:t,children:e})=>c(o)(s,t)?i.jsx(i.Fragment,{children:e}):null,d=({accessWith:o,requireAll:s,baseUrl:t,unAuthorizedPath:e,children:n})=>c(t)(o,s)?i.jsx(i.Fragment,{children:n}):i.jsx(u.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.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=g;exports.PermissionRoute=d;exports.getUseHasPermission=c;exports.useGetPermission=l;exports.useSyncRouter=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../index.esm2017-_6AWldhb.cjs"),h=require("axios"),a=require("react"),u=require("react-router-dom"),i=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");const l=s=>{const[r,t]=a.useState([]);return a.useEffect(()=>{h.get(`${s}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(e=>t(e.data)).catch(e=>{console.error("Getting user permission error:",e)})},[s]),r},m=()=>{const s=u.useNavigate(),r=u.useLocation();if(a.useEffect(()=>{const t={changeRoute:e=>{typeof e=="string"&&window.location.pathname+r.search+r.hash!==e&&s(e)}};window.MicrofeBridge=t},[s,r]),a.useEffect(()=>{var e,n;const t=window.location.pathname+r.search+r.hash;(n=(e=window.parent)==null?void 0:e.HostBridge)==null||n.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}},c=s=>(r,t)=>{const e=l(s);return t?r.every(n=>e==null?void 0:e.includes(n)):r.some(n=>e==null?void 0:e.includes(n))},d=({baseUrl:s,accessWith:r,requireAll:t,children:e})=>c(s)(r,t)?i.jsx(i.Fragment,{children:e}):null,g=({accessWith:s,requireAll:r,baseUrl:t,unAuthorizedPath:e,children:n})=>c(t)(s,r)?i.jsx(i.Fragment,{children:n}):i.jsx(u.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=d;exports.PermissionRoute=g;exports.getUseHasPermission=c;exports.useGetPermission=l;exports.useSyncRouter=m;
@@ -1,58 +1,58 @@
1
- import { M as E, N as M, O as N, a0 as B, Y as G, a as H, c as $, Z as F, U as I, R as O, T as j, V as L, v as U, $ as V, t as X, W as Y, b as Z, u as _, g as b, X as k } from "../index.esm2017-gn4YavpL.js";
2
- import c from "axios";
1
+ import { M as E, N as M, O as N, a0 as B, Y as G, a as H, c as $, Z as F, U as I, R as O, T as j, V as L, v as U, $ as V, t as X, W as Y, b as Z, u as _, g as b, X as k } from "../index.esm2017-VcIv3oNf.js";
2
+ import u from "axios";
3
3
  import { useState as m, useEffect as n } from "react";
4
- import { useNavigate as h, useLocation as l, Navigate as g } from "react-router-dom";
4
+ import { useNavigate as h, useLocation as l, Navigate as d } from "react-router-dom";
5
5
  import { jsx as a, Fragment as i } from "react/jsx-runtime";
6
6
  import "@r2wc/react-to-web-component";
7
7
  import "@mui/material";
8
- const p = (o) => {
9
- const [s, t] = m([]);
8
+ const g = (s) => {
9
+ const [o, t] = m([]);
10
10
  return n(() => {
11
- c.get(`${o}/user-management/api/v1/users/my-account/permissions`, {
11
+ u.get(`${s}/user-management/api/v1/users/my-account/permissions`, {
12
12
  withCredentials: !0
13
13
  }).then((e) => t(e.data)).catch((e) => {
14
14
  console.error("Getting user permission error:", e);
15
15
  });
16
- }, [o]), s;
16
+ }, [s]), o;
17
17
  }, T = () => {
18
- const o = h(), s = l();
18
+ const s = h(), o = l();
19
19
  if (n(() => {
20
20
  const t = {
21
21
  changeRoute: (e) => {
22
- typeof e == "string" && s.pathname + s.search + s.hash !== e && o(e);
22
+ typeof e == "string" && window.location.pathname + o.search + o.hash !== e && s(e);
23
23
  }
24
24
  };
25
25
  window.MicrofeBridge = t;
26
- }, [o, s]), n(() => {
26
+ }, [s, o]), n(() => {
27
27
  var e, r;
28
- const t = s.pathname + s.search + s.hash;
28
+ const t = window.location.pathname + o.search + o.hash;
29
29
  (r = (e = window.parent) == null ? void 0 : e.HostBridge) == null || r.childRouteChange(t);
30
- }, [s]), window.self === window.top) {
30
+ }, [o]), window.self === window.top) {
31
31
  console.log("useSyncRouter: Navigate to /app path"), window.location.href = window.location.href.replace(
32
32
  window.origin,
33
33
  `${window.origin}/app`
34
34
  );
35
35
  return;
36
36
  }
37
- }, u = (o) => (s, t) => {
38
- const e = p(o);
39
- return t ? s.every(
37
+ }, c = (s) => (o, t) => {
38
+ const e = g(s);
39
+ return t ? o.every(
40
40
  (r) => e == null ? void 0 : e.includes(r)
41
- ) : s.some(
41
+ ) : o.some(
42
42
  (r) => e == null ? void 0 : e.includes(r)
43
43
  );
44
44
  }, C = ({
45
- baseUrl: o,
46
- accessWith: s,
45
+ baseUrl: s,
46
+ accessWith: o,
47
47
  requireAll: t,
48
48
  children: e
49
- }) => u(o)(s, t) ? /* @__PURE__ */ a(i, { children: e }) : null, S = ({
50
- accessWith: o,
51
- requireAll: s,
49
+ }) => c(s)(o, t) ? /* @__PURE__ */ a(i, { children: e }) : null, S = ({
50
+ accessWith: s,
51
+ requireAll: o,
52
52
  baseUrl: t,
53
53
  unAuthorizedPath: e,
54
54
  children: r
55
- }) => u(t)(o, s) ? /* @__PURE__ */ a(i, { children: r }) : /* @__PURE__ */ a(g, { to: e, replace: !0 });
55
+ }) => c(t)(s, o) ? /* @__PURE__ */ a(i, { children: r }) : /* @__PURE__ */ a(d, { to: e, replace: !0 });
56
56
  export {
57
57
  E as AuthContext,
58
58
  M as AuthProvider,
@@ -64,7 +64,7 @@ export {
64
64
  H as axiosInstance,
65
65
  $ as color,
66
66
  F as createCustomTheme,
67
- u as getUseHasPermission,
67
+ c as getUseHasPermission,
68
68
  I as handleErrorAxios,
69
69
  O as login,
70
70
  j as logout,
@@ -75,7 +75,7 @@ export {
75
75
  Y as translationConfig,
76
76
  Z as useAuth,
77
77
  _ as useCustomTranslation,
78
- p as useGetPermission,
78
+ g as useGetPermission,
79
79
  T as useSyncRouter,
80
80
  b as useTheme,
81
81
  k as useTranslation
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.2",
4
+ "version": "0.13.1-dev.3",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",