UNPKG

@salla.sa/twilight-components

Version:
182 lines (181 loc) 4.32 kB
/*! * Crafted with ❤ by Salla */ import { h } from "@stencil/core"; import { generateRandomId } from "./utils"; /** * @slot The default slot. */ export class SallaTabHeader { constructor() { this.id = generateRandomId(); this.name = undefined; this.activeClass = undefined; this.height = undefined; this.centered = false; this.isSelected = false; } /** * Expose self for the parent. */ async getChild() { return { selected: this.selected.bind(this), unselect: this.unselect.bind(this), name: this.name, id: this.id }; } unselect() { this.isSelected = false; } selected() { this.isSelected = true; } onClick() { this.getChild().then(child => { this.tabSelected.emit(child); }); } render() { const classes = { 's-tabs-header-item': true, 's-tabs-bg-normal': true, 's-tabs-active': this.isSelected, }; return [ h("div", { class: classes, onClick: this.onClick.bind(this) }, h("slot", null)), ]; } static get is() { return "salla-tab-header"; } static get originalStyleUrls() { return { "$": ["salla-tab-header.scss"] }; } static get styleUrls() { return { "$": ["salla-tab-header.css"] }; } static get properties() { return { "name": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Header identifier name to sync with the content." }, "attribute": "name", "reflect": false }, "activeClass": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "The class applied to the currently active(selected) tab" }, "attribute": "active-class", "reflect": false, "defaultValue": "undefined" }, "height": { "type": "any", "mutable": false, "complexType": { "original": "number | string", "resolved": "number | string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Set the height of the tab bar" }, "attribute": "height", "reflect": false, "defaultValue": "undefined" }, "centered": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Center tab items in the given flex." }, "attribute": "centered", "reflect": false, "defaultValue": "false" } }; } static get states() { return { "isSelected": {} }; } static get events() { return [{ "method": "tabSelected", "name": "tabSelected", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "Emits event object when clicked or selected." }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } static get methods() { return { "getChild": { "complexType": { "signature": "() => Promise<{ selected: any; unselect: any; name: string; id: string; }>", "parameters": [], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<{ selected: any; unselect: any; name: string; id: string; }>" }, "docs": { "text": "Expose self for the parent.", "tags": [] } } }; } } //# sourceMappingURL=salla-tab-header.js.map