baseui 10.9.2 → 10.10.0
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/column-numerical.js +320 -362
- package/data-table/column-numerical.js.flow +285 -287
- package/data-table/constants.js +17 -11
- package/data-table/constants.js.flow +11 -8
- package/data-table/data-table.js +53 -50
- package/data-table/data-table.js.flow +18 -13
- package/data-table/filter-shell.js +27 -4
- package/data-table/filter-shell.js.flow +33 -9
- package/data-table/locale.js +4 -2
- package/data-table/locale.js.flow +6 -2
- package/data-table/measure-column-widths.js +83 -119
- package/data-table/measure-column-widths.js.flow +87 -107
- package/es/data-table/column-numerical.js +252 -320
- package/es/data-table/constants.js +12 -8
- package/es/data-table/data-table.js +18 -16
- package/es/data-table/filter-shell.js +26 -4
- package/es/data-table/locale.js +4 -2
- package/es/data-table/measure-column-widths.js +75 -84
- package/es/timezonepicker/timezone-picker.js +1 -1
- package/esm/data-table/column-numerical.js +317 -360
- package/esm/data-table/constants.js +12 -8
- package/esm/data-table/data-table.js +53 -50
- package/esm/data-table/filter-shell.js +26 -4
- package/esm/data-table/locale.js +4 -2
- package/esm/data-table/measure-column-widths.js +83 -119
- package/esm/timezonepicker/timezone-picker.js +1 -1
- package/package.json +2 -1
- package/timezonepicker/timezone-picker.js +1 -1
- package/timezonepicker/timezone-picker.js.flow +1 -1
|
@@ -19,13 +19,6 @@ 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
|
-
});
|
|
29
22
|
export var DATETIME_OPERATIONS = Object.freeze({
|
|
30
23
|
RANGE_DATETIME: 'RANGE_DATETIME',
|
|
31
24
|
RANGE_DATE: 'RANGE_DATE',
|
|
@@ -39,4 +32,15 @@ export var DATETIME_OPERATIONS = Object.freeze({
|
|
|
39
32
|
export var SORT_DIRECTIONS = Object.freeze({
|
|
40
33
|
ASC: 'ASC',
|
|
41
34
|
DESC: 'DESC'
|
|
42
|
-
});
|
|
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;
|
|
@@ -43,6 +43,12 @@ 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
|
+
|
|
46
52
|
function CellPlacement(_ref) {
|
|
47
53
|
var columnIndex = _ref.columnIndex,
|
|
48
54
|
rowIndex = _ref.rowIndex,
|
|
@@ -301,7 +307,7 @@ function Header(props) {
|
|
|
301
307
|
}))));
|
|
302
308
|
}
|
|
303
309
|
|
|
304
|
-
function Headers(
|
|
310
|
+
function Headers() {
|
|
305
311
|
var _useStyletron5 = useStyletron(),
|
|
306
312
|
_useStyletron6 = _slicedToArray(_useStyletron5, 2),
|
|
307
313
|
css = _useStyletron6[0],
|
|
@@ -320,9 +326,7 @@ function Headers(props) {
|
|
|
320
326
|
position: 'sticky',
|
|
321
327
|
top: 0,
|
|
322
328
|
left: 0,
|
|
323
|
-
width: "".concat(ctx.widths
|
|
324
|
-
return sum + w;
|
|
325
|
-
}, 0), "px"),
|
|
329
|
+
width: "".concat(sum(ctx.widths), "px"),
|
|
326
330
|
height: "".concat(HEADER_ROW_HEIGHT, "px"),
|
|
327
331
|
display: 'flex',
|
|
328
332
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -545,22 +549,27 @@ export function DataTable(_ref2) {
|
|
|
545
549
|
}
|
|
546
550
|
|
|
547
551
|
return rowHeight;
|
|
548
|
-
}, [rowHeight]);
|
|
549
|
-
|
|
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
|
|
550
554
|
|
|
551
|
-
var _React$useState7 = React.useState(
|
|
552
|
-
return 0;
|
|
553
|
-
})),
|
|
555
|
+
var _React$useState7 = React.useState(null),
|
|
554
556
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
555
|
-
|
|
556
|
-
|
|
557
|
+
gridRef = _React$useState8[0],
|
|
558
|
+
setGridRef = _React$useState8[1];
|
|
557
559
|
|
|
558
560
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
559
561
|
return 0;
|
|
560
562
|
})),
|
|
561
563
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
562
|
-
|
|
563
|
-
|
|
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];
|
|
564
573
|
|
|
565
574
|
React.useEffect(function () {
|
|
566
575
|
setMeasuredWidths(function (prev) {
|
|
@@ -575,11 +584,11 @@ export function DataTable(_ref2) {
|
|
|
575
584
|
});
|
|
576
585
|
}, [columns]);
|
|
577
586
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
578
|
-
if (gridRef
|
|
587
|
+
if (gridRef) {
|
|
579
588
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
580
|
-
gridRef.
|
|
589
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
581
590
|
}
|
|
582
|
-
}, [gridRef
|
|
591
|
+
}, [gridRef]);
|
|
583
592
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
584
593
|
setMeasuredWidths(nextWidths);
|
|
585
594
|
resetAfterColumnIndex(0);
|
|
@@ -592,20 +601,20 @@ export function DataTable(_ref2) {
|
|
|
592
601
|
resetAfterColumnIndex(columnIndex);
|
|
593
602
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
594
603
|
|
|
595
|
-
var _React$
|
|
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),
|
|
604
|
+
var _React$useState13 = React.useState(0),
|
|
601
605
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
602
|
-
|
|
603
|
-
|
|
606
|
+
scrollLeft = _React$useState14[0],
|
|
607
|
+
setScrollLeft = _React$useState14[1];
|
|
604
608
|
|
|
605
609
|
var _React$useState15 = React.useState(false),
|
|
606
610
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
607
|
-
|
|
608
|
-
|
|
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];
|
|
609
618
|
|
|
610
619
|
React.useLayoutEffect(function () {
|
|
611
620
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -727,25 +736,18 @@ export function DataTable(_ref2) {
|
|
|
727
736
|
return result;
|
|
728
737
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
729
738
|
|
|
730
|
-
var _React$
|
|
731
|
-
_React$
|
|
732
|
-
browserScrollbarWidth = _React$
|
|
733
|
-
setBrowserScrollbarWidth = _React$
|
|
739
|
+
var _React$useState19 = React.useState(0),
|
|
740
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
741
|
+
browserScrollbarWidth = _React$useState20[0],
|
|
742
|
+
setBrowserScrollbarWidth = _React$useState20[1];
|
|
734
743
|
|
|
735
744
|
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
|
-
|
|
742
745
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
743
746
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
744
747
|
});
|
|
745
748
|
|
|
746
|
-
if (gridRef
|
|
747
|
-
|
|
748
|
-
var gridProps = gridRef.current.props;
|
|
749
|
+
if (gridRef) {
|
|
750
|
+
var gridProps = gridRef.props;
|
|
749
751
|
var isContentTallerThanContainer = false;
|
|
750
752
|
var visibleRowHeight = 0;
|
|
751
753
|
|
|
@@ -782,7 +784,7 @@ export function DataTable(_ref2) {
|
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
return resizedWidths;
|
|
785
|
-
}, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
787
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
786
788
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
787
789
|
var isSelectedAll = React.useMemo(function () {
|
|
788
790
|
if (!selectedRowIds) {
|
|
@@ -826,23 +828,23 @@ export function DataTable(_ref2) {
|
|
|
826
828
|
}
|
|
827
829
|
}, [onSort]);
|
|
828
830
|
|
|
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
|
-
|
|
834
831
|
var _React$useState21 = React.useState(-1),
|
|
835
832
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
836
|
-
|
|
837
|
-
|
|
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];
|
|
838
840
|
|
|
839
841
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
840
842
|
setRowHighlightIndex(nextIndex);
|
|
841
843
|
|
|
842
|
-
if (gridRef
|
|
844
|
+
if (gridRef) {
|
|
843
845
|
if (nextIndex >= 0) {
|
|
844
846
|
// $FlowFixMe - unable to get react-window types
|
|
845
|
-
gridRef.
|
|
847
|
+
gridRef.scrollToItem({
|
|
846
848
|
rowIndex: nextIndex
|
|
847
849
|
});
|
|
848
850
|
}
|
|
@@ -933,8 +935,9 @@ export function DataTable(_ref2) {
|
|
|
933
935
|
}
|
|
934
936
|
}, /*#__PURE__*/React.createElement(VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
935
937
|
, {
|
|
936
|
-
ref:
|
|
938
|
+
ref: setGridRef,
|
|
937
939
|
overscanRowCount: 10,
|
|
940
|
+
overscanColumnCount: 5,
|
|
938
941
|
innerElementType: InnerTableElement,
|
|
939
942
|
columnCount: columns.length,
|
|
940
943
|
columnWidth: function columnWidth(columnIndex) {
|
|
@@ -21,6 +21,7 @@ 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';
|
|
24
25
|
|
|
25
26
|
function FilterShell(props) {
|
|
26
27
|
var _useStyletron = useStyletron(),
|
|
@@ -29,6 +30,21 @@ function FilterShell(props) {
|
|
|
29
30
|
theme = _useStyletron2[1];
|
|
30
31
|
|
|
31
32
|
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
|
+
|
|
32
48
|
return /*#__PURE__*/React.createElement("form", {
|
|
33
49
|
className: css({
|
|
34
50
|
backgroundColor: theme.colors.backgroundPrimary,
|
|
@@ -36,7 +52,7 @@ function FilterShell(props) {
|
|
|
36
52
|
paddingRight: theme.sizing.scale600,
|
|
37
53
|
paddingBottom: theme.sizing.scale600,
|
|
38
54
|
paddingLeft: theme.sizing.scale600,
|
|
39
|
-
width:
|
|
55
|
+
width: FILTER_SHELL_WIDTH
|
|
40
56
|
}),
|
|
41
57
|
onSubmit: function onSubmit(event) {
|
|
42
58
|
event.preventDefault();
|
|
@@ -44,17 +60,23 @@ function FilterShell(props) {
|
|
|
44
60
|
}
|
|
45
61
|
}, props.children, /*#__PURE__*/React.createElement("div", {
|
|
46
62
|
className: css({
|
|
47
|
-
alignItems: 'center',
|
|
48
63
|
display: 'flex',
|
|
64
|
+
flexDirection: 'column',
|
|
49
65
|
justifyContent: 'space-between',
|
|
50
|
-
|
|
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'
|
|
51
73
|
})
|
|
52
74
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
53
75
|
checked: props.exclude,
|
|
54
76
|
onChange: props.onExcludeChange,
|
|
55
77
|
checkmarkType: STYLE_TYPE.toggle_round,
|
|
56
78
|
labelPlacement: "right"
|
|
57
|
-
},
|
|
79
|
+
}, excludeText)), /*#__PURE__*/React.createElement(Button, {
|
|
58
80
|
size: BUTTON_SIZE.compact,
|
|
59
81
|
type: "submit"
|
|
60
82
|
}, locale.datatable.filterApply)));
|
package/esm/data-table/locale.js
CHANGED
|
@@ -6,18 +6,20 @@ 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
|
|
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',
|
|
14
16
|
filterAppliedTo: 'filter applied to',
|
|
15
17
|
optionsLabel: 'Select column to filter by',
|
|
16
18
|
optionsSearch: 'Search for a column to filter by...',
|
|
17
19
|
optionsEmpty: 'No columns available.',
|
|
18
20
|
categoricalFilterSelectAll: 'Select All',
|
|
19
21
|
categoricalFilterSelectClear: 'Clear',
|
|
20
|
-
categoricalFilterEmpty: 'No
|
|
22
|
+
categoricalFilterEmpty: 'No categories found',
|
|
21
23
|
datetimeFilterRange: 'Range',
|
|
22
24
|
datetimeFilterRangeDatetime: 'Date, Time',
|
|
23
25
|
datetimeFilterRangeDate: 'Date',
|
|
@@ -1,11 +1,3 @@
|
|
|
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
|
-
|
|
9
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
2
|
|
|
11
3
|
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."); }
|
|
@@ -27,51 +19,64 @@ LICENSE file in the root directory of this source tree.
|
|
|
27
19
|
import * as React from 'react';
|
|
28
20
|
import { useStyletron } from '../styles/index.js';
|
|
29
21
|
import HeaderCell from './header-cell.js';
|
|
22
|
+
import { useRef } from 'react'; // Measures the column header + sampled data
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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;
|
|
37
31
|
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
setNode = _React$useState4[1];
|
|
32
|
+
var _useStyletron = useStyletron(),
|
|
33
|
+
_useStyletron2 = _slicedToArray(_useStyletron, 1),
|
|
34
|
+
css = _useStyletron2[0];
|
|
42
35
|
|
|
43
|
-
var ref =
|
|
44
|
-
setNode(node);
|
|
45
|
-
}, []);
|
|
36
|
+
var ref = useRef();
|
|
46
37
|
React.useEffect(function () {
|
|
47
38
|
if (typeof document !== 'undefined') {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
setDimensions(node.getBoundingClientRect());
|
|
51
|
-
});
|
|
39
|
+
if (ref.current) {
|
|
40
|
+
onLayout(columnIndex, ref.current.getBoundingClientRect());
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
|
-
}, [
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
}, []);
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
ref: ref,
|
|
46
|
+
className: css({
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
width: 'fit-content'
|
|
50
|
+
})
|
|
51
|
+
}, /*#__PURE__*/React.createElement(HeaderCell, {
|
|
52
|
+
index: columnIndex,
|
|
53
|
+
isHovered: true,
|
|
54
|
+
isMeasured: true,
|
|
55
|
+
isSelectedAll: false,
|
|
56
|
+
isSelectedIndeterminate: false,
|
|
57
|
+
onMouseEnter: function onMouseEnter() {},
|
|
58
|
+
onMouseLeave: function onMouseLeave() {},
|
|
59
|
+
onSelectAll: function onSelectAll() {},
|
|
60
|
+
onSelectNone: function onSelectNone() {},
|
|
61
|
+
onSort: function onSort(i) {},
|
|
62
|
+
sortable: column.sortable,
|
|
63
|
+
sortDirection: null,
|
|
64
|
+
title: column.title,
|
|
65
|
+
isSelectable: isSelectable
|
|
66
|
+
}), sampleIndexes.map(function (rowIndex, i) {
|
|
67
|
+
var Cell = column.renderCell;
|
|
68
|
+
return /*#__PURE__*/React.createElement(Cell, {
|
|
69
|
+
key: "measure-".concat(i),
|
|
70
|
+
value: column.mapDataToValue(rows[rowIndex].data),
|
|
71
|
+
isSelectable: isSelectable,
|
|
72
|
+
isMeasured: true,
|
|
73
|
+
sortable: column.sortable,
|
|
74
|
+
x: 0,
|
|
75
|
+
y: rowIndex
|
|
76
|
+
});
|
|
77
|
+
}));
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
// sample size could likely be generated based on row count, to have higher confidence
|
|
75
80
|
var MAX_SAMPLE_SIZE = 50;
|
|
76
81
|
|
|
77
82
|
function generateSampleIndices(inputMin, inputMax, maxSamples) {
|
|
@@ -103,57 +108,46 @@ function generateSampleIndices(inputMin, inputMax, maxSamples) {
|
|
|
103
108
|
return indices;
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
export default function MeasureColumnWidths(
|
|
107
|
-
var columns =
|
|
108
|
-
rows =
|
|
109
|
-
widths =
|
|
110
|
-
isSelectable =
|
|
111
|
-
onWidthsChange =
|
|
111
|
+
export default function MeasureColumnWidths(_ref2) {
|
|
112
|
+
var columns = _ref2.columns,
|
|
113
|
+
rows = _ref2.rows,
|
|
114
|
+
widths = _ref2.widths,
|
|
115
|
+
isSelectable = _ref2.isSelectable,
|
|
116
|
+
onWidthsChange = _ref2.onWidthsChange;
|
|
112
117
|
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
css =
|
|
118
|
+
var _useStyletron3 = useStyletron(),
|
|
119
|
+
_useStyletron4 = _slicedToArray(_useStyletron3, 1),
|
|
120
|
+
css = _useStyletron4[0];
|
|
116
121
|
|
|
117
|
-
var
|
|
118
|
-
|
|
122
|
+
var widthMap = React.useMemo(function () {
|
|
123
|
+
return new Map();
|
|
124
|
+
}, []);
|
|
119
125
|
var sampleSize = rows.length < MAX_SAMPLE_SIZE ? rows.length : MAX_SAMPLE_SIZE;
|
|
120
126
|
var finishedMeasurementCount = (sampleSize + 1) * columns.length;
|
|
121
|
-
var
|
|
122
|
-
|
|
123
|
-
dimensionsCache.current = widths;
|
|
124
|
-
var indices = generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
125
|
-
return columns.map(function () {
|
|
126
|
-
return indices;
|
|
127
|
-
});
|
|
127
|
+
var sampleIndexes = React.useMemo(function () {
|
|
128
|
+
return generateSampleIndices(0, rows.length - 1, sampleSize);
|
|
128
129
|
}, [columns, rows, widths, sampleSize]);
|
|
129
|
-
var handleDimensionsChange = React.useCallback(function (columnIndex,
|
|
130
|
-
|
|
130
|
+
var handleDimensionsChange = React.useCallback(function (columnIndex, dimensions) {
|
|
131
|
+
var nextWidth = Math.min(Math.max(columns[columnIndex].minWidth || 0, widthMap.get(columnIndex) || 0, dimensions.width + 1), columns[columnIndex].maxWidth || Infinity);
|
|
131
132
|
|
|
132
|
-
if (
|
|
133
|
-
|
|
133
|
+
if (nextWidth !== widthMap.get(columnIndex)) {
|
|
134
|
+
widthMap.set(columnIndex, nextWidth);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
nextWidths[columnIndex] = nextWidth;
|
|
143
|
-
dimensionsCache.current = nextWidths;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (measurementCount.current >= finishedMeasurementCount) {
|
|
147
|
-
onWidthsChange(dimensionsCache.current);
|
|
137
|
+
if ( // Refresh at 100% of done
|
|
138
|
+
widthMap.size === columns.length || // ...50%
|
|
139
|
+
widthMap.size === Math.floor(columns.length / 2) || // ...25%
|
|
140
|
+
widthMap.size === Math.floor(columns.length / 4)) {
|
|
141
|
+
onWidthsChange(Array.from(widthMap.values()));
|
|
148
142
|
}
|
|
149
143
|
}, [columns, finishedMeasurementCount, onWidthsChange]);
|
|
150
144
|
var hiddenStyle = css({
|
|
151
145
|
position: 'absolute',
|
|
152
146
|
overflow: 'hidden',
|
|
153
147
|
height: 0
|
|
154
|
-
});
|
|
148
|
+
}); // Remove the measurement nodes after we are done updating our column width
|
|
155
149
|
|
|
156
|
-
if (
|
|
150
|
+
if (widthMap.size === columns.length) {
|
|
157
151
|
return null;
|
|
158
152
|
}
|
|
159
153
|
|
|
@@ -164,45 +158,15 @@ export default function MeasureColumnWidths(_ref) {
|
|
|
164
158
|
className: hiddenStyle,
|
|
165
159
|
"aria-hidden": true,
|
|
166
160
|
role: "none"
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
})
|
|
161
|
+
}, columns.map(function (column, i) {
|
|
162
|
+
return /*#__PURE__*/React.createElement(MeasureColumn, {
|
|
163
|
+
key: column.title + i,
|
|
164
|
+
column: column,
|
|
165
|
+
rows: rows,
|
|
166
|
+
isSelectable: isSelectable,
|
|
167
|
+
onLayout: handleDimensionsChange,
|
|
168
|
+
columnIndex: i,
|
|
169
|
+
sampleIndexes: sampleIndexes
|
|
206
170
|
});
|
|
207
171
|
}))
|
|
208
172
|
);
|
|
@@ -86,7 +86,7 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
86
86
|
try {
|
|
87
87
|
var offset = getTimezoneOffset(zoneName, compareDate) / 3600000;
|
|
88
88
|
var offsetFormatted = "".concat(offset >= 0 ? '+' : '-').concat(Math.abs(offset));
|
|
89
|
-
var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace(
|
|
89
|
+
var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace(/_/g, ' '));
|
|
90
90
|
|
|
91
91
|
if (_this.props.includeAbbreviations) {
|
|
92
92
|
var abbreviation = format(compareDate, 'zzz', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baseui",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.0",
|
|
4
4
|
"description": "A React Component library implementing the Base design language",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -193,6 +193,7 @@
|
|
|
193
193
|
"dependencies": {
|
|
194
194
|
"@date-io/date-fns": "^2.6.2",
|
|
195
195
|
"card-validator": "^6.2.0",
|
|
196
|
+
"d3": "^6.7.0",
|
|
196
197
|
"date-fns": "^2.6.0",
|
|
197
198
|
"date-fns-tz": "^1.2.2",
|
|
198
199
|
"glob": "^7.1.6",
|
|
@@ -95,7 +95,7 @@ var TimezonePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
95
95
|
try {
|
|
96
96
|
var offset = (0, _dateFnsTz.getTimezoneOffset)(zoneName, compareDate) / 3600000;
|
|
97
97
|
var offsetFormatted = "".concat(offset >= 0 ? '+' : '-').concat(Math.abs(offset));
|
|
98
|
-
var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace(
|
|
98
|
+
var label = "(GMT".concat(offsetFormatted, ") ").concat(zoneName.replace(/_/g, ' '));
|
|
99
99
|
|
|
100
100
|
if (_this.props.includeAbbreviations) {
|
|
101
101
|
var abbreviation = (0, _dateFnsTz.format)(compareDate, 'zzz', {
|
|
@@ -64,7 +64,7 @@ class TimezonePicker extends React.Component<
|
|
|
64
64
|
const offset = getTimezoneOffset(zoneName, compareDate) / 3_600_000;
|
|
65
65
|
|
|
66
66
|
const offsetFormatted = `${offset >= 0 ? '+' : '-'}${Math.abs(offset)}`;
|
|
67
|
-
let label = `(GMT${offsetFormatted}) ${zoneName.replace(
|
|
67
|
+
let label = `(GMT${offsetFormatted}) ${zoneName.replace(/_/g, ' ')}`;
|
|
68
68
|
|
|
69
69
|
if (this.props.includeAbbreviations) {
|
|
70
70
|
const abbreviation = format(compareDate, 'zzz', {timeZone: zoneName});
|