@cloudtower/eagle 490.0.7 → 490.0.8

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.
@@ -0,0 +1,199 @@
1
+ # Table
2
+
3
+ ## 简介
4
+
5
+ Table 是基于 antd Table 二次封装的表格组件,提供统一的 CloudTower 表格样式。用于展示结构化数据列表,支持排序、行选择、展开行、加载状态、错误状态等功能。数据源要求每条记录包含 id 字段作为唯一标识。
6
+
7
+ ## 何时使用
8
+
9
+ - 展示结构化的数据列表(如虚拟机列表、主机列表、集群列表)
10
+ - 需要排序、筛选、分页等交互功能
11
+ - 需要行选择(单选/多选)进行批量操作
12
+ - 需要展开行显示详细信息
13
+
14
+ 不要使用:
15
+
16
+ - 行内编辑场景 --> 请用 `TableForm`
17
+ - 键值对信息展示 --> 请用 `SummaryTable`
18
+ - 纯拖拽排序(不需要表格结构) --> 请用 `SortableList`
19
+
20
+ ## 基础用法
21
+
22
+ ```tsx
23
+ import React from "react";
24
+ import { Table } from "@cloudtower/eagle";
25
+
26
+ interface VMData {
27
+ id: string;
28
+ name: string;
29
+ status: string;
30
+ cpu: number;
31
+ memory: number;
32
+ }
33
+
34
+ const columns = [
35
+ { key: "name", title: "名称", dataIndex: "name" },
36
+ { key: "status", title: "状态", dataIndex: "status" },
37
+ { key: "cpu", title: "CPU (核)", dataIndex: "cpu" },
38
+ { key: "memory", title: "内存 (MB)", dataIndex: "memory" },
39
+ ];
40
+
41
+ const vms: VMData[] = [
42
+ {
43
+ id: "vm-001",
44
+ name: "web-server-01",
45
+ status: "running",
46
+ cpu: 4,
47
+ memory: 8192,
48
+ },
49
+ {
50
+ id: "vm-002",
51
+ name: "db-server-01",
52
+ status: "running",
53
+ cpu: 8,
54
+ memory: 16384,
55
+ },
56
+ ];
57
+
58
+ const App = () => <Table<VMData> columns={columns} dataSource={vms} />;
59
+ ```
60
+
61
+ ## 常见模式
62
+
63
+ ### 模式一:行选择
64
+
65
+ 配合 `rowSelection` 实现行选择功能,常用于批量操作场景。
66
+
67
+ ```tsx
68
+ import React, { useState } from "react";
69
+ import { Table } from "@cloudtower/eagle";
70
+
71
+ interface VMData {
72
+ id: string;
73
+ name: string;
74
+ status: string;
75
+ }
76
+
77
+ const App = () => {
78
+ const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
79
+
80
+ return (
81
+ <Table<VMData>
82
+ columns={columns}
83
+ dataSource={vms}
84
+ rowSelection={{
85
+ selectedRowKeys: selectedKeys,
86
+ onChange: (keys) => setSelectedKeys(keys as string[]),
87
+ }}
88
+ />
89
+ );
90
+ };
91
+ ```
92
+
93
+ ### 模式二:排序功能
94
+
95
+ 通过 `onSorterChange` 回调处理排序逻辑,列配置中设置 `sorter: true` 启用排序。
96
+
97
+ ```tsx
98
+ import React from "react";
99
+ import { Table } from "@cloudtower/eagle";
100
+
101
+ const columns = [
102
+ { key: "name", title: "名称", dataIndex: "name", sorter: true },
103
+ { key: "cpu", title: "CPU", dataIndex: "cpu", sorter: true },
104
+ ];
105
+
106
+ const App = () => {
107
+ const handleSorterChange = (order, key) => {
108
+ console.log("排序:", order, key);
109
+ };
110
+
111
+ return (
112
+ <Table<VMData>
113
+ columns={columns}
114
+ dataSource={vms}
115
+ onSorterChange={handleSorterChange}
116
+ />
117
+ );
118
+ };
119
+ ```
120
+
121
+ ### 模式三:加载与错误状态
122
+
123
+ 通过 `loading` 显示骨架屏加载状态,通过 `error` 显示错误信息。
124
+
125
+ ```tsx
126
+ import React from "react";
127
+ import { Table } from "@cloudtower/eagle";
128
+
129
+ const App = () => {
130
+ const { data, isLoading, isError } = useFetchVMs();
131
+
132
+ return (
133
+ <Table<VMData>
134
+ columns={columns}
135
+ dataSource={data}
136
+ loading={isLoading}
137
+ error={isError ? "加载失败,请重试" : undefined}
138
+ />
139
+ );
140
+ };
141
+ ```
142
+
143
+ ### 模式四:可展开行
144
+
145
+ 通过 `expandable` 配置展开行内容,适用于显示详细信息。
146
+
147
+ ```tsx
148
+ import React from "react";
149
+ import { Table } from "@cloudtower/eagle";
150
+
151
+ const App = () => (
152
+ <Table<VMData>
153
+ columns={columns}
154
+ dataSource={vms}
155
+ expandable={{
156
+ expandedRowRender: (record) => (
157
+ <div>
158
+ <p>ID: {record.id}</p>
159
+ <p>详细信息: ...</p>
160
+ </div>
161
+ ),
162
+ rowExpandable: (record) => record.status === "running",
163
+ }}
164
+ />
165
+ );
166
+ ```
167
+
168
+ ### 模式五:行操作菜单
169
+
170
+ 在列配置中添加操作列,渲染操作按钮或菜单。
171
+
172
+ ```tsx
173
+ import React from "react";
174
+ import { Table, Button, Icon } from "@cloudtower/eagle";
175
+ import { MoreEllipsis316BoldBlueIcon } from "@cloudtower/icons-react";
176
+
177
+ const columns = [
178
+ { key: "name", title: "名称", dataIndex: "name" },
179
+ {
180
+ key: "action",
181
+ title: "操作",
182
+ render: (_, record) => (
183
+ <Button
184
+ size="small"
185
+ type="tertiary"
186
+ prefixIcon={<Icon src={MoreEllipsis316BoldBlueIcon} />}
187
+ onClick={() => console.log("操作:", record)}
188
+ />
189
+ ),
190
+ },
191
+ ];
192
+ ```
193
+
194
+ ## 相关组件
195
+
196
+ - `TableForm`: 表格表单,用于行内编辑场景
197
+ - `SummaryTable`: 摘要表格,用于键值对信息展示
198
+ - `BatchOperation`: 批量操作工具栏,配合行选择使用
199
+ - `Pagination`: 分页器,用于分页控制
package/docs/llms.txt CHANGED
@@ -54,7 +54,7 @@ npm 包名:@cloudtower/eagle
54
54
 
