UNPKG

@scania/tegel

Version:
1 lines 1.79 kB
import{r as t,h as s,H as i,a as o}from"./p-9xxNGlso.js";import{g as e,i as a}from"./p-Bx66i7RU.js";import"./p-CLF3diNe.js";const l=class{constructor(s){t(this,s),this.slotListeners=new Map,this.size="md"}componentWillLoad(){var t,s;const{children:i}=this.host;for(let t=0;t<i.length;t++){const s=i[t];"size"in s&&(s.size=this.size)}let o=this.host;"tds-header-launcher-list"===(null===(s=null===(t=this.host)||void 0===t?void 0:t.parentElement)||void 0===s?void 0:s.tagName.toLowerCase())&&(o=this.host.parentElement);const l=e(o,a);l?this.headingElement=l:console.warn("Heading element for list not found")}componentDidLoad(){var t;null===(t=this.host.shadowRoot)||void 0===t||t.querySelectorAll("slot").forEach((t=>{const s=t=>{this.processAssignedElements(t.target)};t.addEventListener("slotchange",s),s({target:t}),this.slotListeners.set(t,s)}))}processAssignedElements(t){t.assignedElements().forEach((t=>{"li"!==t.tagName.toLowerCase()&&"slot"!==t.tagName.toLowerCase()&&"listitem"!==t.getAttribute("role")&&t.setAttribute("role","listitem"),"slot"===t.tagName.toLowerCase()&&this.processAssignedElements(t)}))}disconnectedCallback(){this.slotListeners.forEach(((t,s)=>{s.removeEventListener("slotchange",t),this.slotListeners.delete(s)}))}render(){var t;const o={role:"list","aria-labelledby":null===(t=this.headingElement)||void 0===t?void 0:t.id};return s(i,Object.assign({key:"87736a915ab274f1fcd30e6eb3ac2b594c323ba9"},o),s("slot",{key:"61a2332a3da99fa2b0fa51a54547e9d5b66fa804"}))}get host(){return o(this)}};l.style=":host{display:block;width:190px;padding:0;margin:0;list-style:none;border-radius:unset;background-color:var(--tds-header-app-launcher-menu-bg)}@media all and (max-width: 384px){:host{width:100vw}}:host([size=lg]){width:320px}";export{l as tds_header_dropdown_list}