@ukpc-lib/react 0.16.3-dev.21 → 0.16.3-dev.24

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-DjebFQF3.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.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.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 o=require("../index.esm2017-Dd_pRw5E.cjs"),R=require("axios"),y=require("react"),U=require("react-router-dom"),g=require("react/jsx-runtime");require("@r2wc/react-to-web-component");require("@mui/material");require("react-query");require("react-dom");require("moment");const D=r=>{const[t,e]=y.useState([]);return y.useEffect(()=>{R.get(`${r}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(i=>e(i.data)).catch(i=>{console.error("Getting user permission error:",i)})},[r]),t},H=r=>{const t=U.useLocation();if(y.useEffect(()=>{var i,c;let e=t.pathname+t.search+t.hash;r&&!e.includes(r)&&(e=r+e),console.log("🚀 ~ PrivateLayout.tsx ~ fullPath:",e),(c=(i=window.top)==null?void 0:i.shellNavigate)==null||c.call(i,"/app"+e,{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 $({open:r,disabled:t}){y.useMemo(()=>{var e,i,c,u;t||(r?(i=(e=window.top)==null?void 0:e.HostBridge)==null||i.openBackdrop(!0):(u=(c=window.top)==null?void 0:c.HostBridge)==null||u.openBackdrop(!1))},[r,t])}const k=(r,t)=>(e,i)=>{const u=o.useUserPermissions({axiosInstance:t,baseUrl:r}).data;return u?i?e.every(f=>u==null?void 0:u.includes(f)):e.some(f=>u==null?void 0:u.includes(f)):!1},M=({baseUrl:r,accessWith:t,requireAll:e,children:i})=>k(r)(t,e)?g.jsx(g.Fragment,{children:i}):null,q=({accessWith:r,requireAll:t,baseUrl:e,children:i})=>k(e)(r,t)?g.jsx(g.Fragment,{children:i}):g.jsx(o.UnauthorizedPage,{});var p={},I;function z(){if(I)return p;I=1,Object.defineProperty(p,"__esModule",{value:!0}),p.parse=f,p.serialize=_;const r=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,e=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/,c=Object.prototype.toString,u=(()=>{const s=function(){};return s.prototype=Object.create(null),s})();function f(s,l){const n=new u,h=s.length;if(h<2)return n;const w=(l==null?void 0:l.decode)||b;let a=0;do{const d=s.indexOf("=",a);if(d===-1)break;const E=s.indexOf(";",a),S=E===-1?h:E;if(d>S){a=s.lastIndexOf(";",d-1)+1;continue}const v=m(s,a,d),j=x(s,d,v),T=s.slice(v,j);if(n[T]===void 0){let P=m(s,d+1,S),L=x(s,S,P);const N=w(s.slice(P,L));n[T]=N}a=S+1}while(a<h);return n}function m(s,l,n){do{const h=s.charCodeAt(l);if(h!==32&&h!==9)return l}while(++l<n);return n}function x(s,l,n){for(;l>n;){const h=s.charCodeAt(--l);if(h!==32&&h!==9)return l+1}return n}function _(s,l,n){const h=(n==null?void 0:n.encode)||encodeURIComponent;if(!r.test(s))throw new TypeError(`argument name is invalid: ${s}`);const w=h(l);if(!t.test(w))throw new TypeError(`argument val is invalid: ${l}`);let a=s+"="+w;if(!n)return a;if(n.maxAge!==void 0){if(!Number.isInteger(n.maxAge))throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);a+="; Max-Age="+n.maxAge}if(n.domain){if(!e.test(n.domain))throw new TypeError(`option domain is invalid: ${n.domain}`);a+="; Domain="+n.domain}if(n.path){if(!i.test(n.path))throw new TypeError(`option path is invalid: ${n.path}`);a+="; Path="+n.path}if(n.expires){if(!A(n.expires)||!Number.isFinite(n.expires.valueOf()))throw new TypeError(`option expires is invalid: ${n.expires}`);a+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(a+="; HttpOnly"),n.secure&&(a+="; Secure"),n.partitioned&&(a+="; Partitioned"),n.priority)switch(typeof n.priority=="string"?n.priority.toLowerCase():void 0){case"low":a+="; Priority=Low";break;case"medium":a+="; Priority=Medium";break;case"high":a+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${n.priority}`)}if(n.sameSite)switch(typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"none":a+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${n.sameSite}`)}return a}function b(s){if(s.indexOf("%")===-1)return s;try{return decodeURIComponent(s)}catch{return s}}function A(s){return c.call(s)==="[object Date]"}return p}var O=z();function B(){const r=typeof global>"u"?void 0:global.TEST_HAS_DOCUMENT_COOKIE;return typeof r=="boolean"?r:typeof document=="object"&&typeof document.cookie=="string"}function K(r){return typeof r=="string"?O.parse(r):typeof r=="object"&&r!==null?r:{}}function C(r,t={}){const e=V(r);if(!t.doNotParse)try{return JSON.parse(e)}catch{}return r}function V(r){return r&&r[0]==="j"&&r[1]===":"?r.substr(2):r}class F{constructor(t,e={}){this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.update=()=>{if(!this.HAS_DOCUMENT_COOKIE)return;const c=this.cookies;this.cookies=O.parse(document.cookie),this._checkChanges(c)};const i=typeof document>"u"?"":document.cookie;this.cookies=K(t||i),this.defaultSetOptions=e,this.HAS_DOCUMENT_COOKIE=B()}_emitChange(t){for(let e=0;e<this.changeListeners.length;++e)this.changeListeners[e](t)}_checkChanges(t){new Set(Object.keys(t).concat(Object.keys(this.cookies))).forEach(i=>{t[i]!==this.cookies[i]&&this._emitChange({name:i,value:C(this.cookies[i])})})}_startPolling(){this.pollingInterval=setInterval(this.update,300)}_stopPolling(){this.pollingInterval&&clearInterval(this.pollingInterval)}get(t,e={}){return e.doNotUpdate||this.update(),C(this.cookies[t],e)}getAll(t={}){t.doNotUpdate||this.update();const e={};for(let i in this.cookies)e[i]=C(this.cookies[i],t);return e}set(t,e,i){i?i=Object.assign(Object.assign({},this.defaultSetOptions),i):i=this.defaultSetOptions;const c=typeof e=="string"?e:JSON.stringify(e);this.cookies=Object.assign(Object.assign({},this.cookies),{[t]:c}),this.HAS_DOCUMENT_COOKIE&&(document.cookie=O.serialize(t,c,i)),this._emitChange({name:t,value:e,options:i})}remove(t,e){const i=e=Object.assign(Object.assign(Object.assign({},this.defaultSetOptions),e),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[t],this.HAS_DOCUMENT_COOKIE&&(document.cookie=O.serialize(t,"",i)),this._emitChange({name:t,value:void 0,options:e})}addChangeListener(t){this.changeListeners.push(t),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===1&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.addEventListener("change",this.update):this._startPolling())}removeChangeListener(t){const e=this.changeListeners.indexOf(t);e>=0&&this.changeListeners.splice(e,1),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===0&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.removeEventListener("change",this.update):this._stopPolling())}removeAllChangeListeners(){for(;this.changeListeners.length>0;)this.removeChangeListener(this.changeListeners[0])}}const G=r=>{const t=new F;let i=new URLSearchParams(window.location.search).get("tenantId")||t.get("tenantId");const c=t.get("accessToken")||null;if(console.log("ThemeProvider1:tenantId",i),!i&&c){const f=atob(c.split(".")[1]),m=JSON.parse(f);i=m.tenantId?m.tenantId.toString():null}console.log("ThemeProvider2:tenantId",i);const u=r.isBrand||i!=null?r.viteThemeUrl:"";return console.log("themeUrl",u),g.jsx(o.SaasThemeProvider,{brandTheme:{enabled:!!u,url:u},children:r.children})};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;exports.HasPermission=M;exports.PermissionRoute=q;exports.ThemeProvider=G;exports.getUseHasPermission=k;exports.useGetPermission=D;exports.useSyncBackdrop=$;exports.useSyncRouter=H;
@@ -1,30 +1,30 @@
1
- import { K as p, U as l } from "../index.esm2017-CChlMOC9.js";
2
- import { M as $, O as D, R as F, a2 as I, $ as L, a as N, c as O, a0 as j, W as z, T as K, V, X, r as Y, a1 as Z, s as _, t as q, Y as J, e as Q, u as W, i as b, Z as ee } from "../index.esm2017-CChlMOC9.js";
3
- import f from "axios";
4
- import { useState as d, useEffect as u, useMemo as h } from "react";
5
- import { useLocation as w } from "react-router-dom";
6
- import { jsx as i, Fragment as c } from "react/jsx-runtime";
1
+ import { K as U, U as D, M as R } from "../index.esm2017-Caitdg72.js";
2
+ import { O as he, R as de, T as fe, a0 as ge, a as me, c as pe, a1 as we, X as Oe, V as Se, W as ye, Y as ke, r as Ce, a2 as xe, s as Ee, t as ve, Z as Ie, e as Te, u as _e, i as be, $ as Pe } from "../index.esm2017-Caitdg72.js";
3
+ import $ from "axios";
4
+ import { useState as H, useEffect as I, useMemo as M } from "react";
5
+ import { useLocation as z } from "react-router-dom";
6
+ import { jsx as O, Fragment as T } from "react/jsx-runtime";
7
7
  import "@r2wc/react-to-web-component";
8
8
  import "@mui/material";
9
9
  import "react-query";
10
10
  import "react-dom";
11
11
  import "moment";
12
- const C = (s) => {
13
- const [r, e] = d([]);
14
- return u(() => {
15
- f.get(`${s}/user-management/api/v1/users/my-account/permissions`, {
12
+ const ne = (r) => {
13
+ const [t, e] = H([]);
14
+ return I(() => {
15
+ $.get(`${r}/user-management/api/v1/users/my-account/permissions`, {
16
16
  withCredentials: !0
17
- }).then((o) => e(o.data)).catch((o) => {
18
- console.error("Getting user permission error:", o);
17
+ }).then((i) => e(i.data)).catch((i) => {
18
+ console.error("Getting user permission error:", i);
19
19
  });
20
- }, [s]), r;
21
- }, E = (s) => {
22
- const r = w();
23
- if (u(() => {
24
- var o, a;
25
- let e = r.pathname + r.search + r.hash;
26
- s && !e.includes(s) && (e = s + e), console.log("🚀 ~ PrivateLayout.tsx ~ fullPath:", e), (a = (o = window.top) == null ? void 0 : o.shellNavigate) == null || a.call(o, "/app" + e, { replace: !0 });
27
- }, [r, s]), window.self === window.top) {
20
+ }, [r]), t;
21
+ }, re = (r) => {
22
+ const t = z();
23
+ if (I(() => {
24
+ var i, a;
25
+ let e = t.pathname + t.search + t.hash;
26
+ r && !e.includes(r) && (e = r + e), console.log("🚀 ~ PrivateLayout.tsx ~ fullPath:", e), (a = (i = window.top) == null ? void 0 : i.shellNavigate) == null || a.call(i, "/app" + e, { replace: !0 });
27
+ }, [t, r]), window.self === window.top) {
28
28
  console.log("useSyncRouter: Navigate to /app path"), window.location.href = window.location.href.replace(
29
29
  window.origin,
30
30
  `${window.origin}/app`
@@ -32,62 +32,287 @@ const C = (s) => {
32
32
  return;
33
33
  }
34
34
  };
35
- function k({
36
- open: s,
37
- disabled: r
35
+ function se({
36
+ open: r,
37
+ disabled: t
38
38
  }) {
39
- h(() => {
40
- var e, o, a, t;
41
- r || (s ? (o = (e = window.top) == null ? void 0 : e.HostBridge) == null || o.openBackdrop(!0) : (t = (a = window.top) == null ? void 0 : a.HostBridge) == null || t.openBackdrop(!1));
42
- }, [s, r]);
39
+ M(() => {
40
+ var e, i, a, c;
41
+ t || (r ? (i = (e = window.top) == null ? void 0 : e.HostBridge) == null || i.openBackdrop(!0) : (c = (a = window.top) == null ? void 0 : a.HostBridge) == null || c.openBackdrop(!1));
42
+ }, [r, t]);
43
43
  }
44
- const m = (s, r) => (e, o) => {
45
- const t = p({
46
- axiosInstance: r,
47
- baseUrl: s
44
+ const _ = (r, t) => (e, i) => {
45
+ const c = U({
46
+ axiosInstance: t,
47
+ baseUrl: r
48
48
  }).data;
49
- return t ? o ? e.every(
50
- (n) => t == null ? void 0 : t.includes(n)
49
+ return c ? i ? e.every(
50
+ (d) => c == null ? void 0 : c.includes(d)
51
51
  ) : e.some(
52
- (n) => t == null ? void 0 : t.includes(n)
52
+ (d) => c == null ? void 0 : c.includes(d)
53
53
  ) : !1;
54
- }, H = ({
55
- baseUrl: s,
56
- accessWith: r,
54
+ }, oe = ({
55
+ baseUrl: r,
56
+ accessWith: t,
57
57
  requireAll: e,
58
- children: o
59
- }) => m(s)(r, e) ? /* @__PURE__ */ i(c, { children: o }) : null, G = ({
60
- accessWith: s,
61
- requireAll: r,
58
+ children: i
59
+ }) => _(r)(t, e) ? /* @__PURE__ */ O(T, { children: i }) : null, ae = ({
60
+ accessWith: r,
61
+ requireAll: t,
62
62
  baseUrl: e,
63
- children: o
64
- }) => m(e)(s, r) ? /* @__PURE__ */ i(c, { children: o }) : /* @__PURE__ */ i(l, {});
63
+ children: i
64
+ }) => _(e)(r, t) ? /* @__PURE__ */ O(T, { children: i }) : /* @__PURE__ */ O(D, {});
65
+ var g = {}, v;
66
+ function K() {
67
+ if (v)
68
+ return g;
69
+ v = 1, Object.defineProperty(g, "__esModule", { value: !0 }), g.parse = d, g.serialize = b;
70
+ const r = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, t = /^[\u0021-\u003A\u003C-\u007E]*$/, e = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, i = /^[\u0020-\u003A\u003D-\u007E]*$/, a = Object.prototype.toString, c = /* @__PURE__ */ (() => {
71
+ const s = function() {
72
+ };
73
+ return s.prototype = /* @__PURE__ */ Object.create(null), s;
74
+ })();
75
+ function d(s, u) {
76
+ const n = new c(), l = s.length;
77
+ if (l < 2)
78
+ return n;
79
+ const m = (u == null ? void 0 : u.decode) || P;
80
+ let o = 0;
81
+ do {
82
+ const h = s.indexOf("=", o);
83
+ if (h === -1)
84
+ break;
85
+ const k = s.indexOf(";", o), p = k === -1 ? l : k;
86
+ if (h > p) {
87
+ o = s.lastIndexOf(";", h - 1) + 1;
88
+ continue;
89
+ }
90
+ const C = f(s, o, h), L = y(s, h, C), x = s.slice(C, L);
91
+ if (n[x] === void 0) {
92
+ let E = f(s, h + 1, p), j = y(s, p, E);
93
+ const N = m(s.slice(E, j));
94
+ n[x] = N;
95
+ }
96
+ o = p + 1;
97
+ } while (o < l);
98
+ return n;
99
+ }
100
+ function f(s, u, n) {
101
+ do {
102
+ const l = s.charCodeAt(u);
103
+ if (l !== 32 && l !== 9)
104
+ return u;
105
+ } while (++u < n);
106
+ return n;
107
+ }
108
+ function y(s, u, n) {
109
+ for (; u > n; ) {
110
+ const l = s.charCodeAt(--u);
111
+ if (l !== 32 && l !== 9)
112
+ return u + 1;
113
+ }
114
+ return n;
115
+ }
116
+ function b(s, u, n) {
117
+ const l = (n == null ? void 0 : n.encode) || encodeURIComponent;
118
+ if (!r.test(s))
119
+ throw new TypeError(`argument name is invalid: ${s}`);
120
+ const m = l(u);
121
+ if (!t.test(m))
122
+ throw new TypeError(`argument val is invalid: ${u}`);
123
+ let o = s + "=" + m;
124
+ if (!n)
125
+ return o;
126
+ if (n.maxAge !== void 0) {
127
+ if (!Number.isInteger(n.maxAge))
128
+ throw new TypeError(`option maxAge is invalid: ${n.maxAge}`);
129
+ o += "; Max-Age=" + n.maxAge;
130
+ }
131
+ if (n.domain) {
132
+ if (!e.test(n.domain))
133
+ throw new TypeError(`option domain is invalid: ${n.domain}`);
134
+ o += "; Domain=" + n.domain;
135
+ }
136
+ if (n.path) {
137
+ if (!i.test(n.path))
138
+ throw new TypeError(`option path is invalid: ${n.path}`);
139
+ o += "; Path=" + n.path;
140
+ }
141
+ if (n.expires) {
142
+ if (!A(n.expires) || !Number.isFinite(n.expires.valueOf()))
143
+ throw new TypeError(`option expires is invalid: ${n.expires}`);
144
+ o += "; Expires=" + n.expires.toUTCString();
145
+ }
146
+ if (n.httpOnly && (o += "; HttpOnly"), n.secure && (o += "; Secure"), n.partitioned && (o += "; Partitioned"), n.priority)
147
+ switch (typeof n.priority == "string" ? n.priority.toLowerCase() : void 0) {
148
+ case "low":
149
+ o += "; Priority=Low";
150
+ break;
151
+ case "medium":
152
+ o += "; Priority=Medium";
153
+ break;
154
+ case "high":
155
+ o += "; Priority=High";
156
+ break;
157
+ default:
158
+ throw new TypeError(`option priority is invalid: ${n.priority}`);
159
+ }
160
+ if (n.sameSite)
161
+ switch (typeof n.sameSite == "string" ? n.sameSite.toLowerCase() : n.sameSite) {
162
+ case !0:
163
+ case "strict":
164
+ o += "; SameSite=Strict";
165
+ break;
166
+ case "lax":
167
+ o += "; SameSite=Lax";
168
+ break;
169
+ case "none":
170
+ o += "; SameSite=None";
171
+ break;
172
+ default:
173
+ throw new TypeError(`option sameSite is invalid: ${n.sameSite}`);
174
+ }
175
+ return o;
176
+ }
177
+ function P(s) {
178
+ if (s.indexOf("%") === -1)
179
+ return s;
180
+ try {
181
+ return decodeURIComponent(s);
182
+ } catch {
183
+ return s;
184
+ }
185
+ }
186
+ function A(s) {
187
+ return a.call(s) === "[object Date]";
188
+ }
189
+ return g;
190
+ }
191
+ var w = K();
192
+ function V() {
193
+ const r = typeof global > "u" ? void 0 : global.TEST_HAS_DOCUMENT_COOKIE;
194
+ return typeof r == "boolean" ? r : typeof document == "object" && typeof document.cookie == "string";
195
+ }
196
+ function B(r) {
197
+ return typeof r == "string" ? w.parse(r) : typeof r == "object" && r !== null ? r : {};
198
+ }
199
+ function S(r, t = {}) {
200
+ const e = q(r);
201
+ if (!t.doNotParse)
202
+ try {
203
+ return JSON.parse(e);
204
+ } catch {
205
+ }
206
+ return r;
207
+ }
208
+ function q(r) {
209
+ return r && r[0] === "j" && r[1] === ":" ? r.substr(2) : r;
210
+ }
211
+ class F {
212
+ constructor(t, e = {}) {
213
+ this.changeListeners = [], this.HAS_DOCUMENT_COOKIE = !1, this.update = () => {
214
+ if (!this.HAS_DOCUMENT_COOKIE)
215
+ return;
216
+ const a = this.cookies;
217
+ this.cookies = w.parse(document.cookie), this._checkChanges(a);
218
+ };
219
+ const i = typeof document > "u" ? "" : document.cookie;
220
+ this.cookies = B(t || i), this.defaultSetOptions = e, this.HAS_DOCUMENT_COOKIE = V();
221
+ }
222
+ _emitChange(t) {
223
+ for (let e = 0; e < this.changeListeners.length; ++e)
224
+ this.changeListeners[e](t);
225
+ }
226
+ _checkChanges(t) {
227
+ new Set(Object.keys(t).concat(Object.keys(this.cookies))).forEach((i) => {
228
+ t[i] !== this.cookies[i] && this._emitChange({
229
+ name: i,
230
+ value: S(this.cookies[i])
231
+ });
232
+ });
233
+ }
234
+ _startPolling() {
235
+ this.pollingInterval = setInterval(this.update, 300);
236
+ }
237
+ _stopPolling() {
238
+ this.pollingInterval && clearInterval(this.pollingInterval);
239
+ }
240
+ get(t, e = {}) {
241
+ return e.doNotUpdate || this.update(), S(this.cookies[t], e);
242
+ }
243
+ getAll(t = {}) {
244
+ t.doNotUpdate || this.update();
245
+ const e = {};
246
+ for (let i in this.cookies)
247
+ e[i] = S(this.cookies[i], t);
248
+ return e;
249
+ }
250
+ set(t, e, i) {
251
+ i ? i = Object.assign(Object.assign({}, this.defaultSetOptions), i) : i = this.defaultSetOptions;
252
+ const a = typeof e == "string" ? e : JSON.stringify(e);
253
+ this.cookies = Object.assign(Object.assign({}, this.cookies), { [t]: a }), this.HAS_DOCUMENT_COOKIE && (document.cookie = w.serialize(t, a, i)), this._emitChange({ name: t, value: e, options: i });
254
+ }
255
+ remove(t, e) {
256
+ const i = e = Object.assign(Object.assign(Object.assign({}, this.defaultSetOptions), e), { expires: new Date(1970, 1, 1, 0, 0, 1), maxAge: 0 });
257
+ this.cookies = Object.assign({}, this.cookies), delete this.cookies[t], this.HAS_DOCUMENT_COOKIE && (document.cookie = w.serialize(t, "", i)), this._emitChange({ name: t, value: void 0, options: e });
258
+ }
259
+ addChangeListener(t) {
260
+ this.changeListeners.push(t), this.HAS_DOCUMENT_COOKIE && this.changeListeners.length === 1 && (typeof window == "object" && "cookieStore" in window ? window.cookieStore.addEventListener("change", this.update) : this._startPolling());
261
+ }
262
+ removeChangeListener(t) {
263
+ const e = this.changeListeners.indexOf(t);
264
+ e >= 0 && this.changeListeners.splice(e, 1), this.HAS_DOCUMENT_COOKIE && this.changeListeners.length === 0 && (typeof window == "object" && "cookieStore" in window ? window.cookieStore.removeEventListener("change", this.update) : this._stopPolling());
265
+ }
266
+ removeAllChangeListeners() {
267
+ for (; this.changeListeners.length > 0; )
268
+ this.removeChangeListener(this.changeListeners[0]);
269
+ }
270
+ }
271
+ const ce = (r) => {
272
+ const t = new F();
273
+ let i = new URLSearchParams(window.location.search).get("tenantId") || t.get("tenantId");
274
+ const a = t.get("accessToken") || null;
275
+ if (console.log("ThemeProvider1:tenantId", i), !i && a) {
276
+ const d = atob(a.split(".")[1]), f = JSON.parse(d);
277
+ i = f.tenantId ? f.tenantId.toString() : null;
278
+ }
279
+ console.log("ThemeProvider2:tenantId", i);
280
+ const c = r.isBrand || i != null ? r.viteThemeUrl : "";
281
+ return console.log("themeUrl", c), /* @__PURE__ */ O(
282
+ R,
283
+ {
284
+ brandTheme: { enabled: !!c, url: c },
285
+ children: r.children
286
+ }
287
+ );
288
+ };
65
289
  export {
66
- $ as AuthContext,
67
- D as AuthProvider,
68
- F as ERROR_MESSAGE,
69
- H as HasPermission,
70
- G as PermissionRoute,
71
- I as SaasThemeProvider,
72
- L as TranslationProvider,
73
- N as axiosInstance,
74
- O as color,
75
- j as createCustomTheme,
76
- m as getUseHasPermission,
77
- z as handleErrorAxios,
78
- K as login,
79
- V as logout,
80
- X as responseInterceptor,
81
- Y as search,
82
- Z as setFavicon,
83
- _ as setShellBackdrop,
84
- q as translate,
85
- J as translationConfig,
86
- Q as useAuth,
87
- W as useCustomTranslation,
88
- C as useGetPermission,
89
- k as useSyncBackdrop,
90
- E as useSyncRouter,
91
- b as useTheme,
92
- ee as useTranslation
290
+ he as AuthContext,
291
+ de as AuthProvider,
292
+ fe as ERROR_MESSAGE,
293
+ oe as HasPermission,
294
+ ae as PermissionRoute,
295
+ R as SaasThemeProvider,
296
+ ce as ThemeProvider,
297
+ ge as TranslationProvider,
298
+ me as axiosInstance,
299
+ pe as color,
300
+ we as createCustomTheme,
301
+ _ as getUseHasPermission,
302
+ Oe as handleErrorAxios,
303
+ Se as login,
304
+ ye as logout,
305
+ ke as responseInterceptor,
306
+ Ce as search,
307
+ xe as setFavicon,
308
+ Ee as setShellBackdrop,
309
+ ve as translate,
310
+ Ie as translationConfig,
311
+ Te as useAuth,
312
+ _e as useCustomTranslation,
313
+ ne as useGetPermission,
314
+ se as useSyncBackdrop,
315
+ re as useSyncRouter,
316
+ be as useTheme,
317
+ Pe as useTranslation
93
318
  };
@@ -0,0 +1,6 @@
1
+ import { BrandThemeProps } from './SaasThemeProvider';
2
+
3
+ export declare const ThemeProvider: (props: BrandThemeProps & {
4
+ isBrand: boolean;
5
+ viteThemeUrl: string;
6
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -2,3 +2,4 @@ export { color } from './Colors';
2
2
  export type { ColorsType } from './Colors';
3
3
  export * from './Theme';
4
4
  export * from './SaasThemeProvider';
5
+ export * from './ThemeProvider';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.16.3-dev.21",
4
+ "version": "0.16.3-dev.24",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",
@@ -62,6 +62,7 @@
62
62
  "jquery": "^3.7.1",
63
63
  "moment": "^2.30.1",
64
64
  "react-bootstrap-daterangepicker": "^8.0.0",
65
+ "react-cookie": "^8.0.1",
65
66
  "react-dnd": "^16.0.1",
66
67
  "react-i18next": "^12.3.1",
67
68
  "react-icons": "^5.0.1",
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { U as d } from "../index-C0bWxjUr.js";
2
+ import { U as d } from "../index-Csm4KbjM.js";
3
3
  import "../react-toastify.esm-H_Xdunfj.js";
4
4
  import "../toast-config/index.js";
5
5
  import "../toast-config-notification/index.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { F as u, u as F } from "../index-C0bWxjUr.js";
2
+ import { F as u, u as F } from "../index-Csm4KbjM.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-Dkof1OzO.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 a } from "../index-C0bWxjUr.js";
2
+ import { G as a } from "../index-Csm4KbjM.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-Dkof1OzO.js";
5
5
  import "../SaasThemeProvider-DUpoV8xb.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { L as n, T as s } from "../index-C0bWxjUr.js";
2
+ import { L as n, T as s } from "../index-Csm4KbjM.js";
3
3
  import "../index-N6zjI_u_.js";
4
4
  import "../index-Dkof1OzO.js";
5
5
  import "../SaasThemeProvider-DUpoV8xb.js";
@@ -1,5 +1,5 @@
1
1
  import "../react-to-web-component-w5r1Fs9q.js";
2
- import { H as o, g as r } from "../index-C0bWxjUr.js";
2
+ import { H as o, g as r } from "../index-Csm4KbjM.js";
3
3
  export {
4
4
  o as HasPermission,
5
5
  r as getUseHasPermission