docs-i18n 0.8.1 → 0.8.2
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.
- package/admin/dist/server/server.js +20 -20
- package/package.json +1 -1
- package/template/app/utils/content-loader.ts +4 -0
- package/template/app/utils/docs.server.ts +7 -0
- package/template/content/blog/en/announcing-query-v5.md +110 -0
- package/template/content/blog/en/hello-world.md +26 -0
- package/template/content/blog/en/i18n-best-practices.md +57 -0
- package/template/content/blog/en/react-query-vs-swr.md +100 -0
- package/template/content/blog/en/state-management-2024.md +143 -0
- package/template/content/blog/en/tanstack-router-1.0.md +121 -0
- package/template/content/blog/ja/announcing-query-v5.md +110 -0
- package/template/content/blog/ja/hello-world.md +26 -0
- package/template/content/blog/zh-hans/announcing-query-v5.md +93 -0
- package/template/content/blog/zh-hans/hello-world.md +26 -0
- package/template/content/docs-i18n/docs.config.json +25 -0
- package/template/content/docs-i18n/en/architecture.md +222 -0
- package/template/content/docs-i18n/en/configuration.md +331 -0
- package/template/content/docs-i18n/en/deployment.md +209 -0
- package/template/content/docs-i18n/en/getting-started.md +168 -0
- package/template/content/docs.config.json +25 -0
- package/template/content/en/admin.md +151 -0
- package/template/content/en/architecture.md +222 -0
- package/template/content/en/cli.md +269 -0
- package/template/content/en/configuration.md +331 -0
- package/template/content/en/deployment.md +209 -0
- package/template/content/en/getting-started.md +168 -0
- package/template/content/form/docs.config.json +18 -0
- package/template/content/form/en/guides/validation.md +175 -0
- package/template/content/form/en/installation.md +63 -0
- package/template/content/form/en/overview.md +71 -0
- package/template/content/form/en/quick-start.md +121 -0
- package/template/content/form/ja/installation.md +63 -0
- package/template/content/form/ja/overview.md +71 -0
- package/template/content/form/zh-hans/installation.md +63 -0
- package/template/content/form/zh-hans/overview.md +71 -0
- package/template/content/query/docs.config.json +32 -0
- package/template/content/query/en/guides/mutations.md +126 -0
- package/template/content/query/en/guides/pagination.md +98 -0
- package/template/content/query/en/guides/queries.md +120 -0
- package/template/content/query/en/installation.md +78 -0
- package/template/content/query/en/overview.md +72 -0
- package/template/content/query/en/quick-start.md +108 -0
- package/template/content/query/ja/installation.md +78 -0
- package/template/content/query/ja/overview.md +72 -0
- package/template/content/query/zh-hans/guides/mutations.md +126 -0
- package/template/content/query/zh-hans/guides/pagination.md +98 -0
- package/template/content/query/zh-hans/guides/queries.md +120 -0
- package/template/content/query/zh-hans/installation.md +95 -0
- package/template/content/query/zh-hans/overview.md +72 -0
- package/template/content/query/zh-hans/quick-start.md +108 -0
- package/template/content/router/docs.config.json +18 -0
- package/template/content/router/en/guides/routing-concepts.md +131 -0
- package/template/content/router/en/installation.md +57 -0
- package/template/content/router/en/overview.md +74 -0
- package/template/content/router/en/quick-start.md +88 -0
- package/template/content/router/ja/installation.md +57 -0
- package/template/content/router/ja/overview.md +78 -0
- package/template/content/router/zh-hans/guides/routing-concepts.md +131 -0
- package/template/content/router/zh-hans/installation.md +57 -0
- package/template/content/router/zh-hans/overview.md +81 -0
- package/template/content/router/zh-hans/quick-start.md +88 -0
- package/template/content/table/docs.config.json +18 -0
- package/template/content/table/en/guides/column-definitions.md +135 -0
- package/template/content/table/en/installation.md +56 -0
- package/template/content/table/en/overview.md +79 -0
- package/template/content/table/en/quick-start.md +112 -0
- package/template/content/table/ja/installation.md +56 -0
- package/template/content/table/ja/overview.md +79 -0
- package/template/content/table/zh-hans/installation.md +56 -0
- package/template/content/table/zh-hans/overview.md +79 -0
- package/template/content/virtual/docs.config.json +18 -0
- package/template/content/virtual/en/guides/dynamic-sizing.md +129 -0
- package/template/content/virtual/en/installation.md +57 -0
- package/template/content/virtual/en/overview.md +74 -0
- package/template/content/virtual/en/quick-start.md +114 -0
- package/template/content/virtual/ja/installation.md +57 -0
- package/template/content/virtual/ja/overview.md +74 -0
- package/template/content/virtual/zh-hans/installation.md +57 -0
- package/template/content/virtual/zh-hans/overview.md +74 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Quick Start
|
|
3
|
+
description: Get up and running with TanStack Virtual
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Quick Start
|
|
7
|
+
|
|
8
|
+
## Basic Vertical List
|
|
9
|
+
|
|
10
|
+
Create a virtualizer for a simple vertical list:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { useVirtualizer } from '@tanstack/react-virtual'
|
|
14
|
+
|
|
15
|
+
function RowVirtualizer() {
|
|
16
|
+
const parentRef = React.useRef<HTMLDivElement>(null)
|
|
17
|
+
|
|
18
|
+
const rowVirtualizer = useVirtualizer({
|
|
19
|
+
count: 10000,
|
|
20
|
+
getScrollElement: () => parentRef.current,
|
|
21
|
+
estimateSize: () => 35,
|
|
22
|
+
overscan: 5,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
ref={parentRef}
|
|
28
|
+
style={{ height: '400px', overflow: 'auto' }}
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
style={{
|
|
32
|
+
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
33
|
+
width: '100%',
|
|
34
|
+
position: 'relative',
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{rowVirtualizer.getVirtualItems().map((virtualRow) => (
|
|
38
|
+
<div
|
|
39
|
+
key={virtualRow.index}
|
|
40
|
+
style={{
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 0,
|
|
43
|
+
left: 0,
|
|
44
|
+
width: '100%',
|
|
45
|
+
height: `${virtualRow.size}px`,
|
|
46
|
+
transform: `translateY(${virtualRow.start}px)`,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
Row {virtualRow.index}
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Dynamic Row Heights
|
|
59
|
+
|
|
60
|
+
For variable-height items, provide a `measureElement` callback:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
const rowVirtualizer = useVirtualizer({
|
|
64
|
+
count: items.length,
|
|
65
|
+
getScrollElement: () => parentRef.current,
|
|
66
|
+
estimateSize: () => 50, // estimated height
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// In your rendered items:
|
|
70
|
+
{rowVirtualizer.getVirtualItems().map((virtualRow) => (
|
|
71
|
+
<div
|
|
72
|
+
key={virtualRow.index}
|
|
73
|
+
ref={rowVirtualizer.measureElement}
|
|
74
|
+
data-index={virtualRow.index}
|
|
75
|
+
>
|
|
76
|
+
{items[virtualRow.index].content}
|
|
77
|
+
</div>
|
|
78
|
+
))}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Horizontal List
|
|
82
|
+
|
|
83
|
+
Pass the `horizontal` option to virtualize a horizontal list:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
const columnVirtualizer = useVirtualizer({
|
|
87
|
+
horizontal: true,
|
|
88
|
+
count: 10000,
|
|
89
|
+
getScrollElement: () => parentRef.current,
|
|
90
|
+
estimateSize: () => 100,
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Grid Virtualization
|
|
95
|
+
|
|
96
|
+
Combine two virtualizers for grid layouts:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
const rowVirtualizer = useVirtualizer({
|
|
100
|
+
count: 10000,
|
|
101
|
+
getScrollElement: () => parentRef.current,
|
|
102
|
+
estimateSize: () => 35,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const columnVirtualizer = useVirtualizer({
|
|
106
|
+
horizontal: true,
|
|
107
|
+
count: 10000,
|
|
108
|
+
getScrollElement: () => parentRef.current,
|
|
109
|
+
estimateSize: () => 100,
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
> [!NOTE]
|
|
114
|
+
> The `overscan` option controls how many items are rendered outside the visible area. Higher values reduce flicker during fast scrolling but use more memory.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: インストール
|
|
3
|
+
description: プロジェクトに TanStack Virtual をインストールする方法
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# インストール
|
|
7
|
+
|
|
8
|
+
## React
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @tanstack/react-virtual
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @tanstack/react-virtual
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @tanstack/react-virtual
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun add @tanstack/react-virtual
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Vue
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @tanstack/vue-virtual
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Solid
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @tanstack/solid-virtual
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Svelte
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @tanstack/svelte-virtual
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 必要要件
|
|
45
|
+
|
|
46
|
+
- React 18+ / Vue 3+ / Solid 1.6+ / Svelte 4+
|
|
47
|
+
- 固定の高さ(水平リストの場合は幅)を持つスクロールコンテナ
|
|
48
|
+
|
|
49
|
+
## バンドルサイズ
|
|
50
|
+
|
|
51
|
+
TanStack Virtual は非常に軽量です:
|
|
52
|
+
|
|
53
|
+
| パッケージ | サイズ(gzip) |
|
|
54
|
+
|---------|---------------|
|
|
55
|
+
| `@tanstack/virtual-core` | ~2.5 KB |
|
|
56
|
+
| `@tanstack/react-virtual` | ~3.5 KB |
|
|
57
|
+
| `@tanstack/vue-virtual` | ~3.5 KB |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TanStack Virtual 概要
|
|
3
|
+
description: 大規模な要素リストを 60FPS で仮想化するヘッドレス UI
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TanStack Virtual
|
|
7
|
+
|
|
8
|
+
TanStack Virtual は、長いリスト要素を仮想化するためのヘッドレスユーティリティを提供します。スクロール位置に基づいてどのアイテムをレンダリングするかのロジックを処理し、マークアップとスタイルの完全な制御はあなたに委ねます。
|
|
9
|
+
|
|
10
|
+
## なぜ仮想化が必要なのか?
|
|
11
|
+
|
|
12
|
+
一度に数千の DOM ノードをレンダリングすると、深刻なパフォーマンスの問題が発生します。仮想化は、ビューポートに現在表示されているアイテムと少量のオーバースキャンバッファのみをレンダリングすることで、この問題を解決します。
|
|
13
|
+
|
|
14
|
+
## 特徴
|
|
15
|
+
|
|
16
|
+
- **フレームワーク非依存** — React、Vue、Solid、Svelte、バニラ JS で動作
|
|
17
|
+
- **垂直・水平** — 任意の方向でリストを仮想化
|
|
18
|
+
- **グリッド仮想化** — 垂直と水平のバーチャライザーを組み合わせてグリッドを実現
|
|
19
|
+
- **動的な行の高さ** — 可変サイズのアイテムと計測をサポート
|
|
20
|
+
- **固定アイテム** — スクロール領域の上部または下部にアイテムを固定
|
|
21
|
+
- **スクロール復元** — ナビゲーション間でスクロール位置を維持
|
|
22
|
+
- **極小バンドル** — gzip 後 5KB 未満
|
|
23
|
+
|
|
24
|
+
## 基本的な例
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useVirtualizer } from '@tanstack/react-virtual'
|
|
28
|
+
|
|
29
|
+
function VirtualList() {
|
|
30
|
+
const parentRef = React.useRef<HTMLDivElement>(null)
|
|
31
|
+
|
|
32
|
+
const virtualizer = useVirtualizer({
|
|
33
|
+
count: 10000,
|
|
34
|
+
getScrollElement: () => parentRef.current,
|
|
35
|
+
estimateSize: () => 35,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div ref={parentRef} style={{ height: '400px', overflow: 'auto' }}>
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
43
|
+
width: '100%',
|
|
44
|
+
position: 'relative',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{virtualizer.getVirtualItems().map((virtualItem) => (
|
|
48
|
+
<div
|
|
49
|
+
key={virtualItem.key}
|
|
50
|
+
style={{
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0,
|
|
54
|
+
width: '100%',
|
|
55
|
+
height: `${virtualItem.size}px`,
|
|
56
|
+
transform: `translateY(${virtualItem.start}px)`,
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
Row {virtualItem.index}
|
|
60
|
+
</div>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## TanStack Virtual を使うべき場面
|
|
69
|
+
|
|
70
|
+
- 100 件以上のアイテムを含むリスト
|
|
71
|
+
- 多数の行を持つテーブル
|
|
72
|
+
- チャット・メッセージインターフェース
|
|
73
|
+
- 無限スクロールフィード
|
|
74
|
+
- 大規模な動的データセットを含む任意の UI
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 安装
|
|
3
|
+
description: 如何在项目中安装 TanStack Virtual
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 安装
|
|
7
|
+
|
|
8
|
+
## React
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @tanstack/react-virtual
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @tanstack/react-virtual
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @tanstack/react-virtual
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
bun add @tanstack/react-virtual
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Vue
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @tanstack/vue-virtual
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Solid
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @tanstack/solid-virtual
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Svelte
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install @tanstack/svelte-virtual
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 环境要求
|
|
45
|
+
|
|
46
|
+
- React 18+ / Vue 3+ / Solid 1.6+ / Svelte 4+
|
|
47
|
+
- 具有固定高度(或水平列表的固定宽度)的滚动容器
|
|
48
|
+
|
|
49
|
+
## 包体积
|
|
50
|
+
|
|
51
|
+
TanStack Virtual 非常轻量:
|
|
52
|
+
|
|
53
|
+
| 包 | 大小(gzip) |
|
|
54
|
+
|---------|---------------|
|
|
55
|
+
| `@tanstack/virtual-core` | ~2.5 KB |
|
|
56
|
+
| `@tanstack/react-virtual` | ~3.5 KB |
|
|
57
|
+
| `@tanstack/vue-virtual` | ~3.5 KB |
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: TanStack Virtual 概览
|
|
3
|
+
description: 无头 UI,以 60FPS 虚拟化大型元素列表
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TanStack Virtual
|
|
7
|
+
|
|
8
|
+
TanStack Virtual 提供无头的虚拟化工具,用于处理长列表元素。它根据滚动位置处理渲染哪些项目的逻辑,同时你保留对标记和样式的完全控制。
|
|
9
|
+
|
|
10
|
+
## 为什么需要虚拟化?
|
|
11
|
+
|
|
12
|
+
一次渲染数千个 DOM 节点会导致严重的性能问题。虚拟化通过仅渲染当前在视口中可见的项目以及少量的预渲染缓冲来解决这个问题。
|
|
13
|
+
|
|
14
|
+
## 特性
|
|
15
|
+
|
|
16
|
+
- **框架无关** — 支持 React、Vue、Solid、Svelte 和原生 JS
|
|
17
|
+
- **垂直和水平** — 任意方向虚拟化列表
|
|
18
|
+
- **网格虚拟化** — 结合垂直和水平虚拟化器实现网格
|
|
19
|
+
- **动态行高** — 支持可变大小的项目及测量
|
|
20
|
+
- **固定项目** — 将项目固定在滚动区域的顶部或底部
|
|
21
|
+
- **滚动恢复** — 在导航中保持滚动位置
|
|
22
|
+
- **极小的包体积** — gzip 后不到 5KB
|
|
23
|
+
|
|
24
|
+
## 基本示例
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { useVirtualizer } from '@tanstack/react-virtual'
|
|
28
|
+
|
|
29
|
+
function VirtualList() {
|
|
30
|
+
const parentRef = React.useRef<HTMLDivElement>(null)
|
|
31
|
+
|
|
32
|
+
const virtualizer = useVirtualizer({
|
|
33
|
+
count: 10000,
|
|
34
|
+
getScrollElement: () => parentRef.current,
|
|
35
|
+
estimateSize: () => 35,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div ref={parentRef} style={{ height: '400px', overflow: 'auto' }}>
|
|
40
|
+
<div
|
|
41
|
+
style={{
|
|
42
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
43
|
+
width: '100%',
|
|
44
|
+
position: 'relative',
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
{virtualizer.getVirtualItems().map((virtualItem) => (
|
|
48
|
+
<div
|
|
49
|
+
key={virtualItem.key}
|
|
50
|
+
style={{
|
|
51
|
+
position: 'absolute',
|
|
52
|
+
top: 0,
|
|
53
|
+
left: 0,
|
|
54
|
+
width: '100%',
|
|
55
|
+
height: `${virtualItem.size}px`,
|
|
56
|
+
transform: `translateY(${virtualItem.start}px)`,
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
Row {virtualItem.index}
|
|
60
|
+
</div>
|
|
61
|
+
))}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 何时使用 TanStack Virtual
|
|
69
|
+
|
|
70
|
+
- 包含 100+ 项的列表
|
|
71
|
+
- 多行的表格
|
|
72
|
+
- 聊天/消息界面
|
|
73
|
+
- 无限滚动的信息流
|
|
74
|
+
- 任何包含大量动态数据集的 UI
|