baseui 10.8.0 → 10.9.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/a11y/a11y.js +2 -2
- package/a11y/a11y.js.flow +3 -3
- package/button/styled-components.js +47 -18
- package/button/styled-components.js.flow +25 -5
- package/combobox/combobox.js +6 -3
- package/combobox/combobox.js.flow +4 -2
- package/combobox/types.js.flow +2 -0
- package/data-table/column-categorical.js +1 -1
- package/data-table/column-categorical.js.flow +2 -2
- package/data-table/column-numerical.js +307 -355
- package/data-table/column-numerical.js.flow +273 -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 -121
- package/data-table/measure-column-widths.js.flow +87 -109
- package/datepicker/styled-components.js +1 -1
- package/datepicker/styled-components.js.flow +4 -1
- package/drawer/drawer.js +3 -1
- package/drawer/drawer.js.flow +7 -1
- package/es/a11y/a11y.js +2 -2
- package/es/button/styled-components.js +32 -2
- package/es/combobox/combobox.js +6 -3
- package/es/data-table/column-categorical.js +2 -2
- package/es/data-table/column-numerical.js +245 -317
- 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 -86
- package/es/datepicker/styled-components.js +1 -1
- package/es/drawer/drawer.js +3 -1
- package/es/index.js +1 -1
- package/es/map-marker/badge-enhancer.js +61 -0
- package/es/map-marker/constants.js +146 -2
- package/es/map-marker/drag-shadow.js +32 -0
- package/es/map-marker/fixed-marker.js +54 -48
- package/es/map-marker/floating-marker.js +21 -12
- package/es/map-marker/index.js +1 -1
- package/es/map-marker/label-enhancer.js +39 -0
- package/es/map-marker/needle.js +26 -0
- package/es/map-marker/pin-head.js +42 -40
- package/es/map-marker/styled-components.js +177 -32
- package/es/map-marker/types.js +1 -1
- package/es/menu/maybe-child-menu.js +0 -2
- package/es/menu/nested-menus.js +49 -3
- package/es/menu/stateful-container.js +13 -12
- package/es/modal/modal.js +3 -1
- package/es/popover/popover.js +3 -1
- package/es/progress-bar/index.js +1 -1
- package/es/progress-bar/progressbar.js +25 -10
- package/es/progress-bar/styled-components.js +9 -5
- package/es/select/select-component.js +2 -10
- package/es/spinner/styled-components.js +34 -16
- package/es/table/filter.js +3 -1
- package/es/themes/dark-theme/color-component-tokens.js +4 -0
- package/es/themes/light-theme/color-component-tokens.js +4 -0
- package/es/timezonepicker/timezone-picker.js +53 -36
- package/es/timezonepicker/tzdata.js +2 -0
- package/es/timezonepicker/update-tzdata.js +69 -0
- package/esm/a11y/a11y.js +3 -3
- package/esm/button/styled-components.js +47 -18
- package/esm/combobox/combobox.js +6 -3
- package/esm/data-table/column-categorical.js +2 -2
- package/esm/data-table/column-numerical.js +304 -353
- 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 -121
- package/esm/datepicker/styled-components.js +1 -1
- package/esm/drawer/drawer.js +3 -1
- package/esm/index.js +1 -1
- package/esm/map-marker/badge-enhancer.js +79 -0
- package/esm/map-marker/constants.js +94 -4
- package/esm/map-marker/drag-shadow.js +53 -0
- package/esm/map-marker/fixed-marker.js +84 -80
- package/esm/map-marker/floating-marker.js +22 -13
- package/esm/map-marker/index.js +1 -1
- package/esm/map-marker/label-enhancer.js +60 -0
- package/esm/map-marker/needle.js +43 -0
- package/esm/map-marker/pin-head.js +77 -66
- package/esm/map-marker/styled-components.js +182 -51
- package/esm/map-marker/types.js +1 -1
- package/esm/menu/maybe-child-menu.js +0 -2
- package/esm/menu/nested-menus.js +66 -5
- package/esm/menu/stateful-container.js +15 -13
- package/esm/modal/modal.js +3 -1
- package/esm/popover/popover.js +3 -1
- package/esm/progress-bar/index.js +1 -1
- package/esm/progress-bar/progressbar.js +32 -10
- package/esm/progress-bar/styled-components.js +9 -4
- package/esm/select/select-component.js +2 -11
- package/esm/spinner/styled-components.js +35 -16
- package/esm/table/filter.js +3 -1
- package/esm/themes/dark-theme/color-component-tokens.js +4 -0
- package/esm/themes/light-theme/color-component-tokens.js +4 -0
- package/esm/timezonepicker/timezone-picker.js +64 -36
- package/esm/timezonepicker/tzdata.js +2 -0
- package/esm/timezonepicker/update-tzdata.js +160 -0
- package/index.js +6 -0
- package/index.js.flow +1 -1
- package/map-marker/badge-enhancer.js +90 -0
- package/map-marker/badge-enhancer.js.flow +86 -0
- package/map-marker/constants.js +103 -5
- package/map-marker/constants.js.flow +152 -0
- package/map-marker/drag-shadow.js +64 -0
- package/map-marker/drag-shadow.js.flow +52 -0
- package/map-marker/fixed-marker.js +84 -78
- package/map-marker/fixed-marker.js.flow +78 -66
- package/map-marker/floating-marker.js +22 -13
- package/map-marker/floating-marker.js.flow +30 -17
- package/map-marker/index.d.ts +125 -24
- package/map-marker/index.js +18 -0
- package/map-marker/index.js.flow +3 -0
- package/map-marker/label-enhancer.js +71 -0
- package/map-marker/label-enhancer.js.flow +63 -0
- package/map-marker/needle.js +54 -0
- package/map-marker/needle.js.flow +29 -0
- package/map-marker/pin-head.js +80 -69
- package/map-marker/pin-head.js.flow +122 -84
- package/map-marker/styled-components.js +200 -62
- package/map-marker/styled-components.js.flow +172 -22
- package/map-marker/types.js.flow +69 -20
- package/menu/index.d.ts +9 -4
- package/menu/maybe-child-menu.js +0 -2
- package/menu/maybe-child-menu.js.flow +0 -2
- package/menu/nested-menus.js +66 -5
- package/menu/nested-menus.js.flow +50 -5
- package/menu/stateful-container.js +15 -13
- package/menu/stateful-container.js.flow +19 -13
- package/menu/types.js.flow +7 -1
- package/modal/modal.js +3 -1
- package/modal/modal.js.flow +2 -0
- package/package.json +5 -4
- package/popover/popover.js +3 -1
- package/popover/popover.js.flow +2 -0
- package/progress-bar/index.d.ts +2 -0
- package/progress-bar/index.js +6 -0
- package/progress-bar/index.js.flow +1 -0
- package/progress-bar/progressbar.js +32 -10
- package/progress-bar/progressbar.js.flow +35 -9
- package/progress-bar/styled-components.js +9 -4
- package/progress-bar/styled-components.js.flow +15 -4
- package/progress-bar/types.js.flow +12 -2
- package/select/select-component.js +2 -11
- package/select/select-component.js.flow +5 -7
- package/spinner/styled-components.js +35 -16
- package/spinner/styled-components.js.flow +37 -19
- package/spinner/types.js.flow +10 -0
- package/styles/index.js.flow +1 -1
- package/table/filter.js +3 -1
- package/table/filter.js.flow +5 -1
- package/themes/dark-theme/color-component-tokens.js +4 -0
- package/themes/dark-theme/color-component-tokens.js.flow +4 -0
- package/themes/light-theme/color-component-tokens.js +4 -0
- package/themes/light-theme/color-component-tokens.js.flow +4 -0
- package/themes/types.js.flow +4 -0
- package/timezonepicker/timezone-picker.js +69 -41
- package/timezonepicker/timezone-picker.js.flow +52 -46
- package/timezonepicker/types.js.flow +1 -1
- package/timezonepicker/tzdata.js +10 -0
- package/timezonepicker/tzdata.js.flow +347 -0
- package/timezonepicker/update-tzdata.js +164 -0
- package/timezonepicker/update-tzdata.js.flow +70 -0
package/data-table/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.MAX_BIN_COUNT = exports.HISTOGRAM_SIZE = exports.FILTER_SHELL_WIDTH = exports.SORT_DIRECTIONS = exports.DATETIME_OPERATIONS = exports.NUMERICAL_FORMATS = exports.COLUMNS = void 0;
|
|
7
7
|
|
|
8
8
|
/*
|
|
9
9
|
Copyright (c) Uber Technologies, Inc.
|
|
@@ -28,14 +28,6 @@ var NUMERICAL_FORMATS = Object.freeze({
|
|
|
28
28
|
PERCENTAGE: 'PERCENTAGE'
|
|
29
29
|
});
|
|
30
30
|
exports.NUMERICAL_FORMATS = NUMERICAL_FORMATS;
|
|
31
|
-
var NUMERICAL_OPERATIONS = Object.freeze({
|
|
32
|
-
EQ: 'EQ',
|
|
33
|
-
GT: 'GT',
|
|
34
|
-
GTE: 'GTE',
|
|
35
|
-
LT: 'LT',
|
|
36
|
-
LTE: 'LTE'
|
|
37
|
-
});
|
|
38
|
-
exports.NUMERICAL_OPERATIONS = NUMERICAL_OPERATIONS;
|
|
39
31
|
var DATETIME_OPERATIONS = Object.freeze({
|
|
40
32
|
RANGE_DATETIME: 'RANGE_DATETIME',
|
|
41
33
|
RANGE_DATE: 'RANGE_DATE',
|
|
@@ -50,5 +42,19 @@ exports.DATETIME_OPERATIONS = DATETIME_OPERATIONS;
|
|
|
50
42
|
var SORT_DIRECTIONS = Object.freeze({
|
|
51
43
|
ASC: 'ASC',
|
|
52
44
|
DESC: 'DESC'
|
|
53
|
-
});
|
|
54
|
-
|
|
45
|
+
}); // If modifying this, take a look at the histogram and adjust. see HISTOGRAM_SIZE
|
|
46
|
+
|
|
47
|
+
exports.SORT_DIRECTIONS = SORT_DIRECTIONS;
|
|
48
|
+
var FILTER_SHELL_WIDTH = '320px'; // Depends on FILTER_SHELL_WIDTH
|
|
49
|
+
|
|
50
|
+
exports.FILTER_SHELL_WIDTH = FILTER_SHELL_WIDTH;
|
|
51
|
+
var HISTOGRAM_SIZE = {
|
|
52
|
+
width: 308,
|
|
53
|
+
height: 120
|
|
54
|
+
}; // Arguably visually appealing within the given width.
|
|
55
|
+
// Smaller and we don't have enough detail per bar.
|
|
56
|
+
// Larger and the bars are too granular and don't align well with the slider steps
|
|
57
|
+
|
|
58
|
+
exports.HISTOGRAM_SIZE = HISTOGRAM_SIZE;
|
|
59
|
+
var MAX_BIN_COUNT = 50;
|
|
60
|
+
exports.MAX_BIN_COUNT = MAX_BIN_COUNT;
|
|
@@ -23,14 +23,6 @@ export const NUMERICAL_FORMATS = Object.freeze({
|
|
|
23
23
|
PERCENTAGE: 'PERCENTAGE',
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export const NUMERICAL_OPERATIONS = Object.freeze({
|
|
27
|
-
EQ: 'EQ',
|
|
28
|
-
GT: 'GT',
|
|
29
|
-
GTE: 'GTE',
|
|
30
|
-
LT: 'LT',
|
|
31
|
-
LTE: 'LTE',
|
|
32
|
-
});
|
|
33
|
-
|
|
34
26
|
export const DATETIME_OPERATIONS = Object.freeze({
|
|
35
27
|
RANGE_DATETIME: 'RANGE_DATETIME',
|
|
36
28
|
RANGE_DATE: 'RANGE_DATE',
|
|
@@ -47,6 +39,17 @@ export const SORT_DIRECTIONS = Object.freeze({
|
|
|
47
39
|
DESC: 'DESC',
|
|
48
40
|
});
|
|
49
41
|
|
|
42
|
+
// If modifying this, take a look at the histogram and adjust. see HISTOGRAM_SIZE
|
|
43
|
+
export const FILTER_SHELL_WIDTH = '320px';
|
|
44
|
+
|
|
45
|
+
// Depends on FILTER_SHELL_WIDTH
|
|
46
|
+
export const HISTOGRAM_SIZE = {width: 308, height: 120};
|
|
47
|
+
|
|
48
|
+
// Arguably visually appealing within the given width.
|
|
49
|
+
// Smaller and we don't have enough detail per bar.
|
|
50
|
+
// Larger and the bars are too granular and don't align well with the slider steps
|
|
51
|
+
export const MAX_BIN_COUNT = 50;
|
|
52
|
+
|
|
50
53
|
declare var __DEV__: boolean;
|
|
51
54
|
declare var __NODE__: boolean;
|
|
52
55
|
declare var __BROWSER__: boolean;
|
package/data-table/data-table.js
CHANGED
|
@@ -62,6 +62,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
62
62
|
// consider pulling this out to a prop if useful.
|
|
63
63
|
var HEADER_ROW_HEIGHT = 48;
|
|
64
64
|
|
|
65
|
+
var sum = function sum(ns) {
|
|
66
|
+
return ns.reduce(function (s, n) {
|
|
67
|
+
return s + n;
|
|
68
|
+
}, 0);
|
|
69
|
+
};
|
|
70
|
+
|
|
65
71
|
function CellPlacement(_ref) {
|
|
66
72
|
var columnIndex = _ref.columnIndex,
|
|
67
73
|
rowIndex = _ref.rowIndex,
|
|
@@ -320,7 +326,7 @@ function Header(props) {
|
|
|
320
326
|
}))));
|
|
321
327
|
}
|
|
322
328
|
|
|
323
|
-
function Headers(
|
|
329
|
+
function Headers() {
|
|
324
330
|
var _useStyletron5 = (0, _index2.useStyletron)(),
|
|
325
331
|
_useStyletron6 = _slicedToArray(_useStyletron5, 2),
|
|
326
332
|
css = _useStyletron6[0],
|
|
@@ -339,9 +345,7 @@ function Headers(props) {
|
|
|
339
345
|
position: 'sticky',
|
|
340
346
|
top: 0,
|
|
341
347
|
left: 0,
|
|
342
|
-
width: "".concat(ctx.widths
|
|
343
|
-
return sum + w;
|
|
344
|
-
}, 0), "px"),
|
|
348
|
+
width: "".concat(sum(ctx.widths), "px"),
|
|
345
349
|
height: "".concat(HEADER_ROW_HEIGHT, "px"),
|
|
346
350
|
display: 'flex',
|
|
347
351
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -564,22 +568,27 @@ function DataTable(_ref2) {
|
|
|
564
568
|
}
|
|
565
569
|
|
|
566
570
|
return rowHeight;
|
|
567
|
-
}, [rowHeight]);
|
|
568
|
-
|
|
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
|
|
569
573
|
|
|
570
|
-
var _React$useState7 = React.useState(
|
|
571
|
-
return 0;
|
|
572
|
-
})),
|
|
574
|
+
var _React$useState7 = React.useState(null),
|
|
573
575
|
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
574
|
-
|
|
575
|
-
|
|
576
|
+
gridRef = _React$useState8[0],
|
|
577
|
+
setGridRef = _React$useState8[1];
|
|
576
578
|
|
|
577
579
|
var _React$useState9 = React.useState(columns.map(function () {
|
|
578
580
|
return 0;
|
|
579
581
|
})),
|
|
580
582
|
_React$useState10 = _slicedToArray(_React$useState9, 2),
|
|
581
|
-
|
|
582
|
-
|
|
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];
|
|
583
592
|
|
|
584
593
|
React.useEffect(function () {
|
|
585
594
|
setMeasuredWidths(function (prev) {
|
|
@@ -594,11 +603,11 @@ function DataTable(_ref2) {
|
|
|
594
603
|
});
|
|
595
604
|
}, [columns]);
|
|
596
605
|
var resetAfterColumnIndex = React.useCallback(function (columnIndex) {
|
|
597
|
-
if (gridRef
|
|
606
|
+
if (gridRef) {
|
|
598
607
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
599
|
-
gridRef.
|
|
608
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
600
609
|
}
|
|
601
|
-
}, [gridRef
|
|
610
|
+
}, [gridRef]);
|
|
602
611
|
var handleWidthsChange = React.useCallback(function (nextWidths) {
|
|
603
612
|
setMeasuredWidths(nextWidths);
|
|
604
613
|
resetAfterColumnIndex(0);
|
|
@@ -611,20 +620,20 @@ function DataTable(_ref2) {
|
|
|
611
620
|
resetAfterColumnIndex(columnIndex);
|
|
612
621
|
}, [setResizeDeltas, resetAfterColumnIndex]);
|
|
613
622
|
|
|
614
|
-
var _React$
|
|
615
|
-
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
616
|
-
scrollLeft = _React$useState12[0],
|
|
617
|
-
setScrollLeft = _React$useState12[1];
|
|
618
|
-
|
|
619
|
-
var _React$useState13 = React.useState(false),
|
|
623
|
+
var _React$useState13 = React.useState(0),
|
|
620
624
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
621
|
-
|
|
622
|
-
|
|
625
|
+
scrollLeft = _React$useState14[0],
|
|
626
|
+
setScrollLeft = _React$useState14[1];
|
|
623
627
|
|
|
624
628
|
var _React$useState15 = React.useState(false),
|
|
625
629
|
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
626
|
-
|
|
627
|
-
|
|
630
|
+
isScrollingX = _React$useState16[0],
|
|
631
|
+
setIsScrollingX = _React$useState16[1];
|
|
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];
|
|
628
637
|
|
|
629
638
|
React.useLayoutEffect(function () {
|
|
630
639
|
if (recentlyScrolledX !== isScrollingX) {
|
|
@@ -746,25 +755,18 @@ function DataTable(_ref2) {
|
|
|
746
755
|
return result;
|
|
747
756
|
}, [sortedIndices, filteredIndices, onIncludedRowsChange, allRows]);
|
|
748
757
|
|
|
749
|
-
var _React$
|
|
750
|
-
_React$
|
|
751
|
-
browserScrollbarWidth = _React$
|
|
752
|
-
setBrowserScrollbarWidth = _React$
|
|
758
|
+
var _React$useState19 = React.useState(0),
|
|
759
|
+
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
760
|
+
browserScrollbarWidth = _React$useState20[0],
|
|
761
|
+
setBrowserScrollbarWidth = _React$useState20[1];
|
|
753
762
|
|
|
754
763
|
var normalizedWidths = React.useMemo(function () {
|
|
755
|
-
var sum = function sum(ns) {
|
|
756
|
-
return ns.reduce(function (s, n) {
|
|
757
|
-
return s + n;
|
|
758
|
-
}, 0);
|
|
759
|
-
};
|
|
760
|
-
|
|
761
764
|
var resizedWidths = measuredWidths.map(function (w, i) {
|
|
762
765
|
return Math.floor(w) + Math.floor(resizeDeltas[i]);
|
|
763
766
|
});
|
|
764
767
|
|
|
765
|
-
if (gridRef
|
|
766
|
-
|
|
767
|
-
var gridProps = gridRef.current.props;
|
|
768
|
+
if (gridRef) {
|
|
769
|
+
var gridProps = gridRef.props;
|
|
768
770
|
var isContentTallerThanContainer = false;
|
|
769
771
|
var visibleRowHeight = 0;
|
|
770
772
|
|
|
@@ -801,7 +803,7 @@ function DataTable(_ref2) {
|
|
|
801
803
|
}
|
|
802
804
|
|
|
803
805
|
return resizedWidths;
|
|
804
|
-
}, [measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
806
|
+
}, [gridRef, measuredWidths, resizeDeltas, browserScrollbarWidth, rows.length, columns]);
|
|
805
807
|
var isSelectable = batchActions ? !!batchActions.length : false;
|
|
806
808
|
var isSelectedAll = React.useMemo(function () {
|
|
807
809
|
if (!selectedRowIds) {
|
|
@@ -845,23 +847,23 @@ function DataTable(_ref2) {
|
|
|
845
847
|
}
|
|
846
848
|
}, [onSort]);
|
|
847
849
|
|
|
848
|
-
var _React$useState19 = React.useState(-1),
|
|
849
|
-
_React$useState20 = _slicedToArray(_React$useState19, 2),
|
|
850
|
-
columnHighlightIndex = _React$useState20[0],
|
|
851
|
-
setColumnHighlightIndex = _React$useState20[1];
|
|
852
|
-
|
|
853
850
|
var _React$useState21 = React.useState(-1),
|
|
854
851
|
_React$useState22 = _slicedToArray(_React$useState21, 2),
|
|
855
|
-
|
|
856
|
-
|
|
852
|
+
columnHighlightIndex = _React$useState22[0],
|
|
853
|
+
setColumnHighlightIndex = _React$useState22[1];
|
|
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];
|
|
857
859
|
|
|
858
860
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
859
861
|
setRowHighlightIndex(nextIndex);
|
|
860
862
|
|
|
861
|
-
if (gridRef
|
|
863
|
+
if (gridRef) {
|
|
862
864
|
if (nextIndex >= 0) {
|
|
863
865
|
// $FlowFixMe - unable to get react-window types
|
|
864
|
-
gridRef.
|
|
866
|
+
gridRef.scrollToItem({
|
|
865
867
|
rowIndex: nextIndex
|
|
866
868
|
});
|
|
867
869
|
}
|
|
@@ -952,8 +954,9 @@ function DataTable(_ref2) {
|
|
|
952
954
|
}
|
|
953
955
|
}, /*#__PURE__*/React.createElement(_reactWindow.VariableSizeGrid // eslint-disable-next-line flowtype/no-weak-types
|
|
954
956
|
, {
|
|
955
|
-
ref:
|
|
957
|
+
ref: setGridRef,
|
|
956
958
|
overscanRowCount: 10,
|
|
959
|
+
overscanColumnCount: 5,
|
|
957
960
|
innerElementType: InnerTableElement,
|
|
958
961
|
columnCount: columns.length,
|
|
959
962
|
columnWidth: function columnWidth(columnIndex) {
|
|
@@ -87,6 +87,8 @@ type CellPlacementPropsT = {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
91
|
+
|
|
90
92
|
function CellPlacement({columnIndex, rowIndex, data, style}) {
|
|
91
93
|
const [css, theme] = useStyletron();
|
|
92
94
|
|
|
@@ -411,7 +413,7 @@ function Header(props: HeaderProps) {
|
|
|
411
413
|
);
|
|
412
414
|
}
|
|
413
415
|
|
|
414
|
-
function Headers(
|
|
416
|
+
function Headers() {
|
|
415
417
|
const [css, theme] = useStyletron();
|
|
416
418
|
const locale = React.useContext(LocaleContext);
|
|
417
419
|
const ctx = React.useContext(HeaderContext);
|
|
@@ -423,7 +425,7 @@ function Headers(props: {||}) {
|
|
|
423
425
|
position: 'sticky',
|
|
424
426
|
top: 0,
|
|
425
427
|
left: 0,
|
|
426
|
-
width: `${ctx.widths
|
|
428
|
+
width: `${sum(ctx.widths)}px`,
|
|
427
429
|
height: `${HEADER_ROW_HEIGHT}px`,
|
|
428
430
|
display: 'flex',
|
|
429
431
|
// this feels bad.. the absolutely positioned children elements
|
|
@@ -696,7 +698,10 @@ export function DataTable({
|
|
|
696
698
|
},
|
|
697
699
|
[rowHeight],
|
|
698
700
|
);
|
|
699
|
-
|
|
701
|
+
|
|
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);
|
|
700
705
|
const [measuredWidths, setMeasuredWidths] = React.useState(
|
|
701
706
|
columns.map(() => 0),
|
|
702
707
|
);
|
|
@@ -712,12 +717,12 @@ export function DataTable({
|
|
|
712
717
|
|
|
713
718
|
const resetAfterColumnIndex = React.useCallback(
|
|
714
719
|
columnIndex => {
|
|
715
|
-
if (gridRef
|
|
720
|
+
if (gridRef) {
|
|
716
721
|
// $FlowFixMe trigger react-window to layout the elements again
|
|
717
|
-
gridRef.
|
|
722
|
+
gridRef.resetAfterColumnIndex(columnIndex, true);
|
|
718
723
|
}
|
|
719
724
|
},
|
|
720
|
-
[gridRef
|
|
725
|
+
[gridRef],
|
|
721
726
|
);
|
|
722
727
|
const handleWidthsChange = React.useCallback(
|
|
723
728
|
nextWidths => {
|
|
@@ -843,13 +848,11 @@ export function DataTable({
|
|
|
843
848
|
|
|
844
849
|
const [browserScrollbarWidth, setBrowserScrollbarWidth] = React.useState(0);
|
|
845
850
|
const normalizedWidths = React.useMemo(() => {
|
|
846
|
-
const sum = ns => ns.reduce((s, n) => s + n, 0);
|
|
847
851
|
const resizedWidths = measuredWidths.map(
|
|
848
852
|
(w, i) => Math.floor(w) + Math.floor(resizeDeltas[i]),
|
|
849
853
|
);
|
|
850
|
-
if (gridRef
|
|
851
|
-
|
|
852
|
-
const gridProps = gridRef.current.props;
|
|
854
|
+
if (gridRef) {
|
|
855
|
+
const gridProps = gridRef.props;
|
|
853
856
|
|
|
854
857
|
let isContentTallerThanContainer = false;
|
|
855
858
|
let visibleRowHeight = 0;
|
|
@@ -886,6 +889,7 @@ export function DataTable({
|
|
|
886
889
|
}
|
|
887
890
|
return resizedWidths;
|
|
888
891
|
}, [
|
|
892
|
+
gridRef,
|
|
889
893
|
measuredWidths,
|
|
890
894
|
resizeDeltas,
|
|
891
895
|
browserScrollbarWidth,
|
|
@@ -948,10 +952,10 @@ export function DataTable({
|
|
|
948
952
|
|
|
949
953
|
function handleRowHighlightIndexChange(nextIndex) {
|
|
950
954
|
setRowHighlightIndex(nextIndex);
|
|
951
|
-
if (gridRef
|
|
955
|
+
if (gridRef) {
|
|
952
956
|
if (nextIndex >= 0) {
|
|
953
957
|
// $FlowFixMe - unable to get react-window types
|
|
954
|
-
gridRef.
|
|
958
|
+
gridRef.scrollToItem({rowIndex: nextIndex});
|
|
955
959
|
}
|
|
956
960
|
if (onRowHighlightChange) {
|
|
957
961
|
onRowHighlightChange(nextIndex, rows[nextIndex - 1]);
|
|
@@ -1051,8 +1055,9 @@ export function DataTable({
|
|
|
1051
1055
|
>
|
|
1052
1056
|
<VariableSizeGrid
|
|
1053
1057
|
// eslint-disable-next-line flowtype/no-weak-types
|
|
1054
|
-
ref={(
|
|
1058
|
+
ref={(setGridRef: any)}
|
|
1055
1059
|
overscanRowCount={10}
|
|
1060
|
+
overscanColumnCount={5}
|
|
1056
1061
|
innerElementType={InnerTableElement}
|
|
1057
1062
|
columnCount={columns.length}
|
|
1058
1063
|
columnWidth={columnIndex => normalizedWidths[columnIndex]}
|
|
@@ -17,6 +17,8 @@ var _index3 = require("../styles/index.js");
|
|
|
17
17
|
|
|
18
18
|
var _index4 = require("../locale/index.js");
|
|
19
19
|
|
|
20
|
+
var _constants = require("./constants.js");
|
|
21
|
+
|
|
20
22
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
23
|
|
|
22
24
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -40,6 +42,21 @@ function FilterShell(props) {
|
|
|
40
42
|
theme = _useStyletron2[1];
|
|
41
43
|
|
|
42
44
|
var locale = React.useContext(_index4.LocaleContext);
|
|
45
|
+
var excludeText;
|
|
46
|
+
|
|
47
|
+
switch (props.excludeKind) {
|
|
48
|
+
case 'value':
|
|
49
|
+
excludeText = locale.datatable.filterExcludeValue;
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
case 'range':
|
|
53
|
+
excludeText = locale.datatable.filterExcludeRange;
|
|
54
|
+
break;
|
|
55
|
+
|
|
56
|
+
default:
|
|
57
|
+
excludeText = locale.datatable.filterExclude;
|
|
58
|
+
}
|
|
59
|
+
|
|
43
60
|
return /*#__PURE__*/React.createElement("form", {
|
|
44
61
|
className: css({
|
|
45
62
|
backgroundColor: theme.colors.backgroundPrimary,
|
|
@@ -47,7 +64,7 @@ function FilterShell(props) {
|
|
|
47
64
|
paddingRight: theme.sizing.scale600,
|
|
48
65
|
paddingBottom: theme.sizing.scale600,
|
|
49
66
|
paddingLeft: theme.sizing.scale600,
|
|
50
|
-
width:
|
|
67
|
+
width: _constants.FILTER_SHELL_WIDTH
|
|
51
68
|
}),
|
|
52
69
|
onSubmit: function onSubmit(event) {
|
|
53
70
|
event.preventDefault();
|
|
@@ -55,17 +72,23 @@ function FilterShell(props) {
|
|
|
55
72
|
}
|
|
56
73
|
}, props.children, /*#__PURE__*/React.createElement("div", {
|
|
57
74
|
className: css({
|
|
58
|
-
alignItems: 'center',
|
|
59
75
|
display: 'flex',
|
|
76
|
+
flexDirection: 'column',
|
|
60
77
|
justifyContent: 'space-between',
|
|
61
|
-
|
|
78
|
+
alignItems: 'flex-end',
|
|
79
|
+
marginTop: theme.sizing.scale600,
|
|
80
|
+
gap: theme.sizing.scale200
|
|
81
|
+
})
|
|
82
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: css({
|
|
84
|
+
alignSelf: 'flex-start'
|
|
62
85
|
})
|
|
63
86
|
}, /*#__PURE__*/React.createElement(_index2.Checkbox, {
|
|
64
87
|
checked: props.exclude,
|
|
65
88
|
onChange: props.onExcludeChange,
|
|
66
89
|
checkmarkType: _index2.STYLE_TYPE.toggle_round,
|
|
67
90
|
labelPlacement: "right"
|
|
68
|
-
},
|
|
91
|
+
}, excludeText)), /*#__PURE__*/React.createElement(_index.Button, {
|
|
69
92
|
size: _index.SIZE.compact,
|
|
70
93
|
type: "submit"
|
|
71
94
|
}, locale.datatable.filterApply)));
|
|
@@ -12,10 +12,14 @@ import {Button, SIZE as BUTTON_SIZE} from '../button/index.js';
|
|
|
12
12
|
import {Checkbox, STYLE_TYPE} from '../checkbox/index.js';
|
|
13
13
|
import {useStyletron} from '../styles/index.js';
|
|
14
14
|
import {LocaleContext} from '../locale/index.js';
|
|
15
|
+
import {FILTER_SHELL_WIDTH} from './constants.js';
|
|
16
|
+
|
|
17
|
+
export type ExcludeKind = 'value' | 'range';
|
|
15
18
|
|
|
16
19
|
type PropsT = {
|
|
17
20
|
children: React.Node,
|
|
18
21
|
exclude: boolean,
|
|
22
|
+
excludeKind?: ExcludeKind,
|
|
19
23
|
onExcludeChange: () => void,
|
|
20
24
|
onApply: () => void,
|
|
21
25
|
};
|
|
@@ -23,6 +27,17 @@ type PropsT = {
|
|
|
23
27
|
function FilterShell(props: PropsT) {
|
|
24
28
|
const [css, theme] = useStyletron();
|
|
25
29
|
const locale = React.useContext(LocaleContext);
|
|
30
|
+
let excludeText;
|
|
31
|
+
switch (props.excludeKind) {
|
|
32
|
+
case 'value':
|
|
33
|
+
excludeText = locale.datatable.filterExcludeValue;
|
|
34
|
+
break;
|
|
35
|
+
case 'range':
|
|
36
|
+
excludeText = locale.datatable.filterExcludeRange;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
excludeText = locale.datatable.filterExclude;
|
|
40
|
+
}
|
|
26
41
|
return (
|
|
27
42
|
<form
|
|
28
43
|
className={css({
|
|
@@ -31,7 +46,7 @@ function FilterShell(props: PropsT) {
|
|
|
31
46
|
paddingRight: theme.sizing.scale600,
|
|
32
47
|
paddingBottom: theme.sizing.scale600,
|
|
33
48
|
paddingLeft: theme.sizing.scale600,
|
|
34
|
-
width:
|
|
49
|
+
width: FILTER_SHELL_WIDTH,
|
|
35
50
|
})}
|
|
36
51
|
onSubmit={event => {
|
|
37
52
|
event.preventDefault();
|
|
@@ -41,20 +56,29 @@ function FilterShell(props: PropsT) {
|
|
|
41
56
|
{props.children}
|
|
42
57
|
<div
|
|
43
58
|
className={css({
|
|
44
|
-
alignItems: 'center',
|
|
45
59
|
display: 'flex',
|
|
60
|
+
flexDirection: 'column',
|
|
46
61
|
justifyContent: 'space-between',
|
|
62
|
+
alignItems: 'flex-end',
|
|
47
63
|
marginTop: theme.sizing.scale600,
|
|
64
|
+
gap: theme.sizing.scale200,
|
|
48
65
|
})}
|
|
49
66
|
>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
labelPlacement="right"
|
|
67
|
+
<div
|
|
68
|
+
className={css({
|
|
69
|
+
alignSelf: 'flex-start',
|
|
70
|
+
})}
|
|
55
71
|
>
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
<Checkbox
|
|
73
|
+
checked={props.exclude}
|
|
74
|
+
onChange={props.onExcludeChange}
|
|
75
|
+
checkmarkType={STYLE_TYPE.toggle_round}
|
|
76
|
+
labelPlacement="right"
|
|
77
|
+
>
|
|
78
|
+
{excludeText}
|
|
79
|
+
</Checkbox>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
58
82
|
<Button size={BUTTON_SIZE.compact} type="submit">
|
|
59
83
|
{locale.datatable.filterApply}
|
|
60
84
|
</Button>
|
package/data-table/locale.js
CHANGED
|
@@ -13,18 +13,20 @@ LICENSE file in the root directory of this source tree.
|
|
|
13
13
|
*/
|
|
14
14
|
var locale = {
|
|
15
15
|
emptyState: 'No rows match the filter criteria defined. Please remove one or more filters to view more data.',
|
|
16
|
-
loadingState: 'Loading
|
|
16
|
+
loadingState: 'Loading rows.',
|
|
17
17
|
searchAriaLabel: 'Search by text',
|
|
18
18
|
filterAdd: 'Add Filter',
|
|
19
19
|
filterExclude: 'Exclude',
|
|
20
20
|
filterApply: 'Apply',
|
|
21
|
+
filterExcludeRange: 'Exclude range',
|
|
22
|
+
filterExcludeValue: 'Exclude value',
|
|
21
23
|
filterAppliedTo: 'filter applied to',
|
|
22
24
|
optionsLabel: 'Select column to filter by',
|
|
23
25
|
optionsSearch: 'Search for a column to filter by...',
|
|
24
26
|
optionsEmpty: 'No columns available.',
|
|
25
27
|
categoricalFilterSelectAll: 'Select All',
|
|
26
28
|
categoricalFilterSelectClear: 'Clear',
|
|
27
|
-
categoricalFilterEmpty: 'No
|
|
29
|
+
categoricalFilterEmpty: 'No categories found',
|
|
28
30
|
datetimeFilterRange: 'Range',
|
|
29
31
|
datetimeFilterRangeDatetime: 'Date, Time',
|
|
30
32
|
datetimeFilterRangeDate: 'Date',
|
|
@@ -12,6 +12,8 @@ export type DataTableLocaleT = {|
|
|
|
12
12
|
searchAriaLabel: string,
|
|
13
13
|
filterAdd: string,
|
|
14
14
|
filterExclude: string,
|
|
15
|
+
filterExcludeRange: string,
|
|
16
|
+
filterExcludeValue: string,
|
|
15
17
|
filterApply: string,
|
|
16
18
|
filterAppliedTo: string,
|
|
17
19
|
optionsLabel: string,
|
|
@@ -43,18 +45,20 @@ export type DataTableLocaleT = {|
|
|
|
43
45
|
const locale = {
|
|
44
46
|
emptyState:
|
|
45
47
|
'No rows match the filter criteria defined. Please remove one or more filters to view more data.',
|
|
46
|
-
loadingState: 'Loading
|
|
48
|
+
loadingState: 'Loading rows.',
|
|
47
49
|
searchAriaLabel: 'Search by text',
|
|
48
50
|
filterAdd: 'Add Filter',
|
|
49
51
|
filterExclude: 'Exclude',
|
|
50
52
|
filterApply: 'Apply',
|
|
53
|
+
filterExcludeRange: 'Exclude range',
|
|
54
|
+
filterExcludeValue: 'Exclude value',
|
|
51
55
|
filterAppliedTo: 'filter applied to',
|
|
52
56
|
optionsLabel: 'Select column to filter by',
|
|
53
57
|
optionsSearch: 'Search for a column to filter by...',
|
|
54
58
|
optionsEmpty: 'No columns available.',
|
|
55
59
|
categoricalFilterSelectAll: 'Select All',
|
|
56
60
|
categoricalFilterSelectClear: 'Clear',
|
|
57
|
-
categoricalFilterEmpty: 'No
|
|
61
|
+
categoricalFilterEmpty: 'No categories found',
|
|
58
62
|
datetimeFilterRange: 'Range',
|
|
59
63
|
datetimeFilterRangeDatetime: 'Date, Time',
|
|
60
64
|
datetimeFilterRangeDate: 'Date',
|