@scania/tegel
Version:
Tegel Design System
1 lines • 3.72 kB
JavaScript
import{t,p as e,H as o,h as d,a as s}from"./index.js";const r=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.disabled=!1,this.selected=!1}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 d(s,{key:"bcb1ed17ebb34e2a458daa2fb3c6f7f52c3d9bf6","aria-selected":this.selected},d("div",{key:"b6ee4cef0bac744ad09e92a32453ba6fb6021c41",class:{selected:this.selected,disabled:this.disabled},style:{width:this.tabWidth+"px"}},d("slot",{key:"b7d230c050fc315fb5de735a0496c69c967bdefe"})))}get host(){return this}static get style(){return':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}:host ::slotted(*:focus-within)::before{outline:2px solid var(--tds-focus-outline-color);box-shadow:0 0 0 1px var(--tds-white);outline-offset:1px;z-index:1;content:"";position:absolute;top:3px;bottom:3px;left:3px;right:3px}:host div:not(.selected){background-color:var(--tds-folder-tab-background);position:relative}:host div:not(.selected)::before{content:"";position:absolute;left:0;top:0;bottom:0;width:1px;background-color:var(--tds-folder-tab-divider-color)}:host div:not(.selected) ::slotted(*){border-top:2px solid transparent;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:2px solid var(--tds-folder-tab-top-border-hover);color:var(--tds-folder-tab-color)}:host div:not(.selected).disabled{background-color:var(--tds-folder-tab-item-background-disabled)}: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-divider-color);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 .selected:hover:not(.disabled){background-color:var(--tds-folder-tab-background-hover);cursor:pointer}:host .selected:hover:not(.disabled) ::slotted(*){color:var(--tds-folder-tab-color)}:host(.first) ::slotted(*){border-left-color:transparent}:host(.first) .selected{border-left:none}'}},[257,"tds-folder-tab",{disabled:[4],selected:[32],tabWidth:[32],setTabWidth:[64],setSelected:[64]}]);function l(){"undefined"!=typeof customElements&&["tds-folder-tab"].forEach((e=>{"tds-folder-tab"===e&&(customElements.get(t(e))||customElements.define(t(e),r))}))}l();const a=r,i=l;export{a as TdsFolderTab,i as defineCustomElement}