beautiful-grid 1.0.2 → 1.0.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 +1 -1
- package/cjs/BGrid.js +2 -2
- package/cjs/components/Table.js +204 -147
- package/cjs/components/selection/CellSelectionOverlayLayer.js +5 -5
- package/cjs/utils/coordinate.js +10 -10
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/virtualScrollWindow.js +67 -0
- package/esm/BGrid.js +2 -2
- package/esm/components/Table.js +163 -109
- package/esm/components/selection/CellSelectionOverlayLayer.js +5 -5
- package/esm/utils/coordinate.js +4 -4
- package/esm/utils/index.js +1 -0
- package/esm/utils/virtualScrollWindow.js +59 -0
- package/package.json +1 -1
- package/types/BGrid.d.ts +1 -1
- package/types/components/Table.d.ts +1 -0
- package/types/components/selection/CellSelectionOverlay.d.ts +1 -0
- package/types/components/selection/CellSelectionOverlayLayer.d.ts +2 -1
- package/types/types.d.ts +13 -0
- package/types/utils/coordinate.d.ts +5 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/virtualScrollWindow.d.ts +24 -0
package/cjs/components/Table.js
CHANGED
|
@@ -164,11 +164,11 @@ var LazyGridOptionalSurfaces = React.lazy(function () {
|
|
|
164
164
|
});
|
|
165
165
|
function Table(props) {
|
|
166
166
|
var _this = this;
|
|
167
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
167
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
168
168
|
var cellSelectionOptions = props.cellSelectionOptions, onChangeData = props.onChangeData, sourceIndexByVisibleIndex = props.sourceIndexByVisibleIndex;
|
|
169
169
|
var cellSelectionEnabled = (_a = cellSelectionOptions === null || cellSelectionOptions === void 0 ? void 0 : cellSelectionOptions.enabled) !== null && _a !== void 0 ? _a : true;
|
|
170
170
|
// [Selector Group 1] Layout & Dimensions - 레이아웃 차원
|
|
171
|
-
var
|
|
171
|
+
var _6 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
172
172
|
width: s.width,
|
|
173
173
|
height: s.height,
|
|
174
174
|
containerBorderWidth: s.containerBorderWidth,
|
|
@@ -176,30 +176,30 @@ function Table(props) {
|
|
|
176
176
|
style: s.style,
|
|
177
177
|
itemHeight: s.itemHeight,
|
|
178
178
|
itemPadding: s.itemPadding,
|
|
179
|
-
}); })), width =
|
|
179
|
+
}); })), width = _6.width, height = _6.height, containerBorderWidth = _6.containerBorderWidth, className = _6.className, style = _6.style, itemHeight = _6.itemHeight, itemPadding = _6.itemPadding;
|
|
180
180
|
// [Selector Group 2] Header, Footer, Summary - 헤더/푸터/요약
|
|
181
|
-
var
|
|
181
|
+
var _7 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
182
182
|
headerHeight: s.headerHeight,
|
|
183
183
|
footerHeight: s.footerHeight,
|
|
184
184
|
bottomBarHeight: s.bottomBarHeight,
|
|
185
185
|
summaryHeight: s.summaryHeight,
|
|
186
|
-
}); })), headerHeight =
|
|
186
|
+
}); })), headerHeight = _7.headerHeight, footerHeight = _7.footerHeight, bottomBarHeight = _7.bottomBarHeight, summaryHeight = _7.summaryHeight;
|
|
187
187
|
// [Selector Group 3] Scroll State - 스크롤 상태
|
|
188
|
-
var
|
|
188
|
+
var _8 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
189
189
|
scrollLeft: s.scrollLeft,
|
|
190
190
|
scrollTop: s.scrollTop,
|
|
191
|
-
}); })), scrollLeft =
|
|
191
|
+
}); })), scrollLeft = _8.scrollLeft, scrollTop = _8.scrollTop;
|
|
192
192
|
// [Selector Group 4] Content, Columns, Data - 컨텐츠 관련
|
|
193
|
-
var
|
|
193
|
+
var _9 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
194
194
|
contentBodyHeight: s.contentBodyHeight,
|
|
195
195
|
columns: s.columns,
|
|
196
196
|
data: s.data,
|
|
197
197
|
frozenColumnsWidth: s.frozenColumnsWidth,
|
|
198
198
|
frozenRowCount: s.frozenRowCount,
|
|
199
199
|
frozenRowsHeight: s.frozenRowsHeight,
|
|
200
|
-
}); })), contentBodyHeight =
|
|
200
|
+
}); })), contentBodyHeight = _9.contentBodyHeight, columns = _9.columns, data = _9.data, frozenColumnsWidth = _9.frozenColumnsWidth, frozenRowCount = _9.frozenRowCount, frozenRowsHeight = _9.frozenRowsHeight;
|
|
201
201
|
// [Selector Group 4-1] Cell selection & navigation - 셀 선택 및 내비게이션
|
|
202
|
-
var
|
|
202
|
+
var _10 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
203
203
|
cellSelectionRange: s.cellSelectionRange,
|
|
204
204
|
cellSelectionRanges: s.cellSelectionRanges,
|
|
205
205
|
activeCell: s.activeCell,
|
|
@@ -208,9 +208,9 @@ function Table(props) {
|
|
|
208
208
|
editItemIndex: s.editItemIndex,
|
|
209
209
|
editable: s.editable,
|
|
210
210
|
handleClick: s.handleClick,
|
|
211
|
-
}); })), cellSelectionRange =
|
|
211
|
+
}); })), cellSelectionRange = _10.cellSelectionRange, cellSelectionRanges = _10.cellSelectionRanges, activeCell = _10.activeCell, activeCellHost = _10.activeCellHost, cellNavigationOptions = _10.cellNavigationOptions, editItemIndex = _10.editItemIndex, editable = _10.editable, handleClick = _10.handleClick;
|
|
212
212
|
// [Selector Group 5] State - 상태
|
|
213
|
-
var
|
|
213
|
+
var _11 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
214
214
|
rowChecked: s.rowChecked,
|
|
215
215
|
page: s.page,
|
|
216
216
|
loading: s.loading,
|
|
@@ -220,8 +220,8 @@ function Table(props) {
|
|
|
220
220
|
scrollbar: s.scrollbar,
|
|
221
221
|
status: s.status,
|
|
222
222
|
pagination: s.pagination,
|
|
223
|
-
}); })), rowChecked =
|
|
224
|
-
var
|
|
223
|
+
}); })), rowChecked = _11.rowChecked, page = _11.page, loading = _11.loading, spinning = _11.spinning, showLineNumber = _11.showLineNumber, summary = _11.summary, scrollbar = _11.scrollbar, status = _11.status, pagination = _11.pagination;
|
|
224
|
+
var _12 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
225
225
|
searchOpen: s.searchOpen,
|
|
226
226
|
searchOptions: s.searchOptions,
|
|
227
227
|
contextMenuOptions: s.contextMenuOptions,
|
|
@@ -230,9 +230,9 @@ function Table(props) {
|
|
|
230
230
|
storeSourceIndexByVisibleIndex: s.sourceIndexByVisibleIndex,
|
|
231
231
|
storeRowKey: s.rowKey,
|
|
232
232
|
cellInteractionSession: s.cellInteractionSession,
|
|
233
|
-
}); })), searchOpen =
|
|
233
|
+
}); })), searchOpen = _12.searchOpen, searchOptions = _12.searchOptions, contextMenuOptions = _12.contextMenuOptions, activeSearchMatchIndex = _12.activeSearchMatchIndex, searchMatches = _12.searchMatches, storeSourceIndexByVisibleIndex = _12.storeSourceIndexByVisibleIndex, storeRowKey = _12.storeRowKey, cellInteractionSession = _12.cellInteractionSession;
|
|
234
234
|
// [Selector Group 6] State Setters - 차원 설정자
|
|
235
|
-
var
|
|
235
|
+
var _13 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
236
236
|
setHeight: s.setHeight,
|
|
237
237
|
setWidth: s.setWidth,
|
|
238
238
|
setContentBodyHeight: s.setContentBodyHeight,
|
|
@@ -245,9 +245,9 @@ function Table(props) {
|
|
|
245
245
|
setItemPadding: s.setItemPadding,
|
|
246
246
|
setLoading: s.setLoading,
|
|
247
247
|
setSpinning: s.setSpinning,
|
|
248
|
-
}); })), setHeight =
|
|
248
|
+
}); })), setHeight = _13.setHeight, setWidth = _13.setWidth, setContentBodyHeight = _13.setContentBodyHeight, setDisplayItemCount = _13.setDisplayItemCount, setHeaderHeight = _13.setHeaderHeight, setFooterHeight = _13.setFooterHeight, setBottomBarHeight = _13.setBottomBarHeight, setSummaryHeight = _13.setSummaryHeight, setItemHeight = _13.setItemHeight, setItemPadding = _13.setItemPadding, setLoading = _13.setLoading, setSpinning = _13.setSpinning;
|
|
249
249
|
// [Selector Group 7] Data & Column Setters - 데이터/열 설정자
|
|
250
|
-
var
|
|
250
|
+
var _14 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
251
251
|
setData: s.setData,
|
|
252
252
|
setSourceData: s.setSourceData,
|
|
253
253
|
setProcessedData: s.setProcessedData,
|
|
@@ -258,9 +258,9 @@ function Table(props) {
|
|
|
258
258
|
setFrozenColumnIndex: s.setFrozenColumnIndex,
|
|
259
259
|
setFrozenRowCount: s.setFrozenRowCount,
|
|
260
260
|
setFrozenRowsHeight: s.setFrozenRowsHeight,
|
|
261
|
-
}); })), setData =
|
|
261
|
+
}); })), setData = _14.setData, setSourceData = _14.setSourceData, setProcessedData = _14.setProcessedData, setColumns = _14.setColumns, setColumnsGroup = _14.setColumnsGroup, setColumnGroups = _14.setColumnGroups, setFrozenColumnsWidth = _14.setFrozenColumnsWidth, setFrozenColumnIndex = _14.setFrozenColumnIndex, setFrozenRowCount = _14.setFrozenRowCount, setFrozenRowsHeight = _14.setFrozenRowsHeight;
|
|
262
262
|
// [Selector Group 8] Row & Sort Setters - 행/정렬 설정자
|
|
263
|
-
var
|
|
263
|
+
var _15 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
264
264
|
setRowChecked: s.setRowChecked,
|
|
265
265
|
setCheckedIndexesMap: s.setCheckedIndexesMap,
|
|
266
266
|
setSort: s.setSort,
|
|
@@ -277,9 +277,9 @@ function Table(props) {
|
|
|
277
277
|
requestSearchOpen: s.requestSearchOpen,
|
|
278
278
|
openContextMenu: s.openContextMenu,
|
|
279
279
|
commitCheckboxCell: s.commitCheckboxCell,
|
|
280
|
-
}); })), setRowChecked =
|
|
280
|
+
}); })), setRowChecked = _15.setRowChecked, setCheckedIndexesMap = _15.setCheckedIndexesMap, setSort = _15.setSort, setSortParams = _15.setSortParams, setDataQuery = _15.setDataQuery, setDataControl = _15.setDataControl, setIcons = _15.setIcons, setActiveToolbox = _15.setActiveToolbox, setRowKey = _15.setRowKey, setFocusedRowKey = _15.setFocusedRowKey, setEditItem = _15.setEditItem, setSearchOptions = _15.setSearchOptions, setContextMenuOptions = _15.setContextMenuOptions, requestSearchOpen = _15.requestSearchOpen, openContextMenu = _15.openContextMenu, commitCheckboxCell = _15.commitCheckboxCell;
|
|
281
281
|
// [Selector Group 9] Pagination & Display Setters - 페이지/표시 설정자
|
|
282
|
-
var
|
|
282
|
+
var _16 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
283
283
|
setPage: s.setPage,
|
|
284
284
|
setDisplayPaginationLength: s.setDisplayPaginationLength,
|
|
285
285
|
setShowLineNumber: s.setShowLineNumber,
|
|
@@ -295,9 +295,9 @@ function Table(props) {
|
|
|
295
295
|
setScrollbar: s.setScrollbar,
|
|
296
296
|
setStatus: s.setStatus,
|
|
297
297
|
setPagination: s.setPagination,
|
|
298
|
-
}); })), setPage =
|
|
298
|
+
}); })), setPage = _16.setPage, setDisplayPaginationLength = _16.setDisplayPaginationLength, setShowLineNumber = _16.setShowLineNumber, setMsg = _16.setMsg, setRowClassName = _16.setRowClassName, setCellMergeOptions = _16.setCellMergeOptions, setVariant = _16.setVariant, setSummary = _16.setSummary, setColumnSortable = _16.setColumnSortable, setReorder = _16.setReorder, setClassName = _16.setClassName, setStyle = _16.setStyle, setScrollbar = _16.setScrollbar, setStatus = _16.setStatus, setPagination = _16.setPagination;
|
|
299
299
|
// [Selector Group 10] Edit & Event Setters - 편집/이벤트 설정자
|
|
300
|
-
var
|
|
300
|
+
var _17 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
301
301
|
setEditable: s.setEditable,
|
|
302
302
|
setEditTrigger: s.setEditTrigger,
|
|
303
303
|
setOnClick: s.setOnClick,
|
|
@@ -306,8 +306,8 @@ function Table(props) {
|
|
|
306
306
|
setOnLoadMore: s.setOnLoadMore,
|
|
307
307
|
setScroll: s.setScroll,
|
|
308
308
|
setInitialized: s.setInitialized,
|
|
309
|
-
}); })), setEditable =
|
|
310
|
-
var
|
|
309
|
+
}); })), setEditable = _17.setEditable, setEditTrigger = _17.setEditTrigger, setOnClick = _17.setOnClick, setOnChangeColumns = _17.setOnChangeColumns, setOnChangeData = _17.setOnChangeData, setOnLoadMore = _17.setOnLoadMore, setScroll = _17.setScroll, setInitialized = _17.setInitialized;
|
|
310
|
+
var _18 = (0, store_1.useAppStore)((0, shallow_1.useShallow)(function (s) { return ({
|
|
311
311
|
setCellSelectionRanges: s.setCellSelectionRanges,
|
|
312
312
|
setCellSelecting: s.setCellSelecting,
|
|
313
313
|
clearCellSelection: s.clearCellSelection,
|
|
@@ -315,10 +315,29 @@ function Table(props) {
|
|
|
315
315
|
moveActiveCell: s.moveActiveCell,
|
|
316
316
|
setCellNavigationOptions: s.setCellNavigationOptions,
|
|
317
317
|
syncActiveCellToBounds: s.syncActiveCellToBounds,
|
|
318
|
-
}); })), setCellSelectionRanges =
|
|
318
|
+
}); })), setCellSelectionRanges = _18.setCellSelectionRanges, setCellSelecting = _18.setCellSelecting, clearCellSelection = _18.clearCellSelection, setActiveCell = _18.setActiveCell, moveActiveCell = _18.moveActiveCell, setCellNavigationOptions = _18.setCellNavigationOptions, syncActiveCellToBounds = _18.syncActiveCellToBounds;
|
|
319
319
|
var trHeight = itemHeight + itemPadding * 2;
|
|
320
320
|
var scrollableBodyHeight = Math.max(contentBodyHeight - frozenRowsHeight, 0);
|
|
321
321
|
var mainViewportWidth = Math.max(width - (frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0), 0);
|
|
322
|
+
var logicalBodyContentHeight = data.length * trHeight;
|
|
323
|
+
var virtualScrollWindowMetrics = React.useMemo(function () {
|
|
324
|
+
return (0, utils_1.getVirtualScrollWindowMetrics)({
|
|
325
|
+
logicalContentHeight: logicalBodyContentHeight,
|
|
326
|
+
viewportHeight: contentBodyHeight,
|
|
327
|
+
enabled: scrollbar.variant !== 'native',
|
|
328
|
+
});
|
|
329
|
+
}, [contentBodyHeight, logicalBodyContentHeight, scrollbar.variant]);
|
|
330
|
+
var _19 = __read(React.useState(0), 2), virtualScrollBase = _19[0], setVirtualScrollBase = _19[1];
|
|
331
|
+
var virtualScrollBaseRef = (0, react_1.useRef)(0);
|
|
332
|
+
var containerRef = (0, react_1.useRef)(null);
|
|
333
|
+
var searchPopoverRef = (0, react_1.useRef)(null);
|
|
334
|
+
var editorPortalRef = (0, react_1.useRef)(null);
|
|
335
|
+
var bodyContainerRef = (0, react_1.useRef)(null);
|
|
336
|
+
var scrollContainerRef = (0, react_1.useRef)(null);
|
|
337
|
+
var logicalVerticalScrollState = React.useMemo(function () { return ({
|
|
338
|
+
scrollTop: scrollTop,
|
|
339
|
+
scrollHeight: virtualScrollWindowMetrics.logicalContentHeight,
|
|
340
|
+
}); }, [scrollTop, virtualScrollWindowMetrics.logicalContentHeight]);
|
|
322
341
|
var hasMultiCellSelection = React.useMemo(function () {
|
|
323
342
|
return cellSelectionRanges.length > 1 ||
|
|
324
343
|
cellSelectionRanges.some(function (range) {
|
|
@@ -418,7 +437,7 @@ function Table(props) {
|
|
|
418
437
|
top: topQuadrant ? 0 : scrollTop,
|
|
419
438
|
width: leftQuadrant ? frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0 : mainViewportWidth,
|
|
420
439
|
height: topQuadrant ? frozenRowsHeight : scrollableBodyHeight,
|
|
421
|
-
} }));
|
|
440
|
+
}, offsetTop: !topQuadrant && virtualScrollWindowMetrics.enabled ? virtualScrollBase : 0 }));
|
|
422
441
|
};
|
|
423
442
|
var visibleScrollableRows = React.useMemo(function () {
|
|
424
443
|
var _a;
|
|
@@ -436,15 +455,14 @@ function Table(props) {
|
|
|
436
455
|
startRowIndex: visibleScrollableRows.startRowIndex,
|
|
437
456
|
endRowIndex: visibleScrollableRows.endRowIndex,
|
|
438
457
|
}); }, [visibleScrollableRows.endRowIndex, visibleScrollableRows.startRowIndex]);
|
|
439
|
-
var frozenScrollableBodyStyle = React.useMemo(function () { return ({
|
|
440
|
-
|
|
441
|
-
|
|
458
|
+
var frozenScrollableBodyStyle = React.useMemo(function () { return ({
|
|
459
|
+
top: virtualScrollWindowMetrics.enabled
|
|
460
|
+
? visibleScrollableRows.paddingTop - virtualScrollBase
|
|
461
|
+
: visibleScrollableRows.paddingTop,
|
|
462
|
+
}); }, [virtualScrollBase, virtualScrollWindowMetrics.enabled, visibleScrollableRows.paddingTop]);
|
|
442
463
|
var warnedContextMenuIdsRef = (0, react_1.useRef)(new Set());
|
|
443
464
|
var warnedContextMenuFactoryRef = (0, react_1.useRef)(false);
|
|
444
|
-
var editorPortalRef = (0, react_1.useRef)(null);
|
|
445
465
|
var editorPortalContext = React.useMemo(function () { return ({ gridRef: containerRef, portalRef: editorPortalRef }); }, []);
|
|
446
|
-
var bodyContainerRef = (0, react_1.useRef)(null);
|
|
447
|
-
var scrollContainerRef = (0, react_1.useRef)(null);
|
|
448
466
|
var rowReorderController = (0, useRowReorderController_1.useRowReorderController)({
|
|
449
467
|
containerRef: containerRef,
|
|
450
468
|
bodyContainerRef: bodyContainerRef,
|
|
@@ -556,7 +574,8 @@ function Table(props) {
|
|
|
556
574
|
var stickyBottomHeight = (summary === null || summary === void 0 ? void 0 : summary.position) === 'bottom' ? summaryHeight : 0;
|
|
557
575
|
var stickyFixedHeight = stickyTopHeight + stickyBottomHeight;
|
|
558
576
|
var scrollViewportHeight = contentBodyHeight + stickyFixedHeight;
|
|
559
|
-
var
|
|
577
|
+
var physicalScrollableRowsHeight = Math.max(virtualScrollWindowMetrics.physicalContentHeight - frozenRowsHeight, 0);
|
|
578
|
+
var scrollPlaneHeight = stickyFixedHeight + virtualScrollWindowMetrics.physicalContentHeight;
|
|
560
579
|
var scrollPlaneContentWidth = (frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0) + scrollableColumnsWidth;
|
|
561
580
|
var scrollPlaneWidth = Math.max(width, scrollPlaneContentWidth);
|
|
562
581
|
var customVerticalScrollbarGutter = scrollbar.vertical.visible && scrollbar.variant === 'classic'
|
|
@@ -567,7 +586,16 @@ function Table(props) {
|
|
|
567
586
|
var scrollPlaneMinWidth = customVerticalScrollbarGutter
|
|
568
587
|
? "max(100%, calc(".concat(scrollPlaneContentWidth, "px + ").concat(customVerticalScrollbarGutter, "))")
|
|
569
588
|
: scrollPlaneWidth;
|
|
570
|
-
var
|
|
589
|
+
var measuredScrollbarMetrics = (0, scrollbar_1.useScrollbarMetrics)(scrollContainerRef, [data.length, itemHeight, itemPadding, contentBodyHeight, width], scrollPlaneContentWidth, stickyFixedHeight);
|
|
590
|
+
var scrollbarMetrics = React.useMemo(function () {
|
|
591
|
+
return virtualScrollWindowMetrics.enabled
|
|
592
|
+
? __assign(__assign({}, measuredScrollbarMetrics), { vertical: {
|
|
593
|
+
viewportSize: contentBodyHeight,
|
|
594
|
+
contentSize: virtualScrollWindowMetrics.logicalContentHeight,
|
|
595
|
+
maxScroll: virtualScrollWindowMetrics.logicalMaxScroll,
|
|
596
|
+
hasOverflow: virtualScrollWindowMetrics.logicalMaxScroll > 1,
|
|
597
|
+
} }) : measuredScrollbarMetrics;
|
|
598
|
+
}, [contentBodyHeight, measuredScrollbarMetrics, virtualScrollWindowMetrics]);
|
|
571
599
|
var measuredVerticalScrollbarGutter = customVerticalScrollbarGutter && scrollbarMetrics.horizontal.hasOverflow
|
|
572
600
|
? Math.max(scrollbarMetrics.horizontal.contentSize - scrollPlaneContentWidth, 0)
|
|
573
601
|
: 0;
|
|
@@ -587,13 +615,17 @@ function Table(props) {
|
|
|
587
615
|
scrollContainerRef.current.scrollLeft = offset;
|
|
588
616
|
}
|
|
589
617
|
}, []);
|
|
590
|
-
var handleScrollTopChange = (0, react_1.useCallback)(function (offset) {
|
|
591
|
-
if (scrollContainerRef.current) {
|
|
592
|
-
scrollContainerRef.current.scrollTop = offset;
|
|
593
|
-
}
|
|
594
|
-
}, []);
|
|
595
618
|
var latestScrollRef = (0, react_1.useRef)({ top: scrollTop, left: scrollLeft });
|
|
596
619
|
var latestCommittedScrollRef = (0, react_1.useRef)({ top: scrollTop, left: scrollLeft });
|
|
620
|
+
var scrollPropsRef = (0, react_1.useRef)({ top: props.scrollTop, left: props.scrollLeft });
|
|
621
|
+
var syncedDataPropRef = (0, react_1.useRef)(props.data);
|
|
622
|
+
var _20 = __read(React.useState(null), 2), rowScrollRequest = _20[0], setRowScrollRequest = _20[1];
|
|
623
|
+
React.useImperativeHandle(props.ref, function () { return ({
|
|
624
|
+
scrollToRow: function (rowIndex, options) {
|
|
625
|
+
var _a;
|
|
626
|
+
setRowScrollRequest({ rowIndex: rowIndex, align: (_a = options === null || options === void 0 ? void 0 : options.align) !== null && _a !== void 0 ? _a : 'nearest' });
|
|
627
|
+
},
|
|
628
|
+
}); }, []);
|
|
597
629
|
var scrollRafRef = (0, react_1.useRef)(null);
|
|
598
630
|
var scrollIdleTimerRef = (0, react_1.useRef)(null);
|
|
599
631
|
var selectionAutoScrollRafRef = (0, react_1.useRef)(null);
|
|
@@ -608,6 +640,7 @@ function Table(props) {
|
|
|
608
640
|
frozenRowCount: frozenRowCount,
|
|
609
641
|
frozenColumnsWidth: frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0,
|
|
610
642
|
frozenRowsHeight: frozenRowsHeight,
|
|
643
|
+
scrollTop: scrollTop,
|
|
611
644
|
trHeight: trHeight,
|
|
612
645
|
});
|
|
613
646
|
(0, react_1.useEffect)(function () {
|
|
@@ -619,9 +652,10 @@ function Table(props) {
|
|
|
619
652
|
frozenRowCount: frozenRowCount,
|
|
620
653
|
frozenColumnsWidth: frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0,
|
|
621
654
|
frozenRowsHeight: frozenRowsHeight,
|
|
655
|
+
scrollTop: scrollTop,
|
|
622
656
|
trHeight: trHeight,
|
|
623
657
|
};
|
|
624
|
-
}, [columns, data.length, props.frozenColumnIndex, frozenColumnsWidth, frozenRowCount, frozenRowsHeight, trHeight]);
|
|
658
|
+
}, [columns, data.length, props.frozenColumnIndex, frozenColumnsWidth, frozenRowCount, frozenRowsHeight, scrollTop, trHeight]);
|
|
625
659
|
var markScrollActive = (0, react_1.useCallback)(function () {
|
|
626
660
|
var _a;
|
|
627
661
|
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('data-bgrid-scrolling', 'true');
|
|
@@ -633,6 +667,28 @@ function Table(props) {
|
|
|
633
667
|
(_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.removeAttribute('data-bgrid-scrolling');
|
|
634
668
|
}, SCROLL_IDLE_DELAY);
|
|
635
669
|
}, []);
|
|
670
|
+
var commitScroll = (0, react_1.useCallback)(function (top, left) {
|
|
671
|
+
var scrollContainer = scrollContainerRef.current;
|
|
672
|
+
if (!scrollContainer)
|
|
673
|
+
return;
|
|
674
|
+
var position = (0, utils_1.getVirtualScrollWindowPosition)(top, virtualScrollWindowMetrics);
|
|
675
|
+
if (virtualScrollBaseRef.current !== position.base) {
|
|
676
|
+
virtualScrollBaseRef.current = position.base;
|
|
677
|
+
setVirtualScrollBase(position.base);
|
|
678
|
+
}
|
|
679
|
+
if (scrollContainer.scrollTop !== position.physicalScrollTop) {
|
|
680
|
+
scrollContainer.scrollTop = position.physicalScrollTop;
|
|
681
|
+
}
|
|
682
|
+
if (scrollContainer.scrollLeft !== left)
|
|
683
|
+
scrollContainer.scrollLeft = left;
|
|
684
|
+
latestScrollRef.current = { top: position.logicalScrollTop, left: left };
|
|
685
|
+
latestCommittedScrollRef.current = { top: position.logicalScrollTop, left: left };
|
|
686
|
+
setScroll(position.logicalScrollTop, left);
|
|
687
|
+
}, [setScroll, virtualScrollWindowMetrics]);
|
|
688
|
+
var handleScrollTopChange = (0, react_1.useCallback)(function (offset) {
|
|
689
|
+
var _a, _b;
|
|
690
|
+
commitScroll(offset, (_b = (_a = scrollContainerRef.current) === null || _a === void 0 ? void 0 : _a.scrollLeft) !== null && _b !== void 0 ? _b : scrollLeft);
|
|
691
|
+
}, [commitScroll, scrollLeft]);
|
|
636
692
|
var scheduleScrollFrame = (0, react_1.useCallback)(function () {
|
|
637
693
|
if (scrollRafRef.current !== null)
|
|
638
694
|
return;
|
|
@@ -642,91 +698,42 @@ function Table(props) {
|
|
|
642
698
|
var scrollContainer = scrollContainerRef.current;
|
|
643
699
|
if (!scrollContainer)
|
|
644
700
|
return;
|
|
645
|
-
var
|
|
646
|
-
|
|
701
|
+
var physicalScrollTop = scrollContainer.scrollTop, scrollLeft = scrollContainer.scrollLeft;
|
|
702
|
+
var position = (0, utils_1.rebaseVirtualScrollWindow)(virtualScrollBaseRef.current, physicalScrollTop, virtualScrollWindowMetrics);
|
|
703
|
+
if (virtualScrollBaseRef.current !== position.base) {
|
|
704
|
+
virtualScrollBaseRef.current = position.base;
|
|
705
|
+
setVirtualScrollBase(position.base);
|
|
706
|
+
}
|
|
707
|
+
if (physicalScrollTop !== position.physicalScrollTop) {
|
|
708
|
+
scrollContainer.scrollTop = position.physicalScrollTop;
|
|
709
|
+
}
|
|
710
|
+
var logicalScrollTop = position.logicalScrollTop;
|
|
711
|
+
latestScrollRef.current = { top: logicalScrollTop, left: scrollLeft };
|
|
647
712
|
var _b = latestCommittedScrollRef.current, committedTop = _b.top, committedLeft = _b.left;
|
|
648
|
-
if (committedTop !==
|
|
649
|
-
latestCommittedScrollRef.current = { top:
|
|
650
|
-
setScroll(
|
|
713
|
+
if (committedTop !== logicalScrollTop || committedLeft !== scrollLeft) {
|
|
714
|
+
latestCommittedScrollRef.current = { top: logicalScrollTop, left: scrollLeft };
|
|
715
|
+
setScroll(logicalScrollTop, scrollLeft);
|
|
651
716
|
}
|
|
652
717
|
if ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.hasAttribute('data-bgrid-scrolling')) {
|
|
653
718
|
scrollRafRef.current = requestAnimationFrame(pollNativeScrollPosition);
|
|
654
719
|
}
|
|
655
720
|
};
|
|
656
721
|
scrollRafRef.current = requestAnimationFrame(pollNativeScrollPosition);
|
|
657
|
-
}, [setScroll]);
|
|
722
|
+
}, [setScroll, virtualScrollWindowMetrics]);
|
|
658
723
|
var onScroll = (0, react_1.useCallback)(function () {
|
|
659
724
|
if (scrollContainerRef.current) {
|
|
660
|
-
var _a = scrollContainerRef.current, scrollTop_1 = _a.scrollTop, scrollLeft_1 = _a.scrollLeft;
|
|
661
|
-
latestScrollRef.current = { top: scrollTop_1, left: scrollLeft_1 };
|
|
662
725
|
markScrollActive();
|
|
663
726
|
scheduleScrollFrame();
|
|
664
727
|
}
|
|
665
728
|
}, [markScrollActive, scheduleScrollFrame]);
|
|
666
|
-
var onWheel = (0, react_1.useCallback)(function (evt) {
|
|
667
|
-
var scrollContainer = scrollContainerRef.current;
|
|
668
|
-
if (!scrollContainer)
|
|
669
|
-
return;
|
|
670
|
-
var delta = { x: 0, y: 0 };
|
|
671
|
-
if (evt.detail) {
|
|
672
|
-
delta.y = evt.detail * 10;
|
|
673
|
-
}
|
|
674
|
-
else if (typeof evt.deltaY === 'undefined') {
|
|
675
|
-
delta.y = -evt.wheelDelta;
|
|
676
|
-
delta.x = 0;
|
|
677
|
-
}
|
|
678
|
-
else {
|
|
679
|
-
delta.y = evt.deltaY;
|
|
680
|
-
delta.x = evt.deltaX;
|
|
681
|
-
}
|
|
682
|
-
if (evt.deltaMode === 1) {
|
|
683
|
-
delta.y = delta.y * 16;
|
|
684
|
-
delta.x = delta.x * 16;
|
|
685
|
-
}
|
|
686
|
-
else if (evt.deltaMode === 2) {
|
|
687
|
-
delta.y = delta.y * scrollContainer.clientHeight;
|
|
688
|
-
delta.x = delta.x * scrollContainer.clientWidth;
|
|
689
|
-
}
|
|
690
|
-
var maxScrollTop = Math.max(scrollContainer.scrollHeight - scrollContainer.clientHeight, 0);
|
|
691
|
-
var maxScrollLeft = Math.max(scrollContainer.scrollWidth - scrollContainer.clientWidth, 0);
|
|
692
|
-
var nextScrollTop = Math.min(maxScrollTop, Math.max(0, scrollContainer.scrollTop + delta.y));
|
|
693
|
-
var nextScrollLeft = Math.min(maxScrollLeft, Math.max(0, scrollContainer.scrollLeft + delta.x));
|
|
694
|
-
var didScrollTop = nextScrollTop !== scrollContainer.scrollTop;
|
|
695
|
-
var didScrollLeft = nextScrollLeft !== scrollContainer.scrollLeft;
|
|
696
|
-
var isVertical = Math.abs(delta.y) > Math.abs(delta.x);
|
|
697
|
-
if (isVertical) {
|
|
698
|
-
if (!didScrollTop)
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
if (!didScrollLeft)
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
evt.preventDefault();
|
|
706
|
-
if (didScrollTop)
|
|
707
|
-
scrollContainer.scrollTop = nextScrollTop;
|
|
708
|
-
if (didScrollLeft)
|
|
709
|
-
scrollContainer.scrollLeft = nextScrollLeft;
|
|
710
|
-
}, []);
|
|
711
729
|
var resetScrollPosition = (0, react_1.useCallback)(function (type) {
|
|
712
|
-
var _a, _b;
|
|
713
|
-
if (type === 'all' || type === 'left')
|
|
714
|
-
(_a = scrollContainerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ left: 0 });
|
|
715
|
-
if (type === 'all' || type === 'top')
|
|
716
|
-
(_b = scrollContainerRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo({ top: 0 });
|
|
717
|
-
}, []);
|
|
718
|
-
var commitScroll = (0, react_1.useCallback)(function (top, left) {
|
|
719
730
|
var scrollContainer = scrollContainerRef.current;
|
|
720
731
|
if (!scrollContainer)
|
|
721
732
|
return;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
latestScrollRef.current = { top: top, left: left };
|
|
727
|
-
latestCommittedScrollRef.current = { top: top, left: left };
|
|
728
|
-
setScroll(top, left);
|
|
729
|
-
}, [setScroll]);
|
|
733
|
+
var nextTop = type === 'all' || type === 'top' ? 0 : latestScrollRef.current.top;
|
|
734
|
+
var nextLeft = type === 'all' || type === 'left' ? 0 : scrollContainer.scrollLeft;
|
|
735
|
+
commitScroll(nextTop, nextLeft);
|
|
736
|
+
}, [commitScroll]);
|
|
730
737
|
(0, react_1.useEffect)(function () {
|
|
731
738
|
var _a, _b;
|
|
732
739
|
if (!searchOpen || activeSearchMatchIndex === undefined)
|
|
@@ -751,6 +758,7 @@ function Table(props) {
|
|
|
751
758
|
frozenRowCount: frozenRowCount,
|
|
752
759
|
columns: columns,
|
|
753
760
|
rowHeight: trHeight,
|
|
761
|
+
verticalScrollState: logicalVerticalScrollState,
|
|
754
762
|
viewportInsets: viewportInsets,
|
|
755
763
|
});
|
|
756
764
|
if (result.didScroll)
|
|
@@ -760,6 +768,7 @@ function Table(props) {
|
|
|
760
768
|
columns,
|
|
761
769
|
commitScroll,
|
|
762
770
|
frozenRowCount,
|
|
771
|
+
logicalVerticalScrollState,
|
|
763
772
|
props.frozenColumnIndex,
|
|
764
773
|
searchMatches,
|
|
765
774
|
searchOpen,
|
|
@@ -992,18 +1001,18 @@ function Table(props) {
|
|
|
992
1001
|
if (!dragState || !pointer || !scrollContainer || !bodyContainer)
|
|
993
1002
|
return;
|
|
994
1003
|
var delta = getSelectionAutoScrollDelta(pointer.clientX, pointer.clientY, bodyContainer, scrollContainer);
|
|
995
|
-
var maxScrollTop =
|
|
1004
|
+
var maxScrollTop = virtualScrollWindowMetrics.logicalMaxScroll;
|
|
996
1005
|
var maxScrollLeft = Math.max(scrollContainer.scrollWidth - scrollContainer.clientWidth, 0);
|
|
997
|
-
var nextScrollTop = (0, coordinate_1.clamp)(
|
|
1006
|
+
var nextScrollTop = (0, coordinate_1.clamp)(latestScrollRef.current.top + delta.y, 0, maxScrollTop);
|
|
998
1007
|
var nextScrollLeft = (0, coordinate_1.clamp)(scrollContainer.scrollLeft + delta.x, 0, maxScrollLeft);
|
|
999
|
-
if (nextScrollTop !==
|
|
1008
|
+
if (nextScrollTop !== latestScrollRef.current.top || nextScrollLeft !== scrollContainer.scrollLeft) {
|
|
1000
1009
|
commitScroll(nextScrollTop, nextScrollLeft);
|
|
1001
1010
|
}
|
|
1002
1011
|
updateSelectionByPointer(pointer.clientX, pointer.clientY);
|
|
1003
1012
|
if (cellSelectionDragRef.current && (delta.x !== 0 || delta.y !== 0)) {
|
|
1004
1013
|
selectionAutoScrollRafRef.current = requestAnimationFrame(runSelectionAutoScroll);
|
|
1005
1014
|
}
|
|
1006
|
-
}, [commitScroll, updateSelectionByPointer]);
|
|
1015
|
+
}, [commitScroll, updateSelectionByPointer, virtualScrollWindowMetrics.logicalMaxScroll]);
|
|
1007
1016
|
var selectAllCells = (0, react_1.useCallback)(function () {
|
|
1008
1017
|
if (!cellSelectionEnabled)
|
|
1009
1018
|
return false;
|
|
@@ -1525,6 +1534,7 @@ function Table(props) {
|
|
|
1525
1534
|
setSourceData(props.sourceData);
|
|
1526
1535
|
}
|
|
1527
1536
|
}
|
|
1537
|
+
syncedDataPropRef.current = props.data;
|
|
1528
1538
|
}, [
|
|
1529
1539
|
props.data,
|
|
1530
1540
|
props.sourceData,
|
|
@@ -1605,9 +1615,13 @@ function Table(props) {
|
|
|
1605
1615
|
setPage,
|
|
1606
1616
|
setDisplayPaginationLength,
|
|
1607
1617
|
]);
|
|
1618
|
+
var previousPageRef = (0, react_1.useRef)((_o = props.page) === null || _o === void 0 ? void 0 : _o.currentPage);
|
|
1608
1619
|
(0, react_1.useEffect)(function () {
|
|
1609
|
-
|
|
1610
|
-
|
|
1620
|
+
var _a, _b;
|
|
1621
|
+
if (previousPageRef.current !== ((_a = props.page) === null || _a === void 0 ? void 0 : _a.currentPage))
|
|
1622
|
+
resetScrollPosition('top');
|
|
1623
|
+
previousPageRef.current = (_b = props.page) === null || _b === void 0 ? void 0 : _b.currentPage;
|
|
1624
|
+
}, [resetScrollPosition, (_p = props.page) === null || _p === void 0 ? void 0 : _p.currentPage]);
|
|
1611
1625
|
// [Group 8] Row key & selection
|
|
1612
1626
|
(0, react_1.useEffect)(function () {
|
|
1613
1627
|
setRowKey(props.rowKey);
|
|
@@ -1679,10 +1693,10 @@ function Table(props) {
|
|
|
1679
1693
|
}, [
|
|
1680
1694
|
columns.length,
|
|
1681
1695
|
data.length,
|
|
1682
|
-
(
|
|
1683
|
-
(
|
|
1684
|
-
(
|
|
1685
|
-
(
|
|
1696
|
+
(_r = (_q = props.cellNavigationOptions) === null || _q === void 0 ? void 0 : _q.activeCell) === null || _r === void 0 ? void 0 : _r.columnIndex,
|
|
1697
|
+
(_t = (_s = props.cellNavigationOptions) === null || _s === void 0 ? void 0 : _s.activeCell) === null || _t === void 0 ? void 0 : _t.rowIndex,
|
|
1698
|
+
(_v = (_u = props.cellNavigationOptions) === null || _u === void 0 ? void 0 : _u.defaultActiveCell) === null || _v === void 0 ? void 0 : _v.columnIndex,
|
|
1699
|
+
(_x = (_w = props.cellNavigationOptions) === null || _w === void 0 ? void 0 : _w.defaultActiveCell) === null || _x === void 0 ? void 0 : _x.rowIndex,
|
|
1686
1700
|
syncActiveCellToBounds,
|
|
1687
1701
|
]);
|
|
1688
1702
|
// setInitialized + DOM event bindings
|
|
@@ -1691,10 +1705,8 @@ function Table(props) {
|
|
|
1691
1705
|
var containerRefCurrent = containerRef.current;
|
|
1692
1706
|
var scrollContainerRefCurrent = scrollContainerRef === null || scrollContainerRef === void 0 ? void 0 : scrollContainerRef.current;
|
|
1693
1707
|
if (scrollContainerRefCurrent) {
|
|
1694
|
-
scrollContainerRefCurrent.removeEventListener('scroll', onScroll);
|
|
1708
|
+
scrollContainerRefCurrent.removeEventListener('scroll', onScroll, true);
|
|
1695
1709
|
scrollContainerRefCurrent.addEventListener('scroll', onScroll, { passive: true, capture: true });
|
|
1696
|
-
// scrollContainerRefCurrent.removeEventListener('wheel', onWheel);
|
|
1697
|
-
// scrollContainerRefCurrent.addEventListener('wheel', onWheel, { passive: false, capture: true });
|
|
1698
1710
|
}
|
|
1699
1711
|
return function () {
|
|
1700
1712
|
if (scrollRafRef.current !== null) {
|
|
@@ -1706,20 +1718,57 @@ function Table(props) {
|
|
|
1706
1718
|
scrollIdleTimerRef.current = null;
|
|
1707
1719
|
}
|
|
1708
1720
|
containerRefCurrent === null || containerRefCurrent === void 0 ? void 0 : containerRefCurrent.removeAttribute('data-bgrid-scrolling');
|
|
1709
|
-
scrollContainerRefCurrent === null || scrollContainerRefCurrent === void 0 ? void 0 : scrollContainerRefCurrent.removeEventListener('scroll', onScroll);
|
|
1721
|
+
scrollContainerRefCurrent === null || scrollContainerRefCurrent === void 0 ? void 0 : scrollContainerRefCurrent.removeEventListener('scroll', onScroll, true);
|
|
1710
1722
|
};
|
|
1711
|
-
}, [onScroll,
|
|
1723
|
+
}, [onScroll, setInitialized]);
|
|
1712
1724
|
React.useLayoutEffect(function () {
|
|
1725
|
+
var _a, _b;
|
|
1713
1726
|
if (!scrollContainerRef.current)
|
|
1714
1727
|
return;
|
|
1715
|
-
if (props.
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1728
|
+
if (props.data !== syncedDataPropRef.current)
|
|
1729
|
+
return;
|
|
1730
|
+
// Resizing or changing the data also changes commitScroll. Only a changed
|
|
1731
|
+
// scroll prop should override the user's current position.
|
|
1732
|
+
var nextTop = props.scrollTop !== scrollPropsRef.current.top
|
|
1733
|
+
? (_a = props.scrollTop) !== null && _a !== void 0 ? _a : latestScrollRef.current.top
|
|
1734
|
+
: latestScrollRef.current.top;
|
|
1735
|
+
var nextLeft = props.scrollLeft !== scrollPropsRef.current.left
|
|
1736
|
+
? (_b = props.scrollLeft) !== null && _b !== void 0 ? _b : latestScrollRef.current.left
|
|
1737
|
+
: latestScrollRef.current.left;
|
|
1738
|
+
scrollPropsRef.current = { top: props.scrollTop, left: props.scrollLeft };
|
|
1739
|
+
commitScroll(nextTop, nextLeft);
|
|
1740
|
+
}, [commitScroll, data, props.data, props.scrollLeft, props.scrollTop]);
|
|
1741
|
+
React.useLayoutEffect(function () {
|
|
1742
|
+
if (!rowScrollRequest)
|
|
1743
|
+
return;
|
|
1744
|
+
// Prop data reaches the per-grid store in an effect. Wait for that render
|
|
1745
|
+
// so appending a row and requesting it in the same event is supported.
|
|
1746
|
+
if (props.data !== syncedDataPropRef.current)
|
|
1747
|
+
return;
|
|
1748
|
+
setRowScrollRequest(null);
|
|
1749
|
+
var rowIndex = rowScrollRequest.rowIndex, align = rowScrollRequest.align;
|
|
1750
|
+
if (!Number.isInteger(rowIndex) || rowIndex < frozenRowCount || rowIndex >= data.length)
|
|
1751
|
+
return;
|
|
1752
|
+
if (scrollableBodyHeight <= 0)
|
|
1753
|
+
return;
|
|
1754
|
+
var rowTop = (rowIndex - frozenRowCount) * trHeight;
|
|
1755
|
+
var rowBottom = rowTop + trHeight;
|
|
1756
|
+
var _a = latestScrollRef.current, top = _a.top, left = _a.left;
|
|
1757
|
+
var nextTop = top;
|
|
1758
|
+
if (align === 'start')
|
|
1759
|
+
nextTop = rowTop;
|
|
1760
|
+
else if (align === 'center')
|
|
1761
|
+
nextTop = rowTop - (scrollableBodyHeight - trHeight) / 2;
|
|
1762
|
+
else if (align === 'end')
|
|
1763
|
+
nextTop = rowBottom - scrollableBodyHeight;
|
|
1764
|
+
else if (rowTop < top)
|
|
1765
|
+
nextTop = rowTop;
|
|
1766
|
+
else if (rowBottom > top + scrollableBodyHeight)
|
|
1767
|
+
nextTop = rowBottom - scrollableBodyHeight;
|
|
1768
|
+
commitScroll(nextTop, left);
|
|
1769
|
+
}, [commitScroll, data, frozenRowCount, props.data, rowScrollRequest, scrollableBodyHeight, trHeight]);
|
|
1722
1770
|
(0, react_1.useEffect)(function () {
|
|
1771
|
+
latestScrollRef.current = { top: scrollTop, left: scrollLeft };
|
|
1723
1772
|
latestCommittedScrollRef.current = { top: scrollTop, left: scrollLeft };
|
|
1724
1773
|
}, [scrollTop, scrollLeft]);
|
|
1725
1774
|
(0, react_1.useEffect)(function () {
|
|
@@ -1769,8 +1818,8 @@ function Table(props) {
|
|
|
1769
1818
|
endCellSelectionDrag();
|
|
1770
1819
|
clearCellSelection();
|
|
1771
1820
|
}, [cellSelectionEnabled, clearCellSelection, endCellSelectionDrag]);
|
|
1772
|
-
var clearCellSelectionOnEscape = (
|
|
1773
|
-
var clearCellSelectionOnOutsideClick = (
|
|
1821
|
+
var clearCellSelectionOnEscape = (_z = (_y = props.cellSelectionOptions) === null || _y === void 0 ? void 0 : _y.clearOnEscape) !== null && _z !== void 0 ? _z : true;
|
|
1822
|
+
var clearCellSelectionOnOutsideClick = (_1 = (_0 = props.cellSelectionOptions) === null || _0 === void 0 ? void 0 : _0.clearOnOutsideClick) !== null && _1 !== void 0 ? _1 : true;
|
|
1774
1823
|
var keyboardRuntimeRef = (0, react_1.useRef)({
|
|
1775
1824
|
activeCell: activeCell,
|
|
1776
1825
|
cellInteractionSession: cellInteractionSession,
|
|
@@ -1788,7 +1837,7 @@ function Table(props) {
|
|
|
1788
1837
|
editable: editable,
|
|
1789
1838
|
editItemIndex: editItemIndex,
|
|
1790
1839
|
endCellSelectionDrag: endCellSelectionDrag,
|
|
1791
|
-
frozenColumnIndex: (
|
|
1840
|
+
frozenColumnIndex: (_2 = props.frozenColumnIndex) !== null && _2 !== void 0 ? _2 : 0,
|
|
1792
1841
|
frozenRowCount: frozenRowCount,
|
|
1793
1842
|
height: height,
|
|
1794
1843
|
handleClick: handleClick,
|
|
@@ -1801,6 +1850,7 @@ function Table(props) {
|
|
|
1801
1850
|
searchOpen: searchOpen,
|
|
1802
1851
|
searchOptions: searchOptions,
|
|
1803
1852
|
trHeight: trHeight,
|
|
1853
|
+
verticalScrollState: logicalVerticalScrollState,
|
|
1804
1854
|
viewportInsets: keyboardViewportInsets,
|
|
1805
1855
|
});
|
|
1806
1856
|
keyboardRuntimeRef.current = {
|
|
@@ -1820,7 +1870,7 @@ function Table(props) {
|
|
|
1820
1870
|
editable: editable,
|
|
1821
1871
|
editItemIndex: editItemIndex,
|
|
1822
1872
|
endCellSelectionDrag: endCellSelectionDrag,
|
|
1823
|
-
frozenColumnIndex: (
|
|
1873
|
+
frozenColumnIndex: (_3 = props.frozenColumnIndex) !== null && _3 !== void 0 ? _3 : 0,
|
|
1824
1874
|
frozenRowCount: frozenRowCount,
|
|
1825
1875
|
height: height,
|
|
1826
1876
|
handleClick: handleClick,
|
|
@@ -1833,6 +1883,7 @@ function Table(props) {
|
|
|
1833
1883
|
searchOpen: searchOpen,
|
|
1834
1884
|
searchOptions: searchOptions,
|
|
1835
1885
|
trHeight: trHeight,
|
|
1886
|
+
verticalScrollState: logicalVerticalScrollState,
|
|
1836
1887
|
viewportInsets: keyboardViewportInsets,
|
|
1837
1888
|
};
|
|
1838
1889
|
(0, react_1.useEffect)(function () {
|
|
@@ -1849,7 +1900,7 @@ function Table(props) {
|
|
|
1849
1900
|
};
|
|
1850
1901
|
var moveWithArrowKey = function (key, extendSelection, toBoundary) {
|
|
1851
1902
|
if (toBoundary === void 0) { toBoundary = false; }
|
|
1852
|
-
var _a = keyboardRuntimeRef.current, activeCell = _a.activeCell, cellInteractionSession = _a.cellInteractionSession, cellNavigationOptions = _a.cellNavigationOptions, cellSelectionEnabled = _a.cellSelectionEnabled, columns = _a.columns, commitScroll = _a.commitScroll, dataLength = _a.dataLength, frozenColumnIndex = _a.frozenColumnIndex, frozenRowCount = _a.frozenRowCount, moveActiveCell = _a.moveActiveCell, trHeight = _a.trHeight, viewportInsets = _a.viewportInsets;
|
|
1903
|
+
var _a = keyboardRuntimeRef.current, activeCell = _a.activeCell, cellInteractionSession = _a.cellInteractionSession, cellNavigationOptions = _a.cellNavigationOptions, cellSelectionEnabled = _a.cellSelectionEnabled, columns = _a.columns, commitScroll = _a.commitScroll, dataLength = _a.dataLength, frozenColumnIndex = _a.frozenColumnIndex, frozenRowCount = _a.frozenRowCount, moveActiveCell = _a.moveActiveCell, trHeight = _a.trHeight, verticalScrollState = _a.verticalScrollState, viewportInsets = _a.viewportInsets;
|
|
1853
1904
|
var container = containerRef.current;
|
|
1854
1905
|
var activeElement = document.activeElement;
|
|
1855
1906
|
if (!container ||
|
|
@@ -1883,6 +1934,7 @@ function Table(props) {
|
|
|
1883
1934
|
frozenRowCount: frozenRowCount,
|
|
1884
1935
|
columns: columns,
|
|
1885
1936
|
rowHeight: trHeight,
|
|
1937
|
+
verticalScrollState: verticalScrollState,
|
|
1886
1938
|
viewportInsets: viewportInsets,
|
|
1887
1939
|
});
|
|
1888
1940
|
if (result.didScroll) {
|
|
@@ -1916,7 +1968,7 @@ function Table(props) {
|
|
|
1916
1968
|
};
|
|
1917
1969
|
var handleKeyDown = function (evt) {
|
|
1918
1970
|
var _a, _b, _c, _d, _e;
|
|
1919
|
-
var _f = keyboardRuntimeRef.current, activeCell = _f.activeCell, cellInteractionSession = _f.cellInteractionSession, cellNavigationOptions = _f.cellNavigationOptions, cellSelectionEnabled = _f.cellSelectionEnabled, clearCellSelection = _f.clearCellSelection, clearCellSelectionOnEscape = _f.clearCellSelectionOnEscape, columns = _f.columns, commitCheckboxCell = _f.commitCheckboxCell, commitScroll = _f.commitScroll, copySelectedCells = _f.copySelectedCells, data = _f.data, dataLength = _f.dataLength, editable = _f.editable, editItemIndex = _f.editItemIndex, endCellSelectionDrag = _f.endCellSelectionDrag, frozenColumnIndex = _f.frozenColumnIndex, frozenRowCount = _f.frozenRowCount, height = _f.height, handleClick = _f.handleClick, moveActiveCell = _f.moveActiveCell, openCellContextMenu = _f.openCellContextMenu, selectAllCells = _f.selectAllCells, setEditItem = _f.setEditItem, requestSearchOpen = _f.requestSearchOpen, searchOpen = _f.searchOpen, searchOptions = _f.searchOptions, trHeight = _f.trHeight, viewportInsets = _f.viewportInsets;
|
|
1971
|
+
var _f = keyboardRuntimeRef.current, activeCell = _f.activeCell, cellInteractionSession = _f.cellInteractionSession, cellNavigationOptions = _f.cellNavigationOptions, cellSelectionEnabled = _f.cellSelectionEnabled, clearCellSelection = _f.clearCellSelection, clearCellSelectionOnEscape = _f.clearCellSelectionOnEscape, columns = _f.columns, commitCheckboxCell = _f.commitCheckboxCell, commitScroll = _f.commitScroll, copySelectedCells = _f.copySelectedCells, data = _f.data, dataLength = _f.dataLength, editable = _f.editable, editItemIndex = _f.editItemIndex, endCellSelectionDrag = _f.endCellSelectionDrag, frozenColumnIndex = _f.frozenColumnIndex, frozenRowCount = _f.frozenRowCount, height = _f.height, handleClick = _f.handleClick, moveActiveCell = _f.moveActiveCell, openCellContextMenu = _f.openCellContextMenu, selectAllCells = _f.selectAllCells, setEditItem = _f.setEditItem, requestSearchOpen = _f.requestSearchOpen, searchOpen = _f.searchOpen, searchOptions = _f.searchOptions, trHeight = _f.trHeight, verticalScrollState = _f.verticalScrollState, viewportInsets = _f.viewportInsets;
|
|
1920
1972
|
var container = containerRef.current;
|
|
1921
1973
|
var activeElement = document.activeElement;
|
|
1922
1974
|
if (!container || (activeElement !== container && !container.contains(activeElement)))
|
|
@@ -2045,6 +2097,7 @@ function Table(props) {
|
|
|
2045
2097
|
frozenRowCount: frozenRowCount,
|
|
2046
2098
|
columns: columns,
|
|
2047
2099
|
rowHeight: trHeight,
|
|
2100
|
+
verticalScrollState: verticalScrollState,
|
|
2048
2101
|
viewportInsets: viewportInsets,
|
|
2049
2102
|
});
|
|
2050
2103
|
if (result.didScroll) {
|
|
@@ -2088,6 +2141,7 @@ function Table(props) {
|
|
|
2088
2141
|
frozenRowCount: frozenRowCount,
|
|
2089
2142
|
columns: columns,
|
|
2090
2143
|
rowHeight: trHeight,
|
|
2144
|
+
verticalScrollState: verticalScrollState,
|
|
2091
2145
|
viewportInsets: viewportInsets,
|
|
2092
2146
|
});
|
|
2093
2147
|
if (result.didScroll) {
|
|
@@ -2115,6 +2169,7 @@ function Table(props) {
|
|
|
2115
2169
|
frozenRowCount: frozenRowCount,
|
|
2116
2170
|
columns: columns,
|
|
2117
2171
|
rowHeight: trHeight,
|
|
2172
|
+
verticalScrollState: verticalScrollState,
|
|
2118
2173
|
viewportInsets: viewportInsets,
|
|
2119
2174
|
});
|
|
2120
2175
|
if (result.didScroll) {
|
|
@@ -2204,7 +2259,7 @@ function Table(props) {
|
|
|
2204
2259
|
if (gateway instanceof HTMLInputElement) {
|
|
2205
2260
|
gateway.focus({ preventScroll: true });
|
|
2206
2261
|
}
|
|
2207
|
-
}, "data-scroll-variant": scrollbar.variant, "data-vertical-scrollbar": scrollbar.variant !== 'native' && scrollbar.vertical.visible ? 'visible' : 'hidden', "data-bgrid-cell-selection-enabled": cellSelectionEnabled ? 'true' : 'false', "data-bgrid-frozen-columns": ((
|
|
2262
|
+
}, "data-scroll-variant": scrollbar.variant, "data-vertical-scrollbar": scrollbar.variant !== 'native' && scrollbar.vertical.visible ? 'visible' : 'hidden', "data-bgrid-cell-selection-enabled": cellSelectionEnabled ? 'true' : 'false', "data-bgrid-frozen-columns": ((_4 = props.frozenColumnIndex) !== null && _4 !== void 0 ? _4 : 0) > 0 ? 'true' : 'false' },
|
|
2208
2263
|
scrollbar.variant !== 'native' && scrollbar.vertical.visible && (React.createElement("div", { className: 'bgrid-vertical-scrollbar-gutter', "aria-hidden": 'true' })),
|
|
2209
2264
|
scrollbar.variant !== 'native' && scrollbar.vertical.visible && (React.createElement("div", { className: 'bgrid-vertical-scrollbar-area', style: {
|
|
2210
2265
|
top: 0,
|
|
@@ -2222,7 +2277,7 @@ function Table(props) {
|
|
|
2222
2277
|
event.stopPropagation();
|
|
2223
2278
|
}
|
|
2224
2279
|
} },
|
|
2225
|
-
React.createElement(ScrollPlane, { style: { height: scrollPlaneHeight, minWidth: scrollPlaneMinWidth } },
|
|
2280
|
+
React.createElement(ScrollPlane, { style: { height: scrollPlaneHeight, minWidth: scrollPlaneMinWidth }, "data-bgrid-virtual-scroll-window": virtualScrollWindowMetrics.enabled ? 'true' : undefined, "data-bgrid-logical-height": virtualScrollWindowMetrics.logicalContentHeight, "data-bgrid-physical-height": virtualScrollWindowMetrics.physicalContentHeight, "data-bgrid-logical-scroll-top": Math.round(scrollTop), "data-bgrid-virtual-scroll-base": virtualScrollWindowMetrics.enabled ? Math.round(virtualScrollBase) : undefined },
|
|
2226
2281
|
React.createElement(HeaderContainer, { style: { height: headerHeight, top: 0 }, role: 'rfdg-header-container' },
|
|
2227
2282
|
(frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0) > 0 && (React.createElement(FrozenHeader, { style: { width: frozenColumnsWidth }, role: 'rfdg-frozen-header' },
|
|
2228
2283
|
React.createElement(TableHeadFrozen_1.default, { container: containerRef }))),
|
|
@@ -2233,7 +2288,7 @@ function Table(props) {
|
|
|
2233
2288
|
React.createElement(TableSummaryFronzen_1.TableSummaryFrozen, { position: 'top' }))),
|
|
2234
2289
|
React.createElement(Summary, { style: { left: frozenColumnsWidth }, role: 'rfdg-summary' },
|
|
2235
2290
|
React.createElement(TableSummary_1.TableSummary, { position: 'top' })))),
|
|
2236
|
-
React.createElement("div", { className: 'bgrid-body-scroll-content', style: { height:
|
|
2291
|
+
React.createElement("div", { className: 'bgrid-body-scroll-content', style: { height: virtualScrollWindowMetrics.physicalContentHeight } },
|
|
2237
2292
|
frozenRowCount > 0 && (React.createElement("div", { className: 'bgrid-frozen-rows-layer', style: { height: frozenRowsHeight, top: stickyTopHeight }, "data-bgrid-row-band": 'frozen' },
|
|
2238
2293
|
(frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0) > 0 && (React.createElement("div", { className: 'bgrid-frozen-rows-left bgrid-frozen-column-boundary', style: { width: frozenColumnsWidth }, role: 'rfdg-frozen-rows-left' },
|
|
2239
2294
|
React.createElement(TableBodyFrozen_1.default, { scrollContainerRef: scrollContainerRef, rowRange: frozenRowRange, role: 'rfdg-body-top-frozen', quadrant: 'top-left', allowRowReorder: false }),
|
|
@@ -2241,17 +2296,19 @@ function Table(props) {
|
|
|
2241
2296
|
React.createElement("div", { className: 'bgrid-frozen-rows-main', style: { left: frozenColumnsWidth }, role: 'rfdg-frozen-rows-main' },
|
|
2242
2297
|
React.createElement(TableBody_1.default, { scrollContainerRef: scrollContainerRef, rowRange: frozenRowRange, role: 'rfdg-body-top', quadrant: 'top-main', allowRowReorder: false }),
|
|
2243
2298
|
renderSelectionOverlay('top-main')))),
|
|
2244
|
-
React.createElement("div", { className: 'bgrid-scrollable-rows-layer', style: { height:
|
|
2299
|
+
React.createElement("div", { className: 'bgrid-scrollable-rows-layer', style: { height: physicalScrollableRowsHeight }, "data-bgrid-row-band": 'scrollable' },
|
|
2245
2300
|
(frozenColumnsWidth !== null && frozenColumnsWidth !== void 0 ? frozenColumnsWidth : 0) > 0 && (React.createElement(FrozenScrollContent, { style: {
|
|
2246
2301
|
width: frozenColumnsWidth,
|
|
2247
|
-
height:
|
|
2302
|
+
height: physicalScrollableRowsHeight,
|
|
2248
2303
|
}, role: 'rfdg-frozen-scroll-container' },
|
|
2249
2304
|
React.createElement(TableBodyFrozen_1.default, { scrollContainerRef: scrollContainerRef, rowRange: scrollableRowRange, style: frozenScrollableBodyStyle, quadrant: 'body-left', onRowReorderPointerDown: rowReorderController.onPointerDown, onRowReorderKeyDown: rowReorderController.onKeyDown }),
|
|
2250
2305
|
renderSelectionOverlay('body-left'))),
|
|
2251
2306
|
React.createElement(ScrollContent, { style: {
|
|
2252
2307
|
left: frozenColumnsWidth,
|
|
2253
|
-
paddingTop:
|
|
2254
|
-
|
|
2308
|
+
paddingTop: virtualScrollWindowMetrics.enabled
|
|
2309
|
+
? visibleScrollableRows.paddingTop - virtualScrollBase
|
|
2310
|
+
: visibleScrollableRows.paddingTop,
|
|
2311
|
+
height: physicalScrollableRowsHeight,
|
|
2255
2312
|
} },
|
|
2256
2313
|
React.createElement(TableBody_1.default, { scrollContainerRef: scrollContainerRef, rowRange: scrollableRowRange, quadrant: 'body-main' }),
|
|
2257
2314
|
renderSelectionOverlay('body-main')))),
|
|
@@ -2261,7 +2318,7 @@ function Table(props) {
|
|
|
2261
2318
|
React.createElement(Summary, { style: { left: frozenColumnsWidth }, role: 'rfdg-summary' },
|
|
2262
2319
|
React.createElement(TableSummary_1.TableSummary, { position: 'bottom' })))))),
|
|
2263
2320
|
React.createElement(BodyViewport, { ref: bodyContainerRef, style: { top: stickyTopHeight, height: contentBodyHeight }, "data-last": !page ? 'true' : undefined },
|
|
2264
|
-
((
|
|
2321
|
+
((_5 = rowReorderController.preview) === null || _5 === void 0 ? void 0 : _5.visible) && (React.createElement("div", { className: 'bgrid-row-reorder-preview', "data-bgrid-row-reorder-phase": rowReorderController.preview.phase, "aria-hidden": 'true' }, rowReorderController.preview.text)),
|
|
2265
2322
|
React.createElement(Loading_1.default, { active: !!spinning, size: 'small' })),
|
|
2266
2323
|
React.createElement("div", { className: 'bgrid-visually-hidden', role: 'status', "aria-live": 'polite', "aria-atomic": 'true' }, rowReorderController.announcement),
|
|
2267
2324
|
React.createElement(CellTextEditorGateway_1.CellTextEditorGateway, { containerRef: containerRef }),
|
|
@@ -2343,7 +2400,7 @@ function getCellPositionFromPointer(_a) {
|
|
|
2343
2400
|
var rowIndex = metrics.frozenRowCount > 0 && clientY < frozenRowsBottom
|
|
2344
2401
|
? (0, coordinate_1.clamp)(Math.floor((clientY - bodyRect.top) / metrics.trHeight), 0, metrics.frozenRowCount - 1)
|
|
2345
2402
|
: (0, coordinate_1.clamp)(metrics.frozenRowCount +
|
|
2346
|
-
Math.floor((
|
|
2403
|
+
Math.floor((metrics.scrollTop +
|
|
2347
2404
|
(0, coordinate_1.clamp)(clientY - scrollRect.top, 0, Math.max(scrollContainer.clientHeight - 1, 0))) /
|
|
2348
2405
|
metrics.trHeight), 0, metrics.dataLength - 1);
|
|
2349
2406
|
var columnIndex = getColumnIndexFromPointer({
|