@kne/table-page 0.1.19 → 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 +260 -15
- package/dist/index.css +27 -20
- package/dist/index.css.map +1 -1
- package/dist/index.js +265 -24
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +261 -26
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
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';
|
|
@@ -1870,7 +1870,7 @@ const Table = p => {
|
|
|
1870
1870
|
}
|
|
1871
1871
|
const config = typeof sticky === 'object' ? Object.assign({}, sticky) : {};
|
|
1872
1872
|
if (hasScrollY) {
|
|
1873
|
-
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$
|
|
1873
|
+
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$2);
|
|
1874
1874
|
return Object.assign({
|
|
1875
1875
|
offsetHeader: 0
|
|
1876
1876
|
}, scrollSticky);
|
|
@@ -2322,11 +2322,11 @@ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
|
2322
2322
|
});
|
|
2323
2323
|
};
|
|
2324
2324
|
|
|
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-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"};
|
|
2326
2326
|
|
|
2327
2327
|
const _excluded$1 = ["getPopupContainer"],
|
|
2328
|
-
_excluded2$1 = ["list", "displayLine", "extraExpand", "className"],
|
|
2329
|
-
_excluded3 = ["className", "style"];
|
|
2328
|
+
_excluded2$1 = ["list", "displayLine", "extraExpand", "className", "searchParamsValue", "mapFilterValue", "value", "defaultValue", "onChange"],
|
|
2329
|
+
_excluded3$1 = ["className", "style"];
|
|
2330
2330
|
const TAB_ALL_KEY = '__all__';
|
|
2331
2331
|
const getTabActiveKey = (filterValue, tabName) => {
|
|
2332
2332
|
var _entry$value;
|
|
@@ -2539,7 +2539,7 @@ const TableToolbar = ({
|
|
|
2539
2539
|
className: searchClassName,
|
|
2540
2540
|
style: searchStyle
|
|
2541
2541
|
} = _ref3,
|
|
2542
|
-
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
2542
|
+
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
2543
2543
|
|
|
2544
2544
|
// tab 已有选中态展示,已选筛选标签中不再重复显示 tab 的值
|
|
2545
2545
|
const displayFilterValue = hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || [];
|
|
@@ -2557,12 +2557,15 @@ const TableToolbar = ({
|
|
|
2557
2557
|
bordered: false,
|
|
2558
2558
|
variant: "filled",
|
|
2559
2559
|
size: isMobile ? 'middle' : 'small',
|
|
2560
|
-
className: classnames(style['table-toolbar-search-input'], searchClassName)
|
|
2560
|
+
className: classnames(style['table-toolbar-search-input'], searchClassName)
|
|
2561
|
+
}, searchRest, {
|
|
2561
2562
|
style: isMobile ? _extends({}, searchStyle, {
|
|
2562
2563
|
width: '100%',
|
|
2563
2564
|
maxWidth: '100%'
|
|
2564
|
-
}) : searchStyle
|
|
2565
|
-
|
|
2565
|
+
}) : _extends({}, searchStyle, {
|
|
2566
|
+
width: 180
|
|
2567
|
+
})
|
|
2568
|
+
})) : null;
|
|
2566
2569
|
const buttonGroupNode = showButtonGroup ? /*#__PURE__*/jsx("div", {
|
|
2567
2570
|
className: style['table-toolbar-button-group'],
|
|
2568
2571
|
children: /*#__PURE__*/jsx(ButtonGroup, _extends({}, resolveToolbarButtonGroupProps(buttonGroup, getPopupContainer)))
|
|
@@ -2642,6 +2645,7 @@ const TableToolbar = ({
|
|
|
2642
2645
|
[style['is-mobile-render']]: isMobileRender
|
|
2643
2646
|
}),
|
|
2644
2647
|
children: /*#__PURE__*/jsx(FilterValueDisplay, {
|
|
2648
|
+
hideLabel: true,
|
|
2645
2649
|
value: displayFilterValue,
|
|
2646
2650
|
onChange: handleValueDisplayChange,
|
|
2647
2651
|
extraExpand: extraExpand,
|
|
@@ -2652,8 +2656,164 @@ const TableToolbar = ({
|
|
|
2652
2656
|
});
|
|
2653
2657
|
};
|
|
2654
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
|
+
|
|
2655
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"],
|
|
2656
|
-
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"]
|
|
2815
|
+
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
|
|
2816
|
+
_excluded3 = ["searchParamsValue"];
|
|
2657
2817
|
const defaultMergeList = (data, newData) => {
|
|
2658
2818
|
return Object.assign({}, newData, {
|
|
2659
2819
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
@@ -2861,8 +3021,24 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2861
3021
|
preferToolbar: hasToolbar
|
|
2862
3022
|
});
|
|
2863
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
|
+
});
|
|
2864
3038
|
const handleFilterChange = useRefCallback(value => {
|
|
2865
3039
|
setFilterValue(value);
|
|
3040
|
+
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
3041
|
+
syncPaginationToUrl(1, currentSize);
|
|
2866
3042
|
reload({
|
|
2867
3043
|
[pagination.paramsType]: buildRequestParamsWithFilter(value, {
|
|
2868
3044
|
[pagination.currentName]: 1
|
|
@@ -2878,17 +3054,19 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2878
3054
|
}, [isComplete, data, scrollTable]);
|
|
2879
3055
|
const handlePaginationChange = useRefCallback((page, size) => {
|
|
2880
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;
|
|
2881
3060
|
if (typeof pagination.onChange === 'function') {
|
|
3061
|
+
syncPaginationToUrl(page, nextSize || currentSize);
|
|
2882
3062
|
pagination.onChange(page, size);
|
|
2883
3063
|
return;
|
|
2884
3064
|
}
|
|
2885
|
-
const nextSize = Number(size);
|
|
2886
|
-
const currentPage = get(requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
2887
|
-
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2888
3065
|
if (nextSize !== currentSize) {
|
|
2889
3066
|
pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
|
|
2890
3067
|
}
|
|
2891
3068
|
if (page !== currentPage || nextSize !== currentSize) {
|
|
3069
|
+
syncPaginationToUrl(page, nextSize);
|
|
2892
3070
|
(pagination.requestType === 'refresh' ? refresh : reload)({
|
|
2893
3071
|
[pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
|
|
2894
3072
|
[pagination.currentName]: page,
|
|
@@ -3102,7 +3280,8 @@ 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({}, {
|
|
@@ -3118,32 +3297,88 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
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, {
|