-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathvscode-table-header-cell.ts
More file actions
81 lines (69 loc) · 2.23 KB
/
vscode-table-header-cell.ts
File metadata and controls
81 lines (69 loc) · 2.23 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import {html, PropertyValues, TemplateResult} from 'lit';
import {property} from 'lit/decorators.js';
import {customElement, VscElement} from '../includes/VscElement.js';
import styles from './vscode-table-header-cell.styles.js';
export type VscTableChangeMinColumnWidthEvent = CustomEvent<{
columnIndex: number;
propertyValue: string;
}>;
export type VscTableChangePreferredColumnWidthEvent = CustomEvent<{
columnIndex: number;
propertyValue: string;
}>;
/**
* @tag vscode-table-header-cell
*
* @cssprop [--vscode-foreground=#cccccc]
* @cssprop [--vscode-font-family=sans-serif]
* @cssprop [--vscode-font-size=13px]
*/
@customElement('vscode-table-header-cell')
export class VscodeTableHeaderCell extends VscElement {
static override styles = styles;
@property({attribute: 'min-width'})
minWidth = '0';
@property({attribute: 'preferred-width'})
preferredWidth = 'auto';
/** @internal */
@property({type: Number})
index = -1;
/** @internal */
@property({reflect: true})
override role = 'columnheader';
protected override willUpdate(changedProperties: PropertyValues): void {
if (changedProperties.has('minWidth') && this.index > -1) {
/** @internal */
this.dispatchEvent(
new CustomEvent('vsc-table-change-min-column-width', {
detail: {columnIndex: this.index, propertyValue: this.minWidth},
bubbles: true,
}) as VscTableChangeMinColumnWidthEvent
);
}
if (changedProperties.has('preferredWidth') && this.index > -1) {
/** @internal */
this.dispatchEvent(
new CustomEvent('vsc-table-change-preferred-column-width', {
detail: {columnIndex: this.index, propertyValue: this.preferredWidth},
bubbles: true,
}) as VscTableChangePreferredColumnWidthEvent
);
}
}
override render(): TemplateResult {
return html`
<div class="wrapper">
<slot></slot>
</div>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'vscode-table-header-cell': VscodeTableHeaderCell;
}
interface GlobalEventHandlersEventMap {
'vsc-table-change-min-column-width': VscTableChangeMinColumnWidthEvent;
'vsc-table-change-preferred-column-width': VscTableChangePreferredColumnWidthEvent;
}
}