@kne/table-page 0.1.35 → 0.1.36
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 +24 -6
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +3 -1
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ npm i --save @kne/table-page
|
|
|
191
191
|
#### 示例代码
|
|
192
192
|
|
|
193
193
|
- TablePage
|
|
194
|
-
- 表格页面组件,基于 @kne/react-fetch 实现数据加载与分页,支持 sticky 固定表头、useSort 服务端排序、renderMobile 移动端卡片、renderCard PC 卡片视图切换、tab 分类切换、列配置、总结栏、树形 dataType(含筛选/批量/操作列/卡片切换/懒加载);空数据(total 为 0)时不显示分页器。文末含仅 SearchInput + renderMobile 自定义卡片示例(验证工具栏与卡片间距)
|
|
194
|
+
- 表格页面组件,基于 @kne/react-fetch 实现数据加载与分页,支持 sticky 固定表头、useSort 服务端排序、renderMobile 移动端卡片、renderCard PC 卡片视图切换、pagination.forceLoadMore(PC Table 触底下拉)、tab 分类切换、列配置、总结栏、树形 dataType(含筛选/批量/操作列/卡片切换/懒加载);空数据(total 为 0)时不显示分页器。文末含仅 SearchInput + renderMobile 自定义卡片示例(验证工具栏与卡片间距)
|
|
195
195
|
- _TablePage(@kne/current-lib_table-page)[import * as _TablePage from "@kne/table-page"],(@kne/current-lib_table-page/dist/index.css),antd(antd),_ReactFilter(@kne/react-filter)[import * as _ReactFilter from "@kne/react-filter"],(@kne/react-filter/dist/index.css)
|
|
196
196
|
|
|
197
197
|
```jsx
|
|
@@ -472,6 +472,10 @@ const Tips = () => (
|
|
|
472
472
|
<Tag style={TIP_TAG_STYLE} color="red">PC 卡片</Tag>
|
|
473
473
|
传入 <code>renderCard</code>(签名同 <code>renderMobile</code>)后,工具栏 <code>buttonGroup</code> 前出现表格/卡片切换按钮,状态按 <code>name</code> 持久化到 localStorage;卡片模式下外框透明、默认触底下拉加载(<code>pagination.forcePagination</code> 可改回分页);<code>forceCard</code> 强制卡片并隐藏切换按钮;移动端忽略。
|
|
474
474
|
</div>
|
|
475
|
+
<div>
|
|
476
|
+
<Tag style={TIP_TAG_STYLE} color="lime">Table 下拉加载</Tag>
|
|
477
|
+
PC Table 默认底部分页;设置 <code>pagination.forceLoadMore</code> 可在不切换卡片的情况下触底下拉(与 <code>forcePagination</code> 同时为 true 时以后者为准)。开启后勿再设 Table <code>scroll.y</code>。
|
|
478
|
+
</div>
|
|
475
479
|
</div>
|
|
476
480
|
);
|
|
477
481
|
|
|
@@ -527,6 +531,7 @@ const BaseExample = () => {
|
|
|
527
531
|
const tableRef = React.useRef();
|
|
528
532
|
const [empty, setEmpty] = useState(false);
|
|
529
533
|
const [cardForcePagination, setCardForcePagination] = useState(false);
|
|
534
|
+
const [tableForceLoadMore, setTableForceLoadMore] = useState(false);
|
|
530
535
|
const [renderType, setRenderType] = useState('Table');
|
|
531
536
|
const emptyRef = React.useRef(false);
|
|
532
537
|
const slowReloadRef = React.useRef(false);
|
|
@@ -606,13 +611,22 @@ const BaseExample = () => {
|
|
|
606
611
|
<span>卡片模式数据加载:</span>
|
|
607
612
|
<Switch checkedChildren="分页" unCheckedChildren="下拉加载" checked={cardForcePagination} onChange={setCardForcePagination} />
|
|
608
613
|
</Flex>
|
|
614
|
+
<Flex align="center" gap={8}>
|
|
615
|
+
<span>Table 数据加载:</span>
|
|
616
|
+
<Switch
|
|
617
|
+
checkedChildren="下拉加载"
|
|
618
|
+
unCheckedChildren="分页"
|
|
619
|
+
checked={tableForceLoadMore}
|
|
620
|
+
onChange={setTableForceLoadMore}
|
|
621
|
+
/>
|
|
622
|
+
</Flex>
|
|
609
623
|
</Space>
|
|
610
624
|
<TablePage
|
|
611
625
|
ref={tableRef}
|
|
612
626
|
name="demo-employee-table"
|
|
613
627
|
renderType={renderType}
|
|
614
|
-
sticky={renderType === 'Table'}
|
|
615
|
-
scroll={renderType === 'Table' ? { x: 1600, y: 400 } : undefined}
|
|
628
|
+
sticky={renderType === 'Table' && !tableForceLoadMore}
|
|
629
|
+
scroll={renderType === 'Table' ? (tableForceLoadMore ? { x: 1600 } : { x: 1600, y: 400 }) : undefined}
|
|
616
630
|
size="large"
|
|
617
631
|
renderMobile
|
|
618
632
|
renderCard={renderEmployeeCard}
|
|
@@ -713,7 +727,8 @@ const BaseExample = () => {
|
|
|
713
727
|
showSizeChanger: true,
|
|
714
728
|
showQuickJumper: true,
|
|
715
729
|
pageSizeOptions: ['10', '20', '50', '100'],
|
|
716
|
-
forcePagination: cardForcePagination
|
|
730
|
+
forcePagination: cardForcePagination,
|
|
731
|
+
forceLoadMore: tableForceLoadMore
|
|
717
732
|
}}
|
|
718
733
|
dataFormat={data => ({
|
|
719
734
|
list: data.pageData,
|
|
@@ -4219,6 +4234,7 @@ render(<BaseExample />);
|
|
|
4219
4234
|
| onChange | function | - | 自定义翻页回调 `(page, size) => void`,传入后覆盖默认请求逻辑 |
|
|
4220
4235
|
| onShowSizeChange | function | - | 每页条数变化回调,组件内部已处理持久化 |
|
|
4221
4236
|
| forcePagination | boolean | `false` | 移动端(`renderMobile` 激活时)与 PC 卡片模式(`renderCard` 生效且切到卡片视图时)默认改为触底下拉加载;设为 `true` 时强制仍使用分页器 |
|
|
4237
|
+
| forceLoadMore | boolean | `false` | PC Table / TableView(非移动端、非卡片视图)默认使用底部分页器;设为 `true` 时改为触底下拉加载并隐藏分页器。与 `forcePagination` 同时为 `true` 时以 `forcePagination` 为准。触底由外层 `ScrollLoader` 驱动,勿再给 Table 设 `scroll.y`(表体内滚动会导致触底不触发);弹窗等场景请给外层定高 |
|
|
4222
4238
|
| mergeList | function | 合并 `pageData` | 下拉加载时合并新旧数据 `(prev, next) => data`,需与 `loader` 返回结构一致 |
|
|
4223
4239
|
| loadMore | object | - | 透传给 `@kne/scroll-loader` 的额外配置(如 `completeTips`、`maxFullCount`) |
|
|
4224
4240
|
| mobile | object | - | 强制分页时的移动端分页器微调(如 `showSizeChanger`、`showLessItems`) |
|
|
@@ -4333,6 +4349,8 @@ render(<BaseExample />);
|
|
|
4333
4349
|
|
|
4334
4350
|
移动端(`renderMobile` 激活)默认使用触底下拉加载(`@kne/scroll-loader` + `react-fetch` 的 `loadMore`),不再展示分页器。若需移动端仍使用分页,请设置 `pagination.forcePagination: true`。
|
|
4335
4351
|
|
|
4352
|
+
PC 桌面 Table 默认使用底部分页器。若需在 Table 模式下也触底下拉加载,请设置 `pagination.forceLoadMore: true`(与 `forcePagination` 同时开启时以后者为准)。
|
|
4353
|
+
|
|
4336
4354
|
#### renderType
|
|
4337
4355
|
|
|
4338
4356
|
通过 `renderType` 选择内部使用的表格组件,默认为 `Table`:
|
|
@@ -4369,7 +4387,7 @@ render(<BaseExample />);
|
|
|
4369
4387
|
|
|
4370
4388
|
### TableView
|
|
4371
4389
|
|
|
4372
|
-
表格视图组件,基于
|
|
4390
|
+
表格视图组件,基于 CSS Grid 布局实现。实现位于 `@kne/table-view`,本包为兼容继续导出。
|
|
4373
4391
|
|
|
4374
4392
|
#### 属性
|
|
4375
4393
|
|
|
@@ -4548,7 +4566,7 @@ const sortedData = useMemo(() => Table.sortDataSource(dataSource, sort, columns)
|
|
|
4548
4566
|
|
|
4549
4567
|
### Table
|
|
4550
4568
|
|
|
4551
|
-
表格组件,以 antd `Table`
|
|
4569
|
+
表格组件,以 antd `Table` 作为展示层。实现位于 `@kne/table-view`,本包为兼容继续导出。外层 API 与 `TableView` 保持一致。
|
|
4552
4570
|
|
|
4553
4571
|
#### 属性
|
|
4554
4572
|
|
package/dist/index.js
CHANGED
|
@@ -1383,7 +1383,9 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1383
1383
|
const useMobileLoadMore = isMobileRenderActive && pagination.open && !pagination.forcePagination;
|
|
1384
1384
|
// PC 卡片模式默认下拉加载,pagination.forcePagination 为 true 时仍用分页
|
|
1385
1385
|
const useCardLoadMore = isCardModeActive && pagination.open && !pagination.forcePagination;
|
|
1386
|
-
|
|
1386
|
+
// PC Table:默认分页;pagination.forceLoadMore 强制触底下拉(与 forcePagination 互斥时以后者为准)
|
|
1387
|
+
const useTableLoadMore = !isMobileRenderActive && !isCardModeActive && pagination.open && !!pagination.forceLoadMore && !pagination.forcePagination;
|
|
1388
|
+
const useLoadMoreMode = useMobileLoadMore || useCardLoadMore || useTableLoadMore;
|
|
1387
1389
|
const currentPage = get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
1388
1390
|
const currentPageSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
1389
1391
|
const loadMoreNoMore = !formatData.total || currentPage * currentPageSize >= formatData.total;
|