-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathselection-column.ts
More file actions
46 lines (44 loc) · 1.17 KB
/
selection-column.ts
File metadata and controls
46 lines (44 loc) · 1.17 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
import { injectTableCellContext } from '@tanstack/angular-table'
import { ChangeDetectionStrategy, Component, computed } from '@angular/core'
import {
injectFlexRenderCellContext,
injectFlexRenderHeaderContext,
} from '../table'
@Component({
template: `
<input
type="checkbox"
[checked]="context.table.getIsAllRowsSelected()"
[indeterminate]="context.table.getIsSomeRowsSelected()"
(change)="context.table.toggleAllRowsSelected()"
/>
`,
host: {
class: 'px-1 block',
},
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TableHeaderSelection {
context = injectFlexRenderHeaderContext()
}
@Component({
template: `
<input
type="checkbox"
[checked]="context.row.getIsSelected()"
[disabled]="!context.row.getCanSelect()"
(change)="context.row.getToggleSelectedHandler()($event)"
/>
`,
host: {
class: 'px-1 block',
},
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TableRowSelection {
readonly cell = injectTableCellContext()
readonly row = computed(() => this.cell().row)
readonly context = injectFlexRenderCellContext()
}