@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/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/header-cell/GroupHeaderCellNext.tsx
|
|
2
|
-
import { OverflowContainer } from "@vuu-ui/vuu-
|
|
2
|
+
import { OverflowContainer } from "@vuu-ui/vuu-ui-controls";
|
|
3
3
|
import { useLayoutEffectSkipFirst } from "@vuu-ui/vuu-utils";
|
|
4
4
|
import cx3 from "clsx";
|
|
5
5
|
import { useCallback as useCallback4, useRef as useRef3, useState as useState2 } from "react";
|
|
@@ -82,7 +82,7 @@ var ColumnResizer = ({
|
|
|
82
82
|
onDragEnd = NOOP,
|
|
83
83
|
onDragStart = NOOP
|
|
84
84
|
}) => {
|
|
85
|
-
const
|
|
85
|
+
const positionRef = useRef({ start: 0, now: 0 });
|
|
86
86
|
const onMouseMove = useCallback2(
|
|
87
87
|
(e) => {
|
|
88
88
|
if (e.stopPropagation) {
|
|
@@ -91,11 +91,13 @@ var ColumnResizer = ({
|
|
|
91
91
|
if (e.preventDefault) {
|
|
92
92
|
e.preventDefault();
|
|
93
93
|
}
|
|
94
|
+
const { current: position } = positionRef;
|
|
94
95
|
const x = Math.round(e.clientX);
|
|
95
|
-
const moveBy = x - position.
|
|
96
|
-
position.
|
|
96
|
+
const moveBy = x - position.now;
|
|
97
|
+
const distanceMoved = position.now - position.start;
|
|
98
|
+
positionRef.current.now = x;
|
|
97
99
|
if (moveBy !== 0) {
|
|
98
|
-
onDrag(e, moveBy);
|
|
100
|
+
onDrag(e, moveBy, distanceMoved);
|
|
99
101
|
}
|
|
100
102
|
},
|
|
101
103
|
[onDrag]
|
|
@@ -104,14 +106,17 @@ var ColumnResizer = ({
|
|
|
104
106
|
(e) => {
|
|
105
107
|
window.removeEventListener("mouseup", onMouseUp);
|
|
106
108
|
window.removeEventListener("mousemove", onMouseMove);
|
|
107
|
-
|
|
109
|
+
const { current: position } = positionRef;
|
|
110
|
+
const distanceMoved = position.now - position.start;
|
|
111
|
+
onDragEnd(e, distanceMoved);
|
|
108
112
|
},
|
|
109
113
|
[onDragEnd, onMouseMove]
|
|
110
114
|
);
|
|
111
115
|
const handleMouseDown = useCallback2(
|
|
112
116
|
(e) => {
|
|
117
|
+
const { current: position } = positionRef;
|
|
113
118
|
onDragStart(e);
|
|
114
|
-
position.
|
|
119
|
+
position.now = position.start = Math.round(e.clientX);
|
|
115
120
|
window.addEventListener("mouseup", onMouseUp);
|
|
116
121
|
window.addEventListener("mousemove", onMouseMove);
|
|
117
122
|
if (e.stopPropagation) {
|
|
@@ -133,26 +138,27 @@ var useTableColumnResize = ({
|
|
|
133
138
|
onResize,
|
|
134
139
|
rootRef
|
|
135
140
|
}) => {
|
|
136
|
-
const widthRef = useRef2(0);
|
|
141
|
+
const widthRef = useRef2({ start: 0, now: 0 });
|
|
137
142
|
const [isResizing, setResizing] = useState(false);
|
|
138
143
|
const { name } = column;
|
|
139
144
|
const handleResizeStart = useCallback3(() => {
|
|
140
145
|
if (onResize && rootRef.current) {
|
|
141
|
-
const { width } =
|
|
142
|
-
|
|
146
|
+
const { current: width } = widthRef;
|
|
147
|
+
const { width: measuredWidth } = rootRef.current.getBoundingClientRect();
|
|
148
|
+
width.start = width.now = Math.round(measuredWidth);
|
|
143
149
|
setResizing(true);
|
|
144
150
|
onResize == null ? void 0 : onResize("begin", name);
|
|
145
151
|
}
|
|
146
152
|
}, [name, onResize, rootRef]);
|
|
147
153
|
const handleResize = useCallback3(
|
|
148
|
-
(_evt, moveBy) => {
|
|
154
|
+
(_evt, moveBy, totalDistanceMoved) => {
|
|
149
155
|
if (rootRef.current) {
|
|
150
156
|
if (onResize) {
|
|
151
|
-
const { width } =
|
|
152
|
-
const newWidth =
|
|
153
|
-
if (newWidth !==
|
|
157
|
+
const { current: width } = widthRef;
|
|
158
|
+
const newWidth = width.start + totalDistanceMoved;
|
|
159
|
+
if (newWidth !== width.now && newWidth > 0) {
|
|
154
160
|
onResize("resize", name, newWidth);
|
|
155
|
-
|
|
161
|
+
width.now = newWidth;
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
}
|
|
@@ -161,7 +167,8 @@ var useTableColumnResize = ({
|
|
|
161
167
|
);
|
|
162
168
|
const handleResizeEnd = useCallback3(() => {
|
|
163
169
|
if (onResize) {
|
|
164
|
-
|
|
170
|
+
const { current: width } = widthRef;
|
|
171
|
+
onResize("end", name, width.now);
|
|
165
172
|
setTimeout(() => {
|
|
166
173
|
setResizing(false);
|
|
167
174
|
}, 80);
|
|
@@ -276,7 +283,7 @@ var GroupHeaderCellNext = ({
|
|
|
276
283
|
{
|
|
277
284
|
...columnPillProps,
|
|
278
285
|
column,
|
|
279
|
-
key: column.
|
|
286
|
+
key: column.name
|
|
280
287
|
}
|
|
281
288
|
);
|
|
282
289
|
})
|
|
@@ -403,17 +410,17 @@ var HeaderCell = ({
|
|
|
403
410
|
};
|
|
404
411
|
|
|
405
412
|
// src/Table.tsx
|
|
413
|
+
import { ContextMenuProvider } from "@vuu-ui/vuu-popups";
|
|
406
414
|
import {
|
|
407
415
|
MeasuredContainer
|
|
408
|
-
} from "@vuu-ui/vuu-
|
|
409
|
-
import {
|
|
410
|
-
import { metadataKeys as metadataKeys7, useId } from "@vuu-ui/vuu-utils";
|
|
416
|
+
} from "@vuu-ui/vuu-ui-controls";
|
|
417
|
+
import { metadataKeys as metadataKeys6, useId } from "@vuu-ui/vuu-utils";
|
|
411
418
|
import { useForkRef } from "@salt-ds/core";
|
|
412
419
|
import cx9 from "clsx";
|
|
413
420
|
import {
|
|
414
421
|
forwardRef,
|
|
415
|
-
useRef as
|
|
416
|
-
useState as
|
|
422
|
+
useRef as useRef15,
|
|
423
|
+
useState as useState8
|
|
417
424
|
} from "react";
|
|
418
425
|
|
|
419
426
|
// src/Row.tsx
|
|
@@ -441,7 +448,7 @@ var TableCell = ({
|
|
|
441
448
|
row
|
|
442
449
|
}) => {
|
|
443
450
|
const { className, style } = useCell(column, classBase4);
|
|
444
|
-
const { CellRenderer, name, valueFormatter } = column;
|
|
451
|
+
const { CellRenderer, index, name, valueFormatter } = column;
|
|
445
452
|
const dataIdx = columnMap[name];
|
|
446
453
|
const handleDataItemEdited = useCallback7(
|
|
447
454
|
(value) => {
|
|
@@ -468,6 +475,7 @@ var TableCell = ({
|
|
|
468
475
|
return /* @__PURE__ */ jsx8(
|
|
469
476
|
"div",
|
|
470
477
|
{
|
|
478
|
+
"aria-colindex": index,
|
|
471
479
|
className,
|
|
472
480
|
onClick: onClick ? handleClick : void 0,
|
|
473
481
|
role: "cell",
|
|
@@ -492,9 +500,14 @@ import cx6 from "clsx";
|
|
|
492
500
|
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
493
501
|
var { IS_LEAF } = metadataKeys;
|
|
494
502
|
var classBase5 = "vuuTableGroupCell";
|
|
495
|
-
var TableGroupCell = ({
|
|
503
|
+
var TableGroupCell = ({
|
|
504
|
+
column,
|
|
505
|
+
columnMap,
|
|
506
|
+
onClick,
|
|
507
|
+
row
|
|
508
|
+
}) => {
|
|
496
509
|
const { columns } = column;
|
|
497
|
-
const [value, offset] = getGroupValueAndOffset(columns, row);
|
|
510
|
+
const [value, offset] = getGroupValueAndOffset(columns, row, columnMap);
|
|
498
511
|
const { className, style } = useCell(column, classBase5);
|
|
499
512
|
const handleClick = useCallback8(
|
|
500
513
|
(evt) => {
|
|
@@ -521,8 +534,7 @@ var TableGroupCell = ({ column, onClick, row }) => {
|
|
|
521
534
|
};
|
|
522
535
|
|
|
523
536
|
// src/Row.tsx
|
|
524
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
525
|
-
import { createElement as createElement2 } from "react";
|
|
537
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
526
538
|
var { IDX, IS_EXPANDED, SELECTED } = metadataKeys2;
|
|
527
539
|
var classBase6 = "vuuTableRow";
|
|
528
540
|
var Row = memo(
|
|
@@ -536,6 +548,7 @@ var Row = memo(
|
|
|
536
548
|
onClick,
|
|
537
549
|
onDataEdited,
|
|
538
550
|
onToggleGroup,
|
|
551
|
+
virtualColSpan = 0,
|
|
539
552
|
zebraStripes = false,
|
|
540
553
|
...htmlAttributes
|
|
541
554
|
}) => {
|
|
@@ -564,66 +577,223 @@ var Row = memo(
|
|
|
564
577
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
565
578
|
const handleGroupCellClick = useCallback9(
|
|
566
579
|
(evt, column) => {
|
|
567
|
-
if (isGroupColumn(column) || isJsonGroup(column, row)) {
|
|
580
|
+
if (isGroupColumn(column) || isJsonGroup(column, row, columnMap)) {
|
|
568
581
|
evt.stopPropagation();
|
|
569
582
|
onToggleGroup == null ? void 0 : onToggleGroup(row, column);
|
|
570
583
|
}
|
|
571
584
|
},
|
|
572
|
-
[onToggleGroup, row]
|
|
585
|
+
[columnMap, onToggleGroup, row]
|
|
573
586
|
);
|
|
574
|
-
return /* @__PURE__ */
|
|
587
|
+
return /* @__PURE__ */ jsxs7(
|
|
575
588
|
"div",
|
|
576
589
|
{
|
|
577
590
|
...htmlAttributes,
|
|
578
|
-
key: `row-${row[0]}`,
|
|
579
591
|
role: "row",
|
|
580
592
|
className,
|
|
581
593
|
onClick: handleRowClick,
|
|
582
|
-
style
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
594
|
+
style,
|
|
595
|
+
children: [
|
|
596
|
+
/* @__PURE__ */ jsx10("span", { className: `${classBase6}-selectionDecorator vuuStickyLeft` }),
|
|
597
|
+
virtualColSpan > 0 ? /* @__PURE__ */ jsx10("div", { className: "vuuTableCell", style: { width: virtualColSpan } }) : null,
|
|
598
|
+
columns.filter(isNotHidden).map((column) => {
|
|
599
|
+
const isGroup = isGroupColumn(column);
|
|
600
|
+
const isJsonCell = isJsonColumn(column);
|
|
601
|
+
const Cell = isGroup ? TableGroupCell : TableCell;
|
|
602
|
+
return /* @__PURE__ */ jsx10(
|
|
603
|
+
Cell,
|
|
604
|
+
{
|
|
605
|
+
column,
|
|
606
|
+
columnMap,
|
|
607
|
+
onClick: isGroup || isJsonCell ? handleGroupCellClick : void 0,
|
|
608
|
+
onDataEdited,
|
|
609
|
+
row
|
|
610
|
+
},
|
|
611
|
+
column.name
|
|
612
|
+
);
|
|
613
|
+
}),
|
|
614
|
+
/* @__PURE__ */ jsx10("span", { className: `${classBase6}-selectionDecorator vuuStickyRight` })
|
|
615
|
+
]
|
|
616
|
+
}
|
|
602
617
|
);
|
|
603
618
|
}
|
|
604
619
|
);
|
|
605
620
|
Row.displayName = "Row";
|
|
606
621
|
|
|
607
|
-
// src/
|
|
622
|
+
// src/table-header/TableHeader.tsx
|
|
623
|
+
import { isGroupColumn as isGroupColumn2, isNotHidden as isNotHidden2 } from "@vuu-ui/vuu-utils";
|
|
624
|
+
import cx8 from "clsx";
|
|
625
|
+
import { memo as memo2 } from "react";
|
|
626
|
+
|
|
627
|
+
// src/table-header/useTableHeader.ts
|
|
608
628
|
import {
|
|
609
629
|
useDragDrop
|
|
610
630
|
} from "@vuu-ui/vuu-ui-controls";
|
|
631
|
+
import { moveColumnTo, visibleColumnAtIndex } from "@vuu-ui/vuu-utils";
|
|
632
|
+
import { useCallback as useCallback10, useRef as useRef6 } from "react";
|
|
633
|
+
var useTableHeader = ({
|
|
634
|
+
columns,
|
|
635
|
+
onMoveColumn,
|
|
636
|
+
onSortColumn,
|
|
637
|
+
tableConfig
|
|
638
|
+
}) => {
|
|
639
|
+
const containerRef = useRef6(null);
|
|
640
|
+
const scrollingContainerRef = useRef6(null);
|
|
641
|
+
const setContainerRef = useCallback10((el) => {
|
|
642
|
+
containerRef.current = el;
|
|
643
|
+
if (el) {
|
|
644
|
+
scrollingContainerRef.current = el.closest(".vuuTable-contentContainer");
|
|
645
|
+
} else {
|
|
646
|
+
scrollingContainerRef.current = null;
|
|
647
|
+
}
|
|
648
|
+
}, []);
|
|
649
|
+
const handleDropColumnHeader = useCallback10(
|
|
650
|
+
({ fromIndex: moveFrom, toIndex: moveTo }) => {
|
|
651
|
+
const column = columns[moveFrom];
|
|
652
|
+
const orderedColumns = moveColumnTo(columns, column, moveTo);
|
|
653
|
+
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
654
|
+
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
655
|
+
const nextColumn = orderedColumns[targetIndex + 1];
|
|
656
|
+
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
657
|
+
if (moveTo > moveFrom && insertPos !== -1) {
|
|
658
|
+
onMoveColumn(moveColumnTo(tableConfig.columns, column, insertPos - 1));
|
|
659
|
+
} else {
|
|
660
|
+
onMoveColumn(moveColumnTo(tableConfig.columns, column, insertPos));
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
[columns, onMoveColumn, tableConfig.columns]
|
|
664
|
+
);
|
|
665
|
+
const handleColumnHeaderClick = useCallback10(
|
|
666
|
+
(evt) => {
|
|
667
|
+
var _a;
|
|
668
|
+
const targetElement = evt.target;
|
|
669
|
+
const headerCell = targetElement.closest(
|
|
670
|
+
".vuuTableHeaderCell"
|
|
671
|
+
);
|
|
672
|
+
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
673
|
+
const column = visibleColumnAtIndex(columns, colIdx);
|
|
674
|
+
const isAdditive = evt.shiftKey;
|
|
675
|
+
column && onSortColumn(column, isAdditive);
|
|
676
|
+
},
|
|
677
|
+
[columns, onSortColumn]
|
|
678
|
+
);
|
|
679
|
+
const {
|
|
680
|
+
onMouseDown: columnHeaderDragMouseDown,
|
|
681
|
+
draggable: draggableColumn,
|
|
682
|
+
...dragDropHook
|
|
683
|
+
} = useDragDrop({
|
|
684
|
+
allowDragDrop: true,
|
|
685
|
+
containerRef,
|
|
686
|
+
draggableClassName: `vuuTable`,
|
|
687
|
+
itemQuery: ".vuuTableHeaderCell",
|
|
688
|
+
onDrop: handleDropColumnHeader,
|
|
689
|
+
orientation: "horizontal",
|
|
690
|
+
scrollingContainerRef
|
|
691
|
+
});
|
|
692
|
+
return {
|
|
693
|
+
draggableColumn,
|
|
694
|
+
draggedColumnIndex: dragDropHook.draggedItemIndex,
|
|
695
|
+
onClick: handleColumnHeaderClick,
|
|
696
|
+
onMouseDown: columnHeaderDragMouseDown,
|
|
697
|
+
setContainerRef
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
// src/table-header/TableHeader.tsx
|
|
702
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
703
|
+
var TableHeader = memo2(
|
|
704
|
+
({
|
|
705
|
+
classBase: classBase10 = "vuuTable",
|
|
706
|
+
columns,
|
|
707
|
+
headings,
|
|
708
|
+
onMoveColumn,
|
|
709
|
+
onMoveGroupColumn,
|
|
710
|
+
onRemoveGroupColumn,
|
|
711
|
+
onResizeColumn,
|
|
712
|
+
onSortColumn,
|
|
713
|
+
tableConfig,
|
|
714
|
+
tableId,
|
|
715
|
+
virtualColSpan = 0
|
|
716
|
+
}) => {
|
|
717
|
+
const {
|
|
718
|
+
draggableColumn,
|
|
719
|
+
draggedColumnIndex,
|
|
720
|
+
onClick,
|
|
721
|
+
onMouseDown,
|
|
722
|
+
setContainerRef
|
|
723
|
+
} = useTableHeader({
|
|
724
|
+
columns,
|
|
725
|
+
onMoveColumn,
|
|
726
|
+
onSortColumn,
|
|
727
|
+
tableConfig
|
|
728
|
+
});
|
|
729
|
+
return /* @__PURE__ */ jsxs8("div", { className: `${classBase10}-col-headings`, ref: setContainerRef, children: [
|
|
730
|
+
headings.map((colHeaders, i) => /* @__PURE__ */ jsx11("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ jsx11("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
|
|
731
|
+
/* @__PURE__ */ jsxs8("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
732
|
+
virtualColSpan > 0 ? /* @__PURE__ */ jsx11(
|
|
733
|
+
"div",
|
|
734
|
+
{
|
|
735
|
+
role: "cell",
|
|
736
|
+
className: "vuuTableCell",
|
|
737
|
+
style: { width: virtualColSpan }
|
|
738
|
+
}
|
|
739
|
+
) : null,
|
|
740
|
+
columns.filter(isNotHidden2).map(
|
|
741
|
+
(col, i) => isGroupColumn2(col) ? /* @__PURE__ */ jsx11(
|
|
742
|
+
GroupHeaderCellNext,
|
|
743
|
+
{
|
|
744
|
+
"aria-colindex": col.index,
|
|
745
|
+
column: col,
|
|
746
|
+
"data-index": i,
|
|
747
|
+
onMoveColumn: onMoveGroupColumn,
|
|
748
|
+
onRemoveColumn: onRemoveGroupColumn,
|
|
749
|
+
onResize: onResizeColumn
|
|
750
|
+
},
|
|
751
|
+
col.name
|
|
752
|
+
) : /* @__PURE__ */ jsx11(
|
|
753
|
+
HeaderCell,
|
|
754
|
+
{
|
|
755
|
+
"aria-colindex": col.index,
|
|
756
|
+
className: cx8({
|
|
757
|
+
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
758
|
+
}),
|
|
759
|
+
column: col,
|
|
760
|
+
"data-index": i,
|
|
761
|
+
id: `${tableId}-col-${i}`,
|
|
762
|
+
onClick,
|
|
763
|
+
onMouseDown,
|
|
764
|
+
onResize: onResizeColumn
|
|
765
|
+
},
|
|
766
|
+
col.name
|
|
767
|
+
)
|
|
768
|
+
),
|
|
769
|
+
draggableColumn
|
|
770
|
+
] })
|
|
771
|
+
] });
|
|
772
|
+
}
|
|
773
|
+
);
|
|
774
|
+
TableHeader.displayName = "TableHeader";
|
|
775
|
+
|
|
776
|
+
// src/useTable.ts
|
|
777
|
+
import {
|
|
778
|
+
useDragDrop as useDragDrop2
|
|
779
|
+
} from "@vuu-ui/vuu-ui-controls";
|
|
611
780
|
import {
|
|
612
781
|
applySort,
|
|
613
782
|
buildColumnMap as buildColumnMap2,
|
|
614
783
|
getIndexFromRowElement as getIndexFromRowElement3,
|
|
615
|
-
isGroupColumn as
|
|
784
|
+
isGroupColumn as isGroupColumn4,
|
|
616
785
|
isJsonGroup as isJsonGroup2,
|
|
617
786
|
isValidNumber,
|
|
618
|
-
metadataKeys as
|
|
787
|
+
metadataKeys as metadataKeys5,
|
|
619
788
|
updateColumn,
|
|
620
789
|
useLayoutEffectSkipFirst as useLayoutEffectSkipFirst2
|
|
621
790
|
} from "@vuu-ui/vuu-utils";
|
|
622
791
|
import {
|
|
623
|
-
useCallback as
|
|
792
|
+
useCallback as useCallback19,
|
|
624
793
|
useEffect as useEffect4,
|
|
625
794
|
useMemo as useMemo6,
|
|
626
|
-
|
|
795
|
+
useRef as useRef14,
|
|
796
|
+
useState as useState7
|
|
627
797
|
} from "react";
|
|
628
798
|
|
|
629
799
|
// src/context-menu/buildContextMenuDescriptors.ts
|
|
@@ -946,7 +1116,7 @@ var updateTableConfig = (config, action) => {
|
|
|
946
1116
|
// src/useCellEditing.ts
|
|
947
1117
|
import { isCharacterKey } from "@vuu-ui/vuu-utils";
|
|
948
1118
|
import {
|
|
949
|
-
useCallback as
|
|
1119
|
+
useCallback as useCallback11
|
|
950
1120
|
} from "react";
|
|
951
1121
|
|
|
952
1122
|
// src/table-dom-utils.ts
|
|
@@ -965,7 +1135,7 @@ var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
|
965
1135
|
return cell;
|
|
966
1136
|
}
|
|
967
1137
|
};
|
|
968
|
-
var cellIsEditable = (cell) => cell.classList.contains("vuuTableCell-editable");
|
|
1138
|
+
var cellIsEditable = (cell) => cell == null ? void 0 : cell.classList.contains("vuuTableCell-editable");
|
|
969
1139
|
var cellIsTextInput = (cell) => cell.querySelector(".vuuTableInputCell") !== null;
|
|
970
1140
|
function getRowIndex(rowEl) {
|
|
971
1141
|
if (rowEl) {
|
|
@@ -978,13 +1148,34 @@ function getRowIndex(rowEl) {
|
|
|
978
1148
|
}
|
|
979
1149
|
var closestRow = (el) => el.closest('[role="row"]');
|
|
980
1150
|
var closestRowIndex = (el) => getRowIndex(closestRow(el));
|
|
1151
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1152
|
+
var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1153
|
+
if (contentContainer) {
|
|
1154
|
+
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1155
|
+
const upperBoundary = viewport.top + totalHeaderHeight;
|
|
1156
|
+
const row = rowEl.getBoundingClientRect();
|
|
1157
|
+
if (row) {
|
|
1158
|
+
if (row.bottom > viewport.bottom) {
|
|
1159
|
+
return ["down", row.bottom - viewport.bottom];
|
|
1160
|
+
} else if (row.top < upperBoundary) {
|
|
1161
|
+
return ["up", row.top - upperBoundary];
|
|
1162
|
+
} else {
|
|
1163
|
+
return NO_SCROLL_NECESSARY;
|
|
1164
|
+
}
|
|
1165
|
+
} else {
|
|
1166
|
+
throw Error("Whats going on, row not found");
|
|
1167
|
+
}
|
|
1168
|
+
} else {
|
|
1169
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
981
1172
|
|
|
982
1173
|
// src/useCellEditing.ts
|
|
983
1174
|
var useCellEditing = ({ navigate }) => {
|
|
984
|
-
const commitHandler =
|
|
1175
|
+
const commitHandler = useCallback11(() => {
|
|
985
1176
|
navigate();
|
|
986
1177
|
}, [navigate]);
|
|
987
|
-
const editInput =
|
|
1178
|
+
const editInput = useCallback11(
|
|
988
1179
|
(evt) => {
|
|
989
1180
|
const cellEl = evt.target;
|
|
990
1181
|
const input = cellEl.matches("input") ? cellEl : cellEl.querySelector("input");
|
|
@@ -995,7 +1186,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
995
1186
|
},
|
|
996
1187
|
[]
|
|
997
1188
|
);
|
|
998
|
-
const focusInput =
|
|
1189
|
+
const focusInput = useCallback11(
|
|
999
1190
|
(evt) => {
|
|
1000
1191
|
const cellEl = evt.target;
|
|
1001
1192
|
const input = cellEl.querySelector("input");
|
|
@@ -1006,7 +1197,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1006
1197
|
},
|
|
1007
1198
|
[]
|
|
1008
1199
|
);
|
|
1009
|
-
const handleKeyDown =
|
|
1200
|
+
const handleKeyDown = useCallback11(
|
|
1010
1201
|
(e) => {
|
|
1011
1202
|
const el = e.target;
|
|
1012
1203
|
if (cellIsTextInput(el)) {
|
|
@@ -1019,7 +1210,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1019
1210
|
},
|
|
1020
1211
|
[editInput, focusInput]
|
|
1021
1212
|
);
|
|
1022
|
-
const handleDoubleClick =
|
|
1213
|
+
const handleDoubleClick = useCallback11(
|
|
1023
1214
|
(e) => {
|
|
1024
1215
|
const el = e.target;
|
|
1025
1216
|
if (el.matches("input") || el.querySelector("input")) {
|
|
@@ -1029,14 +1220,14 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1029
1220
|
},
|
|
1030
1221
|
[editInput]
|
|
1031
1222
|
);
|
|
1032
|
-
const handleBlur =
|
|
1223
|
+
const handleBlur = useCallback11(
|
|
1033
1224
|
(e) => {
|
|
1034
1225
|
const el = e.target;
|
|
1035
1226
|
el.removeEventListener("vuu-commit", commitHandler, true);
|
|
1036
1227
|
},
|
|
1037
1228
|
[commitHandler]
|
|
1038
1229
|
);
|
|
1039
|
-
const handleFocus =
|
|
1230
|
+
const handleFocus = useCallback11(
|
|
1040
1231
|
(e) => {
|
|
1041
1232
|
const el = e.target;
|
|
1042
1233
|
el.addEventListener("vuu-commit", commitHandler, true);
|
|
@@ -1052,8 +1243,8 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1052
1243
|
};
|
|
1053
1244
|
|
|
1054
1245
|
// src/useDataSource.ts
|
|
1055
|
-
import { getFullRange, NULL_RANGE } from "@vuu-ui/vuu-utils";
|
|
1056
|
-
import { useCallback as
|
|
1246
|
+
import { getFullRange, NULL_RANGE, rangesAreSame } from "@vuu-ui/vuu-utils";
|
|
1247
|
+
import { useCallback as useCallback12, useEffect, useMemo as useMemo2, useRef as useRef7, useState as useState4 } from "react";
|
|
1057
1248
|
|
|
1058
1249
|
// src/moving-window.ts
|
|
1059
1250
|
import {
|
|
@@ -1127,16 +1318,16 @@ var useDataSource = ({
|
|
|
1127
1318
|
renderBufferSize = 0
|
|
1128
1319
|
}) => {
|
|
1129
1320
|
const [, forceUpdate] = useState4(null);
|
|
1130
|
-
const data =
|
|
1131
|
-
const isMounted =
|
|
1132
|
-
const hasUpdated =
|
|
1133
|
-
const rangeRef =
|
|
1321
|
+
const data = useRef7([]);
|
|
1322
|
+
const isMounted = useRef7(true);
|
|
1323
|
+
const hasUpdated = useRef7(false);
|
|
1324
|
+
const rangeRef = useRef7(range);
|
|
1134
1325
|
const dataWindow = useMemo2(
|
|
1135
1326
|
() => new MovingWindow(getFullRange(range, renderBufferSize)),
|
|
1136
1327
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1137
1328
|
[]
|
|
1138
1329
|
);
|
|
1139
|
-
const setData =
|
|
1330
|
+
const setData = useCallback12(
|
|
1140
1331
|
(updates) => {
|
|
1141
1332
|
for (const row of updates) {
|
|
1142
1333
|
dataWindow.add(row);
|
|
@@ -1150,7 +1341,7 @@ var useDataSource = ({
|
|
|
1150
1341
|
},
|
|
1151
1342
|
[dataWindow]
|
|
1152
1343
|
);
|
|
1153
|
-
const datasourceMessageHandler =
|
|
1344
|
+
const datasourceMessageHandler = useCallback12(
|
|
1154
1345
|
(message) => {
|
|
1155
1346
|
if (message.type === "subscribed") {
|
|
1156
1347
|
onSubscribed == null ? void 0 : onSubscribed(message);
|
|
@@ -1173,7 +1364,7 @@ var useDataSource = ({
|
|
|
1173
1364
|
},
|
|
1174
1365
|
[dataWindow, onFeatureInvocation, onSizeChange, onSubscribed, setData]
|
|
1175
1366
|
);
|
|
1176
|
-
const getSelectedRows =
|
|
1367
|
+
const getSelectedRows = useCallback12(() => {
|
|
1177
1368
|
return dataWindow.getSelectedRows();
|
|
1178
1369
|
}, [dataWindow]);
|
|
1179
1370
|
useEffect(() => {
|
|
@@ -1197,12 +1388,14 @@ var useDataSource = ({
|
|
|
1197
1388
|
);
|
|
1198
1389
|
}
|
|
1199
1390
|
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
1200
|
-
const setRange =
|
|
1391
|
+
const setRange = useCallback12(
|
|
1201
1392
|
(range2) => {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1393
|
+
if (!rangesAreSame(range2, rangeRef.current)) {
|
|
1394
|
+
const fullRange = getFullRange(range2, renderBufferSize);
|
|
1395
|
+
dataWindow.setRange(fullRange);
|
|
1396
|
+
dataSource.range = rangeRef.current = fullRange;
|
|
1397
|
+
dataSource.emit("range", range2);
|
|
1398
|
+
}
|
|
1206
1399
|
},
|
|
1207
1400
|
[dataSource, dataWindow, renderBufferSize]
|
|
1208
1401
|
);
|
|
@@ -1216,9 +1409,9 @@ var useDataSource = ({
|
|
|
1216
1409
|
};
|
|
1217
1410
|
|
|
1218
1411
|
// src/useInitialValue.ts
|
|
1219
|
-
import { useMemo as useMemo3, useRef as
|
|
1412
|
+
import { useMemo as useMemo3, useRef as useRef8 } from "react";
|
|
1220
1413
|
var useInitialValue = (value) => {
|
|
1221
|
-
const ref =
|
|
1414
|
+
const ref = useRef8(value);
|
|
1222
1415
|
return useMemo3(() => ref.current, []);
|
|
1223
1416
|
};
|
|
1224
1417
|
|
|
@@ -1226,9 +1419,9 @@ var useInitialValue = (value) => {
|
|
|
1226
1419
|
import { getIndexFromRowElement } from "@vuu-ui/vuu-utils";
|
|
1227
1420
|
import { useControlled } from "@salt-ds/core";
|
|
1228
1421
|
import {
|
|
1229
|
-
useCallback as
|
|
1422
|
+
useCallback as useCallback13,
|
|
1230
1423
|
useEffect as useEffect2,
|
|
1231
|
-
useRef as
|
|
1424
|
+
useRef as useRef9
|
|
1232
1425
|
} from "react";
|
|
1233
1426
|
var rowNavigationKeys = /* @__PURE__ */ new Set([
|
|
1234
1427
|
"Home",
|
|
@@ -1298,17 +1491,17 @@ var useKeyboardNavigation = ({
|
|
|
1298
1491
|
viewportRowCount
|
|
1299
1492
|
}) => {
|
|
1300
1493
|
var _a;
|
|
1301
|
-
const focusedCellPos =
|
|
1302
|
-
const focusableCell =
|
|
1303
|
-
const activeCellPos =
|
|
1304
|
-
const highlightedIndexRef =
|
|
1494
|
+
const focusedCellPos = useRef9([-1, -1]);
|
|
1495
|
+
const focusableCell = useRef9();
|
|
1496
|
+
const activeCellPos = useRef9([-1, 0]);
|
|
1497
|
+
const highlightedIndexRef = useRef9();
|
|
1305
1498
|
const [highlightedIndex, setHighlightedIdx] = useControlled({
|
|
1306
1499
|
controlled: highlightedIndexProp,
|
|
1307
1500
|
default: defaultHighlightedIndex,
|
|
1308
1501
|
name: "UseKeyboardNavigation"
|
|
1309
1502
|
});
|
|
1310
1503
|
highlightedIndexRef.current = highlightedIndex;
|
|
1311
|
-
const setHighlightedIndex =
|
|
1504
|
+
const setHighlightedIndex = useCallback13(
|
|
1312
1505
|
(idx, fromKeyboard = false) => {
|
|
1313
1506
|
onHighlight == null ? void 0 : onHighlight(idx);
|
|
1314
1507
|
setHighlightedIdx(idx);
|
|
@@ -1335,7 +1528,7 @@ var useKeyboardNavigation = ({
|
|
|
1335
1528
|
}
|
|
1336
1529
|
return NULL_CELL_POS;
|
|
1337
1530
|
};
|
|
1338
|
-
const focusCell =
|
|
1531
|
+
const focusCell = useCallback13(
|
|
1339
1532
|
(cellPos) => {
|
|
1340
1533
|
var _a2;
|
|
1341
1534
|
if (containerRef.current) {
|
|
@@ -1346,7 +1539,6 @@ var useKeyboardNavigation = ({
|
|
|
1346
1539
|
focusableCell.current = activeCell;
|
|
1347
1540
|
activeCell.setAttribute("tabindex", "0");
|
|
1348
1541
|
}
|
|
1349
|
-
console.log(`scroll row ${cellPos[0]}`);
|
|
1350
1542
|
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex: cellPos[0] });
|
|
1351
1543
|
activeCell.focus({ preventScroll: true });
|
|
1352
1544
|
}
|
|
@@ -1356,7 +1548,7 @@ var useKeyboardNavigation = ({
|
|
|
1356
1548
|
// be often whilst scrolling - store range in a a ref ?
|
|
1357
1549
|
[containerRef, requestScroll]
|
|
1358
1550
|
);
|
|
1359
|
-
const setActiveCell =
|
|
1551
|
+
const setActiveCell = useCallback13(
|
|
1360
1552
|
(rowIdx, colIdx, fromKeyboard = false) => {
|
|
1361
1553
|
const pos = [rowIdx, colIdx];
|
|
1362
1554
|
activeCellPos.current = pos;
|
|
@@ -1371,34 +1563,46 @@ var useKeyboardNavigation = ({
|
|
|
1371
1563
|
},
|
|
1372
1564
|
[focusCell, navigationStyle, setHighlightedIdx]
|
|
1373
1565
|
);
|
|
1374
|
-
const nextPageItemIdx =
|
|
1566
|
+
const nextPageItemIdx = useCallback13(
|
|
1375
1567
|
(key, [rowIdx, colIdx]) => new Promise((resolve) => {
|
|
1376
1568
|
let newRowIdx = rowIdx;
|
|
1377
1569
|
switch (key) {
|
|
1378
|
-
case "PageDown":
|
|
1570
|
+
case "PageDown": {
|
|
1379
1571
|
newRowIdx = Math.min(rowCount - 1, rowIdx + viewportRowCount);
|
|
1380
|
-
|
|
1572
|
+
if (newRowIdx !== rowIdx) {
|
|
1573
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "down" });
|
|
1574
|
+
}
|
|
1381
1575
|
break;
|
|
1382
|
-
|
|
1576
|
+
}
|
|
1577
|
+
case "PageUp": {
|
|
1383
1578
|
newRowIdx = Math.max(0, rowIdx - viewportRowCount);
|
|
1384
|
-
|
|
1579
|
+
if (newRowIdx !== rowIdx) {
|
|
1580
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "up" });
|
|
1581
|
+
}
|
|
1385
1582
|
break;
|
|
1386
|
-
|
|
1583
|
+
}
|
|
1584
|
+
case "Home": {
|
|
1387
1585
|
newRowIdx = 0;
|
|
1388
|
-
|
|
1586
|
+
if (newRowIdx !== rowIdx) {
|
|
1587
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "home" });
|
|
1588
|
+
}
|
|
1389
1589
|
break;
|
|
1390
|
-
|
|
1590
|
+
}
|
|
1591
|
+
case "End": {
|
|
1391
1592
|
newRowIdx = rowCount - 1;
|
|
1392
|
-
|
|
1593
|
+
if (newRowIdx !== rowIdx) {
|
|
1594
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "end" });
|
|
1595
|
+
}
|
|
1393
1596
|
break;
|
|
1597
|
+
}
|
|
1394
1598
|
}
|
|
1395
1599
|
setTimeout(() => {
|
|
1396
1600
|
resolve([newRowIdx, colIdx]);
|
|
1397
|
-
},
|
|
1601
|
+
}, 35);
|
|
1398
1602
|
}),
|
|
1399
1603
|
[requestScroll, rowCount, viewportRowCount]
|
|
1400
1604
|
);
|
|
1401
|
-
const handleFocus =
|
|
1605
|
+
const handleFocus = useCallback13(() => {
|
|
1402
1606
|
var _a2;
|
|
1403
1607
|
if (disableHighlightOnFocus !== true) {
|
|
1404
1608
|
if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
|
|
@@ -1417,7 +1621,7 @@ var useKeyboardNavigation = ({
|
|
|
1417
1621
|
navigationStyle,
|
|
1418
1622
|
setHighlightedIdx
|
|
1419
1623
|
]);
|
|
1420
|
-
const navigateChildItems =
|
|
1624
|
+
const navigateChildItems = useCallback13(
|
|
1421
1625
|
async (key) => {
|
|
1422
1626
|
const [nextRowIdx, nextColIdx] = isPagingKey(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
|
|
1423
1627
|
const [rowIdx, colIdx] = activeCellPos.current;
|
|
@@ -1427,13 +1631,13 @@ var useKeyboardNavigation = ({
|
|
|
1427
1631
|
},
|
|
1428
1632
|
[columnCount, nextPageItemIdx, rowCount, setActiveCell]
|
|
1429
1633
|
);
|
|
1430
|
-
const scrollRowIntoViewIfNecessary =
|
|
1634
|
+
const scrollRowIntoViewIfNecessary = useCallback13(
|
|
1431
1635
|
(rowIndex) => {
|
|
1432
1636
|
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex });
|
|
1433
1637
|
},
|
|
1434
1638
|
[requestScroll]
|
|
1435
1639
|
);
|
|
1436
|
-
const moveHighlightedRow =
|
|
1640
|
+
const moveHighlightedRow = useCallback13(
|
|
1437
1641
|
async (key) => {
|
|
1438
1642
|
const { current: highlighted } = highlightedIndexRef;
|
|
1439
1643
|
const [nextRowIdx] = isPagingKey(key) ? await nextPageItemIdx(key, [highlighted != null ? highlighted : -1, 0]) : nextCellPos(key, [highlighted != null ? highlighted : -1, 0], columnCount, rowCount);
|
|
@@ -1455,7 +1659,7 @@ var useKeyboardNavigation = ({
|
|
|
1455
1659
|
scrollRowIntoViewIfNecessary(highlightedIndexProp);
|
|
1456
1660
|
}
|
|
1457
1661
|
}, [highlightedIndexProp, scrollRowIntoViewIfNecessary]);
|
|
1458
|
-
const handleKeyDown =
|
|
1662
|
+
const handleKeyDown = useCallback13(
|
|
1459
1663
|
(e) => {
|
|
1460
1664
|
if (rowCount > 0 && isNavigationKey(e.key, navigationStyle)) {
|
|
1461
1665
|
e.preventDefault();
|
|
@@ -1469,7 +1673,7 @@ var useKeyboardNavigation = ({
|
|
|
1469
1673
|
},
|
|
1470
1674
|
[rowCount, navigationStyle, moveHighlightedRow, navigateChildItems]
|
|
1471
1675
|
);
|
|
1472
|
-
const handleClick =
|
|
1676
|
+
const handleClick = useCallback13(
|
|
1473
1677
|
// Might not be a cell e.g the Settings button
|
|
1474
1678
|
(evt) => {
|
|
1475
1679
|
const target = evt.target;
|
|
@@ -1481,10 +1685,10 @@ var useKeyboardNavigation = ({
|
|
|
1481
1685
|
},
|
|
1482
1686
|
[setActiveCell]
|
|
1483
1687
|
);
|
|
1484
|
-
const handleMouseLeave =
|
|
1688
|
+
const handleMouseLeave = useCallback13(() => {
|
|
1485
1689
|
setHighlightedIndex(-1);
|
|
1486
1690
|
}, [setHighlightedIndex]);
|
|
1487
|
-
const handleMouseMove =
|
|
1691
|
+
const handleMouseMove = useCallback13(
|
|
1488
1692
|
(evt) => {
|
|
1489
1693
|
const idx = closestRowIndex(evt.target);
|
|
1490
1694
|
if (idx !== -1 && idx !== highlightedIndexRef.current) {
|
|
@@ -1493,7 +1697,7 @@ var useKeyboardNavigation = ({
|
|
|
1493
1697
|
},
|
|
1494
1698
|
[setHighlightedIndex]
|
|
1495
1699
|
);
|
|
1496
|
-
const navigate =
|
|
1700
|
+
const navigate = useCallback13(() => {
|
|
1497
1701
|
navigateChildItems("ArrowDown");
|
|
1498
1702
|
}, [navigateChildItems]);
|
|
1499
1703
|
const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
|
|
@@ -1527,8 +1731,8 @@ import {
|
|
|
1527
1731
|
selectItem
|
|
1528
1732
|
} from "@vuu-ui/vuu-utils";
|
|
1529
1733
|
import {
|
|
1530
|
-
useCallback as
|
|
1531
|
-
useRef as
|
|
1734
|
+
useCallback as useCallback14,
|
|
1735
|
+
useRef as useRef10
|
|
1532
1736
|
} from "react";
|
|
1533
1737
|
var { IDX: IDX2 } = metadataKeys4;
|
|
1534
1738
|
var NO_SELECTION = [];
|
|
@@ -1541,13 +1745,13 @@ var useSelection = ({
|
|
|
1541
1745
|
onSelectionChange
|
|
1542
1746
|
}) => {
|
|
1543
1747
|
selectionModel === "extended" || selectionModel === "checkbox";
|
|
1544
|
-
const lastActiveRef =
|
|
1545
|
-
const selectedRef =
|
|
1546
|
-
const isSelectionEvent =
|
|
1748
|
+
const lastActiveRef = useRef10(-1);
|
|
1749
|
+
const selectedRef = useRef10(NO_SELECTION);
|
|
1750
|
+
const isSelectionEvent = useCallback14(
|
|
1547
1751
|
(evt) => selectionKeys.includes(evt.key),
|
|
1548
1752
|
[selectionKeys]
|
|
1549
1753
|
);
|
|
1550
|
-
const handleRowClick =
|
|
1754
|
+
const handleRowClick = useCallback14(
|
|
1551
1755
|
(row, rangeSelect, keepExistingSelection) => {
|
|
1552
1756
|
const { [IDX2]: idx } = row;
|
|
1553
1757
|
const { current: active } = lastActiveRef;
|
|
@@ -1568,7 +1772,7 @@ var useSelection = ({
|
|
|
1568
1772
|
},
|
|
1569
1773
|
[onSelect, onSelectionChange, selectionModel]
|
|
1570
1774
|
);
|
|
1571
|
-
const handleKeyDown =
|
|
1775
|
+
const handleKeyDown = useCallback14(
|
|
1572
1776
|
(e) => {
|
|
1573
1777
|
if (isSelectionEvent(e)) {
|
|
1574
1778
|
const { current: rowIndex } = highlightedIndexRef;
|
|
@@ -1593,7 +1797,7 @@ var useSelection = ({
|
|
|
1593
1797
|
// src/useTableContextMenu.ts
|
|
1594
1798
|
import { useContextMenu as usePopupContextMenu } from "@vuu-ui/vuu-popups";
|
|
1595
1799
|
import { buildColumnMap, getIndexFromRowElement as getIndexFromRowElement2 } from "@vuu-ui/vuu-utils";
|
|
1596
|
-
import { useCallback as
|
|
1800
|
+
import { useCallback as useCallback15 } from "react";
|
|
1597
1801
|
var NO_ROWS = [];
|
|
1598
1802
|
var useTableContextMenu = ({
|
|
1599
1803
|
columns,
|
|
@@ -1602,7 +1806,7 @@ var useTableContextMenu = ({
|
|
|
1602
1806
|
getSelectedRows
|
|
1603
1807
|
}) => {
|
|
1604
1808
|
const [showContextMenu] = usePopupContextMenu();
|
|
1605
|
-
const onContextMenu =
|
|
1809
|
+
const onContextMenu = useCallback15(
|
|
1606
1810
|
(evt) => {
|
|
1607
1811
|
const target = evt.target;
|
|
1608
1812
|
const cellEl = target == null ? void 0 : target.closest("div[role='cell']");
|
|
@@ -1641,10 +1845,9 @@ import {
|
|
|
1641
1845
|
getValueFormatter,
|
|
1642
1846
|
hasValidationRules,
|
|
1643
1847
|
isFilteredColumn,
|
|
1644
|
-
isGroupColumn as
|
|
1848
|
+
isGroupColumn as isGroupColumn3,
|
|
1645
1849
|
isPinned,
|
|
1646
1850
|
logger,
|
|
1647
|
-
metadataKeys as metadataKeys5,
|
|
1648
1851
|
replaceColumn,
|
|
1649
1852
|
sortPinnedColumns,
|
|
1650
1853
|
stripFilterFromColumns,
|
|
@@ -1654,7 +1857,6 @@ import { buildValidationChecker } from "@vuu-ui/vuu-ui-controls";
|
|
|
1654
1857
|
import { useReducer } from "react";
|
|
1655
1858
|
var { info } = logger("useTableModel");
|
|
1656
1859
|
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1657
|
-
var KEY_OFFSET = metadataKeys5.count;
|
|
1658
1860
|
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
1659
1861
|
var getDataType = (column, tableSchema) => {
|
|
1660
1862
|
const schemaColumn = tableSchema == null ? void 0 : tableSchema.columns.find(
|
|
@@ -1742,7 +1944,6 @@ var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) =>
|
|
|
1742
1944
|
const serverDataType = getDataType(column, tableSchema);
|
|
1743
1945
|
const {
|
|
1744
1946
|
align = getDefaultAlignment(serverDataType),
|
|
1745
|
-
key,
|
|
1746
1947
|
name,
|
|
1747
1948
|
label = getColumnLabel(column),
|
|
1748
1949
|
width = columnDefaultWidth,
|
|
@@ -1755,20 +1956,17 @@ var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) =>
|
|
|
1755
1956
|
HeaderCellContentRenderer: getColumnHeaderContentRenderer(column),
|
|
1756
1957
|
HeaderCellLabelRenderer: getColumnHeaderLabelRenderer(column),
|
|
1757
1958
|
clientSideEditValidationCheck: hasValidationRules(column.type) ? buildValidationChecker(column.type.renderer.rules) : void 0,
|
|
1959
|
+
index: index + 1,
|
|
1758
1960
|
label: getLabel(label, columnFormatHeader),
|
|
1759
|
-
key: key != null ? key : index + KEY_OFFSET,
|
|
1760
1961
|
name,
|
|
1761
1962
|
originalIdx: index,
|
|
1762
1963
|
serverDataType,
|
|
1763
1964
|
valueFormatter: getValueFormatter(column, serverDataType),
|
|
1764
1965
|
width
|
|
1765
1966
|
};
|
|
1766
|
-
if (
|
|
1967
|
+
if (isGroupColumn3(runtimeColumnWithDefaults)) {
|
|
1767
1968
|
runtimeColumnWithDefaults.columns = runtimeColumnWithDefaults.columns.map(
|
|
1768
|
-
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(
|
|
1769
|
-
col,
|
|
1770
|
-
col.key
|
|
1771
|
-
)
|
|
1969
|
+
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(col, index)
|
|
1772
1970
|
);
|
|
1773
1971
|
}
|
|
1774
1972
|
return runtimeColumnWithDefaults;
|
|
@@ -1941,52 +2139,71 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
1941
2139
|
}
|
|
1942
2140
|
|
|
1943
2141
|
// src/useTableScroll.ts
|
|
1944
|
-
import { getRowElementAtIndex } from "@vuu-ui/vuu-utils";
|
|
1945
2142
|
import {
|
|
1946
|
-
|
|
2143
|
+
getColumnsInViewport,
|
|
2144
|
+
getRowElementAtIndex,
|
|
2145
|
+
itemsChanged
|
|
2146
|
+
} from "@vuu-ui/vuu-utils";
|
|
2147
|
+
import {
|
|
2148
|
+
useCallback as useCallback16,
|
|
1947
2149
|
useEffect as useEffect3,
|
|
1948
2150
|
useImperativeHandle,
|
|
1949
2151
|
useMemo as useMemo4,
|
|
1950
|
-
useRef as
|
|
2152
|
+
useRef as useRef11,
|
|
2153
|
+
useState as useState5
|
|
1951
2154
|
} from "react";
|
|
1952
|
-
var
|
|
1953
|
-
|
|
2155
|
+
var SCROLL_MOVE_CHECK_THRESHOLD = 100;
|
|
2156
|
+
var HORIZONTAL_SCROLL_BUFFER = 200;
|
|
2157
|
+
var getMaxScroll = (container) => {
|
|
1954
2158
|
const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
|
|
2159
|
+
return [scrollWidth - clientWidth, scrollHeight - clientHeight];
|
|
2160
|
+
};
|
|
2161
|
+
var getScrollDirection = (prevScrollPositions, scrollPos) => {
|
|
2162
|
+
if (prevScrollPositions === void 0) {
|
|
2163
|
+
return void 0;
|
|
2164
|
+
} else {
|
|
2165
|
+
const { scrollTop: prevTop } = prevScrollPositions;
|
|
2166
|
+
return scrollPos > prevTop ? "fwd" : "bwd";
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
var getPctScroll = (container, currentScrollPos) => {
|
|
2170
|
+
const {
|
|
2171
|
+
clientHeight,
|
|
2172
|
+
clientWidth,
|
|
2173
|
+
scrollHeight,
|
|
2174
|
+
scrollLeft,
|
|
2175
|
+
scrollTop,
|
|
2176
|
+
scrollWidth
|
|
2177
|
+
} = container;
|
|
2178
|
+
const maxScrollLeft = scrollWidth - clientWidth;
|
|
1955
2179
|
const pctScrollLeft = scrollLeft / (scrollWidth - clientWidth);
|
|
1956
|
-
const
|
|
1957
|
-
|
|
2180
|
+
const maxScrollTop = scrollHeight - clientHeight;
|
|
2181
|
+
let pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
2182
|
+
const scrollDirection = getScrollDirection(currentScrollPos, scrollTop);
|
|
2183
|
+
if (scrollDirection === "fwd" && pctScrollTop > 0.99) {
|
|
2184
|
+
pctScrollTop = 1;
|
|
2185
|
+
} else if (scrollDirection === "bwd" && pctScrollTop < 0.02) {
|
|
2186
|
+
pctScrollTop = 0;
|
|
2187
|
+
}
|
|
2188
|
+
return [
|
|
2189
|
+
scrollLeft,
|
|
2190
|
+
pctScrollLeft,
|
|
2191
|
+
maxScrollLeft,
|
|
2192
|
+
scrollTop,
|
|
2193
|
+
pctScrollTop,
|
|
2194
|
+
maxScrollTop
|
|
2195
|
+
];
|
|
1958
2196
|
};
|
|
1959
2197
|
var noScrolling = {
|
|
1960
2198
|
scrollToIndex: () => void 0,
|
|
1961
2199
|
scrollToKey: () => void 0
|
|
1962
2200
|
};
|
|
1963
|
-
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
1964
|
-
var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = rowEl.closest(".vuuTable-contentContainer")) => {
|
|
1965
|
-
if (contentContainer) {
|
|
1966
|
-
const viewport = contentContainer == null ? void 0 : contentContainer.getBoundingClientRect();
|
|
1967
|
-
const upperBoundary = viewport.top + totalHeaderHeight;
|
|
1968
|
-
const row = rowEl.getBoundingClientRect();
|
|
1969
|
-
if (row) {
|
|
1970
|
-
if (row.bottom > viewport.bottom) {
|
|
1971
|
-
return ["down", row.bottom - viewport.bottom];
|
|
1972
|
-
} else if (row.top < upperBoundary) {
|
|
1973
|
-
return ["up", row.top - upperBoundary];
|
|
1974
|
-
} else {
|
|
1975
|
-
return NO_SCROLL_NECESSARY;
|
|
1976
|
-
}
|
|
1977
|
-
} else {
|
|
1978
|
-
throw Error("Whats going on, row not found");
|
|
1979
|
-
}
|
|
1980
|
-
} else {
|
|
1981
|
-
throw Error("Whats going on, scrollbar container not found");
|
|
1982
|
-
}
|
|
1983
|
-
};
|
|
1984
2201
|
var useCallbackRef = ({
|
|
1985
2202
|
onAttach,
|
|
1986
2203
|
onDetach
|
|
1987
2204
|
}) => {
|
|
1988
|
-
const ref =
|
|
1989
|
-
const callbackRef =
|
|
2205
|
+
const ref = useRef11(null);
|
|
2206
|
+
const callbackRef = useCallback16(
|
|
1990
2207
|
(el) => {
|
|
1991
2208
|
if (el) {
|
|
1992
2209
|
ref.current = el;
|
|
@@ -2002,75 +2219,142 @@ var useCallbackRef = ({
|
|
|
2002
2219
|
return callbackRef;
|
|
2003
2220
|
};
|
|
2004
2221
|
var useTableScroll = ({
|
|
2222
|
+
columns,
|
|
2005
2223
|
getRowAtPosition,
|
|
2006
2224
|
onHorizontalScroll,
|
|
2007
2225
|
onVerticalScroll,
|
|
2226
|
+
onVerticalScrollInSitu,
|
|
2008
2227
|
scrollingApiRef,
|
|
2009
2228
|
setRange,
|
|
2010
2229
|
viewportMeasurements
|
|
2011
2230
|
}) => {
|
|
2012
|
-
const firstRowRef =
|
|
2013
|
-
const contentContainerScrolledRef =
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
|
|
2231
|
+
const firstRowRef = useRef11(0);
|
|
2232
|
+
const contentContainerScrolledRef = useRef11(false);
|
|
2233
|
+
const contentContainerPosRef = useRef11({
|
|
2234
|
+
scrollTop: 0,
|
|
2235
|
+
scrollLeft: 0
|
|
2236
|
+
});
|
|
2237
|
+
const scrollbarContainerScrolledRef = useRef11(false);
|
|
2238
|
+
const scrollbarContainerPosRef = useRef11({
|
|
2239
|
+
scrollTop: 0,
|
|
2240
|
+
scrollLeft: 0
|
|
2241
|
+
});
|
|
2242
|
+
const scrollbarContainerRef = useRef11(null);
|
|
2243
|
+
const contentContainerRef = useRef11(null);
|
|
2244
|
+
const lastHorizontalScrollCheckPoint = useRef11(0);
|
|
2017
2245
|
const {
|
|
2018
2246
|
appliedPageSize,
|
|
2019
2247
|
isVirtualScroll,
|
|
2020
|
-
maxScrollContainerScrollHorizontal: maxScrollLeft,
|
|
2021
|
-
maxScrollContainerScrollVertical: maxScrollTop,
|
|
2022
2248
|
rowCount: viewportRowCount,
|
|
2023
|
-
totalHeaderHeight
|
|
2249
|
+
totalHeaderHeight,
|
|
2250
|
+
viewportWidth
|
|
2024
2251
|
} = viewportMeasurements;
|
|
2025
|
-
const
|
|
2252
|
+
const columnsWithinViewportRef = useRef11([]);
|
|
2253
|
+
const [, forceRefresh] = useState5({});
|
|
2254
|
+
const preSpanRef = useRef11(0);
|
|
2255
|
+
useMemo4(() => {
|
|
2256
|
+
const [visibleColumns, offset] = getColumnsInViewport(
|
|
2257
|
+
columns,
|
|
2258
|
+
contentContainerPosRef.current.scrollLeft,
|
|
2259
|
+
contentContainerPosRef.current.scrollLeft + viewportWidth + HORIZONTAL_SCROLL_BUFFER
|
|
2260
|
+
);
|
|
2261
|
+
preSpanRef.current = offset;
|
|
2262
|
+
columnsWithinViewportRef.current = visibleColumns;
|
|
2263
|
+
}, [viewportWidth, columns]);
|
|
2264
|
+
const handleHorizontalScroll = useCallback16(
|
|
2265
|
+
(scrollLeft) => {
|
|
2266
|
+
contentContainerPosRef.current.scrollLeft = scrollLeft;
|
|
2267
|
+
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2268
|
+
if (Math.abs(scrollLeft - lastHorizontalScrollCheckPoint.current) > SCROLL_MOVE_CHECK_THRESHOLD) {
|
|
2269
|
+
lastHorizontalScrollCheckPoint.current = scrollLeft;
|
|
2270
|
+
const [visibleColumns, pre] = getColumnsInViewport(
|
|
2271
|
+
columns,
|
|
2272
|
+
scrollLeft,
|
|
2273
|
+
scrollLeft + viewportWidth + HORIZONTAL_SCROLL_BUFFER
|
|
2274
|
+
);
|
|
2275
|
+
if (itemsChanged(columnsWithinViewportRef.current, visibleColumns)) {
|
|
2276
|
+
preSpanRef.current = pre;
|
|
2277
|
+
columnsWithinViewportRef.current = visibleColumns;
|
|
2278
|
+
forceRefresh({});
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
},
|
|
2282
|
+
[columns, onHorizontalScroll, viewportWidth]
|
|
2283
|
+
);
|
|
2284
|
+
const handleVerticalScroll = useCallback16(
|
|
2026
2285
|
(scrollTop, pctScrollTop) => {
|
|
2286
|
+
contentContainerPosRef.current.scrollTop = scrollTop;
|
|
2027
2287
|
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
2028
2288
|
const firstRow = getRowAtPosition(scrollTop);
|
|
2029
2289
|
if (firstRow !== firstRowRef.current) {
|
|
2030
2290
|
firstRowRef.current = firstRow;
|
|
2031
|
-
setRange({ from: firstRow, to: firstRow + viewportRowCount
|
|
2291
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2032
2292
|
}
|
|
2293
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(0);
|
|
2033
2294
|
},
|
|
2034
|
-
[
|
|
2295
|
+
[
|
|
2296
|
+
getRowAtPosition,
|
|
2297
|
+
onVerticalScroll,
|
|
2298
|
+
onVerticalScrollInSitu,
|
|
2299
|
+
setRange,
|
|
2300
|
+
viewportRowCount
|
|
2301
|
+
]
|
|
2035
2302
|
);
|
|
2036
|
-
const handleScrollbarContainerScroll =
|
|
2303
|
+
const handleScrollbarContainerScroll = useCallback16(() => {
|
|
2037
2304
|
const { current: contentContainer } = contentContainerRef;
|
|
2038
2305
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2039
2306
|
const { current: contentContainerScrolled } = contentContainerScrolledRef;
|
|
2307
|
+
const { current: scrollPos } = scrollbarContainerPosRef;
|
|
2040
2308
|
if (contentContainerScrolled) {
|
|
2041
2309
|
contentContainerScrolledRef.current = false;
|
|
2042
2310
|
} else if (contentContainer && scrollbarContainer) {
|
|
2043
|
-
|
|
2044
|
-
const
|
|
2045
|
-
|
|
2311
|
+
scrollbarContainerScrolledRef.current = true;
|
|
2312
|
+
const [scrollLeft, pctScrollLeft, , scrollTop, pctScrollTop] = getPctScroll(scrollbarContainer, scrollPos);
|
|
2313
|
+
scrollPos.scrollLeft = scrollLeft;
|
|
2314
|
+
scrollPos.scrollTop = scrollTop;
|
|
2315
|
+
const [maxScrollLeft, maxScrollTop] = getMaxScroll(scrollbarContainer);
|
|
2316
|
+
const contentScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
2317
|
+
const contentScrollTop = pctScrollTop * maxScrollTop;
|
|
2046
2318
|
contentContainer.scrollTo({
|
|
2047
|
-
left:
|
|
2048
|
-
top:
|
|
2319
|
+
left: contentScrollLeft,
|
|
2320
|
+
top: contentScrollTop,
|
|
2049
2321
|
behavior: "auto"
|
|
2050
2322
|
});
|
|
2051
2323
|
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2324
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(0);
|
|
2325
|
+
}, [onVerticalScrollInSitu]);
|
|
2326
|
+
const handleContentContainerScroll = useCallback16(() => {
|
|
2327
|
+
const { current: scrollbarContainerScrolled } = scrollbarContainerScrolledRef;
|
|
2054
2328
|
const { current: contentContainer } = contentContainerRef;
|
|
2055
2329
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2056
|
-
const { current: scrollPos } =
|
|
2330
|
+
const { current: scrollPos } = contentContainerPosRef;
|
|
2057
2331
|
if (contentContainer && scrollbarContainer) {
|
|
2058
|
-
const
|
|
2059
|
-
|
|
2332
|
+
const [
|
|
2333
|
+
scrollLeft,
|
|
2334
|
+
pctScrollLeft,
|
|
2335
|
+
maxScrollLeft,
|
|
2336
|
+
scrollTop,
|
|
2337
|
+
pctScrollTop,
|
|
2338
|
+
maxScrollTop
|
|
2339
|
+
] = getPctScroll(contentContainer);
|
|
2060
2340
|
contentContainerScrolledRef.current = true;
|
|
2061
|
-
|
|
2062
|
-
|
|
2341
|
+
if (scrollbarContainerScrolled) {
|
|
2342
|
+
scrollbarContainerScrolledRef.current = false;
|
|
2343
|
+
} else {
|
|
2344
|
+
scrollbarContainer.scrollLeft = Math.round(
|
|
2345
|
+
pctScrollLeft * maxScrollLeft
|
|
2346
|
+
);
|
|
2347
|
+
scrollbarContainer.scrollTop = pctScrollTop * maxScrollTop;
|
|
2348
|
+
}
|
|
2063
2349
|
if (scrollPos.scrollTop !== scrollTop) {
|
|
2064
|
-
scrollPos.scrollTop = scrollTop;
|
|
2065
2350
|
handleVerticalScroll(scrollTop, pctScrollTop);
|
|
2066
2351
|
}
|
|
2067
2352
|
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
2068
|
-
|
|
2069
|
-
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
2353
|
+
handleHorizontalScroll(scrollLeft);
|
|
2070
2354
|
}
|
|
2071
2355
|
}
|
|
2072
|
-
}, [handleVerticalScroll,
|
|
2073
|
-
const handleAttachScrollbarContainer =
|
|
2356
|
+
}, [handleVerticalScroll, handleHorizontalScroll]);
|
|
2357
|
+
const handleAttachScrollbarContainer = useCallback16(
|
|
2074
2358
|
(el) => {
|
|
2075
2359
|
scrollbarContainerRef.current = el;
|
|
2076
2360
|
el.addEventListener("scroll", handleScrollbarContainerScroll, {
|
|
@@ -2079,14 +2363,14 @@ var useTableScroll = ({
|
|
|
2079
2363
|
},
|
|
2080
2364
|
[handleScrollbarContainerScroll]
|
|
2081
2365
|
);
|
|
2082
|
-
const handleDetachScrollbarContainer =
|
|
2366
|
+
const handleDetachScrollbarContainer = useCallback16(
|
|
2083
2367
|
(el) => {
|
|
2084
2368
|
scrollbarContainerRef.current = null;
|
|
2085
2369
|
el.removeEventListener("scroll", handleScrollbarContainerScroll);
|
|
2086
2370
|
},
|
|
2087
2371
|
[handleScrollbarContainerScroll]
|
|
2088
2372
|
);
|
|
2089
|
-
const handleAttachContentContainer =
|
|
2373
|
+
const handleAttachContentContainer = useCallback16(
|
|
2090
2374
|
(el) => {
|
|
2091
2375
|
contentContainerRef.current = el;
|
|
2092
2376
|
el.addEventListener("scroll", handleContentContainerScroll, {
|
|
@@ -2095,7 +2379,7 @@ var useTableScroll = ({
|
|
|
2095
2379
|
},
|
|
2096
2380
|
[handleContentContainerScroll]
|
|
2097
2381
|
);
|
|
2098
|
-
const handleDetachContentContainer =
|
|
2382
|
+
const handleDetachContentContainer = useCallback16(
|
|
2099
2383
|
(el) => {
|
|
2100
2384
|
contentContainerRef.current = null;
|
|
2101
2385
|
el.removeEventListener("scroll", handleContentContainerScroll);
|
|
@@ -2110,15 +2394,16 @@ var useTableScroll = ({
|
|
|
2110
2394
|
onAttach: handleAttachScrollbarContainer,
|
|
2111
2395
|
onDetach: handleDetachScrollbarContainer
|
|
2112
2396
|
});
|
|
2113
|
-
const requestScroll =
|
|
2397
|
+
const requestScroll = useCallback16(
|
|
2114
2398
|
(scrollRequest) => {
|
|
2115
|
-
const { current:
|
|
2116
|
-
if (
|
|
2117
|
-
const
|
|
2399
|
+
const { current: contentContainer } = contentContainerRef;
|
|
2400
|
+
if (contentContainer) {
|
|
2401
|
+
const [maxScrollLeft, maxScrollTop] = getMaxScroll(contentContainer);
|
|
2402
|
+
const { scrollLeft, scrollTop } = contentContainer;
|
|
2118
2403
|
contentContainerScrolledRef.current = false;
|
|
2119
2404
|
if (scrollRequest.type === "scroll-row") {
|
|
2120
2405
|
const activeRow = getRowElementAtIndex(
|
|
2121
|
-
|
|
2406
|
+
contentContainer,
|
|
2122
2407
|
scrollRequest.rowIndex
|
|
2123
2408
|
);
|
|
2124
2409
|
if (activeRow !== null) {
|
|
@@ -2128,10 +2413,14 @@ var useTableScroll = ({
|
|
|
2128
2413
|
);
|
|
2129
2414
|
if (direction && distance) {
|
|
2130
2415
|
if (isVirtualScroll) {
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2416
|
+
const offset = direction === "down" ? 1 : -1;
|
|
2417
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(offset);
|
|
2418
|
+
const firstRow = firstRowRef.current + offset;
|
|
2419
|
+
firstRowRef.current = firstRow;
|
|
2420
|
+
setRange({
|
|
2421
|
+
from: firstRow,
|
|
2422
|
+
to: firstRow + viewportRowCount
|
|
2423
|
+
});
|
|
2135
2424
|
} else {
|
|
2136
2425
|
let newScrollLeft = scrollLeft;
|
|
2137
2426
|
let newScrollTop = scrollTop;
|
|
@@ -2146,7 +2435,7 @@ var useTableScroll = ({
|
|
|
2146
2435
|
maxScrollLeft
|
|
2147
2436
|
);
|
|
2148
2437
|
}
|
|
2149
|
-
|
|
2438
|
+
contentContainer.scrollTo({
|
|
2150
2439
|
top: newScrollTop,
|
|
2151
2440
|
left: newScrollLeft,
|
|
2152
2441
|
behavior: "smooth"
|
|
@@ -2157,14 +2446,18 @@ var useTableScroll = ({
|
|
|
2157
2446
|
} else if (scrollRequest.type === "scroll-page") {
|
|
2158
2447
|
const { direction } = scrollRequest;
|
|
2159
2448
|
if (isVirtualScroll) {
|
|
2160
|
-
|
|
2449
|
+
const offset = direction === "down" ? viewportRowCount : -viewportRowCount;
|
|
2450
|
+
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(offset);
|
|
2451
|
+
const firstRow = firstRowRef.current + offset;
|
|
2452
|
+
firstRowRef.current = firstRow;
|
|
2453
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
2161
2454
|
} else {
|
|
2162
2455
|
const scrollBy = direction === "down" ? appliedPageSize : -appliedPageSize;
|
|
2163
2456
|
const newScrollTop = Math.min(
|
|
2164
2457
|
Math.max(0, scrollTop + scrollBy),
|
|
2165
2458
|
maxScrollTop
|
|
2166
2459
|
);
|
|
2167
|
-
|
|
2460
|
+
contentContainer.scrollTo({
|
|
2168
2461
|
top: newScrollTop,
|
|
2169
2462
|
left: scrollLeft,
|
|
2170
2463
|
behavior: "auto"
|
|
@@ -2173,9 +2466,9 @@ var useTableScroll = ({
|
|
|
2173
2466
|
} else if (scrollRequest.type === "scroll-end") {
|
|
2174
2467
|
const { direction } = scrollRequest;
|
|
2175
2468
|
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
2176
|
-
|
|
2469
|
+
contentContainer.scrollTo({
|
|
2177
2470
|
top: scrollTo,
|
|
2178
|
-
left:
|
|
2471
|
+
left: contentContainer.scrollLeft,
|
|
2179
2472
|
behavior: "auto"
|
|
2180
2473
|
});
|
|
2181
2474
|
}
|
|
@@ -2184,14 +2477,14 @@ var useTableScroll = ({
|
|
|
2184
2477
|
[
|
|
2185
2478
|
appliedPageSize,
|
|
2186
2479
|
isVirtualScroll,
|
|
2187
|
-
|
|
2188
|
-
maxScrollTop,
|
|
2480
|
+
onVerticalScrollInSitu,
|
|
2189
2481
|
setRange,
|
|
2190
2482
|
totalHeaderHeight,
|
|
2191
2483
|
viewportRowCount
|
|
2192
2484
|
]
|
|
2193
2485
|
);
|
|
2194
2486
|
const scrollHandles = useMemo4(
|
|
2487
|
+
// TODO not complete yet
|
|
2195
2488
|
() => ({
|
|
2196
2489
|
scrollToIndex: (rowIndex) => {
|
|
2197
2490
|
if (scrollbarContainerRef.current) {
|
|
@@ -2218,26 +2511,30 @@ var useTableScroll = ({
|
|
|
2218
2511
|
);
|
|
2219
2512
|
useEffect3(() => {
|
|
2220
2513
|
const { current: from } = firstRowRef;
|
|
2221
|
-
const rowRange = { from, to: from + viewportRowCount
|
|
2514
|
+
const rowRange = { from, to: from + viewportRowCount };
|
|
2222
2515
|
setRange(rowRange);
|
|
2223
2516
|
}, [setRange, viewportRowCount]);
|
|
2224
2517
|
return {
|
|
2518
|
+
columnsWithinViewport: columnsWithinViewportRef.current,
|
|
2225
2519
|
/** Ref to be assigned to ScrollbarContainer */
|
|
2226
2520
|
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
2227
2521
|
/** Ref to be assigned to ContentContainer */
|
|
2228
2522
|
contentContainerRef: contentContainerCallbackRef,
|
|
2229
2523
|
/** Scroll the table */
|
|
2230
|
-
requestScroll
|
|
2524
|
+
requestScroll,
|
|
2525
|
+
/** number of leading columns not rendered because of virtualization */
|
|
2526
|
+
virtualColSpan: preSpanRef.current
|
|
2231
2527
|
};
|
|
2232
2528
|
};
|
|
2233
2529
|
|
|
2234
2530
|
// src/useTableViewport.ts
|
|
2235
|
-
import { useCallback as useCallback16, useMemo as useMemo5, useRef as useRef11 } from "react";
|
|
2236
2531
|
import {
|
|
2237
2532
|
actualRowPositioning,
|
|
2533
|
+
measurePinnedColumns,
|
|
2238
2534
|
virtualRowPositioning
|
|
2239
2535
|
} from "@vuu-ui/vuu-utils";
|
|
2240
|
-
|
|
2536
|
+
import { useCallback as useCallback17, useMemo as useMemo5, useRef as useRef12 } from "react";
|
|
2537
|
+
var MAX_PIXEL_HEIGHT = 1e7;
|
|
2241
2538
|
var UNMEASURED_VIEWPORT = {
|
|
2242
2539
|
appliedPageSize: 0,
|
|
2243
2540
|
contentHeight: 0,
|
|
@@ -2246,36 +2543,15 @@ var UNMEASURED_VIEWPORT = {
|
|
|
2246
2543
|
getRowOffset: () => -1,
|
|
2247
2544
|
horizontalScrollbarHeight: 0,
|
|
2248
2545
|
isVirtualScroll: false,
|
|
2249
|
-
maxScrollContainerScrollHorizontal: 0,
|
|
2250
|
-
maxScrollContainerScrollVertical: 0,
|
|
2251
2546
|
pinnedWidthLeft: 0,
|
|
2252
2547
|
pinnedWidthRight: 0,
|
|
2253
2548
|
rowCount: 0,
|
|
2254
|
-
|
|
2549
|
+
setInSituRowOffset: () => void 0,
|
|
2550
|
+
setScrollTop: () => void 0,
|
|
2255
2551
|
totalHeaderHeight: 0,
|
|
2256
2552
|
verticalScrollbarWidth: 0,
|
|
2257
|
-
viewportBodyHeight: 0
|
|
2258
|
-
|
|
2259
|
-
var measurePinnedColumns = (columns) => {
|
|
2260
|
-
let pinnedWidthLeft = 0;
|
|
2261
|
-
let pinnedWidthRight = 0;
|
|
2262
|
-
let unpinnedWidth = 0;
|
|
2263
|
-
for (const column of columns) {
|
|
2264
|
-
const { hidden, pin, width } = column;
|
|
2265
|
-
const visibleWidth = hidden ? 0 : width;
|
|
2266
|
-
if (pin === "left") {
|
|
2267
|
-
pinnedWidthLeft += visibleWidth;
|
|
2268
|
-
} else if (pin === "right") {
|
|
2269
|
-
pinnedWidthRight += visibleWidth;
|
|
2270
|
-
} else {
|
|
2271
|
-
unpinnedWidth += visibleWidth;
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
return {
|
|
2275
|
-
pinnedWidthLeft: pinnedWidthLeft + 4,
|
|
2276
|
-
pinnedWidthRight: pinnedWidthRight + 4,
|
|
2277
|
-
unpinnedWidth
|
|
2278
|
-
};
|
|
2553
|
+
viewportBodyHeight: 0,
|
|
2554
|
+
viewportWidth: 0
|
|
2279
2555
|
};
|
|
2280
2556
|
var useTableViewport = ({
|
|
2281
2557
|
columns,
|
|
@@ -2283,48 +2559,58 @@ var useTableViewport = ({
|
|
|
2283
2559
|
headings,
|
|
2284
2560
|
rowCount,
|
|
2285
2561
|
rowHeight,
|
|
2562
|
+
selectionEndSize = 4,
|
|
2286
2563
|
size
|
|
2287
2564
|
}) => {
|
|
2288
|
-
const
|
|
2289
|
-
const
|
|
2565
|
+
const inSituRowOffsetRef = useRef12(0);
|
|
2566
|
+
const pctScrollTopRef = useRef12(0);
|
|
2567
|
+
const pixelContentHeight = Math.min(rowHeight * rowCount, MAX_PIXEL_HEIGHT);
|
|
2290
2568
|
const virtualContentHeight = rowCount * rowHeight;
|
|
2291
2569
|
const virtualisedExtent = virtualContentHeight - pixelContentHeight;
|
|
2292
2570
|
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = useMemo5(
|
|
2293
|
-
() => measurePinnedColumns(columns),
|
|
2294
|
-
[columns]
|
|
2571
|
+
() => measurePinnedColumns(columns, selectionEndSize),
|
|
2572
|
+
[columns, selectionEndSize]
|
|
2295
2573
|
);
|
|
2296
|
-
const totalHeaderHeightRef =
|
|
2574
|
+
const totalHeaderHeightRef = useRef12(headerHeight);
|
|
2297
2575
|
useMemo5(() => {
|
|
2298
2576
|
totalHeaderHeightRef.current = headerHeight * (1 + headings.length);
|
|
2299
2577
|
}, [headerHeight, headings.length]);
|
|
2300
2578
|
const [getRowOffset, getRowAtPosition, isVirtualScroll] = useMemo5(() => {
|
|
2301
2579
|
if (virtualisedExtent) {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2580
|
+
const [_getRowOffset, getRowAtPosition2, _isVirtual] = virtualRowPositioning(rowHeight, virtualisedExtent, pctScrollTopRef);
|
|
2581
|
+
const getOffset = (row) => {
|
|
2582
|
+
return _getRowOffset(row, inSituRowOffsetRef.current);
|
|
2583
|
+
};
|
|
2584
|
+
return [getOffset, getRowAtPosition2, _isVirtual];
|
|
2307
2585
|
} else {
|
|
2308
2586
|
return actualRowPositioning(rowHeight);
|
|
2309
2587
|
}
|
|
2310
2588
|
}, [virtualisedExtent, rowHeight]);
|
|
2311
|
-
const
|
|
2589
|
+
const setScrollTop = useCallback17((_, scrollPct) => {
|
|
2312
2590
|
pctScrollTopRef.current = scrollPct;
|
|
2313
2591
|
}, []);
|
|
2592
|
+
const setInSituRowOffset = useCallback17((rowIndexOffset) => {
|
|
2593
|
+
if (rowIndexOffset === 0) {
|
|
2594
|
+
inSituRowOffsetRef.current = 0;
|
|
2595
|
+
} else {
|
|
2596
|
+
inSituRowOffsetRef.current = Math.max(
|
|
2597
|
+
0,
|
|
2598
|
+
inSituRowOffsetRef.current + rowIndexOffset
|
|
2599
|
+
);
|
|
2600
|
+
}
|
|
2601
|
+
}, []);
|
|
2314
2602
|
return useMemo5(() => {
|
|
2315
|
-
var _a;
|
|
2316
2603
|
if (size) {
|
|
2317
2604
|
const { current: totalHeaderHeight } = totalHeaderHeightRef;
|
|
2318
2605
|
const scrollbarSize = 15;
|
|
2319
2606
|
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
2320
2607
|
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
2321
|
-
const maxScrollContainerScrollVertical = pixelContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
2322
|
-
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
2323
2608
|
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
2324
2609
|
const count = Number.isInteger(visibleRows) ? visibleRows : Math.ceil(visibleRows);
|
|
2325
2610
|
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
2326
2611
|
const verticalScrollbarWidth = pixelContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
2327
2612
|
const appliedPageSize = count * rowHeight * (pixelContentHeight / virtualContentHeight);
|
|
2613
|
+
const viewportWidth = size.width;
|
|
2328
2614
|
return {
|
|
2329
2615
|
appliedPageSize,
|
|
2330
2616
|
contentHeight: pixelContentHeight,
|
|
@@ -2333,15 +2619,15 @@ var useTableViewport = ({
|
|
|
2333
2619
|
getRowOffset,
|
|
2334
2620
|
isVirtualScroll,
|
|
2335
2621
|
horizontalScrollbarHeight,
|
|
2336
|
-
maxScrollContainerScrollHorizontal,
|
|
2337
|
-
maxScrollContainerScrollVertical,
|
|
2338
2622
|
pinnedWidthLeft,
|
|
2339
2623
|
pinnedWidthRight,
|
|
2340
2624
|
rowCount: count,
|
|
2341
|
-
|
|
2625
|
+
setInSituRowOffset,
|
|
2626
|
+
setScrollTop,
|
|
2342
2627
|
totalHeaderHeight,
|
|
2343
2628
|
verticalScrollbarWidth,
|
|
2344
|
-
viewportBodyHeight
|
|
2629
|
+
viewportBodyHeight,
|
|
2630
|
+
viewportWidth
|
|
2345
2631
|
};
|
|
2346
2632
|
} else {
|
|
2347
2633
|
return UNMEASURED_VIEWPORT;
|
|
@@ -2356,7 +2642,8 @@ var useTableViewport = ({
|
|
|
2356
2642
|
pinnedWidthRight,
|
|
2357
2643
|
pixelContentHeight,
|
|
2358
2644
|
rowHeight,
|
|
2359
|
-
|
|
2645
|
+
setInSituRowOffset,
|
|
2646
|
+
setScrollTop,
|
|
2360
2647
|
size,
|
|
2361
2648
|
virtualContentHeight
|
|
2362
2649
|
]);
|
|
@@ -2365,7 +2652,7 @@ var useTableViewport = ({
|
|
|
2365
2652
|
// src/useTableAndColumnSettings.ts
|
|
2366
2653
|
import { useLayoutProviderDispatch } from "@vuu-ui/vuu-layout";
|
|
2367
2654
|
import { getCalculatedColumnType } from "@vuu-ui/vuu-utils";
|
|
2368
|
-
import { useCallback as
|
|
2655
|
+
import { useCallback as useCallback18, useRef as useRef13, useState as useState6 } from "react";
|
|
2369
2656
|
var useTableAndColumnSettings = ({
|
|
2370
2657
|
availableColumns: availableColumnsProps,
|
|
2371
2658
|
onAvailableColumnsChange,
|
|
@@ -2375,11 +2662,11 @@ var useTableAndColumnSettings = ({
|
|
|
2375
2662
|
tableConfig
|
|
2376
2663
|
}) => {
|
|
2377
2664
|
const dispatchLayoutAction = useLayoutProviderDispatch();
|
|
2378
|
-
const showTableSettingsRef =
|
|
2379
|
-
const [availableColumns, setAvailableColumns] =
|
|
2665
|
+
const showTableSettingsRef = useRef13();
|
|
2666
|
+
const [availableColumns, setAvailableColumns] = useState6(
|
|
2380
2667
|
availableColumnsProps
|
|
2381
2668
|
);
|
|
2382
|
-
const showContextPanel =
|
|
2669
|
+
const showContextPanel = useCallback18(
|
|
2383
2670
|
(componentType, title, props) => {
|
|
2384
2671
|
dispatchLayoutAction({
|
|
2385
2672
|
type: "set-props",
|
|
@@ -2396,13 +2683,13 @@ var useTableAndColumnSettings = ({
|
|
|
2396
2683
|
},
|
|
2397
2684
|
[dispatchLayoutAction]
|
|
2398
2685
|
);
|
|
2399
|
-
const handleCancelCreateColumn =
|
|
2686
|
+
const handleCancelCreateColumn = useCallback18(() => {
|
|
2400
2687
|
requestAnimationFrame(() => {
|
|
2401
2688
|
var _a;
|
|
2402
2689
|
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2403
2690
|
});
|
|
2404
2691
|
}, []);
|
|
2405
|
-
const handleCreateCalculatedColumn =
|
|
2692
|
+
const handleCreateCalculatedColumn = useCallback18(
|
|
2406
2693
|
(column) => {
|
|
2407
2694
|
const newAvailableColumns = availableColumns.concat({
|
|
2408
2695
|
name: column.name,
|
|
@@ -2418,7 +2705,7 @@ var useTableAndColumnSettings = ({
|
|
|
2418
2705
|
},
|
|
2419
2706
|
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2420
2707
|
);
|
|
2421
|
-
const showColumnSettingsPanel =
|
|
2708
|
+
const showColumnSettingsPanel = useCallback18(
|
|
2422
2709
|
(action) => {
|
|
2423
2710
|
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2424
2711
|
column: action.column,
|
|
@@ -2437,7 +2724,7 @@ var useTableAndColumnSettings = ({
|
|
|
2437
2724
|
tableConfig
|
|
2438
2725
|
]
|
|
2439
2726
|
);
|
|
2440
|
-
const handleAddCalculatedColumn =
|
|
2727
|
+
const handleAddCalculatedColumn = useCallback18(() => {
|
|
2441
2728
|
showColumnSettingsPanel({
|
|
2442
2729
|
column: {
|
|
2443
2730
|
name: "::",
|
|
@@ -2447,7 +2734,7 @@ var useTableAndColumnSettings = ({
|
|
|
2447
2734
|
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2448
2735
|
});
|
|
2449
2736
|
}, [showColumnSettingsPanel]);
|
|
2450
|
-
const handleNavigateToColumn =
|
|
2737
|
+
const handleNavigateToColumn = useCallback18(
|
|
2451
2738
|
(columnName) => {
|
|
2452
2739
|
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2453
2740
|
if (column) {
|
|
@@ -2461,7 +2748,7 @@ var useTableAndColumnSettings = ({
|
|
|
2461
2748
|
},
|
|
2462
2749
|
[showColumnSettingsPanel, tableConfig.columns]
|
|
2463
2750
|
);
|
|
2464
|
-
showTableSettingsRef.current =
|
|
2751
|
+
showTableSettingsRef.current = useCallback18(() => {
|
|
2465
2752
|
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2466
2753
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2467
2754
|
name,
|
|
@@ -2492,7 +2779,7 @@ var useTableAndColumnSettings = ({
|
|
|
2492
2779
|
var stripInternalProperties = (tableConfig) => {
|
|
2493
2780
|
return tableConfig;
|
|
2494
2781
|
};
|
|
2495
|
-
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } =
|
|
2782
|
+
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = metadataKeys5;
|
|
2496
2783
|
var NULL_DRAG_DROP = {
|
|
2497
2784
|
draggable: void 0,
|
|
2498
2785
|
onMouseDown: void 0
|
|
@@ -2528,20 +2815,20 @@ var useTable = ({
|
|
|
2528
2815
|
selectionModel,
|
|
2529
2816
|
size
|
|
2530
2817
|
}) => {
|
|
2531
|
-
const [rowCount, setRowCount] =
|
|
2818
|
+
const [rowCount, setRowCount] = useState7(dataSource.size);
|
|
2532
2819
|
if (dataSource === void 0) {
|
|
2533
2820
|
throw Error("no data source provided to Vuu Table");
|
|
2534
2821
|
}
|
|
2535
|
-
const useRowDragDrop = allowDragDrop ?
|
|
2822
|
+
const useRowDragDrop = allowDragDrop ? useDragDrop2 : useNullDragDrop;
|
|
2536
2823
|
const menuBuilder = useMemo6(
|
|
2537
2824
|
() => buildContextMenuDescriptors(dataSource),
|
|
2538
2825
|
[dataSource]
|
|
2539
2826
|
);
|
|
2540
|
-
const onDataRowcountChange =
|
|
2827
|
+
const onDataRowcountChange = useCallback19((size2) => {
|
|
2541
2828
|
setRowCount(size2);
|
|
2542
2829
|
}, []);
|
|
2543
2830
|
const {
|
|
2544
|
-
columns
|
|
2831
|
+
columns,
|
|
2545
2832
|
dispatchColumnAction,
|
|
2546
2833
|
headings,
|
|
2547
2834
|
tableAttributes,
|
|
@@ -2550,11 +2837,11 @@ var useTable = ({
|
|
|
2550
2837
|
useLayoutEffectSkipFirst2(() => {
|
|
2551
2838
|
dispatchColumnAction({
|
|
2552
2839
|
type: "init",
|
|
2553
|
-
|
|
2554
|
-
|
|
2840
|
+
tableConfig: config,
|
|
2841
|
+
dataSource
|
|
2555
2842
|
});
|
|
2556
|
-
}, [
|
|
2557
|
-
const applyTableConfigChange =
|
|
2843
|
+
}, [config, dataSource, dispatchColumnAction]);
|
|
2844
|
+
const applyTableConfigChange = useCallback19(
|
|
2558
2845
|
(config2) => {
|
|
2559
2846
|
dispatchColumnAction({
|
|
2560
2847
|
type: "init",
|
|
@@ -2565,22 +2852,28 @@ var useTable = ({
|
|
|
2565
2852
|
},
|
|
2566
2853
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2567
2854
|
);
|
|
2568
|
-
const [stateColumns, setStateColumns] = useState6();
|
|
2569
|
-
const [columns, setColumnSize] = useMemo6(() => {
|
|
2570
|
-
const setSize = (columnName, width) => {
|
|
2571
|
-
const cols = updateColumn(runtimeColumns, columnName, { width });
|
|
2572
|
-
setStateColumns(cols);
|
|
2573
|
-
};
|
|
2574
|
-
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2575
|
-
}, [runtimeColumns, stateColumns]);
|
|
2576
2855
|
const columnMap = useMemo6(
|
|
2577
2856
|
() => buildColumnMap2(dataSource.columns),
|
|
2578
2857
|
[dataSource.columns]
|
|
2579
2858
|
);
|
|
2859
|
+
const onSubscribed = useCallback19(
|
|
2860
|
+
({ tableSchema }) => {
|
|
2861
|
+
if (tableSchema) {
|
|
2862
|
+
dispatchColumnAction({
|
|
2863
|
+
type: "setTableSchema",
|
|
2864
|
+
tableSchema
|
|
2865
|
+
});
|
|
2866
|
+
} else {
|
|
2867
|
+
console.log("subscription message with no schema");
|
|
2868
|
+
}
|
|
2869
|
+
},
|
|
2870
|
+
[dispatchColumnAction]
|
|
2871
|
+
);
|
|
2580
2872
|
const {
|
|
2581
2873
|
getRowAtPosition,
|
|
2582
2874
|
getRowOffset,
|
|
2583
|
-
|
|
2875
|
+
setInSituRowOffset: viewportHookSetInSituRowOffset,
|
|
2876
|
+
setScrollTop: viewportHookSetScrollTop,
|
|
2584
2877
|
...viewportMeasurements
|
|
2585
2878
|
} = useTableViewport({
|
|
2586
2879
|
columns,
|
|
@@ -2592,21 +2885,8 @@ var useTable = ({
|
|
|
2592
2885
|
});
|
|
2593
2886
|
const initialRange = useInitialValue({
|
|
2594
2887
|
from: 0,
|
|
2595
|
-
to: viewportMeasurements.rowCount
|
|
2888
|
+
to: viewportMeasurements.rowCount
|
|
2596
2889
|
});
|
|
2597
|
-
const onSubscribed = useCallback18(
|
|
2598
|
-
({ tableSchema }) => {
|
|
2599
|
-
if (tableSchema) {
|
|
2600
|
-
dispatchColumnAction({
|
|
2601
|
-
type: "setTableSchema",
|
|
2602
|
-
tableSchema
|
|
2603
|
-
});
|
|
2604
|
-
} else {
|
|
2605
|
-
console.log("subscription message with no schema");
|
|
2606
|
-
}
|
|
2607
|
-
},
|
|
2608
|
-
[dispatchColumnAction]
|
|
2609
|
-
);
|
|
2610
2890
|
const { data, dataRef, getSelectedRows, range, setRange } = useDataSource({
|
|
2611
2891
|
dataSource,
|
|
2612
2892
|
// We need to factor this out of Table
|
|
@@ -2616,7 +2896,17 @@ var useTable = ({
|
|
|
2616
2896
|
onSubscribed,
|
|
2617
2897
|
range: initialRange
|
|
2618
2898
|
});
|
|
2619
|
-
const
|
|
2899
|
+
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2900
|
+
columns,
|
|
2901
|
+
getRowAtPosition,
|
|
2902
|
+
rowHeight,
|
|
2903
|
+
scrollingApiRef,
|
|
2904
|
+
setRange,
|
|
2905
|
+
onVerticalScroll: viewportHookSetScrollTop,
|
|
2906
|
+
onVerticalScrollInSitu: viewportHookSetInSituRowOffset,
|
|
2907
|
+
viewportMeasurements
|
|
2908
|
+
});
|
|
2909
|
+
const handleConfigEditedInSettingsPanel = useCallback19(
|
|
2620
2910
|
(tableConfig2) => {
|
|
2621
2911
|
dispatchColumnAction({
|
|
2622
2912
|
type: "init",
|
|
@@ -2627,7 +2917,7 @@ var useTable = ({
|
|
|
2627
2917
|
},
|
|
2628
2918
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2629
2919
|
);
|
|
2630
|
-
const handleDataSourceConfigChanged =
|
|
2920
|
+
const handleDataSourceConfigChanged = useCallback19(
|
|
2631
2921
|
(dataSourceConfig) => {
|
|
2632
2922
|
dataSource.config = {
|
|
2633
2923
|
...dataSource.config,
|
|
@@ -2645,14 +2935,14 @@ var useTable = ({
|
|
|
2645
2935
|
});
|
|
2646
2936
|
});
|
|
2647
2937
|
}, [dataSource, dispatchColumnAction]);
|
|
2648
|
-
const handleCreateCalculatedColumn =
|
|
2938
|
+
const handleCreateCalculatedColumn = useCallback19(
|
|
2649
2939
|
(column) => {
|
|
2650
2940
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2651
2941
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2652
2942
|
},
|
|
2653
2943
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2654
2944
|
);
|
|
2655
|
-
const hideColumns2 =
|
|
2945
|
+
const hideColumns2 = useCallback19(
|
|
2656
2946
|
(action) => {
|
|
2657
2947
|
const { columns: columns2 } = action;
|
|
2658
2948
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2666,7 +2956,7 @@ var useTable = ({
|
|
|
2666
2956
|
},
|
|
2667
2957
|
[tableConfig, applyTableConfigChange]
|
|
2668
2958
|
);
|
|
2669
|
-
const pinColumn3 =
|
|
2959
|
+
const pinColumn3 = useCallback19(
|
|
2670
2960
|
(action) => {
|
|
2671
2961
|
applyTableConfigChange({
|
|
2672
2962
|
...tableConfig,
|
|
@@ -2689,7 +2979,7 @@ var useTable = ({
|
|
|
2689
2979
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2690
2980
|
tableConfig
|
|
2691
2981
|
});
|
|
2692
|
-
const onPersistentColumnOperation =
|
|
2982
|
+
const onPersistentColumnOperation = useCallback19(
|
|
2693
2983
|
(action) => {
|
|
2694
2984
|
if (isShowColumnSettings(action)) {
|
|
2695
2985
|
showColumnSettingsPanel(action);
|
|
@@ -2718,7 +3008,7 @@ var useTable = ({
|
|
|
2718
3008
|
dataSource,
|
|
2719
3009
|
onPersistentColumnOperation
|
|
2720
3010
|
});
|
|
2721
|
-
const handleSort =
|
|
3011
|
+
const handleSort = useCallback19(
|
|
2722
3012
|
(column, extendSort = false, sortType) => {
|
|
2723
3013
|
if (dataSource) {
|
|
2724
3014
|
dataSource.sort = applySort(
|
|
@@ -2731,15 +3021,18 @@ var useTable = ({
|
|
|
2731
3021
|
},
|
|
2732
3022
|
[dataSource]
|
|
2733
3023
|
);
|
|
2734
|
-
const
|
|
3024
|
+
const resizeCells = useRef14();
|
|
3025
|
+
const onResizeColumn = useCallback19(
|
|
2735
3026
|
(phase, columnName, width) => {
|
|
3027
|
+
var _a, _b, _c;
|
|
2736
3028
|
const column = columns.find((column2) => column2.name === columnName);
|
|
2737
3029
|
if (column) {
|
|
2738
3030
|
if (phase === "resize") {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
}
|
|
3031
|
+
(_a = resizeCells.current) == null ? void 0 : _a.forEach((cell) => {
|
|
3032
|
+
cell.style.width = `${width}px`;
|
|
3033
|
+
});
|
|
2742
3034
|
} else if (phase === "end") {
|
|
3035
|
+
resizeCells.current = void 0;
|
|
2743
3036
|
if (isValidNumber(width)) {
|
|
2744
3037
|
dispatchColumnAction({
|
|
2745
3038
|
type: "resizeColumn",
|
|
@@ -2747,7 +3040,6 @@ var useTable = ({
|
|
|
2747
3040
|
column,
|
|
2748
3041
|
width
|
|
2749
3042
|
});
|
|
2750
|
-
setStateColumns(void 0);
|
|
2751
3043
|
onConfigChange == null ? void 0 : onConfigChange(
|
|
2752
3044
|
stripInternalProperties(
|
|
2753
3045
|
updateTableConfig(tableConfig, {
|
|
@@ -2759,7 +3051,12 @@ var useTable = ({
|
|
|
2759
3051
|
);
|
|
2760
3052
|
}
|
|
2761
3053
|
} else {
|
|
2762
|
-
|
|
3054
|
+
const byColIndex = `[aria-colindex='${column.index}']`;
|
|
3055
|
+
resizeCells.current = Array.from(
|
|
3056
|
+
(_c = (_b = containerRef.current) == null ? void 0 : _b.querySelectorAll(
|
|
3057
|
+
`.vuuTableCell${byColIndex},.vuuTableHeaderCell${byColIndex}`
|
|
3058
|
+
)) != null ? _c : []
|
|
3059
|
+
);
|
|
2763
3060
|
dispatchColumnAction({
|
|
2764
3061
|
type: "resizeColumn",
|
|
2765
3062
|
phase,
|
|
@@ -2773,12 +3070,12 @@ var useTable = ({
|
|
|
2773
3070
|
);
|
|
2774
3071
|
}
|
|
2775
3072
|
},
|
|
2776
|
-
[columns,
|
|
3073
|
+
[columns, dispatchColumnAction, onConfigChange, tableConfig, containerRef]
|
|
2777
3074
|
);
|
|
2778
|
-
const onToggleGroup =
|
|
3075
|
+
const onToggleGroup = useCallback19(
|
|
2779
3076
|
(row, column) => {
|
|
2780
3077
|
var _a, _b;
|
|
2781
|
-
const isJson = isJsonGroup2(column, row);
|
|
3078
|
+
const isJson = isJsonGroup2(column, row, columnMap);
|
|
2782
3079
|
const key = row[KEY];
|
|
2783
3080
|
if (row[IS_EXPANDED2]) {
|
|
2784
3081
|
dataSource.closeTreeNode(key, true);
|
|
@@ -2810,22 +3107,8 @@ var useTable = ({
|
|
|
2810
3107
|
}
|
|
2811
3108
|
}
|
|
2812
3109
|
},
|
|
2813
|
-
[columns, dataSource, dispatchColumnAction]
|
|
3110
|
+
[columnMap, columns, dataSource, dispatchColumnAction]
|
|
2814
3111
|
);
|
|
2815
|
-
const handleVerticalScroll = useCallback18(
|
|
2816
|
-
(_, pctScrollTop) => {
|
|
2817
|
-
setPctScrollTop(pctScrollTop);
|
|
2818
|
-
},
|
|
2819
|
-
[setPctScrollTop]
|
|
2820
|
-
);
|
|
2821
|
-
const { requestScroll, ...scrollProps } = useTableScroll({
|
|
2822
|
-
getRowAtPosition,
|
|
2823
|
-
rowHeight,
|
|
2824
|
-
scrollingApiRef,
|
|
2825
|
-
setRange,
|
|
2826
|
-
onVerticalScroll: handleVerticalScroll,
|
|
2827
|
-
viewportMeasurements
|
|
2828
|
-
});
|
|
2829
3112
|
const {
|
|
2830
3113
|
highlightedIndexRef,
|
|
2831
3114
|
navigate,
|
|
@@ -2852,7 +3135,7 @@ var useTable = ({
|
|
|
2852
3135
|
} = useCellEditing({
|
|
2853
3136
|
navigate
|
|
2854
3137
|
});
|
|
2855
|
-
const handleFocus =
|
|
3138
|
+
const handleFocus = useCallback19(
|
|
2856
3139
|
(e) => {
|
|
2857
3140
|
navigationFocus();
|
|
2858
3141
|
if (!e.defaultPrevented) {
|
|
@@ -2867,15 +3150,15 @@ var useTable = ({
|
|
|
2867
3150
|
dataSource,
|
|
2868
3151
|
getSelectedRows
|
|
2869
3152
|
});
|
|
2870
|
-
const onMoveGroupColumn =
|
|
3153
|
+
const onMoveGroupColumn = useCallback19(
|
|
2871
3154
|
(columns2) => {
|
|
2872
3155
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2873
3156
|
},
|
|
2874
3157
|
[dataSource]
|
|
2875
3158
|
);
|
|
2876
|
-
const onRemoveGroupColumn =
|
|
3159
|
+
const onRemoveGroupColumn = useCallback19(
|
|
2877
3160
|
(column) => {
|
|
2878
|
-
if (
|
|
3161
|
+
if (isGroupColumn4(column)) {
|
|
2879
3162
|
dataSource.groupBy = [];
|
|
2880
3163
|
} else {
|
|
2881
3164
|
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
@@ -2887,7 +3170,7 @@ var useTable = ({
|
|
|
2887
3170
|
},
|
|
2888
3171
|
[dataSource]
|
|
2889
3172
|
);
|
|
2890
|
-
const handleSelectionChange =
|
|
3173
|
+
const handleSelectionChange = useCallback19(
|
|
2891
3174
|
(selected) => {
|
|
2892
3175
|
dataSource.select(selected);
|
|
2893
3176
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
@@ -2903,7 +3186,7 @@ var useTable = ({
|
|
|
2903
3186
|
onSelectionChange: handleSelectionChange,
|
|
2904
3187
|
selectionModel
|
|
2905
3188
|
});
|
|
2906
|
-
const handleKeyDown =
|
|
3189
|
+
const handleKeyDown = useCallback19(
|
|
2907
3190
|
(e) => {
|
|
2908
3191
|
navigationKeyDown(e);
|
|
2909
3192
|
if (!e.defaultPrevented) {
|
|
@@ -2915,25 +3198,15 @@ var useTable = ({
|
|
|
2915
3198
|
},
|
|
2916
3199
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2917
3200
|
);
|
|
2918
|
-
const handleRowClick =
|
|
3201
|
+
const handleRowClick = useCallback19(
|
|
2919
3202
|
(row, rangeSelect, keepExistingSelection) => {
|
|
2920
3203
|
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2921
3204
|
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
2922
3205
|
},
|
|
2923
3206
|
[onRowClickProp, selectionHookOnRowClick]
|
|
2924
3207
|
);
|
|
2925
|
-
|
|
2926
|
-
dispatchColumnAction({
|
|
2927
|
-
type: "init",
|
|
2928
|
-
tableConfig: config,
|
|
2929
|
-
dataSource
|
|
2930
|
-
});
|
|
2931
|
-
}, [config, dataSource, dispatchColumnAction]);
|
|
2932
|
-
const onMoveColumn = useCallback18(
|
|
3208
|
+
const onMoveColumn = useCallback19(
|
|
2933
3209
|
(columns2) => {
|
|
2934
|
-
console.log(`useTable onMoveColumn`, {
|
|
2935
|
-
columns: columns2
|
|
2936
|
-
});
|
|
2937
3210
|
const newTableConfig = {
|
|
2938
3211
|
...tableConfig,
|
|
2939
3212
|
columns: columns2
|
|
@@ -2947,17 +3220,17 @@ var useTable = ({
|
|
|
2947
3220
|
},
|
|
2948
3221
|
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2949
3222
|
);
|
|
2950
|
-
const handleDropRow =
|
|
3223
|
+
const handleDropRow = useCallback19(
|
|
2951
3224
|
(dragDropState) => {
|
|
2952
3225
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2953
3226
|
},
|
|
2954
3227
|
[onDrop]
|
|
2955
3228
|
);
|
|
2956
|
-
const handleDataEdited =
|
|
3229
|
+
const handleDataEdited = useCallback19(
|
|
2957
3230
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2958
3231
|
[dataSource]
|
|
2959
3232
|
);
|
|
2960
|
-
const handleDragStartRow =
|
|
3233
|
+
const handleDragStartRow = useCallback19(
|
|
2961
3234
|
(dragDropState) => {
|
|
2962
3235
|
const { initialDragElement } = dragDropState;
|
|
2963
3236
|
const rowIndex = getIndexFromRowElement3(initialDragElement);
|
|
@@ -3014,137 +3287,10 @@ var useTable = ({
|
|
|
3014
3287
|
};
|
|
3015
3288
|
};
|
|
3016
3289
|
|
|
3017
|
-
// src/table-header/TableHeader.tsx
|
|
3018
|
-
import { isGroupColumn as isGroupColumn4, isNotHidden as isNotHidden2 } from "@vuu-ui/vuu-utils";
|
|
3019
|
-
import cx8 from "clsx";
|
|
3020
|
-
|
|
3021
|
-
// src/table-header/useTableHeader.ts
|
|
3022
|
-
import { useDragDrop as useDragDrop2 } from "@vuu-ui/vuu-ui-controls";
|
|
3023
|
-
import { moveColumnTo, visibleColumnAtIndex } from "@vuu-ui/vuu-utils";
|
|
3024
|
-
import { useCallback as useCallback19, useRef as useRef13 } from "react";
|
|
3025
|
-
var useTableHeader = ({
|
|
3026
|
-
columns,
|
|
3027
|
-
onMoveColumn,
|
|
3028
|
-
onSortColumn,
|
|
3029
|
-
tableConfig
|
|
3030
|
-
}) => {
|
|
3031
|
-
const containerRef = useRef13(null);
|
|
3032
|
-
const handleDropColumnHeader = useCallback19(
|
|
3033
|
-
(moveFrom, moveTo) => {
|
|
3034
|
-
const column = columns[moveFrom];
|
|
3035
|
-
const orderedColumns = moveColumnTo(columns, column, moveTo);
|
|
3036
|
-
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
3037
|
-
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
3038
|
-
const nextColumn = orderedColumns[targetIndex + 1];
|
|
3039
|
-
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
3040
|
-
if (moveTo > moveFrom && insertPos !== -1) {
|
|
3041
|
-
onMoveColumn(moveColumnTo(tableConfig.columns, column, insertPos - 1));
|
|
3042
|
-
} else {
|
|
3043
|
-
onMoveColumn(moveColumnTo(tableConfig.columns, column, insertPos));
|
|
3044
|
-
}
|
|
3045
|
-
},
|
|
3046
|
-
[columns, onMoveColumn, tableConfig.columns]
|
|
3047
|
-
);
|
|
3048
|
-
const handleColumnHeaderClick = useCallback19(
|
|
3049
|
-
(evt) => {
|
|
3050
|
-
var _a;
|
|
3051
|
-
const targetElement = evt.target;
|
|
3052
|
-
const headerCell = targetElement.closest(
|
|
3053
|
-
".vuuTableHeaderCell"
|
|
3054
|
-
);
|
|
3055
|
-
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
3056
|
-
const column = visibleColumnAtIndex(columns, colIdx);
|
|
3057
|
-
const isAdditive = evt.shiftKey;
|
|
3058
|
-
column && onSortColumn(column, isAdditive);
|
|
3059
|
-
},
|
|
3060
|
-
[columns, onSortColumn]
|
|
3061
|
-
);
|
|
3062
|
-
const {
|
|
3063
|
-
onMouseDown: columnHeaderDragMouseDown,
|
|
3064
|
-
draggable: draggableColumn,
|
|
3065
|
-
...dragDropHook
|
|
3066
|
-
} = useDragDrop2({
|
|
3067
|
-
allowDragDrop: true,
|
|
3068
|
-
containerRef,
|
|
3069
|
-
draggableClassName: `vuuTable`,
|
|
3070
|
-
onDrop: handleDropColumnHeader,
|
|
3071
|
-
orientation: "horizontal",
|
|
3072
|
-
itemQuery: ".vuuTableHeaderCell"
|
|
3073
|
-
});
|
|
3074
|
-
return {
|
|
3075
|
-
containerRef,
|
|
3076
|
-
draggableColumn,
|
|
3077
|
-
draggedColumnIndex: dragDropHook.draggedItemIndex,
|
|
3078
|
-
onClick: handleColumnHeaderClick,
|
|
3079
|
-
onMouseDown: columnHeaderDragMouseDown
|
|
3080
|
-
};
|
|
3081
|
-
};
|
|
3082
|
-
|
|
3083
|
-
// src/table-header/TableHeader.tsx
|
|
3084
|
-
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3085
|
-
var TableHeader = ({
|
|
3086
|
-
classBase: classBase10 = "vuuTable",
|
|
3087
|
-
columns,
|
|
3088
|
-
headings,
|
|
3089
|
-
onMoveColumn,
|
|
3090
|
-
onMoveGroupColumn,
|
|
3091
|
-
onRemoveGroupColumn,
|
|
3092
|
-
onResizeColumn,
|
|
3093
|
-
onSortColumn,
|
|
3094
|
-
tableConfig,
|
|
3095
|
-
tableId
|
|
3096
|
-
}) => {
|
|
3097
|
-
const {
|
|
3098
|
-
containerRef,
|
|
3099
|
-
draggableColumn,
|
|
3100
|
-
draggedColumnIndex,
|
|
3101
|
-
onClick,
|
|
3102
|
-
onMouseDown
|
|
3103
|
-
} = useTableHeader({
|
|
3104
|
-
columns,
|
|
3105
|
-
onMoveColumn,
|
|
3106
|
-
onSortColumn,
|
|
3107
|
-
tableConfig
|
|
3108
|
-
});
|
|
3109
|
-
return /* @__PURE__ */ jsxs7("div", { className: `${classBase10}-col-headings`, ref: containerRef, children: [
|
|
3110
|
-
headings.map((colHeaders, i) => /* @__PURE__ */ jsx11("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ jsx11("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
|
|
3111
|
-
/* @__PURE__ */ jsxs7("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
3112
|
-
columns.filter(isNotHidden2).map(
|
|
3113
|
-
(col, i) => isGroupColumn4(col) ? /* @__PURE__ */ jsx11(
|
|
3114
|
-
GroupHeaderCellNext,
|
|
3115
|
-
{
|
|
3116
|
-
column: col,
|
|
3117
|
-
"data-index": i,
|
|
3118
|
-
onMoveColumn: onMoveGroupColumn,
|
|
3119
|
-
onRemoveColumn: onRemoveGroupColumn,
|
|
3120
|
-
onResize: onResizeColumn
|
|
3121
|
-
},
|
|
3122
|
-
col.name
|
|
3123
|
-
) : /* @__PURE__ */ jsx11(
|
|
3124
|
-
HeaderCell,
|
|
3125
|
-
{
|
|
3126
|
-
className: cx8({
|
|
3127
|
-
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
3128
|
-
}),
|
|
3129
|
-
column: col,
|
|
3130
|
-
"data-index": i,
|
|
3131
|
-
id: `${tableId}-col-${i}`,
|
|
3132
|
-
onClick,
|
|
3133
|
-
onMouseDown,
|
|
3134
|
-
onResize: onResizeColumn
|
|
3135
|
-
},
|
|
3136
|
-
col.name
|
|
3137
|
-
)
|
|
3138
|
-
),
|
|
3139
|
-
draggableColumn
|
|
3140
|
-
] })
|
|
3141
|
-
] });
|
|
3142
|
-
};
|
|
3143
|
-
|
|
3144
3290
|
// src/Table.tsx
|
|
3145
|
-
import { jsx as jsx12, jsxs as
|
|
3291
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3146
3292
|
var classBase7 = "vuuTable";
|
|
3147
|
-
var { IDX: IDX3, RENDER_IDX } =
|
|
3293
|
+
var { IDX: IDX3, RENDER_IDX } = metadataKeys6;
|
|
3148
3294
|
var TableCore = ({
|
|
3149
3295
|
Row: Row2 = Row,
|
|
3150
3296
|
allowDragDrop,
|
|
@@ -3226,9 +3372,7 @@ var TableCore = ({
|
|
|
3226
3372
|
const contentContainerClassName = cx9(`${classBase7}-contentContainer`, {
|
|
3227
3373
|
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3228
3374
|
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3229
|
-
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
3230
3375
|
[`${classBase7}-zebra`]: tableAttributes.zebraStripes
|
|
3231
|
-
// [`${classBase}-loading`]: isDataLoading(tableProps.columns),
|
|
3232
3376
|
});
|
|
3233
3377
|
const cssVariables = {
|
|
3234
3378
|
"--content-height": `${viewportMeasurements.contentHeight}px`,
|
|
@@ -3242,7 +3386,7 @@ var TableCore = ({
|
|
|
3242
3386
|
"--vertical-scrollbar-width": `${viewportMeasurements.verticalScrollbarWidth}px`,
|
|
3243
3387
|
"--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
|
|
3244
3388
|
};
|
|
3245
|
-
return /* @__PURE__ */
|
|
3389
|
+
return /* @__PURE__ */ jsxs9(
|
|
3246
3390
|
ContextMenuProvider,
|
|
3247
3391
|
{
|
|
3248
3392
|
menuActionHandler: handleContextMenuAction,
|
|
@@ -3263,7 +3407,7 @@ var TableCore = ({
|
|
|
3263
3407
|
className: contentContainerClassName,
|
|
3264
3408
|
ref: scrollProps.contentContainerRef,
|
|
3265
3409
|
style: cssVariables,
|
|
3266
|
-
children: /* @__PURE__ */
|
|
3410
|
+
children: /* @__PURE__ */ jsxs9(
|
|
3267
3411
|
"div",
|
|
3268
3412
|
{
|
|
3269
3413
|
...tableProps,
|
|
@@ -3274,7 +3418,7 @@ var TableCore = ({
|
|
|
3274
3418
|
showColumnHeaders ? /* @__PURE__ */ jsx12(
|
|
3275
3419
|
TableHeader,
|
|
3276
3420
|
{
|
|
3277
|
-
columns,
|
|
3421
|
+
columns: scrollProps.columnsWithinViewport,
|
|
3278
3422
|
headings,
|
|
3279
3423
|
onMoveColumn,
|
|
3280
3424
|
onMoveGroupColumn,
|
|
@@ -3282,7 +3426,8 @@ var TableCore = ({
|
|
|
3282
3426
|
onResizeColumn,
|
|
3283
3427
|
onSortColumn,
|
|
3284
3428
|
tableConfig,
|
|
3285
|
-
tableId: id
|
|
3429
|
+
tableId: id,
|
|
3430
|
+
virtualColSpan: scrollProps.virtualColSpan
|
|
3286
3431
|
}
|
|
3287
3432
|
) : null,
|
|
3288
3433
|
/* @__PURE__ */ jsx12("div", { className: `${classBase7}-body`, children: data.map((data2) => /* @__PURE__ */ jsx12(
|
|
@@ -3290,13 +3435,14 @@ var TableCore = ({
|
|
|
3290
3435
|
{
|
|
3291
3436
|
"aria-rowindex": data2[0] + 1,
|
|
3292
3437
|
columnMap,
|
|
3293
|
-
columns,
|
|
3438
|
+
columns: scrollProps.columnsWithinViewport,
|
|
3294
3439
|
highlighted: highlightedIndex === data2[IDX3],
|
|
3295
3440
|
onClick: onRowClick,
|
|
3296
3441
|
onDataEdited,
|
|
3297
3442
|
row: data2,
|
|
3298
3443
|
offset: getRowOffset(data2),
|
|
3299
3444
|
onToggleGroup,
|
|
3445
|
+
virtualColSpan: scrollProps.virtualColSpan,
|
|
3300
3446
|
zebraStripes: tableAttributes.zebraStripes
|
|
3301
3447
|
},
|
|
3302
3448
|
data2[RENDER_IDX]
|
|
@@ -3340,8 +3486,8 @@ var Table = forwardRef(function TableNext({
|
|
|
3340
3486
|
style: styleProp,
|
|
3341
3487
|
...htmlAttributes
|
|
3342
3488
|
}, forwardedRef) {
|
|
3343
|
-
const containerRef =
|
|
3344
|
-
const [size, setSize] =
|
|
3489
|
+
const containerRef = useRef15(null);
|
|
3490
|
+
const [size, setSize] = useState8();
|
|
3345
3491
|
if (config === void 0) {
|
|
3346
3492
|
throw Error(
|
|
3347
3493
|
"vuu Table requires config prop. Minimum config is list of Column Descriptors"
|
|
@@ -3394,17 +3540,16 @@ var Table = forwardRef(function TableNext({
|
|
|
3394
3540
|
});
|
|
3395
3541
|
|
|
3396
3542
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3397
|
-
import { memo as
|
|
3543
|
+
import { memo as memo3, useCallback as useCallback20 } from "react";
|
|
3398
3544
|
import { CheckboxIcon, WarnCommit } from "@vuu-ui/vuu-ui-controls";
|
|
3399
3545
|
import { Checkbox } from "@salt-ds/core";
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
import { dispatchCustomEvent, registerComponent } from "@vuu-ui/vuu-utils";
|
|
3546
|
+
import {
|
|
3547
|
+
dataAndColumnUnchanged,
|
|
3548
|
+
dispatchCustomEvent,
|
|
3549
|
+
registerComponent
|
|
3550
|
+
} from "@vuu-ui/vuu-utils";
|
|
3406
3551
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
3407
|
-
var CheckboxCell =
|
|
3552
|
+
var CheckboxCell = memo3(
|
|
3408
3553
|
({ column, columnMap, onCommit = WarnCommit, row }) => {
|
|
3409
3554
|
const dataIdx = columnMap[column.name];
|
|
3410
3555
|
const isChecked = row[dataIdx];
|
|
@@ -3472,13 +3617,14 @@ registerComponent2("input-cell", InputCell, "cell-renderer", {});
|
|
|
3472
3617
|
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3473
3618
|
import { WarnCommit as WarnCommit3 } from "@vuu-ui/vuu-ui-controls";
|
|
3474
3619
|
import {
|
|
3620
|
+
dataAndColumnUnchanged as dataAndColumnUnchanged2,
|
|
3475
3621
|
dispatchCustomEvent as dispatchCustomEvent2,
|
|
3476
3622
|
isTypeDescriptor,
|
|
3477
3623
|
isValueListRenderer,
|
|
3478
3624
|
registerComponent as registerComponent3
|
|
3479
3625
|
} from "@vuu-ui/vuu-utils";
|
|
3480
3626
|
import cx11 from "clsx";
|
|
3481
|
-
import { memo as
|
|
3627
|
+
import { memo as memo4, useCallback as useCallback21 } from "react";
|
|
3482
3628
|
import { CycleStateButton } from "@vuu-ui/vuu-ui-controls";
|
|
3483
3629
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3484
3630
|
var classBase9 = "vuuTableToggleCell";
|
|
@@ -3491,7 +3637,7 @@ var getValueList = ({ name, type }) => {
|
|
|
3491
3637
|
);
|
|
3492
3638
|
}
|
|
3493
3639
|
};
|
|
3494
|
-
var ToggleCell =
|
|
3640
|
+
var ToggleCell = memo4(
|
|
3495
3641
|
function ToggleCell2({
|
|
3496
3642
|
column,
|
|
3497
3643
|
columnMap,
|
|
@@ -3524,16 +3670,16 @@ var ToggleCell = memo3(
|
|
|
3524
3670
|
}
|
|
3525
3671
|
);
|
|
3526
3672
|
},
|
|
3527
|
-
|
|
3673
|
+
dataAndColumnUnchanged2
|
|
3528
3674
|
);
|
|
3529
3675
|
registerComponent3("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
3530
3676
|
|
|
3531
3677
|
// src/useControlledTableNavigation.ts
|
|
3532
3678
|
import { useStateRef } from "@vuu-ui/vuu-ui-controls";
|
|
3533
3679
|
import { dispatchMouseEvent as dispatchMouseEvent2 } from "@vuu-ui/vuu-utils";
|
|
3534
|
-
import { useCallback as useCallback22, useRef as
|
|
3680
|
+
import { useCallback as useCallback22, useRef as useRef16 } from "react";
|
|
3535
3681
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3536
|
-
const tableRef =
|
|
3682
|
+
const tableRef = useRef16(null);
|
|
3537
3683
|
const [highlightedIndexRef, setHighlightedIndex] = useStateRef(initialValue);
|
|
3538
3684
|
const handleKeyDown = useCallback22(
|
|
3539
3685
|
(e) => {
|
|
@@ -3576,8 +3722,6 @@ export {
|
|
|
3576
3722
|
TableCell,
|
|
3577
3723
|
TableGroupCell,
|
|
3578
3724
|
ToggleCell,
|
|
3579
|
-
dataAndColumnUnchanged,
|
|
3580
|
-
howFarIsRowOutsideViewport,
|
|
3581
3725
|
isShowColumnSettings,
|
|
3582
3726
|
isShowTableSettings,
|
|
3583
3727
|
noScrolling,
|