@luigi-project/core 2.18.4-dev.202412180032 → 2.18.4-dev.202412200031

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/luigi.js CHANGED
@@ -23,7 +23,7 @@ Invalid Children:`,t),null):(t.some(a=>{if(a.pathSegment===e||a.pathSegment&&a.p
23
23
  }
24
24
  ${n}
25
25
  </style>
26
- `,t}createCompoundItemContainer(e){const t=e||{},n=document.createElement("div");return n.setAttribute("style",`grid-row: ${t.row||"auto"}; grid-column: ${t.column||"auto"}`),n}}const lp=i=>{const e=i.use;if(e){if(e==="grid")return new Bk(i);if(e.createCompoundContainer||e.createCompoundItemContainer||e.attachCompoundItem)return new Uk(i)}else return new _r(i);return new _r(i)},Jf=(i,e,t,n)=>{e.eventListeners&&e.eventListeners.forEach(l=>{const r=l.source+"."+l.name,a=i[r],o={wcElementId:t,wcElement:n,action:l.action,converter:l.dataConverter};a?a.push(o):i[r]=[o]})},Hk=i=>Object.entries(i).reduce((e,t)=>(e[Yf(t[0])]=Yf(t[1]),e),{}),Yf=(i="")=>String(i).replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/"),Wk="500px",qk="0px";class zk{constructor(){Ul(this,"wcContainerData",new WeakMap)}dynamicImport(e){return import(/* webpackIgnore: true */e)}attachWC(e,t,n,l,r,a,o,c){if(n&&n.contains(t)){const h=document.createElement(e);a&&h.setAttribute("nodeId",a),h.setAttribute("lui_web_component",!0),this.initWC(h,e,n,r,l,a,o),n.replaceChild(h,t),c&&(this.removeTemporaryHeightFromCompoundItemContainer(n),this.wcContainerData.delete(n))}}initWC(e,t,n,l,r,a,o){const c=r.context;e.extendedContext=r,e.extendedContext.currentNode&&(e.extendedContext.clientPermissions=e.extendedContext.currentNode.clientPermissions);const h={linkManager:window.Luigi.navigation,uxManager:window.Luigi.ux,getCurrentLocale:()=>window.Luigi.i18n().getCurrentLocale(),publishEvent:g=>{n.eventBus&&n.eventBus.onPublishEvent(g,a,t)},getActiveFeatureToggleList:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getActiveFeatureToggles:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getPathParams:()=>{var g;return(g=e.extendedContext)!=null&&g.pathParams?e.extendedContext.pathParams:{}},getCoreSearchParams:()=>{const g={clientPermissions:e.extendedContext.clientPermissions};return me.prepareSearchParamsForClient(g)},getClientPermissions:()=>{var g;return(g=e.extendedContext)!=null&&g.clientPermissions?e.extendedContext.clientPermissions:{}},addNodeParams:(g,p)=>{o||window.Luigi.routing().addNodeParams(g,p)},getNodeParams:g=>{var b;if(o)return{};const p=(b=e.extendedContext)!=null&&b.nodeParams?e.extendedContext.nodeParams:{};return g?Hk(p):e.extendedContext.nodeParams},setAnchor:g=>{o||window.Luigi.routing().setAnchor(g)},getAnchor:()=>window.Luigi.routing().getAnchor(),getUserSettings:async()=>await this.getUserSettingsForWc(n._luigi_node),setViewGroupData:g=>{const p=re.findViewGroup(n._luigi_node);if(p){const b=re.getViewGroupSettings(p);b._liveCustomData=g,te.configChanged("navigation.viewgroupdata")}}};if(e.__postProcess){const g=new URL(document.baseURI).origin===new URL(l,document.baseURI).origin?new URL(l,document.baseURI):new URL("./",l);e.__postProcess(c,h,g.origin+g.pathname)}else e.context=c,e.nodeParams=r.nodeParams,e.LuigiClient=h;const d=te.getConfigValue("settings.webcomponentCreationInterceptor");le.isFunction(d)&&d(e,r.currentNode,r,a,o)}generateWCId(e){let t="",n=new URL(e,encodeURI(location.href)).href;for(let l=0;l<n.length;l++)t+=n.charCodeAt(l).toString(16);return"luigi-wc-"+t}registerWCFromUrl(e,t){const n=me.getI18nViewUrl(e);return new Promise((l,r)=>{this.checkWCUrl(n)?this.dynamicImport(n).then(a=>{try{if(!window.customElements.get(t)){let o=a.default;if(!HTMLElement.isPrototypeOf(o)){let c=Object.keys(a);for(let h=0;h<c.length&&(o=a[c[h]],!HTMLElement.isPrototypeOf(o));h++);}window.customElements.define(t,o)}l()}catch(o){r(o)}}).catch(a=>r(a)):(console.warn(`View URL '${n}' not allowed to be included`),r(`View URL '${n}' not allowed`))})}includeSelfRegisteredWCFromUrl(e,t,n){if(this.checkWCUrl(t)){window.Luigi._registerWebcomponent||(window.Luigi._registerWebcomponent=(r,a)=>{const o=this.generateWCId(r);window.customElements.get(o)||window.customElements.define(o,a)});let l=document.createElement("script");l.setAttribute("src",t),e.webcomponent.type==="module"&&l.setAttribute("type","module"),l.setAttribute("defer",!0),l.addEventListener("load",()=>{n()}),document.body.appendChild(l)}else console.warn(`View URL '${t}' not allowed to be included`)}checkWCUrl(e){if(e.indexOf("://")>0||e.trim().indexOf("//")===0){if(new URL(e).host===window.location.host)return!0;const n=te.getConfigValue("navigation.validWebcomponentUrls");if(n&&n.length>0)for(let l of n)try{if(new RegExp(l).test(e))return!0}catch(r){console.error(r)}return!1}return!0}renderWebComponent(e,t,n,l,r,a,o){var p;const c=n.context,h=me.substituteViewUrl(e,{context:c}),d=((p=l==null?void 0:l.webcomponent)==null?void 0:p.tagName)||this.generateWCId(h),g=document.createElement("div");t.appendChild(g),t._luigi_node=l,window.customElements.get(d)?this.attachWC(d,g,t,n,h,r,a,o):window.luigiWCFn?window.luigiWCFn(h,d,g,()=>{this.attachWC(d,g,t,n,h,r,a,o)}):l.webcomponent&&l.webcomponent.selfRegistered?this.includeSelfRegisteredWCFromUrl(l,h,()=>{this.attachWC(d,g,t,n,h,r,a,o)}):this.registerWCFromUrl(h,d).then(()=>{this.attachWC(d,g,t,n,h,r,a,o)})}createCompoundContainerAsync(e,t,n){return new Promise((l,r)=>{var a,o;if(e.viewUrl)try{const c=((a=n==null?void 0:n.webcomponent)==null?void 0:a.tagName)||this.generateWCId(e.viewUrl);(o=n==null?void 0:n.webcomponent)!=null&&o.selfRegistered?this.includeSelfRegisteredWCFromUrl(n,e.viewUrl,()=>{const h=document.createElement(c);h.setAttribute("lui_web_component",!0),this.initWC(h,c,h,e.viewUrl,t,"_root"),l(h)}):this.registerWCFromUrl(e.viewUrl,c).then(()=>{const h=document.createElement(c);h.setAttribute("lui_web_component",!0),this.initWC(h,c,h,e.viewUrl,t,"_root"),l(h)})}catch(c){r(c)}else l(e.createCompoundContainer())})}intersectionObserverCallback(e,t){e.filter(l=>l.isIntersecting).forEach(l=>{const r=l.target,a=this.wcContainerData.get(r);a?this.renderWebComponent(a.viewUrl,a.wc_container,a.extendedContext,a.node,a.nodeId,a.isSpecialMf,!0):console.error("Could not find WC container data",{for:r}),t.unobserve(r)})}setTemporaryHeightForCompoundItemContainer(e,t,n){var r,a,o;if(((r=t.lazyLoadingOptions)==null?void 0:r.noTemporaryContainerHeight)===!0)return;const l=((a=n.layoutConfig)==null?void 0:a.temporaryContainerHeight)||((o=t.lazyLoadingOptions)==null?void 0:o.temporaryContainerHeight)||Wk;e.style.height=l}removeTemporaryHeightFromCompoundItemContainer(e){const t=this.wcContainerData.get(e);(t==null?void 0:t.noTemporaryContainerHeight)!==!0&&e.style.removeProperty("height")}getCompoundRenderer(e,t){const n=e.webcomponent&&!!e.viewUrl;let l;return n?(l=new _r,l.viewUrl=me.substituteViewUrl(e.viewUrl,{context:t}),l.createCompoundItemContainer=r=>{var a=document.createElement("div");return r&&r.slot&&a.setAttribute("slot",r.slot),a}):e.compound.renderer?l=lp(e.compound.renderer):l=new _r,l}createIntersectionObserver(e){var t;return new IntersectionObserver((n,l)=>{this.intersectionObserverCallback(n,l)},{rootMargin:((t=e.compound.lazyLoadingOptions)==null?void 0:t.intersectionRootMargin)||qk})}renderWebComponentCompound(e,t,n){var c,h;const l=((h=(c=e.compound)==null?void 0:c.lazyLoadingOptions)==null?void 0:h.enabled)===!0,r=n.context,a=this.getCompoundRenderer(e,r);let o;return l&&(o=this.createIntersectionObserver(e)),t._luigi_node=e,new Promise(d=>{this.createCompoundContainerAsync(a,n,e).then(g=>{const p={};g.eventBus={listeners:p,onPublishEvent:(b,m,v)=>{const C=p[m+"."+b.type]||[];C.push(...p["*."+b.type]||[]),C.forEach(y=>{const P=y.wcElement||g.querySelector("[nodeId="+y.wcElementId+"]");P?P.dispatchEvent(new CustomEvent(y.action,{detail:y.converter?y.converter(b.detail):b.detail})):console.debug("Could not find event target",y)})}},e.compound.children.forEach((b,m)=>{var P;const v={...r,...b.context},C=a.createCompoundItemContainer(b.layoutConfig),y=b.id||"gen_"+m;C.eventBus=g.eventBus,l?(this.setTemporaryHeightForCompoundItemContainer(C,e.compound,b),a.attachCompoundItem(g,C),this.wcContainerData.set(C,{viewUrl:b.viewUrl,wc_container:C,extendedContext:{context:v},node:b,nodeId:y,isSpecialMf:!0,noTemporaryContainerHeight:(P=e.compound.lazyLoadingOptions)==null?void 0:P.noTemporaryContainerHeight}),o.observe(C)):(a.attachCompoundItem(g,C),this.renderWebComponent(b.viewUrl,C,{context:v},b,y,!0,!1)),Jf(p,b,y)}),t.appendChild(g),Jf(p,e.compound,"_root",g),d(g)})})}getUserSettingsForWc(e){return new Promise((t,n)=>{if(e.userSettingsGroup){const l=e.userSettingsGroup;te.readUserSettings().then(r=>{const o=l&&typeof r=="object"&&r!==null?r[l]:null;t(o)})}else n(null)})}}const dr=new zk;var zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},os={exports:{}};/**
26
+ `,t}createCompoundItemContainer(e){const t=e||{},n=document.createElement("div");return n.setAttribute("style",`grid-row: ${t.row||"auto"}; grid-column: ${t.column||"auto"}`),n}}const lp=i=>{const e=i.use;if(e){if(e==="grid")return new Bk(i);if(e.createCompoundContainer||e.createCompoundItemContainer||e.attachCompoundItem)return new Uk(i)}else return new _r(i);return new _r(i)},Jf=(i,e,t,n)=>{e.eventListeners&&e.eventListeners.forEach(l=>{const r=l.source+"."+l.name,a=i[r],o={wcElementId:t,wcElement:n,action:l.action,converter:l.dataConverter};a?a.push(o):i[r]=[o]})},Hk=i=>Object.entries(i).reduce((e,t)=>(e[Yf(t[0])]=Yf(t[1]),e),{}),Yf=(i="")=>String(i).replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&quot;",'"').replaceAll("&#39;","'").replaceAll("&sol;","/"),Wk="500px",qk="0px";class zk{constructor(){Ul(this,"wcContainerData",new WeakMap)}dynamicImport(e){return import(/* webpackIgnore: true */e)}attachWC(e,t,n,l,r,a,o,c){if(n&&n.contains(t)){const h=document.createElement(e);a&&h.setAttribute("nodeId",a),h.setAttribute("lui_web_component",!0),this.initWC(h,e,n,r,l,a,o),n.replaceChild(h,t),c&&(this.removeTemporaryHeightFromCompoundItemContainer(n),this.wcContainerData.delete(n))}}initWC(e,t,n,l,r,a,o){const c=r.context;e.extendedContext=r,e.extendedContext.currentNode&&(e.extendedContext.clientPermissions=e.extendedContext.currentNode.clientPermissions);const h={linkManager:()=>{const g=window.Luigi.navigation();return new Proxy(g,{get(p,b){return b===p.getCurrentRoute.name?()=>new Promise(m=>{m(p.getCurrentRoute())}):p[b]}})},uxManager:window.Luigi.ux,getCurrentLocale:()=>window.Luigi.i18n().getCurrentLocale(),publishEvent:g=>{n.eventBus&&n.eventBus.onPublishEvent(g,a,t)},getActiveFeatureToggleList:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getActiveFeatureToggles:()=>window.Luigi.featureToggles().getActiveFeatureToggleList(),getPathParams:()=>{var g;return(g=e.extendedContext)!=null&&g.pathParams?e.extendedContext.pathParams:{}},getCoreSearchParams:()=>{const g={clientPermissions:e.extendedContext.clientPermissions};return me.prepareSearchParamsForClient(g)},getClientPermissions:()=>{var g;return(g=e.extendedContext)!=null&&g.clientPermissions?e.extendedContext.clientPermissions:{}},addNodeParams:(g,p)=>{o||window.Luigi.routing().addNodeParams(g,p)},getNodeParams:g=>{var b;if(o)return{};const p=(b=e.extendedContext)!=null&&b.nodeParams?e.extendedContext.nodeParams:{};return g?Hk(p):e.extendedContext.nodeParams},setAnchor:g=>{o||window.Luigi.routing().setAnchor(g)},getAnchor:()=>window.Luigi.routing().getAnchor(),getUserSettings:async()=>await this.getUserSettingsForWc(n._luigi_node),setViewGroupData:g=>{const p=re.findViewGroup(n._luigi_node);if(p){const b=re.getViewGroupSettings(p);b._liveCustomData=g,te.configChanged("navigation.viewgroupdata")}}};if(e.__postProcess){const g=new URL(document.baseURI).origin===new URL(l,document.baseURI).origin?new URL(l,document.baseURI):new URL("./",l);e.__postProcess(c,h,g.origin+g.pathname)}else e.context=c,e.nodeParams=r.nodeParams,e.LuigiClient=h;const d=te.getConfigValue("settings.webcomponentCreationInterceptor");le.isFunction(d)&&d(e,r.currentNode,r,a,o)}generateWCId(e){let t="",n=new URL(e,encodeURI(location.href)).href;for(let l=0;l<n.length;l++)t+=n.charCodeAt(l).toString(16);return"luigi-wc-"+t}registerWCFromUrl(e,t){const n=me.getI18nViewUrl(e);return new Promise((l,r)=>{this.checkWCUrl(n)?this.dynamicImport(n).then(a=>{try{if(!window.customElements.get(t)){let o=a.default;if(!HTMLElement.isPrototypeOf(o)){let c=Object.keys(a);for(let h=0;h<c.length&&(o=a[c[h]],!HTMLElement.isPrototypeOf(o));h++);}window.customElements.define(t,o)}l()}catch(o){r(o)}}).catch(a=>r(a)):(console.warn(`View URL '${n}' not allowed to be included`),r(`View URL '${n}' not allowed`))})}includeSelfRegisteredWCFromUrl(e,t,n){if(this.checkWCUrl(t)){window.Luigi._registerWebcomponent||(window.Luigi._registerWebcomponent=(r,a)=>{const o=this.generateWCId(r);window.customElements.get(o)||window.customElements.define(o,a)});let l=document.createElement("script");l.setAttribute("src",t),e.webcomponent.type==="module"&&l.setAttribute("type","module"),l.setAttribute("defer",!0),l.addEventListener("load",()=>{n()}),document.body.appendChild(l)}else console.warn(`View URL '${t}' not allowed to be included`)}checkWCUrl(e){if(e.indexOf("://")>0||e.trim().indexOf("//")===0){if(new URL(e).host===window.location.host)return!0;const n=te.getConfigValue("navigation.validWebcomponentUrls");if(n&&n.length>0)for(let l of n)try{if(new RegExp(l).test(e))return!0}catch(r){console.error(r)}return!1}return!0}renderWebComponent(e,t,n,l,r,a,o){var p;const c=n.context,h=me.substituteViewUrl(e,{context:c}),d=((p=l==null?void 0:l.webcomponent)==null?void 0:p.tagName)||this.generateWCId(h),g=document.createElement("div");t.appendChild(g),t._luigi_node=l,window.customElements.get(d)?this.attachWC(d,g,t,n,h,r,a,o):window.luigiWCFn?window.luigiWCFn(h,d,g,()=>{this.attachWC(d,g,t,n,h,r,a,o)}):l.webcomponent&&l.webcomponent.selfRegistered?this.includeSelfRegisteredWCFromUrl(l,h,()=>{this.attachWC(d,g,t,n,h,r,a,o)}):this.registerWCFromUrl(h,d).then(()=>{this.attachWC(d,g,t,n,h,r,a,o)})}createCompoundContainerAsync(e,t,n){return new Promise((l,r)=>{var a,o;if(e.viewUrl)try{const c=((a=n==null?void 0:n.webcomponent)==null?void 0:a.tagName)||this.generateWCId(e.viewUrl);(o=n==null?void 0:n.webcomponent)!=null&&o.selfRegistered?this.includeSelfRegisteredWCFromUrl(n,e.viewUrl,()=>{const h=document.createElement(c);h.setAttribute("lui_web_component",!0),this.initWC(h,c,h,e.viewUrl,t,"_root"),l(h)}):this.registerWCFromUrl(e.viewUrl,c).then(()=>{const h=document.createElement(c);h.setAttribute("lui_web_component",!0),this.initWC(h,c,h,e.viewUrl,t,"_root"),l(h)})}catch(c){r(c)}else l(e.createCompoundContainer())})}intersectionObserverCallback(e,t){e.filter(l=>l.isIntersecting).forEach(l=>{const r=l.target,a=this.wcContainerData.get(r);a?this.renderWebComponent(a.viewUrl,a.wc_container,a.extendedContext,a.node,a.nodeId,a.isSpecialMf,!0):console.error("Could not find WC container data",{for:r}),t.unobserve(r)})}setTemporaryHeightForCompoundItemContainer(e,t,n){var r,a,o;if(((r=t.lazyLoadingOptions)==null?void 0:r.noTemporaryContainerHeight)===!0)return;const l=((a=n.layoutConfig)==null?void 0:a.temporaryContainerHeight)||((o=t.lazyLoadingOptions)==null?void 0:o.temporaryContainerHeight)||Wk;e.style.height=l}removeTemporaryHeightFromCompoundItemContainer(e){const t=this.wcContainerData.get(e);(t==null?void 0:t.noTemporaryContainerHeight)!==!0&&e.style.removeProperty("height")}getCompoundRenderer(e,t){const n=e.webcomponent&&!!e.viewUrl;let l;return n?(l=new _r,l.viewUrl=me.substituteViewUrl(e.viewUrl,{context:t}),l.createCompoundItemContainer=r=>{var a=document.createElement("div");return r&&r.slot&&a.setAttribute("slot",r.slot),a}):e.compound.renderer?l=lp(e.compound.renderer):l=new _r,l}createIntersectionObserver(e){var t;return new IntersectionObserver((n,l)=>{this.intersectionObserverCallback(n,l)},{rootMargin:((t=e.compound.lazyLoadingOptions)==null?void 0:t.intersectionRootMargin)||qk})}renderWebComponentCompound(e,t,n){var c,h;const l=((h=(c=e.compound)==null?void 0:c.lazyLoadingOptions)==null?void 0:h.enabled)===!0,r=n.context,a=this.getCompoundRenderer(e,r);let o;return l&&(o=this.createIntersectionObserver(e)),t._luigi_node=e,new Promise(d=>{this.createCompoundContainerAsync(a,n,e).then(g=>{const p={};g.eventBus={listeners:p,onPublishEvent:(b,m,v)=>{const C=p[m+"."+b.type]||[];C.push(...p["*."+b.type]||[]),C.forEach(y=>{const P=y.wcElement||g.querySelector("[nodeId="+y.wcElementId+"]");P?P.dispatchEvent(new CustomEvent(y.action,{detail:y.converter?y.converter(b.detail):b.detail})):console.debug("Could not find event target",y)})}},e.compound.children.forEach((b,m)=>{var P;const v={...r,...b.context},C=a.createCompoundItemContainer(b.layoutConfig),y=b.id||"gen_"+m;C.eventBus=g.eventBus,l?(this.setTemporaryHeightForCompoundItemContainer(C,e.compound,b),a.attachCompoundItem(g,C),this.wcContainerData.set(C,{viewUrl:b.viewUrl,wc_container:C,extendedContext:{context:v},node:b,nodeId:y,isSpecialMf:!0,noTemporaryContainerHeight:(P=e.compound.lazyLoadingOptions)==null?void 0:P.noTemporaryContainerHeight}),o.observe(C)):(a.attachCompoundItem(g,C),this.renderWebComponent(b.viewUrl,C,{context:v},b,y,!0,!1)),Jf(p,b,y)}),t.appendChild(g),Jf(p,e.compound,"_root",g),d(g)})})}getUserSettingsForWc(e){return new Promise((t,n)=>{if(e.userSettingsGroup){const l=e.userSettingsGroup;te.readUserSettings().then(r=>{const o=l&&typeof r=="object"&&r!==null?r[l]:null;t(o)})}else n(null)})}}const dr=new zk;var zr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},os={exports:{}};/**
27
27
  * @license
28
28
  * Lodash <https://lodash.com/>
29
29
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>