@kne/table-page 0.1.2 → 0.1.4
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 +276 -19
- package/dist/index.css +69 -8
- package/dist/index.css.map +1 -1
- package/dist/index.js +317 -156
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +319 -158
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1081,7 +1081,7 @@ const computeColumnsDisplay = ({
|
|
|
1081
1081
|
computeColumnsValue.computeDisplay = computeDisplay;
|
|
1082
1082
|
computeColumnsValue.computeColumnsDisplay = computeColumnsDisplay;
|
|
1083
1083
|
|
|
1084
|
-
var style$5 = {"table":"kne-table-page_lZgIW","tableView":"kne-table-page_fUw6j","grid":"kne-table-page_JlDmf","header-cell":"kne-table-page_P-ebv","col-content":"kne-table-page_HT5Rr","body-row":"kne-table-page_Z6mVv","
|
|
1084
|
+
var style$5 = {"table":"kne-table-page_lZgIW","header":"kne-table-page_d1qN5","col":"kne-table-page_KNy4z","tableView":"kne-table-page_fUw6j","grid":"kne-table-page_JlDmf","header-cell":"kne-table-page_P-ebv","col-content":"kne-table-page_HT5Rr","body-row":"kne-table-page_Z6mVv","body-cell":"kne-table-page_BSOzz","body":"kne-table-page_9qon1","is-selected-all":"kne-table-page_f2i1e","is-selected":"kne-table-page_n3V6m","is-disabled":"kne-table-page_AfmkR","col-width-based":"kne-table-page_ZvnDi","col-width-fill":"kne-table-page_cV7PE","single-checked":"kne-table-page_9UAoL","col-fixed":"kne-table-page_aB-1c","empty":"kne-table-page_SRI8Q"};
|
|
1085
1085
|
|
|
1086
1086
|
var style$4 = {"table":"kne-table-page_awa1L","is-selected-all":"kne-table-page_692q3","is-selected":"kne-table-page_IWgjl","is-disabled":"kne-table-page_YUG4k","has-summary":"kne-table-page_Cb-du","has-group-header":"kne-table-page_7qTC5","is-sticky":"kne-table-page_jGzIR","is-sticky-scroll-y":"kne-table-page_P6lxG","is-sticky-viewport":"kne-table-page_Kr-p6","table-cell":"kne-table-page_HPmr3","selection-col":"kne-table-page_D7YhS","radio-col":"kne-table-page_df9z3","is-computed":"kne-table-page_ZA1Je","is-resize":"kne-table-page_CA0uL","column-resize-guide":"kne-table-page_JARA2"};
|
|
1087
1087
|
|
|
@@ -2034,7 +2034,253 @@ const getColumnEllipsis = column => {
|
|
|
2034
2034
|
return typeof column.ellipsis === 'object' ? column.ellipsis : true;
|
|
2035
2035
|
};
|
|
2036
2036
|
|
|
2037
|
-
const
|
|
2037
|
+
const parsePixelValue = value => {
|
|
2038
|
+
const num = parseFloat(value);
|
|
2039
|
+
return Number.isNaN(num) ? 0 : num;
|
|
2040
|
+
};
|
|
2041
|
+
const isDocumentScrollContainer = container => {
|
|
2042
|
+
return !container || container === document.body || container === document.documentElement || container === document.scrollingElement;
|
|
2043
|
+
};
|
|
2044
|
+
const normalizeScrollTopInsetCSSValue = value => {
|
|
2045
|
+
if (value == null) {
|
|
2046
|
+
return undefined;
|
|
2047
|
+
}
|
|
2048
|
+
if (typeof value === 'number') {
|
|
2049
|
+
return `${value}px`;
|
|
2050
|
+
}
|
|
2051
|
+
return String(value);
|
|
2052
|
+
};
|
|
2053
|
+
const resolveScrollTopInset = (scrollTopInset, stickyOffset) => scrollTopInset != null ? scrollTopInset : stickyOffset;
|
|
2054
|
+
const parseInsetPixels = (inset, element) => {
|
|
2055
|
+
if (inset == null) {
|
|
2056
|
+
return 0;
|
|
2057
|
+
}
|
|
2058
|
+
if (typeof inset === 'number') {
|
|
2059
|
+
return inset;
|
|
2060
|
+
}
|
|
2061
|
+
if (typeof inset === 'string') {
|
|
2062
|
+
const trimmed = inset.trim();
|
|
2063
|
+
if (trimmed.endsWith('px')) {
|
|
2064
|
+
return parsePixelValue(trimmed);
|
|
2065
|
+
}
|
|
2066
|
+
const variableMatch = trimmed.match(/var\(\s*(--[^,\s)]+)/);
|
|
2067
|
+
if (variableMatch) {
|
|
2068
|
+
return readCssVariableLength(element, variableMatch[1], '0px');
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
return 0;
|
|
2072
|
+
};
|
|
2073
|
+
const readScrollTopInsetPixels = element => {
|
|
2074
|
+
const fromVar = readCssVariableLength(element, '--scroll-top-inset', '0px') || readCssVariableLength(element, '--sticky-offset', '0px') || readCssVariableLength(element, '--nav-height', '0px');
|
|
2075
|
+
return fromVar;
|
|
2076
|
+
};
|
|
2077
|
+
const getViewportRect = () => {
|
|
2078
|
+
const visualViewport = window.visualViewport;
|
|
2079
|
+
if (visualViewport) {
|
|
2080
|
+
return {
|
|
2081
|
+
top: visualViewport.offsetTop,
|
|
2082
|
+
bottom: visualViewport.offsetTop + visualViewport.height,
|
|
2083
|
+
left: visualViewport.offsetLeft,
|
|
2084
|
+
right: visualViewport.offsetLeft + visualViewport.width,
|
|
2085
|
+
height: visualViewport.height
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
return {
|
|
2089
|
+
top: 0,
|
|
2090
|
+
bottom: window.innerHeight,
|
|
2091
|
+
left: 0,
|
|
2092
|
+
right: window.innerWidth,
|
|
2093
|
+
height: window.innerHeight
|
|
2094
|
+
};
|
|
2095
|
+
};
|
|
2096
|
+
const getTableElement = root => {
|
|
2097
|
+
if (!root) {
|
|
2098
|
+
return null;
|
|
2099
|
+
}
|
|
2100
|
+
return root.querySelector('.info-page-table') || root;
|
|
2101
|
+
};
|
|
2102
|
+
const getScrollAnchorElement = (root, {
|
|
2103
|
+
preferToolbar: _preferToolbar = false
|
|
2104
|
+
} = {}) => {
|
|
2105
|
+
if (!root) {
|
|
2106
|
+
return null;
|
|
2107
|
+
}
|
|
2108
|
+
if (_preferToolbar) {
|
|
2109
|
+
return root.querySelector('.table-page-toolbar-section') || root.querySelector('.table-with-toolbar') || getTableElement(root);
|
|
2110
|
+
}
|
|
2111
|
+
return getTableElement(root);
|
|
2112
|
+
};
|
|
2113
|
+
const readCssVariableLength = (element, variableName, fallback = '0px') => {
|
|
2114
|
+
if (typeof document === 'undefined') {
|
|
2115
|
+
return 0;
|
|
2116
|
+
}
|
|
2117
|
+
const host = element || document.documentElement;
|
|
2118
|
+
const probe = document.createElement('div');
|
|
2119
|
+
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;height:0;width:0;overflow:hidden;';
|
|
2120
|
+
probe.style.marginTop = `var(${variableName}, ${fallback})`;
|
|
2121
|
+
host.appendChild(probe);
|
|
2122
|
+
const value = parsePixelValue(getComputedStyle(probe).marginTop);
|
|
2123
|
+
host.removeChild(probe);
|
|
2124
|
+
return value;
|
|
2125
|
+
};
|
|
2126
|
+
const resolveScrollContainer = (element, getScrollContainer) => {
|
|
2127
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2128
|
+
if (explicitContainer) {
|
|
2129
|
+
return explicitContainer;
|
|
2130
|
+
}
|
|
2131
|
+
let parent = element == null ? void 0 : element.parentElement;
|
|
2132
|
+
while (parent) {
|
|
2133
|
+
const {
|
|
2134
|
+
overflowY
|
|
2135
|
+
} = getComputedStyle(parent);
|
|
2136
|
+
if (/(auto|scroll|overlay)/.test(overflowY) && parent.scrollHeight > parent.clientHeight + 1) {
|
|
2137
|
+
return parent;
|
|
2138
|
+
}
|
|
2139
|
+
parent = parent.parentElement;
|
|
2140
|
+
}
|
|
2141
|
+
return document.scrollingElement || document.documentElement;
|
|
2142
|
+
};
|
|
2143
|
+
const scrollToElement = (element, {
|
|
2144
|
+
offsetTop: _offsetTop = 0,
|
|
2145
|
+
getScrollContainer
|
|
2146
|
+
} = {}) => {
|
|
2147
|
+
const scrollContainer = resolveScrollContainer(element, getScrollContainer);
|
|
2148
|
+
const targetRect = element.getBoundingClientRect();
|
|
2149
|
+
if (scrollContainer === document.scrollingElement || scrollContainer === document.documentElement || scrollContainer === document.body) {
|
|
2150
|
+
const scrollTop = window.pageYOffset + targetRect.top - _offsetTop;
|
|
2151
|
+
window.scrollTo({
|
|
2152
|
+
top: Math.max(0, scrollTop),
|
|
2153
|
+
behavior: 'auto'
|
|
2154
|
+
});
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
2158
|
+
const nextScrollTop = scrollContainer.scrollTop + targetRect.top - containerRect.top - _offsetTop;
|
|
2159
|
+
scrollContainer.scrollTo({
|
|
2160
|
+
top: Math.max(0, nextScrollTop),
|
|
2161
|
+
behavior: 'auto'
|
|
2162
|
+
});
|
|
2163
|
+
};
|
|
2164
|
+
const scrollAnchorIntoView = (root, {
|
|
2165
|
+
getScrollContainer,
|
|
2166
|
+
preferToolbar: _preferToolbar2 = false
|
|
2167
|
+
} = {}) => {
|
|
2168
|
+
const target = getScrollAnchorElement(root, {
|
|
2169
|
+
preferToolbar: _preferToolbar2
|
|
2170
|
+
});
|
|
2171
|
+
if (!target) {
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
const offsetTop = readScrollTopInsetPixels(target);
|
|
2175
|
+
requestAnimationFrame(() => {
|
|
2176
|
+
requestAnimationFrame(() => {
|
|
2177
|
+
if (isTopEdgeInViewport(target, offsetTop, getScrollContainer)) {
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2180
|
+
scrollToElement(target, {
|
|
2181
|
+
offsetTop,
|
|
2182
|
+
getScrollContainer
|
|
2183
|
+
});
|
|
2184
|
+
});
|
|
2185
|
+
});
|
|
2186
|
+
};
|
|
2187
|
+
const getTableScrollElement = root => {
|
|
2188
|
+
if (!root) {
|
|
2189
|
+
return null;
|
|
2190
|
+
}
|
|
2191
|
+
return root.querySelector('.ant-table-body') || root.querySelector('.ant-table-content');
|
|
2192
|
+
};
|
|
2193
|
+
const getElementViewportState = element => {
|
|
2194
|
+
if (!element) {
|
|
2195
|
+
return {
|
|
2196
|
+
isBottomInViewport: true,
|
|
2197
|
+
isPartiallyInViewport: false,
|
|
2198
|
+
isTopInViewport: true,
|
|
2199
|
+
rect: null,
|
|
2200
|
+
viewport: getViewportRect()
|
|
2201
|
+
};
|
|
2202
|
+
}
|
|
2203
|
+
const rect = element.getBoundingClientRect();
|
|
2204
|
+
const viewport = getViewportRect();
|
|
2205
|
+
return {
|
|
2206
|
+
isBottomInViewport: rect.bottom > viewport.top && rect.bottom <= viewport.bottom,
|
|
2207
|
+
isPartiallyInViewport: rect.top < viewport.bottom && rect.bottom > viewport.top,
|
|
2208
|
+
isTopInViewport: rect.top >= viewport.top && rect.top < viewport.bottom,
|
|
2209
|
+
rect,
|
|
2210
|
+
viewport
|
|
2211
|
+
};
|
|
2212
|
+
};
|
|
2213
|
+
const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) => {
|
|
2214
|
+
if (!element) {
|
|
2215
|
+
return true;
|
|
2216
|
+
}
|
|
2217
|
+
const rect = element.getBoundingClientRect();
|
|
2218
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2219
|
+
if (!isDocumentScrollContainer(explicitContainer)) {
|
|
2220
|
+
const containerRect = explicitContainer.getBoundingClientRect();
|
|
2221
|
+
const _viewportTop = containerRect.top + scrollMarginTop;
|
|
2222
|
+
return rect.top >= _viewportTop && rect.top < containerRect.bottom;
|
|
2223
|
+
}
|
|
2224
|
+
const {
|
|
2225
|
+
isTopInViewport,
|
|
2226
|
+
viewport
|
|
2227
|
+
} = getElementViewportState(element);
|
|
2228
|
+
if (!rect) {
|
|
2229
|
+
return true;
|
|
2230
|
+
}
|
|
2231
|
+
const viewportTop = viewport.top + scrollMarginTop;
|
|
2232
|
+
return rect.top >= viewportTop && rect.top < viewport.bottom;
|
|
2233
|
+
};
|
|
2234
|
+
const shouldShowFloatingScrollbar = (scrollEl, viewportState, getScrollContainer) => {
|
|
2235
|
+
if (!scrollEl || scrollEl.scrollWidth <= scrollEl.clientWidth + 1) {
|
|
2236
|
+
return false;
|
|
2237
|
+
}
|
|
2238
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2239
|
+
if (!isDocumentScrollContainer(explicitContainer)) {
|
|
2240
|
+
const rect = scrollEl.getBoundingClientRect();
|
|
2241
|
+
const containerRect = explicitContainer.getBoundingClientRect();
|
|
2242
|
+
return rect.top < containerRect.bottom && rect.bottom > containerRect.bottom;
|
|
2243
|
+
}
|
|
2244
|
+
const state = viewportState || getElementViewportState(scrollEl);
|
|
2245
|
+
if (!state.isPartiallyInViewport) {
|
|
2246
|
+
return false;
|
|
2247
|
+
}
|
|
2248
|
+
return !state.isBottomInViewport;
|
|
2249
|
+
};
|
|
2250
|
+
const observeViewportIntersection = (element, onChange) => {
|
|
2251
|
+
var _window$visualViewpor, _window$visualViewpor2;
|
|
2252
|
+
if (!element) {
|
|
2253
|
+
return () => {};
|
|
2254
|
+
}
|
|
2255
|
+
const notify = entry => {
|
|
2256
|
+
onChange(getElementViewportState(element));
|
|
2257
|
+
};
|
|
2258
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
2259
|
+
notify();
|
|
2260
|
+
}, {
|
|
2261
|
+
root: null,
|
|
2262
|
+
threshold: [0, 0.01, 0.25, 0.5, 0.75, 1]
|
|
2263
|
+
});
|
|
2264
|
+
observer.observe(element);
|
|
2265
|
+
const handleViewportChange = () => {
|
|
2266
|
+
notify();
|
|
2267
|
+
};
|
|
2268
|
+
window.addEventListener('scroll', handleViewportChange, true);
|
|
2269
|
+
window.addEventListener('resize', handleViewportChange);
|
|
2270
|
+
(_window$visualViewpor = window.visualViewport) == null || _window$visualViewpor.addEventListener('resize', handleViewportChange);
|
|
2271
|
+
(_window$visualViewpor2 = window.visualViewport) == null || _window$visualViewpor2.addEventListener('scroll', handleViewportChange);
|
|
2272
|
+
notify();
|
|
2273
|
+
return () => {
|
|
2274
|
+
var _window$visualViewpor3, _window$visualViewpor4;
|
|
2275
|
+
observer.disconnect();
|
|
2276
|
+
window.removeEventListener('scroll', handleViewportChange, true);
|
|
2277
|
+
window.removeEventListener('resize', handleViewportChange);
|
|
2278
|
+
(_window$visualViewpor3 = window.visualViewport) == null || _window$visualViewpor3.removeEventListener('resize', handleViewportChange);
|
|
2279
|
+
(_window$visualViewpor4 = window.visualViewport) == null || _window$visualViewpor4.removeEventListener('scroll', handleViewportChange);
|
|
2280
|
+
};
|
|
2281
|
+
};
|
|
2282
|
+
|
|
2283
|
+
const _excluded$3 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "name", "controllerOpen", "tableServerApis", "scroll", "summary"],
|
|
2038
2284
|
_excluded2$2 = ["getContainer"];
|
|
2039
2285
|
const mapJustifyToAlign = justify => {
|
|
2040
2286
|
if (justify === 'center') {
|
|
@@ -2100,6 +2346,7 @@ const Table = p => {
|
|
|
2100
2346
|
render,
|
|
2101
2347
|
context,
|
|
2102
2348
|
sticky,
|
|
2349
|
+
scrollTopInset,
|
|
2103
2350
|
stickyOffset,
|
|
2104
2351
|
getStickyContainer,
|
|
2105
2352
|
headerStyle,
|
|
@@ -2352,6 +2599,20 @@ const Table = p => {
|
|
|
2352
2599
|
} : {}, scroll);
|
|
2353
2600
|
}, [hasFixedColumn, controllerOpen, totalWidth, tableWidth, scroll]);
|
|
2354
2601
|
const hasScrollY = (scroll == null ? void 0 : scroll.y) != null && (scroll == null ? void 0 : scroll.y) !== false;
|
|
2602
|
+
const isStickyViewport = !!sticky && !hasScrollY;
|
|
2603
|
+
const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
|
|
2604
|
+
const stickyGetContainer = useMemo(() => {
|
|
2605
|
+
if (!getStickyContainer || hasScrollY) {
|
|
2606
|
+
return undefined;
|
|
2607
|
+
}
|
|
2608
|
+
return () => getStickyContainer() || window;
|
|
2609
|
+
}, [getStickyContainer, hasScrollY]);
|
|
2610
|
+
const parsedScrollTopInset = useMemo(() => {
|
|
2611
|
+
if (!sticky || hasScrollY) {
|
|
2612
|
+
return 0;
|
|
2613
|
+
}
|
|
2614
|
+
return parseInsetPixels(resolvedScrollTopInset, tableRef.current);
|
|
2615
|
+
}, [sticky, hasScrollY, resolvedScrollTopInset, isLayout, dataSource]);
|
|
2355
2616
|
const antdSticky = useMemo(() => {
|
|
2356
2617
|
if (!sticky) {
|
|
2357
2618
|
return undefined;
|
|
@@ -2364,19 +2625,20 @@ const Table = p => {
|
|
|
2364
2625
|
}, scrollSticky);
|
|
2365
2626
|
}
|
|
2366
2627
|
return Object.assign({
|
|
2367
|
-
offsetHeader:
|
|
2368
|
-
}, config,
|
|
2369
|
-
getContainer:
|
|
2628
|
+
offsetHeader: parsedScrollTopInset
|
|
2629
|
+
}, config, stickyGetContainer ? {
|
|
2630
|
+
getContainer: stickyGetContainer
|
|
2370
2631
|
} : null);
|
|
2371
|
-
}, [sticky,
|
|
2632
|
+
}, [sticky, stickyGetContainer, hasScrollY, parsedScrollTopInset]);
|
|
2372
2633
|
const tableWrapperStyle = useMemo(() => {
|
|
2373
|
-
|
|
2634
|
+
const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
|
|
2635
|
+
if (!cssValue) {
|
|
2374
2636
|
return undefined;
|
|
2375
2637
|
}
|
|
2376
2638
|
return {
|
|
2377
|
-
'--
|
|
2639
|
+
'--scroll-top-inset': cssValue
|
|
2378
2640
|
};
|
|
2379
|
-
}, [
|
|
2641
|
+
}, [resolvedScrollTopInset]);
|
|
2380
2642
|
const tableElement = /*#__PURE__*/jsx(Table$1, _extends({}, others, {
|
|
2381
2643
|
showHeader: true,
|
|
2382
2644
|
dataSource: dataSource,
|
|
@@ -2421,14 +2683,14 @@ const Table = p => {
|
|
|
2421
2683
|
}));
|
|
2422
2684
|
const wrappedTable = /*#__PURE__*/jsxs("div", {
|
|
2423
2685
|
ref: tableRef,
|
|
2424
|
-
className: classnames(style$
|
|
2686
|
+
className: classnames(style$4['table'], 'info-page-table', className, {
|
|
2425
2687
|
[style$4['is-resize']]: currentMoveColumnIndex !== null,
|
|
2426
2688
|
[style$4['is-computed']]: isLayout,
|
|
2427
2689
|
[style$4['has-group-header']]: hasGroupHeader,
|
|
2428
2690
|
[style$4['has-summary']]: typeof summary === 'function',
|
|
2429
2691
|
[style$4['is-sticky']]: !!sticky,
|
|
2430
2692
|
[style$4['is-sticky-scroll-y']]: !!sticky && hasScrollY,
|
|
2431
|
-
[style$4['is-sticky-viewport']]:
|
|
2693
|
+
[style$4['is-sticky-viewport']]: isStickyViewport
|
|
2432
2694
|
}),
|
|
2433
2695
|
style: tableWrapperStyle,
|
|
2434
2696
|
children: [/*#__PURE__*/jsx("div", {
|
|
@@ -2818,123 +3080,16 @@ TableView.useSelectedRow = useSelectedRow;
|
|
|
2818
3080
|
TableView.useSort = useSort;
|
|
2819
3081
|
TableView.sortDataSource = useSort.sortDataSource;
|
|
2820
3082
|
|
|
2821
|
-
var style$1 = {"table-page":"kne-table-page_ut9rJ","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","table-in-toolbar":"kne-table-page_sawIT","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr","floating-scrollbar":"kne-table-page_iu8E1","floating-scrollbar-thumb":"kne-table-page_RjZsu","is-moving":"kne-table-page_y-4Ou"};
|
|
2822
|
-
|
|
2823
|
-
const parsePixelValue = value => {
|
|
2824
|
-
const num = parseFloat(value);
|
|
2825
|
-
return Number.isNaN(num) ? 0 : num;
|
|
2826
|
-
};
|
|
2827
|
-
const getViewportRect = () => {
|
|
2828
|
-
const visualViewport = window.visualViewport;
|
|
2829
|
-
if (visualViewport) {
|
|
2830
|
-
return {
|
|
2831
|
-
top: visualViewport.offsetTop,
|
|
2832
|
-
bottom: visualViewport.offsetTop + visualViewport.height,
|
|
2833
|
-
left: visualViewport.offsetLeft,
|
|
2834
|
-
right: visualViewport.offsetLeft + visualViewport.width,
|
|
2835
|
-
height: visualViewport.height
|
|
2836
|
-
};
|
|
2837
|
-
}
|
|
2838
|
-
return {
|
|
2839
|
-
top: 0,
|
|
2840
|
-
bottom: window.innerHeight,
|
|
2841
|
-
left: 0,
|
|
2842
|
-
right: window.innerWidth,
|
|
2843
|
-
height: window.innerHeight
|
|
2844
|
-
};
|
|
2845
|
-
};
|
|
2846
|
-
const getTableElement = root => {
|
|
2847
|
-
if (!root) {
|
|
2848
|
-
return null;
|
|
2849
|
-
}
|
|
2850
|
-
return root.querySelector('.info-page-table') || root;
|
|
2851
|
-
};
|
|
2852
|
-
const getTableScrollElement = root => {
|
|
2853
|
-
if (!root) {
|
|
2854
|
-
return null;
|
|
2855
|
-
}
|
|
2856
|
-
return root.querySelector('.ant-table-body') || root.querySelector('.ant-table-content');
|
|
2857
|
-
};
|
|
2858
|
-
const getElementViewportState = element => {
|
|
2859
|
-
if (!element) {
|
|
2860
|
-
return {
|
|
2861
|
-
isBottomInViewport: true,
|
|
2862
|
-
isPartiallyInViewport: false,
|
|
2863
|
-
isTopInViewport: true,
|
|
2864
|
-
rect: null,
|
|
2865
|
-
viewport: getViewportRect()
|
|
2866
|
-
};
|
|
2867
|
-
}
|
|
2868
|
-
const rect = element.getBoundingClientRect();
|
|
2869
|
-
const viewport = getViewportRect();
|
|
2870
|
-
return {
|
|
2871
|
-
isBottomInViewport: rect.bottom > viewport.top && rect.bottom <= viewport.bottom,
|
|
2872
|
-
isPartiallyInViewport: rect.top < viewport.bottom && rect.bottom > viewport.top,
|
|
2873
|
-
isTopInViewport: rect.top >= viewport.top && rect.top < viewport.bottom,
|
|
2874
|
-
rect,
|
|
2875
|
-
viewport
|
|
2876
|
-
};
|
|
2877
|
-
};
|
|
2878
|
-
const isTopEdgeInViewport = (element, scrollMarginTop = 0) => {
|
|
2879
|
-
const {
|
|
2880
|
-
isTopInViewport,
|
|
2881
|
-
rect,
|
|
2882
|
-
viewport
|
|
2883
|
-
} = getElementViewportState(element);
|
|
2884
|
-
if (!rect) {
|
|
2885
|
-
return true;
|
|
2886
|
-
}
|
|
2887
|
-
const viewportTop = viewport.top + scrollMarginTop;
|
|
2888
|
-
return rect.top >= viewportTop && rect.top < viewport.bottom;
|
|
2889
|
-
};
|
|
2890
|
-
const shouldShowFloatingScrollbar = (scrollEl, viewportState) => {
|
|
2891
|
-
if (!scrollEl || scrollEl.scrollWidth <= scrollEl.clientWidth + 1) {
|
|
2892
|
-
return false;
|
|
2893
|
-
}
|
|
2894
|
-
const state = viewportState || getElementViewportState(scrollEl);
|
|
2895
|
-
if (!state.isPartiallyInViewport) {
|
|
2896
|
-
return false;
|
|
2897
|
-
}
|
|
2898
|
-
return !state.isBottomInViewport;
|
|
2899
|
-
};
|
|
2900
|
-
const observeViewportIntersection = (element, onChange) => {
|
|
2901
|
-
var _window$visualViewpor, _window$visualViewpor2;
|
|
2902
|
-
if (!element) {
|
|
2903
|
-
return () => {};
|
|
2904
|
-
}
|
|
2905
|
-
const notify = entry => {
|
|
2906
|
-
onChange(getElementViewportState(element));
|
|
2907
|
-
};
|
|
2908
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
2909
|
-
notify();
|
|
2910
|
-
}, {
|
|
2911
|
-
root: null,
|
|
2912
|
-
threshold: [0, 0.01, 0.25, 0.5, 0.75, 1]
|
|
2913
|
-
});
|
|
2914
|
-
observer.observe(element);
|
|
2915
|
-
const handleViewportChange = () => {
|
|
2916
|
-
notify();
|
|
2917
|
-
};
|
|
2918
|
-
window.addEventListener('scroll', handleViewportChange, true);
|
|
2919
|
-
window.addEventListener('resize', handleViewportChange);
|
|
2920
|
-
(_window$visualViewpor = window.visualViewport) == null || _window$visualViewpor.addEventListener('resize', handleViewportChange);
|
|
2921
|
-
(_window$visualViewpor2 = window.visualViewport) == null || _window$visualViewpor2.addEventListener('scroll', handleViewportChange);
|
|
2922
|
-
notify();
|
|
2923
|
-
return () => {
|
|
2924
|
-
var _window$visualViewpor3, _window$visualViewpor4;
|
|
2925
|
-
observer.disconnect();
|
|
2926
|
-
window.removeEventListener('scroll', handleViewportChange, true);
|
|
2927
|
-
window.removeEventListener('resize', handleViewportChange);
|
|
2928
|
-
(_window$visualViewpor3 = window.visualViewport) == null || _window$visualViewpor3.removeEventListener('resize', handleViewportChange);
|
|
2929
|
-
(_window$visualViewpor4 = window.visualViewport) == null || _window$visualViewpor4.removeEventListener('scroll', handleViewportChange);
|
|
2930
|
-
};
|
|
2931
|
-
};
|
|
3083
|
+
var style$1 = {"table-page":"kne-table-page_ut9rJ","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","has-summary":"kne-table-page_IRdzb","table-in-toolbar":"kne-table-page_sawIT","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr","floating-scrollbar":"kne-table-page_iu8E1","floating-scrollbar-thumb":"kne-table-page_RjZsu","is-moving":"kne-table-page_y-4Ou"};
|
|
2932
3084
|
|
|
2933
3085
|
const BAR_HEIGHT = 15;
|
|
2934
3086
|
const THUMB_MARGIN = 2;
|
|
2935
|
-
const computeBarMetrics = (scrollEl, viewportState) => {
|
|
3087
|
+
const computeBarMetrics = (scrollEl, viewportState, getPortalContainer) => {
|
|
2936
3088
|
const rect = scrollEl.getBoundingClientRect();
|
|
3089
|
+
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
3090
|
+
const useContainerScroll = !isDocumentScrollContainer(portalContainer);
|
|
2937
3091
|
const viewport = getViewportRect();
|
|
3092
|
+
const anchorRect = useContainerScroll ? portalContainer.getBoundingClientRect() : viewport;
|
|
2938
3093
|
const trackWidth = rect.width;
|
|
2939
3094
|
const thumbWidth = Math.max(trackWidth * scrollEl.clientWidth / scrollEl.scrollWidth - THUMB_MARGIN * 2, 24);
|
|
2940
3095
|
const maxThumbOffset = trackWidth - thumbWidth - THUMB_MARGIN * 2;
|
|
@@ -2942,10 +3097,10 @@ const computeBarMetrics = (scrollEl, viewportState) => {
|
|
|
2942
3097
|
return {
|
|
2943
3098
|
left: rect.left,
|
|
2944
3099
|
width: trackWidth,
|
|
2945
|
-
bottom: window.innerHeight -
|
|
3100
|
+
bottom: window.innerHeight - anchorRect.bottom,
|
|
2946
3101
|
thumbWidth,
|
|
2947
3102
|
thumbLeft: THUMB_MARGIN + maxThumbOffset * scrollRatio,
|
|
2948
|
-
visible: shouldShowFloatingScrollbar(scrollEl, viewportState)
|
|
3103
|
+
visible: shouldShowFloatingScrollbar(scrollEl, viewportState, getPortalContainer)
|
|
2949
3104
|
};
|
|
2950
3105
|
};
|
|
2951
3106
|
const FloatingScrollBar = ({
|
|
@@ -2982,7 +3137,7 @@ const FloatingScrollBar = ({
|
|
|
2982
3137
|
if (!(metrics != null && metrics.visible)) {
|
|
2983
3138
|
return null;
|
|
2984
3139
|
}
|
|
2985
|
-
const portalTarget =
|
|
3140
|
+
const portalTarget = document.body;
|
|
2986
3141
|
return /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
|
|
2987
3142
|
className: classnames(style$1['floating-scrollbar'], 'table-page-floating-scrollbar'),
|
|
2988
3143
|
style: {
|
|
@@ -3031,7 +3186,7 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
|
|
|
3031
3186
|
setMetrics(null);
|
|
3032
3187
|
return;
|
|
3033
3188
|
}
|
|
3034
|
-
setMetrics(computeBarMetrics(scrollEl, viewportStateRef.current));
|
|
3189
|
+
setMetrics(computeBarMetrics(scrollEl, viewportStateRef.current, getPortalContainer));
|
|
3035
3190
|
});
|
|
3036
3191
|
const handleThumbDrag = useRefCallback(deltaX => {
|
|
3037
3192
|
const scrollEl = scrollElRef.current;
|
|
@@ -3103,11 +3258,18 @@ const HorizontalScroller = /*#__PURE__*/forwardRef(({
|
|
|
3103
3258
|
const containerResizeObserver = new ResizeObserver(onLayoutChange);
|
|
3104
3259
|
containerResizeObserver.observe(root);
|
|
3105
3260
|
onLayoutChange();
|
|
3261
|
+
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
3262
|
+
if (!isDocumentScrollContainer(portalContainer)) {
|
|
3263
|
+
portalContainer.addEventListener('scroll', updateMetrics, {
|
|
3264
|
+
passive: true
|
|
3265
|
+
});
|
|
3266
|
+
}
|
|
3106
3267
|
return () => {
|
|
3107
3268
|
detachScrollEl();
|
|
3108
3269
|
containerResizeObserver.disconnect();
|
|
3270
|
+
portalContainer == null || portalContainer.removeEventListener('scroll', updateMetrics);
|
|
3109
3271
|
};
|
|
3110
|
-
}, [_enabled, updateMetrics]);
|
|
3272
|
+
}, [_enabled, updateMetrics, getPortalContainer]);
|
|
3111
3273
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
3112
3274
|
children: [/*#__PURE__*/jsx("div", {
|
|
3113
3275
|
ref: setContainerRef,
|
|
@@ -3202,7 +3364,7 @@ const TableToolbar = ({
|
|
|
3202
3364
|
'table-page-toolbar-section--has-value': hasValueDisplay
|
|
3203
3365
|
}),
|
|
3204
3366
|
children: [/*#__PURE__*/jsxs("div", {
|
|
3205
|
-
className: style['table-toolbar'],
|
|
3367
|
+
className: classnames(style['table-toolbar'], 'table-page-toolbar'),
|
|
3206
3368
|
children: [showBatch ? /*#__PURE__*/jsxs(Fragment, {
|
|
3207
3369
|
children: [/*#__PURE__*/jsx("div", {
|
|
3208
3370
|
className: style['table-toolbar-batch'],
|
|
@@ -3267,7 +3429,7 @@ const TableToolbar = ({
|
|
|
3267
3429
|
});
|
|
3268
3430
|
};
|
|
3269
3431
|
|
|
3270
|
-
const _excluded = ["data", "refresh", "reload", "requestParams", "fetchProps", "isComplete", "loadMore", "send", "dataFormat", "className", "columns", "getColumns", "pagination", "columnRenderProps", "summary", "sticky", "renderType", "horizontalScroller", "getScrollContainer", "filter", "search", "batchActions", "selectedRows", "rowSelection"],
|
|
3432
|
+
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", "batchActions", "selectedRows", "rowSelection"],
|
|
3271
3433
|
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
|
|
3272
3434
|
const readPageSize = key => {
|
|
3273
3435
|
try {
|
|
@@ -3288,27 +3450,6 @@ const writePageSize = (key, size) => {
|
|
|
3288
3450
|
// ignore quota errors
|
|
3289
3451
|
}
|
|
3290
3452
|
};
|
|
3291
|
-
const isTableTopInViewport = target => {
|
|
3292
|
-
const scrollMarginTop = parsePixelValue(getComputedStyle(target).scrollMarginTop);
|
|
3293
|
-
return isTopEdgeInViewport(target, scrollMarginTop);
|
|
3294
|
-
};
|
|
3295
|
-
const scrollTableIntoView = root => {
|
|
3296
|
-
const target = getTableElement(root);
|
|
3297
|
-
if (!target) {
|
|
3298
|
-
return;
|
|
3299
|
-
}
|
|
3300
|
-
requestAnimationFrame(() => {
|
|
3301
|
-
requestAnimationFrame(() => {
|
|
3302
|
-
if (isTableTopInViewport(target)) {
|
|
3303
|
-
return;
|
|
3304
|
-
}
|
|
3305
|
-
target.scrollIntoView({
|
|
3306
|
-
block: 'start',
|
|
3307
|
-
inline: 'nearest'
|
|
3308
|
-
});
|
|
3309
|
-
});
|
|
3310
|
-
});
|
|
3311
|
-
};
|
|
3312
3453
|
const TABLE_COMPONENTS = {
|
|
3313
3454
|
Table,
|
|
3314
3455
|
TableView
|
|
@@ -3366,6 +3507,8 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3366
3507
|
columnRenderProps = {},
|
|
3367
3508
|
summary,
|
|
3368
3509
|
sticky,
|
|
3510
|
+
scrollTopInset,
|
|
3511
|
+
stickyOffset,
|
|
3369
3512
|
renderType = 'Table',
|
|
3370
3513
|
horizontalScroller = true,
|
|
3371
3514
|
getScrollContainer,
|
|
@@ -3408,8 +3551,22 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3408
3551
|
dataFormat,
|
|
3409
3552
|
pagination
|
|
3410
3553
|
}), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
|
|
3554
|
+
const hasToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
|
|
3555
|
+
const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
|
|
3556
|
+
const scrollTopInsetStyle = useMemo(() => {
|
|
3557
|
+
const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
|
|
3558
|
+
if (!cssValue) {
|
|
3559
|
+
return undefined;
|
|
3560
|
+
}
|
|
3561
|
+
return {
|
|
3562
|
+
'--scroll-top-inset': cssValue
|
|
3563
|
+
};
|
|
3564
|
+
}, [resolvedScrollTopInset]);
|
|
3411
3565
|
const scrollTable = useRefCallback(() => {
|
|
3412
|
-
|
|
3566
|
+
scrollAnchorIntoView(tableContentRef.current, {
|
|
3567
|
+
getScrollContainer,
|
|
3568
|
+
preferToolbar: hasToolbar
|
|
3569
|
+
});
|
|
3413
3570
|
});
|
|
3414
3571
|
const handleFilterChange = useRefCallback(value => {
|
|
3415
3572
|
if (!isFilterControlled) {
|
|
@@ -3463,7 +3620,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3463
3620
|
})]
|
|
3464
3621
|
}),
|
|
3465
3622
|
current: get(requestParams, [pagination.paramsType, pagination.currentName], 1),
|
|
3466
|
-
pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize ||
|
|
3623
|
+
pageSize: Number(get(requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50,
|
|
3467
3624
|
onChange: handlePaginationChange,
|
|
3468
3625
|
size: pagination.size,
|
|
3469
3626
|
hideOnSinglePage: pagination.hideOnSinglePage,
|
|
@@ -3472,7 +3629,6 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3472
3629
|
pageSizeOptions: pagination.pageSizeOptions
|
|
3473
3630
|
};
|
|
3474
3631
|
}, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange]);
|
|
3475
|
-
const hasToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
|
|
3476
3632
|
const batchContext = useMemo(() => ({
|
|
3477
3633
|
data,
|
|
3478
3634
|
fetchProps,
|
|
@@ -3494,6 +3650,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3494
3650
|
dataSource: formatData.list,
|
|
3495
3651
|
pagination: false,
|
|
3496
3652
|
sticky,
|
|
3653
|
+
scrollTopInset: resolvedScrollTopInset,
|
|
3497
3654
|
getStickyContainer: getScrollContainer,
|
|
3498
3655
|
className: classnames(className, {
|
|
3499
3656
|
[style$1['table-in-toolbar']]: hasToolbar
|
|
@@ -3511,6 +3668,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3511
3668
|
const tableElement = /*#__PURE__*/jsx(TableComponent, _extends({}, tableProps));
|
|
3512
3669
|
return /*#__PURE__*/jsxs("div", {
|
|
3513
3670
|
className: style$1['table-page'],
|
|
3671
|
+
style: scrollTopInsetStyle,
|
|
3514
3672
|
children: [/*#__PURE__*/jsx(HorizontalScroller, {
|
|
3515
3673
|
ref: tableContentRef,
|
|
3516
3674
|
enabled: horizontalScroller && renderType === 'Table',
|
|
@@ -3553,12 +3711,13 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3553
3711
|
requestType: 'reload',
|
|
3554
3712
|
currentName: 'currentPage',
|
|
3555
3713
|
pageSizeName: 'perPage',
|
|
3556
|
-
pageSize:
|
|
3714
|
+
pageSize: 50
|
|
3557
3715
|
}, pagination);
|
|
3558
3716
|
const pageSizeKey = `${(props.name || 'common').toUpperCase()}_TABLE_PAGE_SIZE`;
|
|
3717
|
+
const cachePageSize = pagination.cachePageSize !== false;
|
|
3559
3718
|
const [pageSize, setPageSize] = useState(() => {
|
|
3560
|
-
var
|
|
3561
|
-
return (
|
|
3719
|
+
var _ref3;
|
|
3720
|
+
return (_ref3 = cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3562
3721
|
});
|
|
3563
3722
|
const params = props[pagination.paramsType];
|
|
3564
3723
|
const filterDefaultParams = useMemo(() => {
|
|
@@ -3583,7 +3742,9 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
|
3583
3742
|
pageSize,
|
|
3584
3743
|
onShowSizeChange: (current, size) => {
|
|
3585
3744
|
const nextSize = Number(size);
|
|
3586
|
-
|
|
3745
|
+
if (cachePageSize) {
|
|
3746
|
+
writePageSize(pageSizeKey, nextSize);
|
|
3747
|
+
}
|
|
3587
3748
|
setPageSize(nextSize);
|
|
3588
3749
|
}
|
|
3589
3750
|
}),
|