Skip to content

Commit da372f6

Browse files
committed
add new devtools POC
1 parent ffde8d8 commit da372f6

32 files changed

Lines changed: 2018 additions & 68 deletions

docs/installation.md

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,51 @@ title: Installation
44

55
Before we dig in to the API, let's get you set up!
66

7-
Install your table adapter as a dependency using your favorite npm package manager.
7+
Install your table adapter as a dependency using your preferred package manager:
88

9-
_Only install ONE of the following packages:_
9+
<!-- ::start:tabs variant="package-managers" -->
1010

11-
## React Table
11+
react: @tanstack/react-table
12+
vue: @tanstack/vue-table
13+
solid: @tanstack/solid-table
14+
svelte: @tanstack/svelte-table
15+
angular: @tanstack/angular-table
16+
lit: @tanstack/lit-table
1217

13-
```bash
14-
npm install @tanstack/react-table
15-
```
18+
<!-- ::end:tabs -->
1619

17-
The `@tanstack/react-table` package works with React 16.8, React 17, React 18, and React 19.
18-
19-
> NOTE: Even though the react adapter works with React 19, it may not work with the new React Compiler that's coming out along-side React 19. This may be fixed in future TanStack Table updates.
20+
<!-- ::start:framework -->
2021

21-
## Vue Table
22+
# React
2223

23-
```bash
24-
npm install @tanstack/vue-table
25-
```
24+
The `@tanstack/react-table` package works with React 16.8, React 17, React 18, and React 19.
2625

27-
The `@tanstack/vue-table` package works with Vue 3.
26+
> [!NOTE]
27+
> Even though the React adapter works with React 19, it may not work with the new React Compiler that's coming out alongside React 19. This may be fixed in future TanStack Table updates.
2828
29-
## Solid Table
29+
# Vue
3030

31-
```bash
32-
npm install @tanstack/solid-table
33-
```
31+
The `@tanstack/vue-table` package works with Vue 3.
3432

35-
The `@tanstack/solid-table` package works with Solid-JS 1
33+
# Solid
3634

37-
## Svelte Table
35+
The `@tanstack/solid-table` package works with Solid-JS 1.
3836

39-
```bash
40-
npm install @tanstack/svelte-table
41-
```
37+
# Svelte
4238

4339
The `@tanstack/svelte-table` package works with Svelte 3 and Svelte 4.
4440

