baseui 10.9.0 → 10.9.1

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.
Files changed (39) hide show
  1. package/data-table/column-numerical.js +355 -307
  2. package/data-table/column-numerical.js.flow +287 -273
  3. package/data-table/constants.js +11 -17
  4. package/data-table/constants.js.flow +8 -11
  5. package/data-table/data-table.js +50 -53
  6. package/data-table/data-table.js.flow +13 -18
  7. package/data-table/filter-shell.js +4 -27
  8. package/data-table/filter-shell.js.flow +9 -33
  9. package/data-table/locale.js +2 -4
  10. package/data-table/locale.js.flow +2 -6
  11. package/data-table/measure-column-widths.js +121 -83
  12. package/data-table/measure-column-widths.js.flow +109 -87
  13. package/es/data-table/column-numerical.js +317 -245
  14. package/es/data-table/constants.js +8 -12
  15. package/es/data-table/data-table.js +16 -18
  16. package/es/data-table/filter-shell.js +4 -26
  17. package/es/data-table/locale.js +2 -4
  18. package/es/data-table/measure-column-widths.js +86 -75
  19. package/es/form-control/form-control.js +58 -7
  20. package/es/form-control/styled-components.js +27 -6
  21. package/es/popover/popover.js +1 -1
  22. package/esm/data-table/column-numerical.js +353 -304
  23. package/esm/data-table/constants.js +8 -12
  24. package/esm/data-table/data-table.js +50 -53
  25. package/esm/data-table/filter-shell.js +4 -26
  26. package/esm/data-table/locale.js +2 -4
  27. package/esm/data-table/measure-column-widths.js +121 -83
  28. package/esm/form-control/form-control.js +60 -9
  29. package/esm/form-control/styled-components.js +23 -3
  30. package/esm/popover/popover.js +1 -1
  31. package/form-control/form-control.js +61 -8
  32. package/form-control/form-control.js.flow +82 -10
  33. package/form-control/index.d.ts +1 -0
  34. package/form-control/styled-components.js +27 -5
  35. package/form-control/styled-components.js.flow +25 -3
  36. package/form-control/types.js.flow +20 -8
  37. package/package.json +1 -2
  38. package/popover/popover.js +1 -1
  39. package/popover/popover.js.flow +1 -1
@@ -19,6 +19,13 @@ export var NUMERICAL_FORMATS = Object.freeze({
19
19
  ACCOUNTING: 'ACCOUNTING',
20
20
  PERCENTAGE: 'PERCENTAGE'
21
21
  });
22
+ export var NUMERICAL_OPERATIONS = Object.freeze({
23
+ EQ: 'EQ',
24
+ GT: 'GT',
25
+ GTE: 'GTE',
26
+ LT: 'LT',
27
+ LTE: 'LTE'
28
+ });
22
29
  export var DATETIME_OPERATIONS = Object.freeze({
23
30
  RANGE_DATETIME: 'RANGE_DATETIME',
24
31
  RANGE_DATE: 'RANGE_DATE',
@@ -32,15 +39,4 @@ export var DATETIME_OPERATIONS = Object.freeze({
32
39
  export var SORT_DIRECTIONS = Object.freeze({
33
40
  ASC: 'ASC',
34
41
  DESC: 'DESC'
35
- }); // If modifying this, take a look at the histogram and adjust. see HISTOGRAM_SIZE
36
-
37
- export var FILTER_SHELL_WIDTH = '320px'; // Depends on FILTER_SHELL_WIDTH
38
-
39
- export var HISTOGRAM_SIZE = {
40
- width: 308,
41
- height: 120
42
- }; // Arguably visually appealing within the given width.
43
- // Smaller and we don't have enough detail per bar.
44
- // Larger and the bars are too granular and don't align well with the slider steps
45
-
46
- export var MAX_BIN_COUNT = 50;
42
+ });
@@ -43,12 +43,6 @@ import { LocaleContext } from '../locale/index.js'; // consider pulling this out
43
43
 
44
44
  var HEADER_ROW_HEIGHT = 48;
45
45
 
46
- var sum = function sum(ns) {
47
- return ns.reduce(function (s, n) {
48
- return s + n;
49
- }, 0);
50
- };
51
-
52
46
  function CellPlacement(_ref) {
53
47
  var columnIndex = _ref.columnIndex,
54
48
  rowIndex = _ref.rowIndex,
@@ -307,7 +301,7 @@ function Header(props) {
307
301
  }))));
