@gulibs/react-vtable 0.0.14 → 0.0.16
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 +98 -2
- package/dist/hooks/use-pro-table.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +188 -150
- package/dist/pro-table.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ function App() {
|
|
|
84
84
|
- **Search & Filter**: Advanced search and filtering capabilities with default behavior for local and remote data modes
|
|
85
85
|
- **Pagination**: Built-in pagination with customizable options
|
|
86
86
|
- **Column Settings**: Show/hide columns, drag to reorder
|
|
87
|
-
- **Row Selection**: Single and multiple row selection with batch actions
|
|
87
|
+
- **Row Selection**: Single and multiple row selection with batch actions, **cross-page selection support** (selection state persists across pages when using `request` or `pagination.onChange`)
|
|
88
88
|
- **Editable Rows**: Inline editing capabilities with various value types
|
|
89
89
|
- **Fixed Columns**: Left and right fixed columns with automatic position calculation and subtle shadow effects (powered by TanStack Table column pinning)
|
|
90
90
|
- **Tree Table**: Hierarchical data display with expandable/collapsible rows, custom expand icons, and accordion mode
|
|
@@ -454,6 +454,54 @@ Tree tables support hierarchical data structures with expandable/collapsible row
|
|
|
454
454
|
/>
|
|
455
455
|
```
|
|
456
456
|
|
|
457
|
+
**Cross-Page Selection Support:**
|
|
458
|
+
|
|
459
|
+
When using `request` or `pagination.onChange` for remote data fetching, the table automatically maintains selection state across pages. This means:
|
|
460
|
+
|
|
461
|
+
- Selections made on one page are preserved when navigating to other pages
|
|
462
|
+
- The batch actions bar shows the **total count** of selected rows across all pages
|
|
463
|
+
- When you return to a previously visited page, your selections are automatically restored
|
|
464
|
+
- The `onChange` callback receives all selected row keys across all pages
|
|
465
|
+
|
|
466
|
+
```tsx
|
|
467
|
+
<ProTable
|
|
468
|
+
columns={columns}
|
|
469
|
+
rowKey="id"
|
|
470
|
+
request={async (params) => {
|
|
471
|
+
const res = await fetchUsers(params)
|
|
472
|
+
return { data: res.items, total: res.total, success: true }
|
|
473
|
+
}}
|
|
474
|
+
rowSelection={{
|
|
475
|
+
type: 'checkbox',
|
|
476
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
477
|
+
// selectedRowKeys contains ALL selected keys across all pages
|
|
478
|
+
// selectedRows contains rows from the current page only
|
|
479
|
+
console.log('Total selected across all pages:', selectedRowKeys.length)
|
|
480
|
+
},
|
|
481
|
+
batchActions: {
|
|
482
|
+
onDelete: (rows) => {
|
|
483
|
+
// This will receive rows from current page only
|
|
484
|
+
// Use selectedRowKeys from onChange for full selection
|
|
485
|
+
console.log('Delete current page rows:', rows)
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}}
|
|
489
|
+
pagination={{
|
|
490
|
+
pageSize: 10,
|
|
491
|
+
showSizeChanger: true,
|
|
492
|
+
onChange: (current, pageSize) => {
|
|
493
|
+
// Selection state is automatically preserved when page changes
|
|
494
|
+
}
|
|
495
|
+
}}
|
|
496
|
+
/>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
**Important Notes:**
|
|
500
|
+
- Cross-page selection works automatically when using `request` or `pagination.onChange`
|
|
501
|
+
- With `dataSource` (local data), selection works normally but doesn't need cross-page support
|
|
502
|
+
- The batch actions bar always shows the total count of selected rows across all pages
|
|
503
|
+
- Use `rowSelection.onChange` to get all selected keys if you need to perform operations on all selected rows
|
|
504
|
+
|
|
457
505
|
#### With Text Ellipsis and Tooltip
|
|
458
506
|
|
|
459
507
|
```tsx
|
|
@@ -736,7 +784,7 @@ function App() {
|
|
|
736
784
|
- **搜索筛选**: 高级搜索和筛选功能,支持本地和远程数据模式的默认行为
|
|
737
785
|
- **分页**: 内置分页,支持自定义选项
|
|
738
786
|
- **列设置**: 显示 / 隐藏列,拖拽重排序
|
|
739
|
-
- **行选择**:
|
|
787
|
+
- **行选择**: 单选和多选行,支持批量操作,**跨页选中支持**(使用 `request` 或 `pagination.onChange` 时,选中状态会在切换页面时保留)
|
|
740
788
|
- **可编辑行**: 内联编辑功能,支持多种值类型
|
|
741
789
|
- **固定列**: 左右固定列,自动计算位置并应用柔和阴影效果(基于 TanStack Table column pinning)
|
|
742
790
|
- **树形表格**: 层次数据展示,支持展开 / 收起行、自定义展开图标和手风琴模式
|
|
@@ -1103,6 +1151,54 @@ import { ProTable, zh_CN } from '@gulibs/react-vtable'
|
|
|
1103
1151
|
/>
|
|
1104
1152
|
```
|
|
1105
1153
|
|
|
1154
|
+
**跨页选中支持:**
|
|
1155
|
+
|
|
1156
|
+
当使用 `request` 或 `pagination.onChange` 进行远程数据获取时,表格会自动维护跨页选中状态。这意味着:
|
|
1157
|
+
|
|
1158
|
+
- 在某一页选择的行,在切换到其他页面时会保留
|
|
1159
|
+
- 批量操作栏会显示**所有页面**的选中总数
|
|
1160
|
+
- 当返回到之前访问过的页面时,之前的选中状态会自动恢复
|
|
1161
|
+
- `onChange` 回调会接收到所有页面的选中行 keys
|
|
1162
|
+
|
|
1163
|
+
```tsx
|
|
1164
|
+
<ProTable
|
|
1165
|
+
columns={columns}
|
|
1166
|
+
rowKey="id"
|
|
1167
|
+
request={async (params) => {
|
|
1168
|
+
const res = await fetchUsers(params)
|
|
1169
|
+
return { data: res.items, total: res.total, success: true }
|
|
1170
|
+
}}
|
|
1171
|
+
rowSelection={{
|
|
1172
|
+
type: 'checkbox',
|
|
1173
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
1174
|
+
// selectedRowKeys 包含所有页面的选中 keys
|
|
1175
|
+
// selectedRows 仅包含当前页的行数据
|
|
1176
|
+
console.log('所有页面选中的总数:', selectedRowKeys.length)
|
|
1177
|
+
},
|
|
1178
|
+
batchActions: {
|
|
1179
|
+
onDelete: (rows) => {
|
|
1180
|
+
// 这里只会收到当前页的行数据
|
|
1181
|
+
// 如需操作所有选中的行,请使用 onChange 中的 selectedRowKeys
|
|
1182
|
+
console.log('删除当前页行:', rows)
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}}
|
|
1186
|
+
pagination={{
|
|
1187
|
+
pageSize: 10,
|
|
1188
|
+
showSizeChanger: true,
|
|
1189
|
+
onChange: (current, pageSize) => {
|
|
1190
|
+
// 切换页面时,选中状态会自动保留
|
|
1191
|
+
}
|
|
1192
|
+
}}
|
|
1193
|
+
/>
|
|
1194
|
+
```
|
|
1195
|
+
|
|
1196
|
+
**重要提示:**
|
|
1197
|
+
- 跨页选中在使用 `request` 或 `pagination.onChange` 时会自动生效
|
|
1198
|
+
- 使用 `dataSource`(本地数据)时,选中功能正常工作,但不需要跨页支持
|
|
1199
|
+
- 批量操作栏始终显示所有页面的选中总数
|
|
1200
|
+
- 如需对所有选中的行进行操作,请使用 `rowSelection.onChange` 获取所有选中的 keys
|
|
1201
|
+
|
|
1106
1202
|
#### 带文本省略和提示框
|
|
1107
1203
|
|
|
1108
1204
|
```tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pro-table.d.ts","sourceRoot":"","sources":["../../lib/hooks/use-pro-table.ts"],"names":[],"mappings":"AAaA,OAAO,EAAiE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAC/F,OAAO,KAAK,EACR,cAAc,EACd,aAAa,EAEhB,MAAM,SAAS,CAAA;AAGhB,UAAU,aAAa,CAAC,CAAC;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,eAAe,EAAE,GAAG,EAAE,CAAA;IACtB,YAAY,EAAE,CAAC,EAAE,CAAA;IACjB,UAAU,EAAE,GAAG,GAAG,IAAI,CAAA;IACtB,aAAa,EAAE,CAAC,GAA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