docs-i18n 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/admin/dist/server/server.js +32 -32
  2. package/package.json +1 -1
  3. package/template/app/routes/$lang.$project.$version.docs.$.tsx +2 -1
  4. package/template/app/routes/$lang.$project.$version.docs.framework.$framework.$.tsx +2 -0
  5. package/template/app/routes/$lang.$project.$version.docs.tsx +2 -1
  6. package/template/app/routes/$lang.$project.docs.$.tsx +2 -1
  7. package/template/app/routes/$lang.$project.docs.tsx +2 -1
  8. package/template/app/routes/$lang.docs.$.tsx +2 -1
  9. package/template/app/routes/$lang.docs.framework.$framework.$.tsx +2 -0
  10. package/template/app/routes/$lang.docs.tsx +2 -1
  11. package/template/app/utils/content-loader.ts +13 -2
  12. package/template/app/utils/docs.server.ts +17 -15
  13. package/template/content/blog/en/announcing-query-v5.md +110 -0
  14. package/template/content/blog/en/hello-world.md +26 -0
  15. package/template/content/blog/en/i18n-best-practices.md +57 -0
  16. package/template/content/blog/en/react-query-vs-swr.md +100 -0
  17. package/template/content/blog/en/state-management-2024.md +143 -0
  18. package/template/content/blog/en/tanstack-router-1.0.md +121 -0
  19. package/template/content/blog/ja/announcing-query-v5.md +110 -0
  20. package/template/content/blog/ja/hello-world.md +26 -0
  21. package/template/content/blog/zh-hans/announcing-query-v5.md +93 -0
  22. package/template/content/blog/zh-hans/hello-world.md +26 -0
  23. package/template/content/docs-i18n/docs.config.json +25 -0
  24. package/template/content/docs-i18n/en/architecture.md +335 -0
  25. package/template/content/docs-i18n/en/cli.md +13 -1
  26. package/template/content/docs-i18n/en/configuration.md +350 -0
  27. package/template/content/docs-i18n/en/deployment.md +222 -0
  28. package/template/content/docs-i18n/en/getting-started.md +189 -0
  29. package/template/content/docs.config.json +25 -0
  30. package/template/content/en/admin.md +151 -0
  31. package/template/content/en/architecture.md +222 -0
  32. package/template/content/en/cli.md +269 -0
  33. package/template/content/en/configuration.md +331 -0
  34. package/template/content/en/deployment.md +209 -0
  35. package/template/content/en/getting-started.md +168 -0
  36. package/template/content/form/docs.config.json +18 -0
  37. package/template/content/form/en/guides/validation.md +175 -0
  38. package/template/content/form/en/installation.md +63 -0
  39. package/template/content/form/en/overview.md +71 -0
  40. package/template/content/form/en/quick-start.md +121 -0
  41. package/template/content/form/ja/installation.md +63 -0
  42. package/template/content/form/ja/overview.md +71 -0
  43. package/template/content/form/zh-hans/installation.md +63 -0
  44. package/template/content/form/zh-hans/overview.md +71 -0
  45. package/template/content/query/docs.config.json +32 -0
  46. package/template/content/query/en/guides/mutations.md +126 -0
  47. package/template/content/query/en/guides/pagination.md +98 -0
  48. package/template/content/query/en/guides/queries.md +120 -0
  49. package/template/content/query/en/installation.md +78 -0
  50. package/template/content/query/en/overview.md +72 -0
  51. package/template/content/query/en/quick-start.md +108 -0
  52. package/template/content/query/ja/installation.md +78 -0
  53. package/template/content/query/ja/overview.md +72 -0
  54. package/template/content/query/zh-hans/guides/mutations.md +126 -0
  55. package/template/content/query/zh-hans/guides/pagination.md +98 -0
  56. package/template/content/query/zh-hans/guides/queries.md +120 -0
  57. package/template/content/query/zh-hans/installation.md +95 -0
  58. package/template/content/query/zh-hans/overview.md +72 -0
  59. package/template/content/query/zh-hans/quick-start.md +108 -0
  60. package/template/content/router/docs.config.json +18 -0
  61. package/template/content/router/en/guides/routing-concepts.md +131 -0
  62. package/template/content/router/en/installation.md +57 -0
  63. package/template/content/router/en/overview.md +74 -0
  64. package/template/content/router/en/quick-start.md +88 -0
  65. package/template/content/router/ja/installation.md +57 -0
  66. package/template/content/router/ja/overview.md +78 -0
  67. package/template/content/router/zh-hans/guides/routing-concepts.md +131 -0
  68. package/template/content/router/zh-hans/installation.md +57 -0
  69. package/template/content/router/zh-hans/overview.md +81 -0
  70. package/template/content/router/zh-hans/quick-start.md +88 -0
  71. package/template/content/table/docs.config.json +18 -0
  72. package/template/content/table/en/guides/column-definitions.md +135 -0
  73. package/template/content/table/en/installation.md +56 -0
  74. package/template/content/table/en/overview.md +79 -0
  75. package/template/content/table/en/quick-start.md +112 -0
  76. package/template/content/table/ja/installation.md +56 -0
  77. package/template/content/table/ja/overview.md +79 -0
  78. package/template/content/table/zh-hans/installation.md +56 -0
  79. package/template/content/table/zh-hans/overview.md +79 -0
  80. package/template/content/virtual/docs.config.json +18 -0
  81. package/template/content/virtual/en/guides/dynamic-sizing.md +129 -0
  82. package/template/content/virtual/en/installation.md +57 -0
  83. package/template/content/virtual/en/overview.md +74 -0
  84. package/template/content/virtual/en/quick-start.md +114 -0
  85. package/template/content/virtual/ja/installation.md +57 -0
  86. package/template/content/virtual/ja/overview.md +74 -0
  87. package/template/content/virtual/zh-hans/installation.md +57 -0
  88. package/template/content/virtual/zh-hans/overview.md +74 -0