308
302
  }
309
303
 
310
- function Headers() {
304
+ function Headers(props) {
311
305
  var _useStyletron5 = useStyletron(),
312
306
  _useStyletron6 = _slicedToArray(_useStyletron5, 2),
313
307
  css = _useStyletron6[0],
@@ -326,7 +320,9 @@ function Headers() {
326
320
  position: 'sticky',
327
321
  top: 0,
328
322
  left: 0,
329
- width: "".concat(sum(ctx.widths), "px"),
323
+ width: "".concat(ctx.widths.reduce(function (sum, w) {
324
+ return sum + w;
325
+ }, 0), "px"),
330
326
  height: "".concat(HEADER_ROW_HEIGHT, "px"),
331
327
  display: 'flex',
332
328
  // this feels bad.. the absolutely positioned children elements
@@ -549,27 +545,22 @@ export function DataTable(_ref2) {
549
545
  }
550
546
 
551
547
  return rowHeight;
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
548
+ }, [rowHeight]);
549
+ var gridRef = React.useRef(null);
554
550
 
555
- var _React$useState7 = React.useState(null),
551
+ var _React$useState7 = React.useState(columns.map(function () {
552
+ return 0;
553
+ })),
556
554
  _React$useState8 = _slicedToArray(_React$useState7, 2),
557
- gridRef = _React$useState8[0],
558
- setGridRef = _React$useState8[1];
555
+ measuredWidths = _React$useState8[0],
556
+ setMeasuredWidths = _React$useState8[1];
559
557
 
560
558
  var _React$useState9 = React.useState(columns.map(function () {
561
559
  return 0;
562
560
  })),
563
561
  _React$useState10 = _slicedToArray(_React$useState9, 2),
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];
562
+ resizeDeltas = _React$useState10[0],
563
+ setResizeDeltas = _React$useState10[1];
573
564
 
574
565
  React.useEffect(function () {
575
566
  setMeasuredWidths(function (prev) {
@@ -584,11 +575,11 @@ export function DataTable(_ref2) {
584
575
  });
585
576
  }, [columns]);
586
577
  var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
587
- if (gridRef) {
578
+ if (gridRef.current) {
588
579
  // $FlowFixMe trigger react-window to layout the elements again
589
- gridRef.resetAfterColumnIndex(columnIndex, true);
580
+ gridRef.current.resetAfterColumnIndex(columnIndex, true);
590
581
  }
591
- }, [gridRef]);
582
+ }, [gridRef.current]);
592
583
  var handleWidthsChange = React.useCallback(function (nextWidths) {
593
584
  setMeasuredWidths(nextWidths);
594
585
  resetAfterColumnIndex(0);
@@ -601,20 +592,20 @@ export function DataTable(_ref2) {
601
592
  resetAfterColumnIndex(columnIndex);
602
593
  }, [setResizeDeltas, resetAfterColumnIndex]);
603
594
 
604
- var _React$useState13 = React.useState(0),
595
+ var _React$useState11 = React.useState(0),
596
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
597
+ scrollLeft = _React$useState12[0],
598
+ setScrollLeft = _React$useState12[1];
599
+
600
+ var _React$useState13 = React.useState(false),
605
601
  _React$useState14 = _slicedToArray(_React$useState13, 2),
606
- scrollLeft = _React$useState14[0],
607
- setScrollLeft = _React$useState14[1];
602
+ isScrollingX = _React$useState14[0],
603
+ setIsScrollingX = _React$useState14[1];
608
604
 
609
605
  var _React$useState15 = React.useState(false),
610
606
  _React$useState16 = _slicedToArray(_React$useState15, 2),
611
- isScrollingX = _React$useState16[0],
612
- setIsScrollingX = _React$useState16[1];
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];
607
+ recentlyScrolledX = _React$useState16[0],
608
+ setRecentlyScrolledX = _React$useState16[1];
618
609
 
