forked from patternfly/patternfly-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpf-thead.ts
More file actions
41 lines (33 loc) · 968 Bytes
/
pf-thead.ts
File metadata and controls
41 lines (33 loc) · 968 Bytes
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
import { LitElement, html, type TemplateResult } from 'lit';
import { customElement } from 'lit/decorators/custom-element.js';
import { thRoleContext } from './context.js';
import styles from './pf-thead.css';
import { provide } from '@lit/context';
/**
* Table head
* @slot - Place element content here
*/
@customElement('pf-thead')
export class PfThead extends LitElement {
static readonly styles: CSSStyleSheet[] = [styles];
@provide({ context: thRoleContext }) private thRowContext = 'columnheader';
connectedCallback(): void {
super.connectedCallback();
this.setAttribute('role', 'rowgroup');
}
render(): TemplateResult<1> {
return html`
<slot @slotchange=${this.#onSlotchange}></slot>
`;
}
#onSlotchange() {
for (const th of this.querySelectorAll(':scope > pf-th')) {
th.setAttribute('role', 'columnheader');
}
}
}
declare global {
interface HTMLElementTagNameMap {
'pf-thead': PfThead;
}
}