UNPKG

@scania/tegel

Version:
111 lines (110 loc) 3.83 kB
import { Host, h } from "@stencil/core"; /** * @slot <default> - <b>Unnamed slot.</b> For the tab link or button. */ export class TdsInlineTab { constructor() { /** Disables the Tab. */ this.disabled = false; this.selected = false; } /** @internal Method to set the Tab as selected. Used by the <tds-inline-tabs> */ async setSelected(selected) { this.selected = selected; } connectedCallback() { const elements = this.host.querySelectorAll('button, a'); for (let index = 0; index < elements.length; index++) { const element = elements[index]; if (!element.getAttribute('aria-controls')) { console.warn('Tegel inline-tab component: Interactive elements should have aria-controls attribute to link the tab to its corresponding panel'); } if (element.getAttribute('role') !== 'tab') { console.warn('Tegel inline-tab component: Interactive elements should have attribute role="tab"'); } if (this.disabled) { element.setAttribute('aria-disabled', 'true'); } else { element.removeAttribute('aria-disabled'); } } } render() { return (h(Host, { key: 'f1dec66ce92e3d2913941faedc3fe0f9d4e0ce17', "aria-selected": this.selected }, h("div", { key: '55335b61d72e1b20d6fddddc40f58c966c827f41', class: { 'inline-tab-item': true, 'selected': this.selected, 'disabled': this.disabled, } }, h("slot", { key: '3ff73b16df1a3a97924ced2f61ff72c92c92835c' })))); } static get is() { return "tds-inline-tab"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["inline-tab.scss"] }; } static get styleUrls() { return { "$": ["inline-tab.css"] }; } static get properties() { return { "disabled": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Disables the Tab." }, "getter": false, "setter": false, "reflect": false, "attribute": "disabled", "defaultValue": "false" } }; } static get states() { return { "selected": {} }; } static get methods() { return { "setSelected": { "complexType": { "signature": "(selected: boolean) => Promise<void>", "parameters": [{ "name": "selected", "type": "boolean", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [{ "name": "internal", "text": "Method to set the Tab as selected. Used by the <tds-inline-tabs>" }] } } }; } static get elementRef() { return "host"; } }