@vuu-ui/vuu-table 0.8.20-debug → 0.8.21-debug
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/cjs/index.js +335 -305
- package/cjs/index.js.map +4 -4
- package/esm/index.js +270 -234
- package/esm/index.js.map +4 -4
- package/index.css +1 -0
- package/index.css.map +2 -2
- package/package.json +9 -8
- package/types/Table.d.ts +6 -1
- package/types/index.d.ts +1 -0
- package/types/table-dom-utils.d.ts +3 -0
- package/types/useKeyboardNavigation.d.ts +1 -1
- package/types/useTable.d.ts +5 -2
- package/types/useTableScroll.d.ts +23 -10
- package/types/useTableViewport.d.ts +2 -0
- package/types/useVirtualViewport.d.ts +0 -13
package/esm/index.js
CHANGED
|
@@ -412,7 +412,7 @@ import { useForkRef } from "@salt-ds/core";
|
|
|
412
412
|
import cx9 from "clsx";
|
|
413
413
|
import {
|
|
414
414
|
forwardRef,
|
|
415
|
-
useRef as
|
|
415
|
+
useRef as useRef14,
|
|
416
416
|
useState as useState7
|
|
417
417
|
} from "react";
|
|
418
418
|
|
|
@@ -575,7 +575,6 @@ var Row = memo(
|
|
|
575
575
|
"div",
|
|
576
576
|
{
|
|
577
577
|
...htmlAttributes,
|
|
578
|
-
"aria-rowindex": row[0] + 1,
|
|
579
578
|
key: `row-${row[0]}`,
|
|
580
579
|
role: "row",
|
|
581
580
|
className,
|
|
@@ -607,12 +606,12 @@ Row.displayName = "Row";
|
|
|
607
606
|
|
|
608
607
|
// src/useTable.ts
|
|
609
608
|
import {
|
|
610
|
-
|
|
609
|
+
useDragDrop
|
|
611
610
|
} from "@vuu-ui/vuu-ui-controls";
|
|
612
611
|
import {
|
|
613
612
|
applySort,
|
|
614
613
|
buildColumnMap as buildColumnMap2,
|
|
615
|
-
getIndexFromRowElement as
|
|
614
|
+
getIndexFromRowElement as getIndexFromRowElement3,
|
|
616
615
|
isGroupColumn as isGroupColumn3,
|
|
617
616
|
isJsonGroup as isJsonGroup2,
|
|
618
617
|
isValidNumber,
|
|
@@ -621,9 +620,9 @@ import {
|
|
|
621
620
|
useLayoutEffectSkipFirst as useLayoutEffectSkipFirst2
|
|
622
621
|
} from "@vuu-ui/vuu-utils";
|
|
623
622
|
import {
|
|
624
|
-
useCallback as
|
|
623
|
+
useCallback as useCallback18,
|
|
625
624
|
useEffect as useEffect4,
|
|
626
|
-
useMemo as
|
|
625
|
+
useMemo as useMemo6,
|
|
627
626
|
useState as useState6
|
|
628
627
|
} from "react";
|
|
629
628
|
|
|
@@ -952,7 +951,7 @@ import {
|
|
|
952
951
|
|
|
953
952
|
// src/table-dom-utils.ts
|
|
954
953
|
var headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell:nth-child(${colIdx})`;
|
|
955
|
-
var dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
954
|
+
var dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx + 1}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
956
955
|
var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
957
956
|
var _a;
|
|
958
957
|
const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
|
|
@@ -1224,6 +1223,7 @@ var useInitialValue = (value) => {
|
|
|
1224
1223
|
};
|
|
1225
1224
|
|
|
1226
1225
|
// src/useKeyboardNavigation.ts
|
|
1226
|
+
import { getIndexFromRowElement } from "@vuu-ui/vuu-utils";
|
|
1227
1227
|
import { useControlled } from "@salt-ds/core";
|
|
1228
1228
|
import {
|
|
1229
1229
|
useCallback as useCallback12,
|
|
@@ -1254,51 +1254,6 @@ var isNavigationKey = (key, navigationStyle) => {
|
|
|
1254
1254
|
var PageKeys = ["Home", "End", "PageUp", "PageDown"];
|
|
1255
1255
|
var isPagingKey = (key) => PageKeys.includes(key);
|
|
1256
1256
|
var NULL_CELL_POS = [-1, -1];
|
|
1257
|
-
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1258
|
-
var howFarIsRowOutsideViewport = (rowEl, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1259
|
-
if (contentContainer) {
|
|
1260
|
-
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1261
|
-
const row = rowEl.getBoundingClientRect();
|
|
1262
|
-
if (row) {
|
|
1263
|
-
if (row.bottom > viewport.bottom) {
|
|
1264
|
-
return ["down", row.bottom - viewport.bottom];
|
|
1265
|
-
} else if (row.top < viewport.top) {
|
|
1266
|
-
return ["up", row.top - viewport.top];
|
|
1267
|
-
} else {
|
|
1268
|
-
return NO_SCROLL_NECESSARY;
|
|
1269
|
-
}
|
|
1270
|
-
} else {
|
|
1271
|
-
throw Error("Whats going on, row not found");
|
|
1272
|
-
}
|
|
1273
|
-
} else {
|
|
1274
|
-
throw Error("Whats going on, scrollbar container not found");
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
var howFarIsCellOutsideViewport = (cellEl) => {
|
|
1278
|
-
var _a;
|
|
1279
|
-
const contentContainer = cellEl.closest(".vuuTable-contentContainer");
|
|
1280
|
-
if (contentContainer) {
|
|
1281
|
-
const rowEl = cellEl.closest(".vuuTableRow");
|
|
1282
|
-
if (rowEl) {
|
|
1283
|
-
const result = howFarIsRowOutsideViewport(rowEl, contentContainer);
|
|
1284
|
-
if (result !== NO_SCROLL_NECESSARY) {
|
|
1285
|
-
return result;
|
|
1286
|
-
}
|
|
1287
|
-
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1288
|
-
const cell = (_a = cellEl.closest(".vuuTableCell")) == null ? void 0 : _a.getBoundingClientRect();
|
|
1289
|
-
if (cell) {
|
|
1290
|
-
if (cell.right > viewport.right) {
|
|
1291
|
-
return ["right", cell.right + 6 - viewport.right];
|
|
1292
|
-
} else if (cell.left < viewport.left) {
|
|
1293
|
-
return ["left", cell.left - viewport.left];
|
|
1294
|
-
}
|
|
1295
|
-
} else {
|
|
1296
|
-
throw Error("Whats going on, cell not found");
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return NO_SCROLL_NECESSARY;
|
|
1301
|
-
};
|
|
1302
1257
|
function nextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
|
|
1303
1258
|
if (key === "ArrowUp") {
|
|
1304
1259
|
if (rowIdx > -1) {
|
|
@@ -1366,14 +1321,14 @@ var useKeyboardNavigation = ({
|
|
|
1366
1321
|
"[role='columnHeader'],[role='cell']"
|
|
1367
1322
|
);
|
|
1368
1323
|
const getTableCellPos = (tableCell) => {
|
|
1369
|
-
var _a2
|
|
1324
|
+
var _a2;
|
|
1370
1325
|
if (tableCell.role === "columnHeader") {
|
|
1371
1326
|
const colIdx = parseInt((_a2 = tableCell.dataset.idx) != null ? _a2 : "-1", 10);
|
|
1372
1327
|
return [-1, colIdx];
|
|
1373
1328
|
} else {
|
|
1374
1329
|
const focusedRow = tableCell.closest("[role='row']");
|
|
1375
1330
|
if (focusedRow) {
|
|
1376
|
-
const rowIdx =
|
|
1331
|
+
const rowIdx = getIndexFromRowElement(focusedRow);
|
|
1377
1332
|
const colIdx = Array.from(focusedRow.childNodes).indexOf(tableCell);
|
|
1378
1333
|
return [rowIdx, colIdx];
|
|
1379
1334
|
}
|
|
@@ -1391,11 +1346,8 @@ var useKeyboardNavigation = ({
|
|
|
1391
1346
|
focusableCell.current = activeCell;
|
|
1392
1347
|
activeCell.setAttribute("tabindex", "0");
|
|
1393
1348
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
1397
|
-
}
|
|
1398
|
-
console.log(`activeCell focus`);
|
|
1349
|
+
console.log(`scroll row ${cellPos[0]}`);
|
|
1350
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex: cellPos[0] });
|
|
1399
1351
|
activeCell.focus({ preventScroll: true });
|
|
1400
1352
|
}
|
|
1401
1353
|
}
|
|
@@ -1477,18 +1429,9 @@ var useKeyboardNavigation = ({
|
|
|
1477
1429
|
);
|
|
1478
1430
|
const scrollRowIntoViewIfNecessary = useCallback12(
|
|
1479
1431
|
(rowIndex) => {
|
|
1480
|
-
|
|
1481
|
-
const activeRow = container == null ? void 0 : container.querySelector(
|
|
1482
|
-
`[aria-rowindex="${rowIndex}"]`
|
|
1483
|
-
);
|
|
1484
|
-
if (activeRow) {
|
|
1485
|
-
const [direction, distance] = howFarIsRowOutsideViewport(activeRow);
|
|
1486
|
-
if (direction && distance) {
|
|
1487
|
-
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1432
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex });
|
|
1490
1433
|
},
|
|
1491
|
-
[
|
|
1434
|
+
[requestScroll]
|
|
1492
1435
|
);
|
|
1493
1436
|
const moveHighlightedRow = useCallback12(
|
|
1494
1437
|
async (key) => {
|
|
@@ -1649,7 +1592,7 @@ var useSelection = ({
|
|
|
1649
1592
|
|
|
1650
1593
|
// src/useTableContextMenu.ts
|
|
1651
1594
|
import { useContextMenu as usePopupContextMenu } from "@vuu-ui/vuu-popups";
|
|
1652
|
-
import { buildColumnMap, getIndexFromRowElement } from "@vuu-ui/vuu-utils";
|
|
1595
|
+
import { buildColumnMap, getIndexFromRowElement as getIndexFromRowElement2 } from "@vuu-ui/vuu-utils";
|
|
1653
1596
|
import { useCallback as useCallback14 } from "react";
|
|
1654
1597
|
var NO_ROWS = [];
|
|
1655
1598
|
var useTableContextMenu = ({
|
|
@@ -1667,7 +1610,7 @@ var useTableContextMenu = ({
|
|
|
1667
1610
|
if (cellEl && rowEl) {
|
|
1668
1611
|
const { selectedRowsCount } = dataSource;
|
|
1669
1612
|
const columnMap = buildColumnMap(columns);
|
|
1670
|
-
const rowIndex =
|
|
1613
|
+
const rowIndex = getIndexFromRowElement2(rowEl);
|
|
1671
1614
|
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
1672
1615
|
const row = data.find(([idx]) => idx === rowIndex);
|
|
1673
1616
|
const columnName = columns[cellIndex];
|
|
@@ -1998,7 +1941,14 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
1998
1941
|
}
|
|
1999
1942
|
|
|
2000
1943
|
// src/useTableScroll.ts
|
|
2001
|
-
import {
|
|
1944
|
+
import { getRowElementAtIndex } from "@vuu-ui/vuu-utils";
|
|
1945
|
+
import {
|
|
1946
|
+
useCallback as useCallback15,
|
|
1947
|
+
useEffect as useEffect3,
|
|
1948
|
+
useImperativeHandle,
|
|
1949
|
+
useMemo as useMemo4,
|
|
1950
|
+
useRef as useRef10
|
|
1951
|
+
} from "react";
|
|
2002
1952
|
var getPctScroll = (container) => {
|
|
2003
1953
|
const { scrollLeft, scrollTop } = container;
|
|
2004
1954
|
const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
|
|
@@ -2006,6 +1956,31 @@ var getPctScroll = (container) => {
|
|
|
2006
1956
|
const pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
2007
1957
|
return [pctScrollLeft, pctScrollTop];
|
|
2008
1958
|
};
|
|
1959
|
+
var noScrolling = {
|
|
1960
|
+
scrollToIndex: () => void 0,
|
|
1961
|
+
scrollToKey: () => void 0
|
|
1962
|
+
};
|
|
1963
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1964
|
+
var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1965
|
+
if (contentContainer) {
|
|
1966
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1967
|
+
const upperBoundary = viewport.top + totalHeaderHeight;
|
|
1968
|
+
const row = rowEl.getBoundingClientRect();
|
|
1969
|
+
if (row) {
|
|
1970
|
+
if (row.bottom > viewport.bottom) {
|
|
1971
|
+
return ["down", row.bottom - viewport.bottom];
|
|
1972
|
+
} else if (row.top < upperBoundary) {
|
|
1973
|
+
return ["up", row.top - upperBoundary];
|
|
1974
|
+
} else {
|
|
1975
|
+
return NO_SCROLL_NECESSARY;
|
|
1976
|
+
}
|
|
1977
|
+
} else {
|
|
1978
|
+
throw Error("Whats going on, row not found");
|
|
1979
|
+
}
|
|
1980
|
+
} else {
|
|
1981
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
2009
1984
|
var useCallbackRef = ({
|
|
2010
1985
|
onAttach,
|
|
2011
1986
|
onDetach
|
|
@@ -2027,17 +2002,37 @@ var useCallbackRef = ({
|
|
|
2027
2002
|
return callbackRef;
|
|
2028
2003
|
};
|
|
2029
2004
|
var useTableScroll = ({
|
|
2030
|
-
|
|
2031
|
-
maxScrollTop,
|
|
2005
|
+
getRowAtPosition,
|
|
2032
2006
|
onHorizontalScroll,
|
|
2033
2007
|
onVerticalScroll,
|
|
2034
|
-
|
|
2035
|
-
|
|
2008
|
+
scrollingApiRef,
|
|
2009
|
+
setRange,
|
|
2010
|
+
viewportMeasurements
|
|
2036
2011
|
}) => {
|
|
2012
|
+
const firstRowRef = useRef10(0);
|
|
2037
2013
|
const contentContainerScrolledRef = useRef10(false);
|
|
2038
2014
|
const scrollPosRef = useRef10({ scrollTop: 0, scrollLeft: 0 });
|
|
2039
2015
|
const scrollbarContainerRef = useRef10(null);
|
|
2040
2016
|
const contentContainerRef = useRef10(null);
|
|
2017
|
+
const {
|
|
2018
|
+
appliedPageSize,
|
|
2019
|
+
isVirtualScroll,
|
|
2020
|
+
maxScrollContainerScrollHorizontal: maxScrollLeft,
|
|
2021
|
+
maxScrollContainerScrollVertical: maxScrollTop,
|
|
2022
|
+
rowCount: viewportRowCount,
|
|
2023
|
+
totalHeaderHeight
|
|
2024
|
+
} = viewportMeasurements;
|
|
2025
|
+
const handleVerticalScroll = useCallback15(
|
|
2026
|
+
(scrollTop, pctScrollTop) => {
|
|
2027
|
+
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
2028
|
+
const firstRow = getRowAtPosition(scrollTop);
|
|
2029
|
+
if (firstRow !== firstRowRef.current) {
|
|
2030
|
+
firstRowRef.current = firstRow;
|
|
2031
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount + 1 });
|
|
2032
|
+
}
|
|
2033
|
+
},
|
|
2034
|
+
[getRowAtPosition, onVerticalScroll, setRange, viewportRowCount]
|
|
2035
|
+
);
|
|
2041
2036
|
const handleScrollbarContainerScroll = useCallback15(() => {
|
|
2042
2037
|
const { current: contentContainer } = contentContainerRef;
|
|
2043
2038
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
@@ -2047,7 +2042,7 @@ var useTableScroll = ({
|
|
|
2047
2042
|
} else if (contentContainer && scrollbarContainer) {
|
|
2048
2043
|
const [pctScrollLeft, pctScrollTop] = getPctScroll(scrollbarContainer);
|
|
2049
2044
|
const rootScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2050
|
-
const rootScrollTop =
|
|
2045
|
+
const rootScrollTop = pctScrollTop * maxScrollTop;
|
|
2051
2046
|
contentContainer.scrollTo({
|
|
2052
2047
|
left: rootScrollLeft,
|
|
2053
2048
|
top: rootScrollTop,
|
|
@@ -2064,17 +2059,17 @@ var useTableScroll = ({
|
|
|
2064
2059
|
const [pctScrollLeft, pctScrollTop] = getPctScroll(contentContainer);
|
|
2065
2060
|
contentContainerScrolledRef.current = true;
|
|
2066
2061
|
scrollbarContainer.scrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2067
|
-
scrollbarContainer.scrollTop =
|
|
2062
|
+
scrollbarContainer.scrollTop = pctScrollTop * maxScrollTop;
|
|
2068
2063
|
if (scrollPos.scrollTop !== scrollTop) {
|
|
2069
2064
|
scrollPos.scrollTop = scrollTop;
|
|
2070
|
-
|
|
2065
|
+
handleVerticalScroll(scrollTop, pctScrollTop);
|
|
2071
2066
|
}
|
|
2072
2067
|
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
2073
2068
|
scrollPos.scrollLeft = scrollLeft;
|
|
2074
2069
|
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2075
2070
|
}
|
|
2076
2071
|
}
|
|
2077
|
-
}, [maxScrollLeft, maxScrollTop, onHorizontalScroll
|
|
2072
|
+
}, [handleVerticalScroll, maxScrollLeft, maxScrollTop, onHorizontalScroll]);
|
|
2078
2073
|
const handleAttachScrollbarContainer = useCallback15(
|
|
2079
2074
|
(el) => {
|
|
2080
2075
|
scrollbarContainerRef.current = el;
|
|
@@ -2121,37 +2116,60 @@ var useTableScroll = ({
|
|
|
2121
2116
|
if (scrollbarContainer) {
|
|
2122
2117
|
const { scrollLeft, scrollTop } = scrollbarContainer;
|
|
2123
2118
|
contentContainerScrolledRef.current = false;
|
|
2124
|
-
if (scrollRequest.type === "scroll-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
newScrollLeft = Math.min(
|
|
2134
|
-
Math.max(0, scrollLeft + scrollRequest.distance),
|
|
2135
|
-
maxScrollLeft
|
|
2119
|
+
if (scrollRequest.type === "scroll-row") {
|
|
2120
|
+
const activeRow = getRowElementAtIndex(
|
|
2121
|
+
scrollbarContainer,
|
|
2122
|
+
scrollRequest.rowIndex
|
|
2123
|
+
);
|
|
2124
|
+
if (activeRow !== null) {
|
|
2125
|
+
const [direction, distance] = howFarIsRowOutsideViewport(
|
|
2126
|
+
activeRow,
|
|
2127
|
+
totalHeaderHeight
|
|
2136
2128
|
);
|
|
2129
|
+
if (direction && distance) {
|
|
2130
|
+
if (isVirtualScroll) {
|
|
2131
|
+
console.log(
|
|
2132
|
+
`virtual scroll row required ${direction} ${distance}
|
|
2133
|
+
first Row ${firstRowRef.current}`
|
|
2134
|
+
);
|
|
2135
|
+
} else {
|
|
2136
|
+
let newScrollLeft = scrollLeft;
|
|
2137
|
+
let newScrollTop = scrollTop;
|
|
2138
|
+
if (direction === "up" || direction === "down") {
|
|
2139
|
+
newScrollTop = Math.min(
|
|
2140
|
+
Math.max(0, scrollTop + distance),
|
|
2141
|
+
maxScrollTop
|
|
2142
|
+
);
|
|
2143
|
+
} else {
|
|
2144
|
+
newScrollLeft = Math.min(
|
|
2145
|
+
Math.max(0, scrollLeft + distance),
|
|
2146
|
+
maxScrollLeft
|
|
2147
|
+
);
|
|
2148
|
+
}
|
|
2149
|
+
scrollbarContainer.scrollTo({
|
|
2150
|
+
top: newScrollTop,
|
|
2151
|
+
left: newScrollLeft,
|
|
2152
|
+
behavior: "smooth"
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2137
2156
|
}
|
|
2138
|
-
scrollbarContainer.scrollTo({
|
|
2139
|
-
top: newScrollTop,
|
|
2140
|
-
left: newScrollLeft,
|
|
2141
|
-
behavior: "smooth"
|
|
2142
|
-
});
|
|
2143
2157
|
} else if (scrollRequest.type === "scroll-page") {
|
|
2144
2158
|
const { direction } = scrollRequest;
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2159
|
+
if (isVirtualScroll) {
|
|
2160
|
+
console.log(`need a virtual page scroll`);
|
|
2161
|
+
} else {
|
|
2162
|
+
const scrollBy = direction === "down" ? appliedPageSize : -appliedPageSize;
|
|
2163
|
+
const newScrollTop = Math.min(
|
|
2164
|
+
Math.max(0, scrollTop + scrollBy),
|
|
2165
|
+
maxScrollTop
|
|
2166
|
+
);
|
|
2167
|
+
scrollbarContainer.scrollTo({
|
|
2168
|
+
top: newScrollTop,
|
|
2169
|
+
left: scrollLeft,
|
|
2170
|
+
behavior: "auto"
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2155
2173
|
} else if (scrollRequest.type === "scroll-end") {
|
|
2156
2174
|
const { direction } = scrollRequest;
|
|
2157
2175
|
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
@@ -2163,8 +2181,46 @@ var useTableScroll = ({
|
|
|
2163
2181
|
}
|
|
2164
2182
|
}
|
|
2165
2183
|
},
|
|
2166
|
-
[
|
|
2184
|
+
[
|
|
2185
|
+
appliedPageSize,
|
|
2186
|
+
isVirtualScroll,
|
|
2187
|
+
maxScrollLeft,
|
|
2188
|
+
maxScrollTop,
|
|
2189
|
+
setRange,
|
|
2190
|
+
totalHeaderHeight,
|
|
2191
|
+
viewportRowCount
|
|
2192
|
+
]
|
|
2167
2193
|
);
|
|
2194
|
+
const scrollHandles = useMemo4(
|
|
2195
|
+
() => ({
|
|
2196
|
+
scrollToIndex: (rowIndex) => {
|
|
2197
|
+
if (scrollbarContainerRef.current) {
|
|
2198
|
+
const scrollPos = (rowIndex - 30) * 20;
|
|
2199
|
+
scrollbarContainerRef.current.scrollTop = scrollPos;
|
|
2200
|
+
}
|
|
2201
|
+
},
|
|
2202
|
+
scrollToKey: (rowKey) => {
|
|
2203
|
+
console.log(`scrollToKey ${rowKey}`);
|
|
2204
|
+
}
|
|
2205
|
+
}),
|
|
2206
|
+
[]
|
|
2207
|
+
);
|
|
2208
|
+
useImperativeHandle(
|
|
2209
|
+
scrollingApiRef,
|
|
2210
|
+
() => {
|
|
2211
|
+
if (scrollbarContainerRef.current) {
|
|
2212
|
+
return scrollHandles;
|
|
2213
|
+
} else {
|
|
2214
|
+
return noScrolling;
|
|
2215
|
+
}
|
|
2216
|
+
},
|
|
2217
|
+
[scrollHandles]
|
|
2218
|
+
);
|
|
2219
|
+
useEffect3(() => {
|
|
2220
|
+
const { current: from } = firstRowRef;
|
|
2221
|
+
const rowRange = { from, to: from + viewportRowCount + 1 };
|
|
2222
|
+
setRange(rowRange);
|
|
2223
|
+
}, [setRange, viewportRowCount]);
|
|
2168
2224
|
return {
|
|
2169
2225
|
/** Ref to be assigned to ScrollbarContainer */
|
|
2170
2226
|
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
@@ -2176,18 +2232,20 @@ var useTableScroll = ({
|
|
|
2176
2232
|
};
|
|
2177
2233
|
|
|
2178
2234
|
// src/useTableViewport.ts
|
|
2179
|
-
import { useCallback as useCallback16, useMemo as
|
|
2235
|
+
import { useCallback as useCallback16, useMemo as useMemo5, useRef as useRef11 } from "react";
|
|
2180
2236
|
import {
|
|
2181
2237
|
actualRowPositioning,
|
|
2182
2238
|
virtualRowPositioning
|
|
2183
2239
|
} from "@vuu-ui/vuu-utils";
|
|
2184
|
-
var MAX_RAW_ROWS =
|
|
2240
|
+
var MAX_RAW_ROWS = 1e5;
|
|
2185
2241
|
var UNMEASURED_VIEWPORT = {
|
|
2242
|
+
appliedPageSize: 0,
|
|
2186
2243
|
contentHeight: 0,
|
|
2187
2244
|
contentWidth: 0,
|
|
2188
2245
|
getRowAtPosition: () => -1,
|
|
2189
2246
|
getRowOffset: () => -1,
|
|
2190
2247
|
horizontalScrollbarHeight: 0,
|
|
2248
|
+
isVirtualScroll: false,
|
|
2191
2249
|
maxScrollContainerScrollHorizontal: 0,
|
|
2192
2250
|
maxScrollContainerScrollVertical: 0,
|
|
2193
2251
|
pinnedWidthLeft: 0,
|
|
@@ -2228,19 +2286,18 @@ var useTableViewport = ({
|
|
|
2228
2286
|
size
|
|
2229
2287
|
}) => {
|
|
2230
2288
|
const pctScrollTopRef = useRef11(0);
|
|
2231
|
-
const
|
|
2232
|
-
const appliedContentHeight = appliedRowCount * rowHeight;
|
|
2289
|
+
const pixelContentHeight = rowHeight * Math.min(rowCount, MAX_RAW_ROWS);
|
|
2233
2290
|
const virtualContentHeight = rowCount * rowHeight;
|
|
2234
|
-
const virtualisedExtent = virtualContentHeight -
|
|
2235
|
-
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } =
|
|
2291
|
+
const virtualisedExtent = virtualContentHeight - pixelContentHeight;
|
|
2292
|
+
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = useMemo5(
|
|
2236
2293
|
() => measurePinnedColumns(columns),
|
|
2237
2294
|
[columns]
|
|
2238
2295
|
);
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
);
|
|
2243
|
-
const [getRowOffset, getRowAtPosition] =
|
|
2296
|
+
const totalHeaderHeightRef = useRef11(headerHeight);
|
|
2297
|
+
useMemo5(() => {
|
|
2298
|
+
totalHeaderHeightRef.current = headerHeight * (1 + headings.length);
|
|
2299
|
+
}, [headerHeight, headings.length]);
|
|
2300
|
+
const [getRowOffset, getRowAtPosition, isVirtualScroll] = useMemo5(() => {
|
|
2244
2301
|
if (virtualisedExtent) {
|
|
2245
2302
|
return virtualRowPositioning(
|
|
2246
2303
|
rowHeight,
|
|
@@ -2248,37 +2305,39 @@ var useTableViewport = ({
|
|
|
2248
2305
|
pctScrollTopRef
|
|
2249
2306
|
);
|
|
2250
2307
|
} else {
|
|
2251
|
-
return
|
|
2308
|
+
return actualRowPositioning(rowHeight);
|
|
2252
2309
|
}
|
|
2253
|
-
}, [
|
|
2310
|
+
}, [virtualisedExtent, rowHeight]);
|
|
2254
2311
|
const setPctScrollTop = useCallback16((scrollPct) => {
|
|
2255
2312
|
pctScrollTopRef.current = scrollPct;
|
|
2256
2313
|
}, []);
|
|
2257
|
-
return
|
|
2314
|
+
return useMemo5(() => {
|
|
2258
2315
|
var _a;
|
|
2259
2316
|
if (size) {
|
|
2260
|
-
const
|
|
2317
|
+
const { current: totalHeaderHeight } = totalHeaderHeightRef;
|
|
2261
2318
|
const scrollbarSize = 15;
|
|
2262
2319
|
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
2263
2320
|
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
2264
|
-
const
|
|
2265
|
-
const maxScrollContainerScrollVertical = appliedContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2321
|
+
const maxScrollContainerScrollVertical = pixelContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2266
2322
|
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
2267
2323
|
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
2268
|
-
const count = Number.isInteger(visibleRows) ? visibleRows
|
|
2324
|
+
const count = Number.isInteger(visibleRows) ? visibleRows : Math.ceil(visibleRows);
|
|
2269
2325
|
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
2270
|
-
const verticalScrollbarWidth =
|
|
2326
|
+
const verticalScrollbarWidth = pixelContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
2327
|
+
const appliedPageSize = count * rowHeight * (pixelContentHeight / virtualContentHeight);
|
|
2271
2328
|
return {
|
|
2272
|
-
|
|
2329
|
+
appliedPageSize,
|
|
2330
|
+
contentHeight: pixelContentHeight,
|
|
2331
|
+
contentWidth,
|
|
2273
2332
|
getRowAtPosition,
|
|
2274
2333
|
getRowOffset,
|
|
2334
|
+
isVirtualScroll,
|
|
2275
2335
|
horizontalScrollbarHeight,
|
|
2276
2336
|
maxScrollContainerScrollHorizontal,
|
|
2277
2337
|
maxScrollContainerScrollVertical,
|
|
2278
2338
|
pinnedWidthLeft,
|
|
2279
2339
|
pinnedWidthRight,
|
|
2280
2340
|
rowCount: count,
|
|
2281
|
-
contentWidth,
|
|
2282
2341
|
setPctScrollTop,
|
|
2283
2342
|
totalHeaderHeight,
|
|
2284
2343
|
verticalScrollbarWidth,
|
|
@@ -2288,53 +2347,25 @@ var useTableViewport = ({
|
|
|
2288
2347
|
return UNMEASURED_VIEWPORT;
|
|
2289
2348
|
}
|
|
2290
2349
|
}, [
|
|
2291
|
-
|
|
2292
|
-
|
|
2350
|
+
getRowAtPosition,
|
|
2351
|
+
getRowOffset,
|
|
2352
|
+
headerHeight,
|
|
2353
|
+
isVirtualScroll,
|
|
2293
2354
|
pinnedWidthLeft,
|
|
2294
2355
|
unpinnedWidth,
|
|
2295
2356
|
pinnedWidthRight,
|
|
2296
|
-
|
|
2297
|
-
headerHeight,
|
|
2357
|
+
pixelContentHeight,
|
|
2298
2358
|
rowHeight,
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2359
|
+
setPctScrollTop,
|
|
2360
|
+
size,
|
|
2361
|
+
virtualContentHeight
|
|
2302
2362
|
]);
|
|
2303
2363
|
};
|
|
2304
2364
|
|
|
2305
|
-
// src/useVirtualViewport.ts
|
|
2306
|
-
import { useCallback as useCallback17, useEffect as useEffect3, useRef as useRef12 } from "react";
|
|
2307
|
-
var useVirtualViewport = ({
|
|
2308
|
-
getRowAtPosition,
|
|
2309
|
-
setRange,
|
|
2310
|
-
viewportMeasurements
|
|
2311
|
-
}) => {
|
|
2312
|
-
const firstRowRef = useRef12(0);
|
|
2313
|
-
const { rowCount: viewportRowCount } = viewportMeasurements;
|
|
2314
|
-
const handleVerticalScroll = useCallback17(
|
|
2315
|
-
(scrollTop) => {
|
|
2316
|
-
const firstRow = getRowAtPosition(scrollTop);
|
|
2317
|
-
if (firstRow !== firstRowRef.current) {
|
|
2318
|
-
firstRowRef.current = firstRow;
|
|
2319
|
-
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2320
|
-
}
|
|
2321
|
-
},
|
|
2322
|
-
[getRowAtPosition, setRange, viewportRowCount]
|
|
2323
|
-
);
|
|
2324
|
-
useEffect3(() => {
|
|
2325
|
-
const { current: from } = firstRowRef;
|
|
2326
|
-
const rowRange = { from, to: from + viewportRowCount };
|
|
2327
|
-
setRange(rowRange);
|
|
2328
|
-
}, [setRange, viewportRowCount]);
|
|
2329
|
-
return {
|
|
2330
|
-
onVerticalScroll: handleVerticalScroll
|
|
2331
|
-
};
|
|
2332
|
-
};
|
|
2333
|
-
|
|
2334
2365
|
// src/useTableAndColumnSettings.ts
|
|
2335
2366
|
import { useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
|
|
2336
2367
|
import { getCalculatedColumnType } from "@vuu-ui/vuu-utils";
|
|
2337
|
-
import { useCallback as
|
|
2368
|
+
import { useCallback as useCallback17, useRef as useRef12, useState as useState5 } from "react";
|
|
2338
2369
|
var useTableAndColumnSettings = ({
|
|
2339
2370
|
availableColumns: availableColumnsProps,
|
|
2340
2371
|
onAvailableColumnsChange,
|
|
@@ -2344,11 +2375,11 @@ var useTableAndColumnSettings = ({
|
|
|
2344
2375
|
tableConfig
|
|
2345
2376
|
}) => {
|
|
2346
2377
|
const dispatchLayoutAction = useLayoutProviderDispatch();
|
|
2347
|
-
const showTableSettingsRef =
|
|
2378
|
+
const showTableSettingsRef = useRef12();
|
|
2348
2379
|
const [availableColumns, setAvailableColumns] = useState5(
|
|
2349
2380
|
availableColumnsProps
|
|
2350
2381
|
);
|
|
2351
|
-
const showContextPanel =
|
|
2382
|
+
const showContextPanel = useCallback17(
|
|
2352
2383
|
(componentType, title, props) => {
|
|
2353
2384
|
dispatchLayoutAction({
|
|
2354
2385
|
type: "set-props",
|
|
@@ -2365,13 +2396,13 @@ var useTableAndColumnSettings = ({
|
|
|
2365
2396
|
},
|
|
2366
2397
|
[dispatchLayoutAction]
|
|
2367
2398
|
);
|
|
2368
|
-
const handleCancelCreateColumn =
|
|
2399
|
+
const handleCancelCreateColumn = useCallback17(() => {
|
|
2369
2400
|
requestAnimationFrame(() => {
|
|
2370
2401
|
var _a;
|
|
2371
2402
|
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2372
2403
|
});
|
|
2373
2404
|
}, []);
|
|
2374
|
-
const handleCreateCalculatedColumn =
|
|
2405
|
+
const handleCreateCalculatedColumn = useCallback17(
|
|
2375
2406
|
(column) => {
|
|
2376
2407
|
const newAvailableColumns = availableColumns.concat({
|
|
2377
2408
|
name: column.name,
|
|
@@ -2387,7 +2418,7 @@ var useTableAndColumnSettings = ({
|
|
|
2387
2418
|
},
|
|
2388
2419
|
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2389
2420
|
);
|
|
2390
|
-
const showColumnSettingsPanel =
|
|
2421
|
+
const showColumnSettingsPanel = useCallback17(
|
|
2391
2422
|
(action) => {
|
|
2392
2423
|
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2393
2424
|
column: action.column,
|
|
@@ -2406,7 +2437,7 @@ var useTableAndColumnSettings = ({
|
|
|
2406
2437
|
tableConfig
|
|
2407
2438
|
]
|
|
2408
2439
|
);
|
|
2409
|
-
const handleAddCalculatedColumn =
|
|
2440
|
+
const handleAddCalculatedColumn = useCallback17(() => {
|
|
2410
2441
|
showColumnSettingsPanel({
|
|
2411
2442
|
column: {
|
|
2412
2443
|
name: "::",
|
|
@@ -2416,7 +2447,7 @@ var useTableAndColumnSettings = ({
|
|
|
2416
2447
|
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2417
2448
|
});
|
|
2418
2449
|
}, [showColumnSettingsPanel]);
|
|
2419
|
-
const handleNavigateToColumn =
|
|
2450
|
+
const handleNavigateToColumn = useCallback17(
|
|
2420
2451
|
(columnName) => {
|
|
2421
2452
|
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2422
2453
|
if (column) {
|
|
@@ -2430,7 +2461,7 @@ var useTableAndColumnSettings = ({
|
|
|
2430
2461
|
},
|
|
2431
2462
|
[showColumnSettingsPanel, tableConfig.columns]
|
|
2432
2463
|
);
|
|
2433
|
-
showTableSettingsRef.current =
|
|
2464
|
+
showTableSettingsRef.current = useCallback17(() => {
|
|
2434
2465
|
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2435
2466
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2436
2467
|
name,
|
|
@@ -2493,6 +2524,7 @@ var useTable = ({
|
|
|
2493
2524
|
onSelectionChange,
|
|
2494
2525
|
renderBufferSize = 0,
|
|
2495
2526
|
rowHeight = 20,
|
|
2527
|
+
scrollingApiRef,
|
|
2496
2528
|
selectionModel,
|
|
2497
2529
|
size
|
|
2498
2530
|
}) => {
|
|
@@ -2501,11 +2533,11 @@ var useTable = ({
|
|
|
2501
2533
|
throw Error("no data source provided to Vuu Table");
|
|
2502
2534
|
}
|
|
2503
2535
|
const useRowDragDrop = allowDragDrop ? useDragDrop : useNullDragDrop;
|
|
2504
|
-
const menuBuilder =
|
|
2536
|
+
const menuBuilder = useMemo6(
|
|
2505
2537
|
() => buildContextMenuDescriptors(dataSource),
|
|
2506
2538
|
[dataSource]
|
|
2507
2539
|
);
|
|
2508
|
-
const onDataRowcountChange =
|
|
2540
|
+
const onDataRowcountChange = useCallback18((size2) => {
|
|
2509
2541
|
setRowCount(size2);
|
|
2510
2542
|
}, []);
|
|
2511
2543
|
const {
|
|
@@ -2522,7 +2554,7 @@ var useTable = ({
|
|
|
2522
2554
|
tableConfig
|
|
2523
2555
|
});
|
|
2524
2556
|
}, [tableConfig, dataSource, dispatchColumnAction]);
|
|
2525
|
-
const applyTableConfigChange =
|
|
2557
|
+
const applyTableConfigChange = useCallback18(
|
|
2526
2558
|
(config2) => {
|
|
2527
2559
|
dispatchColumnAction({
|
|
2528
2560
|
type: "init",
|
|
@@ -2534,14 +2566,14 @@ var useTable = ({
|
|
|
2534
2566
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2535
2567
|
);
|
|
2536
2568
|
const [stateColumns, setStateColumns] = useState6();
|
|
2537
|
-
const [columns, setColumnSize] =
|
|
2569
|
+
const [columns, setColumnSize] = useMemo6(() => {
|
|
2538
2570
|
const setSize = (columnName, width) => {
|
|
2539
2571
|
const cols = updateColumn(runtimeColumns, columnName, { width });
|
|
2540
2572
|
setStateColumns(cols);
|
|
2541
2573
|
};
|
|
2542
2574
|
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2543
2575
|
}, [runtimeColumns, stateColumns]);
|
|
2544
|
-
const columnMap =
|
|
2576
|
+
const columnMap = useMemo6(
|
|
2545
2577
|
() => buildColumnMap2(dataSource.columns),
|
|
2546
2578
|
[dataSource.columns]
|
|
2547
2579
|
);
|
|
@@ -2560,9 +2592,9 @@ var useTable = ({
|
|
|
2560
2592
|
});
|
|
2561
2593
|
const initialRange = useInitialValue({
|
|
2562
2594
|
from: 0,
|
|
2563
|
-
to: viewportMeasurements.rowCount
|
|
2595
|
+
to: viewportMeasurements.rowCount === 0 ? 0 : viewportMeasurements.rowCount + 1
|
|
2564
2596
|
});
|
|
2565
|
-
const onSubscribed =
|
|
2597
|
+
const onSubscribed = useCallback18(
|
|
2566
2598
|
({ tableSchema }) => {
|
|
2567
2599
|
if (tableSchema) {
|
|
2568
2600
|
dispatchColumnAction({
|
|
@@ -2584,9 +2616,8 @@ var useTable = ({
|
|
|
2584
2616
|
onSubscribed,
|
|
2585
2617
|
range: initialRange
|
|
2586
2618
|
});
|
|
2587
|
-
const handleConfigEditedInSettingsPanel =
|
|
2619
|
+
const handleConfigEditedInSettingsPanel = useCallback18(
|
|
2588
2620
|
(tableConfig2) => {
|
|
2589
|
-
console.log(`settings changed`);
|
|
2590
2621
|
dispatchColumnAction({
|
|
2591
2622
|
type: "init",
|
|
2592
2623
|
tableConfig: tableConfig2,
|
|
@@ -2596,7 +2627,7 @@ var useTable = ({
|
|
|
2596
2627
|
},
|
|
2597
2628
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2598
2629
|
);
|
|
2599
|
-
const handleDataSourceConfigChanged =
|
|
2630
|
+
const handleDataSourceConfigChanged = useCallback18(
|
|
2600
2631
|
(dataSourceConfig) => {
|
|
2601
2632
|
dataSource.config = {
|
|
2602
2633
|
...dataSource.config,
|
|
@@ -2614,14 +2645,14 @@ var useTable = ({
|
|
|
2614
2645
|
});
|
|
2615
2646
|
});
|
|
2616
2647
|
}, [dataSource, dispatchColumnAction]);
|
|
2617
|
-
const handleCreateCalculatedColumn =
|
|
2648
|
+
const handleCreateCalculatedColumn = useCallback18(
|
|
2618
2649
|
(column) => {
|
|
2619
2650
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2620
2651
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2621
2652
|
},
|
|
2622
2653
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2623
2654
|
);
|
|
2624
|
-
const hideColumns2 =
|
|
2655
|
+
const hideColumns2 = useCallback18(
|
|
2625
2656
|
(action) => {
|
|
2626
2657
|
const { columns: columns2 } = action;
|
|
2627
2658
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2635,7 +2666,7 @@ var useTable = ({
|
|
|
2635
2666
|
},
|
|
2636
2667
|
[tableConfig, applyTableConfigChange]
|
|
2637
2668
|
);
|
|
2638
|
-
const pinColumn3 =
|
|
2669
|
+
const pinColumn3 = useCallback18(
|
|
2639
2670
|
(action) => {
|
|
2640
2671
|
applyTableConfigChange({
|
|
2641
2672
|
...tableConfig,
|
|
@@ -2658,7 +2689,7 @@ var useTable = ({
|
|
|
2658
2689
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2659
2690
|
tableConfig
|
|
2660
2691
|
});
|
|
2661
|
-
const onPersistentColumnOperation =
|
|
2692
|
+
const onPersistentColumnOperation = useCallback18(
|
|
2662
2693
|
(action) => {
|
|
2663
2694
|
if (isShowColumnSettings(action)) {
|
|
2664
2695
|
showColumnSettingsPanel(action);
|
|
@@ -2687,7 +2718,7 @@ var useTable = ({
|
|
|
2687
2718
|
dataSource,
|
|
2688
2719
|
onPersistentColumnOperation
|
|
2689
2720
|
});
|
|
2690
|
-
const handleSort =
|
|
2721
|
+
const handleSort = useCallback18(
|
|
2691
2722
|
(column, extendSort = false, sortType) => {
|
|
2692
2723
|
if (dataSource) {
|
|
2693
2724
|
dataSource.sort = applySort(
|
|
@@ -2700,7 +2731,7 @@ var useTable = ({
|
|
|
2700
2731
|
},
|
|
2701
2732
|
[dataSource]
|
|
2702
2733
|
);
|
|
2703
|
-
const onResizeColumn =
|
|
2734
|
+
const onResizeColumn = useCallback18(
|
|
2704
2735
|
(phase, columnName, width) => {
|
|
2705
2736
|
const column = columns.find((column2) => column2.name === columnName);
|
|
2706
2737
|
if (column) {
|
|
@@ -2744,7 +2775,7 @@ var useTable = ({
|
|
|
2744
2775
|
},
|
|
2745
2776
|
[columns, tableConfig, dispatchColumnAction, onConfigChange, setColumnSize]
|
|
2746
2777
|
);
|
|
2747
|
-
const onToggleGroup =
|
|
2778
|
+
const onToggleGroup = useCallback18(
|
|
2748
2779
|
(row, column) => {
|
|
2749
2780
|
var _a, _b;
|
|
2750
2781
|
const isJson = isJsonGroup2(column, row);
|
|
@@ -2781,24 +2812,19 @@ var useTable = ({
|
|
|
2781
2812
|
},
|
|
2782
2813
|
[columns, dataSource, dispatchColumnAction]
|
|
2783
2814
|
);
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
setRange,
|
|
2788
|
-
viewportMeasurements
|
|
2789
|
-
});
|
|
2790
|
-
const handleVerticalScroll = useCallback19(
|
|
2791
|
-
(scrollTop) => {
|
|
2792
|
-
onVerticalScroll(scrollTop);
|
|
2815
|
+
const handleVerticalScroll = useCallback18(
|
|
2816
|
+
(_, pctScrollTop) => {
|
|
2817
|
+
setPctScrollTop(pctScrollTop);
|
|
2793
2818
|
},
|
|
2794
|
-
[
|
|
2819
|
+
[setPctScrollTop]
|
|
2795
2820
|
);
|
|
2796
2821
|
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2797
|
-
|
|
2798
|
-
maxScrollTop: viewportMeasurements.maxScrollContainerScrollVertical,
|
|
2822
|
+
getRowAtPosition,
|
|
2799
2823
|
rowHeight,
|
|
2824
|
+
scrollingApiRef,
|
|
2825
|
+
setRange,
|
|
2800
2826
|
onVerticalScroll: handleVerticalScroll,
|
|
2801
|
-
|
|
2827
|
+
viewportMeasurements
|
|
2802
2828
|
});
|
|
2803
2829
|
const {
|
|
2804
2830
|
highlightedIndexRef,
|
|
@@ -2826,7 +2852,7 @@ var useTable = ({
|
|
|
2826
2852
|
} = useCellEditing({
|
|
2827
2853
|
navigate
|
|
2828
2854
|
});
|
|
2829
|
-
const handleFocus =
|
|
2855
|
+
const handleFocus = useCallback18(
|
|
2830
2856
|
(e) => {
|
|
2831
2857
|
navigationFocus();
|
|
2832
2858
|
if (!e.defaultPrevented) {
|
|
@@ -2841,13 +2867,13 @@ var useTable = ({
|
|
|
2841
2867
|
dataSource,
|
|
2842
2868
|
getSelectedRows
|
|
2843
2869
|
});
|
|
2844
|
-
const onMoveGroupColumn =
|
|
2870
|
+
const onMoveGroupColumn = useCallback18(
|
|
2845
2871
|
(columns2) => {
|
|
2846
2872
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2847
2873
|
},
|
|
2848
2874
|
[dataSource]
|
|
2849
2875
|
);
|
|
2850
|
-
const onRemoveGroupColumn =
|
|
2876
|
+
const onRemoveGroupColumn = useCallback18(
|
|
2851
2877
|
(column) => {
|
|
2852
2878
|
if (isGroupColumn3(column)) {
|
|
2853
2879
|
dataSource.groupBy = [];
|
|
@@ -2861,7 +2887,7 @@ var useTable = ({
|
|
|
2861
2887
|
},
|
|
2862
2888
|
[dataSource]
|
|
2863
2889
|
);
|
|
2864
|
-
const handleSelectionChange =
|
|
2890
|
+
const handleSelectionChange = useCallback18(
|
|
2865
2891
|
(selected) => {
|
|
2866
2892
|
dataSource.select(selected);
|
|
2867
2893
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
@@ -2877,7 +2903,7 @@ var useTable = ({
|
|
|
2877
2903
|
onSelectionChange: handleSelectionChange,
|
|
2878
2904
|
selectionModel
|
|
2879
2905
|
});
|
|
2880
|
-
const handleKeyDown =
|
|
2906
|
+
const handleKeyDown = useCallback18(
|
|
2881
2907
|
(e) => {
|
|
2882
2908
|
navigationKeyDown(e);
|
|
2883
2909
|
if (!e.defaultPrevented) {
|
|
@@ -2889,7 +2915,7 @@ var useTable = ({
|
|
|
2889
2915
|
},
|
|
2890
2916
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2891
2917
|
);
|
|
2892
|
-
const handleRowClick =
|
|
2918
|
+
const handleRowClick = useCallback18(
|
|
2893
2919
|
(row, rangeSelect, keepExistingSelection) => {
|
|
2894
2920
|
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2895
2921
|
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
@@ -2903,7 +2929,7 @@ var useTable = ({
|
|
|
2903
2929
|
dataSource
|
|
2904
2930
|
});
|
|
2905
2931
|
}, [config, dataSource, dispatchColumnAction]);
|
|
2906
|
-
const onMoveColumn =
|
|
2932
|
+
const onMoveColumn = useCallback18(
|
|
2907
2933
|
(columns2) => {
|
|
2908
2934
|
console.log(`useTable onMoveColumn`, {
|
|
2909
2935
|
columns: columns2
|
|
@@ -2921,20 +2947,20 @@ var useTable = ({
|
|
|
2921
2947
|
},
|
|
2922
2948
|
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2923
2949
|
);
|
|
2924
|
-
const handleDropRow =
|
|
2950
|
+
const handleDropRow = useCallback18(
|
|
2925
2951
|
(dragDropState) => {
|
|
2926
2952
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2927
2953
|
},
|
|
2928
2954
|
[onDrop]
|
|
2929
2955
|
);
|
|
2930
|
-
const handleDataEdited =
|
|
2956
|
+
const handleDataEdited = useCallback18(
|
|
2931
2957
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2932
2958
|
[dataSource]
|
|
2933
2959
|
);
|
|
2934
|
-
const handleDragStartRow =
|
|
2960
|
+
const handleDragStartRow = useCallback18(
|
|
2935
2961
|
(dragDropState) => {
|
|
2936
2962
|
const { initialDragElement } = dragDropState;
|
|
2937
|
-
const rowIndex =
|
|
2963
|
+
const rowIndex = getIndexFromRowElement3(initialDragElement);
|
|
2938
2964
|
const row = dataRef.current.find((row2) => row2[0] === rowIndex);
|
|
2939
2965
|
if (row) {
|
|
2940
2966
|
dragDropState.setPayload(row);
|
|
@@ -2966,6 +2992,7 @@ var useTable = ({
|
|
|
2966
2992
|
columnMap,
|
|
2967
2993
|
columns,
|
|
2968
2994
|
data,
|
|
2995
|
+
getRowOffset,
|
|
2969
2996
|
handleContextMenuAction,
|
|
2970
2997
|
headings,
|
|
2971
2998
|
highlightedIndex: highlightedIndexRef.current,
|
|
@@ -2992,17 +3019,17 @@ import { isGroupColumn as isGroupColumn4, isNotHidden as isNotHidden2 } from "@v
|
|
|
2992
3019
|
import cx8 from "clsx";
|
|
2993
3020
|
|
|
2994
3021
|
// src/table-header/useTableHeader.ts
|
|
2995
|
-
import {
|
|
3022
|
+
import { useDragDrop as useDragDrop2 } from "@vuu-ui/vuu-ui-controls";
|
|
2996
3023
|
import { moveColumnTo, visibleColumnAtIndex } from "@vuu-ui/vuu-utils";
|
|
2997
|
-
import { useCallback as
|
|
3024
|
+
import { useCallback as useCallback19, useRef as useRef13 } from "react";
|
|
2998
3025
|
var useTableHeader = ({
|
|
2999
3026
|
columns,
|
|
3000
3027
|
onMoveColumn,
|
|
3001
3028
|
onSortColumn,
|
|
3002
3029
|
tableConfig
|
|
3003
3030
|
}) => {
|
|
3004
|
-
const containerRef =
|
|
3005
|
-
const handleDropColumnHeader =
|
|
3031
|
+
const containerRef = useRef13(null);
|
|
3032
|
+
const handleDropColumnHeader = useCallback19(
|
|
3006
3033
|
(moveFrom, moveTo) => {
|
|
3007
3034
|
const column = columns[moveFrom];
|
|
3008
3035
|
const orderedColumns = moveColumnTo(columns, column, moveTo);
|
|
@@ -3018,7 +3045,7 @@ var useTableHeader = ({
|
|
|
3018
3045
|
},
|
|
3019
3046
|
[columns, onMoveColumn, tableConfig.columns]
|
|
3020
3047
|
);
|
|
3021
|
-
const handleColumnHeaderClick =
|
|
3048
|
+
const handleColumnHeaderClick = useCallback19(
|
|
3022
3049
|
(evt) => {
|
|
3023
3050
|
var _a;
|
|
3024
3051
|
const targetElement = evt.target;
|
|
@@ -3138,8 +3165,9 @@ var TableCore = ({
|
|
|
3138
3165
|
onRowClick: onRowClickProp,
|
|
3139
3166
|
onSelect,
|
|
3140
3167
|
onSelectionChange,
|
|
3141
|
-
renderBufferSize =
|
|
3168
|
+
renderBufferSize = 5,
|
|
3142
3169
|
rowHeight = 20,
|
|
3170
|
+
scrollingApiRef,
|
|
3143
3171
|
selectionModel = "extended",
|
|
3144
3172
|
showColumnHeaders = true,
|
|
3145
3173
|
headerHeight = showColumnHeaders ? 25 : 0,
|
|
@@ -3151,6 +3179,7 @@ var TableCore = ({
|
|
|
3151
3179
|
columns,
|
|
3152
3180
|
data,
|
|
3153
3181
|
draggableRow,
|
|
3182
|
+
getRowOffset,
|
|
3154
3183
|
handleContextMenuAction,
|
|
3155
3184
|
headings,
|
|
3156
3185
|
highlightedIndex,
|
|
@@ -3190,10 +3219,11 @@ var TableCore = ({
|
|
|
3190
3219
|
onSelectionChange,
|
|
3191
3220
|
renderBufferSize,
|
|
3192
3221
|
rowHeight,
|
|
3222
|
+
scrollingApiRef,
|
|
3193
3223
|
selectionModel,
|
|
3194
3224
|
size
|
|
3195
3225
|
});
|
|
3196
|
-
const
|
|
3226
|
+
const contentContainerClassName = cx9(`${classBase7}-contentContainer`, {
|
|
3197
3227
|
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3198
3228
|
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3199
3229
|
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
@@ -3230,7 +3260,7 @@ var TableCore = ({
|
|
|
3230
3260
|
/* @__PURE__ */ jsx12(
|
|
3231
3261
|
"div",
|
|
3232
3262
|
{
|
|
3233
|
-
className,
|
|
3263
|
+
className: contentContainerClassName,
|
|
3234
3264
|
ref: scrollProps.contentContainerRef,
|
|
3235
3265
|
style: cssVariables,
|
|
3236
3266
|
children: /* @__PURE__ */ jsxs8(
|
|
@@ -3258,13 +3288,14 @@ var TableCore = ({
|
|
|
3258
3288
|
/* @__PURE__ */ jsx12("div", { className: `${classBase7}-body`, children: data.map((data2) => /* @__PURE__ */ jsx12(
|
|
3259
3289
|
Row2,
|
|
3260
3290
|
{
|
|
3291
|
+
"aria-rowindex": data2[0] + 1,
|
|
3261
3292
|
columnMap,
|
|
3262
3293
|
columns,
|
|
3263
3294
|
highlighted: highlightedIndex === data2[IDX3],
|
|
3264
3295
|
onClick: onRowClick,
|
|
3265
3296
|
onDataEdited,
|
|
3266
3297
|
row: data2,
|
|
3267
|
-
offset:
|
|
3298
|
+
offset: getRowOffset(data2),
|
|
3268
3299
|
onToggleGroup,
|
|
3269
3300
|
zebraStripes: tableAttributes.zebraStripes
|
|
3270
3301
|
},
|
|
@@ -3302,13 +3333,14 @@ var Table = forwardRef(function TableNext({
|
|
|
3302
3333
|
onSelectionChange,
|
|
3303
3334
|
renderBufferSize,
|
|
3304
3335
|
rowHeight,
|
|
3336
|
+
scrollingApiRef,
|
|
3305
3337
|
selectionModel,
|
|
3306
3338
|
showColumnHeaders,
|
|
3307
3339
|
headerHeight,
|
|
3308
3340
|
style: styleProp,
|
|
3309
3341
|
...htmlAttributes
|
|
3310
3342
|
}, forwardedRef) {
|
|
3311
|
-
const containerRef =
|
|
3343
|
+
const containerRef = useRef14(null);
|
|
3312
3344
|
const [size, setSize] = useState7();
|
|
3313
3345
|
if (config === void 0) {
|
|
3314
3346
|
throw Error(
|
|
@@ -3351,6 +3383,7 @@ var Table = forwardRef(function TableNext({
|
|
|
3351
3383
|
onSelectionChange,
|
|
3352
3384
|
renderBufferSize,
|
|
3353
3385
|
rowHeight,
|
|
3386
|
+
scrollingApiRef,
|
|
3354
3387
|
selectionModel,
|
|
3355
3388
|
showColumnHeaders,
|
|
3356
3389
|
size
|
|
@@ -3361,7 +3394,7 @@ var Table = forwardRef(function TableNext({
|
|
|
3361
3394
|
});
|
|
3362
3395
|
|
|
3363
3396
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3364
|
-
import { memo as memo2, useCallback as
|
|
3397
|
+
import { memo as memo2, useCallback as useCallback20 } from "react";
|
|
3365
3398
|
import { CheckboxIcon, WarnCommit } from "@vuu-ui/vuu-ui-controls";
|
|
3366
3399
|
import { Checkbox } from "@salt-ds/core";
|
|
3367
3400
|
|
|
@@ -3375,7 +3408,7 @@ var CheckboxCell = memo2(
|
|
|
3375
3408
|
({ column, columnMap, onCommit = WarnCommit, row }) => {
|
|
3376
3409
|
const dataIdx = columnMap[column.name];
|
|
3377
3410
|
const isChecked = row[dataIdx];
|
|
3378
|
-
const handleCommit =
|
|
3411
|
+
const handleCommit = useCallback20(
|
|
3379
3412
|
(value) => async (evt) => {
|
|
3380
3413
|
const res = await onCommit(value);
|
|
3381
3414
|
if (res === true) {
|
|
@@ -3445,7 +3478,7 @@ import {
|
|
|
3445
3478
|
registerComponent as registerComponent3
|
|
3446
3479
|
} from "@vuu-ui/vuu-utils";
|
|
3447
3480
|
import cx11 from "clsx";
|
|
3448
|
-
import { memo as memo3, useCallback as
|
|
3481
|
+
import { memo as memo3, useCallback as useCallback21 } from "react";
|
|
3449
3482
|
import { CycleStateButton } from "@vuu-ui/vuu-ui-controls";
|
|
3450
3483
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3451
3484
|
var classBase9 = "vuuTableToggleCell";
|
|
@@ -3468,7 +3501,7 @@ var ToggleCell = memo3(
|
|
|
3468
3501
|
const values = getValueList(column);
|
|
3469
3502
|
const dataIdx = columnMap[column.name];
|
|
3470
3503
|
const value = row[dataIdx];
|
|
3471
|
-
const handleCommit =
|
|
3504
|
+
const handleCommit = useCallback21(
|
|
3472
3505
|
(evt, value2) => {
|
|
3473
3506
|
return onCommit(value2).then((response) => {
|
|
3474
3507
|
if (response === true) {
|
|
@@ -3498,11 +3531,11 @@ registerComponent3("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
|
3498
3531
|
// src/useControlledTableNavigation.ts
|
|
3499
3532
|
import { useStateRef } from "@vuu-ui/vuu-ui-controls";
|
|
3500
3533
|
import { dispatchMouseEvent as dispatchMouseEvent2 } from "@vuu-ui/vuu-utils";
|
|
3501
|
-
import { useCallback as
|
|
3534
|
+
import { useCallback as useCallback22, useRef as useRef15 } from "react";
|
|
3502
3535
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3503
|
-
const tableRef =
|
|
3536
|
+
const tableRef = useRef15(null);
|
|
3504
3537
|
const [highlightedIndexRef, setHighlightedIndex] = useStateRef(initialValue);
|
|
3505
|
-
const handleKeyDown =
|
|
3538
|
+
const handleKeyDown = useCallback22(
|
|
3506
3539
|
(e) => {
|
|
3507
3540
|
var _a;
|
|
3508
3541
|
if (e.key === "ArrowDown") {
|
|
@@ -3521,7 +3554,7 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
|
3521
3554
|
},
|
|
3522
3555
|
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3523
3556
|
);
|
|
3524
|
-
const handleHighlight =
|
|
3557
|
+
const handleHighlight = useCallback22(
|
|
3525
3558
|
(idx) => {
|
|
3526
3559
|
setHighlightedIndex(idx);
|
|
3527
3560
|
},
|
|
@@ -3544,11 +3577,14 @@ export {
|
|
|
3544
3577
|
TableGroupCell,
|
|
3545
3578
|
ToggleCell,
|
|
3546
3579
|
dataAndColumnUnchanged,
|
|
3580
|
+
howFarIsRowOutsideViewport,
|
|
3547
3581
|
isShowColumnSettings,
|
|
3548
3582
|
isShowTableSettings,
|
|
3583
|
+
noScrolling,
|
|
3549
3584
|
updateTableConfig,
|
|
3550
3585
|
useControlledTableNavigation,
|
|
3551
3586
|
useTableModel,
|
|
3587
|
+
useTableScroll,
|
|
3552
3588
|
useTableViewport
|
|
3553
3589
|
};
|
|
3554
3590
|
//# sourceMappingURL=index.js.map
|