@ukpc-lib/react 0.16.11 → 0.16.12-sandbox.saas-10032.patch-2

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 e=require("../index.esm2017-JSbc-HDr.cjs"),m=require("axios"),u=require("react"),d=require("react-router-dom"),a=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");require("react-query");require("react-dom");require("moment");const h=s=>{const[t,r]=u.useState([]);return u.useEffect(()=>{m.get(`${s}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(o=>r(o.data)).catch(o=>{console.error("Getting user permission error:",o)})},[s]),t},p=s=>{const t=d.useLocation();if(u.useEffect(()=>{var o,i;let r=t.pathname+t.search+t.hash;s&&!r.includes(s)&&(r=s+r),console.log("🚀 ~ PrivateLayout.tsx ~ fullPath:",r),(i=(o=window.top)==null?void 0:o.shellNavigate)==null||i.call(o,"/app"+r,{replace:!0})},[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}};function g({open:s,disabled:t}){u.useMemo(()=>{var r,o,i,n;t||(s?(o=(r=window.top)==null?void 0:r.HostBridge)==null||o.openBackdrop(!0):(n=(i=window.top)==null?void 0:i.HostBridge)==null||n.openBackdrop(!1))},[s,t])}const l=(s,t)=>(r,o)=>{const n=e.useUserPermissions({axiosInstance:t,baseUrl:s}).data;return n?o?r.every(c=>n==null?void 0:n.includes(c)):r.some(c=>n==null?void 0:n.includes(c)):!1},f=({baseUrl:s,accessWith:t,requireAll:r,children:o})=>l(s)(t,r)?a.jsx(a.Fragment,{children:o}):null,P=({accessWith:s,requireAll:t,baseUrl:r,children:o})=>l(r)(s,t)?a.jsx(a.Fragment,{children:o}):a.jsx(e.UnauthorizedPage,{});exports.AuthContext=e.AuthContext;exports.AuthProvider=e.AuthProvider;exports.ERROR_MESSAGE=e.ERROR_MESSAGE;exports.SaasThemeProvider=e.SaasThemeProvider;exports.TranslationProvider=e.TranslationProvider;exports.X_AUTO_CANCEL=e.X_AUTO_CANCEL;exports.axiosInstance=e.axiosInstance;exports.color=e.color;exports.createCustomTheme=e.createCustomTheme;exports.handleErrorAxios=e.handleErrorAxios;exports.isCanceledError=e.isCanceledError;exports.login=e.login;exports.logout=e.logout;exports.requestInterceptor=e.requestInterceptor;exports.responseInterceptor=e.responseInterceptor;exports.search=e.search;exports.setFavicon=e.setFavicon;exports.setShellBackdrop=e.setShellBackdrop;exports.translate=e.translate;exports.translationConfig=e.translationConfig;exports.useAuth=e.useAuth;exports.useCustomTranslation=e.useCustomTranslation;exports.useTheme=e.useTheme;exports.useTranslation=e.useTranslation;exports.HasPermission=f;exports.PermissionRoute=P;exports.getUseHasPermission=l;exports.useGetPermission=h;exports.useSyncBackdrop=g;exports.useSyncRouter=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.esm2017-Cgo-QAUs.cjs"),m=require("axios"),u=require("react"),d=require("react-router-dom"),a=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");require("react-query");require("react-dom");require("moment");const h=s=>{const[t,r]=u.useState([]);return u.useEffect(()=>{m.get(`${s}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(o=>r(o.data)).catch(o=>{console.error("Getting user permission error:",o)})},[s]),t},p=s=>{const t=d.useLocation();if(u.useEffect(()=>{var o,i;let r=t.pathname+t.search+t.hash;s&&!r.includes(s)&&(r=s+r),console.log("🚀 ~ PrivateLayout.tsx ~ fullPath:",r),(i=(o=window.top)==null?void 0:o.shellNavigate)==null||i.call(o,"/app"+r,{replace:!0})},[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}};function g({open:s,disabled:t}){u.useMemo(()=>{var r,o,i,n;t||(s?(o=(r=window.top)==null?void 0:r.HostBridge)==null||o.openBackdrop(!0):(n=(i=window.top)==null?void 0:i.HostBridge)==null||n.openBackdrop(!1))},[s,t])}const l=(s,t)=>(r,o)=>{const n=e.useUserPermissions({axiosInstance:t,baseUrl:s}).data;return n?o?r.every(c=>n==null?void 0:n.includes(c)):r.some(c=>n==null?void 0:n.includes(c)):!1},f=({baseUrl:s,accessWith:t,requireAll:r,children:o})=>l(s)(t,r)?a.jsx(a.Fragment,{children:o}):null,P=({accessWith:s,requireAll:t,baseUrl:r,children:o})=>l(r)(s,t)?a.jsx(a.Fragment,{children:o}):a.jsx(e.UnauthorizedPage,{});exports.AuthContext=e.AuthContext;exports.AuthProvider=e.AuthProvider;exports.ERROR_MESSAGE=e.ERROR_MESSAGE;exports.SaasThemeProvider=e.SaasThemeProvider;exports.TranslationProvider=e.TranslationProvider;exports.X_AUTO_CANCEL=e.X_AUTO_CANCEL;exports.axiosInstance=e.axiosInstance;exports.color=e.color;exports.createCustomTheme=e.createCustomTheme;exports.handleErrorAxios=e.handleErrorAxios;exports.isCanceledError=e.isCanceledError;exports.login=e.login;exports.logout=e.logout;exports.requestInterceptor=e.requestInterceptor;exports.responseInterceptor=e.responseInterceptor;exports.search=e.search;exports.setFavicon=e.setFavicon;exports.setShellBackdrop=e.setShellBackdrop;exports.translate=e.translate;exports.translationConfig=e.translationConfig;exports.useAuth=e.useAuth;exports.useCustomTranslation=e.useCustomTranslation;exports.useTheme=e.useTheme;exports.useTranslation=e.useTranslation;exports.HasPermission=f;exports.PermissionRoute=P;exports.getUseHasPermission=l;exports.useGetPermission=h;exports.useSyncBackdrop=g;exports.useSyncRouter=p;
@@ -1,5 +1,5 @@
1
- import { K as p, U as l } from "../index.esm2017-LFf2ragx.js";
2
- import { M as L, O as M, R as N, a5 as O, a2 as _, X as $, a as D, c as F, a3 as X, W as j, Y as q, T as z, V as K, $ as V, Z as Y, r as Z, a4 as J, s as Q, t as W, a0 as b, e as ee, u as se, i as oe, a1 as re } from "../index.esm2017-LFf2ragx.js";
1
+ import { K as p, U as l } from "../index.esm2017-DImxTb9q.js";
2
+ import { M as L, O as M, R as N, a5 as O, a2 as _, X as $, a as D, c as F, a3 as X, W as j, Y as q, T as z, V as K, $ as V, Z as Y, r as Z, a4 as J, s as Q, t as W, a0 as b, e as ee, u as se, i as oe, a1 as re } from "../index.esm2017-DImxTb9q.js";
3
3
  import d from "axios";
