@kne/table-page 0.1.23 → 0.1.25
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 +22 -2
- package/dist/index.css +121 -65
- package/dist/index.css.map +1 -1
- package/dist/index.js +446 -461
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +382 -413
- package/dist/index.modern.js.map +1 -1
- package/dist/locale/en-US.js +1 -2
- package/dist/locale/en-US.js.map +1 -1
- package/dist/locale/en-US.modern.js +1 -2
- package/dist/locale/en-US.modern.js.map +1 -1
- package/dist/locale/zh-CN.js +1 -2
- package/dist/locale/zh-CN.js.map +1 -1
- package/dist/locale/zh-CN.modern.js +1 -2
- package/dist/locale/zh-CN.modern.js.map +1 -1
- package/package.json +5 -4
package/dist/index.modern.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '@kne/table-view/dist/index.css';
|
|
2
2
|
import '@kne/scroll-loader/dist/index.css';
|
|
3
3
|
import { withFetch } from '@kne/react-fetch';
|
|
4
|
-
import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Radio, Tabs, Dropdown, Segmented, Pagination } from 'antd';
|
|
5
|
-
import { HolderOutlined, RedoOutlined, SettingOutlined, LoadingOutlined, CaretRightOutlined, DownOutlined,
|
|
4
|
+
import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Radio, Tabs, Dropdown, Segmented, Pagination, Spin, Skeleton } from 'antd';
|
|
5
|
+
import { HolderOutlined, RedoOutlined, SettingOutlined, LoadingOutlined, CaretRightOutlined, DownOutlined, MinusSquareOutlined, TableOutlined, AppstoreOutlined } from '@ant-design/icons';
|
|
6
6
|
import { SearchInput, FilterLines, FilterOuter, FilterValueDisplay, getFilterValue } from '@kne/react-filter';
|
|
7
7
|
import ScrollLoader from '@kne/scroll-loader';
|
|
8
8
|
import { useState, useMemo, useRef, useCallback, useEffect, useLayoutEffect, forwardRef } from 'react';
|
|
@@ -25,8 +25,9 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
25
25
|
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
26
26
|
import filterZhCN from '@kne/react-filter/dist/locale/zh-CN';
|
|
27
27
|
import filterEnUS from '@kne/react-filter/dist/locale/en-US';
|
|
28
|
+
import StickyScroller, { isDocumentScrollContainer, getViewportRect } from '@kne/react-sticky-scroller';
|
|
28
29
|
import useControlValue from '@kne/use-control-value';
|
|
29
|
-
import
|
|
30
|
+
import '@kne/react-sticky-scroller/dist/index.css';
|
|
30
31
|
import '@kne/button-group/dist/index.css';
|
|
31
32
|
import '@kne/react-filter/dist/index.css';
|
|
32
33
|
import ButtonGroup from '@kne/button-group';
|
|
@@ -93,8 +94,7 @@ const locale$1 = {
|
|
|
93
94
|
HiddenInfo: '隐藏的信息',
|
|
94
95
|
Search: '搜索',
|
|
95
96
|
BatchOperations: '批量操作',
|
|
96
|
-
BatchOperationsWithCount: '
|
|
97
|
-
BatchOperationsMobileSelected: '已选:{count}条',
|
|
97
|
+
BatchOperationsWithCount: '已选:{count}条',
|
|
98
98
|
Cancel: '取消',
|
|
99
99
|
Confirm: '确定',
|
|
100
100
|
All: '全部',
|
|
@@ -112,8 +112,7 @@ const locale = {
|
|
|
112
112
|
HiddenInfo: 'Hidden Columns',
|
|
113
113
|
Search: 'Search',
|
|
114
114
|
BatchOperations: 'Batch Actions',
|
|
115
|
-
BatchOperationsWithCount: '
|
|
116
|
-
BatchOperationsMobileSelected: 'Selected: {count}',
|
|
115
|
+
BatchOperationsWithCount: 'Selected: {count}',
|
|
117
116
|
Cancel: 'Cancel',
|
|
118
117
|
Confirm: 'Confirm',
|
|
119
118
|
All: 'All',
|
|
@@ -773,9 +772,6 @@ const parsePixelValue = value => {
|
|
|
773
772
|
const num = parseFloat(value);
|
|
774
773
|
return Number.isNaN(num) ? 0 : num;
|
|
775
774
|
};
|
|
776
|
-
const isDocumentScrollContainer = container => {
|
|
777
|
-
return !container || container === document.body || container === document.documentElement || container === document.scrollingElement;
|
|
778
|
-
};
|
|
779
775
|
const normalizeScrollTopInsetCSSValue = value => {
|
|
780
776
|
if (value == null) {
|
|
781
777
|
return undefined;
|
|
@@ -809,25 +805,6 @@ const readScrollTopInsetPixels = element => {
|
|
|
809
805
|
const fromVar = readCssVariableLength(element, '--scroll-top-inset', '0px') || readCssVariableLength(element, '--sticky-offset', '0px') || readCssVariableLength(element, '--nav-height', '0px');
|
|
810
806
|
return fromVar;
|
|
811
807
|
};
|
|
812
|
-
const getViewportRect = () => {
|
|
813
|
-
const visualViewport = window.visualViewport;
|
|
814
|
-
if (visualViewport) {
|
|
815
|
-
return {
|
|
816
|
-
top: visualViewport.offsetTop,
|
|
817
|
-
bottom: visualViewport.offsetTop + visualViewport.height,
|
|
818
|
-
left: visualViewport.offsetLeft,
|
|
819
|
-
right: visualViewport.offsetLeft + visualViewport.width,
|
|
820
|
-
height: visualViewport.height
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
return {
|
|
824
|
-
top: 0,
|
|
825
|
-
bottom: window.innerHeight,
|
|
826
|
-
left: 0,
|
|
827
|
-
right: window.innerWidth,
|
|
828
|
-
height: window.innerHeight
|
|
829
|
-
};
|
|
830
|
-
};
|
|
831
808
|
const getTableElement = root => {
|
|
832
809
|
if (!root) {
|
|
833
810
|
return null;
|
|
@@ -919,32 +896,6 @@ const scrollAnchorIntoView = (root, {
|
|
|
919
896
|
});
|
|
920
897
|
});
|
|
921
898
|
};
|
|
922
|
-
const getTableScrollElement = root => {
|
|
923
|
-
if (!root) {
|
|
924
|
-
return null;
|
|
925
|
-
}
|
|
926
|
-
return root.querySelector('.ant-table-body') || root.querySelector('.ant-table-content');
|
|
927
|
-
};
|
|
928
|
-
const getElementViewportState = element => {
|
|
929
|
-
if (!element) {
|
|
930
|
-
return {
|
|
931
|
-
isBottomInViewport: true,
|
|
932
|
-
isPartiallyInViewport: false,
|
|
933
|
-
isTopInViewport: true,
|
|
934
|
-
rect: null,
|
|
935
|
-
viewport: getViewportRect()
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
const rect = element.getBoundingClientRect();
|
|
939
|
-
const viewport = getViewportRect();
|
|
940
|
-
return {
|
|
941
|
-
isBottomInViewport: rect.bottom > viewport.top && rect.bottom <= viewport.bottom,
|
|
942
|
-
isPartiallyInViewport: rect.top < viewport.bottom && rect.bottom > viewport.top,
|
|
943
|
-
isTopInViewport: rect.top >= viewport.top && rect.top < viewport.bottom,
|
|
944
|
-
rect,
|
|
945
|
-
viewport
|
|
946
|
-
};
|
|
947
|
-
};
|
|
948
899
|
const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) => {
|
|
949
900
|
if (!element) {
|
|
950
901
|
return true;
|
|
@@ -956,64 +907,10 @@ const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) =
|
|
|
956
907
|
const _viewportTop = containerRect.top + scrollMarginTop;
|
|
957
908
|
return rect.top >= _viewportTop && rect.top < containerRect.bottom;
|
|
958
909
|
}
|
|
959
|
-
const
|
|
960
|
-
isTopInViewport,
|
|
961
|
-
viewport
|
|
962
|
-
} = getElementViewportState(element);
|
|
963
|
-
if (!rect) {
|
|
964
|
-
return true;
|
|
965
|
-
}
|
|
910
|
+
const viewport = getViewportRect();
|
|
966
911
|
const viewportTop = viewport.top + scrollMarginTop;
|
|
967
912
|
return rect.top >= viewportTop && rect.top < viewport.bottom;
|
|
968
913
|
};
|
|
969
|
-
const shouldShowFloatingScrollbar = (scrollEl, viewportState, getScrollContainer) => {
|
|
970
|
-
if (!scrollEl || scrollEl.scrollWidth <= scrollEl.clientWidth + 1) {
|
|
971
|
-
return false;
|
|
972
|
-
}
|
|
973
|
-
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
974
|
-
if (!isDocumentScrollContainer(explicitContainer)) {
|
|
975
|
-
const rect = scrollEl.getBoundingClientRect();
|
|
976
|
-
const containerRect = explicitContainer.getBoundingClientRect();
|
|
977
|
-
return rect.top < containerRect.bottom && rect.bottom > containerRect.bottom;
|
|
978
|
-
}
|
|
979
|
-
const state = viewportState || getElementViewportState(scrollEl);
|
|
980
|
-
if (!state.isPartiallyInViewport) {
|
|
981
|
-
return false;
|
|
982
|
-
}
|
|
983
|
-
return !state.isBottomInViewport;
|
|
984
|
-
};
|
|
985
|
-
const observeViewportIntersection = (element, onChange) => {
|
|
986
|
-
var _window$visualViewpor, _window$visualViewpor2;
|
|
987
|
-
if (!element) {
|
|
988
|
-
return () => {};
|
|
989
|
-
}
|
|
990
|
-
const notify = entry => {
|
|
991
|
-
onChange(getElementViewportState(element));
|
|
992
|
-
};
|
|
993
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
994
|
-
notify();
|
|
995
|
-
}, {
|
|
996
|
-
root: null,
|
|
997
|
-
threshold: [0, 0.01, 0.25, 0.5, 0.75, 1]
|
|
998
|
-
});
|
|
999
|
-
observer.observe(element);
|
|
1000
|
-
const handleViewportChange = () => {
|
|
1001
|
-
notify();
|
|
1002
|
-
};
|
|
1003
|
-
window.addEventListener('scroll', handleViewportChange, true);
|
|
1004
|
-
window.addEventListener('resize', handleViewportChange);
|
|
1005
|
-
(_window$visualViewpor = window.visualViewport) == null || _window$visualViewpor.addEventListener('resize', handleViewportChange);
|
|
1006
|
-
(_window$visualViewpor2 = window.visualViewport) == null || _window$visualViewpor2.addEventListener('scroll', handleViewportChange);
|
|
1007
|
-
notify();
|
|
1008
|
-
return () => {
|
|
1009
|
-
var _window$visualViewpor3, _window$visualViewpor4;
|
|
1010
|
-
observer.disconnect();
|
|
1011
|
-
window.removeEventListener('scroll', handleViewportChange, true);
|
|
1012
|
-
window.removeEventListener('resize', handleViewportChange);
|
|
1013
|
-
(_window$visualViewpor3 = window.visualViewport) == null || _window$visualViewpor3.removeEventListener('resize', handleViewportChange);
|
|
1014
|
-
(_window$visualViewpor4 = window.visualViewport) == null || _window$visualViewpor4.removeEventListener('scroll', handleViewportChange);
|
|
1015
|
-
};
|
|
1016
|
-
};
|
|
1017
914
|
|
|
1018
915
|
/** 叶子去掉空 children,懒加载节点保留 [],避免 antd 把所有节点当成可展开 */
|
|
1019
916
|
const prepareAntdTreeNodes = (nodes, {
|
|
@@ -1199,7 +1096,8 @@ const wrapColContent = node => /*#__PURE__*/jsx("span", {
|
|
|
1199
1096
|
const Table = p => {
|
|
1200
1097
|
const tableRef = useRef(null);
|
|
1201
1098
|
const tableWidth = useElementWidth(tableRef);
|
|
1202
|
-
|
|
1099
|
+
// controllerOpen 默认 true:需等列宽计算;骨架屏等场景显式 false 时可立即渲染
|
|
1100
|
+
const [isLayout, setIsLayout] = useState(() => p.controllerOpen !== false);
|
|
1203
1101
|
const isMobile = useIsMobile();
|
|
1204
1102
|
const props = Object.assign({}, {
|
|
1205
1103
|
rowKey: 'id',
|
|
@@ -2003,268 +1901,7 @@ Table.useSelectedRow = useSelectedRow;
|
|
|
2003
1901
|
Table.useSort = useSort;
|
|
2004
1902
|
Table.sortDataSource = useSort.sortDataSource;
|
|
2005
1903
|
|
|
2006
|
-
var style$1 = {"table-page":"kne-table-page_ut9rJ","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-
|
|
2007
|
-
|
|
2008
|
-
const BAR_HEIGHT = 15;
|
|
2009
|
-
const THUMB_MARGIN = 2;
|
|
2010
|
-
const computeBarMetrics = (scrollEl, viewportState, getPortalContainer) => {
|
|
2011
|
-
const rect = scrollEl.getBoundingClientRect();
|
|
2012
|
-
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
2013
|
-
const useEmbeddedPlacement = !isDocumentScrollContainer(portalContainer);
|
|
2014
|
-
const trackWidth = rect.width;
|
|
2015
|
-
const thumbWidth = Math.max(trackWidth * scrollEl.clientWidth / scrollEl.scrollWidth - THUMB_MARGIN * 2, 24);
|
|
2016
|
-
const maxThumbOffset = trackWidth - thumbWidth - THUMB_MARGIN * 2;
|
|
2017
|
-
const scrollRatio = scrollEl.scrollWidth > scrollEl.clientWidth ? scrollEl.scrollLeft / (scrollEl.scrollWidth - scrollEl.clientWidth) : 0;
|
|
2018
|
-
const visible = shouldShowFloatingScrollbar(scrollEl, viewportState, getPortalContainer);
|
|
2019
|
-
if (useEmbeddedPlacement) {
|
|
2020
|
-
const containerRect = portalContainer.getBoundingClientRect();
|
|
2021
|
-
return {
|
|
2022
|
-
placement: 'embedded',
|
|
2023
|
-
offsetLeft: Math.round(rect.left - containerRect.left),
|
|
2024
|
-
width: Math.round(trackWidth),
|
|
2025
|
-
thumbWidth,
|
|
2026
|
-
thumbLeft: THUMB_MARGIN + maxThumbOffset * scrollRatio,
|
|
2027
|
-
visible
|
|
2028
|
-
};
|
|
2029
|
-
}
|
|
2030
|
-
const viewport = getViewportRect();
|
|
2031
|
-
return {
|
|
2032
|
-
placement: 'fixed',
|
|
2033
|
-
left: Math.round(rect.left),
|
|
2034
|
-
width: Math.round(trackWidth),
|
|
2035
|
-
bottom: window.innerHeight - viewport.bottom,
|
|
2036
|
-
thumbWidth,
|
|
2037
|
-
thumbLeft: THUMB_MARGIN + maxThumbOffset * scrollRatio,
|
|
2038
|
-
visible
|
|
2039
|
-
};
|
|
2040
|
-
};
|
|
2041
|
-
const metricsEqual = (prev, next) => {
|
|
2042
|
-
if (!prev || !next) {
|
|
2043
|
-
return prev === next;
|
|
2044
|
-
}
|
|
2045
|
-
return prev.placement === next.placement && prev.visible === next.visible && prev.width === next.width && prev.thumbWidth === next.thumbWidth && prev.thumbLeft === next.thumbLeft && (prev.placement === 'embedded' ? prev.offsetLeft === next.offsetLeft : prev.left === next.left && prev.bottom === next.bottom);
|
|
2046
|
-
};
|
|
2047
|
-
const FloatingScrollBar = ({
|
|
2048
|
-
metrics,
|
|
2049
|
-
onThumbDrag,
|
|
2050
|
-
getPortalContainer
|
|
2051
|
-
}) => {
|
|
2052
|
-
const startRef = useRef(0);
|
|
2053
|
-
const [moving, setMoving] = useState(false);
|
|
2054
|
-
const movingRef = useRef(false);
|
|
2055
|
-
const onThumbDragRef = useRef(onThumbDrag);
|
|
2056
|
-
onThumbDragRef.current = onThumbDrag;
|
|
2057
|
-
useEffect(() => {
|
|
2058
|
-
movingRef.current = moving;
|
|
2059
|
-
}, [moving]);
|
|
2060
|
-
useEffect(() => {
|
|
2061
|
-
const moveHandler = event => {
|
|
2062
|
-
if (!movingRef.current) {
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
onThumbDragRef.current(event.clientX - startRef.current);
|
|
2066
|
-
startRef.current = event.clientX;
|
|
2067
|
-
};
|
|
2068
|
-
const upHandler = () => {
|
|
2069
|
-
setMoving(false);
|
|
2070
|
-
};
|
|
2071
|
-
document.addEventListener('mousemove', moveHandler, true);
|
|
2072
|
-
document.addEventListener('mouseup', upHandler, true);
|
|
2073
|
-
return () => {
|
|
2074
|
-
document.removeEventListener('mousemove', moveHandler, true);
|
|
2075
|
-
document.removeEventListener('mouseup', upHandler, true);
|
|
2076
|
-
};
|
|
2077
|
-
}, []);
|
|
2078
|
-
if (!(metrics != null && metrics.visible)) {
|
|
2079
|
-
return null;
|
|
2080
|
-
}
|
|
2081
|
-
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
2082
|
-
const useEmbeddedPlacement = metrics.placement === 'embedded';
|
|
2083
|
-
const portalTarget = useEmbeddedPlacement && portalContainer ? portalContainer : document.body;
|
|
2084
|
-
return /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
|
|
2085
|
-
className: classnames(style$1['floating-scrollbar'], 'table-page-floating-scrollbar', {
|
|
2086
|
-
[style$1['floating-scrollbar-embedded']]: useEmbeddedPlacement
|
|
2087
|
-
}),
|
|
2088
|
-
style: useEmbeddedPlacement ? {
|
|
2089
|
-
marginLeft: metrics.offsetLeft,
|
|
2090
|
-
width: metrics.width,
|
|
2091
|
-
height: BAR_HEIGHT
|
|
2092
|
-
} : {
|
|
2093
|
-
left: metrics.left,
|
|
2094
|
-
width: metrics.width,
|
|
2095
|
-
height: BAR_HEIGHT,
|
|
2096
|
-
bottom: metrics.bottom
|
|
2097
|
-
},
|
|
2098
|
-
children: /*#__PURE__*/jsx("div", {
|
|
2099
|
-
className: classnames(style$1['floating-scrollbar-thumb'], {
|
|
2100
|
-
[style$1['is-moving']]: moving
|
|
2101
|
-
}),
|
|
2102
|
-
style: {
|
|
2103
|
-
width: metrics.thumbWidth,
|
|
2104
|
-
left: metrics.thumbLeft
|
|
2105
|
-
},
|
|
2106
|
-
onMouseDown: event => {
|
|
2107
|
-
event.preventDefault();
|
|
2108
|
-
startRef.current = event.clientX;
|
|
2109
|
-
setMoving(true);
|
|
2110
|
-
}
|
|
2111
|
-
})
|
|
2112
|
-
}), portalTarget);
|
|
2113
|
-
};
|
|
2114
|
-
const HorizontalScroller = /*#__PURE__*/forwardRef(({
|
|
2115
|
-
className,
|
|
2116
|
-
enabled: _enabled = true,
|
|
2117
|
-
getPortalContainer,
|
|
2118
|
-
children
|
|
2119
|
-
}, forwardedRef) => {
|
|
2120
|
-
const [metrics, setMetrics] = useState(null);
|
|
2121
|
-
const containerRef = useRef(null);
|
|
2122
|
-
const scrollElRef = useRef(null);
|
|
2123
|
-
const viewportStateRef = useRef(null);
|
|
2124
|
-
const metricsRef = useRef(null);
|
|
2125
|
-
const setContainerRef = useRefCallback(node => {
|
|
2126
|
-
containerRef.current = node;
|
|
2127
|
-
if (typeof forwardedRef === 'function') {
|
|
2128
|
-
forwardedRef(node);
|
|
2129
|
-
} else if (forwardedRef) {
|
|
2130
|
-
forwardedRef.current = node;
|
|
2131
|
-
}
|
|
2132
|
-
});
|
|
2133
|
-
const updateMetrics = useRefCallback(() => {
|
|
2134
|
-
const scrollEl = scrollElRef.current;
|
|
2135
|
-
if (!scrollEl) {
|
|
2136
|
-
metricsRef.current = null;
|
|
2137
|
-
setMetrics(null);
|
|
2138
|
-
return;
|
|
2139
|
-
}
|
|
2140
|
-
const nextMetrics = computeBarMetrics(scrollEl, viewportStateRef.current, getPortalContainer);
|
|
2141
|
-
if (metricsEqual(metricsRef.current, nextMetrics)) {
|
|
2142
|
-
return;
|
|
2143
|
-
}
|
|
2144
|
-
metricsRef.current = nextMetrics;
|
|
2145
|
-
setMetrics(nextMetrics);
|
|
2146
|
-
});
|
|
2147
|
-
const handleThumbDrag = useRefCallback(deltaX => {
|
|
2148
|
-
const scrollEl = scrollElRef.current;
|
|
2149
|
-
if (!scrollEl) {
|
|
2150
|
-
return;
|
|
2151
|
-
}
|
|
2152
|
-
const trackWidth = scrollEl.clientWidth;
|
|
2153
|
-
const scrollableWidth = scrollEl.scrollWidth - scrollEl.clientWidth;
|
|
2154
|
-
const thumbWidth = Math.max(trackWidth * scrollEl.clientWidth / scrollEl.scrollWidth - THUMB_MARGIN * 2, 24);
|
|
2155
|
-
const thumbTravel = trackWidth - thumbWidth - THUMB_MARGIN * 2;
|
|
2156
|
-
if (thumbTravel <= 0) {
|
|
2157
|
-
return;
|
|
2158
|
-
}
|
|
2159
|
-
scrollEl.scrollLeft += deltaX / thumbTravel * scrollableWidth;
|
|
2160
|
-
updateMetrics();
|
|
2161
|
-
});
|
|
2162
|
-
useEffect(() => {
|
|
2163
|
-
if (!_enabled) {
|
|
2164
|
-
scrollElRef.current = null;
|
|
2165
|
-
viewportStateRef.current = null;
|
|
2166
|
-
metricsRef.current = null;
|
|
2167
|
-
setMetrics(null);
|
|
2168
|
-
return undefined;
|
|
2169
|
-
}
|
|
2170
|
-
const root = containerRef.current;
|
|
2171
|
-
if (!root) {
|
|
2172
|
-
return undefined;
|
|
2173
|
-
}
|
|
2174
|
-
let scrollEl = null;
|
|
2175
|
-
let unobserveViewport = null;
|
|
2176
|
-
let contentResizeObserver = null;
|
|
2177
|
-
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
2178
|
-
const useEmbeddedPlacement = !isDocumentScrollContainer(portalContainer);
|
|
2179
|
-
const detachScrollEl = () => {
|
|
2180
|
-
var _contentResizeObserve;
|
|
2181
|
-
unobserveViewport == null || unobserveViewport();
|
|
2182
|
-
unobserveViewport = null;
|
|
2183
|
-
if (!scrollEl) {
|
|
2184
|
-
return;
|
|
2185
|
-
}
|
|
2186
|
-
scrollEl.removeEventListener('scroll', updateMetrics);
|
|
2187
|
-
(_contentResizeObserve = contentResizeObserver) == null || _contentResizeObserve.disconnect();
|
|
2188
|
-
contentResizeObserver = null;
|
|
2189
|
-
scrollElRef.current = null;
|
|
2190
|
-
viewportStateRef.current = null;
|
|
2191
|
-
scrollEl = null;
|
|
2192
|
-
};
|
|
2193
|
-
const attachScrollEl = nextScrollEl => {
|
|
2194
|
-
if (!nextScrollEl || nextScrollEl === scrollEl) {
|
|
2195
|
-
return;
|
|
2196
|
-
}
|
|
2197
|
-
detachScrollEl();
|
|
2198
|
-
scrollEl = nextScrollEl;
|
|
2199
|
-
scrollElRef.current = scrollEl;
|
|
2200
|
-
if (!useEmbeddedPlacement) {
|
|
2201
|
-
unobserveViewport = observeViewportIntersection(scrollEl, state => {
|
|
2202
|
-
viewportStateRef.current = state;
|
|
2203
|
-
updateMetrics();
|
|
2204
|
-
});
|
|
2205
|
-
}
|
|
2206
|
-
scrollEl.addEventListener('scroll', updateMetrics, {
|
|
2207
|
-
passive: true
|
|
2208
|
-
});
|
|
2209
|
-
contentResizeObserver = new ResizeObserver(updateMetrics);
|
|
2210
|
-
contentResizeObserver.observe(scrollEl);
|
|
2211
|
-
Array.from(scrollEl.children).forEach(child => {
|
|
2212
|
-
contentResizeObserver.observe(child);
|
|
2213
|
-
});
|
|
2214
|
-
};
|
|
2215
|
-
const onLayoutChange = () => {
|
|
2216
|
-
attachScrollEl(getTableScrollElement(root));
|
|
2217
|
-
updateMetrics();
|
|
2218
|
-
};
|
|
2219
|
-
const containerResizeObserver = new ResizeObserver(onLayoutChange);
|
|
2220
|
-
containerResizeObserver.observe(root);
|
|
2221
|
-
onLayoutChange();
|
|
2222
|
-
const onWindowChange = () => {
|
|
2223
|
-
if (!useEmbeddedPlacement) {
|
|
2224
|
-
updateMetrics();
|
|
2225
|
-
}
|
|
2226
|
-
};
|
|
2227
|
-
if (!useEmbeddedPlacement) {
|
|
2228
|
-
var _window$visualViewpor, _window$visualViewpor2;
|
|
2229
|
-
window.addEventListener('scroll', onWindowChange, true);
|
|
2230
|
-
window.addEventListener('resize', onWindowChange);
|
|
2231
|
-
(_window$visualViewpor = window.visualViewport) == null || _window$visualViewpor.addEventListener('resize', onWindowChange);
|
|
2232
|
-
(_window$visualViewpor2 = window.visualViewport) == null || _window$visualViewpor2.addEventListener('scroll', onWindowChange);
|
|
2233
|
-
}
|
|
2234
|
-
if (useEmbeddedPlacement && portalContainer) {
|
|
2235
|
-
portalContainer.addEventListener('scroll', updateMetrics, {
|
|
2236
|
-
passive: true
|
|
2237
|
-
});
|
|
2238
|
-
window.addEventListener('resize', updateMetrics);
|
|
2239
|
-
}
|
|
2240
|
-
return () => {
|
|
2241
|
-
detachScrollEl();
|
|
2242
|
-
containerResizeObserver.disconnect();
|
|
2243
|
-
if (!useEmbeddedPlacement) {
|
|
2244
|
-
var _window$visualViewpor3, _window$visualViewpor4;
|
|
2245
|
-
window.removeEventListener('scroll', onWindowChange, true);
|
|
2246
|
-
window.removeEventListener('resize', onWindowChange);
|
|
2247
|
-
(_window$visualViewpor3 = window.visualViewport) == null || _window$visualViewpor3.removeEventListener('resize', onWindowChange);
|
|
2248
|
-
(_window$visualViewpor4 = window.visualViewport) == null || _window$visualViewpor4.removeEventListener('scroll', onWindowChange);
|
|
2249
|
-
}
|
|
2250
|
-
if (useEmbeddedPlacement && portalContainer) {
|
|
2251
|
-
portalContainer.removeEventListener('scroll', updateMetrics);
|
|
2252
|
-
window.removeEventListener('resize', updateMetrics);
|
|
2253
|
-
}
|
|
2254
|
-
};
|
|
2255
|
-
}, [_enabled, updateMetrics, getPortalContainer]);
|
|
2256
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
2257
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
2258
|
-
ref: setContainerRef,
|
|
2259
|
-
className: className,
|
|
2260
|
-
children: children
|
|
2261
|
-
}), _enabled ? /*#__PURE__*/jsx(FloatingScrollBar, {
|
|
2262
|
-
metrics: metrics,
|
|
2263
|
-
onThumbDrag: handleThumbDrag,
|
|
2264
|
-
getPortalContainer: getPortalContainer
|
|
2265
|
-
}) : null]
|
|
2266
|
-
});
|
|
2267
|
-
});
|
|
1904
|
+
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"};
|
|
2268
1905
|
|
|
2269
1906
|
const _excluded$2 = ["size", "moreType", "showLength", "list", "getPopupContainer"];
|
|
2270
1907
|
const hasButtonGroupList = buttonGroup => Array.isArray(buttonGroup == null ? void 0 : buttonGroup.list) && buttonGroup.list.length > 0;
|
|
@@ -2322,7 +1959,7 @@ const resolveToolbarButtonGroupProps = (buttonGroup, getPopupContainer) => {
|
|
|
2322
1959
|
});
|
|
2323
1960
|
};
|
|
2324
1961
|
|
|
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-
|
|
1962
|
+
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","is-mobile":"kne-table-page_n9eAS","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-row":"kne-table-page_zuGJv","table-toolbar-search-input":"kne-table-page_t60hK","table-page-tabs":"kne-table-page_UTy3R","is-mobile-render":"kne-table-page_J-AEV","table-toolbar-mobile-actions":"kne-table-page_I--A1","has-mobile-search":"kne-table-page_14SJt","has-mobile-search-only":"kne-table-page_Y5IR1","has-tabs":"kne-table-page_EImBh","table-toolbar-mobile-filter-row":"kne-table-page_Qo5Zl","table-toolbar-filter":"kne-table-page_Jyfm7","table-toolbar-filter-inner":"kne-table-page_AX3aK","table-toolbar-divider":"kne-table-page_z--2N","table-toolbar-filter-outer":"kne-table-page_PiWGM"};
|
|
2326
1963
|
|
|
2327
1964
|
const _excluded$1 = ["getPopupContainer"],
|
|
2328
1965
|
_excluded2$1 = ["list", "displayLine", "extraExpand", "className", "searchParamsValue", "mapFilterValue", "value", "defaultValue", "onChange"],
|
|
@@ -2413,7 +2050,6 @@ const BatchActions = ({
|
|
|
2413
2050
|
const {
|
|
2414
2051
|
formatMessage
|
|
2415
2052
|
} = useIntl();
|
|
2416
|
-
const isMobile = useIsMobile();
|
|
2417
2053
|
const getPopupContainer = usePopupContainer();
|
|
2418
2054
|
const selectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || [];
|
|
2419
2055
|
const hasSelection = selectedRowKeys.length > 0;
|
|
@@ -2451,11 +2087,7 @@ const BatchActions = ({
|
|
|
2451
2087
|
if (batchMenuItems.length === 0) {
|
|
2452
2088
|
return null;
|
|
2453
2089
|
}
|
|
2454
|
-
const batchButtonLabel = hasSelection ?
|
|
2455
|
-
id: 'BatchOperationsMobileSelected'
|
|
2456
|
-
}, {
|
|
2457
|
-
count: selectedRowKeys.length
|
|
2458
|
-
}) : formatMessage({
|
|
2090
|
+
const batchButtonLabel = hasSelection ? formatMessage({
|
|
2459
2091
|
id: 'BatchOperationsWithCount'
|
|
2460
2092
|
}, {
|
|
2461
2093
|
count: selectedRowKeys.length
|
|
@@ -2478,9 +2110,8 @@ const BatchActions = ({
|
|
|
2478
2110
|
children: [batchButtonLabel, /*#__PURE__*/jsx(DownOutlined, {})]
|
|
2479
2111
|
})
|
|
2480
2112
|
}), hasSelection ? /*#__PURE__*/jsx(Button, {
|
|
2481
|
-
danger: true,
|
|
2482
2113
|
size: "small",
|
|
2483
|
-
icon: /*#__PURE__*/jsx(
|
|
2114
|
+
icon: /*#__PURE__*/jsx(MinusSquareOutlined, {}),
|
|
2484
2115
|
title: formatMessage({
|
|
2485
2116
|
id: 'Cancel'
|
|
2486
2117
|
}),
|
|
@@ -2541,11 +2172,18 @@ const TableToolbar = ({
|
|
|
2541
2172
|
} = _ref3,
|
|
2542
2173
|
searchRest = _objectWithoutPropertiesLoose(_ref3, _excluded3$1);
|
|
2543
2174
|
|
|
2544
|
-
// tab 已有选中态展示,已选筛选标签中不再重复显示 tab
|
|
2545
|
-
const displayFilterValue = hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || []
|
|
2175
|
+
// tab 已有选中态展示,已选筛选标签中不再重复显示 tab 的值;多选清空后的 { value: [] } 也不展示
|
|
2176
|
+
const displayFilterValue = (hasTab ? (filterValue || []).filter(item => (item == null ? void 0 : item.name) !== tab.name) : filterValue || []).filter(item => {
|
|
2177
|
+
const v = item == null ? void 0 : item.value;
|
|
2178
|
+
if (v === null || v === undefined) return false;
|
|
2179
|
+
if (typeof v === 'string' && v.trim() === '') return false;
|
|
2180
|
+
if (Array.isArray(v) && v.length === 0) return false;
|
|
2181
|
+
return true;
|
|
2182
|
+
});
|
|
2546
2183
|
const handleValueDisplayChange = next => {
|
|
2547
2184
|
const tabEntry = hasTab ? (filterValue || []).find(item => (item == null ? void 0 : item.name) === tab.name) : null;
|
|
2548
|
-
|
|
2185
|
+
const payload = tabEntry ? [...(next || []), tabEntry] : next;
|
|
2186
|
+
onFilterChange(payload);
|
|
2549
2187
|
};
|
|
2550
2188
|
const hasValueDisplay = displayFilterValue.length > 0;
|
|
2551
2189
|
const showMobileSearchRow = isMobile && showSearch;
|
|
@@ -2822,9 +2460,228 @@ const isPaginationSearchParamsEnabled = pagination => {
|
|
|
2822
2460
|
return !!(pagination != null && pagination.searchParams && typeof pagination.setSearchParams === 'function');
|
|
2823
2461
|
};
|
|
2824
2462
|
|
|
2825
|
-
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"],
|
|
2826
|
-
_excluded2 = ["
|
|
2827
|
-
_excluded3 = ["
|
|
2463
|
+
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", "filterSeedParams"],
|
|
2464
|
+
_excluded2 = ["loading"],
|
|
2465
|
+
_excluded3 = ["pagination", "horizontalScroller", "getScrollContainer", "filter"],
|
|
2466
|
+
_excluded4 = ["searchParamsValue"];
|
|
2467
|
+
const noop = () => {};
|
|
2468
|
+
const SKELETON_ROW_COUNT = 8;
|
|
2469
|
+
const FALLBACK_SKELETON_COLUMNS = 5;
|
|
2470
|
+
|
|
2471
|
+
/** 是否存在工具栏 / Filter 区域(首屏 loading 需占位保高) */
|
|
2472
|
+
const hasToolbarArea = ({
|
|
2473
|
+
filter,
|
|
2474
|
+
search,
|
|
2475
|
+
tab,
|
|
2476
|
+
batchActions,
|
|
2477
|
+
buttonGroup,
|
|
2478
|
+
renderCard,
|
|
2479
|
+
forceCard
|
|
2480
|
+
}, isMobile) => {
|
|
2481
|
+
var _filter$list;
|
|
2482
|
+
const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
2483
|
+
const hasFilter = !!((filter == null || (_filter$list = filter.list) == null ? void 0 : _filter$list.length) > 0);
|
|
2484
|
+
const hasSearch = !!(search && search.name);
|
|
2485
|
+
const hasBatch = Array.isArray(batchActions) && batchActions.length > 0;
|
|
2486
|
+
const hasBtn = hasButtonGroupList(buttonGroup);
|
|
2487
|
+
const hasCardToggle = !isMobile && resolveRenderCard(renderCard) != null && !forceCard;
|
|
2488
|
+
return hasTab || hasFilter || hasSearch || hasBatch || hasBtn || hasCardToggle;
|
|
2489
|
+
};
|
|
2490
|
+
const flattenLeafColumns = (columns, output = []) => {
|
|
2491
|
+
(columns || []).forEach(column => {
|
|
2492
|
+
if (Array.isArray(column == null ? void 0 : column.children) && column.children.length > 0) {
|
|
2493
|
+
flattenLeafColumns(column.children, output);
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
output.push(column);
|
|
2497
|
+
});
|
|
2498
|
+
return output;
|
|
2499
|
+
};
|
|
2500
|
+
|
|
2501
|
+
/** 首包无 data 时尽量解析列配置;失败则用占位列 */
|
|
2502
|
+
const resolveLoadingColumns = (columns, getColumns) => {
|
|
2503
|
+
try {
|
|
2504
|
+
const raw = typeof getColumns === 'function' ? getColumns(null) : typeof columns === 'function' ? columns(null) : columns;
|
|
2505
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
2506
|
+
return null;
|
|
2507
|
+
}
|
|
2508
|
+
return flattenLeafColumns(resolveColumns(raw));
|
|
2509
|
+
} catch (e) {
|
|
2510
|
+
return null;
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
const CellSkeleton = () => /*#__PURE__*/jsx(Skeleton.Button, {
|
|
2514
|
+
active: true,
|
|
2515
|
+
size: "small",
|
|
2516
|
+
className: style$1['table-cell-skeleton'],
|
|
2517
|
+
style: {
|
|
2518
|
+
width: '70%'
|
|
2519
|
+
}
|
|
2520
|
+
});
|
|
2521
|
+
|
|
2522
|
+
/**
|
|
2523
|
+
* 产出 Table / TableView 共用列:
|
|
2524
|
+
* - 用 render 画骨架(不用 placeholder)
|
|
2525
|
+
* - valueIsEmpty 恒 false,避免 TableView removeEmpty 把空列滤掉导致格子空白
|
|
2526
|
+
*/
|
|
2527
|
+
const buildSkeletonTableColumns = leafColumns => {
|
|
2528
|
+
const source = leafColumns && leafColumns.length > 0 ? leafColumns : Array.from({
|
|
2529
|
+
length: FALLBACK_SKELETON_COLUMNS
|
|
2530
|
+
}, (_, index) => ({
|
|
2531
|
+
name: `__skeleton_col_${index}`,
|
|
2532
|
+
title: ' '
|
|
2533
|
+
}));
|
|
2534
|
+
return source.map((column, index) => {
|
|
2535
|
+
var _column$title;
|
|
2536
|
+
return {
|
|
2537
|
+
name: column.name || column.key || `__skeleton_col_${index}`,
|
|
2538
|
+
title: typeof column.title === 'function' ? ' ' : (_column$title = column.title) != null ? _column$title : ' ',
|
|
2539
|
+
width: column.width,
|
|
2540
|
+
min: column.min,
|
|
2541
|
+
max: column.max,
|
|
2542
|
+
fixed: column.fixed,
|
|
2543
|
+
justify: column.justify,
|
|
2544
|
+
align: column.align,
|
|
2545
|
+
span: column.span,
|
|
2546
|
+
valueIsEmpty: () => false,
|
|
2547
|
+
getValueOf: () => '__skeleton__',
|
|
2548
|
+
render: () => /*#__PURE__*/jsx(CellSkeleton, {})
|
|
2549
|
+
};
|
|
2550
|
+
});
|
|
2551
|
+
};
|
|
2552
|
+
const buildSkeletonDataSource = (rowCount = SKELETON_ROW_COUNT) => Array.from({
|
|
2553
|
+
length: rowCount
|
|
2554
|
+
}, (_, index) => ({
|
|
2555
|
+
id: `__skeleton_row_${index}`
|
|
2556
|
+
}));
|
|
2557
|
+
|
|
2558
|
+
/**
|
|
2559
|
+
* withFetch 首包 loading:Toolbar/Filter 占位保高 + Table/TableView 骨架屏 + loading,
|
|
2560
|
+
* 复用正式表格样式,避免全局绝对定位 Spin 把高度塌成 0。
|
|
2561
|
+
*/
|
|
2562
|
+
const TablePageLoadingShell = withLocale(({
|
|
2563
|
+
filter,
|
|
2564
|
+
search,
|
|
2565
|
+
tab,
|
|
2566
|
+
tabProps,
|
|
2567
|
+
batchActions,
|
|
2568
|
+
buttonGroup,
|
|
2569
|
+
rowSelection,
|
|
2570
|
+
selectedRows,
|
|
2571
|
+
renderMobile: _renderMobile = true,
|
|
2572
|
+
renderCard,
|
|
2573
|
+
forceCard: _forceCard = false,
|
|
2574
|
+
columns,
|
|
2575
|
+
getColumns,
|
|
2576
|
+
pagination: _pagination = {},
|
|
2577
|
+
className,
|
|
2578
|
+
size,
|
|
2579
|
+
renderType: _renderType = 'Table'
|
|
2580
|
+
}) => {
|
|
2581
|
+
var _filter$list2;
|
|
2582
|
+
const isMobile = useIsMobile();
|
|
2583
|
+
const isMobileRenderActive = isRenderMobileActive(_renderMobile, isMobile);
|
|
2584
|
+
const showButtonGroup = hasButtonGroupList(buttonGroup);
|
|
2585
|
+
const resolvedRenderCard = resolveRenderCard(renderCard);
|
|
2586
|
+
const showCardModeToggle = resolvedRenderCard != null && !isMobile && !_forceCard;
|
|
2587
|
+
const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
2588
|
+
const hasInnerToolbar = !!(filter != null && (_filter$list2 = filter.list) != null && _filter$list2.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
|
|
2589
|
+
const showOuterTab = hasTab && !isMobile;
|
|
2590
|
+
const showInnerTab = hasTab && isMobile;
|
|
2591
|
+
const wrapWithToolbar = hasInnerToolbar || showInnerTab;
|
|
2592
|
+
const filterValue = resolveInitialFilterValue(filter);
|
|
2593
|
+
const SkeletonTableComponent = TABLE_COMPONENTS[_renderType] || Table;
|
|
2594
|
+
const useAntdTable = SkeletonTableComponent === Table;
|
|
2595
|
+
const skeletonRowCount = Math.min(Math.max(Number(_pagination.pageSize) || SKELETON_ROW_COUNT, 3), SKELETON_ROW_COUNT);
|
|
2596
|
+
const skeletonColumns = useMemo(() => buildSkeletonTableColumns(resolveLoadingColumns(columns, getColumns)), [columns, getColumns]);
|
|
2597
|
+
const skeletonDataSource = useMemo(() => buildSkeletonDataSource(skeletonRowCount), [skeletonRowCount]);
|
|
2598
|
+
// 与正式表一致保留选择列占位(含表头全选/隐藏 checkbox 宽度);禁用交互
|
|
2599
|
+
const skeletonRowSelection = useMemo(() => {
|
|
2600
|
+
if (!rowSelection) {
|
|
2601
|
+
return undefined;
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
type: rowSelection.type === 'radio' ? 'radio' : 'checkbox',
|
|
2605
|
+
allowSelectedAll: rowSelection.allowSelectedAll,
|
|
2606
|
+
selectedRowKeys: [],
|
|
2607
|
+
onChange: noop,
|
|
2608
|
+
getCheckboxProps: () => ({
|
|
2609
|
+
disabled: true
|
|
2610
|
+
})
|
|
2611
|
+
};
|
|
2612
|
+
}, [rowSelection]);
|
|
2613
|
+
const cardModeToggleNode = showCardModeToggle ? /*#__PURE__*/jsx(Segmented, {
|
|
2614
|
+
className: style$1['card-mode-toggle'],
|
|
2615
|
+
size: "small",
|
|
2616
|
+
value: "table",
|
|
2617
|
+
options: [{
|
|
2618
|
+
value: 'table',
|
|
2619
|
+
icon: /*#__PURE__*/jsx(TableOutlined, {})
|
|
2620
|
+
}, {
|
|
2621
|
+
value: 'card',
|
|
2622
|
+
icon: /*#__PURE__*/jsx(AppstoreOutlined, {})
|
|
2623
|
+
}]
|
|
2624
|
+
}) : null;
|
|
2625
|
+
|
|
2626
|
+
// renderType=TableView 时骨架也用 TableView;桌面端 Table 可透传 loading,其余外层 Spin
|
|
2627
|
+
const showOuterSpin = isMobileRenderActive || !useAntdTable;
|
|
2628
|
+
const tableSkeleton = /*#__PURE__*/jsx(SkeletonTableComponent, _extends({
|
|
2629
|
+
className: classnames({
|
|
2630
|
+
[style$1['table-in-toolbar']]: wrapWithToolbar
|
|
2631
|
+
}, className),
|
|
2632
|
+
columns: skeletonColumns,
|
|
2633
|
+
dataSource: skeletonDataSource,
|
|
2634
|
+
rowSelection: skeletonRowSelection
|
|
2635
|
+
}, useAntdTable ? {
|
|
2636
|
+
loading: !showOuterSpin,
|
|
2637
|
+
controllerOpen: false,
|
|
2638
|
+
pagination: false
|
|
2639
|
+
} : null, {
|
|
2640
|
+
rowKey: "id",
|
|
2641
|
+
size: size,
|
|
2642
|
+
renderMobile: _renderMobile,
|
|
2643
|
+
empty: null
|
|
2644
|
+
}), `skeleton-${_renderType}`);
|
|
2645
|
+
const skeletonNode = showOuterSpin ? /*#__PURE__*/jsx(Spin, {
|
|
2646
|
+
spinning: true,
|
|
2647
|
+
className: style$1['table-skeleton-spin'],
|
|
2648
|
+
children: tableSkeleton
|
|
2649
|
+
}) : tableSkeleton;
|
|
2650
|
+
const toolbarNode = wrapWithToolbar ? /*#__PURE__*/jsx(TableToolbar, {
|
|
2651
|
+
filterValue: filterValue,
|
|
2652
|
+
onFilterChange: noop,
|
|
2653
|
+
filter: filter,
|
|
2654
|
+
search: search,
|
|
2655
|
+
tab: tab,
|
|
2656
|
+
tabProps: tabProps,
|
|
2657
|
+
renderTab: showInnerTab,
|
|
2658
|
+
batchActions: batchActions,
|
|
2659
|
+
buttonGroup: buttonGroup,
|
|
2660
|
+
rowSelection: rowSelection,
|
|
2661
|
+
selectedRows: selectedRows,
|
|
2662
|
+
isMobileRender: isMobileRenderActive,
|
|
2663
|
+
cardModeToggle: cardModeToggleNode
|
|
2664
|
+
}) : null;
|
|
2665
|
+
return /*#__PURE__*/jsx("div", {
|
|
2666
|
+
className: style$1['table-page'],
|
|
2667
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
2668
|
+
className: style$1['table-content'],
|
|
2669
|
+
children: [showOuterTab ? /*#__PURE__*/jsx(TablePageTabs, {
|
|
2670
|
+
filterValue: filterValue,
|
|
2671
|
+
onFilterChange: noop,
|
|
2672
|
+
tab: tab,
|
|
2673
|
+
tabProps: tabProps,
|
|
2674
|
+
className: style$1['table-page-tabs-outer'],
|
|
2675
|
+
isMobileRender: isMobileRenderActive
|
|
2676
|
+
}) : null, wrapWithToolbar ? /*#__PURE__*/jsxs("div", {
|
|
2677
|
+
className: classnames(style$1['table-with-toolbar'], style$1['is-loading-shell'], {
|
|
2678
|
+
[style$1['is-mobile-render']]: isMobileRenderActive
|
|
2679
|
+
}),
|
|
2680
|
+
children: [toolbarNode, skeletonNode]
|
|
2681
|
+
}) : skeletonNode]
|
|
2682
|
+
})
|
|
2683
|
+
});
|
|
2684
|
+
});
|
|
2828
2685
|
const defaultMergeList = (data, newData) => {
|
|
2829
2686
|
return Object.assign({}, newData, {
|
|
2830
2687
|
pageData: [...((data == null ? void 0 : data.pageData) || []), ...((newData == null ? void 0 : newData.pageData) || [])]
|
|
@@ -2902,7 +2759,13 @@ const collectFilterFieldNames = (filter, search, tab) => {
|
|
|
2902
2759
|
}
|
|
2903
2760
|
if (Array.isArray(filter == null ? void 0 : filter.list)) {
|
|
2904
2761
|
filter.list.forEach(row => {
|
|
2762
|
+
// 兼容扁平 list:[{ type, props }];以及分组 list:[[item, item]]
|
|
2905
2763
|
if (!Array.isArray(row)) {
|
|
2764
|
+
var _row$props;
|
|
2765
|
+
const name = row == null || (_row$props = row.props) == null ? void 0 : _row$props.name;
|
|
2766
|
+
if (name) {
|
|
2767
|
+
names.add(name);
|
|
2768
|
+
}
|
|
2906
2769
|
return;
|
|
2907
2770
|
}
|
|
2908
2771
|
row.forEach(item => {
|
|
@@ -2923,8 +2786,36 @@ const omitFilterParams = (params, filterFieldNames) => {
|
|
|
2923
2786
|
});
|
|
2924
2787
|
return next;
|
|
2925
2788
|
};
|
|
2789
|
+
const isPlainObject = value => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
2790
|
+
|
|
2791
|
+
// lodash.merge 不会删掉「新对象里没有的嵌套 key」,且 [] 合并不了旧数组;清空一律写 null
|
|
2792
|
+
const withNestedClears = (prevParams, nextParams) => {
|
|
2793
|
+
const result = Object.assign({}, nextParams);
|
|
2794
|
+
Object.keys(prevParams || {}).forEach(key => {
|
|
2795
|
+
const prevVal = prevParams[key];
|
|
2796
|
+
const nextVal = nextParams[key];
|
|
2797
|
+
if (!isPlainObject(prevVal)) {
|
|
2798
|
+
return;
|
|
2799
|
+
}
|
|
2800
|
+
if (isPlainObject(nextVal)) {
|
|
2801
|
+
const nested = {};
|
|
2802
|
+
Object.keys(prevVal).forEach(nestedKey => {
|
|
2803
|
+
if (!(nestedKey in nextVal)) {
|
|
2804
|
+
nested[nestedKey] = null;
|
|
2805
|
+
}
|
|
2806
|
+
});
|
|
2807
|
+
result[key] = Object.assign({}, nested, nextVal);
|
|
2808
|
+
return;
|
|
2809
|
+
}
|
|
2810
|
+
if (nextVal === undefined) {
|
|
2811
|
+
// 整个嵌套对象被拿掉时,直接 null 覆盖(比逐字段 { ids: null } 更干净)
|
|
2812
|
+
result[key] = null;
|
|
2813
|
+
}
|
|
2814
|
+
});
|
|
2815
|
+
return result;
|
|
2816
|
+
};
|
|
2926
2817
|
const TablePageInnerContent = withLocale(_ref => {
|
|
2927
|
-
var _filter$
|
|
2818
|
+
var _filter$list3;
|
|
2928
2819
|
let {
|
|
2929
2820
|
data,
|
|
2930
2821
|
refresh,
|
|
@@ -2964,7 +2855,8 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2964
2855
|
renderMobile = true,
|
|
2965
2856
|
renderCard,
|
|
2966
2857
|
forceCard = false,
|
|
2967
|
-
mobileSortToolbar
|
|
2858
|
+
mobileSortToolbar,
|
|
2859
|
+
filterSeedParams = {}
|
|
2968
2860
|
} = _ref,
|
|
2969
2861
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
2970
2862
|
const {
|
|
@@ -2993,7 +2885,63 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
2993
2885
|
});
|
|
2994
2886
|
const filterFieldNames = useMemo(() => collectFilterFieldNames(filter, search, tab), [filter, search, tab]);
|
|
2995
2887
|
const buildRequestParamsWithFilter = useRefCallback((value, extra = {}) => {
|
|
2996
|
-
|
|
2888
|
+
const prevFilterParams = Object.assign({}, getFilterParams(filterValue) || {});
|
|
2889
|
+
let filterParams = Object.assign({}, getFilterParams(value) || {});
|
|
2890
|
+
Object.keys(filterParams).forEach(key => {
|
|
2891
|
+
const v = filterParams[key];
|
|
2892
|
+
if (v === undefined || v === '') {
|
|
2893
|
+
delete filterParams[key];
|
|
2894
|
+
} else if (Array.isArray(v) && v.length === 0) {
|
|
2895
|
+
// lodash.merge 用 [] 合并不掉旧数组,改成 null 才能覆盖
|
|
2896
|
+
filterParams[key] = null;
|
|
2897
|
+
}
|
|
2898
|
+
});
|
|
2899
|
+
// mapFilterValue 常返回 { filter: {...} }:嵌套里被删掉的字段写成 null,否则 lodash.merge 会残留
|
|
2900
|
+
filterParams = withNestedClears(prevFilterParams, filterParams);
|
|
2901
|
+
filterParams = withNestedClears(isPlainObject(get(requestParams, [pagination.paramsType, 'filter'])) ? {
|
|
2902
|
+
filter: get(requestParams, [pagination.paramsType, 'filter'])
|
|
2903
|
+
} : {}, filterParams);
|
|
2904
|
+
const currentParams = get(requestParams, pagination.paramsType) || {};
|
|
2905
|
+
const seedParams = filterSeedParams || {};
|
|
2906
|
+
|
|
2907
|
+
// 待清理 key:配置字段 + 旧筛选 + 首包种子(props.data 里的 filterDefaultParams)
|
|
2908
|
+
// react-fetch 用 lodash.merge:省略字段不会覆盖;[] 也合并不掉旧数组,必须显式传 null
|
|
2909
|
+
const keysToClear = new Set([...filterFieldNames, ...Object.keys(prevFilterParams), ...Object.keys(seedParams)]);
|
|
2910
|
+
Object.keys(filterParams).forEach(key => keysToClear.delete(key));
|
|
2911
|
+
keysToClear.delete(pagination.currentName);
|
|
2912
|
+
keysToClear.delete(pagination.pageSizeName);
|
|
2913
|
+
const cleared = {};
|
|
2914
|
+
keysToClear.forEach(name => {
|
|
2915
|
+
cleared[name] = null;
|
|
2916
|
+
});
|
|
2917
|
+
|
|
2918
|
+
// 旧写法把筛选抬升到 props.params.filter,而 mapFilterValue 仍是扁平字段时:必须清掉嵌套 filter 里的同名字段
|
|
2919
|
+
if (isPlainObject(currentParams.filter) && !isPlainObject(filterParams.filter) && filterParams.filter !== null) {
|
|
2920
|
+
const nested = {};
|
|
2921
|
+
const active = new Set(Object.keys(filterParams));
|
|
2922
|
+
new Set([...Object.keys(currentParams.filter), ...filterFieldNames]).forEach(name => {
|
|
2923
|
+
if (name === pagination.currentName || name === pagination.pageSizeName) {
|
|
2924
|
+
return;
|
|
2925
|
+
}
|
|
2926
|
+
if (!active.has(name)) {
|
|
2927
|
+
nested[name] = null;
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
Object.keys(filterParams).forEach(name => {
|
|
2931
|
+
if (filterFieldNames.has(name) || name in currentParams.filter) {
|
|
2932
|
+
nested[name] = filterParams[name];
|
|
2933
|
+
delete filterParams[name];
|
|
2934
|
+
}
|
|
2935
|
+
});
|
|
2936
|
+
filterParams.filter = nested;
|
|
2937
|
+
}
|
|
2938
|
+
const merged = Object.assign({}, omitFilterParams(currentParams, keysToClear), extra, cleared, filterParams);
|
|
2939
|
+
Object.keys(merged).forEach(key => {
|
|
2940
|
+
if (merged[key] === undefined) {
|
|
2941
|
+
delete merged[key];
|
|
2942
|
+
}
|
|
2943
|
+
});
|
|
2944
|
+
return merged;
|
|
2997
2945
|
});
|
|
2998
2946
|
const formatData = useMemo(() => {
|
|
2999
2947
|
return handlerDataFormat(data);
|
|
@@ -3011,7 +2959,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3011
2959
|
pagination
|
|
3012
2960
|
}), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
|
|
3013
2961
|
const hasTab = !!(tab != null && tab.name && Array.isArray(tab.list) && tab.list.length > 0);
|
|
3014
|
-
const hasInnerToolbar = !!(filter != null && (_filter$
|
|
2962
|
+
const hasInnerToolbar = !!(filter != null && (_filter$list3 = filter.list) != null && _filter$list3.length || search && search.name || batchActions && batchActions.length || showButtonGroup || showCardModeToggle);
|
|
3015
2963
|
const showOuterTab = hasTab && !isMobile;
|
|
3016
2964
|
const showInnerTab = hasTab && isMobile;
|
|
3017
2965
|
const wrapWithToolbar = hasInnerToolbar || showInnerTab;
|
|
@@ -3047,13 +2995,14 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3047
2995
|
});
|
|
3048
2996
|
});
|
|
3049
2997
|
const handleFilterChange = useRefCallback(value => {
|
|
2998
|
+
const nextParams = buildRequestParamsWithFilter(value, {
|
|
2999
|
+
[pagination.currentName]: 1
|
|
3000
|
+
});
|
|
3050
3001
|
setFilterValue(value);
|
|
3051
3002
|
const currentSize = Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 20;
|
|
3052
3003
|
syncPaginationToUrl(1, currentSize);
|
|
3053
3004
|
reload({
|
|
3054
|
-
[pagination.paramsType]:
|
|
3055
|
-
[pagination.currentName]: 1
|
|
3056
|
-
})
|
|
3005
|
+
[pagination.paramsType]: nextParams
|
|
3057
3006
|
});
|
|
3058
3007
|
});
|
|
3059
3008
|
useEffect(() => {
|
|
@@ -3226,7 +3175,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3226
3175
|
setCardMode(next);
|
|
3227
3176
|
}
|
|
3228
3177
|
}) : null;
|
|
3229
|
-
const tableMain = /*#__PURE__*/jsxs(
|
|
3178
|
+
const tableMain = /*#__PURE__*/jsxs(StickyScroller, {
|
|
3230
3179
|
ref: tableContentRef,
|
|
3231
3180
|
enabled: horizontalScroller && renderType === 'Table' && !isCardModeActive,
|
|
3232
3181
|
getPortalContainer: getScrollContainer,
|
|
@@ -3286,7 +3235,32 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3286
3235
|
})
|
|
3287
3236
|
});
|
|
3288
3237
|
});
|
|
3289
|
-
const
|
|
3238
|
+
const TablePageFetched = withFetch(TablePageInnerContent);
|
|
3239
|
+
|
|
3240
|
+
// 首包 / refresh loading:Toolbar 占位 + cell 骨架屏 + Spin;外层 grid 再垫一层,盖住首帧 null
|
|
3241
|
+
const TablePageInner = /*#__PURE__*/forwardRef((props, ref) => {
|
|
3242
|
+
const isMobile = useIsMobile();
|
|
3243
|
+
const {
|
|
3244
|
+
loading: loadingProp
|
|
3245
|
+
} = props,
|
|
3246
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
3247
|
+
const reserveToolbar = hasToolbarArea(props, isMobile);
|
|
3248
|
+
const loading = loadingProp !== undefined ? loadingProp : /*#__PURE__*/jsx(TablePageLoadingShell, _extends({}, props));
|
|
3249
|
+
const fetched = /*#__PURE__*/jsx(TablePageFetched, _extends({}, rest, {
|
|
3250
|
+
loading: loading,
|
|
3251
|
+
ref: ref
|
|
3252
|
+
}));
|
|
3253
|
+
if (!reserveToolbar) {
|
|
3254
|
+
return fetched;
|
|
3255
|
+
}
|
|
3256
|
+
return /*#__PURE__*/jsxs("div", {
|
|
3257
|
+
className: style$1['fetch-stack'],
|
|
3258
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
3259
|
+
className: style$1['toolbar-height-reserve'],
|
|
3260
|
+
"aria-hidden": true
|
|
3261
|
+
}), fetched]
|
|
3262
|
+
});
|
|
3263
|
+
});
|
|
3290
3264
|
const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
3291
3265
|
let {
|
|
3292
3266
|
pagination,
|
|
@@ -3294,7 +3268,7 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3294
3268
|
getScrollContainer,
|
|
3295
3269
|
filter: filterProp
|
|
3296
3270
|
} = _ref2,
|
|
3297
|
-
props = _objectWithoutPropertiesLoose(_ref2,
|
|
3271
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
|
|
3298
3272
|
pagination = Object.assign({}, {
|
|
3299
3273
|
showSizeChanger: true,
|
|
3300
3274
|
showQuickJumper: true,
|
|
@@ -3333,7 +3307,7 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3333
3307
|
if (!filterProp) {
|
|
3334
3308
|
return filterProp;
|
|
3335
3309
|
}
|
|
3336
|
-
const rest = _objectWithoutPropertiesLoose(filterProp,
|
|
3310
|
+
const rest = _objectWithoutPropertiesLoose(filterProp, _excluded4);
|
|
3337
3311
|
if ('value' in filterProp) {
|
|
3338
3312
|
return rest;
|
|
3339
3313
|
}
|
|
@@ -3342,24 +3316,18 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3342
3316
|
});
|
|
3343
3317
|
}, [filterProp, fromUrl]);
|
|
3344
3318
|
const params = props[pagination.paramsType];
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
if (!filterProp
|
|
3319
|
+
// 仅作首包种子;后续筛选走 handleFilterChange → reload,避免受控 value 变化改 requestToken 触发 refresh 卸载表格
|
|
3320
|
+
const [filterDefaultParams] = useState(() => {
|
|
3321
|
+
if (!filterProp) {
|
|
3348
3322
|
return {};
|
|
3349
3323
|
}
|
|
3350
|
-
const
|
|
3351
|
-
|
|
3352
|
-
if (
|
|
3353
|
-
// 受控:不改 value;首包用 value ∪ fromUrl 作请求种子
|
|
3354
|
-
initialValue = mergeFilterByName(filterProp.value || [], fromUrl);
|
|
3355
|
-
} else {
|
|
3356
|
-
initialValue = resolveInitialFilterValue(filter);
|
|
3357
|
-
}
|
|
3358
|
-
if (!initialValue.length && !((_ref5 = filter || filterProp) != null && _ref5.mapFilterValue)) {
|
|
3324
|
+
const mapFn = filterProp.mapFilterValue || getFilterValue;
|
|
3325
|
+
const initialValue = 'value' in filterProp ? mergeFilterByName(filterProp.value || [], fromUrl) : mergeFilterByName(filterProp.defaultValue || [], fromUrl);
|
|
3326
|
+
if (!initialValue.length && !filterProp.mapFilterValue) {
|
|
3359
3327
|
return {};
|
|
3360
3328
|
}
|
|
3361
|
-
return
|
|
3362
|
-
}
|
|
3329
|
+
return mapFn(initialValue) || {};
|
|
3330
|
+
});
|
|
3363
3331
|
const urlStrippedRef = useRef(false);
|
|
3364
3332
|
useEffect(() => {
|
|
3365
3333
|
var _filterProp$searchPar, _filterProp$searchPar2;
|
|
@@ -3390,6 +3358,7 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3390
3358
|
}, [params, pagination.pageSizeName, pagination.paramsType, pagination.currentName, pageSize, filterDefaultParams, paginationUrlEnabled, initialCurrent]);
|
|
3391
3359
|
return /*#__PURE__*/jsx(TablePageInner, _extends({}, props, fetchParams, {
|
|
3392
3360
|
filter: filter,
|
|
3361
|
+
filterSeedParams: filterDefaultParams,
|
|
3393
3362
|
horizontalScroller: horizontalScroller,
|
|
3394
3363
|
getScrollContainer: getScrollContainer,
|
|
3395
3364
|
pagination: Object.assign({}, pagination, {
|