@@ -0,0 +1,135 @@
1
+ ---
2
+ title: Column Definitions
3
+ description: Learn how to define and configure columns in TanStack Table
4
+ ---
5
+
6
+ # Column Definitions
7
+
8
+ Column definitions are the single most important part of building a table. They are responsible for defining the data model, how data is displayed, and what features each column supports.
9
+
10
+ ## Column Definition Types
11
+
12
+ TanStack Table supports three types of column definitions:
13
+
14
+ | Type | Purpose | Has data accessor? |
15
+ |---|---|---|
16
+ | **Accessor Columns** | Display data from your data model | Yes |
17
+ | **Display Columns** | Render arbitrary UI (e.g., action buttons) | No |
18
+ | **Group Columns** | Group other columns under a shared header | No |
19
+
20
+ ## Accessor Columns
21
+
22
+ Accessor columns are the most common type. They map directly to a field in your data:
23
+
24
+ ```tsx
25
+ import { createColumnHelper } from '@tanstack/react-table'
26
+
27
+ type Person = {
28
+ firstName: string
29
+ lastName: string
30
+ age: number
31
+ email: string
32
+ }
33
+
34
+ const columnHelper = createColumnHelper<Person>()
35
+
36
+ const columns = [
37
+ columnHelper.accessor('firstName', {
38
+ header: 'First Name',
39
+ cell: (info) => info.getValue(),
40
+ }),
41
+ columnHelper.accessor('lastName', {
42
+ header: 'Last Name',
43
+ }),
44
+ columnHelper.accessor('age', {
45
+ header: 'Age',
46
+ cell: (info) => <span className="font-mono">{info.getValue()}</span>,
47
+ }),
48
+ columnHelper.accessor('email', {
49
+ header: 'Email',
50
+ cell: (info) => (
51
+ <a href={`mailto:${info.getValue()}`} className="text-blue-600 underline">
52
+ {info.getValue()}
53
+ </a>
54
+ ),
55
+ }),
56
+ ]
57
+ ```
58
+
59
+ ## Display Columns
60
+
61
+ Display columns do not have a data accessor and are useful for rendering UI elements like action buttons or row selection checkboxes:
62
+
63
+ ```tsx
64
+ const columns = [
65
+ columnHelper.display({
66
+ id: 'select',
67
+ header: ({ table }) => (
68
+ <input
69
+ type="checkbox"
70
+ checked={table.getIsAllRowsSelected()}
71
+ onChange={table.getToggleAllRowsSelectedHandler()}
72
+ />
73
+ ),
74
+ cell: ({ row }) => (
75
+ <input
76
+ type="checkbox"
77
+ checked={row.getIsSelected()}
78
+ onChange={row.getToggleSelectedHandler()}
79
+ />
80
+ ),
81
+ }),
82
+ // ... accessor columns
83
+ columnHelper.display({
84
+ id: 'actions',
85
+ header: 'Actions',
86
+ cell: ({ row }) => (
87
+ <button onClick={() => handleEdit(row.original)}>Edit</button>
88
+ ),
89
+ }),
90
+ ]
91
+ ```
92
+
93
+ ## Column Sizing
94
+
95
+ You can control column widths through the column definition:
96
+
97
+ ```tsx
98
+ columnHelper.accessor('firstName', {
99
+ header: 'First Name',
100
+ size: 200, // default column size
101
+ minSize: 100, // minimum column size
102
+ maxSize: 300, // maximum column size
103
+ })
104
+ ```
105
+
106
+ > [!NOTE]
107
+ > Column sizes are specified in pixels. The table will attempt to respect these sizes but may adjust them based on available space and other column constraints.
108
+
109
+ ## Header Groups
110
+
111
+ Group columns allow you to create multi-level headers:
112
+
113
+ ```tsx
114
+ const columns = [
115
+ columnHelper.group({
116
+ id: 'name',
117
+ header: 'Name',
118
+ columns: [
119
+ columnHelper.accessor('firstName', { header: 'First' }),
120
+ columnHelper.accessor('lastName', { header: 'Last' }),
121
+ ],
122
+ }),
123
+ columnHelper.group({
124
+ id: 'info',
125
+ header: 'Info',
126
+ columns: [
127
+ columnHelper.accessor('age', { header: 'Age' }),
128
+ columnHelper.accessor('email', { header: 'Email' }),
129
+ ],
130
+ }),
131
+ ]
132
+ ```
133
+
134
+ > [!WARNING]
135
+ > When using group columns, make sure each group has a unique `id`. The `id` is required because group columns do not have an accessor to derive an ID from.
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Installation
3
+ description: How to install TanStack Table in your project
4
+ ---
5
+
6
+ # Installation
7
+
8
+ ## React
9
+
10
+ ```bash
11
+ npm install @tanstack/react-table
12
+ ```
13
+
14
+ ```bash
15
+ pnpm add @tanstack/react-table
16
+ ```
17
+
18
+ ```bash
19
+ yarn add @tanstack/react-table
20
+ ```
21
+
22
+ ```bash
23
+ bun add @tanstack/react-table
24
+ ```
25
+
26
+ ## Vue
27
+
28
+ ```bash
29
+ npm install @tanstack/vue-table
30
+ ```
31
+
32
+ ## Solid
33
+
34
+ ```bash
35
+ npm install @tanstack/solid-table
36
+ ```
37
+
38
+ ## Svelte
39
+
40
+ ```bash
41
+ npm install @tanstack/svelte-table
42
+ ```
43
+
44
+ ## Requirements
45
+
46
+ - TypeScript 4.7+ (recommended)
47
+ - React 18+ / Vue 3+ / Solid 1.6+ / Svelte 4+
48
+
49
+ ## Adapter Pattern
50
+
51
+ TanStack Table uses an adapter pattern. The core logic lives in `@tanstack/table-core`, while framework-specific packages provide thin wrappers:
52
+
53
+ ```ts
54
+ // The core is included automatically — you don't need to install it separately
55
+ import { getCoreRowModel } from '@tanstack/react-table'
56
+ ```
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: TanStack Table Overview
3
+ description: Headless UI for building powerful tables and datagrids
4
+ ---
5
+
6
+ # TanStack Table
7
+
8
+ TanStack Table is a headless UI library for building powerful tables and datagrids for TS/JS, React, Vue, Solid, and Svelte.
9
+
10
+ ## What is "Headless" UI?
11
+
12
+ Headless UI is a term for libraries and utilities that provide the logic, state, processing, and API for UI elements and interactions, but do not provide markup, styles, or pre-built implementations.
13
+
14
+ ## Features
15
+
16
+ - **Framework Agnostic** — Core logic works with React, Vue, Solid, Svelte, and vanilla JS
17
+ - **Sorting** — Multi-column sorting with customizable sort functions
18
+ - **Filtering** — Column and global filtering with custom filter functions
19
+ - **Pagination** — Client-side and server-side pagination
20
+ - **Row Selection** — Single and multi-row selection
21
+ - **Column Ordering & Pinning** — Reorder and pin columns
22
+ - **Column Sizing** — Resizable columns
23
+ - **Virtualization** — Virtual scrolling for large datasets (via TanStack Virtual)
24
+ - **Grouping & Aggregation** — Group rows and aggregate data
25
+
26
+ ## Basic Example
27
+
28
+ ```tsx
29
+ import { createColumnHelper, useReactTable, getCoreRowModel } from '@tanstack/react-table'
30
+
31
+ type Person = {
32
+ firstName: string
33
+ lastName: string
34
+ age: number
35
+ }
36
+
37
+ const columnHelper = createColumnHelper<Person>()
38
+
39
+ const columns = [
40
+ columnHelper.accessor('firstName', { header: 'First Name' }),
41
+ columnHelper.accessor('lastName', { header: 'Last Name' }),
42
+ columnHelper.accessor('age', { header: 'Age' }),
43
+ ]
44
+
45
+ function MyTable({ data }: { data: Person[] }) {
46
+ const table = useReactTable({
47
+ data,
48
+ columns,
49
+ getCoreRowModel: getCoreRowModel(),
50
+ })
51
+
52
+ return (
53
+ <table>
54
+ <thead>
55
+ {table.getHeaderGroups().map((headerGroup) => (
56
+ <tr key={headerGroup.id}>
57
+ {headerGroup.headers.map((header) => (
58
+ <th key={header.id}>
59
+ {flexRender(header.column.columnDef.header, header.getContext())}
60
+ </th>
61
+ ))}
62
+ </tr>
63
+ ))}
64
+ </thead>
65
+ <tbody>
66
+ {table.getRowModel().rows.map((row) => (
67
+ <tr key={row.id}>
68
+ {row.getVisibleCells().map((cell) => (
69
+ <td key={cell.id}>
70
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
71
+ </td>
72
+ ))}
73
+ </tr>
74
+ ))}
75
+ </tbody>
76
+ </table>
77
+ )
78
+ }
79
+ ```
@@ -0,0 +1,112 @@
1
+ ---
2
+ title: Quick Start
3
+ description: Get up and running with TanStack Table
4
+ ---
5
+
6
+ # Quick Start
7
+
8
+ ## Define Your Data
9
+
10
+ Start by defining the shape of your data:
11
+
12
+ ```ts
13
+ type Person = {
14
+ firstName: string
15
+ lastName: string
16
+ age: number
17
+ status: 'active' | 'inactive'
18
+ }
19
+
20
+ const data: Person[] = [
21
+ { firstName: 'Alice', lastName: 'Johnson', age: 32, status: 'active' },
22
+ { firstName: 'Bob', lastName: 'Smith', age: 45, status: 'inactive' },
23
+ { firstName: 'Carol', lastName: 'Williams', age: 28, status: 'active' },
24
+ ]
25
+ ```
26
+
27
+ ## Define Columns
28
+
29
+ Use the column helper for type-safe column definitions:
30
+
31
+ ```tsx
32
+ import { createColumnHelper } from '@tanstack/react-table'
33
+
34
+ const columnHelper = createColumnHelper<Person>()
35
+
36
+ const columns = [
37
+ columnHelper.accessor('firstName', {
38
+ header: 'First Name',
39
+ cell: (info) => info.getValue(),
40
+ }),
41
+ columnHelper.accessor('lastName', {
42
+ header: 'Last Name',
43
+ }),
44
+ columnHelper.accessor('age', {
45
+ header: 'Age',
46
+ }),
47
+ columnHelper.accessor('status', {
48
+ header: 'Status',
49
+ cell: (info) => (
50
+ <span className={info.getValue() === 'active' ? 'text-green-600' : 'text-red-600'}>
51
+ {info.getValue()}
52
+ </span>
53
+ ),
54
+ }),
55
+ ]
56
+ ```
57
+
58
+ ## Create the Table
59
+
60
+ ```tsx
61
+ import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table'
62
+
63
+ function DataTable() {
64
+ const table = useReactTable({
65
+ data,
66
+ columns,
67
+ getCoreRowModel: getCoreRowModel(),
68
+ })
69
+
70
+ return (
71
+ <table>
72
+ <thead>
73
+ {table.getHeaderGroups().map((headerGroup) => (
74
+ <tr key={headerGroup.id}>
75
+ {headerGroup.headers.map((header) => (
76
+ <th key={header.id}>
77
+ {flexRender(header.column.columnDef.header, header.getContext())}
78
+ </th>
79
+ ))}
80
+ </tr>
81
+ ))}
82
+ </thead>
83
+ <tbody>
84
+ {table.getRowModel().rows.map((row) => (
85
+ <tr key={row.id}>
86
+ {row.getVisibleCells().map((cell) => (
87
+ <td key={cell.id}>
88
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
89
+ </td>
90
+ ))}
91
+ </tr>
92
+ ))}
93
+ </tbody>
94
+ </table>
95
+ )
96
+ }
97
+ ```
98
+
99
+ ## Adding Sorting
100
+
101
+ Enable sorting by adding the sorting row model:
102
+
103
+ ```tsx
104
+ import { getSortedRowModel } from '@tanstack/react-table'
105
+
106
+ const table = useReactTable({
107
+ data,
108
+ columns,
109
+ getCoreRowModel: getCoreRowModel(),
110
+ getSortedRowModel: getSortedRowModel(),
111
+ })
112
+ ```
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: インストール
3
+ description: プロジェクトに TanStack Table をインストールする方法
4
+ ---
5
+
6
+ # インストール
7
+
8
+ ## React
9
+
10
+ ```bash
11
+ npm install @tanstack/react-table
12
+ ```
13
+
14
+ ```bash
15
+ pnpm add @tanstack/react-table
16
+ ```
17
+
18
+ ```bash
19
+ yarn add @tanstack/react-table
20
+ ```
21
+
22
+ ```bash
23
+ bun add @tanstack/react-table
24
+ ```
25
+
26
+ ## Vue
27
+
28
+ ```bash
29
+ npm install @tanstack/vue-table
30
+ ```
31
+
32
+ ## Solid
33
+
34
+ ```bash
35
+ npm install @tanstack/solid-table
36
+ ```
37
+
38
+ ## Svelte
39
+
40
+ ```bash
41
+ npm install @tanstack/svelte-table
42
+ ```
43
+
44
+ ## 必要要件
45
+
46
+ - TypeScript 4.7+(推奨)
47
+ - React 18+ / Vue 3+ / Solid 1.6+ / Svelte 4+
48
+
49
+ ## アダプターパターン
50
+
51
+ TanStack Table はアダプターパターンを採用しています。コアロジックは `@tanstack/table-core` にあり、フレームワーク固有のパッケージが薄いラッパーを提供します:
52
+
53
+ ```ts
54
+ // コアは自動的に含まれます — 別途インストールする必要はありません
55
+ import { getCoreRowModel } from '@tanstack/react-table'
56
+ ```
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: TanStack Table 概要
3
+ description: 強力なテーブルとデータグリッドを構築するためのヘッドレス UI
4
+ ---
5
+
6
+ # TanStack Table
7
+
8
+ TanStack Table は、TS/JS、React、Vue、Solid、Svelte 向けの強力なテーブルとデータグリッドを構築するためのヘッドレス UI ライブラリです。
9
+
10
+ ## 「ヘッドレス」UI とは?
11
+
12
+ ヘッドレス UI とは、UI 要素やインタラクションのロジック、状態、処理、API を提供しますが、マークアップ、スタイル、既成の実装は提供しないライブラリやユーティリティを指す用語です。
13
+
14
+ ## 特徴
15
+
16
+ - **フレームワーク非依存** — コアロジックは React、Vue、Solid、Svelte、バニラ JS で動作
17
+ - **ソート** — カスタマイズ可能なソート関数によるマルチカラムソート
18
+ - **フィルタリング** — カスタムフィルター関数によるカラム・グローバルフィルタリング
19
+ - **ページネーション** — クライアントサイドとサーバーサイドのページネーション
20
+ - **行選択** — 単一および複数行の選択
21
+ - **カラムの順序変更とピン留め** — カラムの並べ替えとピン留め
22
+ - **カラムのサイズ変更** — リサイズ可能なカラム
23
+ - **仮想化** — 大規模データセット向けの仮想スクロール(TanStack Virtual 使用)
24
+ - **グルーピングと集約** — 行のグループ化とデータの集約
25
+
26
+ ## 基本的な例
27
+
28
+ ```tsx
29
+ import { createColumnHelper, useReactTable, getCoreRowModel } from '@tanstack/react-table'
30
+
31
+ type Person = {
32
+ firstName: string
33
+ lastName: string
34
+ age: number
35
+ }
36
+
37
+ const columnHelper = createColumnHelper<Person>()
38
+
39
+ const columns = [
40
+ columnHelper.accessor('firstName', { header: 'First Name' }),
41
+ columnHelper.accessor('lastName', { header: 'Last Name' }),
42
+ columnHelper.accessor('age', { header: 'Age' }),
43
+ ]
44
+
45
+ function MyTable({ data }: { data: Person[] }) {
46
+ const table = useReactTable({
47
+ data,
48
+ columns,
49
+ getCoreRowModel: getCoreRowModel(),
50
+ })
51
+
52
+ return (
53
+ <table>
54
+ <thead>
55
+ {table.getHeaderGroups().map((headerGroup) => (
56
+ <tr key={headerGroup.id}>
57
+ {headerGroup.headers.map((header) => (
58
+ <th key={header.id}>
59
+ {flexRender(header.column.columnDef.header, header.getContext())}
60
+ </th>
61
+ ))}
62
+ </tr>
63
+ ))}
64
+ </thead>
65
+ <tbody>
66
+ {table.getRowModel().rows.map((row) => (
67
+ <tr key={row.id}>
68
+ {row.getVisibleCells().map((cell) => (
69
+ <td key={cell.id}>
70
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
71
+ </td>
72
+ ))}
73
+ </tr>
74
+ ))}
75
+ </tbody>
76
+ </table>
77
+ )
78
+ }
79
+ ```
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: 安装
3
+ description: 如何在项目中安装 TanStack Table
4
+ ---
5
+
6
+ # 安装
7
+
8
+ ## React
9
+
10
+ ```bash
11
+ npm install @tanstack/react-table
12
+ ```
13
+
14
+ ```bash
15
+ pnpm add @tanstack/react-table
16
+ ```
17
+
18
+ ```bash
19
+ yarn add @tanstack/react-table
20
+ ```
21
+
22
+ ```bash
23
+ bun add @tanstack/react-table
24
+ ```
25
+
26
+ ## Vue
27
+
28
+ ```bash
29
+ npm install @tanstack/vue-table
30
+ ```
31
+
32
+ ## Solid
33
+
34
+ ```bash
35
+ npm install @tanstack/solid-table
36
+ ```
37
+
38
+ ## Svelte
39
+
40
+ ```bash
41
+ npm install @tanstack/svelte-table
42
+ ```
43
+
44
+ ## 环境要求
45
+
46
+ - TypeScript 4.7+(推荐)
47
+ - React 18+ / Vue 3+ / Solid 1.6+ / Svelte 4+
48
+
49
+ ## 适配器模式
50
+
51
+ TanStack Table 采用适配器模式。核心逻辑位于 `@tanstack/table-core` 中,而各框架包提供轻量级的封装:
52
+
53
+ ```ts
54
+ // 核心会自动包含——无需单独安装
55
+ import { getCoreRowModel } from '@tanstack/react-table'
56
+ ```
@@ -0,0 +1,79 @@
1
+ ---
2
+ title: TanStack Table 概述
3
+ description: 用于构建强大表格和数据网格的无头 UI 库
4
+ ---
5
+
6
+ # TanStack Table
7
+
8
+ TanStack Table 是一个无头 UI 库,用于为 TS/JS、React、Vue、Solid 和 Svelte 构建强大的表格和数据网格。
9
+
10
+ ## 什么是"无头" UI?
11
+
12
+ 无头 UI 是指那些提供 UI 元素和交互的逻辑、状态、处理和 API,但不提供标记、样式或预构建实现的库和工具。
13
+
14
+ ## 特性
15
+
16
+ - **框架无关** — 核心逻辑支持 React、Vue、Solid、Svelte 和原生 JS
17
+ - **排序** — 多列排序,支持自定义排序函数
18
+ - **筛选** — 列筛选和全局筛选,支持自定义筛选函数
19
+ - **分页** — 客户端和服务端分页
20
+ - **行选择** — 单行和多行选择
21
+ - **列排序与固定** — 重新排列和固定列
22
+ - **列大小调整** — 可调整列宽
23
+ - **虚拟化** — 大数据集的虚拟滚动(通过 TanStack Virtual)
24
+ - **分组与聚合** — 对行进行分组和数据聚合
25
+
26
+ ## 基本示例
27
+
28
+ ```tsx
29
+ import { createColumnHelper, useReactTable, getCoreRowModel } from '@tanstack/react-table'
30
+
31
+ type Person = {
32
+ firstName: string
33
+ lastName: string
34
+ age: number
35
+ }
36
+
37
+ const columnHelper = createColumnHelper<Person>()
38
+
39
+ const columns = [
40
+ columnHelper.accessor('firstName', { header: 'First Name' }),
41
+ columnHelper.accessor('lastName', { header: 'Last Name' }),
42
+ columnHelper.accessor('age', { header: 'Age' }),
43
+ ]
44
+
45
+ function MyTable({ data }: { data: Person[] }) {
46
+ const table = useReactTable({
47
+ data,
48
+ columns,
49
+ getCoreRowModel: getCoreRowModel(),
50
+ })
51
+
52
+ return (
53
+ <table>
54
+ <thead>
55
+ {table.getHeaderGroups().map((headerGroup) => (
56
+ <tr key={headerGroup.id}>
57
+ {headerGroup.headers.map((header) => (
58
+ <th key={header.id}>
59
+ {flexRender(header.column.columnDef.header, header.getContext())}
60
+ </th>
61
+ ))}
62
+ </tr>
63
+ ))}
64
+ </thead>
65
+ <tbody>
66
+ {table.getRowModel().rows.map((row) => (
67
+ <tr key={row.id}>
68
+ {row.getVisibleCells().map((cell) => (
69
+ <td key={cell.id}>
70
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
71
+ </td>
72
+ ))}
73
+ </tr>
74
+ ))}
75
+ </tbody>
76
+ </table>
77
+ )
78
+ }
79
+ ```
@@ -0,0 +1,18 @@
1
+ {
2
+ "sections": [
3
+ {
4
+ "label": "Getting Started",
5
+ "children": [
6
+ { "label": "Overview", "to": "overview" },
7
+ { "label": "Installation", "to": "installation" },
8
+ { "label": "Quick Start", "to": "quick-start" }
9
+ ]
10
+ },
11
+ {
12
+ "label": "Guides",
13
+ "children": [
14
+ { "label": "Dynamic Sizing", "to": "guides/dynamic-sizing" }
15
+ ]
16
+ }
17
+ ]
18
+ }