@kne/table-page 0.1.19 → 0.1.23
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 +276 -24
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +272 -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,175 @@ const TableToolbar = ({
|
|
|
2705
2714
|
});
|
|
2706
2715
|
};
|
|
2707
2716
|
|
|
2717
|
+
/**
|
|
2718
|
+
* 与 @kne/react-filter useSearchParamsValue 内部解析保持一致(不从该包导出)。
|
|
2719
|
+
*
|
|
2720
|
+
* fields 项:`name` 为 URL key;`label` 为筛选项标题;可选 `labelKey` 为选中值展示文案的 URL key。
|
|
2721
|
+
*
|
|
2722
|
+
* @param {Object} [options]
|
|
2723
|
+
* @param {URLSearchParams} [options.searchParams]
|
|
2724
|
+
* @param {Array<{ name: string, label?: string, labelKey?: string }>} [options.fields]
|
|
2725
|
+
* @returns {{ items: Array, consumedKeys: string[] }}
|
|
2726
|
+
*/
|
|
2727
|
+
const parseSearchParamsValue = ({
|
|
2728
|
+
searchParams,
|
|
2729
|
+
fields
|
|
2730
|
+
} = {}) => {
|
|
2731
|
+
const items = [];
|
|
2732
|
+
const consumedKeys = [];
|
|
2733
|
+
if (!searchParams || !Array.isArray(fields) || fields.length === 0) {
|
|
2734
|
+
return {
|
|
2735
|
+
items,
|
|
2736
|
+
consumedKeys
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
fields.forEach(field => {
|
|
2740
|
+
const name = field?.name;
|
|
2741
|
+
if (!name || !searchParams.has(name)) {
|
|
2742
|
+
return;
|
|
2743
|
+
}
|
|
2744
|
+
const raw = searchParams.get(name);
|
|
2745
|
+
if (raw == null || raw === '') {
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2748
|
+
consumedKeys.push(name);
|
|
2749
|
+
let valueText = raw;
|
|
2750
|
+
const labelKey = field.labelKey;
|
|
2751
|
+
if (labelKey && searchParams.has(labelKey)) {
|
|
2752
|
+
const fromLabelKey = searchParams.get(labelKey);
|
|
2753
|
+
if (fromLabelKey != null && fromLabelKey !== '') {
|
|
2754
|
+
valueText = fromLabelKey;
|
|
2755
|
+
consumedKeys.push(labelKey);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
const label = field.label != null ? field.label : name;
|
|
2759
|
+
items.push({
|
|
2760
|
+
name,
|
|
2761
|
+
label,
|
|
2762
|
+
value: {
|
|
2763
|
+
label: valueText,
|
|
2764
|
+
value: raw
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
});
|
|
2768
|
+
return {
|
|
2769
|
+
items,
|
|
2770
|
+
consumedKeys
|
|
2771
|
+
};
|
|
2772
|
+
};
|
|
2773
|
+
|
|
2774
|
+
/**
|
|
2775
|
+
* 按 name 合并筛选数组;同名时 fromUrl 覆盖 base。
|
|
2776
|
+
* @param {Array} base
|
|
2777
|
+
* @param {Array} fromUrl
|
|
2778
|
+
* @returns {Array}
|
|
2779
|
+
*/
|
|
2780
|
+
const mergeFilterByName = (base = [], fromUrl = []) => {
|
|
2781
|
+
if (!fromUrl.length) {
|
|
2782
|
+
return Array.isArray(base) ? [...base] : [];
|
|
2783
|
+
}
|
|
2784
|
+
const map = new Map();
|
|
2785
|
+
(base || []).forEach(item => {
|
|
2786
|
+
if (item?.name) {
|
|
2787
|
+
map.set(item.name, item);
|
|
2788
|
+
}
|
|
2789
|
+
});
|
|
2790
|
+
fromUrl.forEach(item => {
|
|
2791
|
+
if (item?.name) {
|
|
2792
|
+
map.set(item.name, item);
|
|
2793
|
+
}
|
|
2794
|
+
});
|
|
2795
|
+
return Array.from(map.values());
|
|
2796
|
+
};
|
|
2797
|
+
|
|
2798
|
+
/**
|
|
2799
|
+
* @param {URLSearchParams} searchParams
|
|
2800
|
+
* @param {string[]} consumedKeys
|
|
2801
|
+
* @returns {URLSearchParams|null}
|
|
2802
|
+
*/
|
|
2803
|
+
const stripConsumedUrlParams = (searchParams, consumedKeys) => {
|
|
2804
|
+
if (!consumedKeys?.length) {
|
|
2805
|
+
return null;
|
|
2806
|
+
}
|
|
2807
|
+
const next = new URLSearchParams(searchParams);
|
|
2808
|
+
let changed = false;
|
|
2809
|
+
consumedKeys.forEach(key => {
|
|
2810
|
+
if (next.has(key)) {
|
|
2811
|
+
next.delete(key);
|
|
2812
|
+
changed = true;
|
|
2813
|
+
}
|
|
2814
|
+
});
|
|
2815
|
+
return changed ? next : null;
|
|
2816
|
+
};
|
|
2817
|
+
const parsePositiveInt = raw => {
|
|
2818
|
+
if (raw == null || raw === '') {
|
|
2819
|
+
return undefined;
|
|
2820
|
+
}
|
|
2821
|
+
const num = Number(raw);
|
|
2822
|
+
if (!Number.isFinite(num) || num <= 0) {
|
|
2823
|
+
return undefined;
|
|
2824
|
+
}
|
|
2825
|
+
return Math.floor(num);
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
/**
|
|
2829
|
+
* 从 URL 读取分页状态(非法数字忽略)。
|
|
2830
|
+
* @param {URLSearchParams} [searchParams]
|
|
2831
|
+
* @param {{ currentName?: string, pageSizeName?: string }} [options]
|
|
2832
|
+
* @returns {{ current?: number, pageSize?: number }}
|
|
2833
|
+
*/
|
|
2834
|
+
const parsePaginationSearchParams = (searchParams, {
|
|
2835
|
+
currentName = 'currentPage',
|
|
2836
|
+
pageSizeName = 'perPage'
|
|
2837
|
+
} = {}) => {
|
|
2838
|
+
const result = {};
|
|
2839
|
+
if (!searchParams) {
|
|
2840
|
+
return result;
|
|
2841
|
+
}
|
|
2842
|
+
const current = parsePositiveInt(searchParams.get(currentName));
|
|
2843
|
+
const pageSize = parsePositiveInt(searchParams.get(pageSizeName));
|
|
2844
|
+
if (current != null) {
|
|
2845
|
+
result.current = current;
|
|
2846
|
+
}
|
|
2847
|
+
if (pageSize != null) {
|
|
2848
|
+
result.pageSize = pageSize;
|
|
2849
|
+
}
|
|
2850
|
+
return result;
|
|
2851
|
+
};
|
|
2852
|
+
|
|
2853
|
+
/**
|
|
2854
|
+
* 写入分页参数到 URL,保留其它 query。
|
|
2855
|
+
* @param {URLSearchParams} [searchParams]
|
|
2856
|
+
* @param {{ current?: number, pageSize?: number, currentName?: string, pageSizeName?: string }} options
|
|
2857
|
+
* @returns {URLSearchParams}
|
|
2858
|
+
*/
|
|
2859
|
+
const patchPaginationSearchParams = (searchParams, {
|
|
2860
|
+
current,
|
|
2861
|
+
pageSize,
|
|
2862
|
+
currentName = 'currentPage',
|
|
2863
|
+
pageSizeName = 'perPage'
|
|
2864
|
+
} = {}) => {
|
|
2865
|
+
const next = new URLSearchParams(searchParams);
|
|
2866
|
+
if (current != null) {
|
|
2867
|
+
next.set(currentName, String(current));
|
|
2868
|
+
}
|
|
2869
|
+
if (pageSize != null) {
|
|
2870
|
+
next.set(pageSizeName, String(pageSize));
|
|
2871
|
+
}
|
|
2872
|
+
return next;
|
|
2873
|
+
};
|
|
2874
|
+
|
|
2875
|
+
/**
|
|
2876
|
+
* @param {object} [pagination]
|
|
2877
|
+
* @returns {boolean}
|
|
2878
|
+
*/
|
|
2879
|
+
const isPaginationSearchParamsEnabled = pagination => {
|
|
2880
|
+
return !!(pagination?.searchParams && typeof pagination.setSearchParams === 'function');
|
|
2881
|
+
};
|
|
2882
|
+
|
|
2708
2883
|
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"]
|
|
2884
|
+
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
|
|
2885
|
+
_excluded3 = ["searchParamsValue"];
|
|
2710
2886
|
const defaultMergeList = (data, newData) => {
|
|
2711
2887
|
return Object.assign({}, newData, {
|
|
2712
2888
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
@@ -2925,8 +3101,24 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2925
3101
|
preferToolbar: hasToolbar
|
|
2926
3102
|
});
|
|
2927
3103
|
});
|
|
3104
|
+
const syncPaginationToUrl = useRefCallback__default["default"]((page, size) => {
|
|
3105
|
+
if (!isPaginationSearchParamsEnabled(pagination)) {
|
|
3106
|
+
return;
|
|
3107
|
+
}
|
|
3108
|
+
const nextParams = patchPaginationSearchParams(pagination.searchParams, {
|
|
3109
|
+
current: page,
|
|
3110
|
+
pageSize: size,
|
|
3111
|
+
currentName: pagination.currentName,
|
|
3112
|
+
pageSizeName: pagination.pageSizeName
|
|
3113
|
+
});
|
|
3114
|
+
pagination.setSearchParams(nextParams, {
|
|
3115
|
+
replace: true
|
|
3116
|
+
});
|
|
3117
|
+
});
|
|
2928
3118
|
const handleFilterChange = useRefCallback__default["default"](value => {
|
|
2929
3119
|
setFilterValue(value);
|
|
3120
|
+
const currentSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
3121
|
+
syncPaginationToUrl(1, currentSize);
|
|
2930
3122
|
reload({
|
|
2931
3123
|
[pagination.paramsType]: buildRequestParamsWithFilter(value, {
|
|
2932
3124
|
[pagination.currentName]: 1
|
|
@@ -2942,17 +3134,19 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2942
3134
|
}, [isComplete, data, scrollTable]);
|
|
2943
3135
|
const handlePaginationChange = useRefCallback__default["default"]((page, size) => {
|
|
2944
3136
|
pendingScrollRef.current = true;
|
|
3137
|
+
const nextSize = Number(size);
|
|
3138
|
+
const currentPage = get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1);
|
|
3139
|
+
const currentSize = Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
2945
3140
|
if (typeof pagination.onChange === 'function') {
|
|
3141
|
+
syncPaginationToUrl(page, nextSize || currentSize);
|
|
2946
3142
|
pagination.onChange(page, size);
|
|
2947
3143
|
return;
|
|
2948
3144
|
}
|
|
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
3145
|
if (nextSize !== currentSize) {
|
|
2953
3146
|
pagination.onShowSizeChange && pagination.onShowSizeChange(page, nextSize);
|
|
2954
3147
|
}
|
|
2955
3148
|
if (page !== currentPage || nextSize !== currentSize) {
|
|
3149
|
+
syncPaginationToUrl(page, nextSize);
|
|
2956
3150
|
(pagination.requestType === 'refresh' ? refresh : reload)({
|
|
2957
3151
|
[pagination.paramsType]: buildRequestParamsWithFilter(filterValue, {
|
|
2958
3152
|
[pagination.currentName]: page,
|
|
@@ -3171,6 +3365,7 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3171
3365
|
_ref2$horizontalScrol = _ref2.horizontalScroller,
|
|
3172
3366
|
horizontalScroller = _ref2$horizontalScrol === void 0 ? true : _ref2$horizontalScrol,
|
|
3173
3367
|
getScrollContainer = _ref2.getScrollContainer,
|
|
3368
|
+
filterProp = _ref2.filter,
|
|
3174
3369
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
3175
3370
|
pagination = Object.assign({}, {
|
|
3176
3371
|
showSizeChanger: true,
|
|
@@ -3185,34 +3380,91 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3185
3380
|
}, pagination);
|
|
3186
3381
|
const pageSizeKey = (props.name || 'common').toUpperCase() + "_TABLE_PAGE_SIZE";
|
|
3187
3382
|
const cachePageSize = pagination.cachePageSize !== false;
|
|
3188
|
-
const
|
|
3189
|
-
|
|
3190
|
-
|
|
3383
|
+
const paginationUrlEnabled = isPaginationSearchParamsEnabled(pagination);
|
|
3384
|
+
const _useState2 = react.useState(() => paginationUrlEnabled ? parsePaginationSearchParams(pagination.searchParams, {
|
|
3385
|
+
currentName: pagination.currentName,
|
|
3386
|
+
pageSizeName: pagination.pageSizeName
|
|
3387
|
+
}) : {}),
|
|
3388
|
+
urlPagination = _useState2[0];
|
|
3389
|
+
const _useState3 = react.useState(() => {
|
|
3390
|
+
var _ref3, _urlPagination$pageSi;
|
|
3391
|
+
return (_ref3 = (_urlPagination$pageSi = urlPagination.pageSize) != null ? _urlPagination$pageSi : cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3392
|
+
}),
|
|
3393
|
+
pageSize = _useState3[0],
|
|
3394
|
+
setPageSize = _useState3[1];
|
|
3395
|
+
const _useState4 = react.useState(() => {
|
|
3396
|
+
if (urlPagination.current != null) {
|
|
3397
|
+
return urlPagination.current;
|
|
3398
|
+
}
|
|
3399
|
+
const fromProps = Number(get__default["default"](props[pagination.paramsType], pagination.currentName));
|
|
3400
|
+
return Number.isFinite(fromProps) && fromProps > 0 ? fromProps : 1;
|
|
3191
3401
|
}),
|
|
3192
|
-
|
|
3193
|
-
|
|
3402
|
+
initialCurrent = _useState4[0];
|
|
3403
|
+
const _useState5 = react.useState(() => parseSearchParamsValue(filterProp == null ? void 0 : filterProp.searchParamsValue)),
|
|
3404
|
+
searchParamsSnapshot = _useState5[0];
|
|
3405
|
+
const fromUrl = searchParamsSnapshot.items,
|
|
3406
|
+
consumedKeys = searchParamsSnapshot.consumedKeys;
|
|
3407
|
+
const filter = react.useMemo(() => {
|
|
3408
|
+
if (!filterProp) {
|
|
3409
|
+
return filterProp;
|
|
3410
|
+
}
|
|
3411
|
+
const rest = _objectWithoutPropertiesLoose(filterProp, _excluded3);
|
|
3412
|
+
if ('value' in filterProp) {
|
|
3413
|
+
return rest;
|
|
3414
|
+
}
|
|
3415
|
+
return Object.assign({}, rest, {
|
|
3416
|
+
defaultValue: mergeFilterByName(filterProp.defaultValue || [], fromUrl)
|
|
3417
|
+
});
|
|
3418
|
+
}, [filterProp, fromUrl]);
|
|
3194
3419
|
const params = props[pagination.paramsType];
|
|
3195
3420
|
const filterDefaultParams = react.useMemo(() => {
|
|
3196
|
-
|
|
3197
|
-
if (!filter) {
|
|
3421
|
+
var _ref4, _ref5;
|
|
3422
|
+
if (!filterProp && !filter) {
|
|
3198
3423
|
return {};
|
|
3199
3424
|
}
|
|
3200
|
-
const
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3425
|
+
const mapFilterValue = ((_ref4 = filter || filterProp) == null ? void 0 : _ref4.mapFilterValue) || reactFilter.getFilterValue;
|
|
3426
|
+
let initialValue;
|
|
3427
|
+
if (filterProp && 'value' in filterProp) {
|
|
3428
|
+
// 受控:不改 value;首包用 value ∪ fromUrl 作请求种子
|
|
3429
|
+
initialValue = mergeFilterByName(filterProp.value || [], fromUrl);
|
|
3430
|
+
} else {
|
|
3431
|
+
initialValue = resolveInitialFilterValue(filter);
|
|
3432
|
+
}
|
|
3433
|
+
if (!initialValue.length && !((_ref5 = filter || filterProp) != null && _ref5.mapFilterValue)) {
|
|
3204
3434
|
return {};
|
|
3205
3435
|
}
|
|
3206
3436
|
return mapFilterValue(initialValue);
|
|
3207
|
-
}, [
|
|
3437
|
+
}, [filter, filterProp, fromUrl]);
|
|
3438
|
+
const urlStrippedRef = react.useRef(false);
|
|
3439
|
+
react.useEffect(() => {
|
|
3440
|
+
var _filterProp$searchPar, _filterProp$searchPar2;
|
|
3441
|
+
if (urlStrippedRef.current) {
|
|
3442
|
+
return;
|
|
3443
|
+
}
|
|
3444
|
+
urlStrippedRef.current = true;
|
|
3445
|
+
const setSearchParams = filterProp == null || (_filterProp$searchPar = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar.setSearchParams;
|
|
3446
|
+
const searchParams = filterProp == null || (_filterProp$searchPar2 = filterProp.searchParamsValue) == null ? void 0 : _filterProp$searchPar2.searchParams;
|
|
3447
|
+
if (typeof setSearchParams !== 'function') {
|
|
3448
|
+
return;
|
|
3449
|
+
}
|
|
3450
|
+
const nextParams = stripConsumedUrlParams(searchParams, consumedKeys);
|
|
3451
|
+
if (nextParams) {
|
|
3452
|
+
setSearchParams(nextParams, {
|
|
3453
|
+
replace: true
|
|
3454
|
+
});
|
|
3455
|
+
}
|
|
3456
|
+
}, [filterProp, consumedKeys]);
|
|
3208
3457
|
const fetchParams = react.useMemo(() => {
|
|
3209
3458
|
return {
|
|
3210
|
-
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, {
|
|
3459
|
+
[pagination.paramsType]: Object.assign({}, params, filterDefaultParams, _extends({}, paginationUrlEnabled ? {
|
|
3460
|
+
[pagination.currentName]: initialCurrent
|
|
3461
|
+
} : null, {
|
|
3211
3462
|
[pagination.pageSizeName]: pageSize
|
|
3212
|
-
})
|
|
3463
|
+
}))
|
|
3213
3464
|
};
|
|
3214
|
-
}, [params, pagination.pageSizeName, pagination.paramsType, pageSize, filterDefaultParams]);
|
|
3465
|
+
}, [params, pagination.pageSizeName, pagination.paramsType, pagination.currentName, pageSize, filterDefaultParams, paginationUrlEnabled, initialCurrent]);
|
|
3215
3466
|
return /*#__PURE__*/jsxRuntime.jsx(TablePageInner, _extends({}, props, fetchParams, {
|
|
3467
|
+
filter: filter,
|
|
3216
3468
|
horizontalScroller: horizontalScroller,
|
|
3217
3469
|
getScrollContainer: getScrollContainer,
|
|
3218
3470
|
pagination: Object.assign({}, pagination, {
|