website-utilities 1.0.440 → 1.0.442

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 CHANGED
@@ -108,9 +108,11 @@ export declare class WebsiteUtilities<TElement = HTMLElement, ExternalProperties
108
108
  */
109
109
  render(reason?: string, resolveRendering?: boolean): Promise<void>;
110
110
  /**
111
- * Frees some memory.
111
+ * Should free up memory listeners related to deprecated HTML.
112
+ * @param reason - Description why rendering is necessary.
113
+ * @param reRenderReason - Description why a re-rendering is necessary.
112
114
  */
113
- disconnectedCallback(): void;
115
+ unRender(reason?: string, reRenderReason?: string): void;
114
116
  grabDomNodes(): void;
115
117
  /**
116
118
  * This method disables scrolling on the given web view.
@@ -166,9 +168,8 @@ export declare class WebsiteUtilities<TElement = HTMLElement, ExternalProperties
166
168
  /**
167
169
  * Removes class names from scroll-to-top buttons to stop running
168
170
  * transitions.
169
- * @param classNames - Optional class names to remove.
170
171
  */
171
- _finishScrollToTopButtonTransition(classNames?: Array<string> | string): void;
172
+ _finishScrollToTopButtonTransition(): void;
172
173
  /**
173
174
  * This method triggers if the view port arrives at special areas.
174
175
  */
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/initializerWarningHelper","clientnode","clientnode/property-types","web-component-wrapper/Web","web-component-wrapper/decorator"],t);else{var o="object"==typeof exports?t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator")):t(e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/initializerWarningHelper"],e.clientnode,e["clientnode/property-types"],e["web-component-wrapper/Web"],e["web-component-wrapper/decorator"]);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,((e,t,o,i,n,r,s)=>(()=>{var a=[,,,e=>{e.exports=t},t=>{t.exports=e},e=>{e.exports=o},e=>{e.exports=i},e=>{e.exports=n},e=>{e.exports=s},e=>{e.exports=r}],l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var o=l[e]={exports:{}};return a[e](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return(()=>{c.r(p),c.d(p,{WebsiteUtilities:()=>P,api:()=>M,default:()=>z,log:()=>E});var e,t,o,i,n,r,s,a,l,u,d,h,m,v,w,f,g,b,y,N,S,T,C,L,D=c(3),O=c.n(D),_=c(4),k=c.n(_),x=(c(5),c(6)),I=c(7),A=c(8),q=c(9);const E=new x.Logger({name:"website-utilities"});let P=(e=(0,A.property)({type:I.object}),t=(0,A.property)({type:I.func}),o=(0,A.property)({type:I.func}),i=(0,A.property)({type:I.func}),n=(0,A.property)({type:I.func}),r=(0,A.property)({type:I.func}),s=(0,A.property)({type:I.func}),a=(0,A.property)({type:I.func}),l=(0,A.property)({type:I.func}),u=(0,A.property)({type:I.func}),d=(0,A.property)({type:I.func}),L=class e extends q.Web{constructor(){super(),this.self=e,O()(this,"options",m,this),O()(this,"onStartUpAnimationComplete",v,this),O()(this,"onSwitchSection",w,this),O()(this,"onViewportMovesAwayFromTop",f,this),O()(this,"onViewportMovesToTop",g,this),O()(this,"onUnfocusResponsiveMenu",b,this),O()(this,"onLoaded",y,this),O()(this,"onButtonClick",N,this),O()(this,"onSectionSwitch",S,this),O()(this,"onLinkClick",T,this),O()(this,"onTrack",C,this),this.currentSectionName="",this.startUpAnimationIsComplete=!1,this.viewportIsOnTop=void 0,this.observerDeregisters=[],this.windowLoadingCoverDomNode=null,this.topDomNode=null,this.priorityNavigationDomNodes=null,this.routerOutletDomNode=null,this.sectionDomNodes={},this.scrollToTopButtonDomNodes=null,this.defineGetterAndSetterInterface()}async onUpdateAttribute(e,t){await super.onUpdateAttribute(e,t),"options"===e&&this._extendOptions()}async render(e="unknown",t=!0){if(await super.render(e,!1),0===Object.keys(this.options).length&&this._extendOptions(),this.disableScrolling(),!this.self.windowLoaded){const e=()=>{this.self.windowLoaded||(this.self.windowLoaded=!0,this._removeLoadingCover().then((()=>{this.enableScrolling(),this._performStartUpEffects().then((()=>{this.addMenuHighlighterViewTransition()})),this.onLoaded()})))};(0,x.onDocumentReady)((()=>{(0,x.timeout)(e,this.options.windowLoadedTimeoutAfterDocLoadedInMSec)})),x.globalContext.window&&this.addSecureEventListener(x.globalContext.window,"load",e)}await this.waitForNestedComponentRendering(),this.grabDomNodes(),this._bindScrollEvents(),this._bindClickTracking(),await this._initializeRouting(),this.initializePriorityNavigation(),await this.resolveRenderingPromiseIfSet(e,t)}disconnectedCallback(){super.disconnectedCallback();for(const e of this.observerDeregisters)e()}grabDomNodes(){var e,t,o;this.topDomNode=this.hostDomNode.querySelector(this.options.selectors.top),this.scrollToTopButtonDomNodes=this.hostDomNode.querySelectorAll(this.options.selectors.scrollToTopButtons),this.priorityNavigationDomNodes=this.hostDomNode.querySelectorAll(`.${this.options.selectors.priorityNavigationClassName}`),this.routerOutletDomNode=this.hostDomNode.querySelector(this.options.selectors.routerOutlet);for(const e of null!==(i=this.routerOutletDomNode?.children)&&void 0!==i?i:[]){var i;const t=e.getAttribute("data-website-utilities-section");""===t?this.sectionDomNodes.default=e:t&&this.options.sectionNames.managed.includes(t)&&(this.sectionDomNodes[t]=e)}this.windowLoadingCoverDomNode=null!==(e=null!==(t=null!==(o=this.hostDomNode.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==o?o:this.hostDomNode.parentElement?.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==t?t:x.globalContext.document?.body.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==e?e:null}disableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.add("wu-disable-scrolling"),this.addSecureEventListener(this.hostDomNode.parentElement,"touchmove",x.preventDefault))}enableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.remove("wu-disable-scrolling"),this.hostDomNode.parentElement.classList.remove("touchmove"),this.hostDomNode.parentElement.removeEventListener("touchmove",x.preventDefault))}async track(e){if(x.globalContext.window?.location&&this.options.tracking){const t={context:`${x.globalContext.window.location.pathname}#`+this.currentSectionName,...e};("number"!=typeof t.value||isNaN(t.value))&&(t.value=1),E.debug('Run tracking code: "event" with arguments:'),E.debug(t);try{await this._onTrack(t)}catch(e){E.warn(`Problem in tracking "${(0,x.represent)(t)}":`,(0,x.represent)(e))}}}initializePriorityNavigation(){const{selectors:e}=this.options,t=e.priorityNavigationOverflowIndicatorClassName;if(0===this.priorityNavigationDomNodes?.length)return;for(const t of this.priorityNavigationDomNodes||[])for(const o of t.querySelectorAll(`[href="#${this.currentSectionName}"]`))o.classList.add(e.activeNavigationItemClassName);const o=()=>{for(const o of this.priorityNavigationDomNodes||[]){const i=o.querySelectorAll("ul > li"),n=Array.from(i).filter((e=>!e.classList.contains(t))),r=i[0].offsetTop;let s=[];for(const e of n){e.offsetTop!==r&&s.push(e)}n.length-s.length<this.options.minimumNumberOfMenuItems&&(s=n.slice());const a=o.querySelector(`.${t}`);if(s.length){const t=s.map((e=>{const t=e.cloneNode(!0);for(const e of t.querySelectorAll("[style]"))e.removeAttribute("style");return t}));for(const t of s)t.classList.add(e.priorityNavigationListItemHideClassName);const i=o.querySelector(e.priorityNavigationOverflowList);if(i)for(const e of t)i.append(e);if(a){const e=this.options.selectors.priorityNavigationShowOverflowIndicatorClassName;o.classList.add(e)}}else a&&o.classList.remove(this.options.selectors.priorityNavigationShowOverflowIndicatorClassName)}};for(const o of this.hostDomNode.querySelectorAll(`.${t}`)){const t=o.closest(`.${e.priorityNavigationClassName}`);this.addSecureEventListener(o,"click",(()=>{t?.classList.toggle(e.priorityNavigationOverflowOpenClassName)})),x.globalContext.document&&this.addSecureEventListener(x.globalContext.document,"click",(o=>{if(t?.classList.contains(e.priorityNavigationOverflowOpenClassName)){const i=Boolean(o.target&&(0,x.getParents)(o.target).some((e=>t===e))),n=this.onUnfocusResponsiveMenu(o,i);(!0===n||!i&&!1!==n)&&t.classList.remove(e.priorityNavigationOverflowOpenClassName)}}))}for(const t of this.priorityNavigationDomNodes||[]){const i=(0,x.trailingThrottle)((()=>{if(!t.classList.contains(e.priorityNavigationOverflowOpenClassName)){t.classList.add(e.priorityNavigationOverflowResizingClassName);for(const o of t.querySelectorAll(e.priorityNavigationOverflowList))for(;o.firstChild;)o.removeChild(o.firstChild);t.classList.remove(this.options.selectors.priorityNavigationShowOverflowIndicatorClassName);for(const o of t.querySelectorAll("ul > li"))o.classList.contains(e.priorityNavigationOverflowIndicatorClassName)||o.classList.remove(e.priorityNavigationListItemHideClassName);o(),t.classList.remove(e.priorityNavigationOverflowResizingClassName)}}),20),n=new ResizeObserver(i);this.observerDeregisters.push((()=>{n.unobserve(t)})),n.observe(t)}o()}addMenuHighlighterViewTransition(){if(!x.globalContext.document)return;const e=document.createElement("style");e.type="text/css";e.appendChild(x.globalContext.document.createTextNode("\n .wu-priority-navigation\n .wu-priority-navigation__link--active::after {\n view-transition-name: wu-menu-highlight;\n }\n ")),x.globalContext.document.getElementsByTagName("head")[0].appendChild(e)}activateNavigationItemHighlighters(e){const t=this.options.selectors.activeNavigationItemClassName;for(const o of this.priorityNavigationDomNodes||[]){for(const e of o.querySelectorAll(`.${t}`))e.classList.remove(t);for(const i of o.querySelectorAll(`[href="#${e}"]`))i.classList.add(t)}}triggerNavigationItemHighlighterSwitching(e){x.globalContext.document?.startViewTransition?x.globalContext.document.startViewTransition((()=>{this.activateNavigationItemHighlighters(e)})):this.activateNavigationItemHighlighters(e)}async _onButtonClick(e){if(!1===await this.onButtonClick(e))return;const t=e.target,o=(0,x.getText)(t).join(" ");this._onTrack({event:"buttonClick",eventType:"click",label:o,reference:t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"button",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}async _onSectionSwitch(e,t,o){!1!==await this.onSectionSwitch(e,t,o)&&x.globalContext.window?.location&&await this._onTrack({event:"sectionSwitch",eventType:"sectionSwitch",label:e,reference:`${x.globalContext.window.location.pathname}#${e}`,subject:"url",userInteraction:!1})}async _onLinkClick(e){if(!1===await this.onLinkClick(e))return;const t=e.target,o=(0,x.getText)(t).join(" ");this._onTrack({event:"linkClick",eventType:"click",label:o,reference:t.getAttribute("href")||t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"link",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}async _onTrack(e){!1!==await this.onTrack(e)&&this.options.tracking&&x.globalContext.dataLayer?.push(e)}_onViewportMovesToTop(){this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;const o=()=>{t.removeEventListener("transitionend",i),t.removeEventListener("transitioncancel",o)},i=()=>{this.viewportIsOnTop&&t.classList.add("wu-top-settled"),o()};t.addEventListener("transitionend",i,{once:!0}),t.addEventListener("transitioncancel",o,{once:!0}),t.classList.add("wu-scroll-up")}}async _onViewportMovesAwayFromTop(){this._finishScrollToTopButtonTransition("wu-top-settled"),await(0,x.timeout)(),this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-scroll-down")}}async switchSection(e,t){if(x.globalContext.window&&"location"in x.globalContext.window&&(""===e||this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))){var o,i;const n=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,this.currentSectionName)?this.sectionDomNodes[this.currentSectionName]:null!==(o=this.sectionDomNodes.default)&&void 0!==o?o:null,r=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,e)?this.sectionDomNodes[e]:null!==(i=this.sectionDomNodes.default)&&void 0!==i?i:null;await this.self.switchSectionLock.acquire(),this.triggerNavigationItemHighlighterSwitching(e),E.debug(`Run section switch from "${this.currentSectionName}" to`,`"${e}".`),this.currentSectionName===e?(n&&(n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"))):this.options.sectionNames.unmanaged.includes(e)&&this.options.sectionNames.unmanaged.includes(this.currentSectionName)||((0,x.interruptableScrollTo)(),n&&(await(0,x.fadeOut)(n),n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),r&&(r.classList.remove("wu-section-inactive"),r.classList.add("wu-section-active"),await(0,x.fadeIn)(r)));const s=this.currentSectionName;this.currentSectionName=e;try{await this._onSectionSwitch(this.currentSectionName,s,t)}catch(e){E.warn("Problem due to call section switch callback on section",`"${this.currentSectionName}": ${(0,x.represent)(e)}`)}await this.self.switchSectionLock.release()}}_extendOptions(){this.setPropertyValue("options",(0,x.extend)(!0,{},this.self._defaultOptions,this.options))}_initializeRouting(){""===this.currentSectionName&&(this.currentSectionName=this.options.sectionNames.default),this._bindNavigationEvents();const e=x.globalContext.location?.hash&&x.globalContext.location.hash.substring(1);e&&(this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))&&(this.currentSectionName=e);for(const e of Object.values(this.sectionDomNodes))e.classList.add("wu-section-inactive");return this.switchSection(e||this.currentSectionName)}_finishScrollToTopButtonTransition(e=["wu-scroll-down","wu-scroll-up"]){for(const o of null!==(t=this.scrollToTopButtonDomNodes)&&void 0!==t?t:[]){var t;o.classList.remove(...[].concat(e))}}_bindScrollEvents(){if(x.globalContext.document)if(x.globalContext.window&&this.addSecureEventListener(x.globalContext.window,"scroll",(e=>{x.globalContext.window?.scrollY?this.viewportIsOnTop&&(this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then(this.onViewportMovesAwayFromTop.bind(this,e))):this.viewportIsOnTop||(this.viewportIsOnTop=!0,this._onViewportMovesToTop(),this.onViewportMovesToTop(e))})),x.globalContext.window?.scrollY)this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then((()=>{this.onViewportMovesAwayFromTop()}));else{this.viewportIsOnTop=!0;for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add("wu-top-settled")}this._onViewportMovesToTop(),this.onViewportMovesToTop()}}async _removeLoadingCover(){await(0,x.timeout)(this.options.additionalPageLoadingTimeInMilliseconds);for(const e of this.hostDomNode.querySelectorAll(`[class^="${this.options.selectors.startUpAnimationClassPrefix}"], [class*=" ${this.options.selectors.startUpAnimationClassPrefix}"]`))e.style.opacity="0";this.windowLoadingCoverDomNode&&await(0,x.fadeOut)(this.windowLoadingCoverDomNode)}async _performStartUpEffects(){const e=[];let t=1;for(;;){const o=this.hostDomNode.querySelectorAll("."+this.options.selectors.startUpAnimationClassPrefix+String(t));if(0===o.length){await Promise.all(e),this.startUpAnimationIsComplete=!0,this.onStartUpAnimationComplete();break}await(0,x.timeout)(this.options.startUpAnimationElementDelayInMilliseconds);for(const t of o){t.style.removeProperty("opacity");const o=(0,x.fadeIn)(t);e.push(o.then((()=>{o.resetStyles()})))}t+=1}}_bindNavigationEvents(){x.globalContext.window&&this.addSecureEventListener(x.globalContext.window,"hashchange",(e=>{if(this.startUpAnimationIsComplete){const t=location.hash.substring(1);this.switchSection(t,e)}})),this._bindScrollToTopButton()}_bindScrollToTopButton(){for(const e of this.scrollToTopButtonDomNodes||[])this.addSecureEventListener(e,"click",(e=>{e.preventDefault(),(0,x.interruptableScrollTo)()}))}_bindClickTracking(){if(this.options.tracking){for(const e of this.hostDomNode.querySelectorAll("a"))this.addSecureEventListener(e,"click",(e=>{this._onLinkClick(e)}));for(const e of this.hostDomNode.querySelectorAll("button"))this.addSecureEventListener(e,"click",(e=>{this._onButtonClick(e)}))}}},L._name="WebsiteUtilities",L._defaultOptions={additionalPageLoadingTimeInMilliseconds:0,startUpAnimationElementDelayInMilliseconds:100,windowLoadedTimeoutAfterDocLoadedInMSec:2e3,domain:"auto",sectionNames:{default:"",managed:["home"],unmanaged:[]},selectors:{windowLoadingCover:".wu-window-loading-cover",startUpAnimationClassPrefix:"wu-start-up-animation-number-",top:".wu-header",routerOutlet:".wu-router-outlet",scrollToTopButtons:".wu-scroll-to-top",priorityNavigationClassName:"wu-priority-navigation",priorityNavigationOverflowOpenClassName:"wu-priority-navigation--overflow-open",priorityNavigationShowOverflowIndicatorClassName:"wu-priority-navigation--show-overflow-indicator",priorityNavigationOverflowResizingClassName:"wu-priority-navigation--resizing",activeNavigationItemClassName:"wu-priority-navigation__link--active",priorityNavigationListItemHideClassName:"wu-priority-navigation__list__item--hide",priorityNavigationOverflowIndicatorClassName:"wu-priority-navigation__list__overflow-indicator",priorityNavigationOverflowList:".wu-priority-navigation__overflow-list"},minimumNumberOfMenuItems:3,tracking:!1},L.windowLoaded=!1,L.switchSectionLock=new x.Lock,h=L,m=k()(h.prototype,"options",[e],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),v=k()(h.prototype,"onStartUpAnimationComplete",[t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),w=k()(h.prototype,"onSwitchSection",[o],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),f=k()(h.prototype,"onViewportMovesAwayFromTop",[i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),g=k()(h.prototype,"onViewportMovesToTop",[n],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),b=k()(h.prototype,"onUnfocusResponsiveMenu",[r],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),y=k()(h.prototype,"onLoaded",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return x.NOOP}}),N=k()(h.prototype,"onButtonClick",[a],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),S=k()(h.prototype,"onSectionSwitch",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e,t,o){return Promise.resolve(void 0)}}}),T=k()(h.prototype,"onLinkClick",[u],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),C=k()(h.prototype,"onTrack",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),h);const M={component:P,register:(e=(0,x.camelCaseToDelimited)(P._name))=>{customElements.define(e,P)}},z=P;x.globalContext.AUTO_DEFINE_WEBSITE_UTILITIES&&M.register()})(),p})()));
1
+ "use strict";if("undefined"!=typeof module&&null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&"undefined"!=typeof __dirname&&null!==__dirname&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window="undefined"==typeof global||null===global?{}:global;!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator"));else if("function"==typeof define&&define.amd)define(["@babel/runtime/helpers/applyDecoratedDescriptor","@babel/runtime/helpers/initializerDefineProperty","@babel/runtime/helpers/initializerWarningHelper","clientnode","clientnode/property-types","web-component-wrapper/Web","web-component-wrapper/decorator"],t);else{var o="object"==typeof exports?t(require("@babel/runtime/helpers/applyDecoratedDescriptor"),require("@babel/runtime/helpers/initializerDefineProperty"),require("@babel/runtime/helpers/initializerWarningHelper"),require("clientnode"),require("clientnode/property-types"),require("web-component-wrapper/Web"),require("web-component-wrapper/decorator")):t(e["@babel/runtime/helpers/applyDecoratedDescriptor"],e["@babel/runtime/helpers/initializerDefineProperty"],e["@babel/runtime/helpers/initializerWarningHelper"],e.clientnode,e["clientnode/property-types"],e["web-component-wrapper/Web"],e["web-component-wrapper/decorator"]);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,((e,t,o,i,n,s,r)=>(()=>{var a=[,,,e=>{e.exports=t},t=>{t.exports=e},e=>{e.exports=o},e=>{e.exports=i},e=>{e.exports=n},e=>{e.exports=r},e=>{e.exports=s}],l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var o=l[e]={exports:{}};return a[e](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return(()=>{c.r(p),c.d(p,{WebsiteUtilities:()=>P,api:()=>M,default:()=>z,log:()=>E});var e,t,o,i,n,s,r,a,l,u,d,h,m,v,w,f,g,b,y,N,S,T,C,L,D=c(3),O=c.n(D),_=c(4),x=c.n(_),k=(c(5),c(6)),I=c(7),A=c(8),q=c(9);const E=new k.Logger({name:"website-utilities"});let P=(e=(0,A.property)({type:I.object}),t=(0,A.property)({type:I.func}),o=(0,A.property)({type:I.func}),i=(0,A.property)({type:I.func}),n=(0,A.property)({type:I.func}),s=(0,A.property)({type:I.func}),r=(0,A.property)({type:I.func}),a=(0,A.property)({type:I.func}),l=(0,A.property)({type:I.func}),u=(0,A.property)({type:I.func}),d=(0,A.property)({type:I.func}),L=class e extends q.Web{constructor(){super(),this.self=e,O()(this,"options",m,this),O()(this,"onStartUpAnimationComplete",v,this),O()(this,"onSwitchSection",w,this),O()(this,"onViewportMovesAwayFromTop",f,this),O()(this,"onViewportMovesToTop",g,this),O()(this,"onUnfocusResponsiveMenu",b,this),O()(this,"onLoaded",y,this),O()(this,"onButtonClick",N,this),O()(this,"onSectionSwitch",S,this),O()(this,"onLinkClick",T,this),O()(this,"onTrack",C,this),this.currentSectionName="",this.startUpAnimationIsComplete=!1,this.viewportIsOnTop=void 0,this.observerDeregisters=[],this.windowLoadingCoverDomNode=null,this.topDomNode=null,this.priorityNavigationDomNodes=null,this.routerOutletDomNode=null,this.sectionDomNodes={},this.scrollToTopButtonDomNodes=null,this.defineGetterAndSetterInterface()}async onUpdateAttribute(e,t){await super.onUpdateAttribute(e,t),"options"===e&&this._extendOptions()}async render(e="unknown",t=!0){if(await super.render(e,!1),0===Object.keys(this.options).length&&this._extendOptions(),this.disableScrolling(),!this.self.windowLoaded){const e=()=>{this.self.windowLoaded||(this.self.windowLoaded=!0,this._removeLoadingCover().then((()=>{this.enableScrolling(),this._performStartUpEffects().then((()=>{this.addMenuHighlighterViewTransition()})),this.onLoaded()})))};(0,k.onDocumentReady)((()=>{(0,k.timeout)(e,this.options.windowLoadedTimeoutAfterDocLoadedInMSec)})),k.globalContext.window&&this.addSecureEventListener(k.globalContext.window,"load",e)}await this.waitForNestedComponentRendering(),this.grabDomNodes(),this._bindScrollEvents(),this._bindClickTracking(),await this._initializeRouting(),this.initializePriorityNavigation(),await this.resolveRenderingPromiseIfSet(e,t)}unRender(e="unknown",t){super.unRender(e,t);for(const e of this.observerDeregisters)e()}grabDomNodes(){var e,t,o;this.topDomNode=this.hostDomNode.querySelector(this.options.selectors.top),this.scrollToTopButtonDomNodes=this.hostDomNode.querySelectorAll(this.options.selectors.scrollToTopButtons),this.priorityNavigationDomNodes=this.hostDomNode.querySelectorAll(`.${this.options.selectors.priorityNavigationClassName}`),this.routerOutletDomNode=this.hostDomNode.querySelector(this.options.selectors.routerOutlet);for(const e of null!==(i=this.routerOutletDomNode?.children)&&void 0!==i?i:[]){var i;const t=e.getAttribute("data-website-utilities-section");""===t?this.sectionDomNodes.default=e:t&&this.options.sectionNames.managed.includes(t)&&(this.sectionDomNodes[t]=e)}this.windowLoadingCoverDomNode=null!==(e=null!==(t=null!==(o=this.hostDomNode.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==o?o:this.hostDomNode.parentElement?.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==t?t:k.globalContext.document?.body.querySelector(this.options.selectors.windowLoadingCover))&&void 0!==e?e:null}disableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.add("wu-disable-scrolling"),this.addSecureEventListener(this.hostDomNode.parentElement,"touchmove",k.preventDefault))}enableScrolling(){this.hostDomNode.parentElement&&(this.hostDomNode.parentElement.classList.remove("wu-disable-scrolling"),this.hostDomNode.parentElement.classList.remove("touchmove"),this.hostDomNode.parentElement.removeEventListener("touchmove",k.preventDefault))}async track(e){if(k.globalContext.window?.location&&this.options.tracking){const t={context:`${k.globalContext.window.location.pathname}#`+this.currentSectionName,...e};("number"!=typeof t.value||isNaN(t.value))&&(t.value=1),E.debug('Run tracking code: "event" with arguments:'),E.debug(t);try{await this._onTrack(t)}catch(e){E.warn(`Problem in tracking "${(0,k.represent)(t)}":`,(0,k.represent)(e))}}}initializePriorityNavigation(){const{selectors:e}=this.options,t=e.priorityNavigationOverflowIndicatorClassName;if(0===this.priorityNavigationDomNodes?.length)return;for(const t of this.priorityNavigationDomNodes||[])for(const o of t.querySelectorAll(`[href="#${this.currentSectionName}"]`))o.classList.add(e.activeNavigationItemClassName);const o=()=>{for(const o of this.priorityNavigationDomNodes||[]){const i=o.querySelectorAll("ul > li"),n=Array.from(i).filter((e=>!e.classList.contains(t))),s=i[0].offsetTop;let r=[];for(const e of n){e.offsetTop!==s&&r.push(e)}n.length-r.length<this.options.minimumNumberOfMenuItems&&(r=n.slice());const a=o.querySelector(`.${t}`);if(r.length){const t=r.map((e=>{const t=e.cloneNode(!0);for(const e of t.querySelectorAll("[style]"))e.removeAttribute("style");return t}));for(const t of r)t.classList.add(e.priorityNavigationListItemHideClassName);const i=o.querySelector(e.priorityNavigationOverflowList);if(i)for(const e of t)i.append(e);if(a){const e=this.options.selectors.priorityNavigationShowOverflowIndicatorClassName;o.classList.add(e)}}else a&&o.classList.remove(this.options.selectors.priorityNavigationShowOverflowIndicatorClassName)}};for(const o of this.hostDomNode.querySelectorAll(`.${t}`)){const t=o.closest(`.${e.priorityNavigationClassName}`);this.addSecureEventListener(o,"click",(()=>{t?.classList.toggle(e.priorityNavigationOverflowOpenClassName)})),k.globalContext.document&&this.addSecureEventListener(k.globalContext.document,"click",(o=>{if(t?.classList.contains(e.priorityNavigationOverflowOpenClassName)){const i=Boolean(o.target&&(0,k.getParents)(o.target).some((e=>t===e))),n=this.onUnfocusResponsiveMenu(o,i);(!0===n||!i&&!1!==n)&&t.classList.remove(e.priorityNavigationOverflowOpenClassName)}}))}for(const t of this.priorityNavigationDomNodes||[]){const i=(0,k.trailingThrottle)((()=>{if(!t.classList.contains(e.priorityNavigationOverflowOpenClassName)){t.classList.add(e.priorityNavigationOverflowResizingClassName);for(const o of t.querySelectorAll(e.priorityNavigationOverflowList))for(;o.firstChild;)o.removeChild(o.firstChild);t.classList.remove(this.options.selectors.priorityNavigationShowOverflowIndicatorClassName);for(const o of t.querySelectorAll("ul > li"))o.classList.contains(e.priorityNavigationOverflowIndicatorClassName)||o.classList.remove(e.priorityNavigationListItemHideClassName);o(),t.classList.remove(e.priorityNavigationOverflowResizingClassName)}}),20),n=new ResizeObserver(i);this.observerDeregisters.push((()=>{n.unobserve(t)})),n.observe(t)}o()}addMenuHighlighterViewTransition(){if(!k.globalContext.document)return;const e=document.createElement("style");e.type="text/css";e.appendChild(k.globalContext.document.createTextNode("\n .wu-priority-navigation\n .wu-priority-navigation__link--active::after {\n view-transition-name: wu-menu-highlight;\n }\n ")),k.globalContext.document.getElementsByTagName("head")[0].appendChild(e)}activateNavigationItemHighlighters(e){const t=this.options.selectors.activeNavigationItemClassName;for(const o of this.priorityNavigationDomNodes||[]){for(const e of o.querySelectorAll(`.${t}`))e.classList.remove(t);for(const i of o.querySelectorAll(`[href="#${e}"]`))i.classList.add(t)}}triggerNavigationItemHighlighterSwitching(e){k.globalContext.document?.startViewTransition?k.globalContext.document.startViewTransition((()=>{this.activateNavigationItemHighlighters(e)})):this.activateNavigationItemHighlighters(e)}async _onButtonClick(e){if(!1===await this.onButtonClick(e))return;const t=e.target,o=(0,k.getText)(t).join(" ");this._onTrack({event:"buttonClick",eventType:"click",label:o,reference:t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"button",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}async _onSectionSwitch(e,t,o){!1!==await this.onSectionSwitch(e,t,o)&&k.globalContext.window?.location&&await this._onTrack({event:"sectionSwitch",eventType:"sectionSwitch",label:e,reference:`${k.globalContext.window.location.pathname}#${e}`,subject:"url",userInteraction:!1})}async _onLinkClick(e){if(!1===await this.onLinkClick(e))return;const t=e.target,o=(0,k.getText)(t).join(" ");this._onTrack({event:"linkClick",eventType:"click",label:o,reference:t.getAttribute("href")||t.getAttribute("action")||t.getAttribute("target")||t.getAttribute("type")||o,subject:"link",value:parseInt(t.getAttribute("website-analytics-value")||"1"),userInteraction:!0})}async _onTrack(e){!1!==await this.onTrack(e)&&this.options.tracking&&k.globalContext.dataLayer?.push(e)}_onViewportMovesToTop(){this._finishScrollToTopButtonTransition();for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;const o=()=>{t.removeEventListener("transitionend",i),t.removeEventListener("transitioncancel",o)},i=()=>{this.viewportIsOnTop&&t.classList.add(this.options.selectors.scrollToTopScrollTopSettledStateClassName),o()};t.addEventListener("transitionend",i,{once:!0}),t.addEventListener("transitioncancel",o,{once:!0}),t.classList.add(this.options.selectors.scrollToTopScrollUpStateClassName)}}async _onViewportMovesAwayFromTop(){for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.remove(this.options.selectors.scrollToTopScrollTopSettledStateClassName)}await(0,k.timeout)(),this._finishScrollToTopButtonTransition();for(const e of null!==(t=this.scrollToTopButtonDomNodes)&&void 0!==t?t:[]){var t;e.classList.add(this.options.selectors.scrollToTopScrollDownStateClassName)}}async switchSection(e,t){if(k.globalContext.window&&"location"in k.globalContext.window&&(""===e||this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))){var o,i;const n=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,this.currentSectionName)?this.sectionDomNodes[this.currentSectionName]:null!==(o=this.sectionDomNodes.default)&&void 0!==o?o:null,s=Object.prototype.hasOwnProperty.call(this.sectionDomNodes,e)?this.sectionDomNodes[e]:null!==(i=this.sectionDomNodes.default)&&void 0!==i?i:null;await this.self.switchSectionLock.acquire(),this.triggerNavigationItemHighlighterSwitching(e),E.debug(`Run section switch from "${this.currentSectionName}" to`,`"${e}".`),this.currentSectionName===e?(n&&(n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),s&&(s.classList.remove("wu-section-inactive"),s.classList.add("wu-section-active"))):this.options.sectionNames.unmanaged.includes(e)&&this.options.sectionNames.unmanaged.includes(this.currentSectionName)||((0,k.interruptableScrollTo)(),n&&(await(0,k.fadeOut)(n),n.classList.remove("wu-section-active"),n.classList.add("wu-section-inactive")),s&&(s.classList.remove("wu-section-inactive"),s.classList.add("wu-section-active"),await(0,k.fadeIn)(s)));const r=this.currentSectionName;this.currentSectionName=e;try{await this._onSectionSwitch(this.currentSectionName,r,t)}catch(e){E.warn("Problem due to call section switch callback on section",`"${this.currentSectionName}": ${(0,k.represent)(e)}`)}await this.self.switchSectionLock.release()}}_extendOptions(){this.setPropertyValue("options",(0,k.extend)(!0,{},this.self._defaultOptions,this.options))}_initializeRouting(){""===this.currentSectionName&&(this.currentSectionName=this.options.sectionNames.default),this._bindNavigationEvents();const e=k.globalContext.location?.hash&&k.globalContext.location.hash.substring(1);e&&(this.options.sectionNames.managed.includes(e)||this.options.sectionNames.unmanaged.includes(e))&&(this.currentSectionName=e);for(const e of Object.values(this.sectionDomNodes))e.classList.add("wu-section-inactive");return this.switchSection(e||this.currentSectionName)}_finishScrollToTopButtonTransition(){for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.remove(this.options.selectors.scrollToTopScrollUpStateClassName,this.options.selectors.scrollToTopScrollDownStateClassName)}}_bindScrollEvents(){if(k.globalContext.document)if(k.globalContext.window&&this.addSecureEventListener(k.globalContext.window,"scroll",(e=>{k.globalContext.window?.scrollY?this.viewportIsOnTop&&(this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then(this.onViewportMovesAwayFromTop.bind(this,e))):this.viewportIsOnTop||(this.viewportIsOnTop=!0,this._onViewportMovesToTop(),this.onViewportMovesToTop(e))})),k.globalContext.window?.scrollY)this.viewportIsOnTop=!1,this._onViewportMovesAwayFromTop().then((()=>{this.onViewportMovesAwayFromTop()}));else{this.viewportIsOnTop=!0;for(const t of null!==(e=this.scrollToTopButtonDomNodes)&&void 0!==e?e:[]){var e;t.classList.add(this.options.selectors.scrollToTopScrollTopSettledStateClassName)}this._onViewportMovesToTop(),this.onViewportMovesToTop()}}async _removeLoadingCover(){await(0,k.timeout)(this.options.additionalPageLoadingTimeInMilliseconds);for(const e of this.hostDomNode.querySelectorAll(`[class^="${this.options.selectors.startUpAnimationClassPrefix}"], [class*=" ${this.options.selectors.startUpAnimationClassPrefix}"]`))e.style.opacity="0";this.windowLoadingCoverDomNode&&await(0,k.fadeOut)(this.windowLoadingCoverDomNode)}async _performStartUpEffects(){const e=[];let t=1;for(;;){const o=this.hostDomNode.querySelectorAll("."+this.options.selectors.startUpAnimationClassPrefix+String(t));if(0===o.length){await Promise.all(e),this.startUpAnimationIsComplete=!0,this.onStartUpAnimationComplete();break}await(0,k.timeout)(this.options.startUpAnimationElementDelayInMilliseconds);for(const t of o){t.style.removeProperty("opacity");const o=(0,k.fadeIn)(t);e.push(o.then((()=>{o.resetStyles()})))}t+=1}}_bindNavigationEvents(){k.globalContext.window&&this.addSecureEventListener(k.globalContext.window,"hashchange",(e=>{if(this.startUpAnimationIsComplete){const t=location.hash.substring(1);this.switchSection(t,e)}})),this._bindScrollToTopButton()}_bindScrollToTopButton(){for(const e of this.scrollToTopButtonDomNodes||[])this.addSecureEventListener(e,"click",(e=>{e.preventDefault(),(0,k.interruptableScrollTo)()}))}_bindClickTracking(){if(this.options.tracking){for(const e of this.hostDomNode.querySelectorAll("a"))this.addSecureEventListener(e,"click",(e=>{this._onLinkClick(e)}));for(const e of this.hostDomNode.querySelectorAll("button"))this.addSecureEventListener(e,"click",(e=>{this._onButtonClick(e)}))}}},L._name="WebsiteUtilities",L._defaultOptions={additionalPageLoadingTimeInMilliseconds:0,startUpAnimationElementDelayInMilliseconds:100,windowLoadedTimeoutAfterDocLoadedInMSec:2e3,domain:"auto",sectionNames:{default:"",managed:["home"],unmanaged:[]},selectors:{windowLoadingCover:".wu-window-loading-cover",startUpAnimationClassPrefix:"wu-start-up-animation-number-",top:".wu-header",routerOutlet:".wu-router-outlet",scrollToTopButtons:".wu-scroll-to-top",scrollToTopScrollTopSettledStateClassName:"wu-top-settled",scrollToTopScrollUpStateClassName:"wu-scroll-up",scrollToTopScrollDownStateClassName:"wu-scroll-down",priorityNavigationClassName:"wu-priority-navigation",priorityNavigationOverflowOpenClassName:"wu-priority-navigation--overflow-open",priorityNavigationShowOverflowIndicatorClassName:"wu-priority-navigation--show-overflow-indicator",priorityNavigationOverflowResizingClassName:"wu-priority-navigation--resizing",activeNavigationItemClassName:"wu-priority-navigation__link--active",priorityNavigationListItemHideClassName:"wu-priority-navigation__list__item--hide",priorityNavigationOverflowIndicatorClassName:"wu-priority-navigation__list__overflow-indicator",priorityNavigationOverflowList:".wu-priority-navigation__overflow-list"},minimumNumberOfMenuItems:3,tracking:!1},L.windowLoaded=!1,L.switchSectionLock=new k.Lock,h=L,m=x()(h.prototype,"options",[e],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),v=x()(h.prototype,"onStartUpAnimationComplete",[t],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),w=x()(h.prototype,"onSwitchSection",[o],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),f=x()(h.prototype,"onViewportMovesAwayFromTop",[i],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),g=x()(h.prototype,"onViewportMovesToTop",[n],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),b=x()(h.prototype,"onUnfocusResponsiveMenu",[s],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),y=x()(h.prototype,"onLoaded",[r],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return k.NOOP}}),N=x()(h.prototype,"onButtonClick",[a],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),S=x()(h.prototype,"onSectionSwitch",[l],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e,t,o){return Promise.resolve(void 0)}}}),T=x()(h.prototype,"onLinkClick",[u],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),C=x()(h.prototype,"onTrack",[d],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return function(e){return Promise.resolve(void 0)}}}),h);const M={component:P,register:(e=(0,k.camelCaseToDelimited)(P._name))=>{customElements.define(e,P)}},z=P;k.globalContext.AUTO_DEFINE_WEBSITE_UTILITIES&&M.register()})(),p})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "website-utilities",
3
- "version": "1.0.440",
3
+ "version": "1.0.442",
4
4
  "description": "extend your web app",
5
5
  "keywords": [
6
6
  "website",
@@ -98,8 +98,8 @@
98
98
  "stylelint": "^17.13.0",
99
99
  "stylelint-config-standard-scss": "^17.0.0",
100
100
  "typescript-eslint": "^8.61.0",
101
- "web-component-wrapper": "^0.0.593",
102
- "web-documentation": "^1.0.31",
101
+ "web-component-wrapper": "^0.0.596",
102
+ "web-documentation": "^1.0.32",
103
103
  "weboptimizer": "^3.0.24",
104
104
  "webpack-dev-server": "^5.2.4"
105
105
  },
package/type.d.ts CHANGED
@@ -14,6 +14,9 @@ export interface DefaultOptions {
14
14
  top: string;
15
15
  routerOutlet: string;
16
16
  scrollToTopButtons: string;
17
+ scrollToTopScrollTopSettledStateClassName: string;
18
+ scrollToTopScrollUpStateClassName: string;
19
+ scrollToTopScrollDownStateClassName: string;
17
20
  priorityNavigationClassName: string;
18
21
  priorityNavigationOverflowOpenClassName: string;
19
22
  priorityNavigationShowOverflowIndicatorClassName: string;