Skip to content

Commit 4108c59

Browse files
authored
feat: per table, table meta and column meta (#6316)
1 parent 5e5ba41 commit 4108c59

48 files changed

Lines changed: 1194 additions & 465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
{ "label": "Cells", "to": "guide/cells" },
8585
{ "label": "Header Groups", "to": "guide/header-groups" },
8686
{ "label": "Headers", "to": "guide/headers" },
87-
{ "label": "Columns", "to": "guide/columns" }
87+
{ "label": "Columns", "to": "guide/columns" },
88+
{ "label": "Table and Column Meta", "to": "guide/table-and-column-meta" }
8889
],
8990
"frameworks": [
9091
{

docs/framework/angular/guide/migrating.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,9 +718,22 @@ import type { StockFeatures, ColumnDef } from '@tanstack/angular-table'
718718
const columns: ColumnDef<StockFeatures, Person>[] = [...]
719719
```
720720

721-
### `ColumnMeta` Generic Change
721+
### `TableMeta`/`ColumnMeta` Typing Changes
722722

723-
If you're using module augmentation to extend `ColumnMeta`, note that it now requires a `TFeatures` parameter.
723+
No more declaration merging required! (Although it still works if you want to keep using it)
724+
725+
Global declaration merging to extend `TableMeta` or `ColumnMeta` works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
726+
727+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
728+
729+
```ts
730+
const features = tableFeatures({
731+
rowSortingFeature,
732+
columnMeta: metaHelper<{ customProperty: string }>(),
733+
})
734+
```
735+
736+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
724737

725738
### `RowData` Type Restriction
726739

@@ -750,7 +763,7 @@ This change improves type safety. If you were passing unusual data types, ensure
750763
- [ ] Rename `sortingFn``sortFn` in column definitions
751764
- [ ] Split column sizing/resizing: use both `columnSizingFeature` and `columnResizingFeature` if needed
752765
- [ ] Rename `columnSizingInfo` state → `columnResizing` (and related options)
753-
- [ ] Update `ColumnMeta` module augmentation to include `TFeatures` generic (if used)
766+
- [ ] If you use `TableMeta`/`ColumnMeta` declaration merging, add the `TFeatures` generic to your augmentations (optionally, switch to the per-table `tableMeta`/`columnMeta` feature slots)
754767
- [ ] (Optional) Use `tableOptions()` for composable configurations
755768
- [ ] (Optional) Use `createTableHook` for reusable table patterns
756769

docs/framework/lit/guide/migrating.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ import type { StockFeatures } from '@tanstack/lit-table'
586586
type PersonColumn = ColumnDef<StockFeatures, Person>
587587
```
588588
589-
### `ColumnMeta` Generic Change
589+
### `TableMeta`/`ColumnMeta` Typing Changes
590+
591+
No more declaration merging required! (Although it still works if you want to keep using it)
592+
593+
Global declaration merging works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
590594
591595
```ts
592596
declare module '@tanstack/lit-table' {
@@ -596,6 +600,19 @@ declare module '@tanstack/lit-table' {
596600
}
597601
```
598602

603+
That's all that's required if you want to keep declaring meta types globally.
604+
605+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
606+
607+
```ts
608+
const features = tableFeatures({
609+
rowSortingFeature,
610+
columnMeta: metaHelper<{ align?: 'left' | 'right' }>(),
611+
})
612+
```
613+
614+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
615+
599616
### `RowData` Type Restriction
600617

601618
Prefer explicit object row types:

docs/framework/preact/guide/migrating.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,11 @@ import type { StockFeatures } from '@tanstack/preact-table'
573573
type PersonColumn = ColumnDef<StockFeatures, Person>
574574
```
575575
576-
### `ColumnMeta` Generic Change
576+
### `TableMeta`/`ColumnMeta` Typing Changes
577577
578-
Module augmentation now includes `TFeatures`:
578+
No more declaration merging required! (Although it still works if you want to keep using it)
579+
580+
Global declaration merging works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
579581
580582
```tsx
581583
declare module '@tanstack/preact-table' {
@@ -585,6 +587,19 @@ declare module '@tanstack/preact-table' {
585587
}
586588
```
587589

590+
That's all that's required if you want to keep declaring meta types globally.
591+
592+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
593+
594+
```tsx
595+
const features = tableFeatures({
596+
rowSortingFeature,
597+
columnMeta: metaHelper<{ align?: 'left' | 'right' }>(),
598+
})
599+
```
600+
601+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
602+
588603
### `RowData` Type Restriction
589604

590605
`RowData` is now constrained to record-like objects or arrays. Prefer object row types such as:

docs/framework/react/guide/migrating.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,9 +988,11 @@ import type { StockFeatures, ColumnDef } from '@tanstack/react-table'
988988
const columns: ColumnDef<StockFeatures, Person>[] = [...]
989989
```
990990

991-
### `ColumnMeta` Generic Change
991+
### `TableMeta`/`ColumnMeta` Typing Changes
992992

993-
If you're using module augmentation to extend `ColumnMeta`, note that it now requires a `TFeatures` parameter:
993+
No more declaration merging required! (Although it still works if you want to keep using it)
994+
995+
Global declaration merging to extend `TableMeta` or `ColumnMeta` works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
994996

995997
```tsx
996998
// v8
@@ -1008,6 +1010,19 @@ declare module '@tanstack/react-table' {
10081010
}
10091011
```
10101012

1013+
That's all that's required if you want to keep declaring meta types globally.
1014+
1015+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
1016+
1017+
```tsx
1018+
const features = tableFeatures({
1019+
rowSortingFeature,
1020+
columnMeta: metaHelper<{ customProperty: string }>(),
1021+
})
1022+
```
1023+
1024+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
1025+
10111026
### `RowData` Type Restriction
10121027

10131028
The `RowData` type is now more restrictive:
@@ -1037,7 +1052,7 @@ This change improves type safety. If you were passing unusual data types, ensure
10371052
- [ ] Rename `sortingFn``sortFn` in column definitions
10381053
- [ ] Split column sizing/resizing: use both `columnSizingFeature` and `columnResizingFeature` if needed
10391054
- [ ] Rename `columnSizingInfo` state`columnResizing` (and related options)
1040-
- [ ] Update `ColumnMeta` module augmentation to include `TFeatures` generic (if used)
1055+
- [ ] If you use `TableMeta`/`ColumnMeta` declaration merging, add the `TFeatures` generic to your augmentations (optionally, switch to the per-table `tableMeta`/`columnMeta` feature slots)
10411056
- [ ] (Optional) Add `table.Subscribe` for render optimizations
10421057
- [ ] (Optional) Subscribe to individual slices via `table.atoms.<slice>` + `useSelector` for the narrowest re-renders
10431058
- [ ] (Optional) Pass writable atoms via the new `atoms` option to own specific state slices externally

docs/framework/solid/guide/migrating.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,11 @@ import type { StockFeatures } from '@tanstack/solid-table'
542542
type PersonColumn = ColumnDef<StockFeatures, Person>
543543
```
544544
545-
### `ColumnMeta` Generic Change
545+
### `TableMeta`/`ColumnMeta` Typing Changes
546+
547+
No more declaration merging required! (Although it still works if you want to keep using it)
548+
549+
Global declaration merging works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
546550
547551
```tsx
548552
declare module '@tanstack/solid-table' {
@@ -552,6 +556,19 @@ declare module '@tanstack/solid-table' {
552556
}
553557
```
554558

559+
That's all that's required if you want to keep declaring meta types globally.
560+
561+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
562+
563+
```tsx
564+
const features = tableFeatures({
565+
rowSortingFeature,
566+
columnMeta: metaHelper<{ align?: 'left' | 'right' }>(),
567+
})
568+
```
569+
570+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
571+
555572
### `RowData` Type Restriction
556573

557574
Prefer explicit object row types:

docs/framework/svelte/guide/migrating.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ import type { StockFeatures } from '@tanstack/svelte-table'
621621
type PersonColumn = ColumnDef<StockFeatures, Person>
622622
```
623623
624-
### `ColumnMeta` Generic Change
624+
### `TableMeta`/`ColumnMeta` Typing Changes
625+
626+
No more declaration merging required! (Although it still works if you want to keep using it)
627+
628+
Global declaration merging works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
625629
626630
```ts
627631
declare module '@tanstack/svelte-table' {
@@ -631,6 +635,19 @@ declare module '@tanstack/svelte-table' {
631635
}
632636
```
633637

638+
That's all that's required if you want to keep declaring meta types globally.
639+
640+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
641+
642+
```ts
643+
const features = tableFeatures({
644+
rowSortingFeature,
645+
columnMeta: metaHelper<{ align?: 'left' | 'right' }>(),
646+
})
647+
```
648+
649+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
650+
634651
### `RowData` Type Restriction
635652

636653
Prefer explicit object row types:

docs/framework/vue/guide/migrating.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,11 @@ import type { StockFeatures } from '@tanstack/vue-table'
567567
type PersonColumn = ColumnDef<StockFeatures, Person>
568568
```
569569
570-
### `ColumnMeta` Generic Change
570+
### `TableMeta`/`ColumnMeta` Typing Changes
571+
572+
No more declaration merging required! (Although it still works if you want to keep using it)
573+
574+
Global declaration merging works exactly like it did in v8. The only change you need to make is updating the generics shape: both interfaces now take `TFeatures` as the first type parameter.
571575
572576
```ts
573577
declare module '@tanstack/vue-table' {
@@ -577,6 +581,19 @@ declare module '@tanstack/vue-table' {
577581
}
578582
```
579583

584+
That's all that's required if you want to keep declaring meta types globally.
585+
586+
Optionally, v9 also adds a new way to declare meta types **per-table** without declaration merging. You can use type-only `tableMeta`/`columnMeta` slots on the `features` option, which only affect tables created with that `features` object:
587+
588+
```ts
589+
const features = tableFeatures({
590+
rowSortingFeature,
591+
columnMeta: metaHelper<{ align?: 'left' | 'right' }>(),
592+
})
593+
```
594+
595+
See the new [Table and Column Meta Guide](../../../guide/table-and-column-meta) for full details on both approaches.
596+
580597
### `RowData` Type Restriction
581598

582599
Prefer explicit object row types:

0 commit comments

Comments
 (0)