@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/cjs/index.js
CHANGED
|
@@ -39,11 +39,14 @@ __export(src_exports, {
|
|
|
39
39
|
TableGroupCell: () => TableGroupCell,
|
|
40
40
|
ToggleCell: () => ToggleCell,
|
|
41
41
|
dataAndColumnUnchanged: () => dataAndColumnUnchanged,
|
|
42
|
+
howFarIsRowOutsideViewport: () => howFarIsRowOutsideViewport,
|
|
42
43
|
isShowColumnSettings: () => isShowColumnSettings,
|
|
43
44
|
isShowTableSettings: () => isShowTableSettings,
|
|
45
|
+
noScrolling: () => noScrolling,
|
|
44
46
|
updateTableConfig: () => updateTableConfig,
|
|
45
47
|
useControlledTableNavigation: () => useControlledTableNavigation,
|
|
46
48
|
useTableModel: () => useTableModel,
|
|
49
|
+
useTableScroll: () => useTableScroll,
|
|
47
50
|
useTableViewport: () => useTableViewport
|
|
48
51
|
});
|
|
49
52
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -451,10 +454,10 @@ var HeaderCell = ({
|
|
|
451
454
|
// src/Table.tsx
|
|
452
455
|
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
453
456
|
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
454
|
-
var
|
|
457
|
+
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
455
458
|
var import_core2 = require("@salt-ds/core");
|
|
456
459
|
var import_clsx9 = __toESM(require("clsx"));
|
|
457
|
-
var
|
|
460
|
+
var import_react25 = require("react");
|
|
458
461
|
|
|
459
462
|
// src/Row.tsx
|
|
460
463
|
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
@@ -608,7 +611,6 @@ var Row = (0, import_react11.memo)(
|
|
|
608
611
|
"div",
|
|
609
612
|
{
|
|
610
613
|
...htmlAttributes,
|
|
611
|
-
"aria-rowindex": row[0] + 1,
|
|
612
614
|
key: `row-${row[0]}`,
|
|
613
615
|
role: "row",
|
|
614
616
|
className,
|
|
@@ -640,8 +642,8 @@ Row.displayName = "Row";
|
|
|
640
642
|
|
|
641
643
|
// src/useTable.ts
|
|
642
644
|
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
643
|
-
var
|
|
644
|
-
var
|
|
645
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
646
|
+
var import_react23 = require("react");
|
|
645
647
|
|
|
646
648
|
// src/context-menu/buildContextMenuDescriptors.ts
|
|
647
649
|
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
@@ -960,7 +962,7 @@ var import_react13 = require("react");
|
|
|
960
962
|
|
|
961
963
|
// src/table-dom-utils.ts
|
|
962
964
|
var headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell:nth-child(${colIdx})`;
|
|
963
|
-
var dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
965
|
+
var dataCellQuery = (rowIdx, colIdx) => `.vuuTable-body > [aria-rowindex='${rowIdx + 1}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
964
966
|
var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
965
967
|
var _a;
|
|
966
968
|
const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
|
|
@@ -1228,6 +1230,7 @@ var useInitialValue = (value) => {
|
|
|
1228
1230
|
};
|
|
1229
1231
|
|
|
1230
1232
|
// src/useKeyboardNavigation.ts
|
|
1233
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
1231
1234
|
var import_core = require("@salt-ds/core");
|
|
1232
1235
|
var import_react16 = require("react");
|
|
1233
1236
|
var rowNavigationKeys = /* @__PURE__ */ new Set([
|
|
@@ -1254,51 +1257,6 @@ var isNavigationKey = (key, navigationStyle) => {
|
|
|
1254
1257
|
var PageKeys = ["Home", "End", "PageUp", "PageDown"];
|
|
1255
1258
|
var isPagingKey = (key) => PageKeys.includes(key);
|
|
1256
1259
|
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
1260
|
function nextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
|
|
1303
1261
|
if (key === "ArrowUp") {
|
|
1304
1262
|
if (rowIdx > -1) {
|
|
@@ -1366,14 +1324,14 @@ var useKeyboardNavigation = ({
|
|
|
1366
1324
|
"[role='columnHeader'],[role='cell']"
|
|
1367
1325
|
);
|
|
1368
1326
|
const getTableCellPos = (tableCell) => {
|
|
1369
|
-
var _a2
|
|
1327
|
+
var _a2;
|
|
1370
1328
|
if (tableCell.role === "columnHeader") {
|
|
1371
1329
|
const colIdx = parseInt((_a2 = tableCell.dataset.idx) != null ? _a2 : "-1", 10);
|
|
1372
1330
|
return [-1, colIdx];
|
|
1373
1331
|
} else {
|
|
1374
1332
|
const focusedRow = tableCell.closest("[role='row']");
|
|
1375
1333
|
if (focusedRow) {
|
|
1376
|
-
const rowIdx =
|
|
1334
|
+
const rowIdx = (0, import_vuu_utils12.getIndexFromRowElement)(focusedRow);
|
|
1377
1335
|
const colIdx = Array.from(focusedRow.childNodes).indexOf(tableCell);
|
|
1378
1336
|
return [rowIdx, colIdx];
|
|
1379
1337
|
}
|
|
@@ -1391,11 +1349,8 @@ var useKeyboardNavigation = ({
|
|
|
1391
1349
|
focusableCell.current = activeCell;
|
|
1392
1350
|
activeCell.setAttribute("tabindex", "0");
|
|
1393
1351
|
}
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
1397
|
-
}
|
|
1398
|
-
console.log(`activeCell focus`);
|
|
1352
|
+
console.log(`scroll row ${cellPos[0]}`);
|
|
1353
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex: cellPos[0] });
|
|
1399
1354
|
activeCell.focus({ preventScroll: true });
|
|
1400
1355
|
}
|
|
1401
1356
|
}
|
|
@@ -1477,18 +1432,9 @@ var useKeyboardNavigation = ({
|
|
|
1477
1432
|
);
|
|
1478
1433
|
const scrollRowIntoViewIfNecessary = (0, import_react16.useCallback)(
|
|
1479
1434
|
(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
|
-
}
|
|
1435
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex });
|
|
1490
1436
|
},
|
|
1491
|
-
[
|
|
1437
|
+
[requestScroll]
|
|
1492
1438
|
);
|
|
1493
1439
|
const moveHighlightedRow = (0, import_react16.useCallback)(
|
|
1494
1440
|
async (key) => {
|
|
@@ -1576,9 +1522,9 @@ var useKeyboardNavigation = ({
|
|
|
1576
1522
|
};
|
|
1577
1523
|
|
|
1578
1524
|
// src/useSelection.ts
|
|
1579
|
-
var
|
|
1525
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1580
1526
|
var import_react17 = require("react");
|
|
1581
|
-
var { IDX: IDX2 } =
|
|
1527
|
+
var { IDX: IDX2 } = import_vuu_utils13.metadataKeys;
|
|
1582
1528
|
var NO_SELECTION = [];
|
|
1583
1529
|
var defaultSelectionKeys = ["Enter", " "];
|
|
1584
1530
|
var useSelection = ({
|
|
@@ -1600,7 +1546,7 @@ var useSelection = ({
|
|
|
1600
1546
|
const { [IDX2]: idx } = row;
|
|
1601
1547
|
const { current: active } = lastActiveRef;
|
|
1602
1548
|
const { current: selected } = selectedRef;
|
|
1603
|
-
const selectOperation = (0,
|
|
1549
|
+
const selectOperation = (0, import_vuu_utils13.isRowSelected)(row) ? import_vuu_utils13.deselectItem : import_vuu_utils13.selectItem;
|
|
1604
1550
|
const newSelected = selectOperation(
|
|
1605
1551
|
selectionModel,
|
|
1606
1552
|
selected,
|
|
@@ -1625,7 +1571,7 @@ var useSelection = ({
|
|
|
1625
1571
|
`[aria-rowindex="${rowIndex}"]`
|
|
1626
1572
|
);
|
|
1627
1573
|
if (rowEl) {
|
|
1628
|
-
(0,
|
|
1574
|
+
(0, import_vuu_utils13.dispatchMouseEvent)(rowEl, "click");
|
|
1629
1575
|
}
|
|
1630
1576
|
}
|
|
1631
1577
|
}
|
|
@@ -1640,7 +1586,7 @@ var useSelection = ({
|
|
|
1640
1586
|
|
|
1641
1587
|
// src/useTableContextMenu.ts
|
|
1642
1588
|
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
1643
|
-
var
|
|
1589
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
1644
1590
|
var import_react18 = require("react");
|
|
1645
1591
|
var NO_ROWS = [];
|
|
1646
1592
|
var useTableContextMenu = ({
|
|
@@ -1657,8 +1603,8 @@ var useTableContextMenu = ({
|
|
|
1657
1603
|
const rowEl = target == null ? void 0 : target.closest("div[role='row']");
|
|
1658
1604
|
if (cellEl && rowEl) {
|
|
1659
1605
|
const { selectedRowsCount } = dataSource;
|
|
1660
|
-
const columnMap = (0,
|
|
1661
|
-
const rowIndex = (0,
|
|
1606
|
+
const columnMap = (0, import_vuu_utils14.buildColumnMap)(columns);
|
|
1607
|
+
const rowIndex = (0, import_vuu_utils14.getIndexFromRowElement)(rowEl);
|
|
1662
1608
|
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
1663
1609
|
const row = data.find(([idx]) => idx === rowIndex);
|
|
1664
1610
|
const columnName = columns[cellIndex];
|
|
@@ -1677,12 +1623,12 @@ var useTableContextMenu = ({
|
|
|
1677
1623
|
};
|
|
1678
1624
|
|
|
1679
1625
|
// src/useTableModel.ts
|
|
1680
|
-
var
|
|
1626
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
1681
1627
|
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
1682
1628
|
var import_react19 = require("react");
|
|
1683
|
-
var { info } = (0,
|
|
1629
|
+
var { info } = (0, import_vuu_utils15.logger)("useTableModel");
|
|
1684
1630
|
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1685
|
-
var KEY_OFFSET =
|
|
1631
|
+
var KEY_OFFSET = import_vuu_utils15.metadataKeys.count;
|
|
1686
1632
|
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
1687
1633
|
var getDataType = (column, tableSchema) => {
|
|
1688
1634
|
const schemaColumn = tableSchema == null ? void 0 : tableSchema.columns.find(
|
|
@@ -1738,13 +1684,13 @@ var useTableModel = (tableConfigProp, dataSource) => {
|
|
|
1738
1684
|
function init({ dataSource, tableConfig }) {
|
|
1739
1685
|
const { columns, ...tableAttributes } = tableConfig;
|
|
1740
1686
|
const { config: dataSourceConfig, tableSchema } = dataSource;
|
|
1741
|
-
const runtimeColumns = columns.filter((0,
|
|
1687
|
+
const runtimeColumns = columns.filter((0, import_vuu_utils15.subscribedOnly)(dataSourceConfig == null ? void 0 : dataSourceConfig.columns)).map(
|
|
1742
1688
|
columnDescriptorToRuntimeColumDescriptor(tableAttributes, tableSchema)
|
|
1743
1689
|
);
|
|
1744
|
-
const maybePinnedColumns = runtimeColumns.some(
|
|
1690
|
+
const maybePinnedColumns = runtimeColumns.some(import_vuu_utils15.isPinned) ? (0, import_vuu_utils15.sortPinnedColumns)(runtimeColumns) : runtimeColumns;
|
|
1745
1691
|
let state = {
|
|
1746
1692
|
columns: maybePinnedColumns,
|
|
1747
|
-
headings: (0,
|
|
1693
|
+
headings: (0, import_vuu_utils15.getTableHeadings)(maybePinnedColumns),
|
|
1748
1694
|
tableConfig,
|
|
1749
1695
|
...tableAttributes
|
|
1750
1696
|
};
|
|
@@ -1772,26 +1718,26 @@ var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) =>
|
|
|
1772
1718
|
align = getDefaultAlignment(serverDataType),
|
|
1773
1719
|
key,
|
|
1774
1720
|
name,
|
|
1775
|
-
label = (0,
|
|
1721
|
+
label = (0, import_vuu_utils15.getColumnLabel)(column),
|
|
1776
1722
|
width = columnDefaultWidth,
|
|
1777
1723
|
...rest
|
|
1778
1724
|
} = column;
|
|
1779
1725
|
const runtimeColumnWithDefaults = {
|
|
1780
1726
|
...rest,
|
|
1781
1727
|
align,
|
|
1782
|
-
CellRenderer: (0,
|
|
1783
|
-
HeaderCellContentRenderer: (0,
|
|
1784
|
-
HeaderCellLabelRenderer: (0,
|
|
1785
|
-
clientSideEditValidationCheck: (0,
|
|
1728
|
+
CellRenderer: (0, import_vuu_utils15.getCellRenderer)(column),
|
|
1729
|
+
HeaderCellContentRenderer: (0, import_vuu_utils15.getColumnHeaderContentRenderer)(column),
|
|
1730
|
+
HeaderCellLabelRenderer: (0, import_vuu_utils15.getColumnHeaderLabelRenderer)(column),
|
|
1731
|
+
clientSideEditValidationCheck: (0, import_vuu_utils15.hasValidationRules)(column.type) ? (0, import_vuu_ui_controls.buildValidationChecker)(column.type.renderer.rules) : void 0,
|
|
1786
1732
|
label: getLabel(label, columnFormatHeader),
|
|
1787
1733
|
key: key != null ? key : index + KEY_OFFSET,
|
|
1788
1734
|
name,
|
|
1789
1735
|
originalIdx: index,
|
|
1790
1736
|
serverDataType,
|
|
1791
|
-
valueFormatter: (0,
|
|
1737
|
+
valueFormatter: (0, import_vuu_utils15.getValueFormatter)(column, serverDataType),
|
|
1792
1738
|
width
|
|
1793
1739
|
};
|
|
1794
|
-
if ((0,
|
|
1740
|
+
if ((0, import_vuu_utils15.isGroupColumn)(runtimeColumnWithDefaults)) {
|
|
1795
1741
|
runtimeColumnWithDefaults.columns = runtimeColumnWithDefaults.columns.map(
|
|
1796
1742
|
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(
|
|
1797
1743
|
col,
|
|
@@ -1888,8 +1834,8 @@ function pinColumn2(state, action) {
|
|
|
1888
1834
|
const { column, pin } = action;
|
|
1889
1835
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1890
1836
|
if (targetColumn) {
|
|
1891
|
-
columns = (0,
|
|
1892
|
-
columns = (0,
|
|
1837
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, pin });
|
|
1838
|
+
columns = (0, import_vuu_utils15.sortPinnedColumns)(columns);
|
|
1893
1839
|
return {
|
|
1894
1840
|
...state,
|
|
1895
1841
|
columns
|
|
@@ -1904,26 +1850,26 @@ function updateColumnProp(state, action) {
|
|
|
1904
1850
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1905
1851
|
if (targetColumn) {
|
|
1906
1852
|
if (align === "left" || align === "right") {
|
|
1907
|
-
columns = (0,
|
|
1853
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, align });
|
|
1908
1854
|
}
|
|
1909
1855
|
if (typeof label === "string") {
|
|
1910
|
-
columns = (0,
|
|
1856
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, label });
|
|
1911
1857
|
}
|
|
1912
1858
|
if (typeof resizing === "boolean") {
|
|
1913
|
-
columns = (0,
|
|
1859
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, resizing });
|
|
1914
1860
|
}
|
|
1915
1861
|
if (typeof hidden === "boolean") {
|
|
1916
|
-
columns = (0,
|
|
1862
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, hidden });
|
|
1917
1863
|
}
|
|
1918
1864
|
if (typeof width === "number") {
|
|
1919
|
-
columns = (0,
|
|
1865
|
+
columns = (0, import_vuu_utils15.replaceColumn)(columns, { ...targetColumn, width });
|
|
1920
1866
|
const targetConfigColumn = tableConfig.columns.find(
|
|
1921
1867
|
(col) => col.name === column.name
|
|
1922
1868
|
);
|
|
1923
1869
|
if (targetConfigColumn) {
|
|
1924
1870
|
tableConfig = {
|
|
1925
1871
|
...tableConfig,
|
|
1926
|
-
columns: (0,
|
|
1872
|
+
columns: (0, import_vuu_utils15.replaceColumn)(tableConfig.columns, {
|
|
1927
1873
|
...targetConfigColumn,
|
|
1928
1874
|
width
|
|
1929
1875
|
})
|
|
@@ -1945,30 +1891,31 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
1945
1891
|
if (hasGroupBy) {
|
|
1946
1892
|
result = {
|
|
1947
1893
|
...state,
|
|
1948
|
-
columns: (0,
|
|
1894
|
+
columns: (0, import_vuu_utils15.applyGroupByToColumns)(result.columns, groupBy, confirmed)
|
|
1949
1895
|
};
|
|
1950
1896
|
}
|
|
1951
1897
|
if (hasSort) {
|
|
1952
1898
|
result = {
|
|
1953
1899
|
...state,
|
|
1954
|
-
columns: (0,
|
|
1900
|
+
columns: (0, import_vuu_utils15.applySortToColumns)(result.columns, sort)
|
|
1955
1901
|
};
|
|
1956
1902
|
}
|
|
1957
1903
|
if (hasFilter) {
|
|
1958
1904
|
result = {
|
|
1959
1905
|
...state,
|
|
1960
|
-
columns: (0,
|
|
1906
|
+
columns: (0, import_vuu_utils15.applyFilterToColumns)(result.columns, filter)
|
|
1961
1907
|
};
|
|
1962
|
-
} else if (result.columns.some(
|
|
1908
|
+
} else if (result.columns.some(import_vuu_utils15.isFilteredColumn)) {
|
|
1963
1909
|
result = {
|
|
1964
1910
|
...state,
|
|
1965
|
-
columns: (0,
|
|
1911
|
+
columns: (0, import_vuu_utils15.stripFilterFromColumns)(result.columns)
|
|
1966
1912
|
};
|
|
1967
1913
|
}
|
|
1968
1914
|
return result;
|
|
1969
1915
|
}
|
|
1970
1916
|
|
|
1971
1917
|
// src/useTableScroll.ts
|
|
1918
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
1972
1919
|
var import_react20 = require("react");
|
|
1973
1920
|
var getPctScroll = (container) => {
|
|
1974
1921
|
const { scrollLeft, scrollTop } = container;
|
|
@@ -1977,6 +1924,31 @@ var getPctScroll = (container) => {
|
|
|
1977
1924
|
const pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
1978
1925
|
return [pctScrollLeft, pctScrollTop];
|
|
1979
1926
|
};
|
|
1927
|
+
var noScrolling = {
|
|
1928
|
+
scrollToIndex: () => void 0,
|
|
1929
|
+
scrollToKey: () => void 0
|
|
1930
|
+
};
|
|
1931
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1932
|
+
var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1933
|
+
if (contentContainer) {
|
|
1934
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1935
|
+
const upperBoundary = viewport.top + totalHeaderHeight;
|
|
1936
|
+
const row = rowEl.getBoundingClientRect();
|
|
1937
|
+
if (row) {
|
|
1938
|
+
if (row.bottom > viewport.bottom) {
|
|
1939
|
+
return ["down", row.bottom - viewport.bottom];
|
|
1940
|
+
} else if (row.top < upperBoundary) {
|
|
1941
|
+
return ["up", row.top - upperBoundary];
|
|
1942
|
+
} else {
|
|
1943
|
+
return NO_SCROLL_NECESSARY;
|
|
1944
|
+
}
|
|
1945
|
+
} else {
|
|
1946
|
+
throw Error("Whats going on, row not found");
|
|
1947
|
+
}
|
|
1948
|
+
} else {
|
|
1949
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1980
1952
|
var useCallbackRef = ({
|
|
1981
1953
|
onAttach,
|
|
1982
1954
|
onDetach
|
|
@@ -1998,17 +1970,37 @@ var useCallbackRef = ({
|
|
|
1998
1970
|
return callbackRef;
|
|
1999
1971
|
};
|
|
2000
1972
|
var useTableScroll = ({
|
|
2001
|
-
|
|
2002
|
-
maxScrollTop,
|
|
1973
|
+
getRowAtPosition,
|
|
2003
1974
|
onHorizontalScroll,
|
|
2004
1975
|
onVerticalScroll,
|
|
2005
|
-
|
|
2006
|
-
|
|
1976
|
+
scrollingApiRef,
|
|
1977
|
+
setRange,
|
|
1978
|
+
viewportMeasurements
|
|
2007
1979
|
}) => {
|
|
1980
|
+
const firstRowRef = (0, import_react20.useRef)(0);
|
|
2008
1981
|
const contentContainerScrolledRef = (0, import_react20.useRef)(false);
|
|
2009
1982
|
const scrollPosRef = (0, import_react20.useRef)({ scrollTop: 0, scrollLeft: 0 });
|
|
2010
1983
|
const scrollbarContainerRef = (0, import_react20.useRef)(null);
|
|
2011
1984
|
const contentContainerRef = (0, import_react20.useRef)(null);
|
|
1985
|
+
const {
|
|
1986
|
+
appliedPageSize,
|
|
1987
|
+
isVirtualScroll,
|
|
1988
|
+
maxScrollContainerScrollHorizontal: maxScrollLeft,
|
|
1989
|
+
maxScrollContainerScrollVertical: maxScrollTop,
|
|
1990
|
+
rowCount: viewportRowCount,
|
|
1991
|
+
totalHeaderHeight
|
|
1992
|
+
} = viewportMeasurements;
|
|
1993
|
+
const handleVerticalScroll = (0, import_react20.useCallback)(
|
|
1994
|
+
(scrollTop, pctScrollTop) => {
|
|
1995
|
+
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
1996
|
+
const firstRow = getRowAtPosition(scrollTop);
|
|
1997
|
+
if (firstRow !== firstRowRef.current) {
|
|
1998
|
+
firstRowRef.current = firstRow;
|
|
1999
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount + 1 });
|
|
2000
|
+
}
|
|
2001
|
+
},
|
|
2002
|
+
[getRowAtPosition, onVerticalScroll, setRange, viewportRowCount]
|
|
2003
|
+
);
|
|
2012
2004
|
const handleScrollbarContainerScroll = (0, import_react20.useCallback)(() => {
|
|
2013
2005
|
const { current: contentContainer } = contentContainerRef;
|
|
2014
2006
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
@@ -2018,7 +2010,7 @@ var useTableScroll = ({
|
|
|
2018
2010
|
} else if (contentContainer && scrollbarContainer) {
|
|
2019
2011
|
const [pctScrollLeft, pctScrollTop] = getPctScroll(scrollbarContainer);
|
|
2020
2012
|
const rootScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2021
|
-
const rootScrollTop =
|
|
2013
|
+
const rootScrollTop = pctScrollTop * maxScrollTop;
|
|
2022
2014
|
contentContainer.scrollTo({
|
|
2023
2015
|
left: rootScrollLeft,
|
|
2024
2016
|
top: rootScrollTop,
|
|
@@ -2035,17 +2027,17 @@ var useTableScroll = ({
|
|
|
2035
2027
|
const [pctScrollLeft, pctScrollTop] = getPctScroll(contentContainer);
|
|
2036
2028
|
contentContainerScrolledRef.current = true;
|
|
2037
2029
|
scrollbarContainer.scrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2038
|
-
scrollbarContainer.scrollTop =
|
|
2030
|
+
scrollbarContainer.scrollTop = pctScrollTop * maxScrollTop;
|
|
2039
2031
|
if (scrollPos.scrollTop !== scrollTop) {
|
|
2040
2032
|
scrollPos.scrollTop = scrollTop;
|
|
2041
|
-
|
|
2033
|
+
handleVerticalScroll(scrollTop, pctScrollTop);
|
|
2042
2034
|
}
|
|
2043
2035
|
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
2044
2036
|
scrollPos.scrollLeft = scrollLeft;
|
|
2045
2037
|
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2046
2038
|
}
|
|
2047
2039
|
}
|
|
2048
|
-
}, [maxScrollLeft, maxScrollTop, onHorizontalScroll
|
|
2040
|
+
}, [handleVerticalScroll, maxScrollLeft, maxScrollTop, onHorizontalScroll]);
|
|
2049
2041
|
const handleAttachScrollbarContainer = (0, import_react20.useCallback)(
|
|
2050
2042
|
(el) => {
|
|
2051
2043
|
scrollbarContainerRef.current = el;
|
|
@@ -2092,37 +2084,60 @@ var useTableScroll = ({
|
|
|
2092
2084
|
if (scrollbarContainer) {
|
|
2093
2085
|
const { scrollLeft, scrollTop } = scrollbarContainer;
|
|
2094
2086
|
contentContainerScrolledRef.current = false;
|
|
2095
|
-
if (scrollRequest.type === "scroll-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
newScrollLeft = Math.min(
|
|
2105
|
-
Math.max(0, scrollLeft + scrollRequest.distance),
|
|
2106
|
-
maxScrollLeft
|
|
2087
|
+
if (scrollRequest.type === "scroll-row") {
|
|
2088
|
+
const activeRow = (0, import_vuu_utils16.getRowElementAtIndex)(
|
|
2089
|
+
scrollbarContainer,
|
|
2090
|
+
scrollRequest.rowIndex
|
|
2091
|
+
);
|
|
2092
|
+
if (activeRow !== null) {
|
|
2093
|
+
const [direction, distance] = howFarIsRowOutsideViewport(
|
|
2094
|
+
activeRow,
|
|
2095
|
+
totalHeaderHeight
|
|
2107
2096
|
);
|
|
2097
|
+
if (direction && distance) {
|
|
2098
|
+
if (isVirtualScroll) {
|
|
2099
|
+
console.log(
|
|
2100
|
+
`virtual scroll row required ${direction} ${distance}
|
|
2101
|
+
first Row ${firstRowRef.current}`
|
|
2102
|
+
);
|
|
2103
|
+
} else {
|
|
2104
|
+
let newScrollLeft = scrollLeft;
|
|
2105
|
+
let newScrollTop = scrollTop;
|
|
2106
|
+
if (direction === "up" || direction === "down") {
|
|
2107
|
+
newScrollTop = Math.min(
|
|
2108
|
+
Math.max(0, scrollTop + distance),
|
|
2109
|
+
maxScrollTop
|
|
2110
|
+
);
|
|
2111
|
+
} else {
|
|
2112
|
+
newScrollLeft = Math.min(
|
|
2113
|
+
Math.max(0, scrollLeft + distance),
|
|
2114
|
+
maxScrollLeft
|
|
2115
|
+
);
|
|
2116
|
+
}
|
|
2117
|
+
scrollbarContainer.scrollTo({
|
|
2118
|
+
top: newScrollTop,
|
|
2119
|
+
left: newScrollLeft,
|
|
2120
|
+
behavior: "smooth"
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2108
2124
|
}
|
|
2109
|
-
scrollbarContainer.scrollTo({
|
|
2110
|
-
top: newScrollTop,
|
|
2111
|
-
left: newScrollLeft,
|
|
2112
|
-
behavior: "smooth"
|
|
2113
|
-
});
|
|
2114
2125
|
} else if (scrollRequest.type === "scroll-page") {
|
|
2115
2126
|
const { direction } = scrollRequest;
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2127
|
+
if (isVirtualScroll) {
|
|
2128
|
+
console.log(`need a virtual page scroll`);
|
|
2129
|
+
} else {
|
|
2130
|
+
const scrollBy = direction === "down" ? appliedPageSize : -appliedPageSize;
|
|
2131
|
+
const newScrollTop = Math.min(
|
|
2132
|
+
Math.max(0, scrollTop + scrollBy),
|
|
2133
|
+
maxScrollTop
|
|
2134
|
+
);
|
|
2135
|
+
scrollbarContainer.scrollTo({
|
|
2136
|
+
top: newScrollTop,
|
|
2137
|
+
left: scrollLeft,
|
|
2138
|
+
behavior: "auto"
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2126
2141
|
} else if (scrollRequest.type === "scroll-end") {
|
|
2127
2142
|
const { direction } = scrollRequest;
|
|
2128
2143
|
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
@@ -2134,8 +2149,46 @@ var useTableScroll = ({
|
|
|
2134
2149
|
}
|
|
2135
2150
|
}
|
|
2136
2151
|
},
|
|
2137
|
-
[
|
|
2152
|
+
[
|
|
2153
|
+
appliedPageSize,
|
|
2154
|
+
isVirtualScroll,
|
|
2155
|
+
maxScrollLeft,
|
|
2156
|
+
maxScrollTop,
|
|
2157
|
+
setRange,
|
|
2158
|
+
totalHeaderHeight,
|
|
2159
|
+
viewportRowCount
|
|
2160
|
+
]
|
|
2138
2161
|
);
|
|
2162
|
+
const scrollHandles = (0, import_react20.useMemo)(
|
|
2163
|
+
() => ({
|
|
2164
|
+
scrollToIndex: (rowIndex) => {
|
|
2165
|
+
if (scrollbarContainerRef.current) {
|
|
2166
|
+
const scrollPos = (rowIndex - 30) * 20;
|
|
2167
|
+
scrollbarContainerRef.current.scrollTop = scrollPos;
|
|
2168
|
+
}
|
|
2169
|
+
},
|
|
2170
|
+
scrollToKey: (rowKey) => {
|
|
2171
|
+
console.log(`scrollToKey ${rowKey}`);
|
|
2172
|
+
}
|
|
2173
|
+
}),
|
|
2174
|
+
[]
|
|
2175
|
+
);
|
|
2176
|
+
(0, import_react20.useImperativeHandle)(
|
|
2177
|
+
scrollingApiRef,
|
|
2178
|
+
() => {
|
|
2179
|
+
if (scrollbarContainerRef.current) {
|
|
2180
|
+
return scrollHandles;
|
|
2181
|
+
} else {
|
|
2182
|
+
return noScrolling;
|
|
2183
|
+
}
|
|
2184
|
+
},
|
|
2185
|
+
[scrollHandles]
|
|
2186
|
+
);
|
|
2187
|
+
(0, import_react20.useEffect)(() => {
|
|
2188
|
+
const { current: from } = firstRowRef;
|
|
2189
|
+
const rowRange = { from, to: from + viewportRowCount + 1 };
|
|
2190
|
+
setRange(rowRange);
|
|
2191
|
+
}, [setRange, viewportRowCount]);
|
|
2139
2192
|
return {
|
|
2140
2193
|
/** Ref to be assigned to ScrollbarContainer */
|
|
2141
2194
|
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
@@ -2148,14 +2201,16 @@ var useTableScroll = ({
|
|
|
2148
2201
|
|
|
2149
2202
|
// src/useTableViewport.ts
|
|
2150
2203
|
var import_react21 = require("react");
|
|
2151
|
-
var
|
|
2152
|
-
var MAX_RAW_ROWS =
|
|
2204
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
2205
|
+
var MAX_RAW_ROWS = 1e5;
|
|
2153
2206
|
var UNMEASURED_VIEWPORT = {
|
|
2207
|
+
appliedPageSize: 0,
|
|
2154
2208
|
contentHeight: 0,
|
|
2155
2209
|
contentWidth: 0,
|
|
2156
2210
|
getRowAtPosition: () => -1,
|
|
2157
2211
|
getRowOffset: () => -1,
|
|
2158
2212
|
horizontalScrollbarHeight: 0,
|
|
2213
|
+
isVirtualScroll: false,
|
|
2159
2214
|
maxScrollContainerScrollHorizontal: 0,
|
|
2160
2215
|
maxScrollContainerScrollVertical: 0,
|
|
2161
2216
|
pinnedWidthLeft: 0,
|
|
@@ -2196,57 +2251,58 @@ var useTableViewport = ({
|
|
|
2196
2251
|
size
|
|
2197
2252
|
}) => {
|
|
2198
2253
|
const pctScrollTopRef = (0, import_react21.useRef)(0);
|
|
2199
|
-
const
|
|
2200
|
-
const appliedContentHeight = appliedRowCount * rowHeight;
|
|
2254
|
+
const pixelContentHeight = rowHeight * Math.min(rowCount, MAX_RAW_ROWS);
|
|
2201
2255
|
const virtualContentHeight = rowCount * rowHeight;
|
|
2202
|
-
const virtualisedExtent = virtualContentHeight -
|
|
2256
|
+
const virtualisedExtent = virtualContentHeight - pixelContentHeight;
|
|
2203
2257
|
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react21.useMemo)(
|
|
2204
2258
|
() => measurePinnedColumns(columns),
|
|
2205
2259
|
[columns]
|
|
2206
2260
|
);
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
);
|
|
2211
|
-
const [getRowOffset, getRowAtPosition] = (0, import_react21.useMemo)(() => {
|
|
2261
|
+
const totalHeaderHeightRef = (0, import_react21.useRef)(headerHeight);
|
|
2262
|
+
(0, import_react21.useMemo)(() => {
|
|
2263
|
+
totalHeaderHeightRef.current = headerHeight * (1 + headings.length);
|
|
2264
|
+
}, [headerHeight, headings.length]);
|
|
2265
|
+
const [getRowOffset, getRowAtPosition, isVirtualScroll] = (0, import_react21.useMemo)(() => {
|
|
2212
2266
|
if (virtualisedExtent) {
|
|
2213
|
-
return (0,
|
|
2267
|
+
return (0, import_vuu_utils17.virtualRowPositioning)(
|
|
2214
2268
|
rowHeight,
|
|
2215
2269
|
virtualisedExtent,
|
|
2216
2270
|
pctScrollTopRef
|
|
2217
2271
|
);
|
|
2218
2272
|
} else {
|
|
2219
|
-
return
|
|
2273
|
+
return (0, import_vuu_utils17.actualRowPositioning)(rowHeight);
|
|
2220
2274
|
}
|
|
2221
|
-
}, [
|
|
2275
|
+
}, [virtualisedExtent, rowHeight]);
|
|
2222
2276
|
const setPctScrollTop = (0, import_react21.useCallback)((scrollPct) => {
|
|
2223
2277
|
pctScrollTopRef.current = scrollPct;
|
|
2224
2278
|
}, []);
|
|
2225
2279
|
return (0, import_react21.useMemo)(() => {
|
|
2226
2280
|
var _a;
|
|
2227
2281
|
if (size) {
|
|
2228
|
-
const
|
|
2282
|
+
const { current: totalHeaderHeight } = totalHeaderHeightRef;
|
|
2229
2283
|
const scrollbarSize = 15;
|
|
2230
2284
|
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
2231
2285
|
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
2232
|
-
const
|
|
2233
|
-
const maxScrollContainerScrollVertical = appliedContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2286
|
+
const maxScrollContainerScrollVertical = pixelContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2234
2287
|
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
2235
2288
|
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
2236
|
-
const count = Number.isInteger(visibleRows) ? visibleRows
|
|
2289
|
+
const count = Number.isInteger(visibleRows) ? visibleRows : Math.ceil(visibleRows);
|
|
2237
2290
|
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
2238
|
-
const verticalScrollbarWidth =
|
|
2291
|
+
const verticalScrollbarWidth = pixelContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
2292
|
+
const appliedPageSize = count * rowHeight * (pixelContentHeight / virtualContentHeight);
|
|
2239
2293
|
return {
|
|
2240
|
-
|
|
2294
|
+
appliedPageSize,
|
|
2295
|
+
contentHeight: pixelContentHeight,
|
|
2296
|
+
contentWidth,
|
|
2241
2297
|
getRowAtPosition,
|
|
2242
2298
|
getRowOffset,
|
|
2299
|
+
isVirtualScroll,
|
|
2243
2300
|
horizontalScrollbarHeight,
|
|
2244
2301
|
maxScrollContainerScrollHorizontal,
|
|
2245
2302
|
maxScrollContainerScrollVertical,
|
|
2246
2303
|
pinnedWidthLeft,
|
|
2247
2304
|
pinnedWidthRight,
|
|
2248
2305
|
rowCount: count,
|
|
2249
|
-
contentWidth,
|
|
2250
2306
|
setPctScrollTop,
|
|
2251
2307
|
totalHeaderHeight,
|
|
2252
2308
|
verticalScrollbarWidth,
|
|
@@ -2256,53 +2312,25 @@ var useTableViewport = ({
|
|
|
2256
2312
|
return UNMEASURED_VIEWPORT;
|
|
2257
2313
|
}
|
|
2258
2314
|
}, [
|
|
2259
|
-
|
|
2260
|
-
|
|
2315
|
+
getRowAtPosition,
|
|
2316
|
+
getRowOffset,
|
|
2317
|
+
headerHeight,
|
|
2318
|
+
isVirtualScroll,
|
|
2261
2319
|
pinnedWidthLeft,
|
|
2262
2320
|
unpinnedWidth,
|
|
2263
2321
|
pinnedWidthRight,
|
|
2264
|
-
|
|
2265
|
-
headerHeight,
|
|
2322
|
+
pixelContentHeight,
|
|
2266
2323
|
rowHeight,
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2324
|
+
setPctScrollTop,
|
|
2325
|
+
size,
|
|
2326
|
+
virtualContentHeight
|
|
2270
2327
|
]);
|
|
2271
2328
|
};
|
|
2272
2329
|
|
|
2273
|
-
// src/useVirtualViewport.ts
|
|
2274
|
-
var import_react22 = require("react");
|
|
2275
|
-
var useVirtualViewport = ({
|
|
2276
|
-
getRowAtPosition,
|
|
2277
|
-
setRange,
|
|
2278
|
-
viewportMeasurements
|
|
2279
|
-
}) => {
|
|
2280
|
-
const firstRowRef = (0, import_react22.useRef)(0);
|
|
2281
|
-
const { rowCount: viewportRowCount } = viewportMeasurements;
|
|
2282
|
-
const handleVerticalScroll = (0, import_react22.useCallback)(
|
|
2283
|
-
(scrollTop) => {
|
|
2284
|
-
const firstRow = getRowAtPosition(scrollTop);
|
|
2285
|
-
if (firstRow !== firstRowRef.current) {
|
|
2286
|
-
firstRowRef.current = firstRow;
|
|
2287
|
-
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2288
|
-
}
|
|
2289
|
-
},
|
|
2290
|
-
[getRowAtPosition, setRange, viewportRowCount]
|
|
2291
|
-
);
|
|
2292
|
-
(0, import_react22.useEffect)(() => {
|
|
2293
|
-
const { current: from } = firstRowRef;
|
|
2294
|
-
const rowRange = { from, to: from + viewportRowCount };
|
|
2295
|
-
setRange(rowRange);
|
|
2296
|
-
}, [setRange, viewportRowCount]);
|
|
2297
|
-
return {
|
|
2298
|
-
onVerticalScroll: handleVerticalScroll
|
|
2299
|
-
};
|
|
2300
|
-
};
|
|
2301
|
-
|
|
2302
2330
|
// src/useTableAndColumnSettings.ts
|
|
2303
2331
|
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
2304
|
-
var
|
|
2305
|
-
var
|
|
2332
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2333
|
+
var import_react22 = require("react");
|
|
2306
2334
|
var useTableAndColumnSettings = ({
|
|
2307
2335
|
availableColumns: availableColumnsProps,
|
|
2308
2336
|
onAvailableColumnsChange,
|
|
@@ -2312,11 +2340,11 @@ var useTableAndColumnSettings = ({
|
|
|
2312
2340
|
tableConfig
|
|
2313
2341
|
}) => {
|
|
2314
2342
|
const dispatchLayoutAction = (0, import_vuu_layout2.useLayoutProviderDispatch)();
|
|
2315
|
-
const showTableSettingsRef = (0,
|
|
2316
|
-
const [availableColumns, setAvailableColumns] = (0,
|
|
2343
|
+
const showTableSettingsRef = (0, import_react22.useRef)();
|
|
2344
|
+
const [availableColumns, setAvailableColumns] = (0, import_react22.useState)(
|
|
2317
2345
|
availableColumnsProps
|
|
2318
2346
|
);
|
|
2319
|
-
const showContextPanel = (0,
|
|
2347
|
+
const showContextPanel = (0, import_react22.useCallback)(
|
|
2320
2348
|
(componentType, title, props) => {
|
|
2321
2349
|
dispatchLayoutAction({
|
|
2322
2350
|
type: "set-props",
|
|
@@ -2333,17 +2361,17 @@ var useTableAndColumnSettings = ({
|
|
|
2333
2361
|
},
|
|
2334
2362
|
[dispatchLayoutAction]
|
|
2335
2363
|
);
|
|
2336
|
-
const handleCancelCreateColumn = (0,
|
|
2364
|
+
const handleCancelCreateColumn = (0, import_react22.useCallback)(() => {
|
|
2337
2365
|
requestAnimationFrame(() => {
|
|
2338
2366
|
var _a;
|
|
2339
2367
|
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2340
2368
|
});
|
|
2341
2369
|
}, []);
|
|
2342
|
-
const handleCreateCalculatedColumn = (0,
|
|
2370
|
+
const handleCreateCalculatedColumn = (0, import_react22.useCallback)(
|
|
2343
2371
|
(column) => {
|
|
2344
2372
|
const newAvailableColumns = availableColumns.concat({
|
|
2345
2373
|
name: column.name,
|
|
2346
|
-
serverDataType: (0,
|
|
2374
|
+
serverDataType: (0, import_vuu_utils18.getCalculatedColumnType)(column)
|
|
2347
2375
|
});
|
|
2348
2376
|
setAvailableColumns(newAvailableColumns);
|
|
2349
2377
|
onAvailableColumnsChange == null ? void 0 : onAvailableColumnsChange(newAvailableColumns);
|
|
@@ -2355,7 +2383,7 @@ var useTableAndColumnSettings = ({
|
|
|
2355
2383
|
},
|
|
2356
2384
|
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2357
2385
|
);
|
|
2358
|
-
const showColumnSettingsPanel = (0,
|
|
2386
|
+
const showColumnSettingsPanel = (0, import_react22.useCallback)(
|
|
2359
2387
|
(action) => {
|
|
2360
2388
|
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2361
2389
|
column: action.column,
|
|
@@ -2374,7 +2402,7 @@ var useTableAndColumnSettings = ({
|
|
|
2374
2402
|
tableConfig
|
|
2375
2403
|
]
|
|
2376
2404
|
);
|
|
2377
|
-
const handleAddCalculatedColumn = (0,
|
|
2405
|
+
const handleAddCalculatedColumn = (0, import_react22.useCallback)(() => {
|
|
2378
2406
|
showColumnSettingsPanel({
|
|
2379
2407
|
column: {
|
|
2380
2408
|
name: "::",
|
|
@@ -2384,7 +2412,7 @@ var useTableAndColumnSettings = ({
|
|
|
2384
2412
|
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2385
2413
|
});
|
|
2386
2414
|
}, [showColumnSettingsPanel]);
|
|
2387
|
-
const handleNavigateToColumn = (0,
|
|
2415
|
+
const handleNavigateToColumn = (0, import_react22.useCallback)(
|
|
2388
2416
|
(columnName) => {
|
|
2389
2417
|
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2390
2418
|
if (column) {
|
|
@@ -2398,7 +2426,7 @@ var useTableAndColumnSettings = ({
|
|
|
2398
2426
|
},
|
|
2399
2427
|
[showColumnSettingsPanel, tableConfig.columns]
|
|
2400
2428
|
);
|
|
2401
|
-
showTableSettingsRef.current = (0,
|
|
2429
|
+
showTableSettingsRef.current = (0, import_react22.useCallback)(() => {
|
|
2402
2430
|
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2403
2431
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2404
2432
|
name,
|
|
@@ -2429,7 +2457,7 @@ var useTableAndColumnSettings = ({
|
|
|
2429
2457
|
var stripInternalProperties = (tableConfig) => {
|
|
2430
2458
|
return tableConfig;
|
|
2431
2459
|
};
|
|
2432
|
-
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } =
|
|
2460
|
+
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils19.metadataKeys;
|
|
2433
2461
|
var NULL_DRAG_DROP = {
|
|
2434
2462
|
draggable: void 0,
|
|
2435
2463
|
onMouseDown: void 0
|
|
@@ -2461,19 +2489,20 @@ var useTable = ({
|
|
|
2461
2489
|
onSelectionChange,
|
|
2462
2490
|
renderBufferSize = 0,
|
|
2463
2491
|
rowHeight = 20,
|
|
2492
|
+
scrollingApiRef,
|
|
2464
2493
|
selectionModel,
|
|
2465
2494
|
size
|
|
2466
2495
|
}) => {
|
|
2467
|
-
const [rowCount, setRowCount] = (0,
|
|
2496
|
+
const [rowCount, setRowCount] = (0, import_react23.useState)(dataSource.size);
|
|
2468
2497
|
if (dataSource === void 0) {
|
|
2469
2498
|
throw Error("no data source provided to Vuu Table");
|
|
2470
2499
|
}
|
|
2471
|
-
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls2.
|
|
2472
|
-
const menuBuilder = (0,
|
|
2500
|
+
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls2.useDragDrop : useNullDragDrop;
|
|
2501
|
+
const menuBuilder = (0, import_react23.useMemo)(
|
|
2473
2502
|
() => buildContextMenuDescriptors(dataSource),
|
|
2474
2503
|
[dataSource]
|
|
2475
2504
|
);
|
|
2476
|
-
const onDataRowcountChange = (0,
|
|
2505
|
+
const onDataRowcountChange = (0, import_react23.useCallback)((size2) => {
|
|
2477
2506
|
setRowCount(size2);
|
|
2478
2507
|
}, []);
|
|
2479
2508
|
const {
|
|
@@ -2483,14 +2512,14 @@ var useTable = ({
|
|
|
2483
2512
|
tableAttributes,
|
|
2484
2513
|
tableConfig
|
|
2485
2514
|
} = useTableModel(config, dataSource);
|
|
2486
|
-
(0,
|
|
2515
|
+
(0, import_vuu_utils19.useLayoutEffectSkipFirst)(() => {
|
|
2487
2516
|
dispatchColumnAction({
|
|
2488
2517
|
type: "init",
|
|
2489
2518
|
dataSource,
|
|
2490
2519
|
tableConfig
|
|
2491
2520
|
});
|
|
2492
2521
|
}, [tableConfig, dataSource, dispatchColumnAction]);
|
|
2493
|
-
const applyTableConfigChange = (0,
|
|
2522
|
+
const applyTableConfigChange = (0, import_react23.useCallback)(
|
|
2494
2523
|
(config2) => {
|
|
2495
2524
|
dispatchColumnAction({
|
|
2496
2525
|
type: "init",
|
|
@@ -2501,16 +2530,16 @@ var useTable = ({
|
|
|
2501
2530
|
},
|
|
2502
2531
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2503
2532
|
);
|
|
2504
|
-
const [stateColumns, setStateColumns] = (0,
|
|
2505
|
-
const [columns, setColumnSize] = (0,
|
|
2533
|
+
const [stateColumns, setStateColumns] = (0, import_react23.useState)();
|
|
2534
|
+
const [columns, setColumnSize] = (0, import_react23.useMemo)(() => {
|
|
2506
2535
|
const setSize = (columnName, width) => {
|
|
2507
|
-
const cols = (0,
|
|
2536
|
+
const cols = (0, import_vuu_utils19.updateColumn)(runtimeColumns, columnName, { width });
|
|
2508
2537
|
setStateColumns(cols);
|
|
2509
2538
|
};
|
|
2510
2539
|
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2511
2540
|
}, [runtimeColumns, stateColumns]);
|
|
2512
|
-
const columnMap = (0,
|
|
2513
|
-
() => (0,
|
|
2541
|
+
const columnMap = (0, import_react23.useMemo)(
|
|
2542
|
+
() => (0, import_vuu_utils19.buildColumnMap)(dataSource.columns),
|
|
2514
2543
|
[dataSource.columns]
|
|
2515
2544
|
);
|
|
2516
2545
|
const {
|
|
@@ -2528,9 +2557,9 @@ var useTable = ({
|
|
|
2528
2557
|
});
|
|
2529
2558
|
const initialRange = useInitialValue({
|
|
2530
2559
|
from: 0,
|
|
2531
|
-
to: viewportMeasurements.rowCount
|
|
2560
|
+
to: viewportMeasurements.rowCount === 0 ? 0 : viewportMeasurements.rowCount + 1
|
|
2532
2561
|
});
|
|
2533
|
-
const onSubscribed = (0,
|
|
2562
|
+
const onSubscribed = (0, import_react23.useCallback)(
|
|
2534
2563
|
({ tableSchema }) => {
|
|
2535
2564
|
if (tableSchema) {
|
|
2536
2565
|
dispatchColumnAction({
|
|
@@ -2552,9 +2581,8 @@ var useTable = ({
|
|
|
2552
2581
|
onSubscribed,
|
|
2553
2582
|
range: initialRange
|
|
2554
2583
|
});
|
|
2555
|
-
const handleConfigEditedInSettingsPanel = (0,
|
|
2584
|
+
const handleConfigEditedInSettingsPanel = (0, import_react23.useCallback)(
|
|
2556
2585
|
(tableConfig2) => {
|
|
2557
|
-
console.log(`settings changed`);
|
|
2558
2586
|
dispatchColumnAction({
|
|
2559
2587
|
type: "init",
|
|
2560
2588
|
tableConfig: tableConfig2,
|
|
@@ -2564,7 +2592,7 @@ var useTable = ({
|
|
|
2564
2592
|
},
|
|
2565
2593
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2566
2594
|
);
|
|
2567
|
-
const handleDataSourceConfigChanged = (0,
|
|
2595
|
+
const handleDataSourceConfigChanged = (0, import_react23.useCallback)(
|
|
2568
2596
|
(dataSourceConfig) => {
|
|
2569
2597
|
dataSource.config = {
|
|
2570
2598
|
...dataSource.config,
|
|
@@ -2573,7 +2601,7 @@ var useTable = ({
|
|
|
2573
2601
|
},
|
|
2574
2602
|
[dataSource]
|
|
2575
2603
|
);
|
|
2576
|
-
(0,
|
|
2604
|
+
(0, import_react23.useEffect)(() => {
|
|
2577
2605
|
dataSource.on("config", (config2, confirmed) => {
|
|
2578
2606
|
dispatchColumnAction({
|
|
2579
2607
|
type: "tableConfig",
|
|
@@ -2582,14 +2610,14 @@ var useTable = ({
|
|
|
2582
2610
|
});
|
|
2583
2611
|
});
|
|
2584
2612
|
}, [dataSource, dispatchColumnAction]);
|
|
2585
|
-
const handleCreateCalculatedColumn = (0,
|
|
2613
|
+
const handleCreateCalculatedColumn = (0, import_react23.useCallback)(
|
|
2586
2614
|
(column) => {
|
|
2587
2615
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2588
2616
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2589
2617
|
},
|
|
2590
2618
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2591
2619
|
);
|
|
2592
|
-
const hideColumns2 = (0,
|
|
2620
|
+
const hideColumns2 = (0, import_react23.useCallback)(
|
|
2593
2621
|
(action) => {
|
|
2594
2622
|
const { columns: columns2 } = action;
|
|
2595
2623
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2603,11 +2631,11 @@ var useTable = ({
|
|
|
2603
2631
|
},
|
|
2604
2632
|
[tableConfig, applyTableConfigChange]
|
|
2605
2633
|
);
|
|
2606
|
-
const pinColumn3 = (0,
|
|
2634
|
+
const pinColumn3 = (0, import_react23.useCallback)(
|
|
2607
2635
|
(action) => {
|
|
2608
2636
|
applyTableConfigChange({
|
|
2609
2637
|
...tableConfig,
|
|
2610
|
-
columns: (0,
|
|
2638
|
+
columns: (0, import_vuu_utils19.updateColumn)(tableConfig.columns, {
|
|
2611
2639
|
...action.column,
|
|
2612
2640
|
pin: action.pin
|
|
2613
2641
|
})
|
|
@@ -2626,7 +2654,7 @@ var useTable = ({
|
|
|
2626
2654
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2627
2655
|
tableConfig
|
|
2628
2656
|
});
|
|
2629
|
-
const onPersistentColumnOperation = (0,
|
|
2657
|
+
const onPersistentColumnOperation = (0, import_react23.useCallback)(
|
|
2630
2658
|
(action) => {
|
|
2631
2659
|
if (isShowColumnSettings(action)) {
|
|
2632
2660
|
showColumnSettingsPanel(action);
|
|
@@ -2655,10 +2683,10 @@ var useTable = ({
|
|
|
2655
2683
|
dataSource,
|
|
2656
2684
|
onPersistentColumnOperation
|
|
2657
2685
|
});
|
|
2658
|
-
const handleSort = (0,
|
|
2686
|
+
const handleSort = (0, import_react23.useCallback)(
|
|
2659
2687
|
(column, extendSort = false, sortType) => {
|
|
2660
2688
|
if (dataSource) {
|
|
2661
|
-
dataSource.sort = (0,
|
|
2689
|
+
dataSource.sort = (0, import_vuu_utils19.applySort)(
|
|
2662
2690
|
dataSource.sort,
|
|
2663
2691
|
column,
|
|
2664
2692
|
extendSort,
|
|
@@ -2668,16 +2696,16 @@ var useTable = ({
|
|
|
2668
2696
|
},
|
|
2669
2697
|
[dataSource]
|
|
2670
2698
|
);
|
|
2671
|
-
const onResizeColumn = (0,
|
|
2699
|
+
const onResizeColumn = (0, import_react23.useCallback)(
|
|
2672
2700
|
(phase, columnName, width) => {
|
|
2673
2701
|
const column = columns.find((column2) => column2.name === columnName);
|
|
2674
2702
|
if (column) {
|
|
2675
2703
|
if (phase === "resize") {
|
|
2676
|
-
if ((0,
|
|
2704
|
+
if ((0, import_vuu_utils19.isValidNumber)(width)) {
|
|
2677
2705
|
setColumnSize(columnName, width);
|
|
2678
2706
|
}
|
|
2679
2707
|
} else if (phase === "end") {
|
|
2680
|
-
if ((0,
|
|
2708
|
+
if ((0, import_vuu_utils19.isValidNumber)(width)) {
|
|
2681
2709
|
dispatchColumnAction({
|
|
2682
2710
|
type: "resizeColumn",
|
|
2683
2711
|
phase,
|
|
@@ -2712,10 +2740,10 @@ var useTable = ({
|
|
|
2712
2740
|
},
|
|
2713
2741
|
[columns, tableConfig, dispatchColumnAction, onConfigChange, setColumnSize]
|
|
2714
2742
|
);
|
|
2715
|
-
const onToggleGroup = (0,
|
|
2743
|
+
const onToggleGroup = (0, import_react23.useCallback)(
|
|
2716
2744
|
(row, column) => {
|
|
2717
2745
|
var _a, _b;
|
|
2718
|
-
const isJson = (0,
|
|
2746
|
+
const isJson = (0, import_vuu_utils19.isJsonGroup)(column, row);
|
|
2719
2747
|
const key = row[KEY];
|
|
2720
2748
|
if (row[IS_EXPANDED2]) {
|
|
2721
2749
|
dataSource.closeTreeNode(key, true);
|
|
@@ -2749,24 +2777,19 @@ var useTable = ({
|
|
|
2749
2777
|
},
|
|
2750
2778
|
[columns, dataSource, dispatchColumnAction]
|
|
2751
2779
|
);
|
|
2752
|
-
const
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
setRange,
|
|
2756
|
-
viewportMeasurements
|
|
2757
|
-
});
|
|
2758
|
-
const handleVerticalScroll = (0, import_react24.useCallback)(
|
|
2759
|
-
(scrollTop) => {
|
|
2760
|
-
onVerticalScroll(scrollTop);
|
|
2780
|
+
const handleVerticalScroll = (0, import_react23.useCallback)(
|
|
2781
|
+
(_, pctScrollTop) => {
|
|
2782
|
+
setPctScrollTop(pctScrollTop);
|
|
2761
2783
|
},
|
|
2762
|
-
[
|
|
2784
|
+
[setPctScrollTop]
|
|
2763
2785
|
);
|
|
2764
2786
|
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2765
|
-
|
|
2766
|
-
maxScrollTop: viewportMeasurements.maxScrollContainerScrollVertical,
|
|
2787
|
+
getRowAtPosition,
|
|
2767
2788
|
rowHeight,
|
|
2789
|
+
scrollingApiRef,
|
|
2790
|
+
setRange,
|
|
2768
2791
|
onVerticalScroll: handleVerticalScroll,
|
|
2769
|
-
|
|
2792
|
+
viewportMeasurements
|
|
2770
2793
|
});
|
|
2771
2794
|
const {
|
|
2772
2795
|
highlightedIndexRef,
|
|
@@ -2794,7 +2817,7 @@ var useTable = ({
|
|
|
2794
2817
|
} = useCellEditing({
|
|
2795
2818
|
navigate
|
|
2796
2819
|
});
|
|
2797
|
-
const handleFocus = (0,
|
|
2820
|
+
const handleFocus = (0, import_react23.useCallback)(
|
|
2798
2821
|
(e) => {
|
|
2799
2822
|
navigationFocus();
|
|
2800
2823
|
if (!e.defaultPrevented) {
|
|
@@ -2809,15 +2832,15 @@ var useTable = ({
|
|
|
2809
2832
|
dataSource,
|
|
2810
2833
|
getSelectedRows
|
|
2811
2834
|
});
|
|
2812
|
-
const onMoveGroupColumn = (0,
|
|
2835
|
+
const onMoveGroupColumn = (0, import_react23.useCallback)(
|
|
2813
2836
|
(columns2) => {
|
|
2814
2837
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2815
2838
|
},
|
|
2816
2839
|
[dataSource]
|
|
2817
2840
|
);
|
|
2818
|
-
const onRemoveGroupColumn = (0,
|
|
2841
|
+
const onRemoveGroupColumn = (0, import_react23.useCallback)(
|
|
2819
2842
|
(column) => {
|
|
2820
|
-
if ((0,
|
|
2843
|
+
if ((0, import_vuu_utils19.isGroupColumn)(column)) {
|
|
2821
2844
|
dataSource.groupBy = [];
|
|
2822
2845
|
} else {
|
|
2823
2846
|
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
@@ -2829,7 +2852,7 @@ var useTable = ({
|
|
|
2829
2852
|
},
|
|
2830
2853
|
[dataSource]
|
|
2831
2854
|
);
|
|
2832
|
-
const handleSelectionChange = (0,
|
|
2855
|
+
const handleSelectionChange = (0, import_react23.useCallback)(
|
|
2833
2856
|
(selected) => {
|
|
2834
2857
|
dataSource.select(selected);
|
|
2835
2858
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
@@ -2845,7 +2868,7 @@ var useTable = ({
|
|
|
2845
2868
|
onSelectionChange: handleSelectionChange,
|
|
2846
2869
|
selectionModel
|
|
2847
2870
|
});
|
|
2848
|
-
const handleKeyDown = (0,
|
|
2871
|
+
const handleKeyDown = (0, import_react23.useCallback)(
|
|
2849
2872
|
(e) => {
|
|
2850
2873
|
navigationKeyDown(e);
|
|
2851
2874
|
if (!e.defaultPrevented) {
|
|
@@ -2857,21 +2880,21 @@ var useTable = ({
|
|
|
2857
2880
|
},
|
|
2858
2881
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2859
2882
|
);
|
|
2860
|
-
const handleRowClick = (0,
|
|
2883
|
+
const handleRowClick = (0, import_react23.useCallback)(
|
|
2861
2884
|
(row, rangeSelect, keepExistingSelection) => {
|
|
2862
2885
|
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2863
2886
|
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
2864
2887
|
},
|
|
2865
2888
|
[onRowClickProp, selectionHookOnRowClick]
|
|
2866
2889
|
);
|
|
2867
|
-
(0,
|
|
2890
|
+
(0, import_vuu_utils19.useLayoutEffectSkipFirst)(() => {
|
|
2868
2891
|
dispatchColumnAction({
|
|
2869
2892
|
type: "init",
|
|
2870
2893
|
tableConfig: config,
|
|
2871
2894
|
dataSource
|
|
2872
2895
|
});
|
|
2873
2896
|
}, [config, dataSource, dispatchColumnAction]);
|
|
2874
|
-
const onMoveColumn = (0,
|
|
2897
|
+
const onMoveColumn = (0, import_react23.useCallback)(
|
|
2875
2898
|
(columns2) => {
|
|
2876
2899
|
console.log(`useTable onMoveColumn`, {
|
|
2877
2900
|
columns: columns2
|
|
@@ -2889,20 +2912,20 @@ var useTable = ({
|
|
|
2889
2912
|
},
|
|
2890
2913
|
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2891
2914
|
);
|
|
2892
|
-
const handleDropRow = (0,
|
|
2915
|
+
const handleDropRow = (0, import_react23.useCallback)(
|
|
2893
2916
|
(dragDropState) => {
|
|
2894
2917
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2895
2918
|
},
|
|
2896
2919
|
[onDrop]
|
|
2897
2920
|
);
|
|
2898
|
-
const handleDataEdited = (0,
|
|
2921
|
+
const handleDataEdited = (0, import_react23.useCallback)(
|
|
2899
2922
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2900
2923
|
[dataSource]
|
|
2901
2924
|
);
|
|
2902
|
-
const handleDragStartRow = (0,
|
|
2925
|
+
const handleDragStartRow = (0, import_react23.useCallback)(
|
|
2903
2926
|
(dragDropState) => {
|
|
2904
2927
|
const { initialDragElement } = dragDropState;
|
|
2905
|
-
const rowIndex = (0,
|
|
2928
|
+
const rowIndex = (0, import_vuu_utils19.getIndexFromRowElement)(initialDragElement);
|
|
2906
2929
|
const row = dataRef.current.find((row2) => row2[0] === rowIndex);
|
|
2907
2930
|
if (row) {
|
|
2908
2931
|
dragDropState.setPayload(row);
|
|
@@ -2934,6 +2957,7 @@ var useTable = ({
|
|
|
2934
2957
|
columnMap,
|
|
2935
2958
|
columns,
|
|
2936
2959
|
data,
|
|
2960
|
+
getRowOffset,
|
|
2937
2961
|
handleContextMenuAction,
|
|
2938
2962
|
headings,
|
|
2939
2963
|
highlightedIndex: highlightedIndexRef.current,
|
|
@@ -2956,37 +2980,37 @@ var useTable = ({
|
|
|
2956
2980
|
};
|
|
2957
2981
|
|
|
2958
2982
|
// src/table-header/TableHeader.tsx
|
|
2959
|
-
var
|
|
2983
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
2960
2984
|
var import_clsx8 = __toESM(require("clsx"));
|
|
2961
2985
|
|
|
2962
2986
|
// src/table-header/useTableHeader.ts
|
|
2963
2987
|
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
2964
|
-
var
|
|
2965
|
-
var
|
|
2988
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
2989
|
+
var import_react24 = require("react");
|
|
2966
2990
|
var useTableHeader = ({
|
|
2967
2991
|
columns,
|
|
2968
2992
|
onMoveColumn,
|
|
2969
2993
|
onSortColumn,
|
|
2970
2994
|
tableConfig
|
|
2971
2995
|
}) => {
|
|
2972
|
-
const containerRef = (0,
|
|
2973
|
-
const handleDropColumnHeader = (0,
|
|
2996
|
+
const containerRef = (0, import_react24.useRef)(null);
|
|
2997
|
+
const handleDropColumnHeader = (0, import_react24.useCallback)(
|
|
2974
2998
|
(moveFrom, moveTo) => {
|
|
2975
2999
|
const column = columns[moveFrom];
|
|
2976
|
-
const orderedColumns = (0,
|
|
3000
|
+
const orderedColumns = (0, import_vuu_utils20.moveColumnTo)(columns, column, moveTo);
|
|
2977
3001
|
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
2978
3002
|
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
2979
3003
|
const nextColumn = orderedColumns[targetIndex + 1];
|
|
2980
3004
|
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
2981
3005
|
if (moveTo > moveFrom && insertPos !== -1) {
|
|
2982
|
-
onMoveColumn((0,
|
|
3006
|
+
onMoveColumn((0, import_vuu_utils20.moveColumnTo)(tableConfig.columns, column, insertPos - 1));
|
|
2983
3007
|
} else {
|
|
2984
|
-
onMoveColumn((0,
|
|
3008
|
+
onMoveColumn((0, import_vuu_utils20.moveColumnTo)(tableConfig.columns, column, insertPos));
|
|
2985
3009
|
}
|
|
2986
3010
|
},
|
|
2987
3011
|
[columns, onMoveColumn, tableConfig.columns]
|
|
2988
3012
|
);
|
|
2989
|
-
const handleColumnHeaderClick = (0,
|
|
3013
|
+
const handleColumnHeaderClick = (0, import_react24.useCallback)(
|
|
2990
3014
|
(evt) => {
|
|
2991
3015
|
var _a;
|
|
2992
3016
|
const targetElement = evt.target;
|
|
@@ -2994,7 +3018,7 @@ var useTableHeader = ({
|
|
|
2994
3018
|
".vuuTableHeaderCell"
|
|
2995
3019
|
);
|
|
2996
3020
|
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
2997
|
-
const column = (0,
|
|
3021
|
+
const column = (0, import_vuu_utils20.visibleColumnAtIndex)(columns, colIdx);
|
|
2998
3022
|
const isAdditive = evt.shiftKey;
|
|
2999
3023
|
column && onSortColumn(column, isAdditive);
|
|
3000
3024
|
},
|
|
@@ -3004,7 +3028,7 @@ var useTableHeader = ({
|
|
|
3004
3028
|
onMouseDown: columnHeaderDragMouseDown,
|
|
3005
3029
|
draggable: draggableColumn,
|
|
3006
3030
|
...dragDropHook
|
|
3007
|
-
} = (0, import_vuu_ui_controls3.
|
|
3031
|
+
} = (0, import_vuu_ui_controls3.useDragDrop)({
|
|
3008
3032
|
allowDragDrop: true,
|
|
3009
3033
|
containerRef,
|
|
3010
3034
|
draggableClassName: `vuuTable`,
|
|
@@ -3050,8 +3074,8 @@ var TableHeader = ({
|
|
|
3050
3074
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headings`, ref: containerRef, children: [
|
|
3051
3075
|
headings.map((colHeaders, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
|
|
3052
3076
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
3053
|
-
columns.filter(
|
|
3054
|
-
(col, i) => (0,
|
|
3077
|
+
columns.filter(import_vuu_utils21.isNotHidden).map(
|
|
3078
|
+
(col, i) => (0, import_vuu_utils21.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3055
3079
|
GroupHeaderCellNext,
|
|
3056
3080
|
{
|
|
3057
3081
|
column: col,
|
|
@@ -3085,7 +3109,7 @@ var TableHeader = ({
|
|
|
3085
3109
|
// src/Table.tsx
|
|
3086
3110
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3087
3111
|
var classBase7 = "vuuTable";
|
|
3088
|
-
var { IDX: IDX3, RENDER_IDX } =
|
|
3112
|
+
var { IDX: IDX3, RENDER_IDX } = import_vuu_utils22.metadataKeys;
|
|
3089
3113
|
var TableCore = ({
|
|
3090
3114
|
Row: Row2 = Row,
|
|
3091
3115
|
allowDragDrop,
|
|
@@ -3106,19 +3130,21 @@ var TableCore = ({
|
|
|
3106
3130
|
onRowClick: onRowClickProp,
|
|
3107
3131
|
onSelect,
|
|
3108
3132
|
onSelectionChange,
|
|
3109
|
-
renderBufferSize =
|
|
3133
|
+
renderBufferSize = 5,
|
|
3110
3134
|
rowHeight = 20,
|
|
3135
|
+
scrollingApiRef,
|
|
3111
3136
|
selectionModel = "extended",
|
|
3112
3137
|
showColumnHeaders = true,
|
|
3113
3138
|
headerHeight = showColumnHeaders ? 25 : 0,
|
|
3114
3139
|
size
|
|
3115
3140
|
}) => {
|
|
3116
|
-
const id = (0,
|
|
3141
|
+
const id = (0, import_vuu_utils22.useId)(idProp);
|
|
3117
3142
|
const {
|
|
3118
3143
|
columnMap,
|
|
3119
3144
|
columns,
|
|
3120
3145
|
data,
|
|
3121
3146
|
draggableRow,
|
|
3147
|
+
getRowOffset,
|
|
3122
3148
|
handleContextMenuAction,
|
|
3123
3149
|
headings,
|
|
3124
3150
|
highlightedIndex,
|
|
@@ -3158,10 +3184,11 @@ var TableCore = ({
|
|
|
3158
3184
|
onSelectionChange,
|
|
3159
3185
|
renderBufferSize,
|
|
3160
3186
|
rowHeight,
|
|
3187
|
+
scrollingApiRef,
|
|
3161
3188
|
selectionModel,
|
|
3162
3189
|
size
|
|
3163
3190
|
});
|
|
3164
|
-
const
|
|
3191
|
+
const contentContainerClassName = (0, import_clsx9.default)(`${classBase7}-contentContainer`, {
|
|
3165
3192
|
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3166
3193
|
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3167
3194
|
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
@@ -3198,7 +3225,7 @@ var TableCore = ({
|
|
|
3198
3225
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3199
3226
|
"div",
|
|
3200
3227
|
{
|
|
3201
|
-
className,
|
|
3228
|
+
className: contentContainerClassName,
|
|
3202
3229
|
ref: scrollProps.contentContainerRef,
|
|
3203
3230
|
style: cssVariables,
|
|
3204
3231
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3226,13 +3253,14 @@ var TableCore = ({
|
|
|
3226
3253
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase7}-body`, children: data.map((data2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3227
3254
|
Row2,
|
|
3228
3255
|
{
|
|
3256
|
+
"aria-rowindex": data2[0] + 1,
|
|
3229
3257
|
columnMap,
|
|
3230
3258
|
columns,
|
|
3231
3259
|
highlighted: highlightedIndex === data2[IDX3],
|
|
3232
3260
|
onClick: onRowClick,
|
|
3233
3261
|
onDataEdited,
|
|
3234
3262
|
row: data2,
|
|
3235
|
-
offset:
|
|
3263
|
+
offset: getRowOffset(data2),
|
|
3236
3264
|
onToggleGroup,
|
|
3237
3265
|
zebraStripes: tableAttributes.zebraStripes
|
|
3238
3266
|
},
|
|
@@ -3248,7 +3276,7 @@ var TableCore = ({
|
|
|
3248
3276
|
}
|
|
3249
3277
|
);
|
|
3250
3278
|
};
|
|
3251
|
-
var Table = (0,
|
|
3279
|
+
var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
3252
3280
|
Row: Row2,
|
|
3253
3281
|
allowDragDrop,
|
|
3254
3282
|
availableColumns,
|
|
@@ -3270,14 +3298,15 @@ var Table = (0, import_react26.forwardRef)(function TableNext({
|
|
|
3270
3298
|
onSelectionChange,
|
|
3271
3299
|
renderBufferSize,
|
|
3272
3300
|
rowHeight,
|
|
3301
|
+
scrollingApiRef,
|
|
3273
3302
|
selectionModel,
|
|
3274
3303
|
showColumnHeaders,
|
|
3275
3304
|
headerHeight,
|
|
3276
3305
|
style: styleProp,
|
|
3277
3306
|
...htmlAttributes
|
|
3278
3307
|
}, forwardedRef) {
|
|
3279
|
-
const containerRef = (0,
|
|
3280
|
-
const [size, setSize] = (0,
|
|
3308
|
+
const containerRef = (0, import_react25.useRef)(null);
|
|
3309
|
+
const [size, setSize] = (0, import_react25.useState)();
|
|
3281
3310
|
if (config === void 0) {
|
|
3282
3311
|
throw Error(
|
|
3283
3312
|
"vuu Table requires config prop. Minimum config is list of Column Descriptors"
|
|
@@ -3319,6 +3348,7 @@ var Table = (0, import_react26.forwardRef)(function TableNext({
|
|
|
3319
3348
|
onSelectionChange,
|
|
3320
3349
|
renderBufferSize,
|
|
3321
3350
|
rowHeight,
|
|
3351
|
+
scrollingApiRef,
|
|
3322
3352
|
selectionModel,
|
|
3323
3353
|
showColumnHeaders,
|
|
3324
3354
|
size
|
|
@@ -3329,7 +3359,7 @@ var Table = (0, import_react26.forwardRef)(function TableNext({
|
|
|
3329
3359
|
});
|
|
3330
3360
|
|
|
3331
3361
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3332
|
-
var
|
|
3362
|
+
var import_react26 = require("react");
|
|
3333
3363
|
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
3334
3364
|
var import_core3 = require("@salt-ds/core");
|
|
3335
3365
|
|
|
@@ -3337,17 +3367,17 @@ var import_core3 = require("@salt-ds/core");
|
|
|
3337
3367
|
var dataAndColumnUnchanged = (p, p1) => p.column === p1.column && p.column.valueFormatter(p.row[p.columnMap[p.column.name]]) === p1.column.valueFormatter(p1.row[p1.columnMap[p1.column.name]]);
|
|
3338
3368
|
|
|
3339
3369
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3340
|
-
var
|
|
3370
|
+
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3341
3371
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3342
|
-
var CheckboxCell = (0,
|
|
3372
|
+
var CheckboxCell = (0, import_react26.memo)(
|
|
3343
3373
|
({ column, columnMap, onCommit = import_vuu_ui_controls4.WarnCommit, row }) => {
|
|
3344
3374
|
const dataIdx = columnMap[column.name];
|
|
3345
3375
|
const isChecked = row[dataIdx];
|
|
3346
|
-
const handleCommit = (0,
|
|
3376
|
+
const handleCommit = (0, import_react26.useCallback)(
|
|
3347
3377
|
(value) => async (evt) => {
|
|
3348
3378
|
const res = await onCommit(value);
|
|
3349
3379
|
if (res === true) {
|
|
3350
|
-
(0,
|
|
3380
|
+
(0, import_vuu_utils23.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3351
3381
|
}
|
|
3352
3382
|
return res;
|
|
3353
3383
|
},
|
|
@@ -3358,12 +3388,12 @@ var CheckboxCell = (0, import_react27.memo)(
|
|
|
3358
3388
|
dataAndColumnUnchanged
|
|
3359
3389
|
);
|
|
3360
3390
|
CheckboxCell.displayName = "CheckboxCell";
|
|
3361
|
-
(0,
|
|
3391
|
+
(0, import_vuu_utils23.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
|
|
3362
3392
|
serverDataType: "boolean"
|
|
3363
3393
|
});
|
|
3364
3394
|
|
|
3365
3395
|
// src/cell-renderers/input-cell/InputCell.tsx
|
|
3366
|
-
var
|
|
3396
|
+
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
3367
3397
|
var import_core4 = require("@salt-ds/core");
|
|
3368
3398
|
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
3369
3399
|
var import_clsx10 = __toESM(require("clsx"));
|
|
@@ -3402,18 +3432,18 @@ var InputCell = ({
|
|
|
3402
3432
|
}
|
|
3403
3433
|
);
|
|
3404
3434
|
};
|
|
3405
|
-
(0,
|
|
3435
|
+
(0, import_vuu_utils24.registerComponent)("input-cell", InputCell, "cell-renderer", {});
|
|
3406
3436
|
|
|
3407
3437
|
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3408
3438
|
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
3409
|
-
var
|
|
3439
|
+
var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
|
|
3410
3440
|
var import_clsx11 = __toESM(require("clsx"));
|
|
3411
|
-
var
|
|
3441
|
+
var import_react27 = require("react");
|
|
3412
3442
|
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3413
3443
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3414
3444
|
var classBase9 = "vuuTableToggleCell";
|
|
3415
3445
|
var getValueList = ({ name, type }) => {
|
|
3416
|
-
if ((0,
|
|
3446
|
+
if ((0, import_vuu_utils25.isTypeDescriptor)(type) && (0, import_vuu_utils25.isValueListRenderer)(type.renderer)) {
|
|
3417
3447
|
return type.renderer.values;
|
|
3418
3448
|
} else {
|
|
3419
3449
|
throw Error(
|
|
@@ -3421,7 +3451,7 @@ var getValueList = ({ name, type }) => {
|
|
|
3421
3451
|
);
|
|
3422
3452
|
}
|
|
3423
3453
|
};
|
|
3424
|
-
var ToggleCell = (0,
|
|
3454
|
+
var ToggleCell = (0, import_react27.memo)(
|
|
3425
3455
|
function ToggleCell2({
|
|
3426
3456
|
column,
|
|
3427
3457
|
columnMap,
|
|
@@ -3431,11 +3461,11 @@ var ToggleCell = (0, import_react28.memo)(
|
|
|
3431
3461
|
const values = getValueList(column);
|
|
3432
3462
|
const dataIdx = columnMap[column.name];
|
|
3433
3463
|
const value = row[dataIdx];
|
|
3434
|
-
const handleCommit = (0,
|
|
3464
|
+
const handleCommit = (0, import_react27.useCallback)(
|
|
3435
3465
|
(evt, value2) => {
|
|
3436
3466
|
return onCommit(value2).then((response) => {
|
|
3437
3467
|
if (response === true) {
|
|
3438
|
-
(0,
|
|
3468
|
+
(0, import_vuu_utils25.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3439
3469
|
}
|
|
3440
3470
|
return response;
|
|
3441
3471
|
});
|
|
@@ -3456,16 +3486,16 @@ var ToggleCell = (0, import_react28.memo)(
|
|
|
3456
3486
|
},
|
|
3457
3487
|
dataAndColumnUnchanged
|
|
3458
3488
|
);
|
|
3459
|
-
(0,
|
|
3489
|
+
(0, import_vuu_utils25.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
3460
3490
|
|
|
3461
3491
|
// src/useControlledTableNavigation.ts
|
|
3462
3492
|
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3463
|
-
var
|
|
3464
|
-
var
|
|
3493
|
+
var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
|
|
3494
|
+
var import_react28 = require("react");
|
|
3465
3495
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3466
|
-
const tableRef = (0,
|
|
3496
|
+
const tableRef = (0, import_react28.useRef)(null);
|
|
3467
3497
|
const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls8.useStateRef)(initialValue);
|
|
3468
|
-
const handleKeyDown = (0,
|
|
3498
|
+
const handleKeyDown = (0, import_react28.useCallback)(
|
|
3469
3499
|
(e) => {
|
|
3470
3500
|
var _a;
|
|
3471
3501
|
if (e.key === "ArrowDown") {
|
|
@@ -3478,13 +3508,13 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
|
3478
3508
|
`[aria-rowindex="${rowIdx}"]`
|
|
3479
3509
|
);
|
|
3480
3510
|
if (rowEl) {
|
|
3481
|
-
(0,
|
|
3511
|
+
(0, import_vuu_utils26.dispatchMouseEvent)(rowEl, "click");
|
|
3482
3512
|
}
|
|
3483
3513
|
}
|
|
3484
3514
|
},
|
|
3485
3515
|
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3486
3516
|
);
|
|
3487
|
-
const handleHighlight = (0,
|
|
3517
|
+
const handleHighlight = (0, import_react28.useCallback)(
|
|
3488
3518
|
(idx) => {
|
|
3489
3519
|
setHighlightedIndex(idx);
|
|
3490
3520
|
},
|