@vuu-ui/vuu-table 0.8.22-debug → 0.8.23-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 +715 -584
- package/cjs/index.js.map +4 -4
- package/esm/index.js +646 -502
- package/esm/index.js.map +4 -4
- package/index.css +7 -1
- package/index.css.map +2 -2
- package/package.json +8 -8
- package/types/Row.d.ts +2 -1
- package/types/Table.d.ts +3 -4
- package/types/cell-renderers/index.d.ts +0 -1
- package/types/column-resizing/ColumnResizer.d.ts +2 -2
- package/types/column-resizing/useTableColumnResize.d.ts +1 -1
- package/types/table-cell/TableGroupCell.d.ts +1 -1
- package/types/table-dom-utils.d.ts +3 -1
- package/types/table-header/TableHeader.d.ts +2 -1
- package/types/table-header/useTableHeader.d.ts +1 -1
- package/types/useTable.d.ts +4 -3
- package/types/useTableScroll.d.ts +14 -4
- package/types/useTableViewport.d.ts +9 -5
- package/types/cell-renderers/cell-utils.d.ts +0 -7
package/cjs/index.js
CHANGED
|
@@ -38,8 +38,6 @@ __export(src_exports, {
|
|
|
38
38
|
TableCell: () => TableCell,
|
|
39
39
|
TableGroupCell: () => TableGroupCell,
|
|
40
40
|
ToggleCell: () => ToggleCell,
|
|
41
|
-
dataAndColumnUnchanged: () => dataAndColumnUnchanged,
|
|
42
|
-
howFarIsRowOutsideViewport: () => howFarIsRowOutsideViewport,
|
|
43
41
|
isShowColumnSettings: () => isShowColumnSettings,
|
|
44
42
|
isShowTableSettings: () => isShowTableSettings,
|
|
45
43
|
noScrolling: () => noScrolling,
|
|
@@ -52,7 +50,7 @@ __export(src_exports, {
|
|
|
52
50
|
module.exports = __toCommonJS(src_exports);
|
|
53
51
|
|
|
54
52
|
// src/header-cell/GroupHeaderCellNext.tsx
|
|
55
|
-
var
|
|
53
|
+
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
56
54
|
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
57
55
|
var import_clsx3 = __toESM(require("clsx"));
|
|
58
56
|
var import_react5 = require("react");
|
|
@@ -135,7 +133,7 @@ var ColumnResizer = ({
|
|
|
135
133
|
onDragEnd = NOOP,
|
|
136
134
|
onDragStart = NOOP
|
|
137
135
|
}) => {
|
|
138
|
-
const
|
|
136
|
+
const positionRef = (0, import_react2.useRef)({ start: 0, now: 0 });
|
|
139
137
|
const onMouseMove = (0, import_react2.useCallback)(
|
|
140
138
|
(e) => {
|
|
141
139
|
if (e.stopPropagation) {
|
|
@@ -144,11 +142,13 @@ var ColumnResizer = ({
|
|
|
144
142
|
if (e.preventDefault) {
|
|
145
143
|
e.preventDefault();
|
|
146
144
|
}
|
|
145
|
+
const { current: position } = positionRef;
|
|
147
146
|
const x = Math.round(e.clientX);
|
|
148
|
-
const moveBy = x - position.
|
|
149
|
-
position.
|
|
147
|
+
const moveBy = x - position.now;
|
|
148
|
+
const distanceMoved = position.now - position.start;
|
|
149
|
+
positionRef.current.now = x;
|
|
150
150
|
if (moveBy !== 0) {
|
|
151
|
-
onDrag(e, moveBy);
|
|
151
|
+
onDrag(e, moveBy, distanceMoved);
|
|
152
152
|
}
|
|
153
153
|
},
|
|
154
154
|
[onDrag]
|
|
@@ -157,14 +157,17 @@ var ColumnResizer = ({
|
|
|
157
157
|
(e) => {
|
|
158
158
|
window.removeEventListener("mouseup", onMouseUp);
|
|
159
159
|
window.removeEventListener("mousemove", onMouseMove);
|
|
160
|
-
|
|
160
|
+
const { current: position } = positionRef;
|
|
161
|
+
const distanceMoved = position.now - position.start;
|
|
162
|
+
onDragEnd(e, distanceMoved);
|
|
161
163
|
},
|
|
162
164
|
[onDragEnd, onMouseMove]
|
|
163
165
|
);
|
|
164
166
|
const handleMouseDown = (0, import_react2.useCallback)(
|
|
165
167
|
(e) => {
|
|
168
|
+
const { current: position } = positionRef;
|
|
166
169
|
onDragStart(e);
|
|
167
|
-
position.
|
|
170
|
+
position.now = position.start = Math.round(e.clientX);
|
|
168
171
|
window.addEventListener("mouseup", onMouseUp);
|
|
169
172
|
window.addEventListener("mousemove", onMouseMove);
|
|
170
173
|
if (e.stopPropagation) {
|
|
@@ -186,26 +189,27 @@ var useTableColumnResize = ({
|
|
|
186
189
|
onResize,
|
|
187
190
|
rootRef
|
|
188
191
|
}) => {
|
|
189
|
-
const widthRef = (0, import_react3.useRef)(0);
|
|
192
|
+
const widthRef = (0, import_react3.useRef)({ start: 0, now: 0 });
|
|
190
193
|
const [isResizing, setResizing] = (0, import_react3.useState)(false);
|
|
191
194
|
const { name } = column;
|
|
192
195
|
const handleResizeStart = (0, import_react3.useCallback)(() => {
|
|
193
196
|
if (onResize && rootRef.current) {
|
|
194
|
-
const { width } =
|
|
195
|
-
|
|
197
|
+
const { current: width } = widthRef;
|
|
198
|
+
const { width: measuredWidth } = rootRef.current.getBoundingClientRect();
|
|
199
|
+
width.start = width.now = Math.round(measuredWidth);
|
|
196
200
|
setResizing(true);
|
|
197
201
|
onResize == null ? void 0 : onResize("begin", name);
|
|
198
202
|
}
|
|
199
203
|
}, [name, onResize, rootRef]);
|
|
200
204
|
const handleResize = (0, import_react3.useCallback)(
|
|
201
|
-
(_evt, moveBy) => {
|
|
205
|
+
(_evt, moveBy, totalDistanceMoved) => {
|
|
202
206
|
if (rootRef.current) {
|
|
203
207
|
if (onResize) {
|
|
204
|
-
const { width } =
|
|
205
|
-
const newWidth =
|
|
206
|
-
if (newWidth !==
|
|
208
|
+
const { current: width } = widthRef;
|
|
209
|
+
const newWidth = width.start + totalDistanceMoved;
|
|
210
|
+
if (newWidth !== width.now && newWidth > 0) {
|
|
207
211
|
onResize("resize", name, newWidth);
|
|
208
|
-
|
|
212
|
+
width.now = newWidth;
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
}
|
|
@@ -214,7 +218,8 @@ var useTableColumnResize = ({
|
|
|
214
218
|
);
|
|
215
219
|
const handleResizeEnd = (0, import_react3.useCallback)(() => {
|
|
216
220
|
if (onResize) {
|
|
217
|
-
|
|
221
|
+
const { current: width } = widthRef;
|
|
222
|
+
onResize("end", name, width.now);
|
|
218
223
|
setTimeout(() => {
|
|
219
224
|
setResizing(false);
|
|
220
225
|
}, 80);
|
|
@@ -316,7 +321,7 @@ var GroupHeaderCellNext = ({
|
|
|
316
321
|
style,
|
|
317
322
|
children: [
|
|
318
323
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
319
|
-
|
|
324
|
+
import_vuu_ui_controls.OverflowContainer,
|
|
320
325
|
{
|
|
321
326
|
allowDragDrop: true,
|
|
322
327
|
className: `${classBase2}-inner`,
|
|
@@ -329,7 +334,7 @@ var GroupHeaderCellNext = ({
|
|
|
329
334
|
{
|
|
330
335
|
...columnPillProps,
|
|
331
336
|
column,
|
|
332
|
-
key: column.
|
|
337
|
+
key: column.name
|
|
333
338
|
}
|
|
334
339
|
);
|
|
335
340
|
})
|
|
@@ -452,8 +457,8 @@ var HeaderCell = ({
|
|
|
452
457
|
};
|
|
453
458
|
|
|
454
459
|
// src/Table.tsx
|
|
455
|
-
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
456
460
|
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
461
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
457
462
|
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
458
463
|
var import_core2 = require("@salt-ds/core");
|
|
459
464
|
var import_clsx9 = __toESM(require("clsx"));
|
|
@@ -477,7 +482,7 @@ var TableCell = ({
|
|
|
477
482
|
row
|
|
478
483
|
}) => {
|
|
479
484
|
const { className, style } = useCell(column, classBase4);
|
|
480
|
-
const { CellRenderer, name, valueFormatter } = column;
|
|
485
|
+
const { CellRenderer, index, name, valueFormatter } = column;
|
|
481
486
|
const dataIdx = columnMap[name];
|
|
482
487
|
const handleDataItemEdited = (0, import_react9.useCallback)(
|
|
483
488
|
(value) => {
|
|
@@ -504,6 +509,7 @@ var TableCell = ({
|
|
|
504
509
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
505
510
|
"div",
|
|
506
511
|
{
|
|
512
|
+
"aria-colindex": index,
|
|
507
513
|
className,
|
|
508
514
|
onClick: onClick ? handleClick : void 0,
|
|
509
515
|
role: "cell",
|
|
@@ -528,9 +534,14 @@ var import_clsx6 = __toESM(require("clsx"));
|
|
|
528
534
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
529
535
|
var { IS_LEAF } = import_vuu_utils4.metadataKeys;
|
|
530
536
|
var classBase5 = "vuuTableGroupCell";
|
|
531
|
-
var TableGroupCell = ({
|
|
537
|
+
var TableGroupCell = ({
|
|
538
|
+
column,
|
|
539
|
+
columnMap,
|
|
540
|
+
onClick,
|
|
541
|
+
row
|
|
542
|
+
}) => {
|
|
532
543
|
const { columns } = column;
|
|
533
|
-
const [value, offset] = (0, import_vuu_utils4.getGroupValueAndOffset)(columns, row);
|
|
544
|
+
const [value, offset] = (0, import_vuu_utils4.getGroupValueAndOffset)(columns, row, columnMap);
|
|
534
545
|
const { className, style } = useCell(column, classBase5);
|
|
535
546
|
const handleClick = (0, import_react10.useCallback)(
|
|
536
547
|
(evt) => {
|
|
@@ -558,7 +569,6 @@ var TableGroupCell = ({ column, onClick, row }) => {
|
|
|
558
569
|
|
|
559
570
|
// src/Row.tsx
|
|
560
571
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
561
|
-
var import_react12 = require("react");
|
|
562
572
|
var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils5.metadataKeys;
|
|
563
573
|
var classBase6 = "vuuTableRow";
|
|
564
574
|
var Row = (0, import_react11.memo)(
|
|
@@ -572,6 +582,7 @@ var Row = (0, import_react11.memo)(
|
|
|
572
582
|
onClick,
|
|
573
583
|
onDataEdited,
|
|
574
584
|
onToggleGroup,
|
|
585
|
+
virtualColSpan = 0,
|
|
575
586
|
zebraStripes = false,
|
|
576
587
|
...htmlAttributes
|
|
577
588
|
}) => {
|
|
@@ -600,53 +611,207 @@ var Row = (0, import_react11.memo)(
|
|
|
600
611
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
601
612
|
const handleGroupCellClick = (0, import_react11.useCallback)(
|
|
602
613
|
(evt, column) => {
|
|
603
|
-
if ((0, import_vuu_utils5.isGroupColumn)(column) || (0, import_vuu_utils5.isJsonGroup)(column, row)) {
|
|
614
|
+
if ((0, import_vuu_utils5.isGroupColumn)(column) || (0, import_vuu_utils5.isJsonGroup)(column, row, columnMap)) {
|
|
604
615
|
evt.stopPropagation();
|
|
605
616
|
onToggleGroup == null ? void 0 : onToggleGroup(row, column);
|
|
606
617
|
}
|
|
607
618
|
},
|
|
608
|
-
[onToggleGroup, row]
|
|
619
|
+
[columnMap, onToggleGroup, row]
|
|
609
620
|
);
|
|
610
|
-
return /* @__PURE__ */ (0,
|
|
621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
611
622
|
"div",
|
|
612
623
|
{
|
|
613
624
|
...htmlAttributes,
|
|
614
|
-
key: `row-${row[0]}`,
|
|
615
625
|
role: "row",
|
|
616
626
|
className,
|
|
617
627
|
onClick: handleRowClick,
|
|
618
|
-
style
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
628
|
+
style,
|
|
629
|
+
children: [
|
|
630
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase6}-selectionDecorator vuuStickyLeft` }),
|
|
631
|
+
virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "vuuTableCell", style: { width: virtualColSpan } }) : null,
|
|
632
|
+
columns.filter(import_vuu_utils5.isNotHidden).map((column) => {
|
|
633
|
+
const isGroup = (0, import_vuu_utils5.isGroupColumn)(column);
|
|
634
|
+
const isJsonCell = (0, import_vuu_utils5.isJsonColumn)(column);
|
|
635
|
+
const Cell = isGroup ? TableGroupCell : TableCell;
|
|
636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
637
|
+
Cell,
|
|
638
|
+
{
|
|
639
|
+
column,
|
|
640
|
+
columnMap,
|
|
641
|
+
onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
|
|
642
|
+
onDataEdited,
|
|
643
|
+
row
|
|
644
|
+
},
|
|
645
|
+
column.name
|
|
646
|
+
);
|
|
647
|
+
}),
|
|
648
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase6}-selectionDecorator vuuStickyRight` })
|
|
649
|
+
]
|
|
650
|
+
}
|
|
638
651
|
);
|
|
639
652
|
}
|
|
640
653
|
);
|
|
641
654
|
Row.displayName = "Row";
|
|
642
655
|
|
|
643
|
-
// src/
|
|
656
|
+
// src/table-header/TableHeader.tsx
|
|
657
|
+
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
658
|
+
var import_clsx8 = __toESM(require("clsx"));
|
|
659
|
+
var import_react13 = require("react");
|
|
660
|
+
|
|
661
|
+
// src/table-header/useTableHeader.ts
|
|
644
662
|
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
645
|
-
var
|
|
646
|
-
var
|
|
663
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
664
|
+
var import_react12 = require("react");
|
|
665
|
+
var useTableHeader = ({
|
|
666
|
+
columns,
|
|
667
|
+
onMoveColumn,
|
|
668
|
+
onSortColumn,
|
|
669
|
+
tableConfig
|
|
670
|
+
}) => {
|
|
671
|
+
const containerRef = (0, import_react12.useRef)(null);
|
|
672
|
+
const scrollingContainerRef = (0, import_react12.useRef)(null);
|
|
673
|
+
const setContainerRef = (0, import_react12.useCallback)((el) => {
|
|
674
|
+
containerRef.current = el;
|
|
675
|
+
if (el) {
|
|
676
|
+
scrollingContainerRef.current = el.closest(".vuuTable-contentContainer");
|
|
677
|
+
} else {
|
|
678
|
+
scrollingContainerRef.current = null;
|
|
679
|
+
}
|
|
680
|
+
}, []);
|
|
681
|
+
const handleDropColumnHeader = (0, import_react12.useCallback)(
|
|
682
|
+
({ fromIndex: moveFrom, toIndex: moveTo }) => {
|
|
683
|
+
const column = columns[moveFrom];
|
|
684
|
+
const orderedColumns = (0, import_vuu_utils6.moveColumnTo)(columns, column, moveTo);
|
|
685
|
+
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
686
|
+
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
687
|
+
const nextColumn = orderedColumns[targetIndex + 1];
|
|
688
|
+
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
689
|
+
if (moveTo > moveFrom && insertPos !== -1) {
|
|
690
|
+
onMoveColumn((0, import_vuu_utils6.moveColumnTo)(tableConfig.columns, column, insertPos - 1));
|
|
691
|
+
} else {
|
|
692
|
+
onMoveColumn((0, import_vuu_utils6.moveColumnTo)(tableConfig.columns, column, insertPos));
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
[columns, onMoveColumn, tableConfig.columns]
|
|
696
|
+
);
|
|
697
|
+
const handleColumnHeaderClick = (0, import_react12.useCallback)(
|
|
698
|
+
(evt) => {
|
|
699
|
+
var _a;
|
|
700
|
+
const targetElement = evt.target;
|
|
701
|
+
const headerCell = targetElement.closest(
|
|
702
|
+
".vuuTableHeaderCell"
|
|
703
|
+
);
|
|
704
|
+
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
705
|
+
const column = (0, import_vuu_utils6.visibleColumnAtIndex)(columns, colIdx);
|
|
706
|
+
const isAdditive = evt.shiftKey;
|
|
707
|
+
column && onSortColumn(column, isAdditive);
|
|
708
|
+
},
|
|
709
|
+
[columns, onSortColumn]
|
|
710
|
+
);
|
|
711
|
+
const {
|
|
712
|
+
onMouseDown: columnHeaderDragMouseDown,
|
|
713
|
+
draggable: draggableColumn,
|
|
714
|
+
...dragDropHook
|
|
715
|
+
} = (0, import_vuu_ui_controls2.useDragDrop)({
|
|
716
|
+
allowDragDrop: true,
|
|
717
|
+
containerRef,
|
|
718
|
+
draggableClassName: `vuuTable`,
|
|
719
|
+
itemQuery: ".vuuTableHeaderCell",
|
|
720
|
+
onDrop: handleDropColumnHeader,
|
|
721
|
+
orientation: "horizontal",
|
|
722
|
+
scrollingContainerRef
|
|
723
|
+
});
|
|
724
|
+
return {
|
|
725
|
+
draggableColumn,
|
|
726
|
+
draggedColumnIndex: dragDropHook.draggedItemIndex,
|
|
727
|
+
onClick: handleColumnHeaderClick,
|
|
728
|
+
onMouseDown: columnHeaderDragMouseDown,
|
|
729
|
+
setContainerRef
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// src/table-header/TableHeader.tsx
|
|
734
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
735
|
+
var TableHeader = (0, import_react13.memo)(
|
|
736
|
+
({
|
|
737
|
+
classBase: classBase10 = "vuuTable",
|
|
738
|
+
columns,
|
|
739
|
+
headings,
|
|
740
|
+
onMoveColumn,
|
|
741
|
+
onMoveGroupColumn,
|
|
742
|
+
onRemoveGroupColumn,
|
|
743
|
+
onResizeColumn,
|
|
744
|
+
onSortColumn,
|
|
745
|
+
tableConfig,
|
|
746
|
+
tableId,
|
|
747
|
+
virtualColSpan = 0
|
|
748
|
+
}) => {
|
|
749
|
+
const {
|
|
750
|
+
draggableColumn,
|
|
751
|
+
draggedColumnIndex,
|
|
752
|
+
onClick,
|
|
753
|
+
onMouseDown,
|
|
754
|
+
setContainerRef
|
|
755
|
+
} = useTableHeader({
|
|
756
|
+
columns,
|
|
757
|
+
onMoveColumn,
|
|
758
|
+
onSortColumn,
|
|
759
|
+
tableConfig
|
|
760
|
+
});
|
|
761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headings`, ref: setContainerRef, children: [
|
|
762
|
+
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)),
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
764
|
+
virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
765
|
+
"div",
|
|
766
|
+
{
|
|
767
|
+
role: "cell",
|
|
768
|
+
className: "vuuTableCell",
|
|
769
|
+
style: { width: virtualColSpan }
|
|
770
|
+
}
|
|
771
|
+
) : null,
|
|
772
|
+
columns.filter(import_vuu_utils7.isNotHidden).map(
|
|
773
|
+
(col, i) => (0, import_vuu_utils7.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
774
|
+
GroupHeaderCellNext,
|
|
775
|
+
{
|
|
776
|
+
"aria-colindex": col.index,
|
|
777
|
+
column: col,
|
|
778
|
+
"data-index": i,
|
|
779
|
+
onMoveColumn: onMoveGroupColumn,
|
|
780
|
+
onRemoveColumn: onRemoveGroupColumn,
|
|
781
|
+
onResize: onResizeColumn
|
|
782
|
+
},
|
|
783
|
+
col.name
|
|
784
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
785
|
+
HeaderCell,
|
|
786
|
+
{
|
|
787
|
+
"aria-colindex": col.index,
|
|
788
|
+
className: (0, import_clsx8.default)({
|
|
789
|
+
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
790
|
+
}),
|
|
791
|
+
column: col,
|
|
792
|
+
"data-index": i,
|
|
793
|
+
id: `${tableId}-col-${i}`,
|
|
794
|
+
onClick,
|
|
795
|
+
onMouseDown,
|
|
796
|
+
onResize: onResizeColumn
|
|
797
|
+
},
|
|
798
|
+
col.name
|
|
799
|
+
)
|
|
800
|
+
),
|
|
801
|
+
draggableColumn
|
|
802
|
+
] })
|
|
803
|
+
] });
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
TableHeader.displayName = "TableHeader";
|
|
807
|
+
|
|
808
|
+
// src/useTable.ts
|
|
809
|
+
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
810
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
811
|
+
var import_react24 = require("react");
|
|
647
812
|
|
|
648
813
|
// src/context-menu/buildContextMenuDescriptors.ts
|
|
649
|
-
var
|
|
814
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
650
815
|
var buildContextMenuDescriptors = (dataSource) => (location, options) => {
|
|
651
816
|
const descriptors = [];
|
|
652
817
|
if (dataSource === void 0) {
|
|
@@ -764,7 +929,7 @@ function buildAggregationMenuItems(options, dataSource) {
|
|
|
764
929
|
{ label: "Count", action: "agg-count", options },
|
|
765
930
|
{ label: "Distinct", action: "agg-distinct", options }
|
|
766
931
|
].concat(
|
|
767
|
-
(0,
|
|
932
|
+
(0, import_vuu_utils8.isNumericColumn)(column) ? [
|
|
768
933
|
{ label: "Sum", action: "agg-sum", options },
|
|
769
934
|
{ label: "Avg", action: "agg-avg", options },
|
|
770
935
|
{ label: "High", action: "agg-high", options },
|
|
@@ -856,11 +1021,11 @@ function buildGroupMenuItems(options, { groupBy }) {
|
|
|
856
1021
|
}
|
|
857
1022
|
|
|
858
1023
|
// src/context-menu/useHandleTableContextMenu.ts
|
|
859
|
-
var
|
|
860
|
-
var
|
|
1024
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
1025
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
861
1026
|
var removeFilterColumn = (dataSourceFilter, column) => {
|
|
862
1027
|
if (dataSourceFilter.filterStruct && column) {
|
|
863
|
-
const [filterStruct, filter] = (0,
|
|
1028
|
+
const [filterStruct, filter] = (0, import_vuu_utils9.removeColumnFromFilter)(
|
|
864
1029
|
column,
|
|
865
1030
|
dataSourceFilter.filterStruct
|
|
866
1031
|
);
|
|
@@ -872,7 +1037,7 @@ var removeFilterColumn = (dataSourceFilter, column) => {
|
|
|
872
1037
|
return dataSourceFilter;
|
|
873
1038
|
}
|
|
874
1039
|
};
|
|
875
|
-
var { Average, Count, Distinct, High, Low, Sum } =
|
|
1040
|
+
var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils10.AggregationType;
|
|
876
1041
|
var useHandleTableContextMenu = ({
|
|
877
1042
|
dataSource,
|
|
878
1043
|
onPersistentColumnOperation
|
|
@@ -883,17 +1048,17 @@ var useHandleTableContextMenu = ({
|
|
|
883
1048
|
const { column } = gridOptions;
|
|
884
1049
|
switch (action.menuId) {
|
|
885
1050
|
case "sort-asc":
|
|
886
|
-
return dataSource.sort = (0,
|
|
1051
|
+
return dataSource.sort = (0, import_vuu_utils10.setSortColumn)(dataSource.sort, column, "A"), true;
|
|
887
1052
|
case "sort-dsc":
|
|
888
|
-
return dataSource.sort = (0,
|
|
1053
|
+
return dataSource.sort = (0, import_vuu_utils10.setSortColumn)(dataSource.sort, column, "D"), true;
|
|
889
1054
|
case "sort-add-asc":
|
|
890
|
-
return dataSource.sort = (0,
|
|
1055
|
+
return dataSource.sort = (0, import_vuu_utils10.addSortColumn)(dataSource.sort, column, "A"), true;
|
|
891
1056
|
case "sort-add-dsc":
|
|
892
|
-
return dataSource.sort = (0,
|
|
1057
|
+
return dataSource.sort = (0, import_vuu_utils10.addSortColumn)(dataSource.sort, column, "D"), true;
|
|
893
1058
|
case "group":
|
|
894
|
-
return dataSource.groupBy = (0,
|
|
1059
|
+
return dataSource.groupBy = (0, import_vuu_utils10.addGroupColumn)(dataSource.groupBy, column), true;
|
|
895
1060
|
case "group-add":
|
|
896
|
-
return dataSource.groupBy = (0,
|
|
1061
|
+
return dataSource.groupBy = (0, import_vuu_utils10.addGroupColumn)(dataSource.groupBy, column), true;
|
|
897
1062
|
case "column-hide":
|
|
898
1063
|
return onPersistentColumnOperation({ type: "hideColumns", columns: [column] }), true;
|
|
899
1064
|
case "column-remove":
|
|
@@ -903,17 +1068,17 @@ var useHandleTableContextMenu = ({
|
|
|
903
1068
|
case "remove-filters":
|
|
904
1069
|
return dataSource.filter = { filter: "" }, true;
|
|
905
1070
|
case "agg-avg":
|
|
906
|
-
return dataSource.aggregations = (0,
|
|
1071
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, Average), true;
|
|
907
1072
|
case "agg-high":
|
|
908
|
-
return dataSource.aggregations = (0,
|
|
1073
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, High), true;
|
|
909
1074
|
case "agg-low":
|
|
910
|
-
return dataSource.aggregations = (0,
|
|
1075
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, Low), true;
|
|
911
1076
|
case "agg-count":
|
|
912
|
-
return dataSource.aggregations = (0,
|
|
1077
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, Count), true;
|
|
913
1078
|
case "agg-distinct":
|
|
914
|
-
return dataSource.aggregations = (0,
|
|
1079
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, Distinct), true;
|
|
915
1080
|
case "agg-sum":
|
|
916
|
-
return dataSource.aggregations = (0,
|
|
1081
|
+
return dataSource.aggregations = (0, import_vuu_utils10.setAggregations)(dataSource.aggregations, column, Sum), true;
|
|
917
1082
|
case "column-pin-floating":
|
|
918
1083
|
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "floating" }), true;
|
|
919
1084
|
case "column-pin-left":
|
|
@@ -957,8 +1122,8 @@ var updateTableConfig = (config, action) => {
|
|
|
957
1122
|
};
|
|
958
1123
|
|
|
959
1124
|
// src/useCellEditing.ts
|
|
960
|
-
var
|
|
961
|
-
var
|
|
1125
|
+
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
1126
|
+
var import_react14 = require("react");
|
|
962
1127
|
|
|
963
1128
|
// src/table-dom-utils.ts
|
|
964
1129
|
var headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell:nth-child(${colIdx})`;
|
|
@@ -976,7 +1141,7 @@ var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
|
976
1141
|
return cell;
|
|
977
1142
|
}
|
|
978
1143
|
};
|
|
979
|
-
var cellIsEditable = (cell) => cell.classList.contains("vuuTableCell-editable");
|
|
1144
|
+
var cellIsEditable = (cell) => cell == null ? void 0 : cell.classList.contains("vuuTableCell-editable");
|
|
980
1145
|
var cellIsTextInput = (cell) => cell.querySelector(".vuuTableInputCell") !== null;
|
|
981
1146
|
function getRowIndex(rowEl) {
|
|
982
1147
|
if (rowEl) {
|
|
@@ -989,13 +1154,34 @@ function getRowIndex(rowEl) {
|
|
|
989
1154
|
}
|
|
990
1155
|
var closestRow = (el) => el.closest('[role="row"]');
|
|
991
1156
|
var closestRowIndex = (el) => getRowIndex(closestRow(el));
|
|
1157
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1158
|
+
var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1159
|
+
if (contentContainer) {
|
|
1160
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1161
|
+
const upperBoundary = viewport.top + totalHeaderHeight;
|
|
1162
|
+
const row = rowEl.getBoundingClientRect();
|
|
1163
|
+
if (row) {
|
|
1164
|
+
if (row.bottom > viewport.bottom) {
|
|
1165
|
+
return ["down", row.bottom - viewport.bottom];
|
|
1166
|
+
} else if (row.top < upperBoundary) {
|
|
1167
|
+
return ["up", row.top - upperBoundary];
|
|
1168
|
+
} else {
|
|
1169
|
+
return NO_SCROLL_NECESSARY;
|
|
1170
|
+
}
|
|
1171
|
+
} else {
|
|
1172
|
+
throw Error("Whats going on, row not found");
|
|
1173
|
+
}
|
|
1174
|
+
} else {
|
|
1175
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
992
1178
|
|
|
993
1179
|
// src/useCellEditing.ts
|
|
994
1180
|
var useCellEditing = ({ navigate }) => {
|
|
995
|
-
const commitHandler = (0,
|
|
1181
|
+
const commitHandler = (0, import_react14.useCallback)(() => {
|
|
996
1182
|
navigate();
|
|
997
1183
|
}, [navigate]);
|
|
998
|
-
const editInput = (0,
|
|
1184
|
+
const editInput = (0, import_react14.useCallback)(
|
|
999
1185
|
(evt) => {
|
|
1000
1186
|
const cellEl = evt.target;
|
|
1001
1187
|
const input = cellEl.matches("input") ? cellEl : cellEl.querySelector("input");
|
|
@@ -1006,7 +1192,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1006
1192
|
},
|
|
1007
1193
|
[]
|
|
1008
1194
|
);
|
|
1009
|
-
const focusInput = (0,
|
|
1195
|
+
const focusInput = (0, import_react14.useCallback)(
|
|
1010
1196
|
(evt) => {
|
|
1011
1197
|
const cellEl = evt.target;
|
|
1012
1198
|
const input = cellEl.querySelector("input");
|
|
@@ -1017,11 +1203,11 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1017
1203
|
},
|
|
1018
1204
|
[]
|
|
1019
1205
|
);
|
|
1020
|
-
const handleKeyDown = (0,
|
|
1206
|
+
const handleKeyDown = (0, import_react14.useCallback)(
|
|
1021
1207
|
(e) => {
|
|
1022
1208
|
const el = e.target;
|
|
1023
1209
|
if (cellIsTextInput(el)) {
|
|
1024
|
-
if ((0,
|
|
1210
|
+
if ((0, import_vuu_utils11.isCharacterKey)(e.key)) {
|
|
1025
1211
|
editInput(e);
|
|
1026
1212
|
} else if (e.key === "Enter") {
|
|
1027
1213
|
focusInput(e);
|
|
@@ -1030,7 +1216,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1030
1216
|
},
|
|
1031
1217
|
[editInput, focusInput]
|
|
1032
1218
|
);
|
|
1033
|
-
const handleDoubleClick = (0,
|
|
1219
|
+
const handleDoubleClick = (0, import_react14.useCallback)(
|
|
1034
1220
|
(e) => {
|
|
1035
1221
|
const el = e.target;
|
|
1036
1222
|
if (el.matches("input") || el.querySelector("input")) {
|
|
@@ -1040,14 +1226,14 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1040
1226
|
},
|
|
1041
1227
|
[editInput]
|
|
1042
1228
|
);
|
|
1043
|
-
const handleBlur = (0,
|
|
1229
|
+
const handleBlur = (0, import_react14.useCallback)(
|
|
1044
1230
|
(e) => {
|
|
1045
1231
|
const el = e.target;
|
|
1046
1232
|
el.removeEventListener("vuu-commit", commitHandler, true);
|
|
1047
1233
|
},
|
|
1048
1234
|
[commitHandler]
|
|
1049
1235
|
);
|
|
1050
|
-
const handleFocus = (0,
|
|
1236
|
+
const handleFocus = (0, import_react14.useCallback)(
|
|
1051
1237
|
(e) => {
|
|
1052
1238
|
const el = e.target;
|
|
1053
1239
|
el.addEventListener("vuu-commit", commitHandler, true);
|
|
@@ -1063,12 +1249,12 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1063
1249
|
};
|
|
1064
1250
|
|
|
1065
1251
|
// src/useDataSource.ts
|
|
1066
|
-
var
|
|
1067
|
-
var
|
|
1252
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1253
|
+
var import_react15 = require("react");
|
|
1068
1254
|
|
|
1069
1255
|
// src/moving-window.ts
|
|
1070
|
-
var
|
|
1071
|
-
var { SELECTED: SELECTED2 } =
|
|
1256
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
1257
|
+
var { SELECTED: SELECTED2 } = import_vuu_utils12.metadataKeys;
|
|
1072
1258
|
var MovingWindow = class {
|
|
1073
1259
|
constructor({ from, to }) {
|
|
1074
1260
|
this.rowCount = 0;
|
|
@@ -1078,7 +1264,7 @@ var MovingWindow = class {
|
|
|
1078
1264
|
}
|
|
1079
1265
|
this.rowCount = rowCount;
|
|
1080
1266
|
};
|
|
1081
|
-
this.range = new
|
|
1267
|
+
this.range = new import_vuu_utils12.WindowRange(from, to);
|
|
1082
1268
|
this.data = new Array(Math.max(0, to - from));
|
|
1083
1269
|
this.rowCount = 0;
|
|
1084
1270
|
}
|
|
@@ -1089,7 +1275,7 @@ var MovingWindow = class {
|
|
|
1089
1275
|
this.data[internalIndex] = data;
|
|
1090
1276
|
if (data[SELECTED2]) {
|
|
1091
1277
|
const previousRow = this.data[internalIndex - 1];
|
|
1092
|
-
if ((0,
|
|
1278
|
+
if ((0, import_vuu_utils12.isRowSelectedLast)(previousRow)) {
|
|
1093
1279
|
this.data[internalIndex - 1] = previousRow.slice();
|
|
1094
1280
|
this.data[internalIndex - 1][SELECTED2] -= 4;
|
|
1095
1281
|
}
|
|
@@ -1130,20 +1316,20 @@ var useDataSource = ({
|
|
|
1130
1316
|
onFeatureInvocation,
|
|
1131
1317
|
onSizeChange,
|
|
1132
1318
|
onSubscribed,
|
|
1133
|
-
range =
|
|
1319
|
+
range = import_vuu_utils13.NULL_RANGE,
|
|
1134
1320
|
renderBufferSize = 0
|
|
1135
1321
|
}) => {
|
|
1136
|
-
const [, forceUpdate] = (0,
|
|
1137
|
-
const data = (0,
|
|
1138
|
-
const isMounted = (0,
|
|
1139
|
-
const hasUpdated = (0,
|
|
1140
|
-
const rangeRef = (0,
|
|
1141
|
-
const dataWindow = (0,
|
|
1142
|
-
() => new MovingWindow((0,
|
|
1322
|
+
const [, forceUpdate] = (0, import_react15.useState)(null);
|
|
1323
|
+
const data = (0, import_react15.useRef)([]);
|
|
1324
|
+
const isMounted = (0, import_react15.useRef)(true);
|
|
1325
|
+
const hasUpdated = (0, import_react15.useRef)(false);
|
|
1326
|
+
const rangeRef = (0, import_react15.useRef)(range);
|
|
1327
|
+
const dataWindow = (0, import_react15.useMemo)(
|
|
1328
|
+
() => new MovingWindow((0, import_vuu_utils13.getFullRange)(range, renderBufferSize)),
|
|
1143
1329
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1144
1330
|
[]
|
|
1145
1331
|
);
|
|
1146
|
-
const setData = (0,
|
|
1332
|
+
const setData = (0, import_react15.useCallback)(
|
|
1147
1333
|
(updates) => {
|
|
1148
1334
|
for (const row of updates) {
|
|
1149
1335
|
dataWindow.add(row);
|
|
@@ -1157,7 +1343,7 @@ var useDataSource = ({
|
|
|
1157
1343
|
},
|
|
1158
1344
|
[dataWindow]
|
|
1159
1345
|
);
|
|
1160
|
-
const datasourceMessageHandler = (0,
|
|
1346
|
+
const datasourceMessageHandler = (0, import_react15.useCallback)(
|
|
1161
1347
|
(message) => {
|
|
1162
1348
|
if (message.type === "subscribed") {
|
|
1163
1349
|
onSubscribed == null ? void 0 : onSubscribed(message);
|
|
@@ -1180,10 +1366,10 @@ var useDataSource = ({
|
|
|
1180
1366
|
},
|
|
1181
1367
|
[dataWindow, onFeatureInvocation, onSizeChange, onSubscribed, setData]
|
|
1182
1368
|
);
|
|
1183
|
-
const getSelectedRows = (0,
|
|
1369
|
+
const getSelectedRows = (0, import_react15.useCallback)(() => {
|
|
1184
1370
|
return dataWindow.getSelectedRows();
|
|
1185
1371
|
}, [dataWindow]);
|
|
1186
|
-
(0,
|
|
1372
|
+
(0, import_react15.useEffect)(() => {
|
|
1187
1373
|
var _a;
|
|
1188
1374
|
isMounted.current = true;
|
|
1189
1375
|
(_a = dataSource.resume) == null ? void 0 : _a.call(dataSource);
|
|
@@ -1193,23 +1379,25 @@ var useDataSource = ({
|
|
|
1193
1379
|
(_a2 = dataSource.suspend) == null ? void 0 : _a2.call(dataSource);
|
|
1194
1380
|
};
|
|
1195
1381
|
}, [dataSource]);
|
|
1196
|
-
(0,
|
|
1382
|
+
(0, import_react15.useEffect)(() => {
|
|
1197
1383
|
var _a;
|
|
1198
1384
|
if (dataSource.status === "disabled") {
|
|
1199
1385
|
(_a = dataSource.enable) == null ? void 0 : _a.call(dataSource, datasourceMessageHandler);
|
|
1200
1386
|
} else {
|
|
1201
1387
|
dataSource == null ? void 0 : dataSource.subscribe(
|
|
1202
|
-
{ range: (0,
|
|
1388
|
+
{ range: (0, import_vuu_utils13.getFullRange)(range, renderBufferSize) },
|
|
1203
1389
|
datasourceMessageHandler
|
|
1204
1390
|
);
|
|
1205
1391
|
}
|
|
1206
1392
|
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
1207
|
-
const setRange = (0,
|
|
1393
|
+
const setRange = (0, import_react15.useCallback)(
|
|
1208
1394
|
(range2) => {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1395
|
+
if (!(0, import_vuu_utils13.rangesAreSame)(range2, rangeRef.current)) {
|
|
1396
|
+
const fullRange = (0, import_vuu_utils13.getFullRange)(range2, renderBufferSize);
|
|
1397
|
+
dataWindow.setRange(fullRange);
|
|
1398
|
+
dataSource.range = rangeRef.current = fullRange;
|
|
1399
|
+
dataSource.emit("range", range2);
|
|
1400
|
+
}
|
|
1213
1401
|
},
|
|
1214
1402
|
[dataSource, dataWindow, renderBufferSize]
|
|
1215
1403
|
);
|
|
@@ -1223,16 +1411,16 @@ var useDataSource = ({
|
|
|
1223
1411
|
};
|
|
1224
1412
|
|
|
1225
1413
|
// src/useInitialValue.ts
|
|
1226
|
-
var
|
|
1414
|
+
var import_react16 = require("react");
|
|
1227
1415
|
var useInitialValue = (value) => {
|
|
1228
|
-
const ref = (0,
|
|
1229
|
-
return (0,
|
|
1416
|
+
const ref = (0, import_react16.useRef)(value);
|
|
1417
|
+
return (0, import_react16.useMemo)(() => ref.current, []);
|
|
1230
1418
|
};
|
|
1231
1419
|
|
|
1232
1420
|
// src/useKeyboardNavigation.ts
|
|
1233
|
-
var
|
|
1421
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
1234
1422
|
var import_core = require("@salt-ds/core");
|
|
1235
|
-
var
|
|
1423
|
+
var import_react17 = require("react");
|
|
1236
1424
|
var rowNavigationKeys = /* @__PURE__ */ new Set([
|
|
1237
1425
|
"Home",
|
|
1238
1426
|
"End",
|
|
@@ -1301,17 +1489,17 @@ var useKeyboardNavigation = ({
|
|
|
1301
1489
|
viewportRowCount
|
|
1302
1490
|
}) => {
|
|
1303
1491
|
var _a;
|
|
1304
|
-
const focusedCellPos = (0,
|
|
1305
|
-
const focusableCell = (0,
|
|
1306
|
-
const activeCellPos = (0,
|
|
1307
|
-
const highlightedIndexRef = (0,
|
|
1492
|
+
const focusedCellPos = (0, import_react17.useRef)([-1, -1]);
|
|
1493
|
+
const focusableCell = (0, import_react17.useRef)();
|
|
1494
|
+
const activeCellPos = (0, import_react17.useRef)([-1, 0]);
|
|
1495
|
+
const highlightedIndexRef = (0, import_react17.useRef)();
|
|
1308
1496
|
const [highlightedIndex, setHighlightedIdx] = (0, import_core.useControlled)({
|
|
1309
1497
|
controlled: highlightedIndexProp,
|
|
1310
1498
|
default: defaultHighlightedIndex,
|
|
1311
1499
|
name: "UseKeyboardNavigation"
|
|
1312
1500
|
});
|
|
1313
1501
|
highlightedIndexRef.current = highlightedIndex;
|
|
1314
|
-
const setHighlightedIndex = (0,
|
|
1502
|
+
const setHighlightedIndex = (0, import_react17.useCallback)(
|
|
1315
1503
|
(idx, fromKeyboard = false) => {
|
|
1316
1504
|
onHighlight == null ? void 0 : onHighlight(idx);
|
|
1317
1505
|
setHighlightedIdx(idx);
|
|
@@ -1331,14 +1519,14 @@ var useKeyboardNavigation = ({
|
|
|
1331
1519
|
} else {
|
|
1332
1520
|
const focusedRow = tableCell.closest("[role='row']");
|
|
1333
1521
|
if (focusedRow) {
|
|
1334
|
-
const rowIdx = (0,
|
|
1522
|
+
const rowIdx = (0, import_vuu_utils14.getIndexFromRowElement)(focusedRow);
|
|
1335
1523
|
const colIdx = Array.from(focusedRow.childNodes).indexOf(tableCell);
|
|
1336
1524
|
return [rowIdx, colIdx];
|
|
1337
1525
|
}
|
|
1338
1526
|
}
|
|
1339
1527
|
return NULL_CELL_POS;
|
|
1340
1528
|
};
|
|
1341
|
-
const focusCell = (0,
|
|
1529
|
+
const focusCell = (0, import_react17.useCallback)(
|
|
1342
1530
|
(cellPos) => {
|
|
1343
1531
|
var _a2;
|
|
1344
1532
|
if (containerRef.current) {
|
|
@@ -1349,7 +1537,6 @@ var useKeyboardNavigation = ({
|
|
|
1349
1537
|
focusableCell.current = activeCell;
|
|
1350
1538
|
activeCell.setAttribute("tabindex", "0");
|
|
1351
1539
|
}
|
|
1352
|
-
console.log(`scroll row ${cellPos[0]}`);
|
|
1353
1540
|
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex: cellPos[0] });
|
|
1354
1541
|
activeCell.focus({ preventScroll: true });
|
|
1355
1542
|
}
|
|
@@ -1359,7 +1546,7 @@ var useKeyboardNavigation = ({
|
|
|
1359
1546
|
// be often whilst scrolling - store range in a a ref ?
|
|
1360
1547
|
[containerRef, requestScroll]
|
|
1361
1548
|
);
|
|
1362
|
-
const setActiveCell = (0,
|
|
1549
|
+
const setActiveCell = (0, import_react17.useCallback)(
|
|
1363
1550
|
(rowIdx, colIdx, fromKeyboard = false) => {
|
|
1364
1551
|
const pos = [rowIdx, colIdx];
|
|
1365
1552
|
activeCellPos.current = pos;
|
|
@@ -1374,34 +1561,46 @@ var useKeyboardNavigation = ({
|
|
|
1374
1561
|
},
|
|
1375
1562
|
[focusCell, navigationStyle, setHighlightedIdx]
|
|
1376
1563
|
);
|
|
1377
|
-
const nextPageItemIdx = (0,
|
|
1564
|
+
const nextPageItemIdx = (0, import_react17.useCallback)(
|
|
1378
1565
|
(key, [rowIdx, colIdx]) => new Promise((resolve) => {
|
|
1379
1566
|
let newRowIdx = rowIdx;
|
|
1380
1567
|
switch (key) {
|
|
1381
|
-
case "PageDown":
|
|
1568
|
+
case "PageDown": {
|
|
1382
1569
|
newRowIdx = Math.min(rowCount - 1, rowIdx + viewportRowCount);
|
|
1383
|
-
|
|
1570
|
+
if (newRowIdx !== rowIdx) {
|
|
1571
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "down" });
|
|
1572
|
+
}
|
|
1384
1573
|
break;
|
|
1385
|
-
|
|
1574
|
+
}
|
|
1575
|
+
case "PageUp": {
|
|
1386
1576
|
newRowIdx = Math.max(0, rowIdx - viewportRowCount);
|
|
1387
|
-
|
|
1577
|
+
if (newRowIdx !== rowIdx) {
|
|
1578
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "up" });
|
|
1579
|
+
}
|
|
1388
1580
|
break;
|
|
1389
|
-
|
|
1581
|
+
}
|
|
1582
|
+
case "Home": {
|
|
1390
1583
|
newRowIdx = 0;
|
|
1391
|
-
|
|
1584
|
+
if (newRowIdx !== rowIdx) {
|
|
1585
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "home" });
|
|
1586
|
+
}
|
|
1392
1587
|
break;
|
|
1393
|
-
|
|
1588
|
+
}
|
|
1589
|
+
case "End": {
|
|
1394
1590
|
newRowIdx = rowCount - 1;
|
|
1395
|
-
|
|
1591
|
+
if (newRowIdx !== rowIdx) {
|
|
1592
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "end" });
|
|
1593
|
+
}
|
|
1396
1594
|
break;
|
|
1595
|
+
}
|
|
1397
1596
|
}
|
|
1398
1597
|
setTimeout(() => {
|
|
1399
1598
|
resolve([newRowIdx, colIdx]);
|
|
1400
|
-
},
|
|
1599
|
+
}, 35);
|
|
1401
1600
|
}),
|
|
1402
1601
|
[requestScroll, rowCount, viewportRowCount]
|
|
1403
1602
|
);
|
|
1404
|
-
const handleFocus = (0,
|
|
1603
|
+
const handleFocus = (0, import_react17.useCallback)(() => {
|
|
1405
1604
|
var _a2;
|
|
1406
1605
|
if (disableHighlightOnFocus !== true) {
|
|
1407
1606
|
if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
|
|
@@ -1420,7 +1619,7 @@ var useKeyboardNavigation = ({
|
|
|
1420
1619
|
navigationStyle,
|
|
1421
1620
|
setHighlightedIdx
|
|
1422
1621
|
]);
|
|
1423
|
-
const navigateChildItems = (0,
|
|
1622
|
+
const navigateChildItems = (0, import_react17.useCallback)(
|
|
1424
1623
|
async (key) => {
|
|
1425
1624
|
const [nextRowIdx, nextColIdx] = isPagingKey(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
|
|
1426
1625
|
const [rowIdx, colIdx] = activeCellPos.current;
|
|
@@ -1430,13 +1629,13 @@ var useKeyboardNavigation = ({
|
|
|
1430
1629
|
},
|
|
1431
1630
|
[columnCount, nextPageItemIdx, rowCount, setActiveCell]
|
|
1432
1631
|
);
|
|
1433
|
-
const scrollRowIntoViewIfNecessary = (0,
|
|
1632
|
+
const scrollRowIntoViewIfNecessary = (0, import_react17.useCallback)(
|
|
1434
1633
|
(rowIndex) => {
|
|
1435
1634
|
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex });
|
|
1436
1635
|
},
|
|
1437
1636
|
[requestScroll]
|
|
1438
1637
|
);
|
|
1439
|
-
const moveHighlightedRow = (0,
|
|
1638
|
+
const moveHighlightedRow = (0, import_react17.useCallback)(
|
|
1440
1639
|
async (key) => {
|
|
1441
1640
|
const { current: highlighted } = highlightedIndexRef;
|
|
1442
1641
|
const [nextRowIdx] = isPagingKey(key) ? await nextPageItemIdx(key, [highlighted != null ? highlighted : -1, 0]) : nextCellPos(key, [highlighted != null ? highlighted : -1, 0], columnCount, rowCount);
|
|
@@ -1453,12 +1652,12 @@ var useKeyboardNavigation = ({
|
|
|
1453
1652
|
setHighlightedIndex
|
|
1454
1653
|
]
|
|
1455
1654
|
);
|
|
1456
|
-
(0,
|
|
1655
|
+
(0, import_react17.useEffect)(() => {
|
|
1457
1656
|
if (highlightedIndexProp !== void 0 && highlightedIndexProp !== -1) {
|
|
1458
1657
|
scrollRowIntoViewIfNecessary(highlightedIndexProp);
|
|
1459
1658
|
}
|
|
1460
1659
|
}, [highlightedIndexProp, scrollRowIntoViewIfNecessary]);
|
|
1461
|
-
const handleKeyDown = (0,
|
|
1660
|
+
const handleKeyDown = (0, import_react17.useCallback)(
|
|
1462
1661
|
(e) => {
|
|
1463
1662
|
if (rowCount > 0 && isNavigationKey(e.key, navigationStyle)) {
|
|
1464
1663
|
e.preventDefault();
|
|
@@ -1472,7 +1671,7 @@ var useKeyboardNavigation = ({
|
|
|
1472
1671
|
},
|
|
1473
1672
|
[rowCount, navigationStyle, moveHighlightedRow, navigateChildItems]
|
|
1474
1673
|
);
|
|
1475
|
-
const handleClick = (0,
|
|
1674
|
+
const handleClick = (0, import_react17.useCallback)(
|
|
1476
1675
|
// Might not be a cell e.g the Settings button
|
|
1477
1676
|
(evt) => {
|
|
1478
1677
|
const target = evt.target;
|
|
@@ -1484,10 +1683,10 @@ var useKeyboardNavigation = ({
|
|
|
1484
1683
|
},
|
|
1485
1684
|
[setActiveCell]
|
|
1486
1685
|
);
|
|
1487
|
-
const handleMouseLeave = (0,
|
|
1686
|
+
const handleMouseLeave = (0, import_react17.useCallback)(() => {
|
|
1488
1687
|
setHighlightedIndex(-1);
|
|
1489
1688
|
}, [setHighlightedIndex]);
|
|
1490
|
-
const handleMouseMove = (0,
|
|
1689
|
+
const handleMouseMove = (0, import_react17.useCallback)(
|
|
1491
1690
|
(evt) => {
|
|
1492
1691
|
const idx = closestRowIndex(evt.target);
|
|
1493
1692
|
if (idx !== -1 && idx !== highlightedIndexRef.current) {
|
|
@@ -1496,11 +1695,11 @@ var useKeyboardNavigation = ({
|
|
|
1496
1695
|
},
|
|
1497
1696
|
[setHighlightedIndex]
|
|
1498
1697
|
);
|
|
1499
|
-
const navigate = (0,
|
|
1698
|
+
const navigate = (0, import_react17.useCallback)(() => {
|
|
1500
1699
|
navigateChildItems("ArrowDown");
|
|
1501
1700
|
}, [navigateChildItems]);
|
|
1502
1701
|
const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
|
|
1503
|
-
(0,
|
|
1702
|
+
(0, import_react17.useEffect)(() => {
|
|
1504
1703
|
if (fullyRendered && focusableCell.current === void 0 && !disableFocus) {
|
|
1505
1704
|
const { current: container } = containerRef;
|
|
1506
1705
|
const cell = (container == null ? void 0 : container.querySelector(headerCellQuery(0))) || (container == null ? void 0 : container.querySelector(dataCellQuery(0, 0)));
|
|
@@ -1522,9 +1721,9 @@ var useKeyboardNavigation = ({
|
|
|
1522
1721
|
};
|
|
1523
1722
|
|
|
1524
1723
|
// src/useSelection.ts
|
|
1525
|
-
var
|
|
1526
|
-
var
|
|
1527
|
-
var { IDX: IDX2 } =
|
|
1724
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
1725
|
+
var import_react18 = require("react");
|
|
1726
|
+
var { IDX: IDX2 } = import_vuu_utils15.metadataKeys;
|
|
1528
1727
|
var NO_SELECTION = [];
|
|
1529
1728
|
var defaultSelectionKeys = ["Enter", " "];
|
|
1530
1729
|
var useSelection = ({
|
|
@@ -1535,18 +1734,18 @@ var useSelection = ({
|
|
|
1535
1734
|
onSelectionChange
|
|
1536
1735
|
}) => {
|
|
1537
1736
|
selectionModel === "extended" || selectionModel === "checkbox";
|
|
1538
|
-
const lastActiveRef = (0,
|
|
1539
|
-
const selectedRef = (0,
|
|
1540
|
-
const isSelectionEvent = (0,
|
|
1737
|
+
const lastActiveRef = (0, import_react18.useRef)(-1);
|
|
1738
|
+
const selectedRef = (0, import_react18.useRef)(NO_SELECTION);
|
|
1739
|
+
const isSelectionEvent = (0, import_react18.useCallback)(
|
|
1541
1740
|
(evt) => selectionKeys.includes(evt.key),
|
|
1542
1741
|
[selectionKeys]
|
|
1543
1742
|
);
|
|
1544
|
-
const handleRowClick = (0,
|
|
1743
|
+
const handleRowClick = (0, import_react18.useCallback)(
|
|
1545
1744
|
(row, rangeSelect, keepExistingSelection) => {
|
|
1546
1745
|
const { [IDX2]: idx } = row;
|
|
1547
1746
|
const { current: active } = lastActiveRef;
|
|
1548
1747
|
const { current: selected } = selectedRef;
|
|
1549
|
-
const selectOperation = (0,
|
|
1748
|
+
const selectOperation = (0, import_vuu_utils15.isRowSelected)(row) ? import_vuu_utils15.deselectItem : import_vuu_utils15.selectItem;
|
|
1550
1749
|
const newSelected = selectOperation(
|
|
1551
1750
|
selectionModel,
|
|
1552
1751
|
selected,
|
|
@@ -1562,7 +1761,7 @@ var useSelection = ({
|
|
|
1562
1761
|
},
|
|
1563
1762
|
[onSelect, onSelectionChange, selectionModel]
|
|
1564
1763
|
);
|
|
1565
|
-
const handleKeyDown = (0,
|
|
1764
|
+
const handleKeyDown = (0, import_react18.useCallback)(
|
|
1566
1765
|
(e) => {
|
|
1567
1766
|
if (isSelectionEvent(e)) {
|
|
1568
1767
|
const { current: rowIndex } = highlightedIndexRef;
|
|
@@ -1571,7 +1770,7 @@ var useSelection = ({
|
|
|
1571
1770
|
`[aria-rowindex="${rowIndex}"]`
|
|
1572
1771
|
);
|
|
1573
1772
|
if (rowEl) {
|
|
1574
|
-
(0,
|
|
1773
|
+
(0, import_vuu_utils15.dispatchMouseEvent)(rowEl, "click");
|
|
1575
1774
|
}
|
|
1576
1775
|
}
|
|
1577
1776
|
}
|
|
@@ -1586,8 +1785,8 @@ var useSelection = ({
|
|
|
1586
1785
|
|
|
1587
1786
|
// src/useTableContextMenu.ts
|
|
1588
1787
|
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
1589
|
-
var
|
|
1590
|
-
var
|
|
1788
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
1789
|
+
var import_react19 = require("react");
|
|
1591
1790
|
var NO_ROWS = [];
|
|
1592
1791
|
var useTableContextMenu = ({
|
|
1593
1792
|
columns,
|
|
@@ -1596,15 +1795,15 @@ var useTableContextMenu = ({
|
|
|
1596
1795
|
getSelectedRows
|
|
1597
1796
|
}) => {
|
|
1598
1797
|
const [showContextMenu] = (0, import_vuu_popups2.useContextMenu)();
|
|
1599
|
-
const onContextMenu = (0,
|
|
1798
|
+
const onContextMenu = (0, import_react19.useCallback)(
|
|
1600
1799
|
(evt) => {
|
|
1601
1800
|
const target = evt.target;
|
|
1602
1801
|
const cellEl = target == null ? void 0 : target.closest("div[role='cell']");
|
|
1603
1802
|
const rowEl = target == null ? void 0 : target.closest("div[role='row']");
|
|
1604
1803
|
if (cellEl && rowEl) {
|
|
1605
1804
|
const { selectedRowsCount } = dataSource;
|
|
1606
|
-
const columnMap = (0,
|
|
1607
|
-
const rowIndex = (0,
|
|
1805
|
+
const columnMap = (0, import_vuu_utils16.buildColumnMap)(columns);
|
|
1806
|
+
const rowIndex = (0, import_vuu_utils16.getIndexFromRowElement)(rowEl);
|
|
1608
1807
|
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
1609
1808
|
const row = data.find(([idx]) => idx === rowIndex);
|
|
1610
1809
|
const columnName = columns[cellIndex];
|
|
@@ -1623,12 +1822,11 @@ var useTableContextMenu = ({
|
|
|
1623
1822
|
};
|
|
1624
1823
|
|
|
1625
1824
|
// src/useTableModel.ts
|
|
1626
|
-
var
|
|
1627
|
-
var
|
|
1628
|
-
var
|
|
1629
|
-
var { info } = (0,
|
|
1825
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
1826
|
+
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
1827
|
+
var import_react20 = require("react");
|
|
1828
|
+
var { info } = (0, import_vuu_utils17.logger)("useTableModel");
|
|
1630
1829
|
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1631
|
-
var KEY_OFFSET = import_vuu_utils15.metadataKeys.count;
|
|
1632
1830
|
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
1633
1831
|
var getDataType = (column, tableSchema) => {
|
|
1634
1832
|
const schemaColumn = tableSchema == null ? void 0 : tableSchema.columns.find(
|
|
@@ -1671,7 +1869,7 @@ var columnReducer = (state, action) => {
|
|
|
1671
1869
|
}
|
|
1672
1870
|
};
|
|
1673
1871
|
var useTableModel = (tableConfigProp, dataSource) => {
|
|
1674
|
-
const [state, dispatchColumnAction] = (0,
|
|
1872
|
+
const [state, dispatchColumnAction] = (0, import_react20.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
|
|
1675
1873
|
const { columns, headings, tableConfig, ...tableAttributes } = state;
|
|
1676
1874
|
return {
|
|
1677
1875
|
columns,
|
|
@@ -1684,13 +1882,13 @@ var useTableModel = (tableConfigProp, dataSource) => {
|
|
|
1684
1882
|
function init({ dataSource, tableConfig }) {
|
|
1685
1883
|
const { columns, ...tableAttributes } = tableConfig;
|
|
1686
1884
|
const { config: dataSourceConfig, tableSchema } = dataSource;
|
|
1687
|
-
const runtimeColumns = columns.filter((0,
|
|
1885
|
+
const runtimeColumns = columns.filter((0, import_vuu_utils17.subscribedOnly)(dataSourceConfig == null ? void 0 : dataSourceConfig.columns)).map(
|
|
1688
1886
|
columnDescriptorToRuntimeColumDescriptor(tableAttributes, tableSchema)
|
|
1689
1887
|
);
|
|
1690
|
-
const maybePinnedColumns = runtimeColumns.some(
|
|
1888
|
+
const maybePinnedColumns = runtimeColumns.some(import_vuu_utils17.isPinned) ? (0, import_vuu_utils17.sortPinnedColumns)(runtimeColumns) : runtimeColumns;
|
|
1691
1889
|
let state = {
|
|
1692
1890
|
columns: maybePinnedColumns,
|
|
1693
|
-
headings: (0,
|
|
1891
|
+
headings: (0, import_vuu_utils17.getTableHeadings)(maybePinnedColumns),
|
|
1694
1892
|
tableConfig,
|
|
1695
1893
|
...tableAttributes
|
|
1696
1894
|
};
|
|
@@ -1716,33 +1914,29 @@ var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) =>
|
|
|
1716
1914
|
const serverDataType = getDataType(column, tableSchema);
|
|
1717
1915
|
const {
|
|
1718
1916
|
align = getDefaultAlignment(serverDataType),
|
|
1719
|
-
key,
|
|
1720
1917
|
name,
|
|
1721
|
-
label = (0,
|
|
1918
|
+
label = (0, import_vuu_utils17.getColumnLabel)(column),
|
|
1722
1919
|
width = columnDefaultWidth,
|
|
1723
1920
|
...rest
|
|
1724
1921
|
} = column;
|
|
1725
1922
|
const runtimeColumnWithDefaults = {
|
|
1726
1923
|
...rest,
|
|
1727
1924
|
align,
|
|
1728
|
-
CellRenderer: (0,
|
|
1729
|
-
HeaderCellContentRenderer: (0,
|
|
1730
|
-
HeaderCellLabelRenderer: (0,
|
|
1731
|
-
clientSideEditValidationCheck: (0,
|
|
1925
|
+
CellRenderer: (0, import_vuu_utils17.getCellRenderer)(column),
|
|
1926
|
+
HeaderCellContentRenderer: (0, import_vuu_utils17.getColumnHeaderContentRenderer)(column),
|
|
1927
|
+
HeaderCellLabelRenderer: (0, import_vuu_utils17.getColumnHeaderLabelRenderer)(column),
|
|
1928
|
+
clientSideEditValidationCheck: (0, import_vuu_utils17.hasValidationRules)(column.type) ? (0, import_vuu_ui_controls3.buildValidationChecker)(column.type.renderer.rules) : void 0,
|
|
1929
|
+
index: index + 1,
|
|
1732
1930
|
label: getLabel(label, columnFormatHeader),
|
|
1733
|
-
key: key != null ? key : index + KEY_OFFSET,
|
|
1734
1931
|
name,
|
|
1735
1932
|
originalIdx: index,
|
|
1736
1933
|
serverDataType,
|
|
1737
|
-
valueFormatter: (0,
|
|
1934
|
+
valueFormatter: (0, import_vuu_utils17.getValueFormatter)(column, serverDataType),
|
|
1738
1935
|
width
|
|
1739
1936
|
};
|
|
1740
|
-
if ((0,
|
|
1937
|
+
if ((0, import_vuu_utils17.isGroupColumn)(runtimeColumnWithDefaults)) {
|
|
1741
1938
|
runtimeColumnWithDefaults.columns = runtimeColumnWithDefaults.columns.map(
|
|
1742
|
-
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(
|
|
1743
|
-
col,
|
|
1744
|
-
col.key
|
|
1745
|
-
)
|
|
1939
|
+
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(col, index)
|
|
1746
1940
|
);
|
|
1747
1941
|
}
|
|
1748
1942
|
return runtimeColumnWithDefaults;
|
|
@@ -1834,8 +2028,8 @@ function pinColumn2(state, action) {
|
|
|
1834
2028
|
const { column, pin } = action;
|
|
1835
2029
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1836
2030
|
if (targetColumn) {
|
|
1837
|
-
columns = (0,
|
|
1838
|
-
columns = (0,
|
|
2031
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, pin });
|
|
2032
|
+
columns = (0, import_vuu_utils17.sortPinnedColumns)(columns);
|
|
1839
2033
|
return {
|
|
1840
2034
|
...state,
|
|
1841
2035
|
columns
|
|
@@ -1850,26 +2044,26 @@ function updateColumnProp(state, action) {
|
|
|
1850
2044
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1851
2045
|
if (targetColumn) {
|
|
1852
2046
|
if (align === "left" || align === "right") {
|
|
1853
|
-
columns = (0,
|
|
2047
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, align });
|
|
1854
2048
|
}
|
|
1855
2049
|
if (typeof label === "string") {
|
|
1856
|
-
columns = (0,
|
|
2050
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, label });
|
|
1857
2051
|
}
|
|
1858
2052
|
if (typeof resizing === "boolean") {
|
|
1859
|
-
columns = (0,
|
|
2053
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, resizing });
|
|
1860
2054
|
}
|
|
1861
2055
|
if (typeof hidden === "boolean") {
|
|
1862
|
-
columns = (0,
|
|
2056
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, hidden });
|
|
1863
2057
|
}
|
|
1864
2058
|
if (typeof width === "number") {
|
|
1865
|
-
columns = (0,
|
|
2059
|
+
columns = (0, import_vuu_utils17.replaceColumn)(columns, { ...targetColumn, width });
|
|
1866
2060
|
const targetConfigColumn = tableConfig.columns.find(
|
|
1867
2061
|
(col) => col.name === column.name
|
|
1868
2062
|
);
|
|
1869
2063
|
if (targetConfigColumn) {
|
|
1870
2064
|
tableConfig = {
|
|
1871
2065
|
...tableConfig,
|
|
1872
|
-
columns: (0,
|
|
2066
|
+
columns: (0, import_vuu_utils17.replaceColumn)(tableConfig.columns, {
|
|
1873
2067
|
...targetConfigColumn,
|
|
1874
2068
|
width
|
|
1875
2069
|
})
|
|
@@ -1891,70 +2085,84 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
1891
2085
|
if (hasGroupBy) {
|
|
1892
2086
|
result = {
|
|
1893
2087
|
...state,
|
|
1894
|
-
columns: (0,
|
|
2088
|
+
columns: (0, import_vuu_utils17.applyGroupByToColumns)(result.columns, groupBy, confirmed)
|
|
1895
2089
|
};
|
|
1896
2090
|
}
|
|
1897
2091
|
if (hasSort) {
|
|
1898
2092
|
result = {
|
|
1899
2093
|
...state,
|
|
1900
|
-
columns: (0,
|
|
2094
|
+
columns: (0, import_vuu_utils17.applySortToColumns)(result.columns, sort)
|
|
1901
2095
|
};
|
|
1902
2096
|
}
|
|
1903
2097
|
if (hasFilter) {
|
|
1904
2098
|
result = {
|
|
1905
2099
|
...state,
|
|
1906
|
-
columns: (0,
|
|
2100
|
+
columns: (0, import_vuu_utils17.applyFilterToColumns)(result.columns, filter)
|
|
1907
2101
|
};
|
|
1908
|
-
} else if (result.columns.some(
|
|
2102
|
+
} else if (result.columns.some(import_vuu_utils17.isFilteredColumn)) {
|
|
1909
2103
|
result = {
|
|
1910
2104
|
...state,
|
|
1911
|
-
columns: (0,
|
|
2105
|
+
columns: (0, import_vuu_utils17.stripFilterFromColumns)(result.columns)
|
|
1912
2106
|
};
|
|
1913
2107
|
}
|
|
1914
2108
|
return result;
|
|
1915
2109
|
}
|
|
1916
2110
|
|
|
1917
2111
|
// src/useTableScroll.ts
|
|
1918
|
-
var
|
|
1919
|
-
var
|
|
1920
|
-
var
|
|
1921
|
-
|
|
2112
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2113
|
+
var import_react21 = require("react");
|
|
2114
|
+
var SCROLL_MOVE_CHECK_THRESHOLD = 100;
|
|
2115
|
+
var HORIZONTAL_SCROLL_BUFFER = 200;
|
|
2116
|
+
var getMaxScroll = (container) => {
|
|
1922
2117
|
const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
|
|
2118
|
+
return [scrollWidth - clientWidth, scrollHeight - clientHeight];
|
|
2119
|
+
};
|
|
2120
|
+
var getScrollDirection = (prevScrollPositions, scrollPos) => {
|
|
2121
|
+
if (prevScrollPositions === void 0) {
|
|
2122
|
+
return void 0;
|
|
2123
|
+
} else {
|
|
2124
|
+
const { scrollTop: prevTop } = prevScrollPositions;
|
|
2125
|
+
return scrollPos > prevTop ? "fwd" : "bwd";
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
var getPctScroll = (container, currentScrollPos) => {
|
|
2129
|
+
const {
|
|
2130
|
+
clientHeight,
|
|
2131
|
+
clientWidth,
|
|
2132
|
+
scrollHeight,
|
|
2133
|
+
scrollLeft,
|
|
2134
|
+
scrollTop,
|
|
2135
|
+
scrollWidth
|
|
2136
|
+
} = container;
|
|
2137
|
+
const maxScrollLeft = scrollWidth - clientWidth;
|
|
1923
2138
|
const pctScrollLeft = scrollLeft / (scrollWidth - clientWidth);
|
|
1924
|
-
const
|
|
1925
|
-
|
|
2139
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
2140
|
+
let pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
2141
|
+
const scrollDirection = getScrollDirection(currentScrollPos, scrollTop);
|
|
2142
|
+
if (scrollDirection === "fwd" && pctScrollTop > 0.99) {
|
|
2143
|
+
pctScrollTop = 1;
|
|
2144
|
+
} else if (scrollDirection === "bwd" && pctScrollTop < 0.02) {
|
|
2145
|
+
pctScrollTop = 0;
|
|
2146
|
+
}
|
|
2147
|
+
return [
|
|
2148
|
+
scrollLeft,
|
|
2149
|
+
pctScrollLeft,
|
|
2150
|
+
maxScrollLeft,
|
|
2151
|
+
scrollTop,
|
|
2152
|
+
pctScrollTop,
|
|
2153
|
+
maxScrollTop
|
|
2154
|
+
];
|
|
1926
2155
|
};
|
|
1927
2156
|
var noScrolling = {
|
|
1928
2157
|
scrollToIndex: () => void 0,
|
|
1929
2158
|
scrollToKey: () => void 0
|
|
1930
2159
|
};
|
|
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
|
-
};
|
|
1952
2160
|
var useCallbackRef = ({
|
|
1953
2161
|
onAttach,
|
|
1954
2162
|
onDetach
|
|
1955
2163
|
}) => {
|
|
1956
|
-
const ref = (0,
|
|
1957
|
-
const callbackRef = (0,
|
|
2164
|
+
const ref = (0, import_react21.useRef)(null);
|
|
2165
|
+
const callbackRef = (0, import_react21.useCallback)(
|
|
1958
2166
|
(el) => {
|
|
1959
2167
|
if (el) {
|
|
1960
2168
|
ref.current = el;
|
|
@@ -1970,75 +2178,142 @@ var useCallbackRef = ({
|
|
|
1970
2178
|
return callbackRef;
|
|
1971
2179
|
};
|
|
1972
2180
|
var useTableScroll = ({
|
|
2181
|
+
columns,
|
|
1973
2182
|
getRowAtPosition,
|
|
1974
2183
|
onHorizontalScroll,
|
|
1975
2184
|
onVerticalScroll,
|
|
2185
|
+
onVerticalScrollInSitu,
|
|
1976
2186
|
scrollingApiRef,
|
|
1977
2187
|
setRange,
|
|
1978
2188
|
viewportMeasurements
|
|
1979
2189
|
}) => {
|
|
1980
|
-
const firstRowRef = (0,
|
|
1981
|
-
const contentContainerScrolledRef = (0,
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
2190
|
+
const firstRowRef = (0, import_react21.useRef)(0);
|
|
2191
|
+
const contentContainerScrolledRef = (0, import_react21.useRef)(false);
|
|
2192
|
+
const contentContainerPosRef = (0, import_react21.useRef)({
|
|
2193
|
+
scrollTop: 0,
|
|
2194
|
+
scrollLeft: 0
|
|
2195
|
+
});
|
|
2196
|
+
const scrollbarContainerScrolledRef = (0, import_react21.useRef)(false);
|
|
2197
|
+
const scrollbarContainerPosRef = (0, import_react21.useRef)({
|
|
2198
|
+
scrollTop: 0,
|
|
2199
|
+
scrollLeft: 0
|
|
2200
|
+
});
|
|
2201
|
+
const scrollbarContainerRef = (0, import_react21.useRef)(null);
|
|
2202
|
+
const contentContainerRef = (0, import_react21.useRef)(null);
|
|
2203
|
+
const lastHorizontalScrollCheckPoint = (0, import_react21.useRef)(0);
|
|
1985
2204
|
const {
|
|
1986
2205
|
appliedPageSize,
|
|
1987
2206
|
isVirtualScroll,
|
|
1988
|
-
maxScrollContainerScrollHorizontal: maxScrollLeft,
|
|
1989
|
-
maxScrollContainerScrollVertical: maxScrollTop,
|
|
1990
2207
|
rowCount: viewportRowCount,
|
|
1991
|
-
totalHeaderHeight
|
|
2208
|
+
totalHeaderHeight,
|
|
2209
|
+
viewportWidth
|
|
1992
2210
|
} = viewportMeasurements;
|
|
1993
|
-
const
|
|
2211
|
+
const columnsWithinViewportRef = (0, import_react21.useRef)([]);
|
|
2212
|
+
const [, forceRefresh] = (0, import_react21.useState)({});
|
|
2213
|
+
const preSpanRef = (0, import_react21.useRef)(0);
|
|
2214
|
+
(0, import_react21.useMemo)(() => {
|
|
2215
|
+
const [visibleColumns, offset] = (0, import_vuu_utils18.getColumnsInViewport)(
|
|
2216
|
+
columns,
|
|
2217
|
+
contentContainerPosRef.current.scrollLeft,
|
|
2218
|
+
contentContainerPosRef.current.scrollLeft + viewportWidth + HORIZONTAL_SCROLL_BUFFER
|
|
2219
|
+
);
|
|
2220
|
+
preSpanRef.current = offset;
|
|
2221
|
+
columnsWithinViewportRef.current = visibleColumns;
|
|
2222
|
+
}, [viewportWidth, columns]);
|
|
2223
|
+
const handleHorizontalScroll = (0, import_react21.useCallback)(
|
|
2224
|
+
(scrollLeft) => {
|
|
2225
|
+
contentContainerPosRef.current.scrollLeft = scrollLeft;
|
|
2226
|
+
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2227
|
+
if (Math.abs(scrollLeft - lastHorizontalScrollCheckPoint.current) > SCROLL_MOVE_CHECK_THRESHOLD) {
|
|
2228
|
+
lastHorizontalScrollCheckPoint.current = scrollLeft;
|
|
2229
|
+
const [visibleColumns, pre] = (0, import_vuu_utils18.getColumnsInViewport)(
|
|
2230
|
+
columns,
|
|
2231
|
+
scrollLeft,
|
|
2232
|
+
scrollLeft + viewportWidth + HORIZONTAL_SCROLL_BUFFER
|
|
2233
|
+
);
|
|
2234
|
+
if ((0, import_vuu_utils18.itemsChanged)(columnsWithinViewportRef.current, visibleColumns)) {
|
|
2235
|
+
preSpanRef.current = pre;
|
|
2236
|
+
columnsWithinViewportRef.current = visibleColumns;
|
|
2237
|
+
forceRefresh({});
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
},
|
|
2241
|
+
[columns, onHorizontalScroll, viewportWidth]
|
|
2242
|
+
);
|
|
2243
|
+
const handleVerticalScroll = (0, import_react21.useCallback)(
|
|
1994
2244
|
(scrollTop, pctScrollTop) => {
|
|
2245
|
+
contentContainerPosRef.current.scrollTop = scrollTop;
|
|
1995
2246
|
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
1996
2247
|
const firstRow = getRowAtPosition(scrollTop);
|
|
1997
2248
|
if (firstRow !== firstRowRef.current) {
|
|
1998
2249
|
firstRowRef.current = firstRow;
|
|
1999
|
-
setRange({ from: firstRow, to: firstRow + viewportRowCount
|
|
2250
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2000
2251
|
}
|
|
2252
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(0);
|
|
2001
2253
|
},
|
|
2002
|
-
[
|
|
2254
|
+
[
|
|
2255
|
+
getRowAtPosition,
|
|
2256
|
+
onVerticalScroll,
|
|
2257
|
+
onVerticalScrollInSitu,
|
|
2258
|
+
setRange,
|
|
2259
|
+
viewportRowCount
|
|
2260
|
+
]
|
|
2003
2261
|
);
|
|
2004
|
-
const handleScrollbarContainerScroll = (0,
|
|
2262
|
+
const handleScrollbarContainerScroll = (0, import_react21.useCallback)(() => {
|
|
2005
2263
|
const { current: contentContainer } = contentContainerRef;
|
|
2006
2264
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2007
2265
|
const { current: contentContainerScrolled } = contentContainerScrolledRef;
|
|
2266
|
+
const { current: scrollPos } = scrollbarContainerPosRef;
|
|
2008
2267
|
if (contentContainerScrolled) {
|
|
2009
2268
|
contentContainerScrolledRef.current = false;
|
|
2010
2269
|
} else if (contentContainer && scrollbarContainer) {
|
|
2011
|
-
|
|
2012
|
-
const
|
|
2013
|
-
|
|
2270
|
+
scrollbarContainerScrolledRef.current = true;
|
|
2271
|
+
const [scrollLeft, pctScrollLeft, , scrollTop, pctScrollTop] = getPctScroll(scrollbarContainer, scrollPos);
|
|
2272
|
+
scrollPos.scrollLeft = scrollLeft;
|
|
2273
|
+
scrollPos.scrollTop = scrollTop;
|
|
2274
|
+
const [maxScrollLeft, maxScrollTop] = getMaxScroll(scrollbarContainer);
|
|
2275
|
+
const contentScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2276
|
+
const contentScrollTop = pctScrollTop * maxScrollTop;
|
|
2014
2277
|
contentContainer.scrollTo({
|
|
2015
|
-
left:
|
|
2016
|
-
top:
|
|
2278
|
+
left: contentScrollLeft,
|
|
2279
|
+
top: contentScrollTop,
|
|
2017
2280
|
behavior: "auto"
|
|
2018
2281
|
});
|
|
2019
2282
|
}
|
|
2020
|
-
|
|
2021
|
-
|
|
2283
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(0);
|
|
2284
|
+
}, [onVerticalScrollInSitu]);
|
|
2285
|
+
const handleContentContainerScroll = (0, import_react21.useCallback)(() => {
|
|
2286
|
+
const { current: scrollbarContainerScrolled } = scrollbarContainerScrolledRef;
|
|
2022
2287
|
const { current: contentContainer } = contentContainerRef;
|
|
2023
2288
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2024
|
-
const { current: scrollPos } =
|
|
2289
|
+
const { current: scrollPos } = contentContainerPosRef;
|
|
2025
2290
|
if (contentContainer && scrollbarContainer) {
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2291
|
+
const [
|
|
2292
|
+
scrollLeft,
|
|
2293
|
+
pctScrollLeft,
|
|
2294
|
+
maxScrollLeft,
|
|
2295
|
+
scrollTop,
|
|
2296
|
+
pctScrollTop,
|
|
2297
|
+
maxScrollTop
|
|
2298
|
+
] = getPctScroll(contentContainer);
|
|
2028
2299
|
contentContainerScrolledRef.current = true;
|
|
2029
|
-
|
|
2030
|
-
|
|
2300
|
+
if (scrollbarContainerScrolled) {
|
|
2301
|
+
scrollbarContainerScrolledRef.current = false;
|
|
2302
|
+
} else {
|
|
2303
|
+
scrollbarContainer.scrollLeft = Math.round(
|
|
2304
|
+
pctScrollLeft * maxScrollLeft
|
|
2305
|
+
);
|
|
2306
|
+
scrollbarContainer.scrollTop = pctScrollTop * maxScrollTop;
|
|
2307
|
+
}
|
|
2031
2308
|
if (scrollPos.scrollTop !== scrollTop) {
|
|
2032
|
-
scrollPos.scrollTop = scrollTop;
|
|
2033
2309
|
handleVerticalScroll(scrollTop, pctScrollTop);
|
|
2034
2310
|
}
|
|
2035
2311
|
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
2036
|
-
|
|
2037
|
-
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2312
|
+
handleHorizontalScroll(scrollLeft);
|
|
2038
2313
|
}
|
|
2039
2314
|
}
|
|
2040
|
-
}, [handleVerticalScroll,
|
|
2041
|
-
const handleAttachScrollbarContainer = (0,
|
|
2315
|
+
}, [handleVerticalScroll, handleHorizontalScroll]);
|
|
2316
|
+
const handleAttachScrollbarContainer = (0, import_react21.useCallback)(
|
|
2042
2317
|
(el) => {
|
|
2043
2318
|
scrollbarContainerRef.current = el;
|
|
2044
2319
|
el.addEventListener("scroll", handleScrollbarContainerScroll, {
|
|
@@ -2047,14 +2322,14 @@ var useTableScroll = ({
|
|
|
2047
2322
|
},
|
|
2048
2323
|
[handleScrollbarContainerScroll]
|
|
2049
2324
|
);
|
|
2050
|
-
const handleDetachScrollbarContainer = (0,
|
|
2325
|
+
const handleDetachScrollbarContainer = (0, import_react21.useCallback)(
|
|
2051
2326
|
(el) => {
|
|
2052
2327
|
scrollbarContainerRef.current = null;
|
|
2053
2328
|
el.removeEventListener("scroll", handleScrollbarContainerScroll);
|
|
2054
2329
|
},
|
|
2055
2330
|
[handleScrollbarContainerScroll]
|
|
2056
2331
|
);
|
|
2057
|
-
const handleAttachContentContainer = (0,
|
|
2332
|
+
const handleAttachContentContainer = (0, import_react21.useCallback)(
|
|
2058
2333
|
(el) => {
|
|
2059
2334
|
contentContainerRef.current = el;
|
|
2060
2335
|
el.addEventListener("scroll", handleContentContainerScroll, {
|
|
@@ -2063,7 +2338,7 @@ var useTableScroll = ({
|
|
|
2063
2338
|
},
|
|
2064
2339
|
[handleContentContainerScroll]
|
|
2065
2340
|
);
|
|
2066
|
-
const handleDetachContentContainer = (0,
|
|
2341
|
+
const handleDetachContentContainer = (0, import_react21.useCallback)(
|
|
2067
2342
|
(el) => {
|
|
2068
2343
|
contentContainerRef.current = null;
|
|
2069
2344
|
el.removeEventListener("scroll", handleContentContainerScroll);
|
|
@@ -2078,15 +2353,16 @@ var useTableScroll = ({
|
|
|
2078
2353
|
onAttach: handleAttachScrollbarContainer,
|
|
2079
2354
|
onDetach: handleDetachScrollbarContainer
|
|
2080
2355
|
});
|
|
2081
|
-
const requestScroll = (0,
|
|
2356
|
+
const requestScroll = (0, import_react21.useCallback)(
|
|
2082
2357
|
(scrollRequest) => {
|
|
2083
|
-
const { current:
|
|
2084
|
-
if (
|
|
2085
|
-
const
|
|
2358
|
+
const { current: contentContainer } = contentContainerRef;
|
|
2359
|
+
if (contentContainer) {
|
|
2360
|
+
const [maxScrollLeft, maxScrollTop] = getMaxScroll(contentContainer);
|
|
2361
|
+
const { scrollLeft, scrollTop } = contentContainer;
|
|
2086
2362
|
contentContainerScrolledRef.current = false;
|
|
2087
2363
|
if (scrollRequest.type === "scroll-row") {
|
|
2088
|
-
const activeRow = (0,
|
|
2089
|
-
|
|
2364
|
+
const activeRow = (0, import_vuu_utils18.getRowElementAtIndex)(
|
|
2365
|
+
contentContainer,
|
|
2090
2366
|
scrollRequest.rowIndex
|
|
2091
2367
|
);
|
|
2092
2368
|
if (activeRow !== null) {
|
|
@@ -2096,10 +2372,14 @@ var useTableScroll = ({
|
|
|
2096
2372
|
);
|
|
2097
2373
|
if (direction && distance) {
|
|
2098
2374
|
if (isVirtualScroll) {
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2375
|
+
const offset = direction === "down" ? 1 : -1;
|
|
2376
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(offset);
|
|
2377
|
+
const firstRow = firstRowRef.current + offset;
|
|
2378
|
+
firstRowRef.current = firstRow;
|
|
2379
|
+
setRange({
|
|
2380
|
+
from: firstRow,
|
|
2381
|
+
to: firstRow + viewportRowCount
|
|
2382
|
+
});
|
|
2103
2383
|
} else {
|
|
2104
2384
|
let newScrollLeft = scrollLeft;
|
|
2105
2385
|
let newScrollTop = scrollTop;
|
|
@@ -2114,7 +2394,7 @@ var useTableScroll = ({
|
|
|
2114
2394
|
maxScrollLeft
|
|
2115
2395
|
);
|
|
2116
2396
|
}
|
|
2117
|
-
|
|
2397
|
+
contentContainer.scrollTo({
|
|
2118
2398
|
top: newScrollTop,
|
|
2119
2399
|
left: newScrollLeft,
|
|
2120
2400
|
behavior: "smooth"
|
|
@@ -2125,14 +2405,18 @@ var useTableScroll = ({
|
|
|
2125
2405
|
} else if (scrollRequest.type === "scroll-page") {
|
|
2126
2406
|
const { direction } = scrollRequest;
|
|
2127
2407
|
if (isVirtualScroll) {
|
|
2128
|
-
|
|
2408
|
+
const offset = direction === "down" ? viewportRowCount : -viewportRowCount;
|
|
2409
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(offset);
|
|
2410
|
+
const firstRow = firstRowRef.current + offset;
|
|
2411
|
+
firstRowRef.current = firstRow;
|
|
2412
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2129
2413
|
} else {
|
|
2130
2414
|
const scrollBy = direction === "down" ? appliedPageSize : -appliedPageSize;
|
|
2131
2415
|
const newScrollTop = Math.min(
|
|
2132
2416
|
Math.max(0, scrollTop + scrollBy),
|
|
2133
2417
|
maxScrollTop
|
|
2134
2418
|
);
|
|
2135
|
-
|
|
2419
|
+
contentContainer.scrollTo({
|
|
2136
2420
|
top: newScrollTop,
|
|
2137
2421
|
left: scrollLeft,
|
|
2138
2422
|
behavior: "auto"
|
|
@@ -2141,9 +2425,9 @@ var useTableScroll = ({
|
|
|
2141
2425
|
} else if (scrollRequest.type === "scroll-end") {
|
|
2142
2426
|
const { direction } = scrollRequest;
|
|
2143
2427
|
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
2144
|
-
|
|
2428
|
+
contentContainer.scrollTo({
|
|
2145
2429
|
top: scrollTo,
|
|
2146
|
-
left:
|
|
2430
|
+
left: contentContainer.scrollLeft,
|
|
2147
2431
|
behavior: "auto"
|
|
2148
2432
|
});
|
|
2149
2433
|
}
|
|
@@ -2152,14 +2436,14 @@ var useTableScroll = ({
|
|
|
2152
2436
|
[
|
|
2153
2437
|
appliedPageSize,
|
|
2154
2438
|
isVirtualScroll,
|
|
2155
|
-
|
|
2156
|
-
maxScrollTop,
|
|
2439
|
+
onVerticalScrollInSitu,
|
|
2157
2440
|
setRange,
|
|
2158
2441
|
totalHeaderHeight,
|
|
2159
2442
|
viewportRowCount
|
|
2160
2443
|
]
|
|
2161
2444
|
);
|
|
2162
|
-
const scrollHandles = (0,
|
|
2445
|
+
const scrollHandles = (0, import_react21.useMemo)(
|
|
2446
|
+
// TODO not complete yet
|
|
2163
2447
|
() => ({
|
|
2164
2448
|
scrollToIndex: (rowIndex) => {
|
|
2165
2449
|
if (scrollbarContainerRef.current) {
|
|
@@ -2173,7 +2457,7 @@ var useTableScroll = ({
|
|
|
2173
2457
|
}),
|
|
2174
2458
|
[]
|
|
2175
2459
|
);
|
|
2176
|
-
(0,
|
|
2460
|
+
(0, import_react21.useImperativeHandle)(
|
|
2177
2461
|
scrollingApiRef,
|
|
2178
2462
|
() => {
|
|
2179
2463
|
if (scrollbarContainerRef.current) {
|
|
@@ -2184,25 +2468,28 @@ var useTableScroll = ({
|
|
|
2184
2468
|
},
|
|
2185
2469
|
[scrollHandles]
|
|
2186
2470
|
);
|
|
2187
|
-
(0,
|
|
2471
|
+
(0, import_react21.useEffect)(() => {
|
|
2188
2472
|
const { current: from } = firstRowRef;
|
|
2189
|
-
const rowRange = { from, to: from + viewportRowCount
|
|
2473
|
+
const rowRange = { from, to: from + viewportRowCount };
|
|
2190
2474
|
setRange(rowRange);
|
|
2191
2475
|
}, [setRange, viewportRowCount]);
|
|
2192
2476
|
return {
|
|
2477
|
+
columnsWithinViewport: columnsWithinViewportRef.current,
|
|
2193
2478
|
/** Ref to be assigned to ScrollbarContainer */
|
|
2194
2479
|
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
2195
2480
|
/** Ref to be assigned to ContentContainer */
|
|
2196
2481
|
contentContainerRef: contentContainerCallbackRef,
|
|
2197
2482
|
/** Scroll the table */
|
|
2198
|
-
requestScroll
|
|
2483
|
+
requestScroll,
|
|
2484
|
+
/** number of leading columns not rendered because of virtualization */
|
|
2485
|
+
virtualColSpan: preSpanRef.current
|
|
2199
2486
|
};
|
|
2200
2487
|
};
|
|
2201
2488
|
|
|
2202
2489
|
// src/useTableViewport.ts
|
|
2203
|
-
var
|
|
2204
|
-
var
|
|
2205
|
-
var
|
|
2490
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
2491
|
+
var import_react22 = require("react");
|
|
2492
|
+
var MAX_PIXEL_HEIGHT = 1e7;
|
|
2206
2493
|
var UNMEASURED_VIEWPORT = {
|
|
2207
2494
|
appliedPageSize: 0,
|
|
2208
2495
|
contentHeight: 0,
|
|
@@ -2211,36 +2498,15 @@ var UNMEASURED_VIEWPORT = {
|
|
|
2211
2498
|
getRowOffset: () => -1,
|
|
2212
2499
|
horizontalScrollbarHeight: 0,
|
|
2213
2500
|
isVirtualScroll: false,
|
|
2214
|
-
maxScrollContainerScrollHorizontal: 0,
|
|
2215
|
-
maxScrollContainerScrollVertical: 0,
|
|
2216
2501
|
pinnedWidthLeft: 0,
|
|
2217
2502
|
pinnedWidthRight: 0,
|
|
2218
2503
|
rowCount: 0,
|
|
2219
|
-
|
|
2504
|
+
setInSituRowOffset: () => void 0,
|
|
2505
|
+
setScrollTop: () => void 0,
|
|
2220
2506
|
totalHeaderHeight: 0,
|
|
2221
2507
|
verticalScrollbarWidth: 0,
|
|
2222
|
-
viewportBodyHeight: 0
|
|
2223
|
-
|
|
2224
|
-
var measurePinnedColumns = (columns) => {
|
|
2225
|
-
let pinnedWidthLeft = 0;
|
|
2226
|
-
let pinnedWidthRight = 0;
|
|
2227
|
-
let unpinnedWidth = 0;
|
|
2228
|
-
for (const column of columns) {
|
|
2229
|
-
const { hidden, pin, width } = column;
|
|
2230
|
-
const visibleWidth = hidden ? 0 : width;
|
|
2231
|
-
if (pin === "left") {
|
|
2232
|
-
pinnedWidthLeft += visibleWidth;
|
|
2233
|
-
} else if (pin === "right") {
|
|
2234
|
-
pinnedWidthRight += visibleWidth;
|
|
2235
|
-
} else {
|
|
2236
|
-
unpinnedWidth += visibleWidth;
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
return {
|
|
2240
|
-
pinnedWidthLeft: pinnedWidthLeft + 4,
|
|
2241
|
-
pinnedWidthRight: pinnedWidthRight + 4,
|
|
2242
|
-
unpinnedWidth
|
|
2243
|
-
};
|
|
2508
|
+
viewportBodyHeight: 0,
|
|
2509
|
+
viewportWidth: 0
|
|
2244
2510
|
};
|
|
2245
2511
|
var useTableViewport = ({
|
|
2246
2512
|
columns,
|
|
@@ -2248,48 +2514,58 @@ var useTableViewport = ({
|
|
|
2248
2514
|
headings,
|
|
2249
2515
|
rowCount,
|
|
2250
2516
|
rowHeight,
|
|
2517
|
+
selectionEndSize = 4,
|
|
2251
2518
|
size
|
|
2252
2519
|
}) => {
|
|
2253
|
-
const
|
|
2254
|
-
const
|
|
2520
|
+
const inSituRowOffsetRef = (0, import_react22.useRef)(0);
|
|
2521
|
+
const pctScrollTopRef = (0, import_react22.useRef)(0);
|
|
2522
|
+
const pixelContentHeight = Math.min(rowHeight * rowCount, MAX_PIXEL_HEIGHT);
|
|
2255
2523
|
const virtualContentHeight = rowCount * rowHeight;
|
|
2256
2524
|
const virtualisedExtent = virtualContentHeight - pixelContentHeight;
|
|
2257
|
-
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0,
|
|
2258
|
-
() => measurePinnedColumns(columns),
|
|
2259
|
-
[columns]
|
|
2525
|
+
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react22.useMemo)(
|
|
2526
|
+
() => (0, import_vuu_utils19.measurePinnedColumns)(columns, selectionEndSize),
|
|
2527
|
+
[columns, selectionEndSize]
|
|
2260
2528
|
);
|
|
2261
|
-
const totalHeaderHeightRef = (0,
|
|
2262
|
-
(0,
|
|
2529
|
+
const totalHeaderHeightRef = (0, import_react22.useRef)(headerHeight);
|
|
2530
|
+
(0, import_react22.useMemo)(() => {
|
|
2263
2531
|
totalHeaderHeightRef.current = headerHeight * (1 + headings.length);
|
|
2264
2532
|
}, [headerHeight, headings.length]);
|
|
2265
|
-
const [getRowOffset, getRowAtPosition, isVirtualScroll] = (0,
|
|
2533
|
+
const [getRowOffset, getRowAtPosition, isVirtualScroll] = (0, import_react22.useMemo)(() => {
|
|
2266
2534
|
if (virtualisedExtent) {
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2535
|
+
const [_getRowOffset, getRowAtPosition2, _isVirtual] = (0, import_vuu_utils19.virtualRowPositioning)(rowHeight, virtualisedExtent, pctScrollTopRef);
|
|
2536
|
+
const getOffset = (row) => {
|
|
2537
|
+
return _getRowOffset(row, inSituRowOffsetRef.current);
|
|
2538
|
+
};
|
|
2539
|
+
return [getOffset, getRowAtPosition2, _isVirtual];
|
|
2272
2540
|
} else {
|
|
2273
|
-
return (0,
|
|
2541
|
+
return (0, import_vuu_utils19.actualRowPositioning)(rowHeight);
|
|
2274
2542
|
}
|
|
2275
2543
|
}, [virtualisedExtent, rowHeight]);
|
|
2276
|
-
const
|
|
2544
|
+
const setScrollTop = (0, import_react22.useCallback)((_, scrollPct) => {
|
|
2277
2545
|
pctScrollTopRef.current = scrollPct;
|
|
2278
2546
|
}, []);
|
|
2279
|
-
|
|
2280
|
-
|
|
2547
|
+
const setInSituRowOffset = (0, import_react22.useCallback)((rowIndexOffset) => {
|
|
2548
|
+
if (rowIndexOffset === 0) {
|
|
2549
|
+
inSituRowOffsetRef.current = 0;
|
|
2550
|
+
} else {
|
|
2551
|
+
inSituRowOffsetRef.current = Math.max(
|
|
2552
|
+
0,
|
|
2553
|
+
inSituRowOffsetRef.current + rowIndexOffset
|
|
2554
|
+
);
|
|
2555
|
+
}
|
|
2556
|
+
}, []);
|
|
2557
|
+
return (0, import_react22.useMemo)(() => {
|
|
2281
2558
|
if (size) {
|
|
2282
2559
|
const { current: totalHeaderHeight } = totalHeaderHeightRef;
|
|
2283
2560
|
const scrollbarSize = 15;
|
|
2284
2561
|
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
2285
2562
|
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
2286
|
-
const maxScrollContainerScrollVertical = pixelContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2287
|
-
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
2288
2563
|
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
2289
2564
|
const count = Number.isInteger(visibleRows) ? visibleRows : Math.ceil(visibleRows);
|
|
2290
2565
|
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
2291
2566
|
const verticalScrollbarWidth = pixelContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
2292
2567
|
const appliedPageSize = count * rowHeight * (pixelContentHeight / virtualContentHeight);
|
|
2568
|
+
const viewportWidth = size.width;
|
|
2293
2569
|
return {
|
|
2294
2570
|
appliedPageSize,
|
|
2295
2571
|
contentHeight: pixelContentHeight,
|
|
@@ -2298,15 +2574,15 @@ var useTableViewport = ({
|
|
|
2298
2574
|
getRowOffset,
|
|
2299
2575
|
isVirtualScroll,
|
|
2300
2576
|
horizontalScrollbarHeight,
|
|
2301
|
-
maxScrollContainerScrollHorizontal,
|
|
2302
|
-
maxScrollContainerScrollVertical,
|
|
2303
2577
|
pinnedWidthLeft,
|
|
2304
2578
|
pinnedWidthRight,
|
|
2305
2579
|
rowCount: count,
|
|
2306
|
-
|
|
2580
|
+
setInSituRowOffset,
|
|
2581
|
+
setScrollTop,
|
|
2307
2582
|
totalHeaderHeight,
|
|
2308
2583
|
verticalScrollbarWidth,
|
|
2309
|
-
viewportBodyHeight
|
|
2584
|
+
viewportBodyHeight,
|
|
2585
|
+
viewportWidth
|
|
2310
2586
|
};
|
|
2311
2587
|
} else {
|
|
2312
2588
|
return UNMEASURED_VIEWPORT;
|
|
@@ -2321,16 +2597,17 @@ var useTableViewport = ({
|
|
|
2321
2597
|
pinnedWidthRight,
|
|
2322
2598
|
pixelContentHeight,
|
|
2323
2599
|
rowHeight,
|
|
2324
|
-
|
|
2600
|
+
setInSituRowOffset,
|
|
2601
|
+
setScrollTop,
|
|
2325
2602
|
size,
|
|
2326
2603
|
virtualContentHeight
|
|
2327
2604
|
]);
|
|
2328
2605
|
};
|
|
2329
2606
|
|
|
2330
2607
|
// src/useTableAndColumnSettings.ts
|
|
2331
|
-
var
|
|
2332
|
-
var
|
|
2333
|
-
var
|
|
2608
|
+
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
2609
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
2610
|
+
var import_react23 = require("react");
|
|
2334
2611
|
var useTableAndColumnSettings = ({
|
|
2335
2612
|
availableColumns: availableColumnsProps,
|
|
2336
2613
|
onAvailableColumnsChange,
|
|
@@ -2339,12 +2616,12 @@ var useTableAndColumnSettings = ({
|
|
|
2339
2616
|
onDataSourceConfigChange,
|
|
2340
2617
|
tableConfig
|
|
2341
2618
|
}) => {
|
|
2342
|
-
const dispatchLayoutAction = (0,
|
|
2343
|
-
const showTableSettingsRef = (0,
|
|
2344
|
-
const [availableColumns, setAvailableColumns] = (0,
|
|
2619
|
+
const dispatchLayoutAction = (0, import_vuu_layout.useLayoutProviderDispatch)();
|
|
2620
|
+
const showTableSettingsRef = (0, import_react23.useRef)();
|
|
2621
|
+
const [availableColumns, setAvailableColumns] = (0, import_react23.useState)(
|
|
2345
2622
|
availableColumnsProps
|
|
2346
2623
|
);
|
|
2347
|
-
const showContextPanel = (0,
|
|
2624
|
+
const showContextPanel = (0, import_react23.useCallback)(
|
|
2348
2625
|
(componentType, title, props) => {
|
|
2349
2626
|
dispatchLayoutAction({
|
|
2350
2627
|
type: "set-props",
|
|
@@ -2361,17 +2638,17 @@ var useTableAndColumnSettings = ({
|
|
|
2361
2638
|
},
|
|
2362
2639
|
[dispatchLayoutAction]
|
|
2363
2640
|
);
|
|
2364
|
-
const handleCancelCreateColumn = (0,
|
|
2641
|
+
const handleCancelCreateColumn = (0, import_react23.useCallback)(() => {
|
|
2365
2642
|
requestAnimationFrame(() => {
|
|
2366
2643
|
var _a;
|
|
2367
2644
|
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2368
2645
|
});
|
|
2369
2646
|
}, []);
|
|
2370
|
-
const handleCreateCalculatedColumn = (0,
|
|
2647
|
+
const handleCreateCalculatedColumn = (0, import_react23.useCallback)(
|
|
2371
2648
|
(column) => {
|
|
2372
2649
|
const newAvailableColumns = availableColumns.concat({
|
|
2373
2650
|
name: column.name,
|
|
2374
|
-
serverDataType: (0,
|
|
2651
|
+
serverDataType: (0, import_vuu_utils20.getCalculatedColumnType)(column)
|
|
2375
2652
|
});
|
|
2376
2653
|
setAvailableColumns(newAvailableColumns);
|
|
2377
2654
|
onAvailableColumnsChange == null ? void 0 : onAvailableColumnsChange(newAvailableColumns);
|
|
@@ -2383,7 +2660,7 @@ var useTableAndColumnSettings = ({
|
|
|
2383
2660
|
},
|
|
2384
2661
|
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2385
2662
|
);
|
|
2386
|
-
const showColumnSettingsPanel = (0,
|
|
2663
|
+
const showColumnSettingsPanel = (0, import_react23.useCallback)(
|
|
2387
2664
|
(action) => {
|
|
2388
2665
|
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2389
2666
|
column: action.column,
|
|
@@ -2402,7 +2679,7 @@ var useTableAndColumnSettings = ({
|
|
|
2402
2679
|
tableConfig
|
|
2403
2680
|
]
|
|
2404
2681
|
);
|
|
2405
|
-
const handleAddCalculatedColumn = (0,
|
|
2682
|
+
const handleAddCalculatedColumn = (0, import_react23.useCallback)(() => {
|
|
2406
2683
|
showColumnSettingsPanel({
|
|
2407
2684
|
column: {
|
|
2408
2685
|
name: "::",
|
|
@@ -2412,7 +2689,7 @@ var useTableAndColumnSettings = ({
|
|
|
2412
2689
|
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2413
2690
|
});
|
|
2414
2691
|
}, [showColumnSettingsPanel]);
|
|
2415
|
-
const handleNavigateToColumn = (0,
|
|
2692
|
+
const handleNavigateToColumn = (0, import_react23.useCallback)(
|
|
2416
2693
|
(columnName) => {
|
|
2417
2694
|
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2418
2695
|
if (column) {
|
|
@@ -2426,7 +2703,7 @@ var useTableAndColumnSettings = ({
|
|
|
2426
2703
|
},
|
|
2427
2704
|
[showColumnSettingsPanel, tableConfig.columns]
|
|
2428
2705
|
);
|
|
2429
|
-
showTableSettingsRef.current = (0,
|
|
2706
|
+
showTableSettingsRef.current = (0, import_react23.useCallback)(() => {
|
|
2430
2707
|
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2431
2708
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2432
2709
|
name,
|
|
@@ -2457,7 +2734,7 @@ var useTableAndColumnSettings = ({
|
|
|
2457
2734
|
var stripInternalProperties = (tableConfig) => {
|
|
2458
2735
|
return tableConfig;
|
|
2459
2736
|
};
|
|
2460
|
-
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } =
|
|
2737
|
+
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils21.metadataKeys;
|
|
2461
2738
|
var NULL_DRAG_DROP = {
|
|
2462
2739
|
draggable: void 0,
|
|
2463
2740
|
onMouseDown: void 0
|
|
@@ -2493,33 +2770,33 @@ var useTable = ({
|
|
|
2493
2770
|
selectionModel,
|
|
2494
2771
|
size
|
|
2495
2772
|
}) => {
|
|
2496
|
-
const [rowCount, setRowCount] = (0,
|
|
2773
|
+
const [rowCount, setRowCount] = (0, import_react24.useState)(dataSource.size);
|
|
2497
2774
|
if (dataSource === void 0) {
|
|
2498
2775
|
throw Error("no data source provided to Vuu Table");
|
|
2499
2776
|
}
|
|
2500
|
-
const useRowDragDrop = allowDragDrop ?
|
|
2501
|
-
const menuBuilder = (0,
|
|
2777
|
+
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls4.useDragDrop : useNullDragDrop;
|
|
2778
|
+
const menuBuilder = (0, import_react24.useMemo)(
|
|
2502
2779
|
() => buildContextMenuDescriptors(dataSource),
|
|
2503
2780
|
[dataSource]
|
|
2504
2781
|
);
|
|
2505
|
-
const onDataRowcountChange = (0,
|
|
2782
|
+
const onDataRowcountChange = (0, import_react24.useCallback)((size2) => {
|
|
2506
2783
|
setRowCount(size2);
|
|
2507
2784
|
}, []);
|
|
2508
2785
|
const {
|
|
2509
|
-
columns
|
|
2786
|
+
columns,
|
|
2510
2787
|
dispatchColumnAction,
|
|
2511
2788
|
headings,
|
|
2512
2789
|
tableAttributes,
|
|
2513
2790
|
tableConfig
|
|
2514
2791
|
} = useTableModel(config, dataSource);
|
|
2515
|
-
(0,
|
|
2792
|
+
(0, import_vuu_utils21.useLayoutEffectSkipFirst)(() => {
|
|
2516
2793
|
dispatchColumnAction({
|
|
2517
2794
|
type: "init",
|
|
2518
|
-
|
|
2519
|
-
|
|
2795
|
+
tableConfig: config,
|
|
2796
|
+
dataSource
|
|
2520
2797
|
});
|
|
2521
|
-
}, [
|
|
2522
|
-
const applyTableConfigChange = (0,
|
|
2798
|
+
}, [config, dataSource, dispatchColumnAction]);
|
|
2799
|
+
const applyTableConfigChange = (0, import_react24.useCallback)(
|
|
2523
2800
|
(config2) => {
|
|
2524
2801
|
dispatchColumnAction({
|
|
2525
2802
|
type: "init",
|
|
@@ -2530,22 +2807,28 @@ var useTable = ({
|
|
|
2530
2807
|
},
|
|
2531
2808
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2532
2809
|
);
|
|
2533
|
-
const
|
|
2534
|
-
|
|
2535
|
-
const setSize = (columnName, width) => {
|
|
2536
|
-
const cols = (0, import_vuu_utils19.updateColumn)(runtimeColumns, columnName, { width });
|
|
2537
|
-
setStateColumns(cols);
|
|
2538
|
-
};
|
|
2539
|
-
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2540
|
-
}, [runtimeColumns, stateColumns]);
|
|
2541
|
-
const columnMap = (0, import_react23.useMemo)(
|
|
2542
|
-
() => (0, import_vuu_utils19.buildColumnMap)(dataSource.columns),
|
|
2810
|
+
const columnMap = (0, import_react24.useMemo)(
|
|
2811
|
+
() => (0, import_vuu_utils21.buildColumnMap)(dataSource.columns),
|
|
2543
2812
|
[dataSource.columns]
|
|
2544
2813
|
);
|
|
2814
|
+
const onSubscribed = (0, import_react24.useCallback)(
|
|
2815
|
+
({ tableSchema }) => {
|
|
2816
|
+
if (tableSchema) {
|
|
2817
|
+
dispatchColumnAction({
|
|
2818
|
+
type: "setTableSchema",
|
|
2819
|
+
tableSchema
|
|
2820
|
+
});
|
|
2821
|
+
} else {
|
|
2822
|
+
console.log("subscription message with no schema");
|
|
2823
|
+
}
|
|
2824
|
+
},
|
|
2825
|
+
[dispatchColumnAction]
|
|
2826
|
+
);
|
|
2545
2827
|
const {
|
|
2546
2828
|
getRowAtPosition,
|
|
2547
2829
|
getRowOffset,
|
|
2548
|
-
|
|
2830
|
+
setInSituRowOffset: viewportHookSetInSituRowOffset,
|
|
2831
|
+
setScrollTop: viewportHookSetScrollTop,
|
|
2549
2832
|
...viewportMeasurements
|
|
2550
2833
|
} = useTableViewport({
|
|
2551
2834
|
columns,
|
|
@@ -2557,21 +2840,8 @@ var useTable = ({
|
|
|
2557
2840
|
});
|
|
2558
2841
|
const initialRange = useInitialValue({
|
|
2559
2842
|
from: 0,
|
|
2560
|
-
to: viewportMeasurements.rowCount
|
|
2843
|
+
to: viewportMeasurements.rowCount
|
|
2561
2844
|
});
|
|
2562
|
-
const onSubscribed = (0, import_react23.useCallback)(
|
|
2563
|
-
({ tableSchema }) => {
|
|
2564
|
-
if (tableSchema) {
|
|
2565
|
-
dispatchColumnAction({
|
|
2566
|
-
type: "setTableSchema",
|
|
2567
|
-
tableSchema
|
|
2568
|
-
});
|
|
2569
|
-
} else {
|
|
2570
|
-
console.log("subscription message with no schema");
|
|
2571
|
-
}
|
|
2572
|
-
},
|
|
2573
|
-
[dispatchColumnAction]
|
|
2574
|
-
);
|
|
2575
2845
|
const { data, dataRef, getSelectedRows, range, setRange } = useDataSource({
|
|
2576
2846
|
dataSource,
|
|
2577
2847
|
// We need to factor this out of Table
|
|
@@ -2581,7 +2851,17 @@ var useTable = ({
|
|
|
2581
2851
|
onSubscribed,
|
|
2582
2852
|
range: initialRange
|
|
2583
2853
|
});
|
|
2584
|
-
const
|
|
2854
|
+
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2855
|
+
columns,
|
|
2856
|
+
getRowAtPosition,
|
|
2857
|
+
rowHeight,
|
|
2858
|
+
scrollingApiRef,
|
|
2859
|
+
setRange,
|
|
2860
|
+
onVerticalScroll: viewportHookSetScrollTop,
|
|
2861
|
+
onVerticalScrollInSitu: viewportHookSetInSituRowOffset,
|
|
2862
|
+
viewportMeasurements
|
|
2863
|
+
});
|
|
2864
|
+
const handleConfigEditedInSettingsPanel = (0, import_react24.useCallback)(
|
|
2585
2865
|
(tableConfig2) => {
|
|
2586
2866
|
dispatchColumnAction({
|
|
2587
2867
|
type: "init",
|
|
@@ -2592,7 +2872,7 @@ var useTable = ({
|
|
|
2592
2872
|
},
|
|
2593
2873
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2594
2874
|
);
|
|
2595
|
-
const handleDataSourceConfigChanged = (0,
|
|
2875
|
+
const handleDataSourceConfigChanged = (0, import_react24.useCallback)(
|
|
2596
2876
|
(dataSourceConfig) => {
|
|
2597
2877
|
dataSource.config = {
|
|
2598
2878
|
...dataSource.config,
|
|
@@ -2601,7 +2881,7 @@ var useTable = ({
|
|
|
2601
2881
|
},
|
|
2602
2882
|
[dataSource]
|
|
2603
2883
|
);
|
|
2604
|
-
(0,
|
|
2884
|
+
(0, import_react24.useEffect)(() => {
|
|
2605
2885
|
dataSource.on("config", (config2, confirmed) => {
|
|
2606
2886
|
dispatchColumnAction({
|
|
2607
2887
|
type: "tableConfig",
|
|
@@ -2610,14 +2890,14 @@ var useTable = ({
|
|
|
2610
2890
|
});
|
|
2611
2891
|
});
|
|
2612
2892
|
}, [dataSource, dispatchColumnAction]);
|
|
2613
|
-
const handleCreateCalculatedColumn = (0,
|
|
2893
|
+
const handleCreateCalculatedColumn = (0, import_react24.useCallback)(
|
|
2614
2894
|
(column) => {
|
|
2615
2895
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2616
2896
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2617
2897
|
},
|
|
2618
2898
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2619
2899
|
);
|
|
2620
|
-
const hideColumns2 = (0,
|
|
2900
|
+
const hideColumns2 = (0, import_react24.useCallback)(
|
|
2621
2901
|
(action) => {
|
|
2622
2902
|
const { columns: columns2 } = action;
|
|
2623
2903
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2631,11 +2911,11 @@ var useTable = ({
|
|
|
2631
2911
|
},
|
|
2632
2912
|
[tableConfig, applyTableConfigChange]
|
|
2633
2913
|
);
|
|
2634
|
-
const pinColumn3 = (0,
|
|
2914
|
+
const pinColumn3 = (0, import_react24.useCallback)(
|
|
2635
2915
|
(action) => {
|
|
2636
2916
|
applyTableConfigChange({
|
|
2637
2917
|
...tableConfig,
|
|
2638
|
-
columns: (0,
|
|
2918
|
+
columns: (0, import_vuu_utils21.updateColumn)(tableConfig.columns, {
|
|
2639
2919
|
...action.column,
|
|
2640
2920
|
pin: action.pin
|
|
2641
2921
|
})
|
|
@@ -2654,7 +2934,7 @@ var useTable = ({
|
|
|
2654
2934
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2655
2935
|
tableConfig
|
|
2656
2936
|
});
|
|
2657
|
-
const onPersistentColumnOperation = (0,
|
|
2937
|
+
const onPersistentColumnOperation = (0, import_react24.useCallback)(
|
|
2658
2938
|
(action) => {
|
|
2659
2939
|
if (isShowColumnSettings(action)) {
|
|
2660
2940
|
showColumnSettingsPanel(action);
|
|
@@ -2683,10 +2963,10 @@ var useTable = ({
|
|
|
2683
2963
|
dataSource,
|
|
2684
2964
|
onPersistentColumnOperation
|
|
2685
2965
|
});
|
|
2686
|
-
const handleSort = (0,
|
|
2966
|
+
const handleSort = (0, import_react24.useCallback)(
|
|
2687
2967
|
(column, extendSort = false, sortType) => {
|
|
2688
2968
|
if (dataSource) {
|
|
2689
|
-
dataSource.sort = (0,
|
|
2969
|
+
dataSource.sort = (0, import_vuu_utils21.applySort)(
|
|
2690
2970
|
dataSource.sort,
|
|
2691
2971
|
column,
|
|
2692
2972
|
extendSort,
|
|
@@ -2696,23 +2976,25 @@ var useTable = ({
|
|
|
2696
2976
|
},
|
|
2697
2977
|
[dataSource]
|
|
2698
2978
|
);
|
|
2699
|
-
const
|
|
2979
|
+
const resizeCells = (0, import_react24.useRef)();
|
|
2980
|
+
const onResizeColumn = (0, import_react24.useCallback)(
|
|
2700
2981
|
(phase, columnName, width) => {
|
|
2982
|
+
var _a, _b, _c;
|
|
2701
2983
|
const column = columns.find((column2) => column2.name === columnName);
|
|
2702
2984
|
if (column) {
|
|
2703
2985
|
if (phase === "resize") {
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
}
|
|
2986
|
+
(_a = resizeCells.current) == null ? void 0 : _a.forEach((cell) => {
|
|
2987
|
+
cell.style.width = `${width}px`;
|
|
2988
|
+
});
|
|
2707
2989
|
} else if (phase === "end") {
|
|
2708
|
-
|
|
2990
|
+
resizeCells.current = void 0;
|
|
2991
|
+
if ((0, import_vuu_utils21.isValidNumber)(width)) {
|
|
2709
2992
|
dispatchColumnAction({
|
|
2710
2993
|
type: "resizeColumn",
|
|
2711
2994
|
phase,
|
|
2712
2995
|
column,
|
|
2713
2996
|
width
|
|
2714
2997
|
});
|
|
2715
|
-
setStateColumns(void 0);
|
|
2716
2998
|
onConfigChange == null ? void 0 : onConfigChange(
|
|
2717
2999
|
stripInternalProperties(
|
|
2718
3000
|
updateTableConfig(tableConfig, {
|
|
@@ -2724,7 +3006,12 @@ var useTable = ({
|
|
|
2724
3006
|
);
|
|
2725
3007
|
}
|
|
2726
3008
|
} else {
|
|
2727
|
-
|
|
3009
|
+
const byColIndex = `[aria-colindex='${column.index}']`;
|
|
3010
|
+
resizeCells.current = Array.from(
|
|
3011
|
+
(_c = (_b = containerRef.current) == null ? void 0 : _b.querySelectorAll(
|
|
3012
|
+
`.vuuTableCell${byColIndex},.vuuTableHeaderCell${byColIndex}`
|
|
3013
|
+
)) != null ? _c : []
|
|
3014
|
+
);
|
|
2728
3015
|
dispatchColumnAction({
|
|
2729
3016
|
type: "resizeColumn",
|
|
2730
3017
|
phase,
|
|
@@ -2738,12 +3025,12 @@ var useTable = ({
|
|
|
2738
3025
|
);
|
|
2739
3026
|
}
|
|
2740
3027
|
},
|
|
2741
|
-
[columns,
|
|
3028
|
+
[columns, dispatchColumnAction, onConfigChange, tableConfig, containerRef]
|
|
2742
3029
|
);
|
|
2743
|
-
const onToggleGroup = (0,
|
|
3030
|
+
const onToggleGroup = (0, import_react24.useCallback)(
|
|
2744
3031
|
(row, column) => {
|
|
2745
3032
|
var _a, _b;
|
|
2746
|
-
const isJson = (0,
|
|
3033
|
+
const isJson = (0, import_vuu_utils21.isJsonGroup)(column, row, columnMap);
|
|
2747
3034
|
const key = row[KEY];
|
|
2748
3035
|
if (row[IS_EXPANDED2]) {
|
|
2749
3036
|
dataSource.closeTreeNode(key, true);
|
|
@@ -2775,22 +3062,8 @@ var useTable = ({
|
|
|
2775
3062
|
}
|
|
2776
3063
|
}
|
|
2777
3064
|
},
|
|
2778
|
-
[columns, dataSource, dispatchColumnAction]
|
|
2779
|
-
);
|
|
2780
|
-
const handleVerticalScroll = (0, import_react23.useCallback)(
|
|
2781
|
-
(_, pctScrollTop) => {
|
|
2782
|
-
setPctScrollTop(pctScrollTop);
|
|
2783
|
-
},
|
|
2784
|
-
[setPctScrollTop]
|
|
3065
|
+
[columnMap, columns, dataSource, dispatchColumnAction]
|
|
2785
3066
|
);
|
|
2786
|
-
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2787
|
-
getRowAtPosition,
|
|
2788
|
-
rowHeight,
|
|
2789
|
-
scrollingApiRef,
|
|
2790
|
-
setRange,
|
|
2791
|
-
onVerticalScroll: handleVerticalScroll,
|
|
2792
|
-
viewportMeasurements
|
|
2793
|
-
});
|
|
2794
3067
|
const {
|
|
2795
3068
|
highlightedIndexRef,
|
|
2796
3069
|
navigate,
|
|
@@ -2817,7 +3090,7 @@ var useTable = ({
|
|
|
2817
3090
|
} = useCellEditing({
|
|
2818
3091
|
navigate
|
|
2819
3092
|
});
|
|
2820
|
-
const handleFocus = (0,
|
|
3093
|
+
const handleFocus = (0, import_react24.useCallback)(
|
|
2821
3094
|
(e) => {
|
|
2822
3095
|
navigationFocus();
|
|
2823
3096
|
if (!e.defaultPrevented) {
|
|
@@ -2832,15 +3105,15 @@ var useTable = ({
|
|
|
2832
3105
|
dataSource,
|
|
2833
3106
|
getSelectedRows
|
|
2834
3107
|
});
|
|
2835
|
-
const onMoveGroupColumn = (0,
|
|
3108
|
+
const onMoveGroupColumn = (0, import_react24.useCallback)(
|
|
2836
3109
|
(columns2) => {
|
|
2837
3110
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2838
3111
|
},
|
|
2839
3112
|
[dataSource]
|
|
2840
3113
|
);
|
|
2841
|
-
const onRemoveGroupColumn = (0,
|
|
3114
|
+
const onRemoveGroupColumn = (0, import_react24.useCallback)(
|
|
2842
3115
|
(column) => {
|
|
2843
|
-
if ((0,
|
|
3116
|
+
if ((0, import_vuu_utils21.isGroupColumn)(column)) {
|
|
2844
3117
|
dataSource.groupBy = [];
|
|
2845
3118
|
} else {
|
|
2846
3119
|
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
@@ -2852,7 +3125,7 @@ var useTable = ({
|
|
|
2852
3125
|
},
|
|
2853
3126
|
[dataSource]
|
|
2854
3127
|
);
|
|
2855
|
-
const handleSelectionChange = (0,
|
|
3128
|
+
const handleSelectionChange = (0, import_react24.useCallback)(
|
|
2856
3129
|
(selected) => {
|
|
2857
3130
|
dataSource.select(selected);
|
|
2858
3131
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
@@ -2868,7 +3141,7 @@ var useTable = ({
|
|
|
2868
3141
|
onSelectionChange: handleSelectionChange,
|
|
2869
3142
|
selectionModel
|
|
2870
3143
|
});
|
|
2871
|
-
const handleKeyDown = (0,
|
|
3144
|
+
const handleKeyDown = (0, import_react24.useCallback)(
|
|
2872
3145
|
(e) => {
|
|
2873
3146
|
navigationKeyDown(e);
|
|
2874
3147
|
if (!e.defaultPrevented) {
|
|
@@ -2880,25 +3153,15 @@ var useTable = ({
|
|
|
2880
3153
|
},
|
|
2881
3154
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2882
3155
|
);
|
|
2883
|
-
const handleRowClick = (0,
|
|
3156
|
+
const handleRowClick = (0, import_react24.useCallback)(
|
|
2884
3157
|
(row, rangeSelect, keepExistingSelection) => {
|
|
2885
3158
|
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2886
3159
|
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
2887
3160
|
},
|
|
2888
3161
|
[onRowClickProp, selectionHookOnRowClick]
|
|
2889
3162
|
);
|
|
2890
|
-
(0,
|
|
2891
|
-
dispatchColumnAction({
|
|
2892
|
-
type: "init",
|
|
2893
|
-
tableConfig: config,
|
|
2894
|
-
dataSource
|
|
2895
|
-
});
|
|
2896
|
-
}, [config, dataSource, dispatchColumnAction]);
|
|
2897
|
-
const onMoveColumn = (0, import_react23.useCallback)(
|
|
3163
|
+
const onMoveColumn = (0, import_react24.useCallback)(
|
|
2898
3164
|
(columns2) => {
|
|
2899
|
-
console.log(`useTable onMoveColumn`, {
|
|
2900
|
-
columns: columns2
|
|
2901
|
-
});
|
|
2902
3165
|
const newTableConfig = {
|
|
2903
3166
|
...tableConfig,
|
|
2904
3167
|
columns: columns2
|
|
@@ -2912,20 +3175,20 @@ var useTable = ({
|
|
|
2912
3175
|
},
|
|
2913
3176
|
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2914
3177
|
);
|
|
2915
|
-
const handleDropRow = (0,
|
|
3178
|
+
const handleDropRow = (0, import_react24.useCallback)(
|
|
2916
3179
|
(dragDropState) => {
|
|
2917
3180
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2918
3181
|
},
|
|
2919
3182
|
[onDrop]
|
|
2920
3183
|
);
|
|
2921
|
-
const handleDataEdited = (0,
|
|
3184
|
+
const handleDataEdited = (0, import_react24.useCallback)(
|
|
2922
3185
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2923
3186
|
[dataSource]
|
|
2924
3187
|
);
|
|
2925
|
-
const handleDragStartRow = (0,
|
|
3188
|
+
const handleDragStartRow = (0, import_react24.useCallback)(
|
|
2926
3189
|
(dragDropState) => {
|
|
2927
3190
|
const { initialDragElement } = dragDropState;
|
|
2928
|
-
const rowIndex = (0,
|
|
3191
|
+
const rowIndex = (0, import_vuu_utils21.getIndexFromRowElement)(initialDragElement);
|
|
2929
3192
|
const row = dataRef.current.find((row2) => row2[0] === rowIndex);
|
|
2930
3193
|
if (row) {
|
|
2931
3194
|
dragDropState.setPayload(row);
|
|
@@ -2979,133 +3242,6 @@ var useTable = ({
|
|
|
2979
3242
|
};
|
|
2980
3243
|
};
|
|
2981
3244
|
|
|
2982
|
-
// src/table-header/TableHeader.tsx
|
|
2983
|
-
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
2984
|
-
var import_clsx8 = __toESM(require("clsx"));
|
|
2985
|
-
|
|
2986
|
-
// src/table-header/useTableHeader.ts
|
|
2987
|
-
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
2988
|
-
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
2989
|
-
var import_react24 = require("react");
|
|
2990
|
-
var useTableHeader = ({
|
|
2991
|
-
columns,
|
|
2992
|
-
onMoveColumn,
|
|
2993
|
-
onSortColumn,
|
|
2994
|
-
tableConfig
|
|
2995
|
-
}) => {
|
|
2996
|
-
const containerRef = (0, import_react24.useRef)(null);
|
|
2997
|
-
const handleDropColumnHeader = (0, import_react24.useCallback)(
|
|
2998
|
-
(moveFrom, moveTo) => {
|
|
2999
|
-
const column = columns[moveFrom];
|
|
3000
|
-
const orderedColumns = (0, import_vuu_utils20.moveColumnTo)(columns, column, moveTo);
|
|
3001
|
-
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
3002
|
-
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
3003
|
-
const nextColumn = orderedColumns[targetIndex + 1];
|
|
3004
|
-
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
3005
|
-
if (moveTo > moveFrom && insertPos !== -1) {
|
|
3006
|
-
onMoveColumn((0, import_vuu_utils20.moveColumnTo)(tableConfig.columns, column, insertPos - 1));
|
|
3007
|
-
} else {
|
|
3008
|
-
onMoveColumn((0, import_vuu_utils20.moveColumnTo)(tableConfig.columns, column, insertPos));
|
|
3009
|
-
}
|
|
3010
|
-
},
|
|
3011
|
-
[columns, onMoveColumn, tableConfig.columns]
|
|
3012
|
-
);
|
|
3013
|
-
const handleColumnHeaderClick = (0, import_react24.useCallback)(
|
|
3014
|
-
(evt) => {
|
|
3015
|
-
var _a;
|
|
3016
|
-
const targetElement = evt.target;
|
|
3017
|
-
const headerCell = targetElement.closest(
|
|
3018
|
-
".vuuTableHeaderCell"
|
|
3019
|
-
);
|
|
3020
|
-
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
3021
|
-
const column = (0, import_vuu_utils20.visibleColumnAtIndex)(columns, colIdx);
|
|
3022
|
-
const isAdditive = evt.shiftKey;
|
|
3023
|
-
column && onSortColumn(column, isAdditive);
|
|
3024
|
-
},
|
|
3025
|
-
[columns, onSortColumn]
|
|
3026
|
-
);
|
|
3027
|
-
const {
|
|
3028
|
-
onMouseDown: columnHeaderDragMouseDown,
|
|
3029
|
-
draggable: draggableColumn,
|
|
3030
|
-
...dragDropHook
|
|
3031
|
-
} = (0, import_vuu_ui_controls3.useDragDrop)({
|
|
3032
|
-
allowDragDrop: true,
|
|
3033
|
-
containerRef,
|
|
3034
|
-
draggableClassName: `vuuTable`,
|
|
3035
|
-
onDrop: handleDropColumnHeader,
|
|
3036
|
-
orientation: "horizontal",
|
|
3037
|
-
itemQuery: ".vuuTableHeaderCell"
|
|
3038
|
-
});
|
|
3039
|
-
return {
|
|
3040
|
-
containerRef,
|
|
3041
|
-
draggableColumn,
|
|
3042
|
-
draggedColumnIndex: dragDropHook.draggedItemIndex,
|
|
3043
|
-
onClick: handleColumnHeaderClick,
|
|
3044
|
-
onMouseDown: columnHeaderDragMouseDown
|
|
3045
|
-
};
|
|
3046
|
-
};
|
|
3047
|
-
|
|
3048
|
-
// src/table-header/TableHeader.tsx
|
|
3049
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3050
|
-
var TableHeader = ({
|
|
3051
|
-
classBase: classBase10 = "vuuTable",
|
|
3052
|
-
columns,
|
|
3053
|
-
headings,
|
|
3054
|
-
onMoveColumn,
|
|
3055
|
-
onMoveGroupColumn,
|
|
3056
|
-
onRemoveGroupColumn,
|
|
3057
|
-
onResizeColumn,
|
|
3058
|
-
onSortColumn,
|
|
3059
|
-
tableConfig,
|
|
3060
|
-
tableId
|
|
3061
|
-
}) => {
|
|
3062
|
-
const {
|
|
3063
|
-
containerRef,
|
|
3064
|
-
draggableColumn,
|
|
3065
|
-
draggedColumnIndex,
|
|
3066
|
-
onClick,
|
|
3067
|
-
onMouseDown
|
|
3068
|
-
} = useTableHeader({
|
|
3069
|
-
columns,
|
|
3070
|
-
onMoveColumn,
|
|
3071
|
-
onSortColumn,
|
|
3072
|
-
tableConfig
|
|
3073
|
-
});
|
|
3074
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headings`, ref: containerRef, children: [
|
|
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)),
|
|
3076
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
3077
|
-
columns.filter(import_vuu_utils21.isNotHidden).map(
|
|
3078
|
-
(col, i) => (0, import_vuu_utils21.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3079
|
-
GroupHeaderCellNext,
|
|
3080
|
-
{
|
|
3081
|
-
column: col,
|
|
3082
|
-
"data-index": i,
|
|
3083
|
-
onMoveColumn: onMoveGroupColumn,
|
|
3084
|
-
onRemoveColumn: onRemoveGroupColumn,
|
|
3085
|
-
onResize: onResizeColumn
|
|
3086
|
-
},
|
|
3087
|
-
col.name
|
|
3088
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3089
|
-
HeaderCell,
|
|
3090
|
-
{
|
|
3091
|
-
className: (0, import_clsx8.default)({
|
|
3092
|
-
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
3093
|
-
}),
|
|
3094
|
-
column: col,
|
|
3095
|
-
"data-index": i,
|
|
3096
|
-
id: `${tableId}-col-${i}`,
|
|
3097
|
-
onClick,
|
|
3098
|
-
onMouseDown,
|
|
3099
|
-
onResize: onResizeColumn
|
|
3100
|
-
},
|
|
3101
|
-
col.name
|
|
3102
|
-
)
|
|
3103
|
-
),
|
|
3104
|
-
draggableColumn
|
|
3105
|
-
] })
|
|
3106
|
-
] });
|
|
3107
|
-
};
|
|
3108
|
-
|
|
3109
3245
|
// src/Table.tsx
|
|
3110
3246
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3111
3247
|
var classBase7 = "vuuTable";
|
|
@@ -3191,9 +3327,7 @@ var TableCore = ({
|
|
|
3191
3327
|
const contentContainerClassName = (0, import_clsx9.default)(`${classBase7}-contentContainer`, {
|
|
3192
3328
|
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3193
3329
|
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3194
|
-
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
3195
3330
|
[`${classBase7}-zebra`]: tableAttributes.zebraStripes
|
|
3196
|
-
// [`${classBase}-loading`]: isDataLoading(tableProps.columns),
|
|
3197
3331
|
});
|
|
3198
3332
|
const cssVariables = {
|
|
3199
3333
|
"--content-height": `${viewportMeasurements.contentHeight}px`,
|
|
@@ -3239,7 +3373,7 @@ var TableCore = ({
|
|
|
3239
3373
|
showColumnHeaders ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3240
3374
|
TableHeader,
|
|
3241
3375
|
{
|
|
3242
|
-
columns,
|
|
3376
|
+
columns: scrollProps.columnsWithinViewport,
|
|
3243
3377
|
headings,
|
|
3244
3378
|
onMoveColumn,
|
|
3245
3379
|
onMoveGroupColumn,
|
|
@@ -3247,7 +3381,8 @@ var TableCore = ({
|
|
|
3247
3381
|
onResizeColumn,
|
|
3248
3382
|
onSortColumn,
|
|
3249
3383
|
tableConfig,
|
|
3250
|
-
tableId: id
|
|
3384
|
+
tableId: id,
|
|
3385
|
+
virtualColSpan: scrollProps.virtualColSpan
|
|
3251
3386
|
}
|
|
3252
3387
|
) : null,
|
|
3253
3388
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase7}-body`, children: data.map((data2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -3255,13 +3390,14 @@ var TableCore = ({
|
|
|
3255
3390
|
{
|
|
3256
3391
|
"aria-rowindex": data2[0] + 1,
|
|
3257
3392
|
columnMap,
|
|
3258
|
-
columns,
|
|
3393
|
+
columns: scrollProps.columnsWithinViewport,
|
|
3259
3394
|
highlighted: highlightedIndex === data2[IDX3],
|
|
3260
3395
|
onClick: onRowClick,
|
|
3261
3396
|
onDataEdited,
|
|
3262
3397
|
row: data2,
|
|
3263
3398
|
offset: getRowOffset(data2),
|
|
3264
3399
|
onToggleGroup,
|
|
3400
|
+
virtualColSpan: scrollProps.virtualColSpan,
|
|
3265
3401
|
zebraStripes: tableAttributes.zebraStripes
|
|
3266
3402
|
},
|
|
3267
3403
|
data2[RENDER_IDX]
|
|
@@ -3316,7 +3452,7 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
|
3316
3452
|
throw Error("vuu Table requires dataSource prop");
|
|
3317
3453
|
}
|
|
3318
3454
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3319
|
-
|
|
3455
|
+
import_vuu_ui_controls5.MeasuredContainer,
|
|
3320
3456
|
{
|
|
3321
3457
|
...htmlAttributes,
|
|
3322
3458
|
className: (0, import_clsx9.default)(classBase7, classNameProp),
|
|
@@ -3360,17 +3496,12 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
|
3360
3496
|
|
|
3361
3497
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3362
3498
|
var import_react26 = require("react");
|
|
3363
|
-
var
|
|
3499
|
+
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
3364
3500
|
var import_core3 = require("@salt-ds/core");
|
|
3365
|
-
|
|
3366
|
-
// src/cell-renderers/cell-utils.ts
|
|
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]]);
|
|
3368
|
-
|
|
3369
|
-
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3370
3501
|
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3371
3502
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3372
3503
|
var CheckboxCell = (0, import_react26.memo)(
|
|
3373
|
-
({ column, columnMap, onCommit =
|
|
3504
|
+
({ column, columnMap, onCommit = import_vuu_ui_controls6.WarnCommit, row }) => {
|
|
3374
3505
|
const dataIdx = columnMap[column.name];
|
|
3375
3506
|
const isChecked = row[dataIdx];
|
|
3376
3507
|
const handleCommit = (0, import_react26.useCallback)(
|
|
@@ -3383,9 +3514,9 @@ var CheckboxCell = (0, import_react26.memo)(
|
|
|
3383
3514
|
},
|
|
3384
3515
|
[onCommit]
|
|
3385
3516
|
);
|
|
3386
|
-
return column.editable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core3.Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3517
|
+
return column.editable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core3.Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_vuu_ui_controls6.CheckboxIcon, { checked: isChecked, disabled: true });
|
|
3387
3518
|
},
|
|
3388
|
-
dataAndColumnUnchanged
|
|
3519
|
+
import_vuu_utils23.dataAndColumnUnchanged
|
|
3389
3520
|
);
|
|
3390
3521
|
CheckboxCell.displayName = "CheckboxCell";
|
|
3391
3522
|
(0, import_vuu_utils23.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
|
|
@@ -3395,7 +3526,7 @@ CheckboxCell.displayName = "CheckboxCell";
|
|
|
3395
3526
|
// src/cell-renderers/input-cell/InputCell.tsx
|
|
3396
3527
|
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
3397
3528
|
var import_core4 = require("@salt-ds/core");
|
|
3398
|
-
var
|
|
3529
|
+
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3399
3530
|
var import_clsx10 = __toESM(require("clsx"));
|
|
3400
3531
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3401
3532
|
var classBase8 = "vuuTableInputCell";
|
|
@@ -3413,7 +3544,7 @@ var InputCell = ({
|
|
|
3413
3544
|
}) => {
|
|
3414
3545
|
const dataIdx = columnMap[column.name];
|
|
3415
3546
|
const { align = "left", clientSideEditValidationCheck } = column;
|
|
3416
|
-
const { warningMessage, ...editProps } = (0,
|
|
3547
|
+
const { warningMessage, ...editProps } = (0, import_vuu_ui_controls7.useEditableText)({
|
|
3417
3548
|
initialValue: row[dataIdx],
|
|
3418
3549
|
onCommit,
|
|
3419
3550
|
clientSideEditValidationCheck
|
|
@@ -3435,11 +3566,11 @@ var InputCell = ({
|
|
|
3435
3566
|
(0, import_vuu_utils24.registerComponent)("input-cell", InputCell, "cell-renderer", {});
|
|
3436
3567
|
|
|
3437
3568
|
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3438
|
-
var
|
|
3569
|
+
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3439
3570
|
var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
|
|
3440
3571
|
var import_clsx11 = __toESM(require("clsx"));
|
|
3441
3572
|
var import_react27 = require("react");
|
|
3442
|
-
var
|
|
3573
|
+
var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
|
|
3443
3574
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3444
3575
|
var classBase9 = "vuuTableToggleCell";
|
|
3445
3576
|
var getValueList = ({ name, type }) => {
|
|
@@ -3455,7 +3586,7 @@ var ToggleCell = (0, import_react27.memo)(
|
|
|
3455
3586
|
function ToggleCell2({
|
|
3456
3587
|
column,
|
|
3457
3588
|
columnMap,
|
|
3458
|
-
onCommit =
|
|
3589
|
+
onCommit = import_vuu_ui_controls8.WarnCommit,
|
|
3459
3590
|
row
|
|
3460
3591
|
}) {
|
|
3461
3592
|
const values = getValueList(column);
|
|
@@ -3473,7 +3604,7 @@ var ToggleCell = (0, import_react27.memo)(
|
|
|
3473
3604
|
[onCommit]
|
|
3474
3605
|
);
|
|
3475
3606
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3476
|
-
|
|
3607
|
+
import_vuu_ui_controls9.CycleStateButton,
|
|
3477
3608
|
{
|
|
3478
3609
|
className: (0, import_clsx11.default)(classBase9, `${classBase9}-${column.name}`),
|
|
3479
3610
|
onCommit: handleCommit,
|
|
@@ -3484,17 +3615,17 @@ var ToggleCell = (0, import_react27.memo)(
|
|
|
3484
3615
|
}
|
|
3485
3616
|
);
|
|
3486
3617
|
},
|
|
3487
|
-
dataAndColumnUnchanged
|
|
3618
|
+
import_vuu_utils25.dataAndColumnUnchanged
|
|
3488
3619
|
);
|
|
3489
3620
|
(0, import_vuu_utils25.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
3490
3621
|
|
|
3491
3622
|
// src/useControlledTableNavigation.ts
|
|
3492
|
-
var
|
|
3623
|
+
var import_vuu_ui_controls10 = require("@vuu-ui/vuu-ui-controls");
|
|
3493
3624
|
var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
|
|
3494
3625
|
var import_react28 = require("react");
|
|
3495
3626
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3496
3627
|
const tableRef = (0, import_react28.useRef)(null);
|
|
3497
|
-
const [highlightedIndexRef, setHighlightedIndex] = (0,
|
|
3628
|
+
const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls10.useStateRef)(initialValue);
|
|
3498
3629
|
const handleKeyDown = (0, import_react28.useCallback)(
|
|
3499
3630
|
(e) => {
|
|
3500
3631
|
var _a;
|