@bluealba/pae-ui-react-core 4.3.0-develop-102 → 4.3.0-develop-112
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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +207 -207
- package/dist/index.systemjs.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -19,7 +19,7 @@ Check the top-level render call using <`+j+">.")}return A}}function Li(b,A){{if(
|
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,Oo,Bt,df,Bt),ki[Bt+Oo]=!0}}return b===r?sf(fe):of(fe),fe}}function af(b,A,j){return $i(b,A,j,!0)}function cf(b,A,j){return $i(b,A,j,!1)}var lf=cf,uf=af;$n.Fragment=r,$n.jsx=lf,$n.jsxs=uf}(),$n}mc.exports=Cf();var l=mc.exports;const gc=_.createContext(null),vc=({module:e,children:t})=>l.jsx(gc.Provider,{value:e,children:t});vc.displayName="PAEModule";const nr=()=>{const e=_.useContext(gc);if(!e)throw new Error("Module metadata was not setup yet !!");return e};function Ds(){if(!window[zn])throw new Error("PAE Global state not found.");return window[zn]}const Ls=()=>{const{authUser:{applications:e}}=Ds();return e||[]},yc=e=>Ls().filter(t=>t.
|
|
22
|
+
<%s key={someKey} {...props} />`,Oo,Bt,df,Bt),ki[Bt+Oo]=!0}}return b===r?sf(fe):of(fe),fe}}function af(b,A,j){return $i(b,A,j,!0)}function cf(b,A,j){return $i(b,A,j,!1)}var lf=cf,uf=af;$n.Fragment=r,$n.jsx=lf,$n.jsxs=uf}(),$n}mc.exports=Cf();var l=mc.exports;const gc=_.createContext(null),vc=({module:e,children:t})=>l.jsx(gc.Provider,{value:e,children:t});vc.displayName="PAEModule";const nr=()=>{const e=_.useContext(gc);if(!e)throw new Error("Module metadata was not setup yet !!");return e};function Ds(){if(!window[zn])throw new Error("PAE Global state not found.");return window[zn]}const Ls=()=>{const{authUser:{applications:e}}=Ds();return e||[]},yc=e=>Ls().filter(t=>t.name===e).flatMap(t=>t.operations),bc=()=>{const{application:e}=nr();return _.useMemo(()=>yc(e),[e])},wc=e=>(...t)=>t.every(n=>e.some(r=>r.name===n)),rr=()=>{const[{authUser:e}]=er(),t=bc();return{authUser:e,hasAccess:_.useMemo(()=>wc(t),[t])}},xf=()=>{const{authUser:e}=rr();return!e||e.id==="anon"},Ms=()=>{var e;return((e=nr().ui)==null?void 0:e.customProps)??{}},ks=e=>{const t=tr();return _.useMemo(()=>{const n=t.find(r=>r.name===e);if(!n)throw new Error(`Could not find the module [${e}] in the local catalog !`);return n},[t,e])},Cc=e=>{var t,n;return((n=(t=ks(e))==null?void 0:t.ui)==null?void 0:n.customProps)??{}},Sf=e=>e.replace(/\/+/g,"/"),Ef=(e,t="only-base-path")=>{const{apiDocs:n,health:r,version:o,changelog:s}=(e==null?void 0:e.commonPaths)||{},i=(a,c="")=>{if(a===void 0&&!c)return;const u=a??c;if(t==="only-base-path")return u;const f=Sf(`${e.baseUrl}/${u}`);return t==="with-module-base"?f:`${document.location.origin}${f}`};return{apiDocsPath:i(n,"/api-docs-json"),healthPath:i(r,"/health"),versionPath:i(o,"/version"),changelogPath:i(s,"/changelog")}};function _f(){window.open(pf,"_self")}const Rf=e=>jr.navigateToUrl(e),Tf=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/,Pf=e=>Tf.test(e),Af=(e,t=2)=>{if(!e)return"";const n=e.split(" ");return n.length===1?n.join("").slice(0,t):n.map(r=>r[0]).join("").slice(0,t)},xc=e=>e.type==="app"||e.type==="tool",Of=e=>e.modules.some(xc)&&e.route&&e.route!=="/",Sc=e=>{const{catalog:t}=Ds();return oo(t.filter(n=>n.application===e))},oo=(e=[])=>e.find(t=>{var n;return xc(t)&&((n=t.ui)==null?void 0:n.route)!=="/"}),Ec=()=>{const e=tr();return _.useMemo(()=>Ls().map(n=>{var s,i,a;const r=jf(e,n.name),o=oo(r);return{name:n.name,displayName:((i=(s=o==null?void 0:o.ui)==null?void 0:s.customProps)==null?void 0:i.overrideApplicationDisplayName)??n.displayName,modules:r,route:(a=o==null?void 0:o.ui)==null?void 0:a.route,roles:[],operations:n.operations}}),[e])},jf=(e,t)=>e.filter(n=>n.application===t)||[],_c=()=>{const e=Ec();return _.useMemo(()=>e.filter(Of),[e])},Rc=e=>_.useMemo(()=>e?Sc(e.name):void 0,[e]),Nt=new Map,If=e=>{try{const{catalog:t}=Ds(),n=t.find(r=>r.name===e);return n!=null&&n.version?`${e}@${n.version}`:e}catch{return e}},so=e=>{const[t,n]=_.useState(null);return _.useEffect(()=>{(async()=>{if(!e){n(null);return}try{const o=If(e);if(Nt.has(o)){const i=Nt.get(o);n(i);return}const s=await System.import(e);Nt.set(o,s),n(s)}catch(o){console.error(`Error importing module ${e}: ${o.message}`),n(null)}})()},[e,n]),t},Nf=e=>{e?(Array.from(Nt.keys()).filter(n=>n.startsWith(e)).forEach(n=>Nt.delete(n)),console.log(`[useApplicationJSModule] Cleared cache for module: ${e}`)):(Nt.clear(),console.log("[useApplicationJSModule] Cleared all module cache"))};typeof window<"u"&&(window.PAE={...window.PAE,clearModuleCache:Nf,getModuleCacheSize:()=>Nt.size,getModuleCacheKeys:()=>Array.from(Nt.keys())});const Tc=e=>{const t=typeof e=="string"?Sc(e):oo(e==null?void 0:e.modules),n=so(t==null?void 0:t.name);return n==null?void 0:n.icon},Pc=e=>{const t=oo(e==null?void 0:e.modules),n=so(t==null?void 0:t.name),[r,o]=_.useState(!1),[s,i]=_.useState({}),a=async()=>(typeof(n==null?void 0:n.menu)=="function"?await n.menu():n==null?void 0:n.menu)||[],c=async()=>{if(!(n!=null&&n.menu))return[];o(!0);const p=Df((e==null?void 0:e.operations)||[]),m=(await a()).map(g=>{const{operations:x,items:h,path:v}=g;if(x!=null&&x.length&&!p(x))return null;const y=(h||[]).filter(w=>{var S;return!((S=w==null?void 0:w.operations)!=null&&S.length)||p(w.operations)});return!y.length&&!v?null:{...g,items:y}}).filter(Boolean);return o(!1),m},u=async()=>{const p=await c();e&&i(m=>({...m,[e.name]:p}))};_.useEffect(()=>{u()},[n==null?void 0:n.menu]);const f=_.useMemo(()=>e?s[e.name]||[]:[],[s,e]);return{loading:r,menu:f}},Df=e=>t=>t.every(n=>e.some(r=>r.name===n)),Lf=e=>Pc(e);function ae(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Ut(e){return function t(n){return arguments.length===0||ae(n)?t:e.apply(this,arguments)}}function wt(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return ae(n)?t:Ut(function(o){return e(n,o)});default:return ae(n)&&ae(r)?t:ae(n)?Ut(function(o){return e(o,r)}):ae(r)?Ut(function(o){return e(n,o)}):e(n,r)}}}function $s(e){return function t(n,r,o){switch(arguments.length){case 0:return t;case 1:return ae(n)?t:wt(function(s,i){return e(n,s,i)});case 2:return ae(n)&&ae(r)?t:ae(n)?wt(function(s,i){return e(s,r,i)}):ae(r)?wt(function(s,i){return e(n,s,i)}):Ut(function(s){return e(n,r,s)});default:return ae(n)&&ae(r)&&ae(o)?t:ae(n)&&ae(r)?wt(function(s,i){return e(s,i,o)}):ae(n)&&ae(o)?wt(function(s,i){return e(s,r,i)}):ae(r)&&ae(o)?wt(function(s,i){return e(n,s,i)}):ae(n)?Ut(function(s){return e(s,r,o)}):ae(r)?Ut(function(s){return e(n,s,o)}):ae(o)?Ut(function(s){return e(n,r,s)}):e(n,r,o)}}}function fr(e,t){return Object.prototype.hasOwnProperty.call(t,e)}function Ui(e){return Object.prototype.toString.call(e)==="[object Object]"}var Mf=$s(function(t,n,r){var o=t(n),s=t(r);return o>s?-1:o<s?1:0}),kf=$s(function(t,n,r){var o={},s;n=n||{},r=r||{};for(s in n)fr(s,n)&&(o[s]=fr(s,r)?t(s,n[s],r[s]):n[s]);for(s in r)fr(s,r)&&!fr(s,o)&&(o[s]=r[s]);return o}),$f=$s(function e(t,n,r){return kf(function(o,s,i){return Ui(s)&&Ui(i)?e(t,s,i):t(o,s,i)},n,r)}),Ff=wt(function(t,n){return $f(function(r,o,s){return s},t,n)}),Bf=wt(function(t,n){return Array.prototype.slice.call(n,0).sort(function(r,o){for(var s=0,i=0;s===0&&i<t.length;)s=t[i](r,o),i+=1;return s})});const Fs=()=>{const e=pc(),t=_c();return _.useMemo(()=>Uf(e,t),[e,t])},Uf=(e,t)=>Bf([Mf(Wf)],t).find(n=>n.route&&e.startsWith(n.route)),Wf=e=>{var t;return((t=e==null?void 0:e.route)==null?void 0:t.length)||-1},Ac=()=>{var e;return(e=Fs())==null?void 0:e.name},Hf=()=>{const e=Fs(),t=Rc(e);return so(t==null?void 0:t.name)},Bs=(e,t)=>{const r=tr().find(o=>o.name===e);if(!r){if(t)return null;throw new Error(`Service with name [${e}] not available in the catalog`)}return r.baseUrl},Us=(e,t)=>{const n=Bs(e,!!t)??t;return _.useCallback((r,o)=>{const i={Accept:"application/json",...(o==null?void 0:o.body)instanceof FormData?{}:{"Content-Type":"application/json"},...o==null?void 0:o.headers};return fetch(Vf(`${n}${r}`),{...o,headers:i})},[n])},Vf=e=>e.replace(/\/+/g,"/"),zf=["impersonate","impersonate-display-name","tenant"],Oc=(e,t)=>{const n=Bs(e,t);return _.useMemo(()=>{if(!n)return null;try{const r=new URL(window.location.href),o=new URL(n,window.location.origin);return zf.forEach(s=>{const i=r.searchParams.get(s);i&&o.searchParams.set(s,i)}),o.toString()}catch(r){return console.error("Error building WebSocket URL:",r),n}},[n])},qf=(e,t)=>n=>({timestamp:new Date(new Date().toUTCString()).toISOString(),module:t.name,moduleVersion:t.version,application:t.application,user:e.username,...n}),Gf=(e,t,n)=>async r=>{if(r.length===0)throw new Error("Invalid call to trackEvents with an empty array of events!");const o=await e("/event",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r.map(qf(t,n)))});if(!o.ok)throw new Error(`Error publishing habits event ${o.statusText}`)},Kf="@bluealba/pae-habits-service",jc=()=>{const{authUser:e}=rr(),t=nr(),n=Us(Kf);return _.useCallback(Gf(n,e,t),[n,e,t])},Qf=()=>{const e=jc();return _.useCallback((t,n)=>e([{name:t,data:n}]),[e])},Ic=e=>{const t=nr(),n=window[fc],[r,o]=_.useState(null);return _.useEffect(()=>n.defineExtensionPoint(t,e,s=>{o(()=>s)}),[o]),r},Nc=(e,t,n)=>{_.useEffect(()=>window[fc].setExtensionPoint(e,t,n),[])},Dc=(e,t)=>{_.useEffect(()=>(window.addEventListener(e,t),()=>window.removeEventListener(e,t)),[e,t])},Lc=e=>{const{cssCustomizationLoadingDelay:t=1e3}=Ms();_.useEffect(()=>{if(!e)return;const n=document.createElement("style");return setTimeout(()=>{n.innerHTML=e,document.head.append(n)},t),()=>n&&n.remove()},[e])},Yf=e=>{var t;return(t=e.split(/[#?]/)[0].split(".").pop())==null?void 0:t.trim()},Zf={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg"},Xf=e=>{const t=Yf(e);return t?Zf[t]:void 0},Jf=(e,t)=>{const n=t??Xf(e);return n?`format(${n})`:""};function Mc(e){const[t,n]=_.useState(!1);return _.useEffect(()=>{if(!(e!=null&&e.length))return;const r=document.createElement("style");r.setAttribute("data-generated-fonts","true");const o=e.flatMap(({fontFamily:i,variants:a})=>a.map(({path:c,fontWeight:u,format:f})=>`
|
|
23
23
|
@font-face {
|
|
24
24
|
font-family: "${i}";
|
|
25
25
|
src: url("${c}") ${Jf(c,f)};
|