@canvas-components/react-list-table 0.3.48 → 0.3.50

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/README.md CHANGED
@@ -1,386 +1,386 @@
1
- # @canvas-components/react-list-table
2
-
3
- `@canvas-components/react-list-table` 是 `@canvas-components/list-table` 的 React 适配层,负责把原生 Canvas 表格接入 React 应用,并提供更接近业务开发习惯的组件化入口。
4
-
5
- 通过顶层 `loading` 属性控制数据加载状态:`<ReactListTable loading={loading} dataSource={rows} columns={columns} />`。加载期间展示加载提示并保留汇总标题;加载完成后,组件自动计算并统一展示完整汇总结果。服务端汇总可通过 `query.summaryValues` 提供,业务侧无需单独管理汇总计算状态。
6
-
7
- ## 属性更新与性能
8
-
9
- - 相同属性引用的父组件重渲染由 `React.memo` 跳过;组件内部交互仍正常更新。
10
- - `onChange`、`onRow` 以及查询、分页、行选择、展开、拖拽和性能通知等事件使用稳定入口,调用时读取最近一次已提交的回调,避免仅回调引用变化就重置底层查询。
11
- - `scroll`、`theme`、`pagination` 等常用配置进行第一层字段比较,内容相同的新对象复用之前的配置。嵌套对象和数组仍按引用判断。
12
- - `columns`、`dataSource`、受控选中/展开数组,以及 `rowKey`、列渲染、`getCheckboxProps` 等影响数据或展示的函数,变化时继续刷新。大数据数组不做深比较,建议用 `useMemo` 或稳定状态保存,并在内容改变时更新引用。
13
-
14
- ## 示例效果
15
-
16
- ![React List Table 基础示例](./assets/examples/basic.gif)
17
-
18
- ### 完整示例图集
19
-
20
- <details>
21
- <summary>100w 数据渲染</summary>
22
-
23
- ![100w 数据渲染](./assets/examples/million-rows.gif)
24
-
25
- </details>
26
-
27
- <details>
28
- <summary>行选择</summary>
29
-
30
- ![行选择](./assets/examples/row-selection.gif)
31
-
32
- </details>
33
-
34
- <details>
35
- <summary>单元格内容</summary>
36
-
37
- ![单元格内容](./assets/examples/cell-content.gif)
38
-
39
- </details>
40
-
41
- <details>
42
- <summary>斑马条纹</summary>
43
-
44
- ![斑马条纹](./assets/examples/striped.gif)
45
-
46
- </details>
47
-
48
- <details>
49
- <summary>主题切换</summary>
50
-
51
- ![主题切换](./assets/examples/theme.gif)
52
-
53
- </details>
54
-
55
- <details>
56
- <summary>高亮模式</summary>
57
-
58
- ![高亮模式](./assets/examples/highlight-mode.gif)
59
-
60
- </details>
61
-
62
- <details>
63
- <summary>右键菜单</summary>
64
-
65
- ![右键菜单](./assets/examples/context-menu.gif)
66
-
67
- </details>
68
-
69
- <details>
70
- <summary>数据格式</summary>
71
-
72
- ![数据格式](./assets/examples/data-format.gif)
73
-
74
- </details>
75
-
76
- <details>
77
- <summary>省略提示</summary>
78
-
79
- ![省略提示](./assets/examples/ellipsis-tooltip.gif)
80
-
81
- </details>
82
-
83
- <details>
84
- <summary>可展开行</summary>
85
-
86
- ![可展开行](./assets/examples/expandable.gif)
87
-
88
- </details>
89
-
90
- <details>
91
- <summary>单元格编辑</summary>
92
-
93
- ![单元格编辑](./assets/examples/editable-cell.gif)
94
-
95
- </details>
96
-
97
- <details>
98
- <summary>远程查询</summary>
99
-
100
- ![远程查询](./assets/examples/remote-query.gif)
101
-
102
- </details>
103
-
104
- <details>
105
- <summary>表格分页</summary>
106
-
107
- ![表格分页](./assets/examples/pagination.gif)
108
-
109
- </details>
110
-
111
- <details>
112
- <summary>空状态</summary>
113
-
114
- ![空状态](./assets/examples/empty-state.gif)
115
-
116
- </details>
117
-
118
- <details>
119
- <summary>宽高配置</summary>
120
-
121
- ![宽高配置](./assets/examples/sized.gif)
122
-
123
- </details>
124
-
125
- <details>
126
- <summary>表头排序、过滤、固定</summary>
127
-
128
- ![表头排序、过滤、固定](./assets/examples/header-actions.gif)
129
-
130
- </details>
131
-
132
- <details>
133
- <summary>多级表头</summary>
134
-
135
- ![多级表头](./assets/examples/multi-header.gif)
136
-
137
- </details>
138
-
139
- <details>
140
- <summary>汇总行</summary>
141
-
142
- ![汇总行](./assets/examples/summary-row.gif)
143
-
144
- </details>
145
-
146
- <details>
147
- <summary>合并行列</summary>
148
-
149
- ![合并行列](./assets/examples/merged-cells.gif)
150
-
151
- </details>
152
-
153
- <details>
154
- <summary>拖动改变列宽</summary>
155
-
156
- ![拖动改变列宽](./assets/examples/resize.gif)
157
-
158
- </details>
159
-
160
- <details>
161
- <summary>轮播滚动</summary>
162
-
163
- ![轮播滚动](./assets/examples/carousel-scroll.gif)
164
-
165
- </details>
166
-
167
- <details>
168
- <summary>缓存配置</summary>
169
-
170
- ![缓存配置](./assets/examples/cached-columns.gif)
171
-
172
- </details>
173
-
174
- <details>
175
- <summary>拖拽表头排序</summary>
176
-
177
- ![拖拽表头排序](./assets/examples/draggable.gif)
178
-
179
- </details>
180
-
181
- <details>
182
- <summary>跨表行拖拽</summary>
183
-
184
- ![跨表行拖拽](./assets/examples/row-drag.gif)
185
-
186
- </details>
187
-
188
- <details>
189
- <summary>超级示例</summary>
190
-
191
- ![超级示例](./assets/examples/super.gif)
192
-
193
- </details>
194
-
195
- ## 功能作用
196
-
197
- - 提供 `ReactListTable` 组件
198
- - 内置工具栏、分页层、编辑层、tooltip、图片预览
199
- - 暴露 `ref` 方法,方便外部校验和滚动定位
200
- - 保持底层大数据性能和纯原生渲染能力
201
-
202
- ## 安装方法
203
-
204
- ```bash
205
- pnpm add @canvas-components/react-list-table @canvas-components/list-table react@^16.8 react-dom@^16.8
206
- ```
207
-
208
- 最低依赖版本:
209
-
210
- - `react >= 16.8.0`
211
- - `react-dom >= 16.8.0`
212
- - `Node.js >= 18.12.0`
213
- - `pnpm >= 9.0.0`
214
-
215
- ## 使用方法
216
-
217
- 打印配置可以通过 `printPresets` 预设交给 `ReactListTable`。每个预设有一个用于选择的名称和打印配置;未提供的字段使用默认值。没有已保存配置时默认使用第一个预设,也可以在打印配置弹窗中切换;启用本地缓存后,后续打开优先恢复所选预设和本地修改。
218
-
219
- ```tsx
220
- import {
221
- ReactListTable,
222
- type ReactListTablePrintPreset,
223
- } from "@canvas-components/react-list-table";
224
-
225
- const printPresets: ReactListTablePrintPreset[] = [
226
- {
227
- name: "横向明细",
228
- config: {
229
- title: "明细清单",
230
- paperSize: "a4",
231
- orientation: "landscape",
232
- rowsPerPage: 24,
233
- pageMargins: { top: 10, right: 10, bottom: 10, left: 10 },
234
- columns: [
235
- { key: "name", width: 60, align: "left" },
236
- { key: "amount", width: 35, align: "right" },
237
- ],
238
- selectedKeys: ["name", "amount"],
239
- },
240
- },
241
- ];
242
-
243
- <ReactListTable
244
- storageKey="invoice-list"
245
- printPresets={printPresets}
246
- columns={columns}
247
- dataSource={data}
248
- />;
249
- ```
250
-
251
- 配置名称显示在打印配置弹窗顶部。列通过 `key` 对应表格列;列宽单位为毫米。需要缓存预设选择和用户调整时提供 `storageKey` 并保持弹窗中的本地缓存选项开启。
252
-
253
- 右键直接打印(包括选择模板打印)会先显示“每次打印页数”设置,默认每批 50 页。可通过 `directPrintPagesPerBatch={20}` 修改默认值,用户仍可在开始前调整。每批只生成并加载指定数量的实际打印页(包括自动续页),关闭浏览器打印窗口后释放该批 iframe;点击“继续下一批”才生成后续批次,也可以取消剩余任务。浏览器无法区分打印窗口中的“打印”和“取消”,因此批次之间不会自动继续。
254
-
255
- ```tsx
256
- import { useMemo, useRef } from "react";
257
- import {
258
- ReactListTable,
259
- type ReactListTableRef,
260
- } from "@canvas-components/react-list-table";
261
-
262
- interface UserRow {
263
- id: number;
264
- name: string;
265
- age: number;
266
- }
267
-
268
- export function DemoTable() {
269
- const tableRef = useRef<ReactListTableRef<UserRow> | null>(null);
270
-
271
- const columns = useMemo(
272
- () => [
273
- { key: "name", title: "姓名", dataIndex: "name", width: 180 },
274
- {
275
- key: "age",
276
- title: "年龄",
277
- dataIndex: "age",
278
- width: 120,
279
- align: "right" as const,
280
- },
281
- ],
282
- [],
283
- );
284
-
285
- return (
286
- <ReactListTable<UserRow>
287
- ref={tableRef}
288
- rowKey="id"
289
- height={480}
290
- columns={columns}
291
- dataSource={[
292
- { id: 1, name: "张三", age: 28 },
293
- { id: 2, name: "李四", age: 31 },
294
- ]}
295
- toolbar={{ showRefresh: true, showExport: true }}
296
- />
297
- );
298
- }
299
- ```
300
-
301
- ## 属性说明
302
-
303
- ### `ReactListTableProps`
304
-
305
- `ReactListTableProps` 继承自 `ListTableOptions`,并额外补充 React 宿主相关能力。
306
-
307
- | 属性 | 类型 | 说明 |
308
- | ----------- | --------------------------------------- | --------------------------- |
309
- | `width` | `number \| string` | 表格宽度 |
310
- | `height` | `number \| string` | 表格高度 |
311
- | `emptyText` | `string` | 空状态文案 |
312
- | `scroll` | `ReactListTableScrollConfig` | React 风格滚动尺寸配置 |
313
- | `locale` | `ReactListTableLocale` | 本地化文案 |
314
- | `onChange` | `ListTableQueryChange<RecordType>` | 查询状态变更回调 |
315
- | `className` | `string` | 根节点类名 |
316
- | `style` | `CSSProperties` | 根节点样式 |
317
- | `title` | `ReactNode` | 标题栏左侧内容 |
318
- | `toolbar` | `false \| ReactListTableToolbarOptions` | 工具栏配置,传 `false` 隐藏 |
319
-
320
- 其余如 `columns`、`dataSource`、`rowSelection`、`expandable`、`pagination`、`rowDrag`、`draggable`、`resizable` 等属性与 `@canvas-components/list-table` 保持一致。
321
-
322
- ### `ReactListTableToolbarOptions`
323
-
324
- | 属性 | 类型 | 说明 |
325
- | -------------------------- | ---------------------------- | ---------------------------------- |
326
- | `showRefresh` | `boolean` | 是否显示刷新按钮 |
327
- | `showFullscreen` | `boolean` | 是否显示全屏按钮 |
328
- | `showDensity` | `boolean` | 是否显示密度切换 |
329
- | `showColumnSetting` | `boolean` | 是否显示列设置 |
330
- | `columnSettingWidth` | `number \| string` | 列设置面板宽度 |
331
- | `columnSettingHeaderExtra` | `ReactNode` | 列设置标题区中重置按钮前的扩展内容 |
332
- | `showExport` | `boolean` | 是否显示导出按钮 |
333
- | `exportOptions` | `ListTableExportXlsxOptions` | 默认导出的文件名和汇总行配置 |
334
- | `onRefresh` | `() => void` | 点击刷新回调 |
335
- | `onExport` | `() => void` | 自定义导出回调 |
336
- | `getFullscreenNode` | `() => HTMLElement \| null` | 自定义全屏节点 |
337
- | `extra` | `ReactNode` | 工具栏右侧额外内容 |
338
-
339
- ## 统一切换调试模式
340
-
341
- `ReactListTableDebugProvider` 可为后代中的全部 `ReactListTable` 同步开启核心调试模式,并默认显示表头、表体、固定列分割线、命中区域和表头操作区。表格自身通过 `debug` 传入的其他选项仍会保留,也可以显式关闭某个可视化项:
342
-
343
- ```tsx
344
- import {
345
- ReactListTable,
346
- ReactListTableDebugProvider,
347
- } from "@canvas-components/react-list-table";
348
-
349
- <ReactListTableDebugProvider enabled={statsEnabled}>
350
- <ReactListTable
351
- columns={columns}
352
- dataSource={dataSource}
353
- debug={{ showBodyBounds: true }}
354
- />
355
- </ReactListTableDebugProvider>;
356
- ```
357
-
358
- ## 方法说明
359
-
360
- ### `ReactListTableRef`
361
-
362
- | 方法 | 签名 | 说明 |
363
- | ------------------ | ------------------------------------------------ | ------------------------------- |
364
- | `validate` | `() => Promise<RecordType[]>` | 触发表格校验 |
365
- | `exportXlsx` | `(options?: ListTableExportXlsxOptions) => void` | 导出 XLSX,可配置文件名和汇总行 |
366
- | `scrollTo` | `(options) => void` | 滚动到指定行 |
367
- | `getDebugSnapshot` | `() => ListTableDebugSnapshot \| null` | 获取调试快照 |
368
-
369
- 导出文件名弹窗使用 `react-components` 的 `ReactModal`、`ReactInput`,默认开启,文件后缀不可编辑。通过表格 `exportOptions={{ fileName: "报表", promptFileName: false }}` 可配置默认名称并跳过弹窗;工具栏 `toolbar.exportOptions` 或实例 `exportXlsx` 的同名选项可覆盖默认配置。取消不会生成文件。XLSX 默认追加当前已显示的汇总行,传入 `includeSummary: false` 可关闭。
370
-
371
- ## 类型别名
372
-
373
- | 类型 | 说明 |
374
- | ---------------------------------------- | ---------------------------------------- |
375
- | `ReactListTableTableProps<RecordType>` | `ReactListTableProps<RecordType>` 的别名 |
376
- | `ReactListTableColumnType<RecordType>` | 单列类型别名 |
377
- | `ReactListTableColumnsType<RecordType>` | 列数组类型别名 |
378
- | `ReactListTableRowSelection<RecordType>` | 行选择类型别名 |
379
- | `ReactListTablePagination` | 分页类型别名 |
380
- | `ReactListTableQuery<RecordType>` | 查询类型别名 |
381
-
382
- ## 推荐场景
383
-
384
- - React 后台管理表格
385
- - 大数据量只读 / 可编辑表格
386
- - 需要原生性能但又希望保留 React 组件用法的场景
1
+ # @canvas-components/react-list-table
2
+
3
+ `@canvas-components/react-list-table` 是 `@canvas-components/list-table` 的 React 适配层,负责把原生 Canvas 表格接入 React 应用,并提供更接近业务开发习惯的组件化入口。
4
+
5
+ 通过顶层 `loading` 属性控制数据加载状态:`<ReactListTable loading={loading} dataSource={rows} columns={columns} />`。加载期间展示加载提示并保留汇总标题;加载完成后,组件自动计算并统一展示完整汇总结果。服务端汇总可通过 `query.summaryValues` 提供,业务侧无需单独管理汇总计算状态。
6
+
7
+ ## 属性更新与性能
8
+
9
+ - 相同属性引用的父组件重渲染由 `React.memo` 跳过;组件内部交互仍正常更新。
10
+ - `onChange`、`onRow` 以及查询、分页、行选择、展开、拖拽和性能通知等事件使用稳定入口,调用时读取最近一次已提交的回调,避免仅回调引用变化就重置底层查询。
11
+ - `scroll`、`theme`、`pagination` 等常用配置进行第一层字段比较,内容相同的新对象复用之前的配置。嵌套对象和数组仍按引用判断。
12
+ - `columns`、`dataSource`、受控选中/展开数组,以及 `rowKey`、列渲染、`getCheckboxProps` 等影响数据或展示的函数,变化时继续刷新。大数据数组不做深比较,建议用 `useMemo` 或稳定状态保存,并在内容改变时更新引用。
13
+
14
+ ## 示例效果
15
+
16
+ ![React List Table 基础示例](./assets/examples/basic.gif)
17
+
18
+ ### 完整示例图集
19
+
20
+ <details>
21
+ <summary>100w 数据渲染</summary>
22
+
23
+ ![100w 数据渲染](./assets/examples/million-rows.gif)
24
+
25
+ </details>
26
+
27
+ <details>
28
+ <summary>行选择</summary>
29
+
30
+ ![行选择](./assets/examples/row-selection.gif)
31
+
32
+ </details>
33
+
34
+ <details>
35
+ <summary>单元格内容</summary>
36
+
37
+ ![单元格内容](./assets/examples/cell-content.gif)
38
+
39
+ </details>
40
+
41
+ <details>
42
+ <summary>斑马条纹</summary>
43
+
44
+ ![斑马条纹](./assets/examples/striped.gif)
45
+
46
+ </details>
47
+
48
+ <details>
49
+ <summary>主题切换</summary>
50
+
51
+ ![主题切换](./assets/examples/theme.gif)
52
+
53
+ </details>
54
+
55
+ <details>
56
+ <summary>高亮模式</summary>
57
+
58
+ ![高亮模式](./assets/examples/highlight-mode.gif)
59
+
60
+ </details>
61
+
62
+ <details>
63
+ <summary>右键菜单</summary>
64
+
65
+ ![右键菜单](./assets/examples/context-menu.gif)
66
+
67
+ </details>
68
+
69
+ <details>
70
+ <summary>数据格式</summary>
71
+
72
+ ![数据格式](./assets/examples/data-format.gif)
73
+
74
+ </details>
75
+
76
+ <details>
77
+ <summary>省略提示</summary>
78
+
79
+ ![省略提示](./assets/examples/ellipsis-tooltip.gif)
80
+
81
+ </details>
82
+
83
+ <details>
84
+ <summary>可展开行</summary>
85
+
86
+ ![可展开行](./assets/examples/expandable.gif)
87
+
88
+ </details>
89
+
90
+ <details>
91
+ <summary>单元格编辑</summary>
92
+
93
+ ![单元格编辑](./assets/examples/editable-cell.gif)
94
+
95
+ </details>
96
+
97
+ <details>
98
+ <summary>远程查询</summary>
99
+
100
+ ![远程查询](./assets/examples/remote-query.gif)
101
+
102
+ </details>
103
+
104
+ <details>
105
+ <summary>表格分页</summary>
106
+
107
+ ![表格分页](./assets/examples/pagination.gif)
108
+
109
+ </details>
110
+
111
+ <details>
112
+ <summary>空状态</summary>
113
+
114
+ ![空状态](./assets/examples/empty-state.gif)
115
+
116
+ </details>
117
+
118
+ <details>
119
+ <summary>宽高配置</summary>
120
+
121
+ ![宽高配置](./assets/examples/sized.gif)
122
+
123
+ </details>
124
+
125
+ <details>
126
+ <summary>表头排序、过滤、固定</summary>
127
+
128
+ ![表头排序、过滤、固定](./assets/examples/header-actions.gif)
129
+
130
+ </details>
131
+
132
+ <details>
133
+ <summary>多级表头</summary>
134
+
135
+ ![多级表头](./assets/examples/multi-header.gif)
136
+
137
+ </details>
138
+
139
+ <details>
140
+ <summary>汇总行</summary>
141
+
142
+ ![汇总行](./assets/examples/summary-row.gif)
143
+
144
+ </details>
145
+
146
+ <details>
147
+ <summary>合并行列</summary>
148
+
149
+ ![合并行列](./assets/examples/merged-cells.gif)
150
+
151
+ </details>
152
+
153
+ <details>
154
+ <summary>拖动改变列宽</summary>
155
+
156
+ ![拖动改变列宽](./assets/examples/resize.gif)
157
+
158
+ </details>
159
+
160
+ <details>
161
+ <summary>轮播滚动</summary>
162
+
163
+ ![轮播滚动](./assets/examples/carousel-scroll.gif)
164
+
165
+ </details>
166
+
167
+ <details>
168
+ <summary>缓存配置</summary>
169
+
170
+ ![缓存配置](./assets/examples/cached-columns.gif)
171
+
172
+ </details>
173
+
174
+ <details>
175
+ <summary>拖拽表头排序</summary>
176
+
177
+ ![拖拽表头排序](./assets/examples/draggable.gif)
178
+
179
+ </details>
180
+
181
+ <details>
182
+ <summary>跨表行拖拽</summary>
183
+
184
+ ![跨表行拖拽](./assets/examples/row-drag.gif)
185
+
186
+ </details>
187
+
188
+ <details>
189
+ <summary>超级示例</summary>
190
+
191
+ ![超级示例](./assets/examples/super.gif)
192
+
193
+ </details>
194
+
195
+ ## 功能作用
196
+
197
+ - 提供 `ReactListTable` 组件
198
+ - 内置工具栏、分页层、编辑层、tooltip、图片预览
199
+ - 暴露 `ref` 方法,方便外部校验和滚动定位
200
+ - 保持底层大数据性能和纯原生渲染能力
201
+
202
+ ## 安装方法
203
+
204
+ ```bash
205
+ pnpm add @canvas-components/react-list-table @canvas-components/list-table react@^16.8 react-dom@^16.8
206
+ ```
207
+
208
+ 最低依赖版本:
209
+
210
+ - `react >= 16.8.0`
211
+ - `react-dom >= 16.8.0`
212
+ - `Node.js >= 18.12.0`
213
+ - `pnpm >= 9.0.0`
214
+
215
+ ## 使用方法
216
+
217
+ 打印配置可以通过 `printPresets` 预设交给 `ReactListTable`。每个预设有一个用于选择的名称和打印配置;未提供的字段使用默认值。没有已保存配置时默认使用第一个预设,也可以在打印配置弹窗中切换;启用本地缓存后,后续打开优先恢复所选预设和本地修改。
218
+
219
+ ```tsx
220
+ import {
221
+ ReactListTable,
222
+ type ReactListTablePrintPreset,
223
+ } from "@canvas-components/react-list-table";
224
+
225
+ const printPresets: ReactListTablePrintPreset[] = [
226
+ {
227
+ name: "横向明细",
228
+ config: {
229
+ title: "明细清单",
230
+ paperSize: "a4",
231
+ orientation: "landscape",
232
+ rowsPerPage: 24,
233
+ pageMargins: { top: 10, right: 10, bottom: 10, left: 10 },
234
+ columns: [
235
+ { key: "name", width: 60, align: "left" },
236
+ { key: "amount", width: 35, align: "right" },
237
+ ],
238
+ selectedKeys: ["name", "amount"],
239
+ },
240
+ },
241
+ ];
242
+
243
+ <ReactListTable
244
+ storageKey="invoice-list"
245
+ printPresets={printPresets}
246
+ columns={columns}
247
+ dataSource={data}
248
+ />;
249
+ ```
250
+
251
+ 配置名称显示在打印配置弹窗顶部。列通过 `key` 对应表格列;列宽单位为毫米。需要缓存预设选择和用户调整时提供 `storageKey` 并保持弹窗中的本地缓存选项开启。
252
+
253
+ 右键直接打印(包括选择模板打印)会先显示“每次打印页数”设置,默认每批 50 页。可通过 `directPrintPagesPerBatch={20}` 修改默认值,用户仍可在开始前调整。每批只生成并加载指定数量的实际打印页(包括自动续页),关闭浏览器打印窗口后释放该批 iframe;点击“继续下一批”才生成后续批次,也可以取消剩余任务。浏览器无法区分打印窗口中的“打印”和“取消”,因此批次之间不会自动继续。
254
+
255
+ ```tsx
256
+ import { useMemo, useRef } from "react";
257
+ import {
258
+ ReactListTable,
259
+ type ReactListTableRef,
260
+ } from "@canvas-components/react-list-table";
261
+
262
+ interface UserRow {
263
+ id: number;
264
+ name: string;
265
+ age: number;
266
+ }
267
+
268
+ export function DemoTable() {
269
+ const tableRef = useRef<ReactListTableRef<UserRow> | null>(null);
270
+
271
+ const columns = useMemo(
272
+ () => [
273
+ { key: "name", title: "姓名", dataIndex: "name", width: 180 },
274
+ {
275
+ key: "age",
276
+ title: "年龄",
277
+ dataIndex: "age",
278
+ width: 120,
279
+ align: "right" as const,
280
+ },
281
+ ],
282
+ [],
283
+ );
284
+
285
+ return (
286
+ <ReactListTable<UserRow>
287
+ ref={tableRef}
288
+ rowKey="id"
289
+ height={480}
290
+ columns={columns}
291
+ dataSource={[
292
+ { id: 1, name: "张三", age: 28 },
293
+ { id: 2, name: "李四", age: 31 },
294
+ ]}
295
+ toolbar={{ showRefresh: true, showExport: true }}
296
+ />
297
+ );
298
+ }
299
+ ```
300
+
301
+ ## 属性说明
302
+
303
+ ### `ReactListTableProps`
304
+
305
+ `ReactListTableProps` 继承自 `ListTableOptions`,并额外补充 React 宿主相关能力。
306
+
307
+ | 属性 | 类型 | 说明 |
308
+ | ----------- | --------------------------------------- | --------------------------- |
309
+ | `width` | `number \| string` | 表格宽度 |
310
+ | `height` | `number \| string` | 表格高度 |
311
+ | `emptyText` | `string` | 空状态文案 |
312
+ | `scroll` | `ReactListTableScrollConfig` | React 风格滚动尺寸配置 |
313
+ | `locale` | `ReactListTableLocale` | 本地化文案 |
314
+ | `onChange` | `ListTableQueryChange<RecordType>` | 查询状态变更回调 |
315
+ | `className` | `string` | 根节点类名 |
316
+ | `style` | `CSSProperties` | 根节点样式 |
317
+ | `title` | `ReactNode` | 标题栏左侧内容 |
318
+ | `toolbar` | `false \| ReactListTableToolbarOptions` | 工具栏配置,传 `false` 隐藏 |
319
+
320
+ 其余如 `columns`、`dataSource`、`rowSelection`、`expandable`、`pagination`、`rowDrag`、`draggable`、`resizable` 等属性与 `@canvas-components/list-table` 保持一致。
321
+
322
+ ### `ReactListTableToolbarOptions`
323
+
324
+ | 属性 | 类型 | 说明 |
325
+ | -------------------------- | ---------------------------- | ---------------------------------- |
326
+ | `showRefresh` | `boolean` | 是否显示刷新按钮 |
327
+ | `showFullscreen` | `boolean` | 是否显示全屏按钮 |
328
+ | `showDensity` | `boolean` | 是否显示密度切换 |
329
+ | `showColumnSetting` | `boolean` | 是否显示列设置 |
330
+ | `columnSettingWidth` | `number \| string` | 列设置面板宽度 |
331
+ | `columnSettingHeaderExtra` | `ReactNode` | 列设置标题区中重置按钮前的扩展内容 |
332
+ | `showExport` | `boolean` | 是否显示导出按钮 |
333
+ | `exportOptions` | `ListTableExportXlsxOptions` | 默认导出的文件名和汇总行配置 |
334
+ | `onRefresh` | `() => void` | 点击刷新回调 |
335
+ | `onExport` | `() => void` | 自定义导出回调 |
336
+ | `getFullscreenNode` | `() => HTMLElement \| null` | 自定义全屏节点 |
337
+ | `extra` | `ReactNode` | 工具栏右侧额外内容 |
338
+
339
+ ## 统一切换调试模式
340
+
341
+ `ReactListTableDebugProvider` 可为后代中的全部 `ReactListTable` 同步开启核心调试模式,并默认显示表头、表体、固定列分割线、命中区域和表头操作区。表格自身通过 `debug` 传入的其他选项仍会保留,也可以显式关闭某个可视化项:
342
+
343
+ ```tsx
344
+ import {
345
+ ReactListTable,
346
+ ReactListTableDebugProvider,
347
+ } from "@canvas-components/react-list-table";
348
+
349
+ <ReactListTableDebugProvider enabled={statsEnabled}>
350
+ <ReactListTable
351
+ columns={columns}
352
+ dataSource={dataSource}
353
+ debug={{ showBodyBounds: true }}
354
+ />
355
+ </ReactListTableDebugProvider>;
356
+ ```
357
+
358
+ ## 方法说明
359
+
360
+ ### `ReactListTableRef`
361
+
362
+ | 方法 | 签名 | 说明 |
363
+ | ------------------ | ------------------------------------------------ | ------------------------------- |
364
+ | `validate` | `() => Promise<RecordType[]>` | 触发表格校验 |
365
+ | `exportXlsx` | `(options?: ListTableExportXlsxOptions) => void` | 导出 XLSX,可配置文件名和汇总行 |
366
+ | `scrollTo` | `(options) => void` | 滚动到指定行 |
367
+ | `getDebugSnapshot` | `() => ListTableDebugSnapshot \| null` | 获取调试快照 |
368
+
369
+ 导出文件名弹窗使用 `react-components` 的 `ReactModal`、`ReactInput`,默认开启,文件后缀不可编辑。通过表格 `exportOptions={{ fileName: "报表", promptFileName: false }}` 可配置默认名称并跳过弹窗;工具栏 `toolbar.exportOptions` 或实例 `exportXlsx` 的同名选项可覆盖默认配置。取消不会生成文件。XLSX 默认追加当前已显示的汇总行,传入 `includeSummary: false` 可关闭。
370
+
371
+ ## 类型别名
372
+
373
+ | 类型 | 说明 |
374
+ | ---------------------------------------- | ---------------------------------------- |
375
+ | `ReactListTableTableProps<RecordType>` | `ReactListTableProps<RecordType>` 的别名 |
376
+ | `ReactListTableColumnType<RecordType>` | 单列类型别名 |
377
+ | `ReactListTableColumnsType<RecordType>` | 列数组类型别名 |
378
+ | `ReactListTableRowSelection<RecordType>` | 行选择类型别名 |
379
+ | `ReactListTablePagination` | 分页类型别名 |
380
+ | `ReactListTableQuery<RecordType>` | 查询类型别名 |
381
+
382
+ ## 推荐场景
383
+
384
+ - React 后台管理表格
385
+ - 大数据量只读 / 可编辑表格
386
+ - 需要原生性能但又希望保留 React 组件用法的场景
package/dist/index.cjs CHANGED
@@ -4238,6 +4238,7 @@ function createTableDocument(source, preset) {
4238
4238
  y: tableY,
4239
4239
  width: contentWidth,
4240
4240
  height: tableHeight,
4241
+ manualHeight: true,
4241
4242
  dataMode: "binding",
4242
4243
  dataPath: `listTable.pages.${index}.rows`,
4243
4244
  dataSource: [],
package/dist/index.js CHANGED
@@ -4237,6 +4237,7 @@ function createTableDocument(source, preset) {
4237
4237
  y: tableY,
4238
4238
  width: contentWidth,
4239
4239
  height: tableHeight,
4240
+ manualHeight: true,
4240
4241
  dataMode: "binding",
4241
4242
  dataPath: `listTable.pages.${index}.rows`,
4242
4243
  dataSource: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/react-list-table",
3
- "version": "0.3.48",
3
+ "version": "0.3.50",
4
4
  "description": "React adapter for the list table core engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,12 +28,12 @@
28
28
  "pnpm": ">=9.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@canvas-components/list-table": "0.3.40",
32
31
  "@canvas-components/print": "0.1.1",
33
- "@canvas-components/print-design": "0.1.2",
34
- "@canvas-components/react-components": "0.3.22",
35
32
  "@canvas-components/chart": "0.3.9",
36
- "@canvas-components/react-print-design": "0.1.3"
33
+ "@canvas-components/react-print-design": "0.1.5",
34
+ "@canvas-components/list-table": "0.3.42",
35
+ "@canvas-components/react-components": "0.3.24",
36
+ "@canvas-components/print-design": "0.1.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "react": ">=16.8.0",