45-
> NOTE: There is not a built-in Svelte 5 adapter yet, but you can still use TanStack Table with Svelte 5 by installing the `@tanstack/table-core` package and using a custom adapter from the community. See this [PR](https://github.com/TanStack/table/pull/5403) for inspiration.
46-
47-
## Angular Table
41+
> [!NOTE]
42+
> There is not a built-in Svelte 5 adapter yet, but you can still use TanStack Table with Svelte 5 by installing the `@tanstack/table-core` package and using a custom adapter from the community. See this [PR](https://github.com/TanStack/table/pull/5403) for inspiration.
4843
49-
```bash
50-
npm install @tanstack/angular-table
51-
```
44+
# Angular
5245

5346
The `@tanstack/angular-table` package works with Angular 17. The Angular adapter uses a new Angular Signal implementation.
5447

55-
## Lit Table
56-
57-
```bash
58-
npm install @tanstack/lit-table
59-
```
48+
# Lit
6049

6150
The `@tanstack/lit-table` package works with Lit 3.
6251

63-
## Table Core (no framework)
64-
65-
```bash
66-
npm install @tanstack/table-core
67-
```
52+
<!-- ::end:framework -->
6853

6954
Don't see your favorite framework (or favorite version of your framework) listed? You can always just use the `@tanstack/table-core` package and build your own adapter in your own codebase. Usually, only a thin wrapper is needed to manage state and rendering for your specific framework. Browse the [source code](https://github.com/TanStack/table/tree/main/packages) of all of the other adapters to see how they work.

examples/react/row-selection/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"react-dom": "^19.2.4"
1919
},
2020
"devDependencies": {
21+
"@tanstack/react-devtools": "0.9.6",
22+
"@tanstack/react-table-devtools": "9.0.0-alpha.11",
2123
"@rollup/plugin-replace": "^6.0.3",
2224
"@types/react": "^19.2.10",
2325
"@types/react-dom": "^19.2.3",

examples/react/row-selection/src/main.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import {
1212
tableFeatures,
1313
useTable,
1414
} from '@tanstack/react-table'
15+
import {
16+
tableDevtoolsPlugin,
17+
} from '@tanstack/react-table-devtools'
18+
import { TanStackDevtools } from '@tanstack/react-devtools'
1519
import { makeData } from './makeData'
1620
import type { HTMLProps } from 'react'
1721
import type { Person } from './makeData'
@@ -111,16 +115,17 @@ function App() {
111115
)
112116

113117
return (
114-
<table.Subscribe
115-
selector={(state) => ({
116-
// don't include row selection state to optimize re-renders
117-
columnFilters: state.columnFilters,
118-
globalFilter: state.globalFilter,
119-
pagination: state.pagination,
120-
})}
121-
>
122-
{(state) => (
123-
<div className="p-2">
118+
<>
119+
<table.Subscribe
120+
selector={(state) => ({
121+
// don't include row selection state to optimize re-renders
122+
columnFilters: state.columnFilters,
123+
globalFilter: state.globalFilter,
124+
pagination: state.pagination,
125+
})}
126+
>
127+
{(state) => (
128+
<div className="p-2">
124129
<div>
125130
<input
126131
value={state.globalFilter ?? ''}
@@ -306,9 +311,11 @@ function App() {
306311
{(state) => <pre>{JSON.stringify(state, null, 2)}</pre>}
307312
</table.Subscribe>
308313
</div>
309-
</div>
310-
)}
311-
</table.Subscribe>
314+
</div>
315+
)}
316+
</table.Subscribe>
317+
<TanStackDevtools plugins={[tableDevtoolsPlugin({ table })]} />
318+
</>
312319
)
313320
}
314321

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"packageManager": "pnpm@10.28.2",
99
"type": "module",
1010
"scripts": {
11-
"build": "nx run-many --targets=build -p @tanstack/table-core @tanstack/react-table @tanstack/preact-table @tanstack/angular-table && size-limit",
12-
"build:all": "nx run-many --targets=build -p @tanstack/table-core @tanstack/react-table @tanstack/preact-table @tanstack/angular-table && size-limit",
11+
"build": "nx run-many --targets=build -p @tanstack/table-core @tanstack/react-table @tanstack/table-devtools @tanstack/react-table-devtools @tanstack/preact-table @tanstack/angular-table && size-limit",
12+
"build:all": "nx run-many --targets=build -p @tanstack/table-core @tanstack/react-table @tanstack/table-devtools @tanstack/react-table-devtools @tanstack/preact-table @tanstack/angular-table && size-limit",
1313
"build:core": "nx build @tanstack/table-core && size-limit",
1414
"cipublish": "node scripts/publish.js",
1515
"clean": "find . -name 'dist' -type d -prune -exec rm -rf {} +",
@@ -23,7 +23,7 @@
2323
"size": "size-limit",
2424
"test": "pnpm run test:ci",
2525
"test:build": "nx affected --target=test:build --exclude='examples/{lit,solid,svelte,vanilla,vue}/**' --exclude='packages/{lit-table,solid-table,svelte-table,vue-table,match-sorter-utils}'",
26-
"test:ci": "nx run-many --targets=test:eslint,test:sherif,test:knip,test:lib,test:types,test:build,build -p @tanstack/table-core @tanstack/react-table @tanstack/preact-table @tanstack/angular-table 'examples/react/**' 'examples/preact/**' 'examples/angular/**'",
26+
"test:ci": "nx run-many --targets=test:eslint,test:sherif,test:knip,test:lib,test:types,test:build,build -p @tanstack/table-core @tanstack/react-table @tanstack/table-devtools @tanstack/react-table-devtools @tanstack/preact-table @tanstack/angular-table 'examples/react/**' 'examples/preact/**' 'examples/angular/**'",
2727
"test:docs": "node scripts/verify-links.ts",
2828
"test:eslint": "nx affected --target=test:eslint --exclude='examples/{lit,solid,svelte,vanilla,vue}/**' --exclude='packages/{lit-table,solid-table,svelte-table,vue-table,match-sorter-utils}'",
2929
"test:knip": "knip",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @ts-check
2+
3+
import pluginReact from '@eslint-react/eslint-plugin'
4+
import pluginReactCompiler from 'eslint-plugin-react-compiler'
5+
import pluginReactHooks from 'eslint-plugin-react-hooks'
6+
import rootConfig from '../../eslint.config.js'
7+
8+
/** @type {any} */
9+
const config = [
10+
...rootConfig,
11+
{
12+
files: ['**/*.{ts,tsx}'],
13+
...pluginReact.configs.recommended,
14+
},
15+
{
16+
plugins: {
17+
'react-hooks': pluginReactHooks,
18+
'react-compiler': pluginReactCompiler,
19+
},
20+
rules: {
21+
'@eslint-react/dom/no-missing-button-type': 'off',
22+
'react-compiler/react-compiler': 'error',
23+
'react-hooks/exhaustive-deps': 'error',
24+
'react-hooks/rules-of-hooks': 'error',
25+
},
26+
},
27+
]
28+
29+
export default config
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"name": "@tanstack/react-table-devtools",
3+
"version": "9.0.0-alpha.11",
4+
"description": "React devtools for TanStack Table.",
5+
"author": "Tanner Linsley",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/TanStack/table.git",
10+
"directory": "packages/react-table-devtools"
11+
},
12+
"homepage": "https://tanstack.com/table",
13+
"funding": {
14+
"type": "github",
15+
"url": "https://github.com/sponsors/tannerlinsley"
16+
},
17+
"keywords": ["react", "tanstack", "table", "devtools"],
18+
"scripts": {
19+
"clean": "rimraf ./build && rimraf ./dist",
20+
"test:eslint": "eslint ./src",
21+
"test:lib": "vitest --passWithNoTests",
22+
"test:lib:dev": "pnpm test:lib --watch",
23+
"test:types": "tsc",
24+
"test:build": "publint --strict",
25+
"build": "vite build"
26+
},
27+
"type": "module",
28+
"types": "dist/esm/index.d.ts",
29+
"module": "dist/esm/index.js",
30+
"exports": {
31+
".": {
32+
"import": {
33+
"types": "./dist/esm/index.d.ts",
34+
"default": "./dist/esm/index.js"
35+
}
36+
},
37+
"./production": {
38+
"import": {
39+
"types": "./dist/esm/production.d.ts",
40+
"default": "./dist/esm/production.js"
41+
}
42+
},
43+
"./package.json": "./package.json"
44+
},
45+
"sideEffects": false,
46+
"engines": {
47+
"node": ">=16"
48+
},
49+
"files": ["dist", "src"],
50+
"dependencies": {
51+
"@tanstack/devtools-utils": "^0.3.0",
52+
"@tanstack/table-core": "workspace:*",
53+
"@tanstack/table-devtools": "workspace:*"
54+
},
55+
"devDependencies": {
56+
"@eslint-react/eslint-plugin": "^2.13.0",
57+
"@types/react": "^19.2.10",
58+
"@vitejs/plugin-react": "^5.1.2",
59+
"eslint-plugin-react-compiler": "19.1.0-rc.2",
60+
"eslint-plugin-react-hooks": "^7.0.1",
61+
"react": "^19.2.4"
62+
},
63+
"peerDependencies": {
64+
"react": ">=18",
65+
"react-dom": ">=18"
66+
}
67+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react'
2+
import { createReactPanel } from '@tanstack/devtools-utils/react'
3+
import { TableDevtoolsCore, setTableDevtoolsTarget } from '@tanstack/table-devtools'
4+
5+
import type { RowData, Table, TableFeatures } from '@tanstack/table-core'
6+
import type { DevtoolsPanelProps } from '@tanstack/devtools-utils/react'
7+
8+
export interface TableDevtoolsReactInit<
9+
TFeatures extends TableFeatures = TableFeatures,
10+
TData extends RowData = RowData,
11+
> extends DevtoolsPanelProps {
12+
table?: Table<TFeatures, TData>
13+
}
14+
15+
const [TableDevtoolsPanelBase, TableDevtoolsPanelNoOp] =
16+
createReactPanel(TableDevtoolsCore)
17+
18+
function TableDevtoolsPanel(props: TableDevtoolsReactInit) {
19+
setTableDevtoolsTarget(props.table)
20+
return <TableDevtoolsPanelBase theme={props.theme} />
21+
}
22+
23+
export { TableDevtoolsPanel, TableDevtoolsPanelNoOp }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use client'
2+
3+
import * as Devtools from './ReactTableDevtools'
4+
import * as plugin from './plugin'
5+
6+
export const TableDevtoolsPanel =
7+
process.env.NODE_ENV !== 'development'
8+
? Devtools.TableDevtoolsPanelNoOp
9+
: Devtools.TableDevtoolsPanel
10+
11+
export const tableDevtoolsPlugin =
12+
process.env.NODE_ENV !== 'development'
13+
? plugin.tableDevtoolsNoOpPlugin
14+
: plugin.tableDevtoolsPlugin
15+
16+
export type { TableDevtoolsReactInit } from './ReactTableDevtools'
17+
export type { TableDevtoolsPluginOptions } from './plugin'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react'
2+
import { TableDevtoolsPanel } from './ReactTableDevtools'
3+
import type { RowData, Table, TableFeatures } from '@tanstack/table-core'
4+
5+
export interface TableDevtoolsPluginOptions<
6+
TFeatures extends TableFeatures = TableFeatures,
7+
TData extends RowData = RowData,
8+
> {
9+
table: Table<TFeatures, TData>
10+
}
11+
12+
function tableDevtoolsPlugin<
13+
TFeatures extends TableFeatures = TableFeatures,
14+
TData extends RowData = RowData,
15+
>(options: TableDevtoolsPluginOptions<TFeatures, TData>) {
16+
return {
17+
name: 'TanStack Table',
18+
render: (_el: HTMLElement, theme: 'light' | 'dark') => (
19+
<TableDevtoolsPanel table={options.table} theme={theme} />
20+
),
21+
}
22+
}
23+
24+
function tableDevtoolsNoOpPlugin<
25+
TFeatures extends TableFeatures = TableFeatures,
26+
TData extends RowData = RowData,
27+
>(_options: TableDevtoolsPluginOptions<TFeatures, TData>) {
28+
return {
29+
name: 'TanStack Table',
30+
render: (_el: HTMLElement, _theme: 'light' | 'dark') => <></>,
31+
}
32+
}
33+
34+
export { tableDevtoolsPlugin, tableDevtoolsNoOpPlugin }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client'
2+
3+
export { TableDevtoolsPanel } from './ReactTableDevtools'
4+
export type { TableDevtoolsReactInit } from './ReactTableDevtools'
5+
export { tableDevtoolsPlugin } from './plugin'
6+
export type { TableDevtoolsPluginOptions } from './plugin'

0 commit comments

Comments
 (0)