@graupl/navigation-shelf 1.0.0-beta.20 → 1.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- var NavigationShelfGenerator=(function(){function A(e,t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${s}" given.`)}for(const s in t)if(!(t[s]instanceof e)){const i=typeof t[s];throw new TypeError(`${s} must be an instance of ${e.name}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function o(e,t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidType() must be inside of an object. "${s}" given.`)}for(const s in t){const i=typeof t[s];if(i!==e)throw new TypeError(`${s} must be a ${e}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function z(e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${t}" given.`)}for(const t in e)try{if(e[t]===null)throw new Error;document.querySelector(e[t])}catch{throw new TypeError(`${t} must be a valid query selector. "${e[t]}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(e){try{if(typeof e!="object"||Array.isArray(e)){const t=typeof e;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!=="string")if(Array.isArray(e[t]))e[t].forEach(i=>{if(typeof i!="string")throw new TypeError(`${t} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${t} must be a string or an array of strings. "${s}" given.`);else{const i={};i[t]=e[t],z(i)}}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function H(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidState() must be inside of an object. "${s}" given.`)}const t=["none","self","child"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function O(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${s}" given.`)}const t=["none","mouse","keyboard","character"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function j(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidSideType() must be inside of an object. "${s}" given.`)}const t=["left","right"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(e){try{const t=e.key||e.keyCode,s={Enter:t==="Enter"||t===13,Space:t===" "||t==="Spacebar"||t===32,Escape:t==="Escape"||t==="Esc"||t===27,ArrowUp:t==="ArrowUp"||t==="Up"||t===38,ArrowRight:t==="ArrowRight"||t==="Right"||t===39,ArrowDown:t==="ArrowDown"||t==="Down"||t===40,ArrowLeft:t==="ArrowLeft"||t==="Left"||t===37,Home:t==="Home"||t===36,End:t==="End"||t===35,Tab:t==="Tab"||t===9};return Object.keys(s).find(i=>s[i]===!0)||""}catch{return""}}function f(e){e.preventDefault(),e.stopPropagation()}function n(e,t){e===""||e.length===0||(typeof e=="string"?t.classList.add(e):t.classList.add(...e))}function l(e,t){e===""||e.length===0||(typeof e=="string"?t.classList.remove(e):t.classList.remove(...e))}function x(e=document){return Array.from(e.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]")).filter(t=>{let s=!0;return t.getAttribute("tabindex")==="-1"&&(s=!1),s})}function q(e=document){return x(e)[0]||!1}function F(e=null){window.Graupl=window.Graupl||{},o("string",{type:e})&&(window.Graupl[e]=window.Graupl[e]||{})}function V(e=null){return o("string",{type:e})?window.Graupl[e]:window.Graupl}function G(e,t={}){o("string",{type:e})&&o("object",{data:t})&&(window.Graupl[e]=t)}function M(e){o("string",{type:e})&&(window.Graupl[e]={})}function N(e,t,s){o("string",{type:e,key:t})&&(window.Graupl[e][t]=s)}function R(e,t){return o("string",{type:e,key:t})?window.Graupl[e][t]:null}function B(e,t){o("string",{type:e,key:t})&&delete window.Graupl[e][t]}var L={initializeStorage:F,getStorage:V,setStorage:G,clearStorage:M,pushToStorage:N,getFromStorage:R,removeFromStorage:B},D=class{constructor(e,t={}){this._equals=t.equals||Object.is,this._current=e,this._committed=e}get value(){return this._current}set value(e){this._current=e}get committed(){return this._committed}get isDirty(){return!this._equals(this._current,this._committed)}commit(){return this._committed=this._current,this}reset(){return this._current=this._committed,this}update(e){return this._current=e(this._current),this}},I=class{_dom={shelf:null,controller:null,lockController:null,hoverController:null,sideController:null,dependents:[]};_selectors={dependents:""};_classes={locked:"locked",unlocked:"unlocked",hover:"hoverable",noHover:"not-hoverable",left:"left-side",right:"right-side",open:"show",close:"hide",transistion:"transitioning",initialize:"initializing"};_durations={transition:250,open:-1,close:-1};_delays={hover:250,enter:-1,leave:-1};_focusState="none";_currentEvent="none";_hover=!1;_hoverTimeout=null;_locked=new D(!1);_softLocked=!1;_side="left";_otherSide="right";_open=!1;_breakpointWidth=1180;_observer=null;_expandEvent=new CustomEvent("grauplNavigationShelfExpand",{bubbles:!0,detail:{shelf:this}});_collapseEvent=new CustomEvent("grauplNavigationShelfCollapse",{bubbles:!0,detail:{shelf:this}});_lockEvent=new CustomEvent("grauplNavigationShelfLock",{bubbles:!0,detail:{shelf:this}});_unlockEvent=new CustomEvent("grauplNavigationShelfUnlock",{bubbles:!0,detail:{shelf:this}});_shiftEvent=new CustomEvent("grauplNavigationShelfShift",{bubbles:!0,detail:{shelf:this}});_enableHoverEvent=new CustomEvent("grauplNavigationShelfEnableHoverable",{bubbles:!0,detail:{shelf:this}});_disableHoverEvent=new CustomEvent("grauplNavigationShelfDisableHover",{bubbles:!0,detail:{shelf:this}});_initialized=!1;_prefix="graupl-";_key="";_errors=[];constructor({shelfElement:e,controllerElement:t,lockControllerElement:s,hoverControllerElement:i,sideControllerElement:r,dependentSelector:a=".shelf-aware",lockedClass:p="locked",unlockedClass:g="unlocked",hoverClass:v="hoverable",noHoverClass:y="not-hoverable",leftClass:k="left-side",rightClass:b="right-side",openClass:E="show",closeClass:h="hide",transitionClass:J="transitioning",transitionDuration:X=250,openDuration:Y=-1,closeDuration:Z=-1,hover:ee=!1,hoverDelay:te=250,enterDelay:se=-1,leaveDelay:ie=-1,locked:oe=!1,side:re="left",prefix:ne="graupl-",initializeClass:le="initializing",initialize:he=!1}={}){this._dom.shelf=e,this._dom.controller=t||null,this._dom.lockController=s||null,this._dom.hoverController=i||null,this._dom.sideController=r||null,this._selectors.dependents=a,this._classes.locked=p||"",this._classes.unlocked=g||"",this._classes.hover=v||"",this._classes.noHover=y||"",this._classes.left=k||"",this._classes.right=b||"",this._classes.open=E||"",this._classes.close=h||"",this._classes.transition=J||"",this._classes.initialize=le||"",this._durations.transition=X,this._durations.open=Y,this._durations.close=Z,this._locked=new D(oe),this._side=re,this._prefix=ne||"",this._hover=ee,this._delays.hover=te,this._delays.enter=se,this._delays.leave=ie,he&&this.initialize()}initialize(){try{if(!this._validate())throw new Error(`Graupl Navigation Shelf: cannot initialize navigation shelf. The following errors have been found:
1
+ var NavigationShelfGenerator=(function(){function A(e,t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${s}" given.`)}for(const s in t)if(!(t[s]instanceof e)){const i=typeof t[s];throw new TypeError(`${s} must be an instance of ${e.name}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function r(e,t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidType() must be inside of an object. "${s}" given.`)}for(const s in t){const i=typeof t[s];if(i!==e)throw new TypeError(`${s} must be a ${e}. "${i}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function z(e){try{if(typeof e!="object"){const t=typeof e;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${t}" given.`)}for(const t in e)try{if(e[t]===null)throw new Error;document.querySelector(e[t])}catch{throw new TypeError(`${t} must be a valid query selector. "${e[t]}" given.`)}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function c(e){try{if(typeof e!="object"||Array.isArray(e)){const t=typeof e;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${t}" given.`)}for(const t in e){const s=typeof e[t];if(s!=="string")if(Array.isArray(e[t]))e[t].forEach(i=>{if(typeof i!="string")throw new TypeError(`${t} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${t} must be a string or an array of strings. "${s}" given.`);else{const i={};i[t]=e[t],z(i)}}return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function H(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidState() must be inside of an object. "${s}" given.`)}const t=["none","self","child"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function O(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${s}" given.`)}const t=["none","mouse","keyboard","character"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function j(e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidSideType() must be inside of an object. "${s}" given.`)}const t=["left","right"];for(const s in e)if(!t.includes(e[s]))throw new TypeError(`${s} must be one of the following values: ${t.join(", ")}. "${e[s]}" given.`);return{status:!0,error:null}}catch(t){return{status:!1,error:t}}}function d(e){try{const t=e.key||e.keyCode,s={Enter:t==="Enter"||t===13,Space:t===" "||t==="Spacebar"||t===32,Escape:t==="Escape"||t==="Esc"||t===27,ArrowUp:t==="ArrowUp"||t==="Up"||t===38,ArrowRight:t==="ArrowRight"||t==="Right"||t===39,ArrowDown:t==="ArrowDown"||t==="Down"||t===40,ArrowLeft:t==="ArrowLeft"||t==="Left"||t===37,Home:t==="Home"||t===36,End:t==="End"||t===35,Tab:t==="Tab"||t===9};return Object.keys(s).find(i=>s[i]===!0)||""}catch{return""}}function f(e){e.preventDefault(),e.stopPropagation()}function n(e,t){e===""||e.length===0||(typeof e=="string"?t.classList.add(e):t.classList.add(...e))}function l(e,t){e===""||e.length===0||(typeof e=="string"?t.classList.remove(e):t.classList.remove(...e))}function x(e=document){return Array.from(e.querySelectorAll("a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]")).filter(t=>{let s=!0;return t.getAttribute("tabindex")==="-1"&&(s=!1),s})}function q(e=document){return x(e)[0]||!1}function F(e=null){window.Graupl=window.Graupl||{},r("string",{type:e})&&(window.Graupl[e]=window.Graupl[e]||{})}function V(e=null){return r("string",{type:e})?window.Graupl[e]:window.Graupl}function G(e,t={}){r("string",{type:e})&&r("object",{data:t})&&(window.Graupl[e]=t)}function M(e){r("string",{type:e})&&(window.Graupl[e]={})}function N(e,t,s){r("string",{type:e,key:t})&&(window.Graupl[e][t]=s)}function R(e,t){return r("string",{type:e,key:t})?window.Graupl[e][t]:null}function B(e,t){r("string",{type:e,key:t})&&delete window.Graupl[e][t]}var L={initializeStorage:F,getStorage:V,setStorage:G,clearStorage:M,pushToStorage:N,getFromStorage:R,removeFromStorage:B},D=class{constructor(e,t={}){this._equals=t.equals||Object.is,this._current=e,this._committed=e}get value(){return this._current}set value(e){this._current=e}get committed(){return this._committed}get isDirty(){return!this._equals(this._current,this._committed)}commit(){return this._committed=this._current,this}reset(){return this._current=this._committed,this}update(e){return this._current=e(this._current),this}},I=class{_dom={shelf:null,controller:null,lockController:null,hoverController:null,sideController:null,dependents:[]};_selectors={dependents:""};_classes={locked:"locked",unlocked:"unlocked",hover:"hoverable",noHover:"not-hoverable",left:"left-side",right:"right-side",open:"show",close:"hide",transistion:"transitioning",initialize:"initializing"};_durations={transition:250,open:-1,close:-1};_delays={hover:250,enter:-1,leave:-1};_focusState="none";_currentEvent="none";_hover=!1;_hoverTimeout=null;_locked=new D(!1);_softLocked=!1;_side="left";_otherSide="right";_open=!1;_breakpointWidth=1180;_observer=null;_expandEvent=new CustomEvent("grauplNavigationShelfExpand",{bubbles:!0,detail:{shelf:this}});_collapseEvent=new CustomEvent("grauplNavigationShelfCollapse",{bubbles:!0,detail:{shelf:this}});_lockEvent=new CustomEvent("grauplNavigationShelfLock",{bubbles:!0,detail:{shelf:this}});_unlockEvent=new CustomEvent("grauplNavigationShelfUnlock",{bubbles:!0,detail:{shelf:this}});_shiftEvent=new CustomEvent("grauplNavigationShelfShift",{bubbles:!0,detail:{shelf:this}});_enableHoverEvent=new CustomEvent("grauplNavigationShelfEnableHoverable",{bubbles:!0,detail:{shelf:this}});_disableHoverEvent=new CustomEvent("grauplNavigationShelfDisableHover",{bubbles:!0,detail:{shelf:this}});_initialized=!1;_prefix="graupl-";_key="";_errors=[];constructor({shelfElement:e,controllerElement:t,lockControllerElement:s,hoverControllerElement:i,sideControllerElement:o,dependentSelector:a=".shelf-aware",lockedClass:u="locked",unlockedClass:g="unlocked",hoverClass:v="hoverable",noHoverClass:y="not-hoverable",leftClass:k="left-side",rightClass:b="right-side",openClass:E="show",closeClass:h="hide",transitionClass:J="transitioning",transitionDuration:X=250,openDuration:Y=-1,closeDuration:Z=-1,hover:ee=!1,hoverDelay:te=250,enterDelay:se=-1,leaveDelay:ie=-1,locked:oe=!1,side:re="left",prefix:ne="graupl-",initializeClass:le="initializing",initialize:he=!1}={}){this._dom.shelf=e,this._dom.controller=t||null,this._dom.lockController=s||null,this._dom.hoverController=i||null,this._dom.sideController=o||null,this._selectors.dependents=a,this._classes.locked=u||"",this._classes.unlocked=g||"",this._classes.hover=v||"",this._classes.noHover=y||"",this._classes.left=k||"",this._classes.right=b||"",this._classes.open=E||"",this._classes.close=h||"",this._classes.transition=J||"",this._classes.initialize=le||"",this._durations.transition=X,this._durations.open=Y,this._durations.close=Z,this._locked=new D(oe),this._side=re,this._prefix=ne||"",this._hover=ee,this._delays.hover=te,this._delays.enter=se,this._delays.leave=ie,he&&this.initialize()}initialize(){try{if(!this._validate())throw new Error(`Graupl Navigation Shelf: cannot initialize navigation shelf. The following errors have been found:
2
2
  - ${this.errors.join(`
3
- - `)}`);this._setTransitionDurations(),this._generateKey(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this._handleResize(),this.dom.controller.getAttribute("aria-expanded")==="true"||this.isLocked?(this._expand(!1,!1),this.isLocked&&this._lock(!1)):this._collapse(!1,!1),this.hover?this._enableHover(!1):this._disableHover(!1),this._shiftSide(!1),L.initializeStorage("navigation-shelves"),L.pushToStorage("navigation-shelves",this.dom.shelf.id,this),this._initialized=!0}catch(e){console.error(e)}}get dom(){return this._dom}get selectors(){return this._selectors}get lockedClass(){return this._classes.locked}set lockedClass(e){c({lockedClass:e}),this._classes.locked!==e&&(this._classes.locked=e)}get unlockedClass(){return this._classes.unlocked}set unlockedClass(e){c({unlockedClass:e}),this._classes.unlocked!==e&&(this._classes.unlocked=e)}get hoverClass(){return this._classes.hover}set hoverClass(e){c({hoverClass:e}),this._classes.hover!==e&&(this._classes.hover=e)}get noHoverClass(){return this._classes.noHover}set noHoverClass(e){c({noHoverClass:e}),this._classes.noHover!==e&&(this._classes.noHover=e)}get leftClass(){return this._classes.left}set leftClass(e){c({leftClass:e}),this._classes.left!==e&&(this._classes.left=e)}get rightClass(){return this._classes.right}set rightClass(e){c({rightClass:e}),this._classes.right!==e&&(this._classes.right=e)}get openClass(){return this._classes.open}set openClass(e){c({openClass:e}),this._classes.open!==e&&(this._classes.open=e)}get closeClass(){return this._classes.close}set closeClass(e){c({closeClass:e}),this._classes.close!==e&&(this._classes.close=e)}get transitionClass(){return this._classes.transition}set transitionClass(e){c({transitionClass:e}),this._classes.transition!==e&&(this._classes.transition=e)}get initializeClass(){return this._classes.initialize}set initializeClass(e){c({initializeClass:e}),this._classes.initialize!==e&&(this._classes.initialize=e)}get transitionDuration(){return this._durations.transition}set transitionDuration(e){o("number",{value:e}),this._durations.transition!==e&&(this._durations.transition=e,this._setTransitionDurations())}get openDuration(){return this._durations.open===-1?this.transitionDuration:this._durations.open}set openDuration(e){o("number",{value:e}),this._durations.open!==e&&(this._durations.open=e,this._setTransitionDurations())}get closeDuration(){return this._durations.close===-1?this.transitionDuration:this._durations.close}set closeDuration(e){o("number",{value:e}),this._durations.close!==e&&(this._durations.close=e,this._setTransitionDurations())}get focusState(){return this._focusState}set focusState(e){H({value:e}),this._focusState!==e&&(this._focusState=e)}get currentEvent(){return this._currentEvent}set currentEvent(e){O({value:e}),this._currentEvent!==e&&(this._currentEvent=e)}get hover(){return this._hover}get hoverDelay(){return this._delays.hover}set hoverDelay(e){o("number",{value:e}),this._delays.hover!==e&&(this._delays.hover=e)}get enterDelay(){return this._delays.enter===-1?this.hoverDelay:this._delays.enter}set enterDelay(e){o("number",{value:e}),this._delays.enter!==e&&(this._delays.enter=e)}get leaveDelay(){return this._delays.leave===-1?this.hoverDelay:this._delays.leave}set leaveDelay(e){o("number",{value:e}),this._delays.leave!==e&&(this._delays.leave=e)}get prefix(){return this._prefix}set prefix(e){o("string",{value:e}),this._prefix!==e&&(this._prefix=e)}get isLocked(){return this._locked.value}get shouldBeLocked(){return this._locked.committed}get side(){return this._side}get otherSide(){return this._otherSide}get key(){return this._key}set key(e){o("string",{value:e}),this._key!==e&&(this._key=e)}get isSoftLocked(){return this._softLocked}set isSoftLocked(e){o("boolean",{value:e}),this._softLocked!==e&&(this._softLocked=e)}get isOpen(){return this._open}get errors(){return this._errors}_validate(){let e=!0;const t={shelfElement:this._dom.shelf,controllerElement:this._dom.controller};this._dom.lockController&&(t.lockControllerElement=this._dom.lockController),this._dom.hoverController&&(t.hoverControllerElement=this._dom.hoverController),this._dom.sideController&&(t.sideControllerElement=this._dom.sideController);const s=A(HTMLElement,t);s.status||(this._errors.push(s.error.message),e=!1);const i={};for(const h of Object.keys(this._classes))this._classes[h]!==""&&(i[`${h}Class`]=this._classes[h]);const r=c(i);r.status||(this._errors.push(r.error.message),e=!1);const a={};for(const h of Object.keys(this._durations))this._durations[h]!==""&&(a[`${h}Duration`]=this._durations[h]);const p=o("number",a);p.status||(this._errors.push(p.error.message),e=!1);const g=o("boolean",{hover:this._hover});g.status||(this._errors.push(g.error.message),e=!1);const v={};for(const h of Object.keys(this._delays))this._delays[h]!==""&&(v[`${h}Delay`]=this._delays[h]);const y=o("number",v);y.status||(this._errors.push(y.error.message),e=!1);const k=o("string",{prefix:this._prefix});k.status||(this._errors.push(k.error.message),e=!1);const b=o("boolean",{locked:this._locked.value});b.status||(this._errors.push(b.error.message),e=!1);const E=j({side:this._side});return E.status||(this._errors.push(E.error.message),e=!1),e}_setDOMElementType(e,{base:t=this.dom.shelf,overwrite:s=!0,strict:i=!0}={}){if(typeof this.selectors[e]=="string"){if(e==="shelf"||e==="controller"||e==="lockController"||e==="hoverController")throw new Error(`Graupl Navigation Shelf: "${e}" element cannot be set through _setDOMElementType.`);if(t!==this.dom.shelf&&A(HTMLElement,{base:t}),Array.isArray(this._dom[e])){const r=Array.from(t.querySelectorAll(this.selectors[e])).filter(a=>i?a.parentElement===t:!0);s?this._dom[e]=r:this._dom[e]=[...this._dom[e],...r]}else{const r=t.querySelector(this.selectors[e]);if(r&&r.parentElement!==t)return;s&&(this._dom[e]=r)}}else throw new Error(`Graupl Navigation Shelf: "${e}" is not a valid element type within the navigation shelf.`)}_resetDOMElementType(e){if(typeof this.selectors[e]=="string"){if(e==="shelf"||e==="controller"||e==="lockController"||e==="hoverController")throw new Error(`Graupl Navigation Shelf: "${e}" element cannot be reset through _resetDOMElementType.`);Array.isArray(this._dom[e])?this._dom[e]=[]:this._dom[e]=null}else throw new Error(`Graupl Navigation Shelf: "${e}" is not a valid element type within the navigation shelf.`)}_setDOMElements(){this._setDOMElementType("dependents",{base:document,strict:!1})}_generateKey(e=!1){(this.key===""||e)&&(this.key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){this.dom.shelf.id=this.dom.shelf.id||`navigation-shelf-${this.key}`,this.dom.controller&&(this.dom.controller.id=this.dom.controller.id||`navigation-shelf-toggle-${this.key}`),this.dom.lockController&&(this.dom.lockController.id=this.dom.lockController.id||`navigation-shelf-lock-toggle-${this.key}`),this.dom.hoverController&&(this.dom.hoverController.id=this.dom.hoverController.id||`navigation-shelf-hover-toggle-${this.key}`)}_setAriaAttributes(){this.dom.controller&&(this.dom.controller.setAttribute("aria-controls",this.dom.shelf.id),this.dom.controller.getAttribute("aria-expanded")!=="true"&&this.dom.controller.setAttribute("aria-expanded","false")),this.dom.lockController&&(this.dom.lockController.setAttribute("aria-controls",this.dom.shelf.id),this.dom.lockController.setAttribute("aria-pressed",this.isLocked?"true":"false")),this.dom.hoverController&&(this.dom.hoverController.setAttribute("aria-controls",this.dom.shelf.id),this.dom.hoverController.setAttribute("aria-pressed",this._hoverType==="on"?"true":"false")),this.dom.sideController&&this.dom.sideController.setAttribute("aria-controls",this.dom.shelf.id)}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){o("function",{callback:e}),o("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleResize(){this._breakpointWidth<=0||(this._observer=new ResizeObserver(e=>{requestAnimationFrame(()=>{for(const t of e){const s=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize,i=s&&typeof s.inlineSize=="number"?s.inlineSize:t.contentRect.width;if(typeof i!="number")continue;const r=i<=this._breakpointWidth,a=i>this._breakpointWidth;r&&this.isOpen?this.close({preserveLock:this.shouldBeLocked}):a&&this.shouldBeLocked&&!this.isOpen&&(this._locked.reset(),this.lock({force:!0}))}})}),this._observer.observe(document.body))}_handleFocus(){this.dom.shelf.addEventListener("focusin",()=>{this.focusState="self",this.open()}),this.dom.shelf.addEventListener("focusout",e=>{e.relatedTarget===null||this.dom.shelf.contains(e.relatedTarget)||(this.focusState="none",this.isLocked||this.close())})}_handleClick(){for(const e of Object.values(this.dom))e&&(Array.isArray(e)||e.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this._clearTimeout()},{passive:!0}));this.dom.controller&&this.dom.controller.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.toggle({preserveLock:!1}),this.isOpen&&(this.focusState="self",this.isSoftLocked=!0))}),this.dom.hoverController&&this.dom.hoverController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleHover(),this.hover&&this.open())}),this.dom.lockController&&this.dom.lockController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleLock())}),this.dom.sideController&&this.dom.sideController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleSide())}),this.dom.shelf.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",this.focusState="self",this.isSoftLocked=!0,this.open())}),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.isLocked||this.dom.shelf===e.target||this.dom.shelf.contains(e.target)||(this.currentEvent="mouse",this.close()))})}_handleHover(){this.dom.shelf.addEventListener("pointerenter",e=>{e.pointerType==="pen"||e.pointerType==="touch"||this.isLocked||this.isSoftLocked||this.hover&&(this.currentEvent="mouse",this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.isOpen||this.open()},this.enterDelay)):this.open())}),this.dom.shelf.addEventListener("pointerleave",e=>{e.pointerType==="pen"||e.pointerType==="touch"||this.isLocked||this.isSoftLocked||this.hover&&(this.currentEvent="mouse",this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.isOpen&&this.close()},this.leaveDelay)):this.close())})}_handleKeydown(){this.dom.shelf.addEventListener("keydown",e=>{d(e)==="Escape"&&f(e)});for(const e of Object.values(this.dom))e&&(Array.isArray(e)||e!==this.dom.shelf&&e.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=d(t);(s==="Space"||s==="Enter")&&f(t)}))}_handleKeyup(){this.dom.shelf.addEventListener("keyup",e=>{this.currentEvent="keyboard",d(e)==="Escape"&&this.close()}),this.dom.controller&&this.dom.controller.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggle(),this.isOpen&&q(this.dom.shelf).focus())}),this.dom.hoverController&&this.dom.hoverController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleHover())}),this.dom.lockController&&this.dom.lockController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleLock())}),this.dom.sideController&&this.dom.sideController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleSide())})}_setTransitionDurations(){this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-transition-duration`,`${this.transitionDuration}ms`),this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-open-transition-duration`,`${this.openDuration}ms`),this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-close-transition-duration`,`${this.closeDuration}ms`)}_expand({emit:e=!0,transition:t=!0}={}){this.dom.controller&&this.dom.controller.setAttribute("aria-expanded","true"),this._initialized?t&&this.transitionClass!==""?(n(this.transitionClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{setTimeout(()=>{l(this.transitionClass,this.dom.shelf)},this.openDuration)})})})):(n(this.openClass,this.dom.shelf),l(this.closeClass,this.dom.shelf)):(n(this.initializeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.openClass,this.dom.shelf),l(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.initializeClass,this.dom.shelf)})})),e&&this.dom.shelf.dispatchEvent(this._expandEvent)}_collapse(e=!0,t=!0){this.dom.controller&&this.dom.controller.setAttribute("aria-expanded","false"),this.isSoftLocked=!1,this._initialized?t&&this.transitionClass!==""?(n(this.transitionClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{setTimeout(()=>{l(this.transitionClass,this.dom.shelf)},this.closeDuration)})})})):(n(this.closeClass,this.dom.shelf),l(this.openClass,this.dom.shelf)):(n(this.initializeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.closeClass,this.dom.shelf),l(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.initializeClass,this.dom.shelf)})})),e&&this.dom.shelf.dispatchEvent(this._collapseEvent)}_lock({emit:e=!0}={}){this.dom.lockController&&this.dom.lockController.setAttribute("aria-pressed","true"),n(this.lockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{n(this.lockedClass,t)}),l(this.unlockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{l(this.unlockedClass,t)}),e&&this.dom.shelf.dispatchEvent(this._lockEvent)}_unlock({emit:e=!0}={}){this.dom.lockController&&this.dom.lockController.setAttribute("aria-pressed","false"),n(this.unlockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{n(this.unlockedClass,t)}),l(this.lockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{l(this.lockedClass,t)}),e&&this.dom.shelf.dispatchEvent(this._unlockEvent)}_shiftSide({emit:e=!0}={}){const t=this._classes[this.side],s=this._classes[this.otherSide];n(t,this.dom.shelf),this.dom.dependents.forEach(i=>{n(t,i)}),l(s,this.dom.shelf),this.dom.dependents.forEach(i=>{l(s,i)}),e&&this.dom.shelf.dispatchEvent(this._shiftEvent)}_enableHover({emit:e=!0}={}){this.dom.hoverController&&this.dom.hoverController.setAttribute("aria-pressed","true"),n(this.hoverClass,this.dom.shelf),l(this.noHoverClass,this.dom.shelf),e&&this.dom.shelf.dispatchEvent(this._enableHoverEvent)}_disableHover({emit:e=!0}={}){this.dom.hoverController&&this.dom.hoverController.setAttribute("aria-pressed","false"),n(this.noHoverClass,this.dom.shelf),l(this.hoverClass,this.dom.shelf),e&&this.dom.shelf.dispatchEvent(this._disableHoverEvent)}open({force:e=!1}={}){this.isOpen&&!e||(this._expand(),this._open=!0)}close({force:e=!1,preserveLock:t=!0}={}){!this.isOpen&&!e||(this.unlock({updateLock:!t}),this._collapse(),this._open=!1)}toggle({force:e=!1,preserveLock:t=!0}={}){this.isOpen?this.close({force:e,preserveLock:t}):this.open({force:e})}lock({force:e=!1}={}){this.isLocked&&!e||(this._locked.value=!0,this._lock(),this._locked.commit(),this.open({force:!0}))}unlock({updateLock:e=!0}={}){if(!this.isLocked){this._locked.value=!1,e&&this._locked.commit();return}this._locked.value=!1,this._unlock(),e&&this._locked.commit()}toggleLock(){this.isLocked?this.unlock():this.lock()}toLeft(){this.side!=="left"&&(this._side="left",this._otherSide="right",this._shiftSide())}toRight(){this.side!=="right"&&(this._side="right",this._otherSide="left",this._shiftSide())}toggleSide(){this.side==="left"?this.toRight():this.toLeft()}enableHover(){this.hover||(this._enableHover(),this._hover=!0)}disableHover(){this.hover&&(this._disableHover(),this._hover=!1)}toggleHover(){this.hover?this.disableHover():this.enableHover()}},K=I;const $=/[\11\12\14\15\40]+/,C="data-once",P=document;function w(e,t,s){return e[`${t}Attribute`](C,s)}function u(e){if(typeof e!="string")throw new TypeError("once ID must be a string");if(e===""||$.test(e))throw new RangeError("once ID must not be empty or contain spaces");return`[${C}~="${e}"]`}function U(e){if(!(e instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function m(e,t=P){let s=e;if(e===null)s=[];else if(e)if(t instanceof Document||t instanceof DocumentFragment||t instanceof Element)typeof e=="string"?s=t.querySelectorAll(e):e instanceof Element&&(s=[e]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function S(e,t,s){return t.filter(i=>{const r=U(i)&&i.matches(e);return r&&s&&s(i),r})}function T(e,{add:t,remove:s}){const i=[];w(e,"has")&&w(e,"get").trim().split($).forEach(a=>{i.indexOf(a)<0&&a!==s&&i.push(a)}),t&&i.push(t);const r=i.join(" ");w(e,r===""?"remove":"set",r)}function _(e,t,s){return S(`:not(${u(e)})`,m(t,s),i=>T(i,{add:e}))}_.remove=(e,t,s)=>S(u(e),m(t,s),i=>T(i,{remove:e})),_.filter=(e,t,s)=>S(u(e),m(t,s)),_.find=(e,t)=>m(e?u(e):`[${C}]`,t);var W=_,Q=(e={},t=document,s=".navigation-shelf")=>{W("graupl-navigation-shelf-generator",s,t).forEach(i=>{const r=i.dataset.grauplNavigationShelfOptions?JSON.parse(i.dataset.grauplNavigationShelfOptions.replace(/'/g,'"'))||{}:{};new K({shelfElement:i,controllerElement:t.querySelector(".navigation-shelf-toggle")||null,lockControllerElement:t.querySelector(".navigation-shelf-lock-toggle")||null,hoverControllerElement:t.querySelector(".navigation-shelf-hover-toggle")||null,sideControllerElement:t.querySelector(".navigation-shelf-side-toggle")||null,initialize:!0,...e,...r})})};return Q})();
3
+ - `)}`);this._setTransitionDurations(),this._generateKey(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this._handleResize(),this.dom.controller.getAttribute("aria-expanded")==="true"||this.isLocked?(this._expand(!1,!1),this.isLocked&&this._lock(!1)):this._collapse(!1,!1),this.hover?this._enableHover(!1):this._disableHover(!1),this._shiftSide(!1),L.initializeStorage("navigation-shelves"),L.pushToStorage("navigation-shelves",this.dom.shelf.id,this),this._initialized=!0}catch(e){console.error(e)}}get dom(){return this._dom}get selectors(){return this._selectors}get lockedClass(){return this._classes.locked}set lockedClass(e){c({lockedClass:e}),this._classes.locked!==e&&(this._classes.locked=e)}get unlockedClass(){return this._classes.unlocked}set unlockedClass(e){c({unlockedClass:e}),this._classes.unlocked!==e&&(this._classes.unlocked=e)}get hoverClass(){return this._classes.hover}set hoverClass(e){c({hoverClass:e}),this._classes.hover!==e&&(this._classes.hover=e)}get noHoverClass(){return this._classes.noHover}set noHoverClass(e){c({noHoverClass:e}),this._classes.noHover!==e&&(this._classes.noHover=e)}get leftClass(){return this._classes.left}set leftClass(e){c({leftClass:e}),this._classes.left!==e&&(this._classes.left=e)}get rightClass(){return this._classes.right}set rightClass(e){c({rightClass:e}),this._classes.right!==e&&(this._classes.right=e)}get openClass(){return this._classes.open}set openClass(e){c({openClass:e}),this._classes.open!==e&&(this._classes.open=e)}get closeClass(){return this._classes.close}set closeClass(e){c({closeClass:e}),this._classes.close!==e&&(this._classes.close=e)}get transitionClass(){return this._classes.transition}set transitionClass(e){c({transitionClass:e}),this._classes.transition!==e&&(this._classes.transition=e)}get initializeClass(){return this._classes.initialize}set initializeClass(e){c({initializeClass:e}),this._classes.initialize!==e&&(this._classes.initialize=e)}get transitionDuration(){return this._durations.transition}set transitionDuration(e){r("number",{value:e}),this._durations.transition!==e&&(this._durations.transition=e,this._setTransitionDurations())}get openDuration(){return this._durations.open===-1?this.transitionDuration:this._durations.open}set openDuration(e){r("number",{value:e}),this._durations.open!==e&&(this._durations.open=e,this._setTransitionDurations())}get closeDuration(){return this._durations.close===-1?this.transitionDuration:this._durations.close}set closeDuration(e){r("number",{value:e}),this._durations.close!==e&&(this._durations.close=e,this._setTransitionDurations())}get focusState(){return this._focusState}set focusState(e){H({value:e}),this._focusState!==e&&(this._focusState=e)}get currentEvent(){return this._currentEvent}set currentEvent(e){O({value:e}),this._currentEvent!==e&&(this._currentEvent=e)}get hover(){return this._hover}get hoverDelay(){return this._delays.hover}set hoverDelay(e){r("number",{value:e}),this._delays.hover!==e&&(this._delays.hover=e)}get enterDelay(){return this._delays.enter===-1?this.hoverDelay:this._delays.enter}set enterDelay(e){r("number",{value:e}),this._delays.enter!==e&&(this._delays.enter=e)}get leaveDelay(){return this._delays.leave===-1?this.hoverDelay:this._delays.leave}set leaveDelay(e){r("number",{value:e}),this._delays.leave!==e&&(this._delays.leave=e)}get prefix(){return this._prefix}set prefix(e){r("string",{value:e}),this._prefix!==e&&(this._prefix=e)}get isLocked(){return this._locked.value}get shouldBeLocked(){return this._locked.committed}get side(){return this._side}get otherSide(){return this._otherSide}get key(){return this._key}set key(e){r("string",{value:e}),this._key!==e&&(this._key=e)}get isSoftLocked(){return this._softLocked}set isSoftLocked(e){r("boolean",{value:e}),this._softLocked!==e&&(this._softLocked=e)}get isOpen(){return this._open}get errors(){return this._errors}_validate(){let e=!0;const t={shelfElement:this._dom.shelf,controllerElement:this._dom.controller};this._dom.lockController&&(t.lockControllerElement=this._dom.lockController),this._dom.hoverController&&(t.hoverControllerElement=this._dom.hoverController),this._dom.sideController&&(t.sideControllerElement=this._dom.sideController);const s=A(HTMLElement,t);s.status||(this._errors.push(s.error.message),e=!1);const i={};for(const h of Object.keys(this._classes))this._classes[h]!==""&&(i[`${h}Class`]=this._classes[h]);const o=c(i);o.status||(this._errors.push(o.error.message),e=!1);const a={};for(const h of Object.keys(this._durations))this._durations[h]!==""&&(a[`${h}Duration`]=this._durations[h]);const u=r("number",a);u.status||(this._errors.push(u.error.message),e=!1);const g=r("boolean",{hover:this._hover});g.status||(this._errors.push(g.error.message),e=!1);const v={};for(const h of Object.keys(this._delays))this._delays[h]!==""&&(v[`${h}Delay`]=this._delays[h]);const y=r("number",v);y.status||(this._errors.push(y.error.message),e=!1);const k=r("string",{prefix:this._prefix});k.status||(this._errors.push(k.error.message),e=!1);const b=r("boolean",{locked:this._locked.value});b.status||(this._errors.push(b.error.message),e=!1);const E=j({side:this._side});return E.status||(this._errors.push(E.error.message),e=!1),e}_setDOMElementType(e,{base:t=this.dom.shelf,overwrite:s=!0,strict:i=!0}={}){if(typeof this.selectors[e]=="string"){if(e==="shelf"||e==="controller"||e==="lockController"||e==="hoverController")throw new Error(`Graupl Navigation Shelf: "${e}" element cannot be set through _setDOMElementType.`);if(t!==this.dom.shelf&&A(HTMLElement,{base:t}),Array.isArray(this._dom[e])){const o=Array.from(t.querySelectorAll(this.selectors[e])).filter(a=>i?a.parentElement===t:!0);s?this._dom[e]=o:this._dom[e]=[...this._dom[e],...o]}else{const o=t.querySelector(this.selectors[e]);if(o&&o.parentElement!==t)return;s&&(this._dom[e]=o)}}else throw new Error(`Graupl Navigation Shelf: "${e}" is not a valid element type within the navigation shelf.`)}_resetDOMElementType(e){if(typeof this.selectors[e]=="string"){if(e==="shelf"||e==="controller"||e==="lockController"||e==="hoverController")throw new Error(`Graupl Navigation Shelf: "${e}" element cannot be reset through _resetDOMElementType.`);Array.isArray(this._dom[e])?this._dom[e]=[]:this._dom[e]=null}else throw new Error(`Graupl Navigation Shelf: "${e}" is not a valid element type within the navigation shelf.`)}_setDOMElements(){this._setDOMElementType("dependents",{base:document,strict:!1})}_generateKey(e=!1){(this.key===""||e)&&(this.key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){this.dom.shelf.id=this.dom.shelf.id||`navigation-shelf-${this.key}`,this.dom.controller&&(this.dom.controller.id=this.dom.controller.id||`navigation-shelf-toggle-${this.key}`),this.dom.lockController&&(this.dom.lockController.id=this.dom.lockController.id||`navigation-shelf-lock-toggle-${this.key}`),this.dom.hoverController&&(this.dom.hoverController.id=this.dom.hoverController.id||`navigation-shelf-hover-toggle-${this.key}`)}_setAriaAttributes(){this.dom.controller&&(this.dom.controller.setAttribute("aria-controls",this.dom.shelf.id),this.dom.controller.getAttribute("aria-expanded")!=="true"&&this.dom.controller.setAttribute("aria-expanded","false")),this.dom.lockController&&(this.dom.lockController.setAttribute("aria-controls",this.dom.shelf.id),this.dom.lockController.setAttribute("aria-pressed",this.isLocked?"true":"false")),this.dom.hoverController&&(this.dom.hoverController.setAttribute("aria-controls",this.dom.shelf.id),this.dom.hoverController.setAttribute("aria-pressed",this._hoverType==="on"?"true":"false")),this.dom.sideController&&this.dom.sideController.setAttribute("aria-controls",this.dom.shelf.id)}_clearTimeout(){clearTimeout(this._hoverTimeout)}_setTimeout(e,t){r("function",{callback:e}),r("number",{delay:t}),this._hoverTimeout=setTimeout(e,t)}_handleResize(){if(this._breakpointWidth<=0)return;let e=0;this._observer=new ResizeObserver(t=>{requestAnimationFrame(()=>{for(const s of t){const i=Array.isArray(s.contentBoxSize)?s.contentBoxSize[0]:s.contentBoxSize,o=i&&typeof i.inlineSize=="number"?i.inlineSize:s.contentRect.width;if(typeof o!="number"||e===o)continue;const a=o<=this._breakpointWidth,u=o>this._breakpointWidth;a&&this.isOpen?this.close({preserveLock:this.shouldBeLocked}):u&&this.shouldBeLocked&&!this.isOpen&&(this._locked.reset(),this.lock({force:!0})),e=o}})}),this._observer.observe(document.body)}_handleFocus(){this.dom.shelf.addEventListener("focusin",()=>{this.focusState="self",this.open()}),this.dom.shelf.addEventListener("focusout",e=>{e.relatedTarget===null||this.dom.shelf.contains(e.relatedTarget)||(this.focusState="none",this.isLocked||this.close())})}_handleClick(){for(const e of Object.values(this.dom))e&&(Array.isArray(e)||e.addEventListener("pointerdown",()=>{this.currentEvent="mouse",this._clearTimeout()},{passive:!0}));this.dom.controller&&this.dom.controller.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.toggle({preserveLock:!1}),this.isOpen&&(this.focusState="self",this.isSoftLocked=!0))}),this.dom.hoverController&&this.dom.hoverController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleHover(),this.hover&&this.open())}),this.dom.lockController&&this.dom.lockController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleLock())}),this.dom.sideController&&this.dom.sideController.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",f(e),this.focusState="self",this.toggleSide())}),this.dom.shelf.addEventListener("pointerup",e=>{e.button===0&&(this.currentEvent="mouse",this.focusState="self",this.isSoftLocked=!0,this.open())}),document.addEventListener("pointerup",e=>{this.focusState!=="none"&&(this.isLocked||this.dom.shelf===e.target||this.dom.shelf.contains(e.target)||(this.currentEvent="mouse",this.close()))})}_handleHover(){this.dom.shelf.addEventListener("pointerenter",e=>{e.pointerType==="pen"||e.pointerType==="touch"||this.isLocked||this.isSoftLocked||this.hover&&(this.currentEvent="mouse",this.enterDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.isOpen||this.open()},this.enterDelay)):this.open())}),this.dom.shelf.addEventListener("pointerleave",e=>{e.pointerType==="pen"||e.pointerType==="touch"||this.isLocked||this.isSoftLocked||this.hover&&(this.currentEvent="mouse",this.leaveDelay>0?(this._clearTimeout(),this._setTimeout(()=>{this.isOpen&&this.close()},this.leaveDelay)):this.close())})}_handleKeydown(){this.dom.shelf.addEventListener("keydown",e=>{d(e)==="Escape"&&f(e)});for(const e of Object.values(this.dom))e&&(Array.isArray(e)||e!==this.dom.shelf&&e.addEventListener("keydown",t=>{this.currentEvent="keyboard";const s=d(t);(s==="Space"||s==="Enter")&&f(t)}))}_handleKeyup(){this.dom.shelf.addEventListener("keyup",e=>{this.currentEvent="keyboard",d(e)==="Escape"&&this.close()}),this.dom.controller&&this.dom.controller.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggle(),this.isOpen&&q(this.dom.shelf).focus())}),this.dom.hoverController&&this.dom.hoverController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleHover())}),this.dom.lockController&&this.dom.lockController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleLock())}),this.dom.sideController&&this.dom.sideController.addEventListener("keyup",e=>{this.currentEvent="keyboard";const t=d(e);(t==="Space"||t==="Enter")&&(f(e),this.toggleSide())})}_setTransitionDurations(){this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-transition-duration`,`${this.transitionDuration}ms`),this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-open-transition-duration`,`${this.openDuration}ms`),this.dom.shelf.style.setProperty(`--${this.prefix}navigation-shelf-close-transition-duration`,`${this.closeDuration}ms`)}_expand({emit:e=!0,transition:t=!0}={}){this.dom.controller&&this.dom.controller.setAttribute("aria-expanded","true"),this._initialized?t&&this.transitionClass!==""?(n(this.transitionClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{setTimeout(()=>{l(this.transitionClass,this.dom.shelf)},this.openDuration)})})})):(n(this.openClass,this.dom.shelf),l(this.closeClass,this.dom.shelf)):(n(this.initializeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.openClass,this.dom.shelf),l(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.initializeClass,this.dom.shelf)})})),e&&this.dom.shelf.dispatchEvent(this._expandEvent)}_collapse(e=!0,t=!0){this.dom.controller&&this.dom.controller.setAttribute("aria-expanded","false"),this.isSoftLocked=!1,this._initialized?t&&this.transitionClass!==""?(n(this.transitionClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.closeClass,this.dom.shelf),requestAnimationFrame(()=>{setTimeout(()=>{l(this.transitionClass,this.dom.shelf)},this.closeDuration)})})})):(n(this.closeClass,this.dom.shelf),l(this.openClass,this.dom.shelf)):(n(this.initializeClass,this.dom.shelf),requestAnimationFrame(()=>{n(this.closeClass,this.dom.shelf),l(this.openClass,this.dom.shelf),requestAnimationFrame(()=>{l(this.initializeClass,this.dom.shelf)})})),e&&this.dom.shelf.dispatchEvent(this._collapseEvent)}_lock({emit:e=!0}={}){this.dom.lockController&&this.dom.lockController.setAttribute("aria-pressed","true"),n(this.lockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{n(this.lockedClass,t)}),l(this.unlockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{l(this.unlockedClass,t)}),e&&this.dom.shelf.dispatchEvent(this._lockEvent)}_unlock({emit:e=!0}={}){this.dom.lockController&&this.dom.lockController.setAttribute("aria-pressed","false"),n(this.unlockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{n(this.unlockedClass,t)}),l(this.lockedClass,this.dom.shelf),this.dom.dependents.forEach(t=>{l(this.lockedClass,t)}),e&&this.dom.shelf.dispatchEvent(this._unlockEvent)}_shiftSide({emit:e=!0}={}){const t=this._classes[this.side],s=this._classes[this.otherSide];n(t,this.dom.shelf),this.dom.dependents.forEach(i=>{n(t,i)}),l(s,this.dom.shelf),this.dom.dependents.forEach(i=>{l(s,i)}),e&&this.dom.shelf.dispatchEvent(this._shiftEvent)}_enableHover({emit:e=!0}={}){this.dom.hoverController&&this.dom.hoverController.setAttribute("aria-pressed","true"),n(this.hoverClass,this.dom.shelf),l(this.noHoverClass,this.dom.shelf),e&&this.dom.shelf.dispatchEvent(this._enableHoverEvent)}_disableHover({emit:e=!0}={}){this.dom.hoverController&&this.dom.hoverController.setAttribute("aria-pressed","false"),n(this.noHoverClass,this.dom.shelf),l(this.hoverClass,this.dom.shelf),e&&this.dom.shelf.dispatchEvent(this._disableHoverEvent)}open({force:e=!1}={}){this.isOpen&&!e||(this._expand(),this._open=!0)}close({force:e=!1,preserveLock:t=!0}={}){!this.isOpen&&!e||(this.unlock({updateLock:!t}),this._collapse(),this._open=!1)}toggle({force:e=!1,preserveLock:t=!0}={}){this.isOpen?this.close({force:e,preserveLock:t}):this.open({force:e})}lock({force:e=!1}={}){this.isLocked&&!e||(this._locked.value=!0,this._lock(),this._locked.commit(),this.open({force:!0}))}unlock({updateLock:e=!0}={}){if(!this.isLocked){this._locked.value=!1,e&&this._locked.commit();return}this._locked.value=!1,this._unlock(),e&&this._locked.commit()}toggleLock(){this.isLocked?this.unlock():this.lock()}toLeft(){this.side!=="left"&&(this._side="left",this._otherSide="right",this._shiftSide())}toRight(){this.side!=="right"&&(this._side="right",this._otherSide="left",this._shiftSide())}toggleSide(){this.side==="left"?this.toRight():this.toLeft()}enableHover(){this.hover||(this._enableHover(),this._hover=!0)}disableHover(){this.hover&&(this._disableHover(),this._hover=!1)}toggleHover(){this.hover?this.disableHover():this.enableHover()}},K=I;const $=/[\11\12\14\15\40]+/,C="data-once",P=document;function w(e,t,s){return e[`${t}Attribute`](C,s)}function m(e){if(typeof e!="string")throw new TypeError("once ID must be a string");if(e===""||$.test(e))throw new RangeError("once ID must not be empty or contain spaces");return`[${C}~="${e}"]`}function U(e){if(!(e instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function _(e,t=P){let s=e;if(e===null)s=[];else if(e)if(t instanceof Document||t instanceof DocumentFragment||t instanceof Element)typeof e=="string"?s=t.querySelectorAll(e):e instanceof Element&&(s=[e]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function S(e,t,s){return t.filter(i=>{const o=U(i)&&i.matches(e);return o&&s&&s(i),o})}function T(e,{add:t,remove:s}){const i=[];w(e,"has")&&w(e,"get").trim().split($).forEach(a=>{i.indexOf(a)<0&&a!==s&&i.push(a)}),t&&i.push(t);const o=i.join(" ");w(e,o===""?"remove":"set",o)}function p(e,t,s){return S(`:not(${m(e)})`,_(t,s),i=>T(i,{add:e}))}p.remove=(e,t,s)=>S(m(e),_(t,s),i=>T(i,{remove:e})),p.filter=(e,t,s)=>S(m(e),_(t,s)),p.find=(e,t)=>_(e?m(e):`[${C}]`,t);var W=p,Q=(e={},t=document,s=".navigation-shelf")=>{W("graupl-navigation-shelf-generator",s,t).forEach(i=>{const o=i.dataset.grauplNavigationShelfOptions?JSON.parse(i.dataset.grauplNavigationShelfOptions.replace(/'/g,'"'))||{}:{};new K({shelfElement:i,controllerElement:t.querySelector(".navigation-shelf-toggle")||null,lockControllerElement:t.querySelector(".navigation-shelf-lock-toggle")||null,hoverControllerElement:t.querySelector(".navigation-shelf-hover-toggle")||null,sideControllerElement:t.querySelector(".navigation-shelf-side-toggle")||null,initialize:!0,...e,...o})})};return Q})();
4
4
 
5
5
  //# sourceMappingURL=navigation-shelf.iife.js.map