4
4
  import { useState as f, useEffect as u, useMemo as h } from "react";
5
5
  import { useLocation as w } from "react-router-dom";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.16.11",
4
+ "version": "0.16.12-sandbox.saas-10032.patch-2",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { F, u as v } from "../index-DCG0bvL_.js";
2
+ import { F, u as v } from "../index-R85_H1AH.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-BBl8HzU3.js";
5
5
  import "../react-toastify.esm-H_Xdunfj.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { G as e } from "../index-DCG0bvL_.js";
2
+ import { G as e } from "../index-R85_H1AH.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-BBl8HzU3.js";
5
5
  import "../SaasThemeProvider-DUpoV8xb.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { L as s, T as L } from "../index-DCG0bvL_.js";
2
+ import { L as s, T as L } from "../index-R85_H1AH.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-Ch-015PG.js";
5
5
  import "../index-BBl8HzU3.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { H as o, g as r } from "../index-DCG0bvL_.js";
2
+ import { H as o, g as r } from "../index-R85_H1AH.js";
3
3
  export {
4
4
  o as HasPermission,
5
5
  r as getUseHasPermission
@@ -1965,22 +1965,22 @@ tn.getAdapter = Vk.getAdapter;
1965
1965
  tn.HttpStatusCode = Sy;
1966
1966
  tn.default = tn;
1967
1967
  const {
1968
- Axios: sfe,
1969
- AxiosError: ofe,
1970
- CanceledError: afe,
1971
- isCancel: lfe,
1972
- CancelToken: ufe,
1973
- VERSION: cfe,
1974
- all: ffe,
1975
- Cancel: dfe,
1976
- isAxiosError: hfe,
1977
- spread: pfe,
1978
- toFormData: mfe,
1979
- AxiosHeaders: gfe,
1980
- HttpStatusCode: vfe,
1981
- formToJSON: yfe,
1982
- getAdapter: bfe,
1983
- mergeConfig: xfe
1968
+ Axios: ofe,
1969
+ AxiosError: afe,
1970
+ CanceledError: lfe,
1971
+ isCancel: ufe,
1972
+ CancelToken: cfe,
1973
+ VERSION: ffe,
1974
+ all: dfe,
1975
+ Cancel: hfe,
1976
+ isAxiosError: pfe,
1977
+ spread: mfe,
1978
+ toFormData: gfe,
1979
+ AxiosHeaders: vfe,
1980
+ HttpStatusCode: yfe,
1981
+ formToJSON: bfe,
1982
+ getAdapter: xfe,
1983
+ mergeConfig: wfe
1984
1984
  } = tn;
1985
1985
  var If = /* @__PURE__ */ function() {
1986
1986
  function e() {
@@ -12260,7 +12260,7 @@ function o8({
12260
12260
  }
12261
12261
  ) }) });
