Skip to content

Commit 63ea77c

Browse files
riccardoperraautofix-ci[bot]KevinVandy
authored
feat: add angular devtools support and fix core devtools reactivity (#6248)
* feat: add angular devtools * fix(table-devtools): fix table state reactivity Refactor devtools panel with a more solid-idiomatic approach, using memo and dynamic `useTableState` subscription via Accessor getter to not break reactivity. * Add devtools in all angular examples * Use a stable identifier reference to register devtools in table * Fix dependency versions * ci: apply automated fixes * generate instanceId for react-table * fix basic external store examples mark table.store as deprecated in adapter table types replace table.store.state with table.state in examples * add external atoms example in angular * update package lock * ci: apply automated fixes * update angular adapter for readonly atom reactivity pattern * add missing angular examples (WIP) * clean up devtools on examples * fix some angular reactivity * ci: apply automated fixes * fix solid and svelte reactivity issues * update docs gen * apply pr feedback * make state reads consistent in angular examples * ci: apply automated fixes * fix infinite render in angular column-pinning-split --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
1 parent 5093a27 commit 63ea77c

555 files changed

Lines changed: 18338 additions & 1847 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: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,11 @@
936936
{
937937
"label": "angular",
938938
"children": [
939-
{ "label": "Basic (Inject Table)", "to": "framework/angular/examples/basic-inject-table" },
940-
{ "label": "Basic (App Table)", "to": "framework/angular/examples/basic-app-table" }
939+
{ "label": "Basic (injectTable)", "to": "framework/angular/examples/basic-inject-table" },
940+
{ "label": "Basic (createAppTable)", "to": "framework/angular/examples/basic-app-table" },
941+
{ "label": "Basic (External State)", "to": "framework/angular/examples/basic-external-state" },
942+
{ "label": "Basic (External Atoms)", "to": "framework/angular/examples/basic-external-atoms" },
943+
{ "label": "Header Groups", "to": "framework/angular/examples/column-groups" }
941944
]
942945
},
943946
{
@@ -1020,15 +1023,22 @@
10201023
"label": "angular",
10211024
"children": [
10221025
{ "label": "Column Filters", "to": "framework/angular/examples/filters" },
1026+
{ "label": "Column Filters (Faceted)", "to": "framework/angular/examples/filters-faceted" },
1027+
{ "label": "Fuzzy Search Filters", "to": "framework/angular/examples/filters-fuzzy" },
10231028
{ "label": "Column Ordering", "to": "framework/angular/examples/column-ordering" },
10241029
{ "label": "Column Pinning", "to": "framework/angular/examples/column-pinning" },
1025-
{ "label": "Column Pinning (Sticky)", "to": "framework/angular/examples/column-pinning-sticky" },
1026-
{ "label": "Column Resizing", "to": "framework/angular/examples/column-resizing-performant" },
1030+
{ "label": "Column Pinning (Split)", "to": "framework/angular/examples/column-pinning-split" },
1031+
{ "label": "Sticky Column Pinning", "to": "framework/angular/examples/column-pinning-sticky" },
1032+
{ "label": "Column Sizing", "to": "framework/angular/examples/column-sizing" },
1033+
{ "label": "Column Resizing", "to": "framework/angular/examples/column-resizing" },
1034+
{ "label": "Performant Column Resizing", "to": "framework/angular/examples/column-resizing-performant" },
10271035
{ "label": "Column Visibility", "to": "framework/angular/examples/column-visibility" },
1028-
{ "label": "Row Expanding", "to": "framework/angular/examples/expanding" },
1029-
{ "label": "Column Grouping", "to": "framework/angular/examples/grouping" },
1036+
{ "label": "Expanding", "to": "framework/angular/examples/expanding" },
1037+
{ "label": "Grouping", "to": "framework/angular/examples/grouping" },
1038+
{ "label": "Pagination", "to": "framework/angular/examples/pagination" },
1039+
{ "label": "Row Pinning", "to": "framework/angular/examples/row-pinning" },
10301040
{ "label": "Row Selection", "to": "framework/angular/examples/row-selection" },
1031-
{ "label": "Row Selection (Signal)", "to": "framework/angular/examples/row-selection-signal" },
1041+
{ "label": "Sorting", "to": "framework/angular/examples/sorting" },
10321042
{ "label": "Kitchen Sink (All Features)", "to": "framework/angular/examples/kitchen-sink" }
10331043
]
10341044
},
@@ -1192,8 +1202,14 @@
11921202
{ "label": "Composable Tables", "to": "framework/angular/examples/composable-tables" },
11931203
{ "label": "Custom Plugin", "to": "framework/angular/examples/custom-plugin" },
11941204
{ "label": "Sub Components", "to": "framework/angular/examples/sub-components" },
1205+
{ "label": "With TanStack Virtual - Columns", "to": "framework/angular/examples/virtualized-columns" },
1206+
{ "label": "With TanStack Virtual - Rows", "to": "framework/angular/examples/virtualized-rows" },
1207+
{ "label": "With TanStack Virtual - Infinite Scrolling", "to": "framework/angular/examples/virtualized-infinite-scrolling" },
1208+
{ "label": "With TanStack Form", "to": "framework/angular/examples/with-tanstack-form" },
1209+
{ "label": "With TanStack Query", "to": "framework/angular/examples/with-tanstack-query" },
11951210
{ "label": "Fetch API data (SPA / SSR)", "to": "framework/angular/examples/remote-data" },
11961211
{ "label": "Signal Input", "to": "framework/angular/examples/signal-input" },
1212+
{ "label": "Row Selection (Signal)", "to": "framework/angular/examples/row-selection-signal" },
11971213
{ "label": "Editable data", "to": "framework/angular/examples/editable" },
11981214
{ "label": "Row Drag & Drop", "to": "framework/angular/examples/row-dnd" }
11991215
]

