@kne/table-page 0.1.38 → 0.1.42
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 +217 -7
- package/dist/index.css +69 -19
- package/dist/index.css.map +1 -1
- package/dist/index.js +254 -134
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +171 -34
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +3 -0
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +3 -0
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +3 -0
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +3 -0
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -35,11 +35,14 @@ var filterEnUS__default = /*#__PURE__*/_interopDefaultLegacy(filterEnUS);
|
|
|
35
35
|
var StickyScroller__default = /*#__PURE__*/_interopDefaultLegacy(StickyScroller);
|
|
36
36
|
var ButtonGroup__default = /*#__PURE__*/_interopDefaultLegacy(ButtonGroup);
|
|
37
37
|
|
|
38
|
-
var style$1 = {"table-page":"kne-table-page_ut9rJ","fetch-stack":"kne-table-page_dpy7d","toolbar-height-reserve":"kne-table-page_daceW","table-page-tabs-outer":"kne-table-page_IowJl","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","is-sticky":"kne-table-page_7lYyk","is-loading-shell":"kne-table-page_LY8zA","is-mobile-render":"kne-table-page_D6KGb","has-summary":"kne-table-page_IRdzb","table-cell-skeleton":"kne-table-page_--DrO","table-skeleton-spin":"kne-table-page_cZ1zq","table-in-toolbar":"kne-table-page_sawIT","is-card-mode":"kne-table-page_kH6wM","is-card-render":"kne-table-page_-WbMN","card-mode-toggle":"kne-table-page_ostpI","mobile-load-more":"kne-table-page_UqVnb","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr"};
|
|
38
|
+
var style$1 = {"table-page":"kne-table-page_ut9rJ","fetch-stack":"kne-table-page_dpy7d","toolbar-height-reserve":"kne-table-page_daceW","table-page-tabs-outer":"kne-table-page_IowJl","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","is-sticky":"kne-table-page_7lYyk","is-loading-shell":"kne-table-page_LY8zA","is-mobile-render":"kne-table-page_D6KGb","has-summary":"kne-table-page_IRdzb","table-cell-skeleton":"kne-table-page_--DrO","table-skeleton-spin":"kne-table-page_cZ1zq","table-in-toolbar":"kne-table-page_sawIT","is-card-mode":"kne-table-page_kH6wM","is-card-render":"kne-table-page_-WbMN","card-mode-toggle":"kne-table-page_ostpI","mobile-load-more":"kne-table-page_UqVnb","pagination":"kne-table-page_DSTEf","is-single-page-compact":"kne-table-page_ocbDG","mobile-pagination":"kne-table-page_-MB-i","is-center":"kne-table-page_b5Udg","mobile-pagination-meta":"kne-table-page_gEH6a","mobile-pagination-bar":"kne-table-page_fSlSC","mobile-pagination-btn":"kne-table-page_berbk","mobile-pagination-indicator":"kne-table-page_ZjzID","mobile-pagination-current":"kne-table-page_rZTa3","mobile-pagination-divider":"kne-table-page_Kl1Ux","total_text":"kne-table-page_pJhKr"};
|
|
39
39
|
|
|
40
40
|
const locale$1 = {
|
|
41
41
|
TotalText: '共',
|
|
42
42
|
ItemText: '条',
|
|
43
|
+
PrevPage: '上一页',
|
|
44
|
+
NextPage: '下一页',
|
|
45
|
+
PageSizeText: '{size} 条/页',
|
|
43
46
|
UnnamedColumn: '未命名列',
|
|
44
47
|
EditTable: '编辑表格',
|
|
45
48
|
RestoreDefault: '恢复默认',
|
|
@@ -58,6 +61,9 @@ const locale$1 = {
|
|
|
58
61
|
const locale = {
|
|
59
62
|
TotalText: 'Total',
|
|
60
63
|
ItemText: 'items',
|
|
64
|
+
PrevPage: 'Prev',
|
|
65
|
+
NextPage: 'Next',
|
|
66
|
+
PageSizeText: '{size} / page',
|
|
61
67
|
UnnamedColumn: 'Unnamed',
|
|
62
68
|
EditTable: 'Edit Table',
|
|
63
69
|
RestoreDefault: 'Restore Default',
|
|
@@ -140,9 +146,9 @@ const resolveButtonGroupProps = (buttonGroup, getPopupContainer, {
|
|
|
140
146
|
getPopupContainer: userGetPopupContainer ?? getPopupContainer
|
|
141
147
|
};
|
|
142
148
|
};
|
|
143
|
-
const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
149
|
+
const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer, isMobile) => {
|
|
144
150
|
return resolveButtonGroupProps(buttonGroup, getPopupContainer, {
|
|
145
|
-
defaultSize: 'small',
|
|
151
|
+
defaultSize: isMobile ? 'middle' : 'small',
|
|
146
152
|
// 未显式传 showLength 时走 ButtonGroup 自适应测宽(@kne/overflow-items)
|
|
147
153
|
defaultShowLength: undefined,
|
|
148
154
|
minShowLength: 1
|
|
@@ -172,6 +178,7 @@ const TablePageTabs = ({
|
|
|
172
178
|
formatMessage
|
|
173
179
|
} = reactIntl.useIntl();
|
|
174
180
|
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
181
|
+
const isMobile = responsiveUtils.useIsMobile();
|
|
175
182
|
const showTab = !!(tab?.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
176
183
|
const {
|
|
177
184
|
getPopupContainer: userGetPopupContainer,
|
|
@@ -216,7 +223,7 @@ const TablePageTabs = ({
|
|
|
216
223
|
[style['is-mobile-render']]: isMobileRender
|
|
217
224
|
}),
|
|
218
225
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Tabs, {
|
|
219
|
-
size:
|
|
226
|
+
size: isMobile ? 'middle' : 'small',
|
|
220
227
|
...restTabProps,
|
|
221
228
|
getPopupContainer: userGetPopupContainer ?? getPopupContainer,
|
|
222
229
|
activeKey: getTabActiveKey(filterValue, tab.name),
|
|
@@ -236,6 +243,8 @@ const BatchActions = ({
|
|
|
236
243
|
formatMessage
|
|
237
244
|
} = reactIntl.useIntl();
|
|
238
245
|
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
246
|
+
const isMobile = responsiveUtils.useIsMobile();
|
|
247
|
+
const buttonSize = isMobile ? 'middle' : 'small';
|
|
239
248
|
const selectedRowKeys = rowSelection?.selectedRowKeys || [];
|
|
240
249
|
const hasSelection = selectedRowKeys.length > 0;
|
|
241
250
|
const batchMenuItems = react.useMemo(() => {
|
|
@@ -290,13 +299,13 @@ const BatchActions = ({
|
|
|
290
299
|
trigger: ['click'],
|
|
291
300
|
getPopupContainer: getPopupContainer,
|
|
292
301
|
children: /*#__PURE__*/jsxRuntime.jsxs(antd.Button, {
|
|
293
|
-
size:
|
|
302
|
+
size: buttonSize,
|
|
294
303
|
disabled: !hasSelection,
|
|
295
304
|
className: style['table-toolbar-batch-btn'],
|
|
296
305
|
children: [batchButtonLabel, /*#__PURE__*/jsxRuntime.jsx(icons.DownOutlined, {})]
|
|
297
306
|
})
|
|
298
307
|
}), hasSelection ? /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
299
|
-
size:
|
|
308
|
+
size: buttonSize,
|
|
300
309
|
icon: /*#__PURE__*/jsxRuntime.jsx(icons.MinusSquareOutlined, {}),
|
|
301
310
|
title: formatMessage({
|
|
302
311
|
id: 'Cancel'
|
|
@@ -397,7 +406,7 @@ const TableToolbar = ({
|
|
|
397
406
|
const buttonGroupNode = showButtonGroup ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
398
407
|
className: style['table-toolbar-button-group'],
|
|
399
408
|
children: /*#__PURE__*/jsxRuntime.jsx(ButtonGroup__default["default"], {
|
|
400
|
-
...resolveToolbarButtonGroupProps(buttonGroup, getPopupContainer)
|
|
409
|
+
...resolveToolbarButtonGroupProps(buttonGroup, getPopupContainer, isMobile)
|
|
401
410
|
})
|
|
402
411
|
}) : null;
|
|
403
412
|
const batchActionsNode = showBatchInToolbar ? /*#__PURE__*/jsxRuntime.jsx(BatchActions, {
|
|
@@ -487,6 +496,86 @@ const TableToolbar = ({
|
|
|
487
496
|
});
|
|
488
497
|
};
|
|
489
498
|
|
|
499
|
+
const MobilePagination = ({
|
|
500
|
+
className,
|
|
501
|
+
current,
|
|
502
|
+
pageSize,
|
|
503
|
+
total,
|
|
504
|
+
onChange,
|
|
505
|
+
showTotal,
|
|
506
|
+
showSizeChanger,
|
|
507
|
+
pageSizeOptions,
|
|
508
|
+
compact
|
|
509
|
+
}) => {
|
|
510
|
+
const {
|
|
511
|
+
formatMessage
|
|
512
|
+
} = reactIntl.useIntl();
|
|
513
|
+
const totalPages = Math.max(Math.ceil(total / pageSize), 1);
|
|
514
|
+
const rangeStart = (current - 1) * pageSize + 1;
|
|
515
|
+
const rangeEnd = Math.min(current * pageSize, total);
|
|
516
|
+
const totalNode = typeof showTotal === 'function' ? showTotal(total, [rangeStart, rangeEnd]) : null;
|
|
517
|
+
const hasMeta = !!totalNode || showSizeChanger;
|
|
518
|
+
if (compact && !hasMeta) {
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
522
|
+
className: classnames__default["default"](style$1['mobile-pagination'], {
|
|
523
|
+
[style$1['is-center']]: !hasMeta
|
|
524
|
+
}, className),
|
|
525
|
+
children: [hasMeta ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
526
|
+
className: style$1['mobile-pagination-meta'],
|
|
527
|
+
children: [totalNode ? /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
528
|
+
children: totalNode
|
|
529
|
+
}) : null, showSizeChanger ? /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
|
|
530
|
+
size: "small",
|
|
531
|
+
variant: "borderless",
|
|
532
|
+
value: pageSize,
|
|
533
|
+
onChange: size => onChange(1, size),
|
|
534
|
+
options: pageSizeOptions.map(item => ({
|
|
535
|
+
value: Number(item),
|
|
536
|
+
label: formatMessage({
|
|
537
|
+
id: 'PageSizeText'
|
|
538
|
+
}, {
|
|
539
|
+
size: item
|
|
540
|
+
})
|
|
541
|
+
}))
|
|
542
|
+
}) : null]
|
|
543
|
+
}) : null, compact ? null : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
544
|
+
className: style$1['mobile-pagination-bar'],
|
|
545
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
546
|
+
type: "text",
|
|
547
|
+
shape: "circle",
|
|
548
|
+
className: style$1['mobile-pagination-btn'],
|
|
549
|
+
"aria-label": formatMessage({
|
|
550
|
+
id: 'PrevPage'
|
|
551
|
+
}),
|
|
552
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.LeftOutlined, {}),
|
|
553
|
+
disabled: current <= 1,
|
|
554
|
+
onClick: () => onChange(current - 1, pageSize)
|
|
555
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
556
|
+
className: style$1['mobile-pagination-indicator'],
|
|
557
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
558
|
+
className: style$1['mobile-pagination-current'],
|
|
559
|
+
children: current
|
|
560
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
561
|
+
className: style$1['mobile-pagination-divider'],
|
|
562
|
+
children: "/"
|
|
563
|
+
}), totalPages]
|
|
564
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
565
|
+
type: "text",
|
|
566
|
+
shape: "circle",
|
|
567
|
+
className: style$1['mobile-pagination-btn'],
|
|
568
|
+
"aria-label": formatMessage({
|
|
569
|
+
id: 'NextPage'
|
|
570
|
+
}),
|
|
571
|
+
icon: /*#__PURE__*/jsxRuntime.jsx(icons.RightOutlined, {}),
|
|
572
|
+
disabled: current >= totalPages,
|
|
573
|
+
onClick: () => onChange(current + 1, pageSize)
|
|
574
|
+
})]
|
|
575
|
+
})]
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
|
|
490
579
|
const parsePixelValue = value => {
|
|
491
580
|
const num = parseFloat(value);
|
|
492
581
|
return Number.isNaN(num) ? 0 : num;
|
|
@@ -779,20 +868,40 @@ const isPaginationSearchParamsEnabled = pagination => {
|
|
|
779
868
|
};
|
|
780
869
|
|
|
781
870
|
const noop = () => {};
|
|
871
|
+
const EMPTY_COLUMN_RENDER_PROPS = {};
|
|
872
|
+
const shallowEqual = (a, b) => {
|
|
873
|
+
if (a === b) {
|
|
874
|
+
return true;
|
|
875
|
+
}
|
|
876
|
+
if (!a || !b) {
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
const keysA = Object.keys(a);
|
|
880
|
+
const keysB = Object.keys(b);
|
|
881
|
+
return keysA.length === keysB.length && keysA.every(key => Object.prototype.hasOwnProperty.call(b, key) && a[key] === b[key]);
|
|
882
|
+
};
|
|
883
|
+
|
|
884
|
+
/** react-fetch 每次渲染都 pick 出新的 fetchProps;浅比较相同时沿用旧引用 */
|
|
885
|
+
const useShallowStable = value => {
|
|
886
|
+
const ref = react.useRef(value);
|
|
887
|
+
if (!shallowEqual(ref.current, value)) {
|
|
888
|
+
ref.current = value;
|
|
889
|
+
}
|
|
890
|
+
return ref.current;
|
|
891
|
+
};
|
|
782
892
|
const SKELETON_ROW_COUNT = 8;
|
|
783
893
|
const FALLBACK_SKELETON_COLUMNS = 5;
|
|
784
894
|
|
|
785
895
|
/** 是否存在工具栏 / Filter 区域(首屏 loading 需占位保高) */
|
|
786
|
-
const hasToolbarArea = (
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
} = _ref;
|
|
896
|
+
const hasToolbarArea = ({
|
|
897
|
+
filter,
|
|
898
|
+
search,
|
|
899
|
+
tab,
|
|
900
|
+
batchActions,
|
|
901
|
+
buttonGroup,
|
|
902
|
+
renderCard,
|
|
903
|
+
forceCard
|
|
904
|
+
}, isMobile) => {
|
|
796
905
|
const hasTab = !!(tab?.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
797
906
|
const hasFilter = !!(filter?.list?.length > 0);
|
|
798
907
|
const hasSearch = !!(search && search.name);
|
|
@@ -801,10 +910,7 @@ const hasToolbarArea = (_ref, isMobile) => {
|
|
|
801
910
|
const hasCardToggle = !isMobile && resolveRenderCard(renderCard) != null && !forceCard;
|
|
802
911
|
return hasTab || hasFilter || hasSearch || hasBatch || hasBtn || hasCardToggle;
|
|
803
912
|
};
|
|
804
|
-
const flattenLeafColumns =
|
|
805
|
-
if (output === void 0) {
|
|
806
|
-
output = [];
|
|
807
|
-
}
|
|
913
|
+
const flattenLeafColumns = (columns, output = []) => {
|
|
808
914
|
(columns || []).forEach(column => {
|
|
809
915
|
if (Array.isArray(column?.children) && column.children.length > 0) {
|
|
810
916
|
flattenLeafColumns(column.children, output);
|
|
@@ -863,41 +969,35 @@ const buildSkeletonTableColumns = leafColumns => {
|
|
|
863
969
|
render: () => /*#__PURE__*/jsxRuntime.jsx(CellSkeleton, {})
|
|
864
970
|
}));
|
|
865
971
|
};
|
|
866
|
-
const buildSkeletonDataSource =
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
length: rowCount
|
|
872
|
-
}, (_, index) => ({
|
|
873
|
-
id: `__skeleton_row_${index}`
|
|
874
|
-
}));
|
|
875
|
-
};
|
|
972
|
+
const buildSkeletonDataSource = (rowCount = SKELETON_ROW_COUNT) => Array.from({
|
|
973
|
+
length: rowCount
|
|
974
|
+
}, (_, index) => ({
|
|
975
|
+
id: `__skeleton_row_${index}`
|
|
976
|
+
}));
|
|
876
977
|
|
|
877
978
|
/**
|
|
878
979
|
* withFetch 首包 loading:Toolbar/Filter 占位保高 + Table/TableView 骨架屏 + loading,
|
|
879
980
|
* 复用正式表格样式,避免全局绝对定位 Spin 把高度塌成 0。
|
|
880
981
|
*/
|
|
881
|
-
const TablePageLoadingShell = withLocale(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
} = _ref2;
|
|
982
|
+
const TablePageLoadingShell = withLocale(({
|
|
983
|
+
filter,
|
|
984
|
+
search,
|
|
985
|
+
tab,
|
|
986
|
+
tabProps,
|
|
987
|
+
batchActions,
|
|
988
|
+
buttonGroup,
|
|
989
|
+
rowSelection,
|
|
990
|
+
selectedRows,
|
|
991
|
+
renderMobile = true,
|
|
992
|
+
renderCard,
|
|
993
|
+
forceCard = false,
|
|
994
|
+
columns,
|
|
995
|
+
getColumns,
|
|
996
|
+
pagination = {},
|
|
997
|
+
className,
|
|
998
|
+
size,
|
|
999
|
+
renderType = 'Table'
|
|
1000
|
+
}) => {
|
|
901
1001
|
const isMobile = responsiveUtils.useIsMobile();
|
|
902
1002
|
const isMobileRenderActive = tableView.isRenderMobileActive(renderMobile, isMobile);
|
|
903
1003
|
const showButtonGroup = hasButtonGroupList(buttonGroup);
|
|
@@ -1130,51 +1230,50 @@ const withNestedClears = (prevParams, nextParams) => {
|
|
|
1130
1230
|
});
|
|
1131
1231
|
return result;
|
|
1132
1232
|
};
|
|
1133
|
-
const TablePageInnerContent = withLocale(
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
} = _ref3;
|
|
1233
|
+
const TablePageInnerContent = withLocale(({
|
|
1234
|
+
data,
|
|
1235
|
+
refresh,
|
|
1236
|
+
reload,
|
|
1237
|
+
requestParams,
|
|
1238
|
+
fetchProps,
|
|
1239
|
+
isComplete,
|
|
1240
|
+
loadMore,
|
|
1241
|
+
send,
|
|
1242
|
+
dataFormat = data => {
|
|
1243
|
+
return {
|
|
1244
|
+
list: data.pageData,
|
|
1245
|
+
total: data.totalCount,
|
|
1246
|
+
data
|
|
1247
|
+
};
|
|
1248
|
+
},
|
|
1249
|
+
className,
|
|
1250
|
+
columns,
|
|
1251
|
+
getColumns,
|
|
1252
|
+
pagination = {},
|
|
1253
|
+
columnRenderProps = EMPTY_COLUMN_RENDER_PROPS,
|
|
1254
|
+
summary,
|
|
1255
|
+
sticky,
|
|
1256
|
+
scrollTopInset,
|
|
1257
|
+
stickyOffset,
|
|
1258
|
+
renderType = 'Table',
|
|
1259
|
+
horizontalScroller = true,
|
|
1260
|
+
getScrollContainer,
|
|
1261
|
+
filter,
|
|
1262
|
+
search,
|
|
1263
|
+
tab,
|
|
1264
|
+
tabProps,
|
|
1265
|
+
batchActions,
|
|
1266
|
+
buttonGroup,
|
|
1267
|
+
selectedRows,
|
|
1268
|
+
rowSelection,
|
|
1269
|
+
renderMobile = true,
|
|
1270
|
+
renderCard,
|
|
1271
|
+
forceCard = false,
|
|
1272
|
+
mobileSortToolbar,
|
|
1273
|
+
filterSeedParams = {},
|
|
1274
|
+
filterFetchApiRef,
|
|
1275
|
+
...props
|
|
1276
|
+
}) => {
|
|
1178
1277
|
const {
|
|
1179
1278
|
formatMessage
|
|
1180
1279
|
} = reactIntl.useIntl();
|
|
@@ -1200,10 +1299,7 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1200
1299
|
return mapFilterValue(value || []);
|
|
1201
1300
|
});
|
|
1202
1301
|
const filterFieldNames = react.useMemo(() => collectFilterFieldNames(filter, search, tab), [filter, search, tab]);
|
|
1203
|
-
const buildRequestParamsWithFilter = useRefCallback__default["default"](
|
|
1204
|
-
if (extra === void 0) {
|
|
1205
|
-
extra = {};
|
|
1206
|
-
}
|
|
1302
|
+
const buildRequestParamsWithFilter = useRefCallback__default["default"]((value, extra = {}) => {
|
|
1207
1303
|
const prevFilterParams = Object.assign({}, getFilterParams(filterValue) || {});
|
|
1208
1304
|
let filterParams = Object.assign({}, getFilterParams(value) || {});
|
|
1209
1305
|
Object.keys(filterParams).forEach(key => {
|
|
@@ -1266,10 +1362,7 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1266
1362
|
// react-fetch 的 reload 以 props.data(首包种子)为底合并,裸调会丢掉当前已选筛选。
|
|
1267
1363
|
// 对外(ref / batchActions / summary)统一注入 filterValue,保证 UI 与查询一致。
|
|
1268
1364
|
// handleFilterChange 仍走原始 reload:setState 前要用新 value 组参,不能读旧 filterValue。
|
|
1269
|
-
const injectFilterParams = useRefCallback__default["default"](
|
|
1270
|
-
if (sendProps === void 0) {
|
|
1271
|
-
sendProps = {};
|
|
1272
|
-
}
|
|
1365
|
+
const injectFilterParams = useRefCallback__default["default"]((sendProps = {}) => {
|
|
1273
1366
|
const paramsType = pagination.paramsType;
|
|
1274
1367
|
const incoming = get__default["default"](sendProps, paramsType);
|
|
1275
1368
|
return Object.assign({}, sendProps, {
|
|
@@ -1291,7 +1384,9 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1291
1384
|
const formatData = react.useMemo(() => {
|
|
1292
1385
|
return handlerDataFormat(data);
|
|
1293
1386
|
}, [data, handlerDataFormat]);
|
|
1294
|
-
|
|
1387
|
+
|
|
1388
|
+
// 列定义与 context 保持引用稳定:table-view 据此复用单元格内容,避免无关重渲染刷新整表
|
|
1389
|
+
const resolvedColumns = react.useMemo(() => typeof getColumns === 'function' ? getColumns(data) : typeof columns === 'function' ? columns(data) : columns, [getColumns, columns, data]);
|
|
1295
1390
|
const fetchContext = react.useMemo(() => ({
|
|
1296
1391
|
data,
|
|
1297
1392
|
fetchProps,
|
|
@@ -1402,48 +1497,70 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1402
1497
|
return Promise.reject(e);
|
|
1403
1498
|
}
|
|
1404
1499
|
});
|
|
1405
|
-
const
|
|
1500
|
+
const paginationView = react.useMemo(() => {
|
|
1406
1501
|
if (useLoadMoreMode || !pagination.open || !(formatData.total > 0)) {
|
|
1407
1502
|
return null;
|
|
1408
1503
|
}
|
|
1409
|
-
const
|
|
1504
|
+
const DEFAULT_PAGE_SIZE_OPTIONS = ['10', '20', '50', '100'];
|
|
1505
|
+
const pageSizeOptions = pagination.pageSizeOptions || DEFAULT_PAGE_SIZE_OPTIONS;
|
|
1506
|
+
const optionSizes = pageSizeOptions.map(Number).filter(n => Number.isFinite(n) && n > 0);
|
|
1507
|
+
const minPageSize = optionSizes.length ? Math.min(...optionSizes) : pagination.pageSize || 20;
|
|
1508
|
+
const total = formatData.total;
|
|
1509
|
+
// 总数小于最小可选每页条数时,切换 pageSize 无实质意义,不展示分页条
|
|
1510
|
+
if (total < minPageSize) {
|
|
1511
|
+
return null;
|
|
1512
|
+
}
|
|
1513
|
+
const pageSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
1514
|
+
const isSinglePage = total <= pageSize;
|
|
1515
|
+
// hideOnSinglePage 默认 true:仅一页时改为精简条(总数 + 每页条数),而非整块隐藏,避免 pageSize 调大后无法切回
|
|
1516
|
+
const useCompact = pagination.hideOnSinglePage !== false && isSinglePage;
|
|
1517
|
+
const defaultShowTotal = showTotal => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1410
1518
|
children: [formatMessage({
|
|
1411
1519
|
id: 'TotalText'
|
|
1412
1520
|
}), "\xA0", /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1413
1521
|
className: style$1['total_text'],
|
|
1414
|
-
children:
|
|
1522
|
+
children: showTotal
|
|
1415
1523
|
}), "\xA0", formatMessage({
|
|
1416
1524
|
id: 'ItemText'
|
|
1417
1525
|
})]
|
|
1418
1526
|
});
|
|
1419
1527
|
const baseConfig = {
|
|
1420
|
-
total
|
|
1528
|
+
total,
|
|
1421
1529
|
...(pagination.showTotal !== false ? {
|
|
1422
1530
|
showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
|
|
1423
1531
|
} : {}),
|
|
1424
1532
|
current: get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1),
|
|
1425
|
-
pageSize
|
|
1533
|
+
pageSize,
|
|
1426
1534
|
onChange: handlePaginationChange,
|
|
1427
1535
|
size: pagination.size,
|
|
1428
|
-
hideOnSinglePage
|
|
1536
|
+
// 可见性由上方逻辑接管,避免 antd hideOnSinglePage 把 sizeChanger 一并藏掉
|
|
1537
|
+
hideOnSinglePage: false,
|
|
1429
1538
|
showSizeChanger: pagination.showSizeChanger,
|
|
1430
|
-
showQuickJumper: pagination.showQuickJumper,
|
|
1431
|
-
pageSizeOptions
|
|
1539
|
+
showQuickJumper: useCompact ? false : pagination.showQuickJumper,
|
|
1540
|
+
pageSizeOptions
|
|
1432
1541
|
};
|
|
1433
1542
|
if (!isMobileRenderActive) {
|
|
1434
|
-
return
|
|
1543
|
+
return {
|
|
1544
|
+
config: baseConfig,
|
|
1545
|
+
compact: useCompact
|
|
1546
|
+
};
|
|
1435
1547
|
}
|
|
1436
1548
|
const mobilePagination = pagination.mobile || {};
|
|
1437
1549
|
return {
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1550
|
+
config: {
|
|
1551
|
+
total,
|
|
1552
|
+
showTotal: baseConfig.showTotal,
|
|
1553
|
+
current: baseConfig.current,
|
|
1554
|
+
pageSize,
|
|
1555
|
+
onChange: handlePaginationChange,
|
|
1556
|
+
showSizeChanger: mobilePagination.showSizeChanger === true && pagination.showSizeChanger !== false,
|
|
1557
|
+
pageSizeOptions
|
|
1558
|
+
},
|
|
1559
|
+
compact: useCompact
|
|
1445
1560
|
};
|
|
1446
1561
|
}, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange, isMobileRenderActive, useLoadMoreMode]);
|
|
1562
|
+
const paginationConfig = paginationView?.config || null;
|
|
1563
|
+
const paginationCompact = !!paginationView?.compact;
|
|
1447
1564
|
const batchContext = react.useMemo(() => ({
|
|
1448
1565
|
data,
|
|
1449
1566
|
fetchProps,
|
|
@@ -1455,12 +1572,13 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1455
1572
|
dataFormat,
|
|
1456
1573
|
pagination
|
|
1457
1574
|
}), [data, fetchProps, requestParams, refreshWithFilter, reloadWithFilter, loadMoreWithFilter, sendWithFilter, dataFormat, pagination]);
|
|
1458
|
-
const
|
|
1575
|
+
const stableFetchProps = useShallowStable(fetchProps);
|
|
1576
|
+
const tableContext = react.useMemo(() => ({
|
|
1459
1577
|
...columnRenderProps,
|
|
1460
1578
|
requestParams,
|
|
1461
|
-
fetchProps,
|
|
1579
|
+
fetchProps: stableFetchProps,
|
|
1462
1580
|
data
|
|
1463
|
-
};
|
|
1581
|
+
}), [columnRenderProps, requestParams, stableFetchProps, data]);
|
|
1464
1582
|
|
|
1465
1583
|
// 移动端卡片模式下批量操作渲染在「全选/排序」行的排序后面
|
|
1466
1584
|
const showMobileBatchInCardToolbar = isMobileRenderActive && Array.isArray(batchActions) && batchActions.length > 0;
|
|
@@ -1583,9 +1701,12 @@ const TablePageInnerContent = withLocale(_ref3 => {
|
|
|
1583
1701
|
onLoader: handleLoadMore,
|
|
1584
1702
|
children: tableMain
|
|
1585
1703
|
}) : /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1586
|
-
children: [tableMain, paginationConfig ? /*#__PURE__*/jsxRuntime.jsx(
|
|
1704
|
+
children: [tableMain, paginationConfig ? isMobileRenderActive ? /*#__PURE__*/jsxRuntime.jsx(MobilePagination, {
|
|
1705
|
+
...paginationConfig,
|
|
1706
|
+
compact: paginationCompact
|
|
1707
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(antd.Pagination, {
|
|
1587
1708
|
className: classnames__default["default"](style$1['pagination'], {
|
|
1588
|
-
[style$1['is-
|
|
1709
|
+
[style$1['is-single-page-compact']]: paginationCompact
|
|
1589
1710
|
}),
|
|
1590
1711
|
...paginationConfig
|
|
1591
1712
|
}) : null]
|
|
@@ -1656,14 +1777,13 @@ const TablePageInner = /*#__PURE__*/react.forwardRef((props, ref) => {
|
|
|
1656
1777
|
}), fetched]
|
|
1657
1778
|
});
|
|
1658
1779
|
});
|
|
1659
|
-
const TablePage = /*#__PURE__*/react.forwardRef((
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
} = _ref4;
|
|
1780
|
+
const TablePage = /*#__PURE__*/react.forwardRef(({
|
|
1781
|
+
pagination,
|
|
1782
|
+
horizontalScroller = true,
|
|
1783
|
+
getScrollContainer,
|
|
1784
|
+
filter: filterProp,
|
|
1785
|
+
...props
|
|
1786
|
+
}, ref) => {
|
|
1667
1787
|
pagination = Object.assign({}, {
|
|
1668
1788
|
showSizeChanger: true,
|
|
1669
1789
|
showQuickJumper: true,
|