@kne/table-page 0.1.17 → 0.1.22
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 +286 -20
- package/dist/index.css +36 -22
- package/dist/index.css.map +1 -1
- package/dist/index.js +278 -37
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +274 -39
- package/dist/index.modern.js.map +1 -1
- package/package.json +3 -3
package/dist/index.modern.js
CHANGED
|
@@ -1157,7 +1157,7 @@ const TreeExpandContent = ({
|
|
|
1157
1157
|
|
|
1158
1158
|
const _excluded$3 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "renderMobile", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "mobileSortToolbar", "name", "controllerOpen", "tableServerApis", "scroll", "summary", "size", "dataType", "parentKey", "childrenKey", "hasChildrenKey", "treeTitleKey", "onLoadChildren", "expandedKeys", "defaultExpandedKeys", "onExpandedKeysChange", "indentSize"],
|
|
1159
1159
|
_excluded2$2 = ["y"],
|
|
1160
|
-
_excluded3$
|
|
1160
|
+
_excluded3$2 = ["getContainer"];
|
|
1161
1161
|
const mapJustifyToAlign = justify => {
|
|
1162
1162
|
if (justify === 'center') {
|
|
1163
1163
|
return 'center';
|
|
@@ -1414,16 +1414,15 @@ const Table = p => {
|
|
|
1414
1414
|
setResizeGuideStyle(null);
|
|
1415
1415
|
return;
|
|
1416
1416
|
}
|
|
1417
|
+
const wrapperRect = root.getBoundingClientRect();
|
|
1417
1418
|
const headerRect = headerCell.getBoundingClientRect();
|
|
1418
1419
|
const resizeBar = headerCell.querySelector('.table-cell-resize-bar');
|
|
1419
1420
|
const barRect = resizeBar == null ? void 0 : resizeBar.getBoundingClientRect();
|
|
1420
1421
|
const containerRect = tableContainer.getBoundingClientRect();
|
|
1421
1422
|
setResizeGuideStyle({
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
height: Math.round(containerRect.height),
|
|
1426
|
-
zIndex: 100
|
|
1423
|
+
left: Math.round(((_barRect$right = barRect == null ? void 0 : barRect.right) != null ? _barRect$right : headerRect.right) - wrapperRect.left),
|
|
1424
|
+
top: Math.round(containerRect.top - wrapperRect.top),
|
|
1425
|
+
height: Math.round(containerRect.height)
|
|
1427
1426
|
});
|
|
1428
1427
|
}, [currentMoveColumnIndex]);
|
|
1429
1428
|
useLayoutEffect(() => {
|
|
@@ -1871,7 +1870,7 @@ const Table = p => {
|
|
|
1871
1870
|
}
|
|
1872
1871
|
const config = typeof sticky === 'object' ? Object.assign({}, sticky) : {};
|
|
1873
1872
|
if (hasScrollY) {
|
|
1874
|
-
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$
|
|
1873
|
+
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$2);
|
|
1875
1874
|
return Object.assign({
|
|
1876
1875
|
offsetHeader: 0
|
|
1877
1876
|
}, scrollSticky);
|
|
@@ -2323,11 +2322,11 @@ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
|
2323
2322
|
});
|
|
2324
2323
|
};
|
|
2325
2324
|
|
|
2326
|
-
var style = {"kne-responsive-boundary":"kne-table-page_u90lj","kne-responsive-scroll":"kne-table-page_bSj1H","table-toolbar-section":"kne-table-page_I21Xn","has-value-display":"kne-table-page_COnMY","table-toolbar":"kne-table-page_x6mv7","table-toolbar-value-display":"kne-table-page_vbwMg","table-toolbar-batch":"kne-table-page_k8-Ku","table-toolbar-batch-btn":"kne-table-page_gZtbT","table-toolbar-batch-clear-btn":"kne-table-page_o6Oml","table-toolbar-actions":"kne-table-page_t3-57","table-toolbar-button-group":"kne-table-page_2sdSC","table-toolbar-search":"kne-table-page_pB5en","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","is-mobile":"kne-table-page_n9eAS","table-toolbar-mobile-actions":"kne-table-page_I--A1","table-toolbar-mobile-filter-row":"kne-table-page_Qo5Zl","table-toolbar-filter":"kne-table-page_Jyfm7","has-mobile-search":"kne-table-page_14SJt","table-toolbar-search-row":"kne-table-page_zuGJv","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-
|
|
2325
|
+
var style = {"kne-responsive-boundary":"kne-table-page_u90lj","kne-responsive-scroll":"kne-table-page_bSj1H","table-toolbar-section":"kne-table-page_I21Xn","has-value-display":"kne-table-page_COnMY","table-toolbar":"kne-table-page_x6mv7","table-toolbar-value-display":"kne-table-page_vbwMg","table-toolbar-batch":"kne-table-page_k8-Ku","table-toolbar-batch-btn":"kne-table-page_gZtbT","table-toolbar-batch-clear-btn":"kne-table-page_o6Oml","table-toolbar-actions":"kne-table-page_t3-57","table-toolbar-button-group":"kne-table-page_2sdSC","table-toolbar-search":"kne-table-page_pB5en","table-toolbar-search-input":"kne-table-page_t60hK","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","is-mobile":"kne-table-page_n9eAS","table-toolbar-mobile-actions":"kne-table-page_I--A1","table-toolbar-mobile-filter-row":"kne-table-page_Qo5Zl","table-toolbar-filter":"kne-table-page_Jyfm7","has-mobile-search":"kne-table-page_14SJt","table-toolbar-search-row":"kne-table-page_zuGJv","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-outer":"kne-table-page_PiWGM","table-toolbar-filter-inner":"kne-table-page_AX3aK"};
|
|
2327
2326
|
|
|
2328
2327
|
const _excluded$1 = ["getPopupContainer"],
|
|
2329
|
-
_excluded2$1 = ["list", "displayLine", "extraExpand", "className"],
|
|
2330
|
-
_excluded3 = ["className", "style"];
|
|
2328
|
+
_excluded2$1 = ["list", "displayLine", "extraExpand", "className", "searchParamsValue", "mapFilterValue", "value", "defaultValue", "onChange"],
|
|
2329
|
+
_excluded3$1 = ["className", "style"];
|
|
2331
2330
|
const TAB_ALL_KEY = '__all__';
|
|
2332
2331
|
const getTabActiveKey = (filterValue, tabName) => {
|
|
2333
2332
|
var _entry$value;
|
|
@@ -2540,7 +2539,7 @@ const TableToolbar = ({
|
|
|
2540
2539
|
className: searchClassName,
|
|
2541
2540
|
style: searchStyle
|
|
2542
2541
|
} = _ref3,
|
|
2543
|
-
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
2542
|
+
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
2544
2543
|
|
|
2545
2544
|
// tab 已有选中态展示,已选筛选标签中不再重复显示 tab 的值
|
|
2546
2545
|
const displayFilterValue = hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || [];
|
|
@@ -2558,12 +2557,15 @@ const TableToolbar = ({
|
|
|
2558
2557
|
bordered: false,
|
|
2559
2558
|
variant: "filled",
|
|
2560
2559
|
size: isMobile ? 'middle' : 'small',
|
|
2561
|
-
className: classnames(style['table-toolbar-search-input'], searchClassName)
|
|
2560
|
+
className: classnames(style['table-toolbar-search-input'], searchClassName)
|
|
2561
|
+
}, searchRest, {
|
|
2562
2562
|
style: isMobile ? _extends({}, searchStyle, {
|
|
2563
2563
|
width: '100%',
|
|
2564
2564
|
maxWidth: '100%'
|
|
2565
|
-
}) : searchStyle
|
|
2566
|
-
|
|
2565
|
+
}) : _extends({}, searchStyle, {
|
|
2566
|
+
width: 180
|
|
2567
|
+
})
|
|
2568
|
+
})) : null;
|
|
2567
2569
|
const buttonGroupNode = showButtonGroup ? /*#__PURE__*/jsx("div", {
|
|
2568
2570
|
className: style['table-toolbar-button-group'],
|
|
2569
2571
|
children: /*#__PURE__*/jsx(ButtonGroup, _extends({}, resolveToolbarButtonGroupProps(buttonGroup, getPopupContainer)))
|
|
@@ -2643,6 +2645,7 @@ const TableToolbar = ({
|
|
|
2643
2645
|
[style['is-mobile-render']]: isMobileRender
|
|
2644
2646
|
}),
|
|
2645
2647
|
children: /*#__PURE__*/jsx(FilterValueDisplay, {
|
|
2648
|
+
hideLabel: true,
|
|
2646
2649
|
value: displayFilterValue,
|
|
2647
2650
|
onChange: handleValueDisplayChange,
|
|
2648
2651
|
extraExpand: extraExpand,
|
|
@@ -2653,8 +2656,164 @@ const TableToolbar = ({
|
|
|
2653
2656
|
});
|
|
2654
2657
|
};
|
|
2655
2658
|
|
|
2659
|
+
/**
|
|
2660
|
+
* 与 @kne/react-filter useSearchParamsValue 内部解析保持一致(不从该包导出)。
|
|
2661
|
+
*
|
|
2662
|
+
* @param {Object} [options]
|
|
2663
|
+
* @param {URLSearchParams} [options.searchParams]
|
|
2664
|
+
* @param {Array<{ name: string, label?: string }>} [options.fields]
|
|
2665
|
+
* @returns {{ items: Array, consumedKeys: string[] }}
|
|
2666
|
+
*/
|
|
2667
|
+
const parseSearchParamsValue = ({
|
|
2668
|
+
searchParams,
|
|
2669
|
+
fields
|
|
2670
|
+
} = {}) => {
|
|
2671
|
+
const items = [];
|
|
2672
|
+
const consumedKeys = [];
|
|
2673
|
+
if (!searchParams || !Array.isArray(fields) || fields.length === 0) {
|
|
2674
|
+
return {
|
|
2675
|
+
items,
|
|
2676
|
+
consumedKeys
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
fields.forEach(field => {
|
|
2680
|
+
const name = field == null ? void 0 : field.name;
|
|
2681
|
+
if (!name || !searchParams.has(name)) {
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2684
|
+
const raw = searchParams.get(name);
|
|
2685
|
+
if (raw == null || raw === '') {
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
consumedKeys.push(name);
|
|
2689
|
+
const label = field.label != null ? field.label : name;
|
|
2690
|
+
items.push({
|
|
2691
|
+
name,
|
|
2692
|
+
label,
|
|
2693
|
+
value: {
|
|
2694
|
+
label: raw,
|
|
2695
|
+
value: raw
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
});
|
|
2699
|
+
return {
|
|
2700
|
+
items,
|
|
2701
|
+
consumedKeys
|
|
2702
|
+
};
|
|
2703
|
+
};
|
|
2704
|
+
|
|
2705
|
+
/**
|
|
2706
|
+
* 按 name 合并筛选数组;同名时 fromUrl 覆盖 base。
|
|
2707
|
+
* @param {Array} base
|
|
2708
|
+
* @param {Array} fromUrl
|
|
2709
|
+
* @returns {Array}
|
|
2710
|
+
*/
|
|
2711
|
+
const mergeFilterByName = (base = [], fromUrl = []) => {
|
|
2712
|
+
if (!fromUrl.length) {
|
|
2713
|
+
return Array.isArray(base) ? [...base] : [];
|
|
2714
|
+
}
|
|
2715
|
+
const map = new Map();
|
|
2716
|
+
(base || []).forEach(item => {
|
|
2717
|
+
if (item != null && item.name) {
|
|
2718
|
+
map.set(item.name, item);
|
|
2719
|
+
}
|
|
2720
|
+
});
|
|
2721
|
+
fromUrl.forEach(item => {
|
|
2722
|
+
if (item != null && item.name) {
|
|
2723
|
+
map.set(item.name, item);
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
return Array.from(map.values());
|
|
2727
|
+
};
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* @param {URLSearchParams} searchParams
|
|
2731
|
+
* @param {string[]} consumedKeys
|
|
2732
|
+
* @returns {URLSearchParams|null}
|
|
2733
|
+
*/
|
|
2734
|
+
const stripConsumedUrlParams = (searchParams, consumedKeys) => {
|
|
2735
|
+
if (!(consumedKeys != null && consumedKeys.length)) {
|
|
2736
|
+
return null;
|
|
2737
|
+
}
|
|
2738
|
+
const next = new URLSearchParams(searchParams);
|
|
2739
|
+
let changed = false;
|
|
2740
|
+
consumedKeys.forEach(key => {
|
|
2741
|
+
if (next.has(key)) {
|
|
2742
|
+
next.delete(key);
|
|
2743
|
+
changed = true;
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
return changed ? next : null;
|
|
2747
|
+
};
|
|
2748
|
+
const parsePositiveInt = raw => {
|
|
2749
|
+
if (raw == null || raw === '') {
|
|
2750
|
+
return undefined;
|
|
2751
|
+
}
|
|
2752
|
+
const num = Number(raw);
|
|
2753
|
+
if (!Number.isFinite(num) || num <= 0) {
|
|
2754
|
+
return undefined;
|
|
2755
|
+
}
|
|
2756
|
+
return Math.floor(num);
|
|
2757
|
+
};
|
|
2758
|
+
|
|
2759
|
+
/**
|
|
2760
|
+
* 从 URL 读取分页状态(非法数字忽略)。
|
|
2761
|
+
* @param {URLSearchParams} [searchParams]
|
|
2762
|
+
* @param {{ currentName?: string, pageSizeName?: string }} [options]
|
|
2763
|
+
* @returns {{ current?: number, pageSize?: number }}
|
|
2764
|
+
*/
|
|
2765
|
+
const parsePaginationSearchParams = (searchParams, {
|
|
2766
|
+
currentName: _currentName = 'currentPage',
|
|
2767
|
+
pageSizeName: _pageSizeName = 'perPage'
|
|
2768
|
+
} = {}) => {
|
|
2769
|
+
const result = {};
|
|
2770
|
+
if (!searchParams) {
|
|
2771
|
+
return result;
|
|
2772
|
+
}
|
|
2773
|
+
const current = parsePositiveInt(searchParams.get(_currentName));
|
|
2774
|
+
const pageSize = parsePositiveInt(searchParams.get(_pageSizeName));
|
|
2775
|
+
if (current != null) {
|
|
2776
|
+
result.current = current;
|
|
2777
|
+
}
|
|
2778
|
+
if (pageSize != null) {
|
|
2779
|
+
result.pageSize = pageSize;
|
|
2780
|
+
}
|
|
2781
|
+
return result;
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
/**
|
|
2785
|
+
* 写入分页参数到 URL,保留其它 query。
|
|
2786
|
+
* @param {URLSearchParams} [searchParams]
|
|
2787
|
+
* @param {{ current?: number, pageSize?: number, currentName?: string, pageSizeName?: string }} options
|
|
2788
|
+
* @returns {URLSearchParams}
|
|
2789
|
+
*/
|
|
2790
|
+
const patchPaginationSearchParams = (searchParams, {
|
|
2791
|
+
current,
|
|
2792
|
+
pageSize,
|
|
2793
|
+
currentName: _currentName2 = 'currentPage',
|
|
2794
|
+
pageSizeName: _pageSizeName2 = 'perPage'
|
|
2795
|
+
} = {}) => {
|
|
2796
|
+
const next = new URLSearchParams(searchParams);
|
|
2797
|
+
if (current != null) {
|
|
2798
|
+
next.set(_currentName2, String(current));
|
|
2799
|
+
}
|
|
2800
|
+
if (pageSize != null) {
|
|
2801
|
+
next.set(_pageSizeName2, String(pageSize));
|
|
2802
|
+
}
|
|
2803
|
+
return next;
|
|
2804
|
+
};
|
|
2805
|
+
|
|
2806
|
+
/**
|
|
2807
|
+
* @param {object} [pagination]
|
|
2808
|
+
* @returns {boolean}
|
|
2809
|
+
*/
|
|
2810
|
+
const isPaginationSearchParamsEnabled = pagination => {
|
|
2811
|
+
return !!(pagination != null && pagination.searchParams && typeof pagination.setSearchParams === 'function');
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2656
2814
|
const _excluded = ["data", "refresh", "reload", "requestParams", "fetchProps", "isComplete", "loadMore", "send", "dataFormat", "className", "columns", "getColumns", "pagination", "columnRenderProps", "summary", "sticky", "scrollTopInset", "stickyOffset", "renderType", "horizontalScroller", "getScrollContainer", "filter", "search", "tab", "tabProps", "batchActions", "buttonGroup", "selectedRows", "rowSelection", "renderMobile", "renderCard", "forceCard", "mobileSortToolbar"],
|
|
2657
|
-
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"]
|
|
2815
|
+
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
|
|
2816
|
+
_excluded3 = ["searchParamsValue"];
|
|
2658
2817
|
const defaultMergeList = (data, newData) => {
|
|
2659
2818
|
return Object.assign({}, newData, {
|
|
2660
2819
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
@@ -2862,8 +3021,24 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2862
3021
|
preferToolbar: hasToolbar
|
|
2863
3022
|
});
|
|
2864
3023
|
});
|
|
3024
|
+
const syncPaginationToUrl = useRefCallback((page, size) => {
|
|
3025
|
+
if (!isPaginationSearchParamsEnabled(pagination)) {
|
|
3026
|
+
return;
|
|
3027
|
+
}
|
|
3028
|
+
const nextParams = patchPaginationSearchParams(pagination.searchParams, {
|
|
3029
|
+
current: page,
|
|
3030
|
+
pageSize: size,
|
|
3031
|
+
currentName: pagination.currentName,
|
|
3032
|
+
pageSizeName: pagination.pageSizeName
|
|
3033
|
+
});
|
|
3034
|
+
pagination.setSearchParams(nextParams, {
|
|
3035
|
+
replace: true
|
|
3036
|
+
});
|
|
3037
|
+
});
|
|
2865
3038
|
const handleFilterChange = useRefCallback(value => {
|
|
2866
3039
|
setFilterValue(value);
|
|
3040
|
+
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
3041
|
+
syncPaginationToUrl(1, currentSize);
|
|
2867
3042
|
reload({
|
|
2868
3043
|
[pagination.paramsType]: buildRequestParamsWithFilter(value, {
|
|
2869
3044
|
[pagination.currentName]: 1
|
|
@@ -2879,17 +3054,19 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2879
3054
|
}, [isComplete, data, scrollTable]);
|
|
2880
3055
|
const handlePaginationChange = useRefCallback((page, size) => {
|
|
2881
3056
|
pendingScrollRef.current = true;
|
|
3057
|
+
const nextSize = Number(size);
|
|
3058
|
+
const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
3059
|
+
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2882
3060
|
if (typeof pagination.onChange === 'function') {
|
|
3061
|
+
syncPaginationToUrl(page, nextSize || currentSize);
|
|
2883
3062
|
pagination.onChange(page, size);
|
|
2884
3063
|
return;
|
|
2885
3064
|
}
|
|
2886
|
-
const nextSize = Number(size);
|
|
2887
|
-
const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
2888
|
-
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50;
|
|
2889
3065
|
if (nextSize !== currentSize) {
|
|
2890
3066
|
pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
|
|
2891
3067
|
}
|
|
2892
3068
|
if (page !== currentPage || nextSize !== currentSize) {
|
|
3069
|
+
syncPaginationToUrl(page, nextSize);
|
|
2893
3070
|
(pagination.requestType === 'refresh' ? refresh : reload)({
|
|
2894
3071
|
[pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
|
|
2895
3072
|
[pagination.currentName]: page,
|
|
@@ -2903,7 +3080,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2903
3080
|
const useCardLoadMore = isCardModeActive && pagination.open && !pagination.forcePagination;
|
|
2904
3081
|
const useLoadMoreMode = useMobileLoadMore || useCardLoadMore;
|
|
2905
3082
|
const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
2906
|
-
const currentPageSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize ||
|
|
3083
|
+
const currentPageSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2907
3084
|
const loadMoreNoMore = !formatData.total || currentPage * currentPageSize >= formatData.total;
|
|
2908
3085
|
const handleLoadMore = useRefCallback(async () => {
|
|
2909
3086
|
const mergeList = pagination.mergeList || defaultMergeList;
|
|
@@ -2935,7 +3112,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2935
3112
|
showTotal: typeof pagination.showTotal === 'function' ? pagination.showTotal : defaultShowTotal
|
|
2936
3113
|
} : {}, {
|
|
2937
3114
|
current: get(requestParams, [pagination.paramsType, pagination.currentName], 1),
|
|
2938
|
-
pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize ||
|
|
3115
|
+
pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20,
|
|
2939
3116
|
onChange: handlePaginationChange,
|
|
2940
3117
|
size: pagination.size,
|
|
2941
3118
|
hideOnSinglePage: pagination.hideOnSinglePage,
|
|
@@ -3042,9 +3219,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3042
3219
|
ref: tableContentRef,
|
|
3043
3220
|
enabled: horizontalScroller && renderType === 'Table' && !isCardModeActive,
|
|
3044
3221
|
getPortalContainer: getScrollContainer,
|
|
3045
|
-
className:
|
|
3046
|
-
'is-loading': !isComplete && !data
|
|
3047
|
-
}),
|
|
3222
|
+
className: style$1['table-content'],
|
|
3048
3223
|
children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
|
|
3049
3224
|
filterValue: filterValue,
|
|
3050
3225
|
onFilterChange: handleFilterChange,
|
|
@@ -3077,7 +3252,10 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3077
3252
|
}) : tableElement]
|
|
3078
3253
|
});
|
|
3079
3254
|
return /*#__PURE__*/jsx("div", {
|
|
3080
|
-
className: style$1['table-page'],
|
|
3255
|
+
className: classnames(style$1['table-page'], 'loading-container', {
|
|
3256
|
+
// reload 会保留旧 data,仅将 isComplete 置为 false;用蒙层提示切换中,避免卸载表格
|
|
3257
|
+
'is-loading': !isComplete
|
|
3258
|
+
}),
|
|
3081
3259
|
style: scrollTopInsetStyle,
|
|
3082
3260
|
children: useLoadMoreMode ? /*#__PURE__*/jsx(ScrollLoader, _extends({
|
|
3083
3261
|
className: style$1['mobile-load-more'],
|
|
@@ -3102,48 +3280,105 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3102
3280
|
let {
|
|
3103
3281
|
pagination,
|
|
3104
3282
|
horizontalScroller = true,
|
|
3105
|
-
getScrollContainer
|
|
3283
|
+
getScrollContainer,
|
|
3284
|
+
filter: filterProp
|
|
3106
3285
|
} = _ref2,
|
|
3107
3286
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
3108
3287
|
pagination = Object.assign({}, {
|
|
3109
3288
|
showSizeChanger: true,
|
|
3110
3289
|
showQuickJumper: true,
|
|
3111
|
-
hideOnSinglePage:
|
|
3290
|
+
hideOnSinglePage: true,
|
|
3112
3291
|
open: true,
|
|
3113
3292
|
paramsType: 'data',
|
|
3114
3293
|
requestType: 'reload',
|
|
3115
3294
|
currentName: 'currentPage',
|
|
3116
3295
|
pageSizeName: 'perPage',
|
|
3117
|
-
pageSize:
|
|
3296
|
+
pageSize: 20
|
|
3118
3297
|
}, pagination);
|
|
3119
3298
|
const pageSizeKey = `${(props.name || 'common').toUpperCase()}_TABLE_PAGE_SIZE`;
|
|
3120
3299
|
const cachePageSize = pagination.cachePageSize !== false;
|
|
3300
|
+
const paginationUrlEnabled = isPaginationSearchParamsEnabled(pagination);
|
|
3301
|
+
const [urlPagination] = useState(() => paginationUrlEnabled ? parsePaginationSearchParams(pagination.searchParams, {
|
|
3302
|
+
currentName: pagination.currentName,
|
|
3303
|
+
pageSizeName: pagination.pageSizeName
|
|
3304
|
+
}) : {});
|
|
3121
3305
|
const [pageSize, setPageSize] = useState(() => {
|
|
3122
|
-
var _ref3;
|
|
3123
|
-
return (_ref3 = cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3306
|
+
var _ref3, _urlPagination$pageSi;
|
|
3307
|
+
return (_ref3 = (_urlPagination$pageSi = urlPagination.pageSize) != null ? _urlPagination$pageSi : cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3308
|
+
});
|
|
3309
|
+
const [initialCurrent] = useState(() => {
|
|
3310
|
+
if (urlPagination.current != null) {
|
|
3311
|
+
return urlPagination.current;
|
|
3312
|
+
}
|
|
3313
|
+
const fromProps = Number(get(props[pagination.paramsType], pagination.currentName));
|
|
3314
|
+
return Number.isFinite(fromProps) && fromProps > 0 ? fromProps : 1;
|
|
3124
3315
|
});
|
|
3316
|
+
const [searchParamsSnapshot] = useState(() => parseSearchParamsValue(filterProp == null ? void 0 : filterProp.searchParamsValue));
|
|
3317
|
+
const {
|
|
3318
|
+
items: fromUrl,
|
|
3319
|
+
consumedKeys
|
|
3320
|
+
} = searchParamsSnapshot;
|
|
3321
|
+
const filter = useMemo(() => {
|
|
3322
|
+
if (!filterProp) {
|
|
3323
|
+
return filterProp;
|
|
3324
|
+
}
|
|
3325
|
+
const rest = _objectWithoutPropertiesLoose(filterProp, _excluded3);
|
|
3326
|
+
if ('value' in filterProp) {
|
|
3327
|
+
return rest;
|
|
3328
|
+
}
|
|
3329
|
+
return Object.assign({}, rest, {
|
|
3330
|
+
defaultValue: mergeFilterByName(filterProp.defaultValue || [], fromUrl)
|
|
3331
|
+
});
|
|
3332
|
+
}, [filterProp, fromUrl]);
|
|
3125
3333
|
const params = props[pagination.paramsType];
|
|
3126
3334
|
const filterDefaultParams = useMemo(() => {
|
|
3127
|
-
|
|
3128
|
-
if (!filter) {
|
|
3335
|
+
var _ref4, _ref5;
|
|
3336
|
+
if (!filterProp && !filter) {
|
|
3129
3337
|
return {};
|
|
3130
3338
|
}
|
|
3131
|
-
const
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3339
|
+
const mapFilterValue = ((_ref4 = filter || filterProp) == null ? void 0 : _ref4.mapFilterValue) || getFilterValue;
|
|
3340
|
+
let initialValue;
|
|
3341
|
+
if (filterProp && 'value' in filterProp) {
|
|
3342
|
+
// 受控:不改 value;首包用 value ∪ fromUrl 作请求种子
|
|
3343
|
+
initialValue = mergeFilterByName(filterProp.value || [], fromUrl);
|
|
3344
|
+
} else {
|
|
3345
|
+
initialValue = resolveInitialFilterValue(filter);
|
|
3346
|
+
}
|
|
3347
|
+
if (!initialValue.length && !((_ref5 = filter || filterProp) != null && _ref5.mapFilterValue)) {
|
|
3135
3348
|
return {};
|
|
3136
3349
|
}
|
|
3137
3350
|
return mapFilterValue(initialValue);
|
|
3138
|
-
}, [
|
|
3351
|
+
}, [filter, filterProp, fromUrl]);
|
|
3352
|
+
const urlStrippedRef = useRef(false);
|
|
3353
|
+
useEffect(() => {
|
|
3354
|
+
var _filterProp$searchPar, _filterProp$searchPar2;
|
|
3355
|
+
if (urlStrippedRef.current) {
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3358
|
+
urlStrippedRef.current = true;
|
|
3359
|
+
const setSearchParams = filterProp == null || (_filterProp$searchPar = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar.setSearchParams;
|
|
3360
|
+
const searchParams = filterProp == null || (_filterProp$searchPar2 = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar2.searchParams;
|
|
3361
|
+
if (typeof setSearchParams !== 'function') {
|
|
3362
|
+
return;
|
|
3363
|
+
}
|
|
3364
|
+
const nextParams = stripConsumedUrlParams(searchParams, consumedKeys);
|
|
3365
|
+
if (nextParams) {
|
|
3366
|
+
setSearchParams(nextParams, {
|
|
3367
|
+
replace: true
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
}, [filterProp, consumedKeys]);
|
|
3139
3371
|
const fetchParams = useMemo(() => {
|
|
3140
3372
|
return {
|
|
3141
|
-
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, {
|
|
3373
|
+
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, _extends({}, paginationUrlEnabled ? {
|
|
3374
|
+
[pagination.currentName]: initialCurrent
|
|
3375
|
+
} : null, {
|
|
3142
3376
|
[pagination.pageSizeName]: pageSize
|
|
3143
|
-
})
|
|
3377
|
+
}))
|
|
3144
3378
|
};
|
|
3145
|
-
}, [params, pagination.pageSizeName, pagination.paramsType, pageSize, filterDefaultParams]);
|
|
3379
|
+
}, [params, pagination.pageSizeName, pagination.paramsType, pagination.currentName, pageSize, filterDefaultParams, paginationUrlEnabled, initialCurrent]);
|
|
3146
3380
|
return /*#__PURE__*/jsx(TablePageInner, _extends({}, props, fetchParams, {
|
|
3381
|
+
filter: filter,
|
|
3147
3382
|
horizontalScroller: horizontalScroller,
|
|
3148
3383
|
getScrollContainer: getScrollContainer,
|
|
3149
3384
|
pagination: Object.assign({}, pagination, {
|