55
55
  ## 数据展示
56
56
 
57
- - Table: 表格,封装 antd Table
57
+ - [Table](core/Table/guide.md): 表格组件,基于 antd Table 二次封装,支持排序、行选择、展开行、加载/错误状态
58
58
  - Tab: 标签页,封装 antd Tabs
59
59
  - Collapse: 折叠面板(继承 antd Collapse)
60
60
  - Tag: 标签,支持多种预设颜色
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudtower/eagle",
3
- "version": "490.0.7",
3
+ "version": "490.0.8",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "sync:color": "node tools/fetch-figma-color.js"
28
28
  },
29
29
  "dependencies": {
30
- "@cloudtower/icons-react": "^490.0.7",
31
- "@cloudtower/parrot": "^490.0.7",
30
+ "@cloudtower/icons-react": "^490.0.8",
31
+ "@cloudtower/parrot": "^490.0.8",
32
32
  "@cloudtower/rc-notification": "^4.6.1",
33
33
  "@linaria/core": "^4.2.2",
34
34
  "@linaria/react": "^4.3.0",
@@ -116,5 +116,5 @@
116
116
  "vite": "^4.5.1",
117
117
  "vitest": "^3.1.1"
118
118
  },
119
- "gitHead": "1a6679790080e9e7795cddbdc2eea5411e0d5456"
119
+ "gitHead": "2cb4416270f3177c216eae26478125019dd52175"
120
120
  }