@scania/tegel
Version:
Tegel Design System
1 lines • 2.94 kB
JavaScript
import{r as t,h as e,H as o,g as d}from"./p-2049fab2.js";const s=class{constructor(e){t(this,e),this.disabled=!1,this.selected=!1,this.tabWidth=void 0}async setTabWidth(t){this.tabWidth=t}async setSelected(t){this.selected=t}connectedCallback(){const t=this.host.querySelectorAll("button, a");for(let e=0;e<t.length;e++){const o=t[e];o.getAttribute("aria-controls")||console.warn("Tegel folder-tab component: Interactive elements should have aria-controls attribute to link the tab to its corresponding panel"),"tab"!==o.getAttribute("role")&&console.warn('Tegel folder-tab component: Interactive elements should have attribute role="tab"'),this.disabled?o.setAttribute("aria-disabled","true"):o.removeAttribute("aria-disabled")}}render(){return e(o,{key:"19a42f7143a8f32130642bd50dd6817f871fdf20","aria-selected":this.selected},e("div",{key:"51bef3bebff5e13d7c949529919865780d8b33de",class:{selected:this.selected,disabled:this.disabled},style:{width:`${this.tabWidth}px`}},e("slot",{key:"2b661d3518f047f7bd0e50a121987eb62c5d42e8"})))}get host(){return d(this)}};s.style=':host{box-sizing:border-box;position:relative}:host *{box-sizing:border-box}:host ::slotted(*){all:unset;min-width:142px;display:block;width:calc(100% - 32px);font:var(--tds-headline-07) !important;letter-spacing:var(--tds-headline-07-ls) !important;cursor:pointer;padding:16px;white-space:nowrap;text-decoration:none;text-align:left;outline:none;border:none;border-left:1px solid;border-left-color:transparent}:host ::slotted(*:focus-visible){outline:2px solid var(--tds-focus-outline-color);box-shadow:0 0 0 1px var(--tds-white);outline-offset:1px;z-index:1}:host div:not(.selected){background-color:var(--tds-folder-tab-background)}:host div:not(.selected) ::slotted(*){border-left-color:var(--tds-folder-tab-divider-color);border-top:2px solid var(--tds-folder-tab-background);color:var(--tds-folder-tab-item-color)}:host div:not(.selected):hover:not(.disabled){background-color:var(--tds-folder-tab-background-hover);cursor:pointer}:host div:not(.selected):hover:not(.disabled) ::slotted(*){border-top-color:var(--tds-folder-tab-background-hover);color:var(--tds-folder-tab-color)}:host div:not(.selected).disabled ::slotted(*){color:var(--tds-folder-tab-item-color-disabled)}:host div:not(.selected).disabled ::slotted(*:focus-visible){outline:none}:host div:not(.selected).disabled ::slotted(*:hover){cursor:not-allowed}:host div:not(.selected).disabled ::slotted(*::after){content:none}:host .selected{background-color:var(--tds-folder-tab-background-selected);border-top:2px solid var(--tds-folder-tab-border-selected)}:host .selected::after{content:" ";background-color:var(--tds-folder-tab-background-selected);width:1px;top:0;bottom:0;right:-1px;display:block;position:absolute;z-index:1}:host .selected ::slotted(*){color:var(--tds-folder-tab-color)}:host(.first) :not(.selected) ::slotted(*){border-left-color:transparent}';export{s as tds_folder_tab}