baseui 0.0.0-alpha-c54ce6f → 0.0.0-alpha-80026d1
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 +43 -44
- package/data-table/data-table.js.flow +16 -12
- package/data-table/measure-column-widths.js +1 -3
- package/data-table/measure-column-widths.js.flow +2 -5
- package/es/data-table/data-table.js +15 -12
- package/es/data-table/measure-column-widths.js +1 -3
- package/esm/data-table/data-table.js +43 -44
- package/esm/data-table/measure-column-widths.js +1 -3
- package/package.json +1 -1
package/data-table/data-table.js
CHANGED
|
@@ -568,27 +568,24 @@ function DataTable(_ref2) {
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
return rowHeight;
|
|
571
|
-
}, [rowHeight]);
|
|
572
|
-
//
|
|
571
|
+
}, [rowHeight]);
|
|
572
|
+
var gridRef = React.useRef(null); // // We use state for our ref, to allow hooks to update when the ref changes.
|
|
573
|
+
// // eslint-disable-next-line flowtype/no-weak-types
|
|
574
|
+
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
573
575
|
|
|
574
|
-
var _React$useState7 = React.useState(
|
|
576
|
+
var _React$useState7 = React.useState(columns.map(function () {
|
|
577
|
+
return 0;
|
|
578
|
+
})),
|
|
575
579
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
576
|
-
|
|
577
|
-
|
|
580
|
+
measuredWidths = _React$useState8[0],
|
|
581
|
+
setMeasuredWidths = _React$useState8[1];
|
|
578
582
|
|
|
579
583
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
580
584
|
return 0;
|
|
581
585
|
})),
|
|
582
586
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
583
|
-
|
|
584
|
-
|
|
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];
|
|
587
|
+
resizeDeltas = _React$useState10[0],
|
|
588
|
+
setResizeDeltas = _React$useState10[1];
|
|
592
589
|
|
|
593
590
|
React.useEffect(function () {
|
|
594
591
|
setMeasuredWidths(function (prev) {
|
|
@@ -603,11 +600,11 @@ function DataTable(_ref2) {
|
|
|
603
600
|
});
|
|
604
601
|
}, [columns]);
|
|
605
602
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
606
|
-
if (gridRef) {
|
|
603
|
+
if (gridRef.current) {
|
|
607
604
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
608
|
-
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
605
|
+
gridRef.current.resetAfterColumnIndex(columnIndex, true);
|
|
609
606
|
}
|
|
610
|
-
}, [gridRef]);
|
|
607
|
+
}, [gridRef.current]);
|
|
611
608
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
612
609
|
setMeasuredWidths(nextWidths);
|
|
613
610
|
resetAfterColumnIndex(0);
|
|
@@ -620,20 +617,20 @@ function DataTable(_ref2) {
|
|
|
620
617
|
resetAfterColumnIndex(columnIndex);
|
|
621
618
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
622
619
|
|
|
623
|
-
var _React$
|
|
620
|
+
var _React$useState11 = React.useState(0),
|
|
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
626
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
625
|
-
|
|
626
|
-
|
|
627
|
+
isScrollingX = _React$useState14[0],
|
|
628
|
+
setIsScrollingX = _React$useState14[1];
|
|
627
629
|
|
|
628
630
|
var _React$useState15 = React.useState(false),
|
|
629
631
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
var _React$useState17 = React.useState(false),
|
|
634
|
-
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
635
|
-
recentlyScrolledX = _React$useState18[0],
|
|
636
|
-
setRecentlyScrolledX = _React$useState18[1];
|
|
632
|
+
recentlyScrolledX = _React$useState16[0],
|
|
633
|
+
setRecentlyScrolledX = _React$useState16[1];
|
|
637
634
|
|
|
638
635
|
React.useLayoutEffect(function () {
|
|
639
636
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -755,18 +752,19 @@ function DataTable(_ref2) {
|
|
|
755
752
|
return result;
|
|
756
753
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
757
754
|
|
|
758
|
-
var _React$
|
|
759
|
-
_React$
|
|
760
|
-
browserScrollbarWidth = _React$
|
|
761
|
-
setBrowserScrollbarWidth = _React$
|
|
755
|
+
var _React$useState17 = React.useState(0),
|
|
756
|
+
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
757
|
+
browserScrollbarWidth = _React$useState18[0],
|
|
758
|
+
setBrowserScrollbarWidth = _React$useState18[1];
|
|
762
759
|
|
|
763
760
|
var normalizedWidths = React.useMemo(function () {
|
|
764
761
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
765
762
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
766
763
|
});
|
|
767
764
|
|
|
768
|
-
if (gridRef) {
|
|
769
|
-
|
|
765
|
+
if (gridRef.current) {
|
|
766
|
+
// $FlowFixMe
|
|
767
|
+
var gridProps = gridRef.current.props;
|
|
770
768
|
var isContentTallerThanContainer = false;
|
|
771
769
|
var visibleRowHeight = 0;
|
|
772
770
|
|
|
@@ -803,7 +801,8 @@ function DataTable(_ref2) {
|
|
|
803
801
|
}
|
|
804
802
|
|
|
805
803
|
return resizedWidths;
|
|
806
|
-
}, [gridRef,
|
|
804
|
+
}, [// gridRef,
|
|
805
|
+
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
807
806
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
808
807
|
var isSelectedAll = React.useMemo(function () {
|
|
809
808
|
if (!selectedRowIds) {
|
|
@@ -847,23 +846,23 @@ function DataTable(_ref2) {
|
|
|
847
846
|
}
|
|
848
847
|
}, [onSort]);
|
|
849
848
|
|
|
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
|
+
|
|
850
854
|
var _React$useState21 = React.useState(-1),
|
|
851
855
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
var _React$useState23 = React.useState(-1),
|
|
856
|
-
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
857
|
-
rowHighlightIndex = _React$useState24[0],
|
|
858
|
-
setRowHighlightIndex = _React$useState24[1];
|
|
856
|
+
rowHighlightIndex = _React$useState22[0],
|
|
857
|
+
setRowHighlightIndex = _React$useState22[1];
|
|
859
858
|
|
|
860
859
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
861
860
|
setRowHighlightIndex(nextIndex);
|
|
862
861
|
|
|
863
|
-
if (gridRef) {
|
|
862
|
+
if (gridRef.current) {
|
|
864
863
|
if (nextIndex >= 0) {
|
|
865
864
|
// $FlowFixMe - unable to get react-window types
|
|
866
|
-
gridRef.scrollToItem({
|
|
865
|
+
gridRef.current.scrollToItem({
|
|
867
866
|
rowIndex: nextIndex
|
|
868
867
|
});
|
|
869
868
|
}
|
|
@@ -954,7 +953,7 @@ function DataTable(_ref2) {
|
|
|
954
953
|
}
|
|
955
954
|
}, /*#__PURE__*/React.createElement(_reactWindow.VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
956
955
|
, {
|
|
957
|
-
ref:
|
|
956
|
+
ref: gridRef,
|
|
958
957
|
overscanRowCount: 10,
|
|
959
958
|
overscanColumnCount: 5,
|
|
960
959
|
innerElementType: InnerTableElement,
|
|
@@ -699,9 +699,12 @@ export function DataTable({
|
|
|
699
699
|
[rowHeight],
|
|
700
700
|
);
|
|
701
701
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
702
|
+
const gridRef = React.useRef<typeof VariableSizeGrid | null>(null);
|
|
703
|
+
|
|
704
|
+
// // We use state for our ref, to allow hooks to update when the ref changes.
|
|
705
|
+
// // eslint-disable-next-line flowtype/no-weak-types
|
|
706
|
+
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
707
|
+
|
|
705
708
|
const [measuredWidths, setMeasuredWidths] = React.useState(
|
|
706
709
|
columns.map(() => 0),
|
|
707
710
|
);
|
|
@@ -717,12 +720,12 @@ export function DataTable({
|
|
|
717
720
|
|
|
718
721
|
const resetAfterColumnIndex = React.useCallback(
|
|
719
722
|
columnIndex => {
|
|
720
|
-
if (gridRef) {
|
|
723
|
+
if (gridRef.current) {
|
|
721
724
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
722
|
-
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
725
|
+
gridRef.current.resetAfterColumnIndex(columnIndex, true);
|
|
723
726
|
}
|
|
724
727
|
},
|
|
725
|
-
[gridRef],
|
|
728
|
+
[gridRef.current],
|
|
726
729
|
);
|
|
727
730
|
const handleWidthsChange = React.useCallback(
|
|
728
731
|
nextWidths => {
|
|
@@ -851,8 +854,9 @@ export function DataTable({
|
|
|
851
854
|
const resizedWidths = measuredWidths.map(
|
|
852
855
|
(w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]),
|
|
853
856
|
);
|
|
854
|
-
if (gridRef) {
|
|
855
|
-
|
|
857
|
+
if (gridRef.current) {
|
|
858
|
+
// $FlowFixMe
|
|
859
|
+
const gridProps = gridRef.current.props;
|
|
856
860
|
|
|
857
861
|
let isContentTallerThanContainer = false;
|
|
858
862
|
let visibleRowHeight = 0;
|
|
@@ -889,7 +893,7 @@ export function DataTable({
|
|
|
889
893
|
}
|
|
890
894
|
return resizedWidths;
|
|
891
895
|
}, [
|
|
892
|
-
gridRef,
|
|
896
|
+
// gridRef,
|
|
893
897
|
measuredWidths,
|
|
894
898
|
resizeDeltas,
|
|
895
899
|
browserScrollbarWidth,
|
|
@@ -952,10 +956,10 @@ export function DataTable({
|
|
|
952
956
|
|
|
953
957
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
954
958
|
setRowHighlightIndex(nextIndex);
|
|
955
|
-
if (gridRef) {
|
|
959
|
+
if (gridRef.current) {
|
|
956
960
|
if (nextIndex >= 0) {
|
|
957
961
|
// $FlowFixMe - unable to get react-window types
|
|
958
|
-
gridRef.scrollToItem({rowIndex: nextIndex});
|
|
962
|
+
gridRef.current.scrollToItem({rowIndex: nextIndex});
|
|
959
963
|
}
|
|
960
964
|
if (onRowHighlightChange) {
|
|
961
965
|
onRowHighlightChange(nextIndex, rows[nextIndex - 1]);
|
|
@@ -1055,7 +1059,7 @@ export function DataTable({
|
|
|
1055
1059
|
>
|
|
1056
1060
|
<VariableSizeGrid
|
|
1057
1061
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
1058
|
-
ref={(
|
|
1062
|
+
ref={(gridRef: any)}
|
|
1059
1063
|
overscanRowCount={10}
|
|
1060
1064
|
overscanColumnCount={5}
|
|
1061
1065
|
innerElementType={InnerTableElement}
|
|
@@ -44,8 +44,7 @@ function MeasureColumn(_ref) {
|
|
|
44
44
|
_useStyletron2 = _slicedToArray(_useStyletron, 1),
|
|
45
45
|
css = _useStyletron2[0];
|
|
46
46
|
|
|
47
|
-
var ref =
|
|
48
|
-
console.log('measure column', columnIndex);
|
|
47
|
+
var ref = React.useRef();
|
|
49
48
|
React.useEffect(function () {
|
|
50
49
|
if (typeof document !== 'undefined') {
|
|
51
50
|
if (ref.current) {
|
|
@@ -140,7 +139,6 @@ function MeasureColumnWidths(_ref2) {
|
|
|
140
139
|
return generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
141
140
|
}, [columns, rows, widths, sampleSize]);
|
|
142
141
|
var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
|
|
143
|
-
console.log('handle dimensions change', columnIndex, dimensions);
|
|
144
142
|
var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
145
143
|
|
|
146
144
|
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
@@ -25,10 +25,7 @@ function MeasureColumn({
|
|
|
25
25
|
}) {
|
|
26
26
|
const [css] = useStyletron();
|
|
27
27
|
|
|
28
|
-
const ref = useRef();
|
|
29
|
-
|
|
30
|
-
console.log('measure column', columnIndex);
|
|
31
|
-
|
|
28
|
+
const ref = React.useRef();
|
|
32
29
|
React.useEffect(() => {
|
|
33
30
|
if (__BROWSER__) {
|
|
34
31
|
if (ref.current) {
|
|
@@ -136,7 +133,6 @@ export default function MeasureColumnWidths({
|
|
|
136
133
|
|
|
137
134
|
const handleDimensionsChange = React.useCallback(
|
|
138
135
|
(columnIndex, dimensions) => {
|
|
139
|
-
console.log('handle dimensions change', columnIndex, dimensions);
|
|
140
136
|
const nextWidth = Math.min(
|
|
141
137
|
Math.max(
|
|
142
138
|
columns[columnIndex].minWidth || 0,
|
|
@@ -149,6 +145,7 @@ export default function MeasureColumnWidths({
|
|
|
149
145
|
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
150
146
|
widthMap.set(columnIndex, nextWidth);
|
|
151
147
|
}
|
|
148
|
+
|
|
152
149
|
if (
|
|
153
150
|
// Refresh at 100% of done
|
|
154
151
|
widthMap.size === columns.length ||
|
|
@@ -469,10 +469,11 @@ export function DataTable({
|
|
|
469
469
|
}
|
|
470
470
|
|
|
471
471
|
return rowHeight;
|
|
472
|
-
}, [rowHeight]);
|
|
473
|
-
//
|
|
472
|
+
}, [rowHeight]);
|
|
473
|
+
const gridRef = React.useRef(null); // // We use state for our ref, to allow hooks to update when the ref changes.
|
|
474
|
+
// // eslint-disable-next-line flowtype/no-weak-types
|
|
475
|
+
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
474
476
|
|
|
475
|
-
const [gridRef, setGridRef] = React.useState(null);
|
|
476
477
|
const [measuredWidths, setMeasuredWidths] = React.useState(columns.map(() => 0));
|
|
477
478
|
const [resizeDeltas, setResizeDeltas] = React.useState(columns.map(() => 0));
|
|
478
479
|
React.useEffect(() => {
|
|
@@ -484,11 +485,11 @@ export function DataTable({
|
|
|
484
485
|
});
|
|
485
486
|
}, [columns]);
|
|
486
487
|
const resetAfterColumnIndex = React.useCallback(columnIndex => {
|
|
487
|
-
if (gridRef) {
|
|
488
|
+
if (gridRef.current) {
|
|
488
489
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
489
|
-
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
490
|
+
gridRef.current.resetAfterColumnIndex(columnIndex, true);
|
|
490
491
|
}
|
|
491
|
-
}, [gridRef]);
|
|
492
|
+
}, [gridRef.current]);
|
|
492
493
|
const handleWidthsChange = React.useCallback(nextWidths => {
|
|
493
494
|
setMeasuredWidths(nextWidths);
|
|
494
495
|
resetAfterColumnIndex(0);
|
|
@@ -600,8 +601,9 @@ export function DataTable({
|
|
|
600
601
|
const normalizedWidths = React.useMemo(() => {
|
|
601
602
|
const resizedWidths = measuredWidths.map((w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]));
|
|
602
603
|
|
|
603
|
-
if (gridRef) {
|
|
604
|
-
|
|
604
|
+
if (gridRef.current) {
|
|
605
|
+
// $FlowFixMe
|
|
606
|
+
const gridProps = gridRef.current.props;
|
|
605
607
|
let isContentTallerThanContainer = false;
|
|
606
608
|
let visibleRowHeight = 0;
|
|
607
609
|
|
|
@@ -636,7 +638,8 @@ export function DataTable({
|
|
|
636
638
|
}
|
|
637
639
|
|
|
638
640
|
return resizedWidths;
|
|
639
|
-
}, [gridRef,
|
|
641
|
+
}, [// gridRef,
|
|
642
|
+
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
640
643
|
const isSelectable = batchActions ? !!batchActions.length : false;
|
|
641
644
|
const isSelectedAll = React.useMemo(() => {
|
|
642
645
|
if (!selectedRowIds) {
|
|
@@ -685,10 +688,10 @@ export function DataTable({
|
|
|
685
688
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
686
689
|
setRowHighlightIndex(nextIndex);
|
|
687
690
|
|
|
688
|
-
if (gridRef) {
|
|
691
|
+
if (gridRef.current) {
|
|
689
692
|
if (nextIndex >= 0) {
|
|
690
693
|
// $FlowFixMe - unable to get react-window types
|
|
691
|
-
gridRef.scrollToItem({
|
|
694
|
+
gridRef.current.scrollToItem({
|
|
692
695
|
rowIndex: nextIndex
|
|
693
696
|
});
|
|
694
697
|
}
|
|
@@ -777,7 +780,7 @@ export function DataTable({
|
|
|
777
780
|
}
|
|
778
781
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
779
782
|
, {
|
|
780
|
-
ref:
|
|
783
|
+
ref: gridRef,
|
|
781
784
|
overscanRowCount: 10,
|
|
782
785
|
overscanColumnCount: 5,
|
|
783
786
|
innerElementType: InnerTableElement,
|
|
@@ -18,8 +18,7 @@ function MeasureColumn({
|
|
|
18
18
|
onLayout
|
|
19
19
|
}) {
|
|
20
20
|
const [css] = useStyletron();
|
|
21
|
-
const ref = useRef();
|
|
22
|
-
console.log('measure column', columnIndex);
|
|
21
|
+
const ref = React.useRef();
|
|
23
22
|
React.useEffect(() => {
|
|
24
23
|
if (typeof document !== 'undefined') {
|
|
25
24
|
if (ref.current) {
|
|
@@ -108,7 +107,6 @@ export default function MeasureColumnWidths({
|
|
|
108
107
|
return generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
109
108
|
}, [columns, rows, widths, sampleSize]);
|
|
110
109
|
const handleDimensionsChange = React.useCallback((columnIndex, dimensions) => {
|
|
111
|
-
console.log('handle dimensions change', columnIndex, dimensions);
|
|
112
110
|
const nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
113
111
|
|
|
114
112
|
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
@@ -549,27 +549,24 @@ export function DataTable(_ref2) {
|
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
return rowHeight;
|
|
552
|
-
}, [rowHeight]);
|
|
553
|
-
//
|
|
552
|
+
}, [rowHeight]);
|
|
553
|
+
var gridRef = React.useRef(null); // // We use state for our ref, to allow hooks to update when the ref changes.
|
|
554
|
+
// // eslint-disable-next-line flowtype/no-weak-types
|
|
555
|
+
// const [gridRef, setGridRef] = React.useState<?VariableSizeGrid<any>>(null);
|
|
554
556
|
|
|
555
|
-
var _React$useState7 = React.useState(
|
|
557
|
+
var _React$useState7 = React.useState(columns.map(function () {
|
|
558
|
+
return 0;
|
|
559
|
+
})),
|
|
556
560
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
557
|
-
|
|
558
|
-
|
|
561
|
+
measuredWidths = _React$useState8[0],
|
|
562
|
+
setMeasuredWidths = _React$useState8[1];
|
|
559
563
|
|
|
560
564
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
561
565
|
return 0;
|
|
562
566
|
})),
|
|
563
567
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
564
|
-
|
|
565
|
-
|
|
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];
|
|
568
|
+
resizeDeltas = _React$useState10[0],
|
|
569
|
+
setResizeDeltas = _React$useState10[1];
|
|
573
570
|
|
|
574
571
|
React.useEffect(function () {
|
|
575
572
|
setMeasuredWidths(function (prev) {
|
|
@@ -584,11 +581,11 @@ export function DataTable(_ref2) {
|
|
|
584
581
|
});
|
|
585
582
|
}, [columns]);
|
|
586
583
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
587
|
-
if (gridRef) {
|
|
584
|
+
if (gridRef.current) {
|
|
588
585
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
589
|
-
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
586
|
+
gridRef.current.resetAfterColumnIndex(columnIndex, true);
|
|
590
587
|
}
|
|
591
|
-
}, [gridRef]);
|
|
588
|
+
}, [gridRef.current]);
|
|
592
589
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
593
590
|
setMeasuredWidths(nextWidths);
|
|
594
591
|
resetAfterColumnIndex(0);
|
|
@@ -601,20 +598,20 @@ export function DataTable(_ref2) {
|
|
|
601
598
|
resetAfterColumnIndex(columnIndex);
|
|
602
599
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
603
600
|
|
|
604
|
-
var _React$
|
|
601
|
+
var _React$useState11 = React.useState(0),
|
|
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
607
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
+
isScrollingX = _React$useState14[0],
|
|
609
|
+
setIsScrollingX = _React$useState14[1];
|
|
608
610
|
|
|
609
611
|
var _React$useState15 = React.useState(false),
|
|
610
612
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
var _React$useState17 = React.useState(false),
|
|
615
|
-
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
616
|
-
recentlyScrolledX = _React$useState18[0],
|
|
617
|
-
setRecentlyScrolledX = _React$useState18[1];
|
|
613
|
+
recentlyScrolledX = _React$useState16[0],
|
|
614
|
+
setRecentlyScrolledX = _React$useState16[1];
|
|
618
615
|
|
|
619
616
|
React.useLayoutEffect(function () {
|
|
620
617
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -736,18 +733,19 @@ export function DataTable(_ref2) {
|
|
|
736
733
|
return result;
|
|
737
734
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
738
735
|
|
|
739
|
-
var _React$
|
|
740
|
-
_React$
|
|
741
|
-
browserScrollbarWidth = _React$
|
|
742
|
-
setBrowserScrollbarWidth = _React$
|
|
736
|
+
var _React$useState17 = React.useState(0),
|
|
737
|
+
_React$useState18 = _slicedToArray(_React$useState17, 2),
|
|
738
|
+
browserScrollbarWidth = _React$useState18[0],
|
|
739
|
+
setBrowserScrollbarWidth = _React$useState18[1];
|
|
743
740
|
|
|
744
741
|
var normalizedWidths = React.useMemo(function () {
|
|
745
742
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
746
743
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
747
744
|
});
|
|
748
745
|
|
|
749
|
-
if (gridRef) {
|
|
750
|
-
|
|
746
|
+
if (gridRef.current) {
|
|
747
|
+
// $FlowFixMe
|
|
748
|
+
var gridProps = gridRef.current.props;
|
|
751
749
|
var isContentTallerThanContainer = false;
|
|
752
750
|
var visibleRowHeight = 0;
|
|
753
751
|
|
|
@@ -784,7 +782,8 @@ export function DataTable(_ref2) {
|
|
|
784
782
|
}
|
|
785
783
|
|
|
786
784
|
return resizedWidths;
|
|
787
|
-
}, [gridRef,
|
|
785
|
+
}, [// gridRef,
|
|
786
|
+
measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
788
787
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
789
788
|
var isSelectedAll = React.useMemo(function () {
|
|
790
789
|
if (!selectedRowIds) {
|
|
@@ -828,23 +827,23 @@ export function DataTable(_ref2) {
|
|
|
828
827
|
}
|
|
829
828
|
}, [onSort]);
|
|
830
829
|
|
|
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
|
+
|
|
831
835
|
var _React$useState21 = React.useState(-1),
|
|
832
836
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
var _React$useState23 = React.useState(-1),
|
|
837
|
-
_React$useState24 = _slicedToArray(_React$useState23, 2),
|
|
838
|
-
rowHighlightIndex = _React$useState24[0],
|
|
839
|
-
setRowHighlightIndex = _React$useState24[1];
|
|
837
|
+
rowHighlightIndex = _React$useState22[0],
|
|
838
|
+
setRowHighlightIndex = _React$useState22[1];
|
|
840
839
|
|
|
841
840
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
842
841
|
setRowHighlightIndex(nextIndex);
|
|
843
842
|
|
|
844
|
-
if (gridRef) {
|
|
843
|
+
if (gridRef.current) {
|
|
845
844
|
if (nextIndex >= 0) {
|
|
846
845
|
// $FlowFixMe - unable to get react-window types
|
|
847
|
-
gridRef.scrollToItem({
|
|
846
|
+
gridRef.current.scrollToItem({
|
|
848
847
|
rowIndex: nextIndex
|
|
849
848
|
});
|
|
850
849
|
}
|
|
@@ -935,7 +934,7 @@ export function DataTable(_ref2) {
|
|
|
935
934
|
}
|
|
936
935
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
937
936
|
, {
|
|
938
|
-
ref:
|
|
937
|
+
ref: gridRef,
|
|
939
938
|
overscanRowCount: 10,
|
|
940
939
|
overscanColumnCount: 5,
|
|
941
940
|
innerElementType: InnerTableElement,
|
|
@@ -33,8 +33,7 @@ function MeasureColumn(_ref) {
|
|
|
33
33
|
_useStyletron2 = _slicedToArray(_useStyletron, 1),
|
|
34
34
|
css = _useStyletron2[0];
|
|
35
35
|
|
|
36
|
-
var ref = useRef();
|
|
37
|
-
console.log('measure column', columnIndex);
|
|
36
|
+
var ref = React.useRef();
|
|
38
37
|
React.useEffect(function () {
|
|
39
38
|
if (typeof document !== 'undefined') {
|
|
40
39
|
if (ref.current) {
|
|
@@ -129,7 +128,6 @@ export default function MeasureColumnWidths(_ref2) {
|
|
|
129
128
|
return generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
130
129
|
}, [columns, rows, widths, sampleSize]);
|
|
131
130
|
var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
|
|
132
|
-
console.log('handle dimensions change', columnIndex, dimensions);
|
|
133
131
|
var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
134
132
|
|
|
135
133
|
if (nextWidth !== widthMap.get(columnIndex)) {
|