UNPKG

carbon-custom-elements

Version:

A Carbon Design System variant that's as easy to use as native HTML elements, with no framework tax, no framework silo.

1 lines 2.08 kB
{"version":3,"sources":["components/tabs/tab.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,qBAAqB,MAAM,2CAA2C,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAKnC;;;GAGG;AACH,cACM,KAAM,SAAQ,qBAAqB;IACvC;;;;OAIG;IAEH,WAAW,UAAS;IAEpB;;;OAGG;IAEH,OAAO,UAAS;IAEhB;;OAEG;IAEH,IAAI,YAAqB;IAEzB,iBAAiB;IAOjB,MAAM;IAUN,MAAM,CAAC,MAAM,MAAU;CACxB;AAED,eAAe,KAAK,CAAC","file":"tab.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019, 2020\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, property, customElement } from 'lit-element';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport BXContentSwitcherItem from '../content-switcher/content-switcher-item';\nimport { TABS_TYPE } from './tabs';\nimport styles from './tabs.scss';\n\nconst { prefix } = settings;\n\n/**\n * Basic tab.\n * @element bx-tab\n */\n@customElement(`${prefix}-tab`)\nclass BXTab extends BXContentSwitcherItem {\n /**\n * `true` if this tab should be highlighted.\n * If `true`, parent `<bx-tabs>` selects/deselects this tab upon keyboard interaction.\n * @private\n */\n @property({ type: Boolean, reflect: true })\n highlighted = false;\n\n /**\n * `true` if this tab is in a focused `<bx-tabs>`.\n * @private\n */\n @property({ type: Boolean, reflect: true, attribute: 'in-focus' })\n inFocus = false;\n\n /**\n * Tab type.\n */\n @property({ reflect: true })\n type = TABS_TYPE.REGULAR;\n\n connectedCallback() {\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'listitem');\n }\n super.connectedCallback();\n }\n\n render() {\n const { disabled, selected } = this;\n // No `href`/`tabindex` to not to make this `<a>` click-focusable\n return html`\n <a class=\"${prefix}--tabs__nav-link\" role=\"tab\" ?disabled=\"${disabled}\" aria-selected=\"${Boolean(selected)}\">\n <slot></slot>\n </a>\n `;\n }\n\n static styles = styles;\n}\n\nexport default BXTab;\n"]}