-
Notifications
You must be signed in to change notification settings - Fork 2
/
tab-panel.ts
44 lines (37 loc) · 1.15 KB
/
tab-panel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { LitElement, html } from 'lit';
import { registerComponent } from '../common/definitions/register.js';
import { createCounter } from '../common/util.js';
import { styles } from './themes/tab-panel.base.css.js';
/**
* Represents the content of a tab
*
* @element igc-tab-panel
*
* @slot - Renders the content.
*/
export default class IgcTabPanelComponent extends LitElement {
public static readonly tagName = 'igc-tab-panel';
public static override styles = styles;
/* blazorSuppress */
public static register() {
registerComponent(IgcTabPanelComponent);
}
private static readonly increment = createCounter();
public override connectedCallback() {
super.connectedCallback();
this.setAttribute('role', 'tabpanel');
this.tabIndex = this.hasAttribute('tabindex') ? this.tabIndex : 0;
this.slot = this.slot.length > 0 ? this.slot : 'panel';
this.id =
this.getAttribute('id') ||
`igc-tab-panel-${IgcTabPanelComponent.increment()}`;
}
protected override render() {
return html`<slot></slot>`;
}
}
declare global {
interface HTMLElementTagNameMap {
'igc-tab-panel': IgcTabPanelComponent;
}
}