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

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-KfDAWE5S.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-CGsdCZDL.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-CGsdCZDL.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-1",
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-jpNYweHN.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-jpNYweHN.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-jpNYweHN.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-jpNYweHN.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,34 @@ 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])), d = s.filter(
40407
+ (p) => !c.has(p.id)
40408
+ ), h = s.filter(
40409
+ (p) => c.has(p.id)
40410
+ );
40411
+ return d.sort(
40412
+ (p, y) => {
40413
+ var b, C;
40414
+ return (((b = p.data) == null ? void 0 : b.name) || "").localeCompare(((C = y.data) == null ? void 0 : C.name) || "", void 0, {
40415
+ sensitivity: "base"
40416
+ });
40417
+ }
40418
+ ), h.sort(
40419
+ (p, y) => (c.get(p.id) || 0) - (c.get(y.id) || 0)
40420
+ ), [
40421
+ ...i ? [i] : [],
40422
+ ...d,
40423
+ ...h,
40424
+ ...o
40425
+ ];
40426
+ }
40427
+ function Uce(e) {
40401
40428
  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
40429
  Jh === null ? !0 : Jh === "true"
40403
40430
  ), [p, y] = A.useState(window.location.href), b = A.useRef(null);
@@ -40437,7 +40464,7 @@ function Hce(e) {
40437
40464
  text: _e.name,
40438
40465
  data: _e
40439
40466
  }));
40440
- r($e);
40467
+ r((_e) => Hce($e, _e));
40441
40468
  } catch (ie) {
40442
40469
  console.error("Global menu", ie), Bf(
40443
40470
  ((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 +40855,14 @@ const QD = {
40828
40855
  "/anpr/page/Issues/Index?status=Closed": ["/anpr/page/Issues"],
40829
40856
  "/anpr/page/Issues/Index": ["/anpr/page/Issues"]
40830
40857
  };
40831
- function Uce(e, t) {
40858
+ function zce(e, t) {
40832
40859
  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
40860
  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
40861
  }
40835
40862
  function ZD(e, t) {
40836
40863
  const n = e.map((o) => ({
40837
40864
  item: o,
40838
- priority: o.path ? Uce(o.path, t) : 0
40865
+ priority: o.path ? zce(o.path, t) : 0
40839
40866
  })).filter((o) => o.priority > 0);
40840
40867
  console.log(" index.tsx ~ matchedItems:", n);
40841
40868
  const r = n.length > 0 ? n.reduce(
@@ -40858,7 +40885,7 @@ function lN(e) {
40858
40885
  path: window.location.origin + "/app" + n.path
40859
40886
  } : (n.children && (n.children = lN(n.children)), n));
40860
40887
  }
40861
- function zce(e) {
40888
+ function Yce(e) {
40862
40889
  return (
40863
40890
  // <ShadowDOM.div>
40864
40891
  /* @__PURE__ */ L.jsx(
@@ -40871,17 +40898,17 @@ function zce(e) {
40871
40898
  position: "relative"
40872
40899
  },
40873
40900
  className: "backdrop-delay-transition",
40874
- children: /* @__PURE__ */ L.jsx(Hce, { ...e })
40901
+ children: /* @__PURE__ */ L.jsx(Uce, { ...e })
40875
40902
  }
40876
40903
  )
40877
40904
  );
40878
40905
  }
40879
- function Yce(e) {
40906
+ function qce(e) {
40880
40907
  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 }) }) });
40908
+ 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
40909
  }
40883
40910
  {
40884
- const e = Yp(Yce, {
40911
+ const e = Yp(qce, {
40885
40912
  props: {
40886
40913
  baseUrl: "string",
40887
40914
  menuPath: "string",
@@ -40899,10 +40926,10 @@ function Yce(e) {
40899
40926
  }
40900
40927
  export {
40901
40928
  Ete as F,
40902
- zce as G,
40929
+ Yce as G,
40903
40930
  vU as H,
40904
40931
  s8 as L,
40905
- wfe as T,
40932
+ Sfe as T,
40906
40933
  gU as g,
40907
40934
  DI as u
40908
40935
  };