12262
12262
  }
12263
- function wfe(e) {
12263
+ function Sfe(e) {
12264
12264
  const { user: t, logout: n, isFetching: r } = mU();
12265
12265
  return /* @__PURE__ */ L.jsx(
12266
12266
  DP,
@@ -40397,7 +40397,41 @@ function Wce(e) {
40397
40397
  });
40398
40398
  window.dispatchEvent(t);
40399
40399
  }
40400
- function Hce(e) {
40400
+ function Hce(e, t) {
40401
+ const n = (p) => p.parent === 0, r = (p) => {
40402
+ var y;
40403
+ return ((y = p.data) == null ? void 0 : y.name) === "Home";
40404
+ }, i = e.find((p) => n(p) && r(p)), s = e.filter(
40405
+ (p) => n(p) && !r(p)
40406
+ ), o = e.filter((p) => !n(p)), l = t.filter((p) => n(p) && !r(p)).map((p) => p.id), c = new Map(l.map((p, y) => [p, y]));
40407
+ if (l.length === 0)
40408
+ return [
40409
+ ...i ? [i] : [],
40410
+ ...s,
40411
+ ...o
40412
+ ];
40413
+ const d = s.filter(
40414
+ (p) => !c.has(p.id)
40415
+ ), h = s.filter(
40416
+ (p) => c.has(p.id)
40417
+ );
40418
+ return d.sort(
40419
+ (p, y) => {
40420
+ var b, C;
40421
+ return (((b = p.data) == null ? void 0 : b.name) || "").localeCompare(((C = y.data) == null ? void 0 : C.name) || "", void 0, {
40422
+ sensitivity: "base"
40423
+ });
40424
+ }
40425
+ ), h.sort(
40426
+ (p, y) => (c.get(p.id) || 0) - (c.get(y.id) || 0)
40427
+ ), [
40428
+ ...i ? [i] : [],
40429
+ ...d,
40430
+ ...h,
40431
+ ...o
40432
+ ];
40433
+ }
40434
+ function Uce(e) {
40401
40435
  const t = fk(), [n, r] = A.useState([]), i = n.map((re) => re.data), [s, o] = A.useState(!1), [l, c] = A.useState([]), [d, h] = A.useState(
40402
40436
  Jh === null ? !0 : Jh === "true"
40403
40437
  ), [p, y] = A.useState(window.location.href), b = A.useRef(null);
@@ -40437,7 +40471,7 @@ function Hce(e) {
40437
40471
  text: _e.name,
40438
40472
  data: _e
40439
40473
  }));
40440
- r($e);
40474
+ r((_e) => Hce($e, _e));
40441
40475
  } catch (ie) {
40442
40476
  console.error("Global menu", ie), Bf(
40443
40477
  ((J = (se = ie.response) == null ? void 0 : se.data) == null ? void 0 : J.errorMessage) || ie.message || qt("components.menu.pushError.menuError", { defaultValue: "Have error when set favorite menu item" })
@@ -40828,14 +40862,14 @@ const QD = {
40828
40862
  "/anpr/page/Issues/Index?status=Closed": ["/anpr/page/Issues"],
40829
40863
  "/anpr/page/Issues/Index": ["/anpr/page/Issues"]
40830
40864
  };
40831
- function Uce(e, t) {
40865
+ function zce(e, t) {
40832
40866
  const r = e.replace(window.origin, "").replace("/app", ""), i = new URL(r, window.location.origin), s = new URL(t.replace("/app", ""), window.origin), o = (localStorage.getItem("latestClickMenuPath") || "").replace("/app", "");
40833
40867
  return r && QD[r] && QD[r].some((l) => t.replace("/app", "").includes(l)) ? o === r ? 5 : 4 : i.pathname === s.pathname && i.search === s.search ? 3 : i.pathname === s.pathname ? 2 : s.pathname.startsWith(i.pathname) ? 1 : 0;
40834
40868
  }
40835
40869
  function ZD(e, t) {
40836
40870
  const n = e.map((o) => ({
40837
40871
  item: o,
40838
- priority: o.path ? Uce(o.path, t) : 0
40872
+ priority: o.path ? zce(o.path, t) : 0
40839
40873
  })).filter((o) => o.priority > 0);
40840
40874
  console.log(" index.tsx ~ matchedItems:", n);
40841
40875
  const r = n.length > 0 ? n.reduce(
@@ -40858,7 +40892,7 @@ function lN(e) {
40858
40892
  path: window.location.origin + "/app" + n.path
40859
40893
  } : (n.children && (n.children = lN(n.children)), n));
40860
40894
  }
40861
- function zce(e) {
40895
+ function Yce(e) {
40862
40896
  return (
40863
40897
  // <ShadowDOM.div>
40864
40898
  /* @__PURE__ */ L.jsx(
@@ -40871,17 +40905,17 @@ function zce(e) {
40871
40905
  position: "relative"
40872
40906
  },
40873
40907
  className: "backdrop-delay-transition",
40874
- children: /* @__PURE__ */ L.jsx(Hce, { ...e })
40908
+ children: /* @__PURE__ */ L.jsx(Uce, { ...e })
40875
40909
  }
40876
40910
  )
40877
40911
  );
40878
40912
  }
40879
- function Yce(e) {
40913
+ function qce(e) {
40880
40914
  const t = { ...Dn, ...e.brandColors };
40881
- return console.log("props.brandColors", t), /* @__PURE__ */ L.jsx(ck, { children: /* @__PURE__ */ L.jsx(z5, { theme: MU({ colors: t }), children: /* @__PURE__ */ L.jsx(zce, { ...e, ssr: !0 }) }) });
40915
+ return console.log("props.brandColors", t), /* @__PURE__ */ L.jsx(ck, { children: /* @__PURE__ */ L.jsx(z5, { theme: MU({ colors: t }), children: /* @__PURE__ */ L.jsx(Yce, { ...e, ssr: !0 }) }) });
40882
40916
  }
40883
40917
  {
40884
- const e = Yp(Yce, {
40918
+ const e = Yp(qce, {
40885
40919
  props: {
40886
40920
  baseUrl: "string",
40887
40921
  menuPath: "string",
@@ -40899,10 +40933,10 @@ function Yce(e) {
40899
40933
  }
40900
40934
  export {
40901
40935
  Ete as F,
40902
- zce as G,
40936
+ Yce as G,
40903
40937
  vU as H,
40904
40938
  s8 as L,
40905
- wfe as T,
40939
+ Sfe as T,
40906
40940
  gU as g,
40907
40941
  DI as u
40908
40942
  };