619
610
  React.useLayoutEffect(function () {
620
611
  if (recentlyScrolledX !== isScrollingX) {
@@ -736,18 +727,25 @@ export function DataTable(_ref2) {
736
727
  return result;
737
728
  }, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
738
729
 
739
- var _React$useState19 = React.useState(0),
740
- _React$useState20 = _slicedToArray(_React$useState19, 2),
741
- browserScrollbarWidth = _React$useState20[0],
742
- setBrowserScrollbarWidth = _React$useState20[1];
730
+ var _React$useState17 = React.useState(0),
731
+ _React$useState18 = _slicedToArray(_React$useState17, 2),
732
+ browserScrollbarWidth = _React$useState18[0],
733
+ setBrowserScrollbarWidth = _React$useState18[1];
743
734
 
744
735
  var normalizedWidths = React.useMemo(function () {
736
+ var sum = function sum(ns) {
737
+ return ns.reduce(function (s, n) {
738
+ return s + n;
739
+ }, 0);
740
+ };
741
+
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
- var gridProps = gridRef.props;
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,7 @@ export function DataTable(_ref2) {
784
782
  }
785
783
 
786
784
  return resizedWidths;
787
- }, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
785
+ }, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
788
786
  var isSelectable = batchActions ? !!batchActions.length : false;
789
787
  var isSelectedAll = React.useMemo(function () {
790
788
  if (!selectedRowIds) {
@@ -828,23 +826,23 @@ export function DataTable(_ref2) {
828
826
  }
829
827
  }, [onSort]);
830
828
 
829
+ var _React$useState19 = React.useState(-1),
830
+ _React$useState20 = _slicedToArray(_React$useState19, 2),
831
+ columnHighlightIndex = _React$useState20[0],
832
+ setColumnHighlightIndex = _React$useState20[1];
833
+
831
834
  var _React$useState21 = React.useState(-1),
832
835
  _React$useState22 = _slicedToArray(_React$useState21, 2),
833
- columnHighlightIndex = _React$useState22[0],
834
- setColumnHighlightIndex = _React$useState22[1];
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];
836
+ rowHighlightIndex = _React$useState22[0],
837
+ setRowHighlightIndex = _React$useState22[1];
840
838
 
841
839
  function handleRowHighlightIndexChange(nextIndex) {
842
840
  setRowHighlightIndex(nextIndex);
843
841
 
844
- if (gridRef) {
842
+ if (gridRef.current) {
845
843
  if (nextIndex >= 0) {
846
844
  // $FlowFixMe - unable to get react-window types
847
- gridRef.scrollToItem({
845
+ gridRef.current.scrollToItem({
848
846
  rowIndex: nextIndex
849
847
  });
850
848
  }
@@ -935,9 +933,8 @@ export function DataTable(_ref2) {
935
933
  }
936
934
  }, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
937
935
  , {
938
- ref: setGridRef,
936
+ ref: gridRef,
939
937
  overscanRowCount: 10,
940
- overscanColumnCount: 5,
941
938
  innerElementType: InnerTableElement,
942
939
  columnCount: columns.length,
943
940
  columnWidth: function columnWidth(columnIndex) {
@@ -21,7 +21,6 @@ import { Button, SIZE as BUTTON_SIZE } from '../button/index.js';
21
21
  import { Checkbox, STYLE_TYPE } from '../checkbox/index.js';
22
22
  import { useStyletron } from '../styles/index.js';
23
23
  import { LocaleContext } from '../locale/index.js';
24
- import { FILTER_SHELL_WIDTH } from './constants.js';
25
24
 
26
25
  function FilterShell(props) {
27
26
  var _useStyletron = useStyletron(),
@@ -30,21 +29,6 @@ function FilterShell(props) {
30
29
  theme = _useStyletron2[1];
31
30
 
32
31
  var locale = React.useContext(LocaleContext);
33
- var excludeText;
34
-
35
- switch (props.excludeKind) {
36
- case 'value':
37
- excludeText = locale.datatable.filterExcludeValue;
38
- break;
39
-
40
- case 'range':
41
- excludeText = locale.datatable.filterExcludeRange;
42
- break;
43
-
44
- default:
45
- excludeText = locale.datatable.filterExclude;
46
- }
47
-
48
32
  return /*#__PURE__*/React.createElement("form", {
49
33
  className: css({
50
34
  backgroundColor: theme.colors.backgroundPrimary,
@@ -52,7 +36,7 @@ function FilterShell(props) {
52
36
  paddingRight: theme.sizing.scale600,
53
37
  paddingBottom: theme.sizing.scale600,
54
38
  paddingLeft: theme.sizing.scale600,
55
- width: FILTER_SHELL_WIDTH
39
+ width: '320px'
56
40
  }),
57
41
  onSubmit: function onSubmit(event) {
58
42
  event.preventDefault();
@@ -60,23 +44,17 @@ function FilterShell(props) {
60
44
  }
61
45
  }, props.children, /*#__PURE__*/React.createElement("div", {
62
46
  className: css({
47
+ alignItems: 'center',
63
48
  display: 'flex',
64
- flexDirection: 'column',
65
49
  justifyContent: 'space-between',
66
- alignItems: 'flex-end',
67
- marginTop: theme.sizing.scale600,
68
- gap: theme.sizing.scale200
69
- })
70
- }, /*#__PURE__*/React.createElement("div", {
71
- className: css({
72
- alignSelf: 'flex-start'
50
+ marginTop: theme.sizing.scale600
73
51
  })
74
52
  }, /*#__PURE__*/React.createElement(Checkbox, {
75
53
  checked: props.exclude,
76
54
  onChange: props.onExcludeChange,
77
55
  checkmarkType: STYLE_TYPE.toggle_round,
78
56
  labelPlacement: "right"
79
- }, excludeText)), /*#__PURE__*/React.createElement(Button, {
57
+ }, locale.datatable.filterExclude), /*#__PURE__*/React.createElement(Button, {
80
58
  size: BUTTON_SIZE.compact,
81
59
  type: "submit"
82
60
  }, locale.datatable.filterApply)));
@@ -6,20 +6,18 @@ LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  var locale = {
8
8
  emptyState: 'No rows match the filter criteria defined. Please remove one or more filters to view more data.',
9
- loadingState: 'Loading rows.',
9
+ loadingState: 'Loading Rows.',
10
10
  searchAriaLabel: 'Search by text',
11
11
  filterAdd: 'Add Filter',
12
12
  filterExclude: 'Exclude',
13
13
  filterApply: 'Apply',
14
- filterExcludeRange: 'Exclude range',
15
- filterExcludeValue: 'Exclude value',
16
14
  filterAppliedTo: 'filter applied to',
17
15
  optionsLabel: 'Select column to filter by',
18
16
  optionsSearch: 'Search for a column to filter by...',
19
17
  optionsEmpty: 'No columns available.',
20
18
  categoricalFilterSelectAll: 'Select All',
21
19
  categoricalFilterSelectClear: 'Clear',
22
- categoricalFilterEmpty: 'No categories found',
20
+ categoricalFilterEmpty: 'No Categories Found',
23
21
  datetimeFilterRange: 'Range',
24
22
  datetimeFilterRangeDatetime: 'Date, Time',
25
23
  datetimeFilterRangeDate: 'Date',
@@ -1,3 +1,11 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
6
+
7
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
+
1
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
10
 
3
11
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -19,62 +27,51 @@ LICENSE file in the root directory of this source tree.
19
27
  import * as React from 'react';
20
28
  import { useStyletron } from '../styles/index.js';
21
29
  import HeaderCell from './header-cell.js';
22
- import { useRef } from 'react'; // Measures the column header + sampled data
23
30
 
24
- function MeasureColumn(_ref) {
25
- var sampleIndexes = _ref.sampleIndexes,
26
- column = _ref.column,
27
- columnIndex = _ref.columnIndex,
28
- rows = _ref.rows,
29
- isSelectable = _ref.isSelectable,
30
- onLayout = _ref.onLayout;
31
+ // https://github.com/Swizec/useDimensions
32
+ function useDimensions() {
33
+ var _React$useState = React.useState({}),
34
+ _React$useState2 = _slicedToArray(_React$useState, 2),
35
+ dimensions = _React$useState2[0],
36
+ setDimensions = _React$useState2[1];
31
37
 
32
- var _useStyletron = useStyletron(),
33
- _useStyletron2 = _slicedToArray(_useStyletron, 1),
34
- css = _useStyletron2[0];
38
+ var _React$useState3 = React.useState(null),
39
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
40
+ node = _React$useState4[0],
41
+ setNode = _React$useState4[1];
35
42
 
36
- var ref = useRef();
43
+ var ref = React.useCallback(function (node) {
44
+ setNode(node);
45
+ }, []);
37
46
  React.useEffect(function () {
38
- if (ref.current) {
39
- onLayout(columnIndex, ref.current.getBoundingClientRect());
47
+ if (typeof document !== 'undefined') {
48
+ if (node) {
49
+ window.requestAnimationFrame(function () {
50
+ setDimensions(node.getBoundingClientRect());
51
+ });
52
+ }
40
53
  }
41
- }, []);
42
- return /*#__PURE__*/React.createElement("div", {
43
- ref: ref,
44
- className: css({
45
- display: 'flex',
46
- flexDirection: 'column',
47
- width: 'fit-content'
48
- })
49
- }, /*#__PURE__*/React.createElement(HeaderCell, {
50
- index: columnIndex,
51
- isHovered: true,
52
- isMeasured: true,
53
- isSelectedAll: false,
54
- isSelectedIndeterminate: false,
55
- onMouseEnter: function onMouseEnter() {},
56
- onMouseLeave: function onMouseLeave() {},
57
- onSelectAll: function onSelectAll() {},
58
- onSelectNone: function onSelectNone() {},
59
- onSort: function onSort(i) {},
60
- sortable: column.sortable,
61
- sortDirection: null,
62
- title: column.title,
63
- isSelectable: isSelectable
64
- }), sampleIndexes.map(function (rowIndex, i) {
65
- var Cell = column.renderCell;
66
- return /*#__PURE__*/React.createElement(Cell, {
67
- key: "measure-".concat(i),
68
- value: column.mapDataToValue(rows[rowIndex].data),
69
- isSelectable: isSelectable,
70
- isMeasured: true,
71
- sortable: column.sortable,
72
- x: 0,
73
- y: rowIndex
74
- });
75
- }));
54
+ }, [node]);
55
+ return [ref, dimensions];
56
+ }
57
+
58
+ function ElementMeasurer(props) {
59
+ var onDimensionsChange = props.onDimensionsChange;
60
+
61
+ var _useDimensions = useDimensions(),
62
+ _useDimensions2 = _slicedToArray(_useDimensions, 2),
63
+ ref = _useDimensions2[0],
64
+ dimensions = _useDimensions2[1];
65
+
66
+ React.useEffect(function () {
67
+ onDimensionsChange(dimensions);
68
+ }, [dimensions, onDimensionsChange]);
69
+ return /*#__PURE__*/React.cloneElement(props.item, {
70
+ ref: ref
71
+ });
76
72
  }
77
73
 
74
+ // sample size could likely be generated based on row count, to have higher confidence
78
75
  var MAX_SAMPLE_SIZE = 50;
79
76
 
80
77
  function generateSampleIndices(inputMin, inputMax, maxSamples) {
@@ -106,46 +103,57 @@ function generateSampleIndices(inputMin, inputMax, maxSamples) {
106
103
  return indices;
107
104
  }
108
105
 
109
- export default function MeasureColumnWidths(_ref2) {
110
- var columns = _ref2.columns,
111
- rows = _ref2.rows,
112
- widths = _ref2.widths,
113
- isSelectable = _ref2.isSelectable,
114
- onWidthsChange = _ref2.onWidthsChange;
106
+ export default function MeasureColumnWidths(_ref) {
107
+ var columns = _ref.columns,
108
+ rows = _ref.rows,
109
+ widths = _ref.widths,
110
+ isSelectable = _ref.isSelectable,
111
+ onWidthsChange = _ref.onWidthsChange;
115
112
 
116
- var _useStyletron3 = useStyletron(),
117
- _useStyletron4 = _slicedToArray(_useStyletron3, 1),
118
- css = _useStyletron4[0];
113
+ var _useStyletron = useStyletron(),
114
+ _useStyletron2 = _slicedToArray(_useStyletron, 1),
115
+ css = _useStyletron2[0];
119
116
 
120
- var widthMap = React.useMemo(function () {
121
- return new Map();
122
- }, []);
117
+ var measurementCount = React.useRef(0);
118
+ var dimensionsCache = React.useRef(widths);
123
119
  var sampleSize = rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
124
120
  var finishedMeasurementCount = (sampleSize + 1) * columns.length;
125
- var sampleIndexes = React.useMemo(function () {
126
- return generateSampleIndices(0, rows.length - 1, sampleSize);
121
+ var sampleRowIndicesByColumn = React.useMemo(function () {
122
+ measurementCount.current = 0;
123
+ dimensionsCache.current = widths;
124
+ var indices = generateSampleIndices(0, rows.length - 1, sampleSize);
125
+ return columns.map(function () {
126
+ return indices;
127
+ });
127
128
  }, [columns, rows, widths, sampleSize]);
128
- var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
129
- var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
129
+ var handleDimensionsChange = React.useCallback(function (columnIndex, rowIndex, dimensions) {
130
+ if (dimensions.width === undefined) return;
130
131
 
131
- if (nextWidth !== widthMap.get(columnIndex)) {
132
- widthMap.set(columnIndex, nextWidth);
132
+ if (columns[columnIndex] === undefined || dimensionsCache.current[columnIndex] === undefined) {
133
+ return;
133
134
  }
134
135
 
135
- if ( // Refresh at 100% of done
136
- widthMap.size === columns.length || // ...50%
137
- widthMap.size === Math.floor(columns.length / 2) || // ...25%
138
- widthMap.size === Math.floor(columns.length / 4)) {
139
- onWidthsChange(Array.from(widthMap.values()));
136
+ measurementCount.current += 1;
137
+ var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, dimensionsCache.current[columnIndex], dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
138
+
139
+ if (nextWidth !== dimensionsCache.current[columnIndex]) {
140
+ var nextWidths = _toConsumableArray(dimensionsCache.current);
141
+
142
+ nextWidths[columnIndex] = nextWidth;
143
+ dimensionsCache.current = nextWidths;
144
+ }
145
+
146
+ if (measurementCount.current >= finishedMeasurementCount) {
147
+ onWidthsChange(dimensionsCache.current);
140
148
  }
141
149
  }, [columns, finishedMeasurementCount, onWidthsChange]);
142
150
  var hiddenStyle = css({
143
151
  position: 'absolute',
144
152
  overflow: 'hidden',
145
153
  height: 0
146
- }); // Remove the measurement nodes after we are done updating our column width
154
+ });
147
155
 
148
- if (widthMap.size === columns.length) {
156
+ if (measurementCount.current >= finishedMeasurementCount) {
149
157
  return null;
150
158
  }
151
159
 
@@ -156,15 +164,45 @@ export default function MeasureColumnWidths(_ref2) {
156
164
  className: hiddenStyle,
157
165
  "aria-hidden": true,
158
166
  role: "none"
159
- }, columns.map(function (column, i) {
160
- return /*#__PURE__*/React.createElement(MeasureColumn, {
161
- key: column.title + i,
162
- column: column,
163
- rows: rows,
164
- isSelectable: isSelectable,
165
- onLayout: handleDimensionsChange,
166
- columnIndex: i,
167
- sampleIndexes: sampleIndexes
167
+ }, sampleRowIndicesByColumn.map(function (rowIndices, columnIndex) {
168
+ var Cell = columns[columnIndex].renderCell;
169
+ return rowIndices.map(function (rowIndex) {
170
+ return /*#__PURE__*/React.createElement(ElementMeasurer, {
171
+ key: "measure-".concat(columnIndex, "-").concat(rowIndex),
172
+ onDimensionsChange: function onDimensionsChange(dimensions) {
173
+ return handleDimensionsChange(columnIndex, rowIndex, dimensions);
174
+ },
175
+ item: /*#__PURE__*/React.createElement(Cell, {
176
+ value: columns[columnIndex].mapDataToValue(rows[rowIndex].data),
177
+ isMeasured: true,
178
+ onSelect: isSelectable && columnIndex === 0 ? function () {} : undefined,
179
+ x: columnIndex,
180
+ y: rowIndex
181
+ })
182
+ });
183
+ });
184
+ }), columns.map(function (column, columnIndex) {
185
+ return /*#__PURE__*/React.createElement(ElementMeasurer, {
186
+ key: "measure-column-".concat(columnIndex),
187
+ onDimensionsChange: function onDimensionsChange(dimensions) {
188
+ return handleDimensionsChange(columnIndex, -1, dimensions);
189
+ },
190
+ item: /*#__PURE__*/React.createElement(HeaderCell, {
191
+ index: columnIndex,
192
+ isHovered: true,
193
+ isMeasured: true,
194
+ isSelectable: isSelectable && columnIndex === 0,
195
+ isSelectedAll: false,
196
+ isSelectedIndeterminate: false,
197
+ onMouseEnter: function onMouseEnter() {},
198
+ onMouseLeave: function onMouseLeave() {},
199
+ onSelectAll: function onSelectAll() {},
200
+ onSelectNone: function onSelectNone() {},
201
+ onSort: function onSort(i) {},
202
+ sortable: column.sortable,
203
+ sortDirection: null,
204
+ title: column.title
205
+ })
168
206
  });
169
207
  }))
170
208
  );