Skip to content

Commit bcb4c78

Browse files
committed
clean up extra noinfer, angular examples
1 parent 525fbcb commit bcb4c78

File tree

20 files changed

+103
-99
lines changed

20 files changed

+103
-99
lines changed

examples/angular/column-ordering/src/app/app.component.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
FlexRenderDirective,
99
columnOrderingFeature,
1010
columnVisibilityFeature,
11-
createCoreRowModel,
1211
injectTable,
12+
tableFeatures,
1313
} from '@tanstack/angular-table'
1414
import { faker } from '@faker-js/faker'
1515
import { makeData } from './makeData'
@@ -20,7 +20,12 @@ import type {
2020
ColumnVisibilityState,
2121
} from '@tanstack/angular-table'
2222

23-
const defaultColumns: Array<ColumnDef<any, Person>> = [
23+
const _features = tableFeatures({
24+
columnVisibilityFeature,
25+
columnOrderingFeature,
26+
})
27+
28+
const defaultColumns: Array<ColumnDef<typeof _features, Person>> = [
2429
{
2530
header: 'Name',
2631
footer: (props) => props.column.id,
@@ -85,12 +90,9 @@ export class AppComponent {
8590
readonly columnOrder = signal<ColumnOrderState>([])
8691

8792
readonly table = injectTable(() => ({
88-
data: this.data(),
89-
_features: {
90-
columnVisibilityFeature,
91-
columnOrderingFeature,
92-
},
93+
_features,
9394
columns: defaultColumns,
95+
data: this.data(),
9496
state: {
9597
columnOrder: this.columnOrder(),
9698
columnVisibility: this.columnVisibility(),

examples/angular/column-pinning-sticky/src/app/app.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import {
66
columnResizingFeature,
77
columnSizingFeature,
88
columnVisibilityFeature,
9-
createCoreRowModel,
109
injectTable,
1110
} from '@tanstack/angular-table'
1211
import { faker } from '@faker-js/faker'
13-
import { NgStyle, NgTemplateOutlet, SlicePipe } from '@angular/common'
12+
import { NgStyle } from '@angular/common'
1413
import { makeData } from './makeData'
1514
import type {
1615
Column,
@@ -94,15 +93,15 @@ export class AppComponent {
9493
readonly split = signal(false)
9594

9695
table = injectTable(() => ({
97-
data: this.data(),
9896
_features: {
99-
columnPinningFeature,
100-
columnVisibilityFeature,
101-
columnSizingFeature,
10297
columnOrderingFeature,
98+
columnPinningFeature,
10399
columnResizingFeature,
100+
columnSizingFeature,
101+
columnVisibilityFeature,
104102
},
105103
columns: this.columns(),
104+
data: this.data(),
106105
debugTable: true,
107106
debugHeaders: true,
108107
debugColumns: true,

examples/angular/column-pinning/src/app/app.component.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import {
99
columnOrderingFeature,
1010
columnPinningFeature,
1111
columnVisibilityFeature,
12-
createCoreRowModel,
1312
injectTable,
14-
rowPinningFeature,
13+
tableFeatures,
1514
} from '@tanstack/angular-table'
1615
import { faker } from '@faker-js/faker'
1716
import { NgTemplateOutlet, SlicePipe } from '@angular/common'
@@ -32,7 +31,13 @@ type Person = {
3231
progress: number
3332
}
3433

35-
const defaultColumns: Array<ColumnDef<any, Person>> = [
34+
const _features = tableFeatures({
35+
columnPinningFeature,
36+
columnOrderingFeature,
37+
columnVisibilityFeature,
38+
})
39+
40+
const defaultColumns: Array<ColumnDef<typeof _features, Person>> = [
3641
{
3742
header: 'Name',
3843
footer: (props) => props.column.id,
@@ -102,13 +107,9 @@ export class AppComponent {
102107
readonly split = signal(false)
103108

104109
table = injectTable(() => ({
105-
data: this.data(),
106-
_features: {
107-
columnPinningFeature,
108-
columnOrderingFeature,
109-
columnVisibilityFeature,
110-
},
110+
_features,
111111
columns: defaultColumns,
112+
data: this.data(),
112113
state: {
113114
columnVisibility: this.columnVisibility(),
114115
columnOrder: this.columnOrder(),

examples/angular/column-visibility/src/app/app.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import {
66
} from '@angular/core'
77
import {
88
FlexRenderDirective,
9+
columnVisibilityFeature,
910
createCoreRowModel,
1011
injectTable,
12+
tableFeatures,
1113
} from '@tanstack/angular-table'
1214
import type { OnInit } from '@angular/core'
1315
import type { ColumnDef, ColumnVisibilityState } from '@tanstack/angular-table'
@@ -21,6 +23,10 @@ type Person = {
2123
progress: number
2224
}
2325

26+
const _features = tableFeatures({
27+
columnVisibilityFeature,
28+
})
29+
2430
const defaultData: Array<Person> = [
2531
{
2632
firstName: 'tanner',
@@ -48,7 +54,7 @@ const defaultData: Array<Person> = [
4854
},
4955
]
5056

51-
const defaultColumns: Array<ColumnDef<any, Person>> = [
57+
const defaultColumns: Array<ColumnDef<typeof _features, Person>> = [
5258
{
5359
header: 'Name',
5460
footer: (props) => props.column.id,
@@ -112,8 +118,9 @@ export class AppComponent implements OnInit {
112118
readonly columnVisibility = signal<ColumnVisibilityState>({})
113119

114120
table = injectTable(() => ({
115-
data: this.data(),
121+
_features,
116122
columns: defaultColumns,
123+
data: this.data(),
117124
state: {
118125
columnVisibility: this.columnVisibility(),
119126
},

examples/angular/filters/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<tbody>
4949
@for (row of table.getRowModel().rows; track row.id) {
5050
<tr>
51-
@for (cell of row.getVisibleCells(); track cell.id) {
51+
@for (cell of row.getAllCells(); track cell.id) {
5252
<td>
5353
<ng-container
5454
*flexRender="

examples/angular/filters/src/app/app.component.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
} from '@angular/core'
77
import {
88
FlexRenderDirective,
9+
columnFacetingFeature,
10+
columnFilteringFeature,
911
createCoreRowModel,
1012
createFacetedMinMaxValues,
1113
createFacetedRowModel,
@@ -15,6 +17,9 @@ import {
1517
createSortedRowModel,
1618
injectTable,
1719
isFunction,
20+
rowPaginationFeature,
21+
rowSortingFeature,
22+
tableFeatures,
1823
} from '@tanstack/angular-table'
1924
import { FormsModule } from '@angular/forms'
2025
import { NgClass } from '@angular/common'
@@ -27,6 +32,13 @@ import type {
2732
} from '@tanstack/angular-table'
2833
import type { Person } from './makeData'
2934

35+
export const _features = tableFeatures({
36+
columnFilteringFeature,
37+
columnFacetingFeature,
38+
rowPaginationFeature,
39+
rowSortingFeature,
40+
})
41+
3042
@Component({
3143
selector: 'app-root',
3244
standalone: true,
@@ -38,7 +50,7 @@ export class AppComponent {
3850
readonly columnFilters = signal<ColumnFiltersState>([])
3951
readonly data = signal(makeData(5000))
4052

41-
readonly columns: Array<ColumnDef<any, Person>> = [
53+
readonly columns: Array<ColumnDef<typeof _features, Person>> = [
4254
{
4355
accessorKey: 'firstName',
4456
cell: (info) => info.getValue(),
@@ -79,7 +91,8 @@ export class AppComponent {
7991
},
8092
]
8193

82-
table = injectTable<any, Person>(() => ({
94+
table = injectTable<typeof _features, Person>(() => ({
95+
_features,
8396
columns: this.columns,
8497
data: this.data(),
8598
state: {

examples/angular/filters/src/app/table-filter.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { CommonModule } from '@angular/common'
22
import { Component, computed, input } from '@angular/core'
33
import { DebouncedInputDirective } from './debounced-input.directive'
4+
import type { _features } from './app.component'
5+
import type { Person } from './makeData'
46
import type {
57
CellData,
68
Column,
@@ -90,13 +92,10 @@ declare module '@tanstack/angular-table' {
9092
standalone: true,
9193
imports: [CommonModule, DebouncedInputDirective],
9294
})
93-
export class FilterComponent<
94-
TFeatures extends TableFeatures,
95-
TData extends RowData,
96-
> {
97-
column = input.required<Column<any, any>>()
95+
export class FilterComponent {
96+
column = input.required<Column<typeof _features, Person>>()
9897

99-
table = input.required<Table<TFeatures, TData>>()
98+
table = input.required<Table<typeof _features, Person>>()
10099

101100
readonly filterVariant = computed(() => {
102101
return (this.column().columnDef.meta ?? {}).filterVariant

examples/angular/grouping/src/app/app.component.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,27 @@ import {
99
FlexRenderDirective,
1010
columnFilteringFeature,
1111
columnGroupingFeature,
12-
createCoreRowModel,
1312
createExpandedRowModel,
1413
createFilteredRowModel,
1514
createGroupedRowModel,
1615
createPaginatedRowModel,
1716
injectTable,
17+
isFunction,
1818
rowExpandingFeature,
1919
rowPaginationFeature,
20-
tableOptions,
20+
tableFeatures,
2121
} from '@tanstack/angular-table'
2222
import { columns } from './columns'
2323
import { makeData } from './makeData'
2424
import type { GroupingState, Updater } from '@tanstack/angular-table'
2525

26+
export const _features = tableFeatures({
27+
columnGroupingFeature,
28+
rowPaginationFeature,
29+
columnFilteringFeature,
30+
rowExpandingFeature,
31+
})
32+
2633
@Component({
2734
selector: 'app-root',
2835
standalone: true,
@@ -40,31 +47,25 @@ export class AppComponent {
4047
)
4148

4249
readonly table = injectTable(() => ({
50+
_features,
51+
_rowModels: {
52+
groupedRowModel: createGroupedRowModel(),
53+
expandedRowModel: createExpandedRowModel(),
54+
paginatedRowModel: createPaginatedRowModel(),
55+
filteredRowModel: createFilteredRowModel(),
56+
},
4357
data: this.data(),
44-
columns: columns,
58+
columns,
4559
initialState: {
4660
pagination: { pageSize: 20, pageIndex: 0 },
4761
},
4862
state: {
4963
grouping: this.grouping(),
5064
},
51-
_features: {
52-
columnGroupingFeature,
53-
rowPaginationFeature,
54-
columnFilteringFeature,
55-
rowExpandingFeature,
56-
},
57-
_rowModels: {
58-
groupedRowModel: createGroupedRowModel(),
59-
expandedRowModel: createExpandedRowModel(),
60-
paginatedRowModel: createPaginatedRowModel(),
61-
filteredRowModel: createFilteredRowModel(),
62-
},
6365
onGroupingChange: (updaterOrValue: Updater<GroupingState>) => {
64-
const groupingState =
65-
typeof updaterOrValue === 'function'
66-
? updaterOrValue([...this.grouping()])
67-
: updaterOrValue
66+
const groupingState = isFunction(updaterOrValue)
67+
? updaterOrValue([...this.grouping()])
68+
: updaterOrValue
6869
this.grouping.set(groupingState)
6970
},
7071
}))

examples/angular/grouping/src/app/columns.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { _features } from './app.component'
12
import type { ColumnDef } from '@tanstack/angular-table'
23

34
export type Person = {
@@ -10,7 +11,7 @@ export type Person = {
1011
subRows?: Array<Person>
1112
}
1213

13-
export const columns: Array<ColumnDef<any, Person>> = [
14+
export const columns: Array<ColumnDef<typeof _features, Person>> = [
1415
{
1516
header: 'Name',
1617
columns: [

examples/angular/row-selection-signal/src/app/app.component.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
injectTable,
1515
rowPaginationFeature,
1616
rowSelectionFeature,
17+
tableFeatures,
1718
} from '@tanstack/angular-table'
1819
import { FilterComponent } from './filter'
1920
import { makeData } from './makeData'
@@ -25,6 +26,13 @@ import type { Person } from './makeData'
2526
import type { ColumnDef, RowSelectionState } from '@tanstack/angular-table'
2627
import type { TemplateRef } from '@angular/core'
2728

29+
const _features = tableFeatures({
30+
columnFilteringFeature,
31+
columnVisibilityFeature,
32+
rowPaginationFeature,
33+
rowSelectionFeature,
34+
})
35+
2836
@Component({
2937
selector: 'app-root',
3038
standalone: true,
@@ -40,7 +48,7 @@ export class AppComponent {
4048
readonly ageHeaderCell =
4149
viewChild.required<TemplateRef<unknown>>('ageHeaderCell')
4250

43-
readonly columns: Array<ColumnDef<any, Person>> = [
51+
readonly columns: Array<ColumnDef<typeof _features, Person>> = [
4452
{
4553
id: 'select',
4654
header: () => TableHeadSelectionComponent<Person>,
@@ -99,17 +107,12 @@ export class AppComponent {
99107
]
100108

101109
table = injectTable(() => ({
102-
data: this.data(),
103-
_features: {
104-
rowSelectionFeature,
105-
rowPaginationFeature,
106-
columnFilteringFeature,
107-
columnVisibilityFeature,
108-
},
110+
_features,
109111
_rowModels: {
110112
filteredRowModel: createFilteredRowModel(),
111113
paginatedRowModel: createPaginatedRowModel(),
112114
},
115+
data: this.data(),
113116
columns: this.columns,
114117
state: {
115118
rowSelection: this.rowSelection(),

0 commit comments

Comments
 (0)