@telia-ace/widget-types-grid 1.3.57 → 1.3.58-rc.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.
- package/index.d.ts +1 -0
- package/index.js +14 -14
- package/index.mjs +467 -407
- package/package.json +6 -7
- package/ui/overlay-focus.d.ts +29 -0
package/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as Component } from './ui/component';
|
|
|
2
2
|
export { default as DetachedComponent } from './ui/detached-component';
|
|
3
3
|
export { default as NotFound } from './ui/not-found';
|
|
4
4
|
export { styling as genericComponentStyling } from './ui/styles';
|
|
5
|
+
export { isModalActive } from './ui/overlay-focus';
|
|
5
6
|
export { default as GridWidget, default as Widget } from './widget';
|
package/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var oe=Object.create;var K=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var de=(t,n,e)=>n in t?K(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var le=(t,n,e,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of ae(n))!ue.call(t,i)&&i!==e&&K(t,i,{get:()=>n[i],enumerable:!(s=re(n,i))||s.enumerable});return t};var I=(t,n,e)=>(e=t!=null?oe(ce(t)):{},le(n||!t||!t.__esModule?K(e,"default",{value:t,enumerable:!0}):e,t));var L=(t,n,e)=>de(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),z=require("@emotion/react"),w=require("@telia-ace/widget-core"),p=require("@telia-ace/widget-ui"),v=require("react"),k=require("@emotion/styled"),E=require("@telia-ace/widget-utilities"),Q=require("react-transition-group"),_=require("react-router-dom"),he=require("@telia-ace/widget-routing"),h=require("@telia-ace/widget-services"),pe=require("@webprovisions/bootstrapping"),J=require("@webprovisions/platform");var H=(t=>(t.back="back",t.forth="forth",t))(H||{});const me=(t,n,e)=>typeof e[t]=="number"&&typeof e[n]=="number"&&e[t]>e[n]?"back":"forth",X=({views:t,location:n,render:e})=>f.jsx(_.Switch,{location:n&&{...n,pathname:n.pathname.split("?")[0]},children:[...Object.keys(t).filter(s=>!!t[s].path),...Object.keys(t).filter(s=>!t[s].path)].map(s=>{const{path:i}=t[s];return i?Array.isArray(i)?i.map(o=>f.jsx(_.Route,{exact:!0,path:o,render:()=>e(s)},s)):f.jsx(_.Route,{exact:!0,path:i,render:()=>e(s)},s):f.jsx(_.Route,{render:()=>e(s)},s)})}),ge=k.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
4
|
flex: 1;
|
|
5
|
-
`,
|
|
5
|
+
`,fe=k(p.Grid)`
|
|
6
6
|
position: absolute;
|
|
7
7
|
left: 0;
|
|
8
8
|
right: 0;
|
|
9
9
|
${t=>!!t.animationCss&&t.animationCss}
|
|
10
10
|
${t=>!!t.scrollableCss&&t.scrollableCss}
|
|
11
|
-
`,
|
|
11
|
+
`,be={index:1,search:2,browse:3,guide:4,contact:5,"contact-method":6,conversation:7},ye=({className:t="",...n})=>{const[e,s]=v.useState("index"),[i,o]=v.useState(H.forth),r=p.useRouteData(),a=p.useRouter(),c=p.useProperties(),l=p.useContext(),d=p.useContainer(),u=p.useComponentNode(),{gap:m="0"}=l,{columns:b=1,animation:y="none",scrollable:g=!1,...S}=c,[C,D]=p.useScroll(g);if(!u||!a)return null;const{location:R}=a;r.name!==e&&r.name!==""&&y&&(o(me(e,r.name,be)),s(r.name));const{views:A}=d.get("$settings");if(!Object.keys(A).length)return null;const x=(O,N,P)=>{const M=G(N,P),j=u.getChildren(O)[0];return f.jsx(fe,{...n,...S,scrollableCss:C,ref:D,columns:b,gap:m,...M,className:E.appendClassNames(t,"humany-view"),children:f.jsx(B,{id:j.id,branch:"default"})})},G=(O,N)=>{if(y==="slide"||y==="fade")return{animationCss:p.transitionComposer.composeViewTransition(O,y,N),"data-state":O}};return f.jsx(ge,{className:"humany-animated-view",children:f.jsx(Q.TransitionGroup,{component:null,childFactory:O=>v.cloneElement(O,{direction:i}),children:f.jsx(Q.Transition,{timeout:{enter:500,exit:500},onEnter:O=>O==null?void 0:O.clientHeight,unmountOnExit:!0,direction:H.forth,children:(O,{direction:N})=>f.jsx(X,{views:A,location:R,render:P=>x(P,O,N)})},e)})})},we=k(p.Grid)`
|
|
12
12
|
${t=>!!t.scrollableCss&&t.scrollableCss}
|
|
13
|
-
`,
|
|
13
|
+
`,ve=({className:t="",...n})=>{const e=p.useProperties(),s=p.useContext(),i=p.useContainer(),o=p.useComponentNode(),{views:r}=i.get("$settings"),{gap:a="0"}=s,{columns:c=1,animation:l="none",scrollable:d=!1,...u}=e,[m,b]=p.useScroll(d);return o?f.jsx(we,{...n,...u,scrollableCss:m,ref:b,columns:c,gap:a,className:E.appendClassNames(t,"humany-view"),children:f.jsx(X,{views:r,render:y=>{const g=o.getChildren(y)[0];return f.jsx(B,{id:g.id,node:g,branch:"default"})}})}):null},W=t=>{var n,e;return z.css`
|
|
14
14
|
outline: none;
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
* {
|
|
@@ -33,24 +33,24 @@
|
|
|
33
33
|
`}
|
|
34
34
|
|
|
35
35
|
&:focus-visible {
|
|
36
|
-
${
|
|
36
|
+
${p.paddedBorderTabStyle(t)};
|
|
37
37
|
}
|
|
38
|
-
`},
|
|
38
|
+
`},Se=k(ve)`
|
|
39
39
|
${t=>W(t)}
|
|
40
|
-
`,
|
|
40
|
+
`,Ce=k(ye)`
|
|
41
41
|
${t=>W(t)}
|
|
42
|
-
`,
|
|
42
|
+
`,Oe=k.div`
|
|
43
43
|
text-align: center;
|
|
44
|
-
${t=>{var n,e,
|
|
44
|
+
${t=>{var n,e,s;return typeof((n=t.theme.colors)==null?void 0:n.warning)<"u"&&z.css`
|
|
45
45
|
color: ${(e=t.theme.colors)==null?void 0:e.warning};
|
|
46
|
-
border: 2px dashed ${(
|
|
46
|
+
border: 2px dashed ${(s=t.theme.colors)==null?void 0:s.warning};
|
|
47
47
|
`}}
|
|
48
48
|
${t=>typeof t.theme.borderRadius<"u"&&`border-radius: ${t.theme.borderRadius};`}
|
|
49
49
|
${t=>W(t)}
|
|
50
|
-
`,
|
|
50
|
+
`,Ee=v.forwardRef(({className:t="",children:n,...e},s)=>{const i=p.useComponent(),{name:o,type:r,id:a}=p.useComponentDescriptor(),c=v.useMemo(()=>i?k(i)`
|
|
51
51
|
${W}
|
|
52
|
-
${
|
|
53
|
-
`:null,[
|
|
52
|
+
${p.filterCssPropsStyle}
|
|
53
|
+
`:null,[i]);return typeof i>"u"?null:i===null||c===null?process.env.NODE_ENV!=="production"?f.jsx(Oe,{...e,title:`type: ${r}, definition-id: ${o}, instance-id: ${a}`,className:E.appendClassNames(t,"humany-non-resolved-component"),children:f.jsx(p.Typography,{variant:"h5",children:"Non Resolved Component Type"})}):null:f.jsx(v.Suspense,{fallback:null,children:f.jsx(c,{ref:s,...e,className:E.appendClassNames(t,"humany-component",`humany-component-${o}`),children:n})})}),xe=t=>{const n=p.useComponentNode(t),e=p.useComponentPlatform(),[s,i]=v.useState({}),o=p.useIsMounted();return v.useEffect(()=>{n&&o.current&&i(n.attributes.properties)},[n,t,o]),v.useEffect(()=>{if(e){const r=e.events.subscribe("components:properties-changed",(a,c)=>{n===c.node&&o.current&&i(c.node.attributes.properties)});return()=>{r()}}},[e,o,t,n]),s},Me=(t,n)=>n?!0:typeof t=="string"?t==="full":t>0,B=v.forwardRef(({className:t="",id:n,branch:e,node:s,ariaLabel:i,tabIndex:o,context:r,...a},c)=>{const l=p.useComponentPlatform(),d=p.useContainer(),[u,m]=v.useState(),b=p.useColumns(),y=p.useContext(n),g=xe(n),{size:S="none",indent:C=0}=p.useLayout(n),D=Me(S,s);if(v.useEffect(()=>{if(l){if(n&&!s){const M=l.nodes.get(n);if(M&&(m(w.asDescriptor(M,e)),D)){const j=M.mount(d);return()=>{j()}}}else if(s){m(w.asDescriptor(s,e));const M=s.mount(d);return()=>{M()}}}},[l,n,s,D]),!u||!D)return null;const R={...y,...r||{}},{cardinal:A,fonts:x={},accessibility:G={},...O}=R,N={type:x.type,base:x.base||"16px",small:x.small||"0.8em",normal:x.normal||"1em",medium:x.medium||"1.2em",large:x.large||"1.6em",huge:x.huge||"2.5em"},P={...O,fonts:N,accessibility:{...G}};return typeof A=="number"&&(P.sizes={cardinal:A,small:`${A}px`,normal:`${A*3}px`,medium:`${A*5}px`,large:`${A*8}px`}),f.jsx(z.ThemeProvider,{theme:P,children:f.jsx(p.ComponentNodeContext.Provider,{value:u,children:f.jsx(p.ComponentPropertyContext.Provider,{value:g,children:(()=>{const M={"data-width":S==="full"?b:Math.min(S,b),"data-indent":C,"data-name":u.name,"data-node-id":u.id,"data-component-type":u.type,"aria-label":i,tabIndex:o,id:u.id,role:g.role?g&&g.role:null,...a};switch(u.type){case"view":return typeof g.animation=="string"&&g.animation!=="none"?f.jsx(Ce,{...M,className:t}):f.jsx(Se,{...M,className:t});default:{const j=p.filterCssProps(g);return f.jsx(Ee,{ref:c,...M,...j,className:t})}}})()})})})}),ee=({builder:t})=>{const n=p.useContainer(),[e,s]=v.useState(null);return v.useEffect(()=>{n.getAsync("components").then(i=>t(i).then(o=>{s(o)}))},[]),v.useEffect(()=>()=>{e&&n.getAsync("components").then(i=>{i.nodes.detached=i.nodes.detached.filter(o=>o.id!==e.id)})},[e]),e?f.jsx(B,{id:e.id,node:e,branch:"default"}):null},De=Object.freeze(Object.defineProperty({__proto__:null,default:ee},Symbol.toStringTag,{value:"Module"})),Ae=v.lazy(()=>Promise.resolve().then(()=>De)),Ne=({showSearch:t=!1})=>{const n=z.useTheme(),e=p.useContainer();return f.jsx(v.Suspense,{fallback:null,children:f.jsx(Ae,{builder:s=>e.get("settings").then(i=>{var l;const{properties:o,context:r}=Object.keys(i.components).reduce((d,u)=>(i.components[u].type==="not-found"&&(d.properties=i.components[u].properties,d.context=i.components[u].context),d),{properties:{},context:{}});o.showSearch=t;const a=s.createNode("area",{detached:!0});if(a.name="not-found-area",a.writeLayout({size:"full"}),t){const d=Object.keys(i.components).reduce((m,b)=>i.components[b].type==="search"?i.components[b].properties:m,{}),u=s.createNode("search",{detached:!0});u.writeLayout({size:"full"}),u.writeProperties({"css-margin-bottom":((l=n==null?void 0:n.sizes)==null?void 0:l.normal)||"15px",...d}),a.appendChild(u)}const c=s.createNode("not-found",{detached:!0});return c.writeLayout({size:"full"}),c.writeProperties(o),c.writeContext(r),a.appendChild(c),a})})})},Le='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',F=t=>t.getClientRects().length>0&&window.getComputedStyle(t).visibility!=="hidden",te=(t,n=F)=>Array.from(t.querySelectorAll(Le)).filter(n),q=t=>!!t.querySelector('[aria-modal="true"], .humany-area-modal'),$e=t=>t.tagName==="BUTTON"||t.tagName==="A"&&t.hasAttribute("href")||t.tagName==="INPUT"&&["button","submit"].includes(t.type),ke=t=>{if($e(t))return()=>{};const n=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t.click())};return t.addEventListener("keydown",n),()=>t.removeEventListener("keydown",n)},Pe=(t,n,e,s=F)=>{const i=te(n,s),o=document.activeElement;if(!i.length||!o){t.preventDefault();return}(t.shiftKey?i.some(a=>a.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING):i.some(a=>o.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING))||(t.preventDefault(),e&&e.isConnected&&s(e)?e.focus():(t.shiftKey?i[i.length-1]:i[0]).focus())},Re=(t,{timeout:n=1e3,interval:e=50,visible:s=F}={})=>{const i=()=>{if(q(t))return!0;const a=t.querySelector("h1");return!a||!s(a)?!1:(a.hasAttribute("tabindex")||a.setAttribute("tabindex","-1"),a.focus(),document.activeElement===a)};if(i())return()=>{};const o=Date.now(),r=window.setInterval(()=>{var a;i()?window.clearInterval(r):Date.now()-o>=n&&(window.clearInterval(r),t.contains(document.activeElement)||(a=t.querySelector('[data-node-id][tabindex="-1"]'))==null||a.focus())},e);return()=>window.clearInterval(r)},je=(t,n,e,s=F)=>{let i=!1,o=()=>{};const r=t.events.subscribe("widget:render-state-changed",(l,{next:d})=>{i=d==="open",o(),o=i?Re(n,{visible:s}):()=>{}}),a=l=>{!i||q(n)||(l.key==="Tab"?Pe(l,n,e,s):l.key==="Escape"&&window.setTimeout(()=>{i&&!E.isEscapeHandled(l)&&t.invoke("hide",{focusTrigger:!0})}))},c=l=>{if(!i||l.key!=="Tab"||q(n))return;const d=te(n,s);d.length&&(l.preventDefault(),(l.shiftKey?d[d.length-1]:d[0]).focus())};return n.addEventListener("keydown",a),e.addEventListener("keydown",c),()=>{o(),r(),n.removeEventListener("keydown",a),e.removeEventListener("keydown",c)}},Ie=t=>{if(t){const{type:n,content:e}=t;switch(n){case"FontAwesome":return`<i class="humany-icon fa fa-${e}"></i>`;case"Uri":return`<i class="humany-icon humany-custom-icon" style="background: url(${e}) no-repeat center center;background-size: contain;"></i>`;default:return""}}},We=t=>{const n=(i,o)=>{i&&(o?i.classList.add("humany-tabbing"):i.classList.remove("humany-tabbing"))},e=i=>{i.key==="Tab"?n(t,!0):i.key==="Enter"&&document.activeElement&&document.activeElement.classList.contains("humany-trigger")||n(t,!1)},s=i=>{document.activeElement&&document.activeElement.classList.contains("humany-trigger")&&document.activeElement.classList.contains("humany-tabbing")||n(t,!1)};return document.addEventListener("keydown",e),document.addEventListener("click",s),()=>{document.removeEventListener("keydown",e),document.removeEventListener("click",s)}};function _e(t,n){const{symbol:e,widgetName:s,label:i="",ariaLabel:o="",tooltip:r=""}=n;t.classList.add("humany-trigger"),t.classList.add(`humany_${s}`),i.length&&t.classList.add("humany-has-text"),o.length&&!t.getAttribute("aria-label")&&t.setAttribute("aria-label",o),o.length&&!t.getAttribute("tabindex")&&t.setAttribute("tabindex","0"),r.length&&!t.getAttribute("title")&&t.setAttribute("title",r);const a=Ie(e)||"";return t.innerHTML=`${a}
|
|
54
54
|
<span class="humany-close">
|
|
55
55
|
<svg width="18" height="9" viewBox="0 0 18 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
56
56
|
<path d="M9 9C8.81794 9.00045 8.63759 8.96634 8.46939 8.89965C8.3012 8.83295 8.14851 8.735 8.02015 8.61145L0.194523 1.12367C0.068294 0.99862 -0.00155266 0.831133 2.61958e-05 0.657285C0.00160506 0.483436 0.0744832 0.317136 0.202964 0.194202C0.331445 0.0712675 0.505249 0.00153576 0.686941 2.50649e-05C0.868634 -0.00148563 1.04368 0.0653456 1.17437 0.186125L9 7.6739L16.8256 0.186125C16.9563 0.0653456 17.1314 -0.00148563 17.3131 2.50649e-05C17.4948 0.00153576 17.6686 0.0712675 17.797 0.194202C17.9255 0.317136 17.9984 0.483436 18 0.657285C18.0016 0.831133 17.9317 0.99862 17.8055 1.12367L9.97985 8.61145C9.85149 8.735 9.6988 8.83295 9.53061 8.89965C9.36241 8.96634 9.18206 9.00045 9 9Z" fill="white"/>
|
|
@@ -68,4 +68,4 @@
|
|
|
68
68
|
stroke-miterlimit="10" />
|
|
69
69
|
</svg>
|
|
70
70
|
</span>
|
|
71
|
-
${s.length?`<span>${s}</span>`:""}`,setTimeout(()=>t&&t.classList.add("humany-rendered")),De(t)}function Le(t,n){t instanceof HTMLElement?(n&&t.setAttribute("title",n),t.classList.remove("humany-active"),t.classList.remove("humany-loading")):t instanceof Array&&t.forEach(e=>{n&&e.setAttribute("title",n),e.classList.remove("humany-active"),e.classList.remove("humany-loading")})}function $e(t){t instanceof HTMLElement?(t.classList.remove("humany-active"),t.classList.add("humany-loading")):t instanceof Array&&t.forEach(n=>{n.classList.remove("humany-active"),n.classList.add("humany-loading")})}function X(t,n){t instanceof HTMLElement?(n&&t.setAttribute("title",n),t.classList.add("humany-active"),t.classList.remove("humany-loading")):t instanceof Array&&t.forEach(e=>{n&&e.setAttribute("title",n),e.classList.add("humany-active"),e.classList.remove("humany-loading")})}var $=(t=>(t.Inline="inline",t.Link="link",t.Badge="badge",t.Unsupported="unsupported",t))($||{});const Pe=(t,n)=>t&&n?"both":t?"widgetDOM":n?"triggerDOM":"none",ee=t=>t?typeof t=="boolean"&&t?"link":typeof t=="object"&&!Array.isArray(t)?"badge":"unsupported":"inline",Re=(t,n,e,i,s=!1)=>{var g,d;const o=Pe(n,e),r=ee(i),a={widgetDOMElement:n?n.cloneNode(!0):void 0,triggerDOMElement:e?e.cloneNode(!0):void 0},c={triggerType:r,cachedOriginals:a,widgetDOMElement:document.createElement("div")};switch(o){case"both":{c.widgetDOMElement=n||document.createElement("div"),r!=="inline"&&(c.triggerDOMElement=e);break}case"widgetDOM":{if(c.widgetDOMElement=n||document.createElement("div"),r!=="inline"){const u=document.body.appendChild(document.createElement("a"));r==="link"&&(u.innerText=t),c.triggerDOMElement=u}break}case"triggerDOM":{const u=document.createElement("div");c.widgetDOMElement=u,r==="inline"?(u.id=(e==null?void 0:e.id)||"",s?(u.style.display="none",(g=e==null?void 0:e.parentNode)==null||g.appendChild(u),c.callback=()=>{var p;(p=e==null?void 0:e.parentNode)==null||p.replaceChild(u,e),u.style.display=(e==null?void 0:e.style.display)||"block"}):(d=e==null?void 0:e.parentNode)==null||d.replaceChild(u,e),c.cachedOriginals.widgetDOMElement=e,c.cachedOriginals.triggerDOMElement=void 0):(c.widgetDOMElement=document.body.appendChild(u),c.triggerDOMElement=e);break}case"none":{const u=document.body.appendChild(document.createElement("div"));if(c.widgetDOMElement=u,r!=="inline"){const p=document.body.appendChild(document.createElement("a"));r==="link"&&(p.innerText=t),c.triggerDOMElement=p}break}}return c},ke="modals";class je{constructor(n,e){L(this,"container");L(this,"unsubscribe",[]);var a,c,g,d,u,p,b;this.options=e,this.container=n.createChild(this),this.container.register("widgetDOMElement",this.options.widgetDOMElement),this.container.register("triggerDOMElement",this.options.triggerDOMElement);const i=this.container.get("$widget"),s=n.get("$settings");(a=this.options.widgetDOMElement)==null||a.classList.add("humany-widget"),(c=this.options.widgetDOMElement)==null||c.setAttribute("role","region"),(d=this.options.widgetDOMElement)==null||d.setAttribute("aria-label",((g=s==null?void 0:s.data)==null?void 0:g.widgetAriaLabel)??"Widget"),this.options.triggerDOMElement&&((u=this.options.widgetDOMElement)==null||u.setAttribute("id",`humany_widget_${i.name}`),(p=this.options.triggerDOMElement)==null||p.setAttribute("aria-controls",`humany_widget_${i.name}`)),(b=this.options.widgetDOMElement)==null||b.classList.add(`humany_${i.name}`),new MutationObserver(()=>{Array.from(this.options.widgetDOMElement.querySelectorAll('[aria-label=""]')).forEach(y=>y.removeAttribute("aria-label"))}).observe(this.options.widgetDOMElement,{childList:!0,subtree:!0});const r=n.get("widgetDOMElements")||[];n.register("widgetDOMElements",[...r,this.options.widgetDOMElement])}render(){const{widgetDOMElement:n,triggerDOMElement:e}=this.options,i=this.container.get("$widget");return n.getAttribute("data-rendered")==="true"?Promise.resolve():(e&&this.options.triggerType===$.Badge&&$e(e),Promise.resolve().then(()=>require("./render-M_i97UPk.js")).then(s=>s.default(this.container,n)).then(()=>{if(n.setAttribute("data-rendered","true"),e&&this.options.triggerType===$.Badge){const o=this.options.triggerOptions.openTooltip;X(e,o)}M.notifyDataLoaded(this.container,n);const s=this.container.get("$environment").widgets.all();l.readStorage(this.container,ke,l.StorageMedium.Session).then(o=>{o&&o.forEach(r=>{s.find(a=>a.name===r.name&&a.state==="activated")&&i.events.dispatch("widget:modal-opened",r)})})}))}renderBadge(n){const{triggerDOMElement:e}=this.options;if(!e)return;e.getAttribute("role")||e.setAttribute("role","button");const{name:i}=this.container.get("$widget"),{label:s,symbol:o,ariaLabel:r,closedTooltip:a,openTooltip:c}=n,g={closedTooltip:a,openTooltip:c};this.options.triggerOptions=g;const d=Ne(e,{label:s,symbol:o,ariaLabel:r,widgetName:i,tooltip:a});this.unsubscribe.push(d)}dispose(){return Promise.resolve().then(()=>require("./unmount-1FZXwHPT.js")).then(n=>{var s,o,r,a;const{triggerDOMElement:e,widgetDOMElement:i}=this.options;n.default(i),this.options.cachedOriginals.widgetDOMElement&&i&&((s=i.parentNode)==null||s.replaceChild(this.options.cachedOriginals.widgetDOMElement,i)),this.options.cachedOriginals.triggerDOMElement&&e&&((o=e.parentNode)==null||o.replaceChild(this.options.cachedOriginals.triggerDOMElement,e)),this.unsubscribe.forEach(c=>{c()}),(r=i.parentNode)==null||r.removeChild(i),(a=e==null?void 0:e.parentNode)==null||a.removeChild(e)})}}const I="changesets",Ve=t=>{const n={tags:t.tags};return t.context&&typeof t.context!="function"&&(n.context=t.context),t.properties&&typeof t.properties!="function"&&(n.properties=t.properties),t.layout&&typeof t.layout!="function"&&(n.layout=t.layout),n};class F{constructor(n,e){this.container=n,this.storageWriter=e}static create(n){return l.createStorageWriter(n,I,l.StorageCategory.Necessary,{medium:l.StorageMedium.Local}).then(e=>new F(n,e))}write(n,e,i,s){return M.lock(this)(()=>l.readStorage(this.container,I,l.StorageMedium.Local).then((o={})=>{const{keys:r=[],items:a={}}=o,c=r.indexOf(n);return c>-1&&r.splice(c,1),r.push(n),a[n]={options:s,attributes:Ve(i),rules:e.rules},this.storageWriter({keys:r,items:a})}))}remove(n){return M.lock(this)(()=>l.readStorage(this.container,I,l.StorageMedium.Local).then((e={})=>{const{keys:i=[],items:s={}}=e,o=i.indexOf(n);if(o>-1)return i.splice(o,1),delete s[n],this.storageWriter(e)}))}load(n){return M.lock(this)(()=>l.readStorage(this.container,I,l.StorageMedium.Local).then((e={})=>{const{keys:i=[],items:s={}}=e;i.forEach(o=>{const r=s[o];if(r){const{rules:a,attributes:c,options:g}=r;n.write({attributes:c,options:g,target:new w.ComponentQuery(n,a)})}})}))}}const We=t=>{const{container:n}=t;return F.create(n).then(e=>{const i=n.get("$settings"),s={localStorage:e},o=new w.ComponentPlatform(t,s),r=w.createComponentModel(o,i);return t.events.subscribe("widget:state-change",(a,c)=>{c.state===Q.WidgetState.Deactivating&&r()}),o})},_e=t=>import("@telia-ace/widget-routing").then(({RoutingService:n,HistoryMode:e})=>t.get("settings").then(i=>{const{routing:{initialPath:s="/",mode:o=e.scopedHash,basePath:r},views:a}=i;return new n(t,{initialPath:s,mode:o,routes:Object.keys(a).map(g=>({name:g,path:a[g].path})),basePath:r})})),Ie=t=>import("@telia-ace/widget-services").then(({StorageProvider:n})=>new n),qe=t=>import("@telia-ace/widget-core").then(({ActionResolver:n})=>new n(t)),ze=t=>import("@telia-ace/widget-core").then(({ComponentResolver:n})=>new n(t)),Te=t=>import("@telia-ace/widget-core").then(({ComponentPlatform:n,createComponentModel:e})=>We(t.get("$widget"))),H="$settings",q="open",Y="activeStickyWidget";class te extends Q.WidgetType{constructor(e){super(e);L(this,"outlets",new Map);L(this,"activated");L(this,"subs",[]);L(this,"handleBootstrapping",e=>{const i={triggerDOMElement:e.sourceDOMElement,withRenderState:"storage"};this.container.get("settings").then(s=>{const{activate:o}=s;(typeof o>"u"||o===null||o===!0)&&(this.activated=(this.activated||this.widget.activate()).then(()=>this.attach(i)))})});this.container.registerAsync("storage",()=>Ie(this.container)),this.container.registerFactory("settings",()=>l.readStorage(this.container,H,l.StorageMedium.Local).then((i={})=>({...this.container.get("$settings"),...i}))),le.supportBootstrapping(this,"load",this.handleBootstrapping),this.container.registerAsync("componentResolver",()=>ze(this.container)),this.container.registerAsync("router",()=>_e(this.container)),this.container.registerAsync("actionResolver",()=>qe(this.container)),this.container.register("matchMedia",window.matchMedia),this.container.registerAsync("components",()=>Te(this.container))}initialize(){const e=this.container.getManyAsync("actionResolver","router","components"),i=this.container.get("csp");return i&&(window.webprovisionsEnvironmentVariables||(window.webprovisionsEnvironmentVariables={}),window.webprovisionsEnvironmentVariables.cspNonce=i.nonce),Promise.all([e,this.container.get("settings")]).then(([{actionResolver:s,router:o,components:r},a])=>{var d;s.subscribe(this.widget.name,(u,p,b)=>this.onAction(p,b));const c=u=>{r.nodes.query({type:"view"}).forEach(p=>{r.setSwitch(p,u)})},g=((d=o.getInitialRoute())==null?void 0:d.name)||"index";return c(g),this.events.subscribe("widget:data-loaded",(u,{element:p})=>{this.widget.container.get("seoConfiguration")&&this.events.dispatch("widget:preloaded-replaced",{element:p})}),this.events.subscribe("router:change",(u,{previous:p={routeData:{}},next:b={routeData:{}}})=>{const{routeData:y}=p,{routeData:m}=b,S=Object.keys(a.views).reduce((C,A)=>typeof a.views[A].path>"u"?A:C,"");!m.name&&S?c(S):c(m.name),M.removeNullAndUndefinedValues(y&&y.params),M.removeNullAndUndefinedValues(m&&m.params),this.container.getAsync("actionResolver").then(C=>{C.action(this.widget.name,"routeChange",{next:m,previous:y})})}),o.initialize()})}attach(e={}){return this.container.get("settings").then(({trigger:i})=>{var b,y;const{widgetDOMElement:s,key:o=M.uuid(),triggerDOMElement:r,withRenderState:a}=e,g=ee(i)===$.Inline&&((r==null?void 0:r.childElementCount)||0)>0,d=Re(this.widget.name,s,r,i,g);this.outlets.size<1&&!a&&this.setRenderState("unset");const u=()=>{const m=()=>S.querySelectorAll("[data-loading=true]").length===0,[S]=this.widget.container.get("widgetDOMElements"),C=(D,E)=>{m()&&(d.callback&&d.callback(),E.disconnect())},A={attributes:!0,subtree:!0,childList:!0};m()&&d.callback&&d.callback(),new MutationObserver(C).observe(S,A)};g&&this.widget.container.getAsync("dataClient").then(({events:m})=>{m.subscribe("data-client:fetched",(S,C)=>{C.unresolvedQueries===0&&u()})});const p=this.getOrCreateViewOutlet(o,d);if(this.outlets.set(o,p),this.widget.events.dispatch("widget:attached",{},{bubbles:!0}),d.triggerType===$.Badge&&i&&((b=d.triggerDOMElement)==null||b.setAttribute("aria-expanded","false"),p==null||p.renderBadge(i)),d.triggerType!==$.Inline&&((y=d.triggerDOMElement)==null||y.addEventListener("click",m=>{m.preventDefault(),this.container.get("settings").then(({trigger:S})=>{p.render().then(()=>this.renderState()).then(C=>S&&S.action&&S.action==="hide"?C===w.WidgetRenderState.open?this.hide():this.open():C===w.WidgetRenderState.open?this.close():this.open())})})),this.outlets.size>1)return this.renderState().then(m=>{this.triggerStateIfApplicable(m)});if(a)return a==="storage"?this.renderState().then(m=>{if(d.triggerType===$.Inline){this.triggerStateIfApplicable("open");return}this.triggerStateIfApplicable(m)}):this.triggerStateIfApplicable(a)})}detach(e){if(e){if(this.outlets.has(e)){const i=this.outlets.get(e);i==null||i.dispose(),this.outlets.delete(e);return}process.env.NODE_ENV!=="production"&&console.warn(`detach(): Could not find View Outlet with key ${e}`);return}this.outlets.forEach(i=>{i.dispose()}),this.outlets.clear()}triggerStateIfApplicable(e){return this.container.getAsync("router").then(i=>{switch(e){case"closed":this.close();break;case"open":this.open();break;case"hidden":this.hide(),i.start();break;default:return}})}getOrCreateViewOutlet(e,i){return this.outlets.has(e)?this.outlets.get(e):new je(this.container,i)}render(e={}){if(process.env.NODE_ENV!=="production"&&console.warn("widget.render() is deprecated. Use widget.attach() instead."),e.open){const i={...e,withRenderState:"open"};return this.attach(i)}return this.attach(e)}activate(e){e!=null&&e.override&&this.setSettings(()=>e.override),e!=null&&e.apiNotificationPriorityBy&&this.container.register("apiNotificationPriorityBy",e.apiNotificationPriorityBy)}setSettings(e){return Promise.all([this.container.get("settings"),l.createStorageWriter(this.container,H,l.StorageCategory.Necessary,{medium:l.StorageMedium.Local})]).then(([i,s])=>Promise.resolve(e(i)).then(o=>s(o).then(()=>{const r={...i,...o};return this.widget.events.dispatch("widget:settings-updated",r),r})))}clearSettings(){return l.createStorageWriter(this.container,H,l.StorageCategory.Necessary,{medium:l.StorageMedium.Local}).then(e=>e()).then(()=>this.container.get("settings")).then(e=>{this.widget.events.dispatch("widget:settings-updated",e)})}action({action:e,value:i}){return this.container.getAsync("actionResolver").then(s=>{s.action(this.widget.name,e,i)})}renderState(){if(ue.onWidgetUrl(this.container))return Promise.resolve(w.WidgetRenderState.open);const e=()=>l.readStorage(this.container,q,l.StorageMedium.Session).then((s=w.WidgetRenderState.closed)=>s),i=()=>l.readStorage(this.container,q,l.StorageMedium.Session).then((s=w.WidgetRenderState.closed)=>s);return this.container.getAsync("router").then(s=>s.isSticky()?i().then(o=>o===w.WidgetRenderState.open?o:e()):e())}hide(e){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("hide(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):(this.outlets.forEach(i=>{if(i.render(),e!=null&&e.focusTrigger){const{options:{triggerDOMElement:s}}=i;s==null||s.focus()}}),this.action({action:"hide"}).then(()=>{this.setTriggerState(!1)}))}open(){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("open(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):(this.outlets.forEach(e=>e.render()),this.action({action:"open"}).then(()=>(this.widget.events.dispatch("tracking:widget-rendered",{}),this.onOpen())))}close(){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("close(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):this.action({action:"close"}).then(()=>{this.widget.events.dispatch("tracking:widget-minimized",{}),this.onClose()})}show(){return process.env.NODE_ENV!=="production"&&console.warn("show(): Command is deprecated and will be removed in the future. Use open() instead."),this.open()}onAction(e,i){switch(e){case"close":case"open":case"hide":const s=e==="open"?w.WidgetRenderState.open:e==="close"?w.WidgetRenderState.closed:w.WidgetRenderState.hidden;return this.setRenderState(s).then(()=>{this.setTriggerState(s===w.WidgetRenderState.open),s!==w.WidgetRenderState.hidden?s===w.WidgetRenderState.open?this.onOpen():this.onClose():this.outlets.forEach(o=>{var r;return(r=o.options.triggerDOMElement)==null?void 0:r.setAttribute("aria-expanded","false")})})}}setRenderState(e){const{invoke:i,events:s}=this.container.get("$widget");return Promise.all([l.createStorageWriter(this.container,q,l.StorageCategory.Necessary,{medium:l.StorageMedium.Session}),l.createStorageWriter(this.container,q,l.StorageCategory.Necessary,{medium:l.StorageMedium.Local,duration:{minutes:5}}),this.container.getAsync("router"),i("renderState")]).then(([o,r,a,c])=>{e==="unset"||!e?(r(),o()):(a.isSticky()&&r(e),o(e)),s.dispatch("widget:render-state-changed",{previous:c,next:e})})}onOpen(){return this.container.getAsync("router").then(e=>(this.outlets.forEach(i=>{i.options.triggerDOMElement&&i.options.triggerDOMElement.setAttribute("aria-expanded","true")}),e.start()))}onClose(){const e=this.container.getManyAsync("router","components");return this.container.get("settings").then(s=>{const{activate:o}=this.container.get("$settings");return s.activate!==o?this.setSettings(()=>Promise.resolve({activate:o})):Promise.resolve()}).then(()=>e).then(({router:s,components:o})=>{const r=o.nodes.visible;return this.outlets.forEach(a=>{var c;return(c=a.options.triggerDOMElement)==null?void 0:c.setAttribute("aria-expanded","false")}),r.filter(a=>a.attributes.properties.animation&&a.attributes.properties.animation!=="none").length?new Promise(a=>{setTimeout(()=>{a(s)},200)}):Promise.resolve(s)}).then(s=>s.stop())}setTriggerState(e){this.outlets.forEach(i=>{const{options:{triggerDOMElement:s,triggerOptions:o}}=i,{openTooltip:r,closedTooltip:a}=o||{};s&&(e?X(s,r):Le(s,a))})}deactivate(){this.subs.forEach(i=>i());const e=[];return this.outlets.forEach(i=>e.push(i.dispose())),l.readStorage(this.container,Y,l.StorageMedium.Local).then(i=>i===this.widget.name?l.createStorageWriter(this.container,Y,l.StorageCategory.Necessary,{medium:l.StorageMedium.Local,scope:l.StorageScope.Implementation}).then(s=>s()).then(()=>Promise.all(e)):Promise.all(e))}}exports.Component=T;exports.DetachedComponent=J;exports.GridWidget=te;exports.NotFound=Me;exports.Widget=te;exports.genericComponentStyling=W;
|
|
71
|
+
${i.length?`<span>${i}</span>`:""}`,setTimeout(()=>t&&t.classList.add("humany-rendered")),We(t)}function Ve(t,n){t instanceof HTMLElement?(n&&t.setAttribute("title",n),t.classList.remove("humany-active"),t.classList.remove("humany-loading")):t instanceof Array&&t.forEach(e=>{n&&e.setAttribute("title",n),e.classList.remove("humany-active"),e.classList.remove("humany-loading")})}function Te(t){t instanceof HTMLElement?(t.classList.remove("humany-active"),t.classList.add("humany-loading")):t instanceof Array&&t.forEach(n=>{n.classList.remove("humany-active"),n.classList.add("humany-loading")})}function ne(t,n){t instanceof HTMLElement?(n&&t.setAttribute("title",n),t.classList.add("humany-active"),t.classList.remove("humany-loading")):t instanceof Array&&t.forEach(e=>{n&&e.setAttribute("title",n),e.classList.add("humany-active"),e.classList.remove("humany-loading")})}var $=(t=>(t.Inline="inline",t.Link="link",t.Badge="badge",t.Unsupported="unsupported",t))($||{});const qe=(t,n)=>t&&n?"both":t?"widgetDOM":n?"triggerDOM":"none",ie=t=>t?typeof t=="boolean"&&t?"link":typeof t=="object"&&!Array.isArray(t)?"badge":"unsupported":"inline",ze=(t,n,e,s,i=!1)=>{var l,d;const o=qe(n,e),r=ie(s),a={widgetDOMElement:n?n.cloneNode(!0):void 0,triggerDOMElement:e?e.cloneNode(!0):void 0},c={triggerType:r,cachedOriginals:a,widgetDOMElement:document.createElement("div")};switch(o){case"both":{c.widgetDOMElement=n||document.createElement("div"),r!=="inline"&&(c.triggerDOMElement=e);break}case"widgetDOM":{if(c.widgetDOMElement=n||document.createElement("div"),r!=="inline"){const u=document.body.appendChild(document.createElement("a"));r==="link"&&(u.innerText=t),c.triggerDOMElement=u}break}case"triggerDOM":{const u=document.createElement("div");c.widgetDOMElement=u,r==="inline"?(u.id=(e==null?void 0:e.id)||"",i?(u.style.display="none",(l=e==null?void 0:e.parentNode)==null||l.appendChild(u),c.callback=()=>{var m;(m=e==null?void 0:e.parentNode)==null||m.replaceChild(u,e),u.style.display=(e==null?void 0:e.style.display)||"block"}):(d=e==null?void 0:e.parentNode)==null||d.replaceChild(u,e),c.cachedOriginals.widgetDOMElement=e,c.cachedOriginals.triggerDOMElement=void 0):(c.widgetDOMElement=document.body.appendChild(u),c.triggerDOMElement=e);break}case"none":{const u=document.body.appendChild(document.createElement("div"));if(c.widgetDOMElement=u,r!=="inline"){const m=document.body.appendChild(document.createElement("a"));r==="link"&&(m.innerText=t),c.triggerDOMElement=m}break}}return c},Be="modals";class Fe{constructor(n,e){L(this,"container");L(this,"unsubscribe",[]);var a,c,l,d,u,m,b;this.options=e,this.container=n.createChild(this),this.container.register("widgetDOMElement",this.options.widgetDOMElement),this.container.register("triggerDOMElement",this.options.triggerDOMElement);const s=this.container.get("$widget"),i=n.get("$settings");(a=this.options.widgetDOMElement)==null||a.classList.add("humany-widget"),(c=this.options.widgetDOMElement)==null||c.setAttribute("role","region"),(d=this.options.widgetDOMElement)==null||d.setAttribute("aria-label",((l=i==null?void 0:i.data)==null?void 0:l.widgetAriaLabel)??"Widget"),this.options.triggerDOMElement&&((u=this.options.widgetDOMElement)==null||u.setAttribute("id",`humany_widget_${s.name}`),(m=this.options.triggerDOMElement)==null||m.setAttribute("aria-controls",`humany_widget_${s.name}`),this.unsubscribe.push(je(s,this.options.widgetDOMElement,this.options.triggerDOMElement),ke(this.options.triggerDOMElement))),(b=this.options.widgetDOMElement)==null||b.classList.add(`humany_${s.name}`),new MutationObserver(()=>{Array.from(this.options.widgetDOMElement.querySelectorAll('[aria-label=""]')).forEach(y=>y.removeAttribute("aria-label"))}).observe(this.options.widgetDOMElement,{childList:!0,subtree:!0});const r=n.get("widgetDOMElements")||[];n.register("widgetDOMElements",[...r,this.options.widgetDOMElement])}render(){const{widgetDOMElement:n,triggerDOMElement:e}=this.options,s=this.container.get("$widget");return n.getAttribute("data-rendered")==="true"?Promise.resolve():(e&&this.options.triggerType===$.Badge&&Te(e),Promise.resolve().then(()=>require("./render-M_i97UPk.js")).then(i=>i.default(this.container,n)).then(()=>{if(n.setAttribute("data-rendered","true"),e&&this.options.triggerType===$.Badge){const o=this.options.triggerOptions.openTooltip;ne(e,o)}E.notifyDataLoaded(this.container,n);const i=this.container.get("$environment").widgets.all();h.readStorage(this.container,Be,h.StorageMedium.Session).then(o=>{o&&o.forEach(r=>{i.find(a=>a.name===r.name&&a.state==="activated")&&s.events.dispatch("widget:modal-opened",r)})})}))}renderBadge(n){const{triggerDOMElement:e}=this.options;if(!e)return;e.getAttribute("role")||e.setAttribute("role","button");const{name:s}=this.container.get("$widget"),{label:i,symbol:o,ariaLabel:r,closedTooltip:a,openTooltip:c}=n,l={closedTooltip:a,openTooltip:c};this.options.triggerOptions=l;const d=_e(e,{label:i,symbol:o,ariaLabel:r,widgetName:s,tooltip:a});this.unsubscribe.push(d)}dispose(){return Promise.resolve().then(()=>require("./unmount-1FZXwHPT.js")).then(n=>{var i,o,r,a;const{triggerDOMElement:e,widgetDOMElement:s}=this.options;n.default(s),this.options.cachedOriginals.widgetDOMElement&&s&&((i=s.parentNode)==null||i.replaceChild(this.options.cachedOriginals.widgetDOMElement,s)),this.options.cachedOriginals.triggerDOMElement&&e&&((o=e.parentNode)==null||o.replaceChild(this.options.cachedOriginals.triggerDOMElement,e)),this.unsubscribe.forEach(c=>{c()}),(r=s.parentNode)==null||r.removeChild(s),(a=e==null?void 0:e.parentNode)==null||a.removeChild(e)})}}const V="changesets",Ge=t=>{const n={tags:t.tags};return t.context&&typeof t.context!="function"&&(n.context=t.context),t.properties&&typeof t.properties!="function"&&(n.properties=t.properties),t.layout&&typeof t.layout!="function"&&(n.layout=t.layout),n};class Y{constructor(n,e){this.container=n,this.storageWriter=e}static create(n){return h.createStorageWriter(n,V,h.StorageCategory.Necessary,{medium:h.StorageMedium.Local}).then(e=>new Y(n,e))}write(n,e,s,i){return E.lock(this)(()=>h.readStorage(this.container,V,h.StorageMedium.Local).then((o={})=>{const{keys:r=[],items:a={}}=o,c=r.indexOf(n);return c>-1&&r.splice(c,1),r.push(n),a[n]={options:i,attributes:Ge(s),rules:e.rules},this.storageWriter({keys:r,items:a})}))}remove(n){return E.lock(this)(()=>h.readStorage(this.container,V,h.StorageMedium.Local).then((e={})=>{const{keys:s=[],items:i={}}=e,o=s.indexOf(n);if(o>-1)return s.splice(o,1),delete i[n],this.storageWriter(e)}))}load(n){return E.lock(this)(()=>h.readStorage(this.container,V,h.StorageMedium.Local).then((e={})=>{const{keys:s=[],items:i={}}=e;s.forEach(o=>{const r=i[o];if(r){const{rules:a,attributes:c,options:l}=r;n.write({attributes:c,options:l,target:new w.ComponentQuery(n,a)})}})}))}}const Ke=t=>{const{container:n}=t;return Y.create(n).then(e=>{const s=n.get("$settings"),i={localStorage:e},o=new w.ComponentPlatform(t,i),r=w.createComponentModel(o,s);return t.events.subscribe("widget:state-change",(a,c)=>{c.state===J.WidgetState.Deactivating&&r()}),o})},Ue=t=>import("@telia-ace/widget-routing").then(({RoutingService:n,HistoryMode:e})=>t.get("settings").then(s=>{const{routing:{initialPath:i="/",mode:o=e.scopedHash,basePath:r},views:a}=s;return new n(t,{initialPath:i,mode:o,routes:Object.keys(a).map(l=>({name:l,path:a[l].path})),basePath:r})})),He=t=>import("@telia-ace/widget-services").then(({StorageProvider:n})=>new n),Ye=t=>import("@telia-ace/widget-core").then(({ActionResolver:n})=>new n(t)),Qe=t=>import("@telia-ace/widget-core").then(({ComponentResolver:n})=>new n(t)),Ze=t=>import("@telia-ace/widget-core").then(({ComponentPlatform:n,createComponentModel:e})=>Ke(t.get("$widget"))),U="$settings",T="open",Z="activeStickyWidget";class se extends J.WidgetType{constructor(e){super(e);L(this,"outlets",new Map);L(this,"activated");L(this,"subs",[]);L(this,"handleBootstrapping",e=>{const s={triggerDOMElement:e.sourceDOMElement,withRenderState:"storage"};this.container.get("settings").then(i=>{const{activate:o}=i;(typeof o>"u"||o===null||o===!0)&&(this.activated=(this.activated||this.widget.activate()).then(()=>this.attach(s)))})});this.container.registerAsync("storage",()=>He(this.container)),this.container.registerFactory("settings",()=>h.readStorage(this.container,U,h.StorageMedium.Local).then((s={})=>({...this.container.get("$settings"),...s}))),pe.supportBootstrapping(this,"load",this.handleBootstrapping),this.container.registerAsync("componentResolver",()=>Qe(this.container)),this.container.registerAsync("router",()=>Ue(this.container)),this.container.registerAsync("actionResolver",()=>Ye(this.container)),this.container.register("matchMedia",window.matchMedia),this.container.registerAsync("components",()=>Ze(this.container))}initialize(){const e=this.container.getManyAsync("actionResolver","router","components"),s=this.container.get("csp");return s&&(window.webprovisionsEnvironmentVariables||(window.webprovisionsEnvironmentVariables={}),window.webprovisionsEnvironmentVariables.cspNonce=s.nonce),Promise.all([e,this.container.get("settings")]).then(([{actionResolver:i,router:o,components:r},a])=>{var d;i.subscribe(this.widget.name,(u,m,b)=>this.onAction(m,b));const c=u=>{r.nodes.query({type:"view"}).forEach(m=>{r.setSwitch(m,u)})},l=((d=o.getInitialRoute())==null?void 0:d.name)||"index";return c(l),this.events.subscribe("widget:data-loaded",(u,{element:m})=>{this.widget.container.get("seoConfiguration")&&this.events.dispatch("widget:preloaded-replaced",{element:m})}),this.events.subscribe("router:change",(u,{previous:m={routeData:{}},next:b={routeData:{}}})=>{const{routeData:y}=m,{routeData:g}=b,S=Object.keys(a.views).reduce((C,D)=>typeof a.views[D].path>"u"?D:C,"");!g.name&&S?c(S):c(g.name),E.removeNullAndUndefinedValues(y&&y.params),E.removeNullAndUndefinedValues(g&&g.params),this.container.getAsync("actionResolver").then(C=>{C.action(this.widget.name,"routeChange",{next:g,previous:y})})}),o.initialize()})}attach(e={}){return this.container.get("settings").then(({trigger:s})=>{var b,y;const{widgetDOMElement:i,key:o=E.uuid(),triggerDOMElement:r,withRenderState:a}=e,l=ie(s)===$.Inline&&((r==null?void 0:r.childElementCount)||0)>0,d=ze(this.widget.name,i,r,s,l);this.outlets.size<1&&!a&&this.setRenderState("unset");const u=()=>{const g=()=>S.querySelectorAll("[data-loading=true]").length===0,[S]=this.widget.container.get("widgetDOMElements"),C=(A,x)=>{g()&&(d.callback&&d.callback(),x.disconnect())},D={attributes:!0,subtree:!0,childList:!0};g()&&d.callback&&d.callback(),new MutationObserver(C).observe(S,D)};l&&this.widget.container.getAsync("dataClient").then(({events:g})=>{g.subscribe("data-client:fetched",(S,C)=>{C.unresolvedQueries===0&&u()})});const m=this.getOrCreateViewOutlet(o,d);if(this.outlets.set(o,m),this.widget.events.dispatch("widget:attached",{},{bubbles:!0}),d.triggerType===$.Badge&&s&&((b=d.triggerDOMElement)==null||b.setAttribute("aria-expanded","false"),m==null||m.renderBadge(s)),d.triggerType!==$.Inline&&((y=d.triggerDOMElement)==null||y.addEventListener("click",g=>{g.preventDefault(),this.container.get("settings").then(({trigger:S})=>{m.render().then(()=>this.renderState()).then(C=>S&&S.action&&S.action==="hide"?C===w.WidgetRenderState.open?this.hide():this.open():C===w.WidgetRenderState.open?this.close():this.open())})})),this.outlets.size>1)return this.renderState().then(g=>{this.triggerStateIfApplicable(g)});if(a)return a==="storage"?this.renderState().then(g=>{if(d.triggerType===$.Inline){this.triggerStateIfApplicable("open");return}this.triggerStateIfApplicable(g)}):this.triggerStateIfApplicable(a)})}detach(e){if(e){if(this.outlets.has(e)){const s=this.outlets.get(e);s==null||s.dispose(),this.outlets.delete(e);return}process.env.NODE_ENV!=="production"&&console.warn(`detach(): Could not find View Outlet with key ${e}`);return}this.outlets.forEach(s=>{s.dispose()}),this.outlets.clear()}triggerStateIfApplicable(e){return this.container.getAsync("router").then(s=>{switch(e){case"closed":this.close();break;case"open":this.open();break;case"hidden":this.hide(),s.start();break;default:return}})}getOrCreateViewOutlet(e,s){return this.outlets.has(e)?this.outlets.get(e):new Fe(this.container,s)}render(e={}){if(process.env.NODE_ENV!=="production"&&console.warn("widget.render() is deprecated. Use widget.attach() instead."),e.open){const s={...e,withRenderState:"open"};return this.attach(s)}return this.attach(e)}activate(e){e!=null&&e.override&&this.setSettings(()=>e.override),e!=null&&e.apiNotificationPriorityBy&&this.container.register("apiNotificationPriorityBy",e.apiNotificationPriorityBy)}setSettings(e){return Promise.all([this.container.get("settings"),h.createStorageWriter(this.container,U,h.StorageCategory.Necessary,{medium:h.StorageMedium.Local})]).then(([s,i])=>Promise.resolve(e(s)).then(o=>i(o).then(()=>{const r={...s,...o};return this.widget.events.dispatch("widget:settings-updated",r),r})))}clearSettings(){return h.createStorageWriter(this.container,U,h.StorageCategory.Necessary,{medium:h.StorageMedium.Local}).then(e=>e()).then(()=>this.container.get("settings")).then(e=>{this.widget.events.dispatch("widget:settings-updated",e)})}action({action:e,value:s}){return this.container.getAsync("actionResolver").then(i=>{i.action(this.widget.name,e,s)})}renderState(){if(he.onWidgetUrl(this.container))return Promise.resolve(w.WidgetRenderState.open);const e=()=>h.readStorage(this.container,T,h.StorageMedium.Session).then((i=w.WidgetRenderState.closed)=>i),s=()=>h.readStorage(this.container,T,h.StorageMedium.Session).then((i=w.WidgetRenderState.closed)=>i);return this.container.getAsync("router").then(i=>i.isSticky()?s().then(o=>o===w.WidgetRenderState.open?o:e()):e())}hide(e){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("hide(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):(this.outlets.forEach(s=>{if(s.render(),e!=null&&e.focusTrigger){const{options:{triggerDOMElement:i}}=s;i==null||i.focus()}}),this.action({action:"hide"}).then(()=>{this.setTriggerState(!1)}))}open(){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("open(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):(this.outlets.forEach(e=>e.render()),this.action({action:"open"}).then(()=>(this.widget.events.dispatch("tracking:widget-rendered",{}),this.onOpen())))}close(){return this.outlets.size<1?(process.env.NODE_ENV!=="production"&&console.warn("close(): No-op as no view outlets are registered. Invoke the attach() command first."),Promise.resolve()):this.action({action:"close"}).then(()=>{this.widget.events.dispatch("tracking:widget-minimized",{}),this.onClose()})}show(){return process.env.NODE_ENV!=="production"&&console.warn("show(): Command is deprecated and will be removed in the future. Use open() instead."),this.open()}onAction(e,s){switch(e){case"close":case"open":case"hide":const i=e==="open"?w.WidgetRenderState.open:e==="close"?w.WidgetRenderState.closed:w.WidgetRenderState.hidden;return this.setRenderState(i).then(()=>{this.setTriggerState(i===w.WidgetRenderState.open),i!==w.WidgetRenderState.hidden?i===w.WidgetRenderState.open?this.onOpen():this.onClose():this.outlets.forEach(o=>{var r;return(r=o.options.triggerDOMElement)==null?void 0:r.setAttribute("aria-expanded","false")})})}}setRenderState(e){const{invoke:s,events:i}=this.container.get("$widget");return Promise.all([h.createStorageWriter(this.container,T,h.StorageCategory.Necessary,{medium:h.StorageMedium.Session}),h.createStorageWriter(this.container,T,h.StorageCategory.Necessary,{medium:h.StorageMedium.Local,duration:{minutes:5}}),this.container.getAsync("router"),s("renderState")]).then(([o,r,a,c])=>{e==="unset"||!e?(r(),o()):(a.isSticky()&&r(e),o(e)),i.dispatch("widget:render-state-changed",{previous:c,next:e})})}onOpen(){return this.container.getAsync("router").then(e=>(this.outlets.forEach(s=>{s.options.triggerDOMElement&&s.options.triggerDOMElement.setAttribute("aria-expanded","true")}),e.start()))}onClose(){const e=this.container.getManyAsync("router","components");return this.container.get("settings").then(i=>{const{activate:o}=this.container.get("$settings");return i.activate!==o?this.setSettings(()=>Promise.resolve({activate:o})):Promise.resolve()}).then(()=>e).then(({router:i,components:o})=>{const r=o.nodes.visible;return this.outlets.forEach(a=>{var c;return(c=a.options.triggerDOMElement)==null?void 0:c.setAttribute("aria-expanded","false")}),r.filter(a=>a.attributes.properties.animation&&a.attributes.properties.animation!=="none").length?new Promise(a=>{setTimeout(()=>{a(i)},200)}):Promise.resolve(i)}).then(i=>i.stop())}setTriggerState(e){this.outlets.forEach(s=>{const{options:{triggerDOMElement:i,triggerOptions:o}}=s,{openTooltip:r,closedTooltip:a}=o||{};i&&(e?ne(i,r):Ve(i,a))})}deactivate(){this.subs.forEach(s=>s());const e=[];return this.outlets.forEach(s=>e.push(s.dispose())),h.readStorage(this.container,Z,h.StorageMedium.Local).then(s=>s===this.widget.name?h.createStorageWriter(this.container,Z,h.StorageCategory.Necessary,{medium:h.StorageMedium.Local,scope:h.StorageScope.Implementation}).then(i=>i()).then(()=>Promise.all(e)):Promise.all(e))}}exports.Component=B;exports.DetachedComponent=ee;exports.GridWidget=se;exports.NotFound=Ne;exports.Widget=se;exports.genericComponentStyling=W;exports.isModalActive=q;
|