docs/framework/angular/guide/migrating.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,23 @@ const v9Table = injectTable(() => ({
277277

278278
### Accessing State
279279

280-
In v8, you accessed state via `table.getState()`. In v9, state is accessed via the store:
280+
In v8, you accessed state via `table.getState()`. In v9, read the specific
281+
state slice from `table.atoms.<slice>.get()` where possible. Use `table.state`
282+
when you need the full flat state shape, such as debug JSON.
281283

282284
```ts
283285
// v8
284286
const state = table.getState()
285287
const v8 = table.getState()
286288
const { sorting, pagination } = v8
287289

288-
// v9 - via the store
289-
const fullState = table.store.state
290-
const v9 = table.store.state
290+
// v9 - per-slice reads, preferred for Angular render code
291+
const sorting = table.atoms.sorting.get()
292+
const pagination = table.atoms.pagination.get()
293+
294+
// v9 - full-state flat proxy
295+
const fullState = table.state
296+
const v9 = table.state
291297
const { sorting: v9Sorting, pagination: v9Pagination } = v9
292298
```
293299

@@ -344,7 +350,7 @@ class TableCmp {
344350

345351
// Provide an equality function for object slices
346352
readonly pagination = computed(
347-
() => this.table.store.state.pagination,
353+
() => this.table.atoms.pagination.get(),
348354
{ equal: shallow },
349355
)
350356

@@ -732,7 +738,7 @@ The `RowData` type is now more restrictive.
732738
- [ ] Migrate `get*RowModel()` options to `_rowModels`
733739
- [ ] Update row model factories to include `Fns` parameters where needed
734740
- [ ] Update TypeScript types to include `TFeatures` generic
735-
- [ ] Update state access: `table.getState()``table.store.state`
741+
- [ ] Update state access: `table.getState().slice``table.atoms.<slice>.get()` where possible; use `table.state` for full-state/debug reads
736742
- [ ] Update `createColumnHelper<TData>()``createColumnHelper<TFeatures, TData>()`
737743
- [ ] Replace `enablePinning` with `enableColumnPinning`/`enableRowPinning` if used
738744
- [ ] Rename `sortingFn``sortFn` in column definitions
@@ -747,7 +753,7 @@ The `RowData` type is now more restrictive.
747753
## Examples
748754

749755
Check out these examples to see v9 patterns in action:
750-
- [Basic](../examples/basic)
756+
- [Basic (Inject Table)](../examples/basic-inject-table)
751757
- [Basic (App Table)](../examples/basic-app-table)
752758
- [Filters](../examples/filters)
753759
- [Column Ordering](../examples/column-ordering)

docs/framework/angular/guide/table-state.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ A table instance has a few state surfaces:
2828

2929
- `table.baseAtoms` are the internal writable atoms created from the resolved initial state.
3030
- `table.atoms` are readonly derived atoms exposed per registered state slice.
31-
- `table.store` is a readonly flat TanStack Store derived by putting all of the registered `table.atoms` together.
31+
- `table.state` is a readonly flat proxy over the registered `table.atoms`, useful for full-state debug output.
32+
- `table.store` is the underlying readonly flat TanStack Store. Prefer `table.atoms` or `table.state` in app code.
3233

3334
The Angular adapter provides `angularReactivity(injector)` as the table's reactivity binding. Core readonly atoms are Angular `computed` values, writable atoms are Angular `signal` values, and subscriptions bridge through `toObservable(computed(...), { injector })`. `injectTable` reruns the options initializer when Angular signals read inside it change, then calls `table.setOptions`.
3435

@@ -80,11 +81,11 @@ const pagination = this.table.atoms.pagination.get()
8081
const sorting = this.table.atoms.sorting.get()
8182
```
8283

83-
You can also read the current flat store snapshot:
84+
Use `table.state` when you need the current flat state shape, such as debug JSON:
8485

8586
```ts
86-
const tableState = this.table.store.state
87-
const pagination = this.table.store.state.pagination
87+
const tableState = this.table.state
88+
const stateJson = JSON.stringify(this.table.state, null, 2)
8889
```
8990

9091
Atom reads are signal reads in Angular. If `this.table.atoms.pagination.get()` is used in a template expression, `computed(...)`, or `effect(...)`, Angular tracks it and updates when that atom changes.
@@ -115,11 +116,11 @@ readonly pagination = computed(
115116
readonly pageIndex = computed(() => this.pagination().pageIndex)
116117
```
117118

118-
You can also select from the flat store if that is more convenient.
119+
You can also select from the flat state proxy if that is more convenient, but prefer direct atoms for narrow render reads.
119120

120121
```ts
121122
readonly pagination = computed(
122-
() => this.table.store.state.pagination,
123+
() => this.table.state.pagination,
123124
{ equal: shallow },
124125
)
125126
```

docs/framework/angular/reference/functions/injectTable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: injectTable
99
function injectTable<TFeatures, TData>(options): AngularTable<TFeatures, TData>;
1010
```
1111

12-
Defined in: [packages/angular-table/src/injectTable.ts:92](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L92)
12+
Defined in: [packages/angular-table/src/injectTable.ts:106](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L106)
1313

1414
Creates and returns an Angular-reactive table instance.
1515

docs/framework/angular/reference/type-aliases/AngularTable.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,34 @@ title: AngularTable
66
# Type Alias: AngularTable\<TFeatures, TData\>
77

88
```ts
9-
type AngularTable<TFeatures, TData> = Table<TFeatures, TData>;
9+
type AngularTable<TFeatures, TData> = Table<TFeatures, TData> & object;
1010
```
1111

12-
Defined in: [packages/angular-table/src/injectTable.ts:31](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L31)
12+
Defined in: [packages/angular-table/src/injectTable.ts:33](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L33)
13+
14+
## Type Declaration
15+
16+
### state
17+
18+
```ts
19+
readonly state: Readonly<TableState<TFeatures>>;
20+
```
21+
22+
The current table state exposed as a flat proxy. Prefer
23+
`table.atoms.<slice>.get()` when reading a specific slice.
24+
25+
### ~~store~~
26+
27+
```ts
28+
readonly store: Table<TFeatures, TData>["store"];
29+
```
30+
31+
#### Deprecated
32+
33+
Prefer `table.atoms.<slice>.get()` for template/render reads
34+
of a specific state slice, `table.state` for full-state debug snapshots, or
35+
Angular computed values around explicit selectors. `table.store.state` is a
36+
current-value snapshot and is easy to misuse in render code.
1337

1438
## Type Parameters
1539

docs/framework/angular/reference/type-aliases/SubscribeSource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type SubscribeSource<TValue> =
1313
| ReadonlyStore<TValue>;
1414
```
1515

16-
Defined in: [packages/angular-table/src/injectTable.ts:25](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L25)
16+
Defined in: [packages/angular-table/src/injectTable.ts:27](https://github.com/TanStack/table/blob/main/packages/angular-table/src/injectTable.ts#L27)
1717

1818
## Type Parameters
1919

docs/framework/lit/reference/classes/TableController.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: TableController
55

66
# Class: TableController\<TFeatures, TData\>
77

8-
Defined in: [TableController.ts:132](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L132)
8+
Defined in: [TableController.ts:139](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L139)
99

1010
A Lit ReactiveController for TanStack Table integration.
1111

@@ -57,7 +57,7 @@ class MyTable extends LitElement {
5757
new TableController<TFeatures, TData>(host): TableController<TFeatures, TData>;
5858
```
5959

60-
Defined in: [TableController.ts:143](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L143)
60+
Defined in: [TableController.ts:150](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L150)
6161

6262
#### Parameters
6363

@@ -77,7 +77,7 @@ Defined in: [TableController.ts:143](https://github.com/TanStack/table/blob/main
7777
host: ReactiveControllerHost;
7878
```
7979

80-
Defined in: [TableController.ts:136](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L136)
80+
Defined in: [TableController.ts:143](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L143)
8181

8282
## Methods
8383

@@ -87,7 +87,7 @@ Defined in: [TableController.ts:136](https://github.com/TanStack/table/blob/main
8787
hostConnected(): void;
8888
```
8989

90-
Defined in: [TableController.ts:244](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L244)
90+
Defined in: [TableController.ts:251](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L251)
9191

9292
Called when the host is connected to the component tree. For custom
9393
element hosts, this corresponds to the `connectedCallback()` lifecycle,
@@ -111,7 +111,7 @@ ReactiveController.hostConnected
111111
hostDisconnected(): void;
112112
```
113113

114-
Defined in: [TableController.ts:248](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L248)
114+
Defined in: [TableController.ts:255](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L255)
115115

116116
Called when the host is disconnected from the component tree. For custom
117117
element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
@@ -136,7 +136,7 @@ ReactiveController.hostDisconnected
136136
table<TSelected>(tableOptions, selector?): LitTable<TFeatures, TData, TSelected>;
137137
```
138138
139-
Defined in: [TableController.ts:163](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L163)
139+
Defined in: [TableController.ts:170](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L170)
140140
141141
Returns the Lit-backed table instance for the current render pass.
142142

docs/framework/lit/reference/type-aliases/LitTable.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: LitTable
66
# Type Alias: LitTable\<TFeatures, TData, TSelected\>
77

88
```ts
9-
type LitTable<TFeatures, TData, TSelected> = Table<TFeatures, TData> & object;
9+
type LitTable<TFeatures, TData, TSelected> = Omit<Table<TFeatures, TData>, "store"> & object;
1010
```
1111

1212
Defined in: [TableController.ts:30](https://github.com/TanStack/table/blob/main/packages/lit-table/src/TableController.ts#L30)
@@ -41,7 +41,7 @@ readonly state: Readonly<TSelected>;
4141
```
4242

4343
The selected state of the table. This state may not match the structure of
44-
`table.store.state` because it is selected by the `selector` function that
44+
the full table state because it is selected by the selector function that
4545
you pass as the 2nd argument to `controller.table()`.
4646

4747
#### Example
@@ -54,6 +54,19 @@ const table = this.tableController.table(options, (state) => ({
5454
console.log(table.state.globalFilter)
5555
```
5656

57+
### ~~store~~
58+
59+
```ts
60+
readonly store: Table<TFeatures, TData>["store"];
61+
```
62+
63+
#### Deprecated
64+
65+
Prefer `table.state` for render reads,
66+
`table.atoms.<slice>.get()` for slice snapshots, or `table.Subscribe` for
67+
explicit subscriptions. `table.store.state` is a current-value snapshot and
68+
is easy to misuse in render code.
69+
5770
### Subscribe()
5871

5972
```ts

docs/framework/preact/guide/create-table-hook.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: createTableHook Guide
33
---
44

5-
`createTableHook` is an advanced API for building reusable, composable table configurations in Preact. It mirrors the [React `createTableHook` API](../react/guide/create-table-hook) — you define features, row models, and pre-bound components once, then reuse them across multiple tables with minimal boilerplate.
5+
`createTableHook` is an advanced API for building reusable, composable table configurations in Preact. It mirrors the [React `createTableHook` API](../../react/guide/create-table-hook) — you define features, row models, and pre-bound components once, then reuse them across multiple tables with minimal boilerplate.
66

77
> **When to use it:** Use `createTableHook` when you have multiple tables that share the same configuration. For a single table, `useTable` is sufficient.
88
@@ -165,5 +165,5 @@ Same as React: `table.AppTable`, `table.AppHeader`, `table.AppCell`, and `table.
165165

166166
## See Also
167167

168-
- [React createTableHook Guide](../react/guide/create-table-hook) — The React guide has more detailed examples and the same API.
169-
- [Composable Tables (React)](../react/examples/composable-tables) — Reference implementation (Preact API mirrors React).
168+
- [React createTableHook Guide](../../react/guide/create-table-hook) — The React guide has more detailed examples and the same API.
169+
- [Composable Tables (React)](../../react/examples/composable-tables) — Reference implementation (Preact API mirrors React).

docs/framework/preact/reference/functions/useTable.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: useTable
99
function useTable<TFeatures, TData, TSelected>(tableOptions, selector?): PreactTable<TFeatures, TData, TSelected>;
1010
```
1111

12-
Defined in: [useTable.ts:103](https://github.com/TanStack/table/blob/main/packages/preact-table/src/useTable.ts#L103)
12+
Defined in: [useTable.ts:113](https://github.com/TanStack/table/blob/main/packages/preact-table/src/useTable.ts#L113)
1313

1414
Creates a Preact table instance backed by TanStack Store atoms.
1515

0 commit comments

Comments
 (0)