@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.js
CHANGED
|
@@ -1082,7 +1082,7 @@ const computeColumnsDisplay = ({
|
|
|
1082
1082
|
computeColumnsValue.computeDisplay = computeDisplay;
|
|
1083
1083
|
computeColumnsValue.computeColumnsDisplay = computeColumnsDisplay;
|
|
1084
1084
|
|
|
1085
|
-
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","
|
|
1085
|
+
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"};
|
|
1086
1086
|
|
|
1087
1087
|
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"};
|
|
1088
1088
|
|
|
@@ -2094,7 +2094,251 @@ const getColumnEllipsis = column => {
|
|
|
2094
2094
|
return typeof column.ellipsis === 'object' ? column.ellipsis : true;
|
|
2095
2095
|
};
|
|
2096
2096
|
|
|
2097
|
-
const
|
|
2097
|
+
const parsePixelValue = value => {
|
|
2098
|
+
const num = parseFloat(value);
|
|
2099
|
+
return Number.isNaN(num) ? 0 : num;
|
|
2100
|
+
};
|
|
2101
|
+
const isDocumentScrollContainer = container => {
|
|
2102
|
+
return !container || container === document.body || container === document.documentElement || container === document.scrollingElement;
|
|
2103
|
+
};
|
|
2104
|
+
const normalizeScrollTopInsetCSSValue = value => {
|
|
2105
|
+
if (value == null) {
|
|
2106
|
+
return undefined;
|
|
2107
|
+
}
|
|
2108
|
+
if (typeof value === 'number') {
|
|
2109
|
+
return `${value}px`;
|
|
2110
|
+
}
|
|
2111
|
+
return String(value);
|
|
2112
|
+
};
|
|
2113
|
+
const resolveScrollTopInset = (scrollTopInset, stickyOffset) => scrollTopInset ?? stickyOffset;
|
|
2114
|
+
const parseInsetPixels = (inset, element) => {
|
|
2115
|
+
if (inset == null) {
|
|
2116
|
+
return 0;
|
|
2117
|
+
}
|
|
2118
|
+
if (typeof inset === 'number') {
|
|
2119
|
+
return inset;
|
|
2120
|
+
}
|
|
2121
|
+
if (typeof inset === 'string') {
|
|
2122
|
+
const trimmed = inset.trim();
|
|
2123
|
+
if (trimmed.endsWith('px')) {
|
|
2124
|
+
return parsePixelValue(trimmed);
|
|
2125
|
+
}
|
|
2126
|
+
const variableMatch = trimmed.match(/var\(\s*(--[^,\s)]+)/);
|
|
2127
|
+
if (variableMatch) {
|
|
2128
|
+
return readCssVariableLength(element, variableMatch[1], '0px');
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
return 0;
|
|
2132
|
+
};
|
|
2133
|
+
const readScrollTopInsetPixels = element => {
|
|
2134
|
+
const fromVar = readCssVariableLength(element, '--scroll-top-inset', '0px') || readCssVariableLength(element, '--sticky-offset', '0px') || readCssVariableLength(element, '--nav-height', '0px');
|
|
2135
|
+
return fromVar;
|
|
2136
|
+
};
|
|
2137
|
+
const getViewportRect = () => {
|
|
2138
|
+
const visualViewport = window.visualViewport;
|
|
2139
|
+
if (visualViewport) {
|
|
2140
|
+
return {
|
|
2141
|
+
top: visualViewport.offsetTop,
|
|
2142
|
+
bottom: visualViewport.offsetTop + visualViewport.height,
|
|
2143
|
+
left: visualViewport.offsetLeft,
|
|
2144
|
+
right: visualViewport.offsetLeft + visualViewport.width,
|
|
2145
|
+
height: visualViewport.height
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
return {
|
|
2149
|
+
top: 0,
|
|
2150
|
+
bottom: window.innerHeight,
|
|
2151
|
+
left: 0,
|
|
2152
|
+
right: window.innerWidth,
|
|
2153
|
+
height: window.innerHeight
|
|
2154
|
+
};
|
|
2155
|
+
};
|
|
2156
|
+
const getTableElement = root => {
|
|
2157
|
+
if (!root) {
|
|
2158
|
+
return null;
|
|
2159
|
+
}
|
|
2160
|
+
return root.querySelector('.info-page-table') || root;
|
|
2161
|
+
};
|
|
2162
|
+
const getScrollAnchorElement = (root, {
|
|
2163
|
+
preferToolbar = false
|
|
2164
|
+
} = {}) => {
|
|
2165
|
+
if (!root) {
|
|
2166
|
+
return null;
|
|
2167
|
+
}
|
|
2168
|
+
if (preferToolbar) {
|
|
2169
|
+
return root.querySelector('.table-page-toolbar-section') || root.querySelector('.table-with-toolbar') || getTableElement(root);
|
|
2170
|
+
}
|
|
2171
|
+
return getTableElement(root);
|
|
2172
|
+
};
|
|
2173
|
+
const readCssVariableLength = (element, variableName, fallback = '0px') => {
|
|
2174
|
+
if (typeof document === 'undefined') {
|
|
2175
|
+
return 0;
|
|
2176
|
+
}
|
|
2177
|
+
const host = element || document.documentElement;
|
|
2178
|
+
const probe = document.createElement('div');
|
|
2179
|
+
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;height:0;width:0;overflow:hidden;';
|
|
2180
|
+
probe.style.marginTop = `var(${variableName}, ${fallback})`;
|
|
2181
|
+
host.appendChild(probe);
|
|
2182
|
+
const value = parsePixelValue(getComputedStyle(probe).marginTop);
|
|
2183
|
+
host.removeChild(probe);
|
|
2184
|
+
return value;
|
|
2185
|
+
};
|
|
2186
|
+
const resolveScrollContainer = (element, getScrollContainer) => {
|
|
2187
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2188
|
+
if (explicitContainer) {
|
|
2189
|
+
return explicitContainer;
|
|
2190
|
+
}
|
|
2191
|
+
let parent = element?.parentElement;
|
|
2192
|
+
while (parent) {
|
|
2193
|
+
const {
|
|
2194
|
+
overflowY
|
|
2195
|
+
} = getComputedStyle(parent);
|
|
2196
|
+
if (/(auto|scroll|overlay)/.test(overflowY) && parent.scrollHeight > parent.clientHeight + 1) {
|
|
2197
|
+
return parent;
|
|
2198
|
+
}
|
|
2199
|
+
parent = parent.parentElement;
|
|
2200
|
+
}
|
|
2201
|
+
return document.scrollingElement || document.documentElement;
|
|
2202
|
+
};
|
|
2203
|
+
const scrollToElement = (element, {
|
|
2204
|
+
offsetTop = 0,
|
|
2205
|
+
getScrollContainer
|
|
2206
|
+
} = {}) => {
|
|
2207
|
+
const scrollContainer = resolveScrollContainer(element, getScrollContainer);
|
|
2208
|
+
const targetRect = element.getBoundingClientRect();
|
|
2209
|
+
if (scrollContainer === document.scrollingElement || scrollContainer === document.documentElement || scrollContainer === document.body) {
|
|
2210
|
+
const scrollTop = window.pageYOffset + targetRect.top - offsetTop;
|
|
2211
|
+
window.scrollTo({
|
|
2212
|
+
top: Math.max(0, scrollTop),
|
|
2213
|
+
behavior: 'auto'
|
|
2214
|
+
});
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
2218
|
+
const nextScrollTop = scrollContainer.scrollTop + targetRect.top - containerRect.top - offsetTop;
|
|
2219
|
+
scrollContainer.scrollTo({
|
|
2220
|
+
top: Math.max(0, nextScrollTop),
|
|
2221
|
+
behavior: 'auto'
|
|
2222
|
+
});
|
|
2223
|
+
};
|
|
2224
|
+
const scrollAnchorIntoView = (root, {
|
|
2225
|
+
getScrollContainer,
|
|
2226
|
+
preferToolbar = false
|
|
2227
|
+
} = {}) => {
|
|
2228
|
+
const target = getScrollAnchorElement(root, {
|
|
2229
|
+
preferToolbar
|
|
2230
|
+
});
|
|
2231
|
+
if (!target) {
|
|
2232
|
+
return;
|
|
2233
|
+
}
|
|
2234
|
+
const offsetTop = readScrollTopInsetPixels(target);
|
|
2235
|
+
requestAnimationFrame(() => {
|
|
2236
|
+
requestAnimationFrame(() => {
|
|
2237
|
+
if (isTopEdgeInViewport(target, offsetTop, getScrollContainer)) {
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
scrollToElement(target, {
|
|
2241
|
+
offsetTop,
|
|
2242
|
+
getScrollContainer
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2245
|
+
});
|
|
2246
|
+
};
|
|
2247
|
+
const getTableScrollElement = root => {
|
|
2248
|
+
if (!root) {
|
|
2249
|
+
return null;
|
|
2250
|
+
}
|
|
2251
|
+
return root.querySelector('.ant-table-body') || root.querySelector('.ant-table-content');
|
|
2252
|
+
};
|
|
2253
|
+
const getElementViewportState = element => {
|
|
2254
|
+
if (!element) {
|
|
2255
|
+
return {
|
|
2256
|
+
isBottomInViewport: true,
|
|
2257
|
+
isPartiallyInViewport: false,
|
|
2258
|
+
isTopInViewport: true,
|
|
2259
|
+
rect: null,
|
|
2260
|
+
viewport: getViewportRect()
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
const rect = element.getBoundingClientRect();
|
|
2264
|
+
const viewport = getViewportRect();
|
|
2265
|
+
return {
|
|
2266
|
+
isBottomInViewport: rect.bottom > viewport.top && rect.bottom <= viewport.bottom,
|
|
2267
|
+
isPartiallyInViewport: rect.top < viewport.bottom && rect.bottom > viewport.top,
|
|
2268
|
+
isTopInViewport: rect.top >= viewport.top && rect.top < viewport.bottom,
|
|
2269
|
+
rect,
|
|
2270
|
+
viewport
|
|
2271
|
+
};
|
|
2272
|
+
};
|
|
2273
|
+
const isTopEdgeInViewport = (element, scrollMarginTop = 0, getScrollContainer) => {
|
|
2274
|
+
if (!element) {
|
|
2275
|
+
return true;
|
|
2276
|
+
}
|
|
2277
|
+
const rect = element.getBoundingClientRect();
|
|
2278
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2279
|
+
if (!isDocumentScrollContainer(explicitContainer)) {
|
|
2280
|
+
const containerRect = explicitContainer.getBoundingClientRect();
|
|
2281
|
+
const viewportTop = containerRect.top + scrollMarginTop;
|
|
2282
|
+
return rect.top >= viewportTop && rect.top < containerRect.bottom;
|
|
2283
|
+
}
|
|
2284
|
+
const {
|
|
2285
|
+
isTopInViewport,
|
|
2286
|
+
viewport
|
|
2287
|
+
} = getElementViewportState(element);
|
|
2288
|
+
if (!rect) {
|
|
2289
|
+
return true;
|
|
2290
|
+
}
|
|
2291
|
+
const viewportTop = viewport.top + scrollMarginTop;
|
|
2292
|
+
return rect.top >= viewportTop && rect.top < viewport.bottom;
|
|
2293
|
+
};
|
|
2294
|
+
const shouldShowFloatingScrollbar = (scrollEl, viewportState, getScrollContainer) => {
|
|
2295
|
+
if (!scrollEl || scrollEl.scrollWidth <= scrollEl.clientWidth + 1) {
|
|
2296
|
+
return false;
|
|
2297
|
+
}
|
|
2298
|
+
const explicitContainer = typeof getScrollContainer === 'function' ? getScrollContainer() : null;
|
|
2299
|
+
if (!isDocumentScrollContainer(explicitContainer)) {
|
|
2300
|
+
const rect = scrollEl.getBoundingClientRect();
|
|
2301
|
+
const containerRect = explicitContainer.getBoundingClientRect();
|
|
2302
|
+
return rect.top < containerRect.bottom && rect.bottom > containerRect.bottom;
|
|
2303
|
+
}
|
|
2304
|
+
const state = viewportState || getElementViewportState(scrollEl);
|
|
2305
|
+
if (!state.isPartiallyInViewport) {
|
|
2306
|
+
return false;
|
|
2307
|
+
}
|
|
2308
|
+
return !state.isBottomInViewport;
|
|
2309
|
+
};
|
|
2310
|
+
const observeViewportIntersection = (element, onChange) => {
|
|
2311
|
+
if (!element) {
|
|
2312
|
+
return () => {};
|
|
2313
|
+
}
|
|
2314
|
+
const notify = entry => {
|
|
2315
|
+
onChange(getElementViewportState(element));
|
|
2316
|
+
};
|
|
2317
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
2318
|
+
notify();
|
|
2319
|
+
}, {
|
|
2320
|
+
root: null,
|
|
2321
|
+
threshold: [0, 0.01, 0.25, 0.5, 0.75, 1]
|
|
2322
|
+
});
|
|
2323
|
+
observer.observe(element);
|
|
2324
|
+
const handleViewportChange = () => {
|
|
2325
|
+
notify();
|
|
2326
|
+
};
|
|
2327
|
+
window.addEventListener('scroll', handleViewportChange, true);
|
|
2328
|
+
window.addEventListener('resize', handleViewportChange);
|
|
2329
|
+
window.visualViewport?.addEventListener('resize', handleViewportChange);
|
|
2330
|
+
window.visualViewport?.addEventListener('scroll', handleViewportChange);
|
|
2331
|
+
notify();
|
|
2332
|
+
return () => {
|
|
2333
|
+
observer.disconnect();
|
|
2334
|
+
window.removeEventListener('scroll', handleViewportChange, true);
|
|
2335
|
+
window.removeEventListener('resize', handleViewportChange);
|
|
2336
|
+
window.visualViewport?.removeEventListener('resize', handleViewportChange);
|
|
2337
|
+
window.visualViewport?.removeEventListener('scroll', handleViewportChange);
|
|
2338
|
+
};
|
|
2339
|
+
};
|
|
2340
|
+
|
|
2341
|
+
const _excluded$2 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "name", "controllerOpen", "tableServerApis", "scroll", "summary"],
|
|
2098
2342
|
_excluded2$1 = ["getContainer"];
|
|
2099
2343
|
const mapJustifyToAlign = justify => {
|
|
2100
2344
|
if (justify === 'center') {
|
|
@@ -2163,6 +2407,7 @@ const Table = p => {
|
|
|
2163
2407
|
render = props.render,
|
|
2164
2408
|
context = props.context,
|
|
2165
2409
|
sticky = props.sticky,
|
|
2410
|
+
scrollTopInset = props.scrollTopInset,
|
|
2166
2411
|
stickyOffset = props.stickyOffset,
|
|
2167
2412
|
getStickyContainer = props.getStickyContainer,
|
|
2168
2413
|
headerStyle = props.headerStyle,
|
|
@@ -2413,6 +2658,20 @@ const Table = p => {
|
|
|
2413
2658
|
} : {}, scroll);
|
|
2414
2659
|
}, [hasFixedColumn, controllerOpen, totalWidth, tableWidth, scroll]);
|
|
2415
2660
|
const hasScrollY = (scroll == null ? void 0 : scroll.y) != null && (scroll == null ? void 0 : scroll.y) !== false;
|
|
2661
|
+
const isStickyViewport = !!sticky && !hasScrollY;
|
|
2662
|
+
const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
|
|
2663
|
+
const stickyGetContainer = react.useMemo(() => {
|
|
2664
|
+
if (!getStickyContainer || hasScrollY) {
|
|
2665
|
+
return undefined;
|
|
2666
|
+
}
|
|
2667
|
+
return () => getStickyContainer() || window;
|
|
2668
|
+
}, [getStickyContainer, hasScrollY]);
|
|
2669
|
+
const parsedScrollTopInset = react.useMemo(() => {
|
|
2670
|
+
if (!sticky || hasScrollY) {
|
|
2671
|
+
return 0;
|
|
2672
|
+
}
|
|
2673
|
+
return parseInsetPixels(resolvedScrollTopInset, tableRef.current);
|
|
2674
|
+
}, [sticky, hasScrollY, resolvedScrollTopInset, isLayout, dataSource]);
|
|
2416
2675
|
const antdSticky = react.useMemo(() => {
|
|
2417
2676
|
if (!sticky) {
|
|
2418
2677
|
return undefined;
|
|
@@ -2425,19 +2684,20 @@ const Table = p => {
|
|
|
2425
2684
|
}, scrollSticky);
|
|
2426
2685
|
}
|
|
2427
2686
|
return Object.assign({
|
|
2428
|
-
offsetHeader:
|
|
2429
|
-
}, config,
|
|
2430
|
-
getContainer:
|
|
2687
|
+
offsetHeader: parsedScrollTopInset
|
|
2688
|
+
}, config, stickyGetContainer ? {
|
|
2689
|
+
getContainer: stickyGetContainer
|
|
2431
2690
|
} : null);
|
|
2432
|
-
}, [sticky,
|
|
2691
|
+
}, [sticky, stickyGetContainer, hasScrollY, parsedScrollTopInset]);
|
|
2433
2692
|
const tableWrapperStyle = react.useMemo(() => {
|
|
2434
|
-
|
|
2693
|
+
const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
|
|
2694
|
+
if (!cssValue) {
|
|
2435
2695
|
return undefined;
|
|
2436
2696
|
}
|
|
2437
2697
|
return {
|
|
2438
|
-
'--
|
|
2698
|
+
'--scroll-top-inset': cssValue
|
|
2439
2699
|
};
|
|
2440
|
-
}, [
|
|
2700
|
+
}, [resolvedScrollTopInset]);
|
|
2441
2701
|
const tableElement = /*#__PURE__*/jsxRuntime.jsx(antd.Table, _extends({}, others, {
|
|
2442
2702
|
showHeader: true,
|
|
2443
2703
|
dataSource: dataSource,
|
|
@@ -2484,14 +2744,14 @@ const Table = p => {
|
|
|
2484
2744
|
}));
|
|
2485
2745
|
const wrappedTable = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2486
2746
|
ref: tableRef,
|
|
2487
|
-
className: classnames__default["default"](style$
|
|
2747
|
+
className: classnames__default["default"](style$4['table'], 'info-page-table', className, {
|
|
2488
2748
|
[style$4['is-resize']]: currentMoveColumnIndex !== null,
|
|
2489
2749
|
[style$4['is-computed']]: isLayout,
|
|
2490
2750
|
[style$4['has-group-header']]: hasGroupHeader,
|
|
2491
2751
|
[style$4['has-summary']]: typeof summary === 'function',
|
|
2492
2752
|
[style$4['is-sticky']]: !!sticky,
|
|
2493
2753
|
[style$4['is-sticky-scroll-y']]: !!sticky && hasScrollY,
|
|
2494
|
-
[style$4['is-sticky-viewport']]:
|
|
2754
|
+
[style$4['is-sticky-viewport']]: isStickyViewport
|
|
2495
2755
|
}),
|
|
2496
2756
|
style: tableWrapperStyle,
|
|
2497
2757
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -2879,121 +3139,16 @@ TableView.useSelectedRow = useSelectedRow;
|
|
|
2879
3139
|
TableView.useSort = useSort;
|
|
2880
3140
|
TableView.sortDataSource = useSort.sortDataSource;
|
|
2881
3141
|
|
|
2882
|
-
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"};
|
|
2883
|
-
|
|
2884
|
-
const parsePixelValue = value => {
|
|
2885
|
-
const num = parseFloat(value);
|
|
2886
|
-
return Number.isNaN(num) ? 0 : num;
|
|
2887
|
-
};
|
|
2888
|
-
const getViewportRect = () => {
|
|
2889
|
-
const visualViewport = window.visualViewport;
|
|
2890
|
-
if (visualViewport) {
|
|
2891
|
-
return {
|
|
2892
|
-
top: visualViewport.offsetTop,
|
|
2893
|
-
bottom: visualViewport.offsetTop + visualViewport.height,
|
|
2894
|
-
left: visualViewport.offsetLeft,
|
|
2895
|
-
right: visualViewport.offsetLeft + visualViewport.width,
|
|
2896
|
-
height: visualViewport.height
|
|
2897
|
-
};
|
|
2898
|
-
}
|
|
2899
|
-
return {
|
|
2900
|
-
top: 0,
|
|
2901
|
-
bottom: window.innerHeight,
|
|
2902
|
-
left: 0,
|
|
2903
|
-
right: window.innerWidth,
|
|
2904
|
-
height: window.innerHeight
|
|
2905
|
-
};
|
|
2906
|
-
};
|
|
2907
|
-
const getTableElement = root => {
|
|
2908
|
-
if (!root) {
|
|
2909
|
-
return null;
|
|
2910
|
-
}
|
|
2911
|
-
return root.querySelector('.info-page-table') || root;
|
|
2912
|
-
};
|
|
2913
|
-
const getTableScrollElement = root => {
|
|
2914
|
-
if (!root) {
|
|
2915
|
-
return null;
|
|
2916
|
-
}
|
|
2917
|
-
return root.querySelector('.ant-table-body') || root.querySelector('.ant-table-content');
|
|
2918
|
-
};
|
|
2919
|
-
const getElementViewportState = element => {
|
|
2920
|
-
if (!element) {
|
|
2921
|
-
return {
|
|
2922
|
-
isBottomInViewport: true,
|
|
2923
|
-
isPartiallyInViewport: false,
|
|
2924
|
-
isTopInViewport: true,
|
|
2925
|
-
rect: null,
|
|
2926
|
-
viewport: getViewportRect()
|
|
2927
|
-
};
|
|
2928
|
-
}
|
|
2929
|
-
const rect = element.getBoundingClientRect();
|
|
2930
|
-
const viewport = getViewportRect();
|
|
2931
|
-
return {
|
|
2932
|
-
isBottomInViewport: rect.bottom > viewport.top && rect.bottom <= viewport.bottom,
|
|
2933
|
-
isPartiallyInViewport: rect.top < viewport.bottom && rect.bottom > viewport.top,
|
|
2934
|
-
isTopInViewport: rect.top >= viewport.top && rect.top < viewport.bottom,
|
|
2935
|
-
rect,
|
|
2936
|
-
viewport
|
|
2937
|
-
};
|
|
2938
|
-
};
|
|
2939
|
-
const isTopEdgeInViewport = (element, scrollMarginTop = 0) => {
|
|
2940
|
-
const {
|
|
2941
|
-
isTopInViewport,
|
|
2942
|
-
rect,
|
|
2943
|
-
viewport
|
|
2944
|
-
} = getElementViewportState(element);
|
|
2945
|
-
if (!rect) {
|
|
2946
|
-
return true;
|
|
2947
|
-
}
|
|
2948
|
-
const viewportTop = viewport.top + scrollMarginTop;
|
|
2949
|
-
return rect.top >= viewportTop && rect.top < viewport.bottom;
|
|
2950
|
-
};
|
|
2951
|
-
const shouldShowFloatingScrollbar = (scrollEl, viewportState) => {
|
|
2952
|
-
if (!scrollEl || scrollEl.scrollWidth <= scrollEl.clientWidth + 1) {
|
|
2953
|
-
return false;
|
|
2954
|
-
}
|
|
2955
|
-
const state = viewportState || getElementViewportState(scrollEl);
|
|
2956
|
-
if (!state.isPartiallyInViewport) {
|
|
2957
|
-
return false;
|
|
2958
|
-
}
|
|
2959
|
-
return !state.isBottomInViewport;
|
|
2960
|
-
};
|
|
2961
|
-
const observeViewportIntersection = (element, onChange) => {
|
|
2962
|
-
if (!element) {
|
|
2963
|
-
return () => {};
|
|
2964
|
-
}
|
|
2965
|
-
const notify = entry => {
|
|
2966
|
-
onChange(getElementViewportState(element));
|
|
2967
|
-
};
|
|
2968
|
-
const observer = new IntersectionObserver(([entry]) => {
|
|
2969
|
-
notify();
|
|
2970
|
-
}, {
|
|
2971
|
-
root: null,
|
|
2972
|
-
threshold: [0, 0.01, 0.25, 0.5, 0.75, 1]
|
|
2973
|
-
});
|
|
2974
|
-
observer.observe(element);
|
|
2975
|
-
const handleViewportChange = () => {
|
|
2976
|
-
notify();
|
|
2977
|
-
};
|
|
2978
|
-
window.addEventListener('scroll', handleViewportChange, true);
|
|
2979
|
-
window.addEventListener('resize', handleViewportChange);
|
|
2980
|
-
window.visualViewport?.addEventListener('resize', handleViewportChange);
|
|
2981
|
-
window.visualViewport?.addEventListener('scroll', handleViewportChange);
|
|
2982
|
-
notify();
|
|
2983
|
-
return () => {
|
|
2984
|
-
observer.disconnect();
|
|
2985
|
-
window.removeEventListener('scroll', handleViewportChange, true);
|
|
2986
|
-
window.removeEventListener('resize', handleViewportChange);
|
|
2987
|
-
window.visualViewport?.removeEventListener('resize', handleViewportChange);
|
|
2988
|
-
window.visualViewport?.removeEventListener('scroll', handleViewportChange);
|
|
2989
|
-
};
|
|
2990
|
-
};
|
|
3142
|
+
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"};
|
|
2991
3143
|
|
|
2992
3144
|
const BAR_HEIGHT = 15;
|
|
2993
3145
|
const THUMB_MARGIN = 2;
|
|
2994
|
-
const computeBarMetrics = (scrollEl, viewportState) => {
|
|
3146
|
+
const computeBarMetrics = (scrollEl, viewportState, getPortalContainer) => {
|
|
2995
3147
|
const rect = scrollEl.getBoundingClientRect();
|
|
3148
|
+
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
3149
|
+
const useContainerScroll = !isDocumentScrollContainer(portalContainer);
|
|
2996
3150
|
const viewport = getViewportRect();
|
|
3151
|
+
const anchorRect = useContainerScroll ? portalContainer.getBoundingClientRect() : viewport;
|
|
2997
3152
|
const trackWidth = rect.width;
|
|
2998
3153
|
const thumbWidth = Math.max(trackWidth * scrollEl.clientWidth / scrollEl.scrollWidth - THUMB_MARGIN * 2, 24);
|
|
2999
3154
|
const maxThumbOffset = trackWidth - thumbWidth - THUMB_MARGIN * 2;
|
|
@@ -3001,10 +3156,10 @@ const computeBarMetrics = (scrollEl, viewportState) => {
|
|
|
3001
3156
|
return {
|
|
3002
3157
|
left: rect.left,
|
|
3003
3158
|
width: trackWidth,
|
|
3004
|
-
bottom: window.innerHeight -
|
|
3159
|
+
bottom: window.innerHeight - anchorRect.bottom,
|
|
3005
3160
|
thumbWidth,
|
|
3006
3161
|
thumbLeft: THUMB_MARGIN + maxThumbOffset * scrollRatio,
|
|
3007
|
-
visible: shouldShowFloatingScrollbar(scrollEl, viewportState)
|
|
3162
|
+
visible: shouldShowFloatingScrollbar(scrollEl, viewportState, getPortalContainer)
|
|
3008
3163
|
};
|
|
3009
3164
|
};
|
|
3010
3165
|
const FloatingScrollBar = ({
|
|
@@ -3041,7 +3196,7 @@ const FloatingScrollBar = ({
|
|
|
3041
3196
|
if (!metrics?.visible) {
|
|
3042
3197
|
return null;
|
|
3043
3198
|
}
|
|
3044
|
-
const portalTarget =
|
|
3199
|
+
const portalTarget = document.body;
|
|
3045
3200
|
return /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3046
3201
|
className: classnames__default["default"](style$1['floating-scrollbar'], 'table-page-floating-scrollbar'),
|
|
3047
3202
|
style: {
|
|
@@ -3090,7 +3245,7 @@ const HorizontalScroller = /*#__PURE__*/react.forwardRef(({
|
|
|
3090
3245
|
setMetrics(null);
|
|
3091
3246
|
return;
|
|
3092
3247
|
}
|
|
3093
|
-
setMetrics(computeBarMetrics(scrollEl, viewportStateRef.current));
|
|
3248
|
+
setMetrics(computeBarMetrics(scrollEl, viewportStateRef.current, getPortalContainer));
|
|
3094
3249
|
});
|
|
3095
3250
|
const handleThumbDrag = useRefCallback__default["default"](deltaX => {
|
|
3096
3251
|
const scrollEl = scrollElRef.current;
|
|
@@ -3161,11 +3316,18 @@ const HorizontalScroller = /*#__PURE__*/react.forwardRef(({
|
|
|
3161
3316
|
const containerResizeObserver = new ResizeObserver(onLayoutChange);
|
|
3162
3317
|
containerResizeObserver.observe(root);
|
|
3163
3318
|
onLayoutChange();
|
|
3319
|
+
const portalContainer = typeof getPortalContainer === 'function' ? getPortalContainer() : null;
|
|
3320
|
+
if (!isDocumentScrollContainer(portalContainer)) {
|
|
3321
|
+
portalContainer.addEventListener('scroll', updateMetrics, {
|
|
3322
|
+
passive: true
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3164
3325
|
return () => {
|
|
3165
3326
|
detachScrollEl();
|
|
3166
3327
|
containerResizeObserver.disconnect();
|
|
3328
|
+
portalContainer?.removeEventListener('scroll', updateMetrics);
|
|
3167
3329
|
};
|
|
3168
|
-
}, [enabled, updateMetrics]);
|
|
3330
|
+
}, [enabled, updateMetrics, getPortalContainer]);
|
|
3169
3331
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3170
3332
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3171
3333
|
ref: setContainerRef,
|
|
@@ -3256,7 +3418,7 @@ const TableToolbar = ({
|
|
|
3256
3418
|
'table-page-toolbar-section--has-value': hasValueDisplay
|
|
3257
3419
|
}),
|
|
3258
3420
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3259
|
-
className: style['table-toolbar'],
|
|
3421
|
+
className: classnames__default["default"](style['table-toolbar'], 'table-page-toolbar'),
|
|
3260
3422
|
children: [showBatch ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
3261
3423
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
3262
3424
|
className: style['table-toolbar-batch'],
|
|
@@ -3323,7 +3485,7 @@ const TableToolbar = ({
|
|
|
3323
3485
|
});
|
|
3324
3486
|
};
|
|
3325
3487
|
|
|
3326
|
-
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"],
|
|
3488
|
+
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"],
|
|
3327
3489
|
_excluded2 = ["pagination", "horizontalScroller", "getScrollContainer"];
|
|
3328
3490
|
const readPageSize = key => {
|
|
3329
3491
|
try {
|
|
@@ -3344,27 +3506,6 @@ const writePageSize = (key, size) => {
|
|
|
3344
3506
|
// ignore quota errors
|
|
3345
3507
|
}
|
|
3346
3508
|
};
|
|
3347
|
-
const isTableTopInViewport = target => {
|
|
3348
|
-
const scrollMarginTop = parsePixelValue(getComputedStyle(target).scrollMarginTop);
|
|
3349
|
-
return isTopEdgeInViewport(target, scrollMarginTop);
|
|
3350
|
-
};
|
|
3351
|
-
const scrollTableIntoView = root => {
|
|
3352
|
-
const target = getTableElement(root);
|
|
3353
|
-
if (!target) {
|
|
3354
|
-
return;
|
|
3355
|
-
}
|
|
3356
|
-
requestAnimationFrame(() => {
|
|
3357
|
-
requestAnimationFrame(() => {
|
|
3358
|
-
if (isTableTopInViewport(target)) {
|
|
3359
|
-
return;
|
|
3360
|
-
}
|
|
3361
|
-
target.scrollIntoView({
|
|
3362
|
-
block: 'start',
|
|
3363
|
-
inline: 'nearest'
|
|
3364
|
-
});
|
|
3365
|
-
});
|
|
3366
|
-
});
|
|
3367
|
-
};
|
|
3368
3509
|
const TABLE_COMPONENTS = {
|
|
3369
3510
|
Table,
|
|
3370
3511
|
TableView
|
|
@@ -3424,6 +3565,8 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3424
3565
|
columnRenderProps = _ref$columnRenderProp === void 0 ? {} : _ref$columnRenderProp,
|
|
3425
3566
|
summary = _ref.summary,
|
|
3426
3567
|
sticky = _ref.sticky,
|
|
3568
|
+
scrollTopInset = _ref.scrollTopInset,
|
|
3569
|
+
stickyOffset = _ref.stickyOffset,
|
|
3427
3570
|
_ref$renderType = _ref.renderType,
|
|
3428
3571
|
renderType = _ref$renderType === void 0 ? 'Table' : _ref$renderType,
|
|
3429
3572
|
_ref$horizontalScroll = _ref.horizontalScroller,
|
|
@@ -3471,8 +3614,22 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3471
3614
|
dataFormat,
|
|
3472
3615
|
pagination
|
|
3473
3616
|
}), [data, fetchProps, requestParams, refresh, reload, loadMore, send, dataFormat, pagination]);
|
|
3617
|
+
const hasToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
|
|
3618
|
+
const resolvedScrollTopInset = resolveScrollTopInset(scrollTopInset, stickyOffset);
|
|
3619
|
+
const scrollTopInsetStyle = react.useMemo(() => {
|
|
3620
|
+
const cssValue = normalizeScrollTopInsetCSSValue(resolvedScrollTopInset);
|
|
3621
|
+
if (!cssValue) {
|
|
3622
|
+
return undefined;
|
|
3623
|
+
}
|
|
3624
|
+
return {
|
|
3625
|
+
'--scroll-top-inset': cssValue
|
|
3626
|
+
};
|
|
3627
|
+
}, [resolvedScrollTopInset]);
|
|
3474
3628
|
const scrollTable = useRefCallback__default["default"](() => {
|
|
3475
|
-
|
|
3629
|
+
scrollAnchorIntoView(tableContentRef.current, {
|
|
3630
|
+
getScrollContainer,
|
|
3631
|
+
preferToolbar: hasToolbar
|
|
3632
|
+
});
|
|
3476
3633
|
});
|
|
3477
3634
|
const handleFilterChange = useRefCallback__default["default"](value => {
|
|
3478
3635
|
if (!isFilterControlled) {
|
|
@@ -3526,7 +3683,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3526
3683
|
})]
|
|
3527
3684
|
}),
|
|
3528
3685
|
current: get__default["default"](requestParams, [pagination.paramsType, pagination.currentName], 1),
|
|
3529
|
-
pageSize: Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize ||
|
|
3686
|
+
pageSize: Number(get__default["default"](requestParams, [pagination.paramsType, pagination.pageSizeName], pagination.pageSize)) || pagination.pageSize || 50,
|
|
3530
3687
|
onChange: handlePaginationChange,
|
|
3531
3688
|
size: pagination.size,
|
|
3532
3689
|
hideOnSinglePage: pagination.hideOnSinglePage,
|
|
@@ -3535,7 +3692,6 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3535
3692
|
pageSizeOptions: pagination.pageSizeOptions
|
|
3536
3693
|
};
|
|
3537
3694
|
}, [pagination, formatData.total, requestParams, formatMessage, handlePaginationChange]);
|
|
3538
|
-
const hasToolbar = !!(filter != null && (_filter$list = filter.list) != null && _filter$list.length || search && search.name || batchActions && batchActions.length);
|
|
3539
3695
|
const batchContext = react.useMemo(() => ({
|
|
3540
3696
|
data,
|
|
3541
3697
|
fetchProps,
|
|
@@ -3557,6 +3713,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3557
3713
|
dataSource: formatData.list,
|
|
3558
3714
|
pagination: false,
|
|
3559
3715
|
sticky,
|
|
3716
|
+
scrollTopInset: resolvedScrollTopInset,
|
|
3560
3717
|
getStickyContainer: getScrollContainer,
|
|
3561
3718
|
className: classnames__default["default"](className, {
|
|
3562
3719
|
[style$1['table-in-toolbar']]: hasToolbar
|
|
@@ -3574,6 +3731,7 @@ const TablePageInnerContent = withLocale(_ref => {
|
|
|
3574
3731
|
const tableElement = /*#__PURE__*/jsxRuntime.jsx(TableComponent, _extends({}, tableProps));
|
|
3575
3732
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
3576
3733
|
className: style$1['table-page'],
|
|
3734
|
+
style: scrollTopInsetStyle,
|
|
3577
3735
|
children: [/*#__PURE__*/jsxRuntime.jsx(HorizontalScroller, {
|
|
3578
3736
|
ref: tableContentRef,
|
|
3579
3737
|
enabled: horizontalScroller && renderType === 'Table',
|
|
@@ -3615,12 +3773,13 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3615
3773
|
requestType: 'reload',
|
|
3616
3774
|
currentName: 'currentPage',
|
|
3617
3775
|
pageSizeName: 'perPage',
|
|
3618
|
-
pageSize:
|
|
3776
|
+
pageSize: 50
|
|
3619
3777
|
}, pagination);
|
|
3620
3778
|
const pageSizeKey = (props.name || 'common').toUpperCase() + "_TABLE_PAGE_SIZE";
|
|
3779
|
+
const cachePageSize = pagination.cachePageSize !== false;
|
|
3621
3780
|
const _useState2 = react.useState(() => {
|
|
3622
|
-
var
|
|
3623
|
-
return (
|
|
3781
|
+
var _ref3;
|
|
3782
|
+
return (_ref3 = cachePageSize ? readPageSize(pageSizeKey) : null) != null ? _ref3 : pagination.pageSize;
|
|
3624
3783
|
}),
|
|
3625
3784
|
pageSize = _useState2[0],
|
|
3626
3785
|
setPageSize = _useState2[1];
|
|
@@ -3647,7 +3806,9 @@ const TablePage = /*#__PURE__*/react.forwardRef((_ref2, ref) => {
|
|
|
3647
3806
|
pageSize,
|
|
3648
3807
|
onShowSizeChange: (current, size) => {
|
|
3649
3808
|
const nextSize = Number(size);
|
|
3650
|
-
|
|
3809
|
+
if (cachePageSize) {
|
|
3810
|
+
writePageSize(pageSizeKey, nextSize);
|
|
3811
|
+
}
|
|
3651
3812
|
setPageSize(nextSize);
|
|
3652
3813
|
}
|
|
3653
3814
|
}),
|