baseui 0.0.0-alpha-80026d1 → 0.0.0-alpha-0ccfc47
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/data-table/data-table.js +45 -43
- package/data-table/data-table.js.flow +13 -16
- package/data-table/measure-column-widths.js +3 -4
- package/data-table/measure-column-widths.js.flow +3 -3
- package/es/data-table/data-table.js +13 -15
- package/es/data-table/measure-column-widths.js +3 -4
- package/esm/data-table/data-table.js +45 -43
- package/esm/data-table/measure-column-widths.js +3 -4
- package/package.json +1 -1
package/data-table/data-table.js
CHANGED
|
@@ -568,24 +568,27 @@ function DataTable(_ref2) {
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
return rowHeight;
|
|
571
|
-
}, [rowHeight]);
|
|
572
|
-
|
|
573
|
-
// // eslint-disable-next-line flowtype/no-weak-types
|
|
574
|
-
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
571
|
+
}, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
|
|
572
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
575
573
|
|
|
576
|
-
var _React$useState7 = React.useState(
|
|
577
|
-
return 0;
|
|
578
|
-
})),
|
|
574
|
+
var _React$useState7 = React.useState(null),
|
|
579
575
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
580
|
-
|
|
581
|
-
|
|
576
|
+
gridRef = _React$useState8[0],
|
|
577
|
+
setGridRef = _React$useState8[1];
|
|
582
578
|
|
|
583
579
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
584
580
|
return 0;
|
|
585
581
|
})),
|
|
586
582
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
587
|
-
|
|
588
|
-
|
|
583
|
+
measuredWidths = _React$useState10[0],
|
|
584
|
+
setMeasuredWidths = _React$useState10[1];
|
|
585
|
+
|
|
586
|
+
var _React$useState11 = React.useState(columns.map(function () {
|
|
587
|
+
return 0;
|
|
588
|
+
})),
|
|
589
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
590
|
+
resizeDeltas = _React$useState12[0],
|
|
591
|
+
setResizeDeltas = _React$useState12[1];
|
|
589
592
|
|
|
590
593
|
React.useEffect(function () {
|
|
591
594
|
setMeasuredWidths(function (prev) {
|
|
@@ -600,12 +603,13 @@ function DataTable(_ref2) {
|
|
|
600
603
|
});
|
|
601
604
|
}, [columns]);
|
|
602
605
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
603
|
-
if (gridRef
|
|
606
|
+
if (gridRef) {
|
|
604
607
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
605
|
-
gridRef.
|
|
608
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
606
609
|
}
|
|
607
|
-
}, [gridRef
|
|
610
|
+
}, [gridRef]);
|
|
608
611
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
612
|
+
console.log('next widths', nextWidths);
|
|
609
613
|
setMeasuredWidths(nextWidths);
|
|
610
614
|
resetAfterColumnIndex(0);
|
|
611
615
|
}, [setMeasuredWidths, resetAfterColumnIndex]);
|
|
@@ -617,20 +621,20 @@ function DataTable(_ref2) {
|
|
|
617
621
|
resetAfterColumnIndex(columnIndex);
|
|
618
622
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
619
623
|
|
|
620
|
-
var _React$
|
|
621
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
622
|
-
scrollLeft = _React$useState12[0],
|
|
623
|
-
setScrollLeft = _React$useState12[1];
|
|
624
|
-
|
|
625
|
-
var _React$useState13 = React.useState(false),
|
|
624
|
+
var _React$useState13 = React.useState(0),
|
|
626
625
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
627
|
-
|
|
628
|
-
|
|
626
|
+
scrollLeft = _React$useState14[0],
|
|
627
|
+
setScrollLeft = _React$useState14[1];
|
|
629
628
|
|
|
630
629
|
var _React$useState15 = React.useState(false),
|
|
631
630
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
632
|
-
|
|
633
|
-
|
|
631
|
+
isScrollingX = _React$useState16[0],
|
|
632
|
+
setIsScrollingX = _React$useState16[1];
|
|
633
|
+
|
|
634
|
+
var _React$useState17 = React.useState(false),
|
|
635
|
+
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
636
|
+
recentlyScrolledX = _React$useState18[0],
|
|
637
|
+
setRecentlyScrolledX = _React$useState18[1];
|
|
634
638
|
|
|
635
639
|
React.useLayoutEffect(function () {
|
|
636
640
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -752,19 +756,18 @@ function DataTable(_ref2) {
|
|
|
752
756
|
return result;
|
|
753
757
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
754
758
|
|
|
755
|
-
var _React$
|
|
756
|
-
_React$
|
|
757
|
-
browserScrollbarWidth = _React$
|
|
758
|
-
setBrowserScrollbarWidth = _React$
|
|
759
|
+
var _React$useState19 = React.useState(0),
|
|
760
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
761
|
+
browserScrollbarWidth = _React$useState20[0],
|
|
762
|
+
setBrowserScrollbarWidth = _React$useState20[1];
|
|
759
763
|
|
|
760
764
|
var normalizedWidths = React.useMemo(function () {
|
|
761
765
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
762
766
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
763
767
|
});
|
|
764
768
|
|
|
765
|
-
if (gridRef
|
|
766
|
-
|
|
767
|
-
var gridProps = gridRef.current.props;
|
|
769
|
+
if (gridRef) {
|
|
770
|
+
var gridProps = gridRef.props;
|
|
768
771
|
var isContentTallerThanContainer = false;
|
|
769
772
|
var visibleRowHeight = 0;
|
|
770
773
|
|
|
@@ -801,8 +804,7 @@ function DataTable(_ref2) {
|
|
|
801
804
|
}
|
|
802
805
|
|
|
803
806
|
return resizedWidths;
|
|
804
|
-
}, [
|
|
805
|
-
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
807
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
806
808
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
807
809
|
var isSelectedAll = React.useMemo(function () {
|
|
808
810
|
if (!selectedRowIds) {
|
|
@@ -846,23 +848,23 @@ function DataTable(_ref2) {
|
|
|
846
848
|
}
|
|
847
849
|
}, [onSort]);
|
|
848
850
|
|
|
849
|
-
var _React$useState19 = React.useState(-1),
|
|
850
|
-
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
851
|
-
columnHighlightIndex = _React$useState20[0],
|
|
852
|
-
setColumnHighlightIndex = _React$useState20[1];
|
|
853
|
-
|
|
854
851
|
var _React$useState21 = React.useState(-1),
|
|
855
852
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
856
|
-
|
|
857
|
-
|
|
853
|
+
columnHighlightIndex = _React$useState22[0],
|
|
854
|
+
setColumnHighlightIndex = _React$useState22[1];
|
|
855
|
+
|
|
856
|
+
var _React$useState23 = React.useState(-1),
|
|
857
|
+
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
858
|
+
rowHighlightIndex = _React$useState24[0],
|
|
859
|
+
setRowHighlightIndex = _React$useState24[1];
|
|
858
860
|
|
|
859
861
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
860
862
|
setRowHighlightIndex(nextIndex);
|
|
861
863
|
|
|
862
|
-
if (gridRef
|
|
864
|
+
if (gridRef) {
|
|
863
865
|
if (nextIndex >= 0) {
|
|
864
866
|
// $FlowFixMe - unable to get react-window types
|
|
865
|
-
gridRef.
|
|
867
|
+
gridRef.scrollToItem({
|
|
866
868
|
rowIndex: nextIndex
|
|
867
869
|
});
|
|
868
870
|
}
|
|
@@ -953,7 +955,7 @@ function DataTable(_ref2) {
|
|
|
953
955
|
}
|
|
954
956
|
}, /*#__PURE__*/React.createElement(_reactWindow.VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
955
957
|
, {
|
|
956
|
-
ref:
|
|
958
|
+
ref: setGridRef,
|
|
957
959
|
overscanRowCount: 10,
|
|
958
960
|
overscanColumnCount: 5,
|
|
959
961
|
innerElementType: InnerTableElement,
|
|
@@ -699,12 +699,9 @@ export function DataTable({
|
|
|
699
699
|
[rowHeight],
|
|
700
700
|
);
|
|
701
701
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
// // eslint-disable-next-line flowtype/no-weak-types
|
|
706
|
-
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
707
|
-
|
|
702
|
+
// We use state for our ref, to allow hooks to update when the ref changes.
|
|
703
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
704
|
+
const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
708
705
|
const [measuredWidths, setMeasuredWidths] = React.useState(
|
|
709
706
|
columns.map(() => 0),
|
|
710
707
|
);
|
|
@@ -720,15 +717,16 @@ export function DataTable({
|
|
|
720
717
|
|
|
721
718
|
const resetAfterColumnIndex = React.useCallback(
|
|
722
719
|
columnIndex => {
|
|
723
|
-
if (gridRef
|
|
720
|
+
if (gridRef) {
|
|
724
721
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
725
|
-
gridRef.
|
|
722
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
726
723
|
}
|
|
727
724
|
},
|
|
728
|
-
[gridRef
|
|
725
|
+
[gridRef],
|
|
729
726
|
);
|
|
730
727
|
const handleWidthsChange = React.useCallback(
|
|
731
728
|
nextWidths => {
|
|
729
|
+
console.log('next widths', nextWidths);
|
|
732
730
|
setMeasuredWidths(nextWidths);
|
|
733
731
|
resetAfterColumnIndex(0);
|
|
734
732
|
},
|
|
@@ -854,9 +852,8 @@ export function DataTable({
|
|
|
854
852
|
const resizedWidths = measuredWidths.map(
|
|
855
853
|
(w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]),
|
|
856
854
|
);
|
|
857
|
-
if (gridRef
|
|
858
|
-
|
|
859
|
-
const gridProps = gridRef.current.props;
|
|
855
|
+
if (gridRef) {
|
|
856
|
+
const gridProps = gridRef.props;
|
|
860
857
|
|
|
861
858
|
let isContentTallerThanContainer = false;
|
|
862
859
|
let visibleRowHeight = 0;
|
|
@@ -893,7 +890,7 @@ export function DataTable({
|
|
|
893
890
|
}
|
|
894
891
|
return resizedWidths;
|
|
895
892
|
}, [
|
|
896
|
-
|
|
893
|
+
gridRef,
|
|
897
894
|
measuredWidths,
|
|
898
895
|
resizeDeltas,
|
|
899
896
|
browserScrollbarWidth,
|
|
@@ -956,10 +953,10 @@ export function DataTable({
|
|
|
956
953
|
|
|
957
954
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
958
955
|
setRowHighlightIndex(nextIndex);
|
|
959
|
-
if (gridRef
|
|
956
|
+
if (gridRef) {
|
|
960
957
|
if (nextIndex >= 0) {
|
|
961
958
|
// $FlowFixMe - unable to get react-window types
|
|
962
|
-
gridRef.
|
|
959
|
+
gridRef.scrollToItem({rowIndex: nextIndex});
|
|
963
960
|
}
|
|
964
961
|
if (onRowHighlightChange) {
|
|
965
962
|
onRowHighlightChange(nextIndex, rows[nextIndex - 1]);
|
|
@@ -1059,7 +1056,7 @@ export function DataTable({
|
|
|
1059
1056
|
>
|
|
1060
1057
|
<VariableSizeGrid
|
|
1061
1058
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
1062
|
-
ref={(
|
|
1059
|
+
ref={(setGridRef: any)}
|
|
1063
1060
|
overscanRowCount={10}
|
|
1064
1061
|
overscanColumnCount={5}
|
|
1065
1062
|
innerElementType={InnerTableElement}
|
|
@@ -157,10 +157,9 @@ function MeasureColumnWidths(_ref2) {
|
|
|
157
157
|
overflow: 'hidden',
|
|
158
158
|
height: 0
|
|
159
159
|
}); // Remove the measurement nodes after we are done updating our column width
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
160
|
+
// if (widthMap.size === columns.length) {
|
|
161
|
+
// return null;
|
|
162
|
+
// }
|
|
164
163
|
|
|
165
164
|
return (
|
|
166
165
|
/*#__PURE__*/
|
|
@@ -167,9 +167,9 @@ export default function MeasureColumnWidths({
|
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
// Remove the measurement nodes after we are done updating our column width
|
|
170
|
-
if (widthMap.size === columns.length) {
|
|
171
|
-
|
|
172
|
-
}
|
|
170
|
+
// if (widthMap.size === columns.length) {
|
|
171
|
+
// return null;
|
|
172
|
+
// }
|
|
173
173
|
|
|
174
174
|
return (
|
|
175
175
|
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
@@ -469,11 +469,10 @@ export function DataTable({
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
return rowHeight;
|
|
472
|
-
}, [rowHeight]);
|
|
473
|
-
|
|
474
|
-
// // eslint-disable-next-line flowtype/no-weak-types
|
|
475
|
-
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
472
|
+
}, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
|
|
473
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
476
474
|
|
|
475
|
+
const [gridRef, setGridRef] = React.useState(null);
|
|
477
476
|
const [measuredWidths, setMeasuredWidths] = React.useState(columns.map(() => 0));
|
|
478
477
|
const [resizeDeltas, setResizeDeltas] = React.useState(columns.map(() => 0));
|
|
479
478
|
React.useEffect(() => {
|
|
@@ -485,12 +484,13 @@ export function DataTable({
|
|
|
485
484
|
});
|
|
486
485
|
}, [columns]);
|
|
487
486
|
const resetAfterColumnIndex = React.useCallback(columnIndex => {
|
|
488
|
-
if (gridRef
|
|
487
|
+
if (gridRef) {
|
|
489
488
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
490
|
-
gridRef.
|
|
489
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
491
490
|
}
|
|
492
|
-
}, [gridRef
|
|
491
|
+
}, [gridRef]);
|
|
493
492
|
const handleWidthsChange = React.useCallback(nextWidths => {
|
|
493
|
+
console.log('next widths', nextWidths);
|
|
494
494
|
setMeasuredWidths(nextWidths);
|
|
495
495
|
resetAfterColumnIndex(0);
|
|
496
496
|
}, [setMeasuredWidths, resetAfterColumnIndex]);
|
|
@@ -601,9 +601,8 @@ export function DataTable({
|
|
|
601
601
|
const normalizedWidths = React.useMemo(() => {
|
|
602
602
|
const resizedWidths = measuredWidths.map((w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]));
|
|
603
603
|
|
|
604
|
-
if (gridRef
|
|
605
|
-
|
|
606
|
-
const gridProps = gridRef.current.props;
|
|
604
|
+
if (gridRef) {
|
|
605
|
+
const gridProps = gridRef.props;
|
|
607
606
|
let isContentTallerThanContainer = false;
|
|
608
607
|
let visibleRowHeight = 0;
|
|
609
608
|
|
|
@@ -638,8 +637,7 @@ export function DataTable({
|
|
|
638
637
|
}
|
|
639
638
|
|
|
640
639
|
return resizedWidths;
|
|
641
|
-
}, [
|
|
642
|
-
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
640
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
643
641
|
const isSelectable = batchActions ? !!batchActions.length : false;
|
|
644
642
|
const isSelectedAll = React.useMemo(() => {
|
|
645
643
|
if (!selectedRowIds) {
|
|
@@ -688,10 +686,10 @@ export function DataTable({
|
|
|
688
686
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
689
687
|
setRowHighlightIndex(nextIndex);
|
|
690
688
|
|
|
691
|
-
if (gridRef
|
|
689
|
+
if (gridRef) {
|
|
692
690
|
if (nextIndex >= 0) {
|
|
693
691
|
// $FlowFixMe - unable to get react-window types
|
|
694
|
-
gridRef.
|
|
692
|
+
gridRef.scrollToItem({
|
|
695
693
|
rowIndex: nextIndex
|
|
696
694
|
});
|
|
697
695
|
}
|
|
@@ -780,7 +778,7 @@ export function DataTable({
|
|
|
780
778
|
}
|
|
781
779
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
782
780
|
, {
|
|
783
|
-
ref:
|
|
781
|
+
ref: setGridRef,
|
|
784
782
|
overscanRowCount: 10,
|
|
785
783
|
overscanColumnCount: 5,
|
|
786
784
|
innerElementType: InnerTableElement,
|
|
@@ -125,10 +125,9 @@ export default function MeasureColumnWidths({
|
|
|
125
125
|
overflow: 'hidden',
|
|
126
126
|
height: 0
|
|
127
127
|
}); // Remove the measurement nodes after we are done updating our column width
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
128
|
+
// if (widthMap.size === columns.length) {
|
|
129
|
+
// return null;
|
|
130
|
+
// }
|
|
132
131
|
|
|
133
132
|
return (
|
|
134
133
|
/*#__PURE__*/
|
|
@@ -549,24 +549,27 @@ export function DataTable(_ref2) {
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
return rowHeight;
|
|
552
|
-
}, [rowHeight]);
|
|
553
|
-
|
|
554
|
-
// // eslint-disable-next-line flowtype/no-weak-types
|
|
555
|
-
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
552
|
+
}, [rowHeight]); // We use state for our ref, to allow hooks to update when the ref changes.
|
|
553
|
+
// eslint-disable-next-line flowtype/no-weak-types
|
|
556
554
|
|
|
557
|
-
var _React$useState7 = React.useState(
|
|
558
|
-
return 0;
|
|
559
|
-
})),
|
|
555
|
+
var _React$useState7 = React.useState(null),
|
|
560
556
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
561
|
-
|
|
562
|
-
|
|
557
|
+
gridRef = _React$useState8[0],
|
|
558
|
+
setGridRef = _React$useState8[1];
|
|
563
559
|
|
|
564
560
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
565
561
|
return 0;
|
|
566
562
|
})),
|
|
567
563
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
568
|
-
|
|
569
|
-
|
|
564
|
+
measuredWidths = _React$useState10[0],
|
|
565
|
+
setMeasuredWidths = _React$useState10[1];
|
|
566
|
+
|
|
567
|
+
var _React$useState11 = React.useState(columns.map(function () {
|
|
568
|
+
return 0;
|
|
569
|
+
})),
|
|
570
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
571
|
+
resizeDeltas = _React$useState12[0],
|
|
572
|
+
setResizeDeltas = _React$useState12[1];
|
|
570
573
|
|
|
571
574
|
React.useEffect(function () {
|
|
572
575
|
setMeasuredWidths(function (prev) {
|
|
@@ -581,12 +584,13 @@ export function DataTable(_ref2) {
|
|
|
581
584
|
});
|
|
582
585
|
}, [columns]);
|
|
583
586
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
584
|
-
if (gridRef
|
|
587
|
+
if (gridRef) {
|
|
585
588
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
586
|
-
gridRef.
|
|
589
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
587
590
|
}
|
|
588
|
-
}, [gridRef
|
|
591
|
+
}, [gridRef]);
|
|
589
592
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
593
|
+
console.log('next widths', nextWidths);
|
|
590
594
|
setMeasuredWidths(nextWidths);
|
|
591
595
|
resetAfterColumnIndex(0);
|
|
592
596
|
}, [setMeasuredWidths, resetAfterColumnIndex]);
|
|
@@ -598,20 +602,20 @@ export function DataTable(_ref2) {
|
|
|
598
602
|
resetAfterColumnIndex(columnIndex);
|
|
599
603
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
600
604
|
|
|
601
|
-
var _React$
|
|
602
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
603
|
-
scrollLeft = _React$useState12[0],
|
|
604
|
-
setScrollLeft = _React$useState12[1];
|
|
605
|
-
|
|
606
|
-
var _React$useState13 = React.useState(false),
|
|
605
|
+
var _React$useState13 = React.useState(0),
|
|
607
606
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
scrollLeft = _React$useState14[0],
|
|
608
|
+
setScrollLeft = _React$useState14[1];
|
|
610
609
|
|
|
611
610
|
var _React$useState15 = React.useState(false),
|
|
612
611
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
613
|
-
|
|
614
|
-
|
|
612
|
+
isScrollingX = _React$useState16[0],
|
|
613
|
+
setIsScrollingX = _React$useState16[1];
|
|
614
|
+
|
|
615
|
+
var _React$useState17 = React.useState(false),
|
|
616
|
+
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
617
|
+
recentlyScrolledX = _React$useState18[0],
|
|
618
|
+
setRecentlyScrolledX = _React$useState18[1];
|
|
615
619
|
|
|
616
620
|
React.useLayoutEffect(function () {
|
|
617
621
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -733,19 +737,18 @@ export function DataTable(_ref2) {
|
|
|
733
737
|
return result;
|
|
734
738
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
735
739
|
|
|
736
|
-
var _React$
|
|
737
|
-
_React$
|
|
738
|
-
browserScrollbarWidth = _React$
|
|
739
|
-
setBrowserScrollbarWidth = _React$
|
|
740
|
+
var _React$useState19 = React.useState(0),
|
|
741
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
742
|
+
browserScrollbarWidth = _React$useState20[0],
|
|
743
|
+
setBrowserScrollbarWidth = _React$useState20[1];
|
|
740
744
|
|
|
741
745
|
var normalizedWidths = React.useMemo(function () {
|
|
742
746
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
743
747
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
744
748
|
});
|
|
745
749
|
|
|
746
|
-
if (gridRef
|
|
747
|
-
|
|
748
|
-
var gridProps = gridRef.current.props;
|
|
750
|
+
if (gridRef) {
|
|
751
|
+
var gridProps = gridRef.props;
|
|
749
752
|
var isContentTallerThanContainer = false;
|
|
750
753
|
var visibleRowHeight = 0;
|
|
751
754
|
|
|
@@ -782,8 +785,7 @@ export function DataTable(_ref2) {
|
|
|
782
785
|
}
|
|
783
786
|
|
|
784
787
|
return resizedWidths;
|
|
785
|
-
}, [
|
|
786
|
-
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
788
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
787
789
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
788
790
|
var isSelectedAll = React.useMemo(function () {
|
|
789
791
|
if (!selectedRowIds) {
|
|
@@ -827,23 +829,23 @@ export function DataTable(_ref2) {
|
|
|
827
829
|
}
|
|
828
830
|
}, [onSort]);
|
|
829
831
|
|
|
830
|
-
var _React$useState19 = React.useState(-1),
|
|
831
|
-
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
832
|
-
columnHighlightIndex = _React$useState20[0],
|
|
833
|
-
setColumnHighlightIndex = _React$useState20[1];
|
|
834
|
-
|
|
835
832
|
var _React$useState21 = React.useState(-1),
|
|
836
833
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
837
|
-
|
|
838
|
-
|
|
834
|
+
columnHighlightIndex = _React$useState22[0],
|
|
835
|
+
setColumnHighlightIndex = _React$useState22[1];
|
|
836
|
+
|
|
837
|
+
var _React$useState23 = React.useState(-1),
|
|
838
|
+
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
839
|
+
rowHighlightIndex = _React$useState24[0],
|
|
840
|
+
setRowHighlightIndex = _React$useState24[1];
|
|
839
841
|
|
|
840
842
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
841
843
|
setRowHighlightIndex(nextIndex);
|
|
842
844
|
|
|
843
|
-
if (gridRef
|
|
845
|
+
if (gridRef) {
|
|
844
846
|
if (nextIndex >= 0) {
|
|
845
847
|
// $FlowFixMe - unable to get react-window types
|
|
846
|
-
gridRef.
|
|
848
|
+
gridRef.scrollToItem({
|
|
847
849
|
rowIndex: nextIndex
|
|
848
850
|
});
|
|
849
851
|
}
|
|
@@ -934,7 +936,7 @@ export function DataTable(_ref2) {
|
|
|
934
936
|
}
|
|
935
937
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
936
938
|
, {
|
|
937
|
-
ref:
|
|
939
|
+
ref: setGridRef,
|
|
938
940
|
overscanRowCount: 10,
|
|
939
941
|
overscanColumnCount: 5,
|
|
940
942
|
innerElementType: InnerTableElement,
|
|
@@ -146,10 +146,9 @@ export default function MeasureColumnWidths(_ref2) {
|
|
|
146
146
|
overflow: 'hidden',
|
|
147
147
|
height: 0
|
|
148
148
|
}); // Remove the measurement nodes after we are done updating our column width
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
149
|
+
// if (widthMap.size === columns.length) {
|
|
150
|
+
// return null;
|
|
151
|
+
// }
|
|
153
152
|
|
|
154
153
|
return (
|
|
155
154
|
/*#__PURE__*/
|