@scania/tegel
Version:
Tegel Design System
1 lines • 1.72 kB
JavaScript
import{r as t,h as s,H as e,g as i}from"./p-2049fab2.js";import{g as o,i as a}from"./p-9332c225.js";import"./p-52bf0fdf.js";const d=class{constructor(s){t(this,s),this.slotListeners=new Map,this.size="md",this.headingElement=void 0}componentWillLoad(){const{children:t}=this.host;for(let s=0;s<t.length;s++){const e=t[s];"size"in e&&(e.size=this.size)}let s=this.host;"tds-header-launcher-list"===this.host.parentElement.tagName.toLowerCase()&&(s=this.host.parentElement);const e=o(s,a);e?this.headingElement=e:console.warn("Heading element for list not found")}componentDidLoad(){this.host.shadowRoot.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 i={role:"list","aria-labelledby":null===(t=this.headingElement)||void 0===t?void 0:t.id};return s(e,Object.assign({key:"3eeb33a5a5ba4afbfa21bd65fc4ad8ca7d8feddf"},i),s("slot",{key:"5561862a0377a76cae8d781849c4de10c9e8cdeb"}))}get host(){return i(this)}};d.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{d as tds_header_dropdown_list}