@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.js
CHANGED
|
@@ -1206,7 +1206,7 @@ const TreeExpandContent = ({
|
|
|
1206
1206
|
|
|
1207
1207
|
const _excluded$1 = ["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"],
|
|
1208
1208
|
_excluded2$1 = ["y"],
|
|
1209
|
-
_excluded3 = ["getContainer"];
|
|
1209
|
+
_excluded3$1 = ["getContainer"];
|
|
1210
1210
|
const mapJustifyToAlign = justify => {
|
|
1211
1211
|
if (justify === 'center') {
|
|
1212
1212
|
return 'center';
|
|
@@ -1924,7 +1924,7 @@ const Table = p => {
|
|
|
1924
1924
|
}
|
|
1925
1925
|
const config = typeof sticky === 'object' ? Object.assign({}, sticky) : {};
|
|
1926
1926
|
if (hasScrollY) {
|
|
1927
|
-
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3);
|
|
1927
|
+
const scrollSticky = _objectWithoutPropertiesLoose(config, _excluded3$1);
|
|
1928
1928
|
return Object.assign({
|
|
1929
1929
|
offsetHeader: 0
|
|
1930
1930
|
}, scrollSticky);
|
|
@@ -2377,7 +2377,7 @@ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
|
2377
2377
|
});
|
|
2378
2378
|
};
|
|
2379
2379
|
|
|
2380
|
-
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-
|
|
2380
|
+
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"};
|
|
2381
2381
|
|
|
2382
2382
|
const TAB_ALL_KEY = '__all__';
|
|
2383
2383
|
const getTabActiveKey = (filterValue, tabName) => {
|
|
@@ -2581,6 +2581,11 @@ const TableToolbar = ({
|
|
|
2581
2581
|
displayLine = 1,
|
|
2582
2582
|
extraExpand,
|
|
2583
2583
|
className: filterClassName,
|
|
2584
|
+
searchParamsValue: _searchParamsValue,
|
|
2585
|
+
mapFilterValue: _mapFilterValue,
|
|
2586
|
+
value: _value,
|
|
2587
|
+
defaultValue: _defaultValue,
|
|
2588
|
+
onChange: _onChange,
|
|
2584
2589
|
...filterRest
|
|
2585
2590
|
} = filter || {};
|
|
2586
2591
|
const {
|
|
@@ -2606,12 +2611,15 @@ const TableToolbar = ({
|
|
|
2606
2611
|
variant: "filled",
|
|
2607
2612
|
size: isMobile ? 'middle' : 'small',
|
|
2608
2613
|
className: classnames__default["default"](style['table-toolbar-search-input'], searchClassName),
|
|
2614
|
+
...searchRest,
|
|
2609
2615
|
style: isMobile ? {
|
|
2610
2616
|
...searchStyle,
|
|
2611
2617
|
width: '100%',
|
|
2612
2618
|
maxWidth: '100%'
|
|
2613
|
-
} :
|
|
2614
|
-
|
|
2619
|
+
} : {
|
|
2620
|
+
...searchStyle,
|
|
2621
|
+
width: 180
|
|
2622
|
+
}
|
|
2615
2623
|
}) : null;
|
|
2616
2624
|
const buttonGroupNode = showButtonGroup ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2617
2625
|
className: style['table-toolbar-button-group'],
|
|
@@ -2695,6 +2703,7 @@ const TableToolbar = ({
|
|
|
2695
2703
|
[style['is-mobile-render']]: isMobileRender
|
|
2696
2704
|
}),
|
|
2697
2705
|
children: /*#__PURE__*/jsxRuntime.jsx(reactFilter.FilterValueDisplay, {
|
|
2706
|
+
hideLabel: true,
|
|
2698
2707
|
value: displayFilterValue,
|
|
2699
2708
|
onChange: handleValueDisplayChange,
|
|
2700
2709
|
extraExpand: extraExpand,
|
|
@@ -2705,8 +2714,164 @@ const TableToolbar = ({
|
|
|
2705
2714
|
});
|
|
2706
2715
|
};
|
|
2707
2716
|
|
|
2717
|
+
/**
|
|
2718
|
+
* 与 @kne/react-filter useSearchParamsValue 内部解析保持一致(不从该包导出)。
|
|
2719
|
+
*
|
|
2720
|
+
* @param {Object} [options]
|
|
2721
|
+
* @param {URLSearchParams} [options.searchParams]
|
|
2722
|
+
* @param {Array<{ name: string, label?: string }>} [options.fields]
|
|
2723
|
+
* @returns {{ items: Array, consumedKeys: string[] }}
|
|
2724
|
+
*/
|
|
2725
|
+
const parseSearchParamsValue = ({
|
|
2726
|
+
searchParams,
|
|
2727
|
+
fields
|
|
2728
|
+
} = {}) => {
|
|
2729
|
+
const items = [];
|
|
2730
|
+
const consumedKeys = [];
|
|
2731
|
+
if (!searchParams || !Array.isArray(fields) || fields.length === 0) {
|
|
2732
|
+
return {
|
|
2733
|
+
items,
|
|
2734
|
+
consumedKeys
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
fields.forEach(field => {
|
|
2738
|
+
const name = field?.name;
|
|
2739
|
+
if (!name || !searchParams.has(name)) {
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
const raw = searchParams.get(name);
|
|
2743
|
+
if (raw == null || raw === '') {
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
consumedKeys.push(name);
|
|
2747
|
+
const label = field.label != null ? field.label : name;
|
|
2748
|
+
items.push({
|
|
2749
|
+
name,
|
|
2750
|
+
label,
|
|
2751
|
+
value: {
|
|
2752
|
+
label: raw,
|
|
2753
|
+
value: raw
|
|
2754
|
+
}
|
|
2755
|
+
});
|
|
2756
|
+
});
|
|
2757
|
+
return {
|
|
2758
|
+
items,
|
|
2759
|
+
consumedKeys
|
|
2760
|
+
};
|
|
2761
|
+
};
|
|
2762
|
+
|
|
2763
|
+
/**
|
|
2764
|
+
* 按 name 合并筛选数组;同名时 fromUrl 覆盖 base。
|
|
2765
|
+
* @param {Array} base
|
|
2766
|
+
* @param {Array} fromUrl
|
|
2767
|
+
* @returns {Array}
|
|
2768
|
+
*/
|
|
2769
|
+
const mergeFilterByName = (base = [], fromUrl = []) => {
|
|
2770
|
+
if (!fromUrl.length) {
|
|
2771
|
+
return Array.isArray(base) ? [...base] : [];
|
|
2772
|
+
}
|
|
2773
|
+
const map = new Map();
|
|
2774
|
+
(base || []).forEach(item => {
|
|
2775
|
+
if (item?.name) {
|
|
2776
|
+
map.set(item.name, item);
|
|
2777
|
+
}
|
|
2778
|
+
});
|
|
2779
|
+
fromUrl.forEach(item => {
|
|
2780
|
+
if (item?.name) {
|
|
2781
|
+
map.set(item.name, item);
|
|
2782
|
+
}
|
|
2783
|
+
});
|
|
2784
|
+
return Array.from(map.values());
|
|
2785
|
+
};
|
|
2786
|
+
|
|
2787
|
+
/**
|
|
2788
|
+
* @param {URLSearchParams} searchParams
|
|
2789
|
+
* @param {string[]} consumedKeys
|
|
2790
|
+
* @returns {URLSearchParams|null}
|
|
2791
|
+
*/
|
|
2792
|
+
const stripConsumedUrlParams = (searchParams, consumedKeys) => {
|
|
2793
|
+
if (!consumedKeys?.length) {
|
|
2794
|
+
return null;
|
|
2795
|
+
}
|
|
2796
|
+
const next = new URLSearchParams(searchParams);
|
|
2797
|
+
let changed = false;
|
|
2798
|
+
consumedKeys.forEach(key => {
|
|
2799
|
+
if (next.has(key)) {
|
|
2800
|
+
next.delete(key);
|
|
2801
|
+
changed = true;
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
return changed ? next : null;
|
|
2805
|
+
};
|
|
2806
|
+
const parsePositiveInt = raw => {
|
|
2807
|
+
if (raw == null || raw === '') {
|
|
2808
|
+
return undefined;
|
|
2809
|
+
}
|
|
2810
|
+
const num = Number(raw);
|
|
2811
|
+
if (!Number.isFinite(num) || num <= 0) {
|
|
2812
|
+
return undefined;
|
|
2813
|
+
}
|
|
2814
|
+
return Math.floor(num);
|
|
2815
|
+
};
|
|
2816
|
+
|
|
2817
|
+
/**
|
|
2818
|
+
* 从 URL 读取分页状态(非法数字忽略)。
|
|
2819
|
+
* @param {URLSearchParams} [searchParams]
|
|
2820
|
+
* @param {{ currentName?: string, pageSizeName?: string }} [options]
|
|
2821
|
+
* @returns {{ current?: number, pageSize?: number }}
|
|
2822
|
+
*/
|
|
2823
|
+
const parsePaginationSearchParams = (searchParams, {
|
|
2824
|
+
currentName = 'currentPage',
|
|
2825
|
+
pageSizeName = 'perPage'
|
|
2826
|
+
} = {}) => {
|
|
2827
|
+
const result = {};
|
|
2828
|
+
if (!searchParams) {
|
|
2829
|
+
return result;
|
|
2830
|
+
}
|
|
2831
|
+
const current = parsePositiveInt(searchParams.get(currentName));
|
|
2832
|
+
const pageSize = parsePositiveInt(searchParams.get(pageSizeName));
|
|
2833
|
+
if (current != null) {
|
|
2834
|
+
result.current = current;
|
|
2835
|
+
}
|
|
2836
|
+
if (pageSize != null) {
|
|
2837
|
+
result.pageSize = pageSize;
|
|
2838
|
+
}
|
|
2839
|
+
return result;
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2842
|
+
/**
|
|
2843
|
+
* 写入分页参数到 URL,保留其它 query。
|
|
2844
|
+
* @param {URLSearchParams} [searchParams]
|
|
2845
|
+
* @param {{ current?: number, pageSize?: number, currentName?: string, pageSizeName?: string }} options
|
|
2846
|
+
* @returns {URLSearchParams}
|
|
2847
|
+
*/
|
|
2848
|
+
const patchPaginationSearchParams = (searchParams, {
|
|
2849
|
+
current,
|
|
2850
|
+
pageSize,
|
|
2851
|
+
currentName = 'currentPage',
|
|
2852
|
+
pageSizeName = 'perPage'
|
|
2853
|
+
} = {}) => {
|
|
2854
|
+
const next = new URLSearchParams(searchParams);
|
|
2855
|
+
if (current != null) {
|
|
2856
|
+
next.set(currentName, String(current));
|
|
2857
|
+
}
|
|
2858
|
+
if (pageSize != null) {
|
|
2859
|
+
next.set(pageSizeName, String(pageSize));
|
|
2860
|
+
}
|
|
2861
|
+
return next;
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2864
|
+
/**
|
|
2865
|
+
* @param {object} [pagination]
|
|
2866
|
+
* @returns {boolean}
|
|
2867
|
+
*/
|
|
2868
|
+
const isPaginationSearchParamsEnabled = pagination => {
|
|
2869
|
+
return !!(pagination?.searchParams && typeof pagination.setSearchParams === 'function');
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2708
2872
|
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"],
|
|
2709
|
-
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"]
|
|
2873
|
+
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
|
|
2874
|
+
_excluded3 = ["searchParamsValue"];
|
|
2710
2875
|
const defaultMergeList = (data, newData) => {
|
|
2711
2876
|
return Object.assign({}, newData, {
|
|
2712
2877
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
@@ -2925,8 +3090,24 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2925
3090
|
preferToolbar: hasToolbar
|
|
2926
3091
|
});
|
|
2927
3092
|
});
|
|
3093
|
+
const syncPaginationToUrl = useRefCallback__default["default"]((page, size) => {
|
|
3094
|
+
if (!isPaginationSearchParamsEnabled(pagination)) {
|
|
3095
|
+
return;
|
|
3096
|
+
}
|
|
3097
|
+
const nextParams = patchPaginationSearchParams(pagination.searchParams, {
|
|
3098
|
+
current: page,
|
|
3099
|
+
pageSize: size,
|
|
3100
|
+
currentName: pagination.currentName,
|
|
3101
|
+
pageSizeName: pagination.pageSizeName
|
|
3102
|
+
});
|
|
3103
|
+
pagination.setSearchParams(nextParams, {
|
|
3104
|
+
replace: true
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
2928
3107
|
const handleFilterChange = useRefCallback__default["default"](value => {
|
|
2929
3108
|
setFilterValue(value);
|
|
3109
|
+
const currentSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
3110
|
+
syncPaginationToUrl(1, currentSize);
|
|
2930
3111
|
reload({
|
|
2931
3112
|
[pagination.paramsType]: buildRequestParamsWithFilter(value, {
|
|
2932
3113
|
[pagination.currentName]: 1
|
|
@@ -2942,17 +3123,19 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2942
3123
|
}, [isComplete, data, scrollTable]);
|
|
2943
3124
|
const handlePaginationChange = useRefCallback__default["default"]((page, size) => {
|
|
2944
3125
|
pendingScrollRef.current = true;
|
|
3126
|
+
const nextSize = Number(size);
|
|
3127
|
+
const currentPage = get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
3128
|
+
const currentSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2945
3129
|
if (typeof pagination.onChange === 'function') {
|
|
3130
|
+
syncPaginationToUrl(page, nextSize || currentSize);
|
|
2946
3131
|
pagination.onChange(page, size);
|
|
2947
3132
|
return;
|
|
2948
3133
|
}
|
|
2949
|
-
const nextSize = Number(size);
|
|
2950
|
-
const currentPage = get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
2951
|
-
const currentSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2952
3134
|
if (nextSize !== currentSize) {
|
|
2953
3135
|
pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
|
|
2954
3136
|
}
|
|
2955
3137
|
if (page !== currentPage || nextSize !== currentSize) {
|
|
3138
|
+
syncPaginationToUrl(page, nextSize);
|
|
2956
3139
|
(pagination.requestType === 'refresh' ? refresh : reload)({
|
|
2957
3140
|
[pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
|
|
2958
3141
|
[pagination.currentName]: page,
|
|
@@ -3171,6 +3354,7 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3171
3354
|
_ref2$horizontalScrol = _ref2.horizontalScroller,
|
|
3172
3355
|
horizontalScroller = _ref2$horizontalScrol === void 0 ? true : _ref2$horizontalScrol,
|
|
3173
3356
|
getScrollContainer = _ref2.getScrollContainer,
|
|
3357
|
+
filterProp = _ref2.filter,
|
|
3174
3358
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
3175
3359
|
pagination = Object.assign({}, {
|
|
3176
3360
|
showSizeChanger: true,
|
|
@@ -3185,34 +3369,91 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3185
3369
|
}, pagination);
|
|
3186
3370
|
const pageSizeKey = (props.name || 'common').toUpperCase() + "_TABLE_PAGE_SIZE";
|
|
3187
3371
|
const cachePageSize = pagination.cachePageSize !== false;
|
|
3188
|
-
const
|
|
3189
|
-
|
|
3190
|
-
|
|
3372
|
+
const paginationUrlEnabled = isPaginationSearchParamsEnabled(pagination);
|
|
3373
|
+
const _useState2 = react.useState(() => paginationUrlEnabled ? parsePaginationSearchParams(pagination.searchParams, {
|
|
3374
|
+
currentName: pagination.currentName,
|
|
3375
|
+
pageSizeName: pagination.pageSizeName
|
|
3376
|
+
}) : {}),
|
|
3377
|
+
urlPagination = _useState2[0];
|
|
3378
|
+
const _useState3 = react.useState(() => {
|
|
3379
|
+
var _ref3, _urlPagination$pageSi;
|
|
3380
|
+
return (_ref3 = (_urlPagination$pageSi = urlPagination.pageSize) != null ? _urlPagination$pageSi : cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3191
3381
|
}),
|
|
3192
|
-
pageSize =
|
|
3193
|
-
setPageSize =
|
|
3382
|
+
pageSize = _useState3[0],
|
|
3383
|
+
setPageSize = _useState3[1];
|
|
3384
|
+
const _useState4 = react.useState(() => {
|
|
3385
|
+
if (urlPagination.current != null) {
|
|
3386
|
+
return urlPagination.current;
|
|
3387
|
+
}
|
|
3388
|
+
const fromProps = Number(get__default["default"](props[pagination.paramsType], pagination.currentName));
|
|
3389
|
+
return Number.isFinite(fromProps) && fromProps > 0 ? fromProps : 1;
|
|
3390
|
+
}),
|
|
3391
|
+
initialCurrent = _useState4[0];
|
|
3392
|
+
const _useState5 = react.useState(() => parseSearchParamsValue(filterProp == null ? void 0 : filterProp.searchParamsValue)),
|
|
3393
|
+
searchParamsSnapshot = _useState5[0];
|
|
3394
|
+
const fromUrl = searchParamsSnapshot.items,
|
|
3395
|
+
consumedKeys = searchParamsSnapshot.consumedKeys;
|
|
3396
|
+
const filter = react.useMemo(() => {
|
|
3397
|
+
if (!filterProp) {
|
|
3398
|
+
return filterProp;
|
|
3399
|
+
}
|
|
3400
|
+
const rest = _objectWithoutPropertiesLoose(filterProp, _excluded3);
|
|
3401
|
+
if ('value' in filterProp) {
|
|
3402
|
+
return rest;
|
|
3403
|
+
}
|
|
3404
|
+
return Object.assign({}, rest, {
|
|
3405
|
+
defaultValue: mergeFilterByName(filterProp.defaultValue || [], fromUrl)
|
|
3406
|
+
});
|
|
3407
|
+
}, [filterProp, fromUrl]);
|
|
3194
3408
|
const params = props[pagination.paramsType];
|
|
3195
3409
|
const filterDefaultParams = react.useMemo(() => {
|
|
3196
|
-
|
|
3197
|
-
if (!filter) {
|
|
3410
|
+
var _ref4, _ref5;
|
|
3411
|
+
if (!filterProp && !filter) {
|
|
3198
3412
|
return {};
|
|
3199
3413
|
}
|
|
3200
|
-
const
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3414
|
+
const mapFilterValue = ((_ref4 = filter || filterProp) == null ? void 0 : _ref4.mapFilterValue) || reactFilter.getFilterValue;
|
|
3415
|
+
let initialValue;
|
|
3416
|
+
if (filterProp && 'value' in filterProp) {
|
|
3417
|
+
// 受控:不改 value;首包用 value ∪ fromUrl 作请求种子
|
|
3418
|
+
initialValue = mergeFilterByName(filterProp.value || [], fromUrl);
|
|
3419
|
+
} else {
|
|
3420
|
+
initialValue = resolveInitialFilterValue(filter);
|
|
3421
|
+
}
|
|
3422
|
+
if (!initialValue.length && !((_ref5 = filter || filterProp) != null && _ref5.mapFilterValue)) {
|
|
3204
3423
|
return {};
|
|
3205
3424
|
}
|
|
3206
3425
|
return mapFilterValue(initialValue);
|
|
3207
|
-
}, [
|
|
3426
|
+
}, [filter, filterProp, fromUrl]);
|
|
3427
|
+
const urlStrippedRef = react.useRef(false);
|
|
3428
|
+
react.useEffect(() => {
|
|
3429
|
+
var _filterProp$searchPar, _filterProp$searchPar2;
|
|
3430
|
+
if (urlStrippedRef.current) {
|
|
3431
|
+
return;
|
|
3432
|
+
}
|
|
3433
|
+
urlStrippedRef.current = true;
|
|
3434
|
+
const setSearchParams = filterProp == null || (_filterProp$searchPar = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar.setSearchParams;
|
|
3435
|
+
const searchParams = filterProp == null || (_filterProp$searchPar2 = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar2.searchParams;
|
|
3436
|
+
if (typeof setSearchParams !== 'function') {
|
|
3437
|
+
return;
|
|
3438
|
+
}
|
|
3439
|
+
const nextParams = stripConsumedUrlParams(searchParams, consumedKeys);
|
|
3440
|
+
if (nextParams) {
|
|
3441
|
+
setSearchParams(nextParams, {
|
|
3442
|
+
replace: true
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
}, [filterProp, consumedKeys]);
|
|
3208
3446
|
const fetchParams = react.useMemo(() => {
|
|
3209
3447
|
return {
|
|
3210
|
-
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, {
|
|
3448
|
+
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, _extends({}, paginationUrlEnabled ? {
|
|
3449
|
+
[pagination.currentName]: initialCurrent
|
|
3450
|
+
} : null, {
|
|
3211
3451
|
[pagination.pageSizeName]: pageSize
|
|
3212
|
-
})
|
|
3452
|
+
}))
|
|
3213
3453
|
};
|
|
3214
|
-
}, [params, pagination.pageSizeName, pagination.paramsType, pageSize, filterDefaultParams]);
|
|
3454
|
+
}, [params, pagination.pageSizeName, pagination.paramsType, pagination.currentName, pageSize, filterDefaultParams, paginationUrlEnabled, initialCurrent]);
|
|
3215
3455
|
return /*#__PURE__*/jsxRuntime.jsx(TablePageInner, _extends({}, props, fetchParams, {
|
|
3456
|
+
filter: filter,
|
|
3216
3457
|
horizontalScroller: horizontalScroller,
|
|
3217
3458
|
getScrollContainer: getScrollContainer,
|
|
3218
3459
|
pagination: Object.assign({}, pagination, {
|