@elastic/eui 76.0.2 → 76.2.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/dist/eui_theme_dark.css +37 -6
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +37 -6
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
- package/es/components/datagrid/body/data_grid_body.js +19 -395
- package/es/components/datagrid/body/data_grid_body_custom.js +908 -0
- package/es/components/datagrid/body/data_grid_body_virtualized.js +1031 -0
- package/es/components/datagrid/body/data_grid_cell.js +16 -12
- package/es/components/datagrid/body/data_grid_cell_popover.js +32 -12
- package/es/components/datagrid/body/data_grid_cell_wrapper.js +132 -0
- package/es/components/datagrid/body/header/data_grid_header_row.js +3 -2
- package/es/components/datagrid/data_grid.js +21 -5
- package/es/components/datagrid/data_grid_types.js +18 -1
- package/es/components/datagrid/utils/row_heights.js +111 -31
- package/es/components/date_picker/auto_refresh/auto_refresh.js +2 -1
- package/es/components/form/range/dual_range.js +14 -7
- package/es/components/form/range/range.js +10 -3
- package/es/components/form/super_select/super_select.js +21 -18
- package/es/components/form/super_select/super_select_control.js +7 -14
- package/es/components/selectable/selectable.js +59 -36
- package/es/components/selectable/selectable_list/selectable_list.js +1 -1
- package/es/components/suggest/suggest.js +3 -10
- package/eui.d.ts +253 -146
- package/i18ntokens.json +89 -57
- package/lib/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
- package/lib/components/datagrid/body/data_grid_body.js +19 -416
- package/lib/components/datagrid/body/data_grid_body_custom.js +927 -0
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +1059 -0
- package/lib/components/datagrid/body/data_grid_cell.js +16 -12
- package/lib/components/datagrid/body/data_grid_cell_popover.js +35 -12
- package/lib/components/datagrid/body/data_grid_cell_wrapper.js +147 -0
- package/lib/components/datagrid/body/header/data_grid_header_row.js +4 -2
- package/lib/components/datagrid/data_grid.js +21 -4
- package/lib/components/datagrid/data_grid_types.js +22 -1
- package/lib/components/datagrid/utils/row_heights.js +116 -33
- package/lib/components/date_picker/auto_refresh/auto_refresh.js +2 -1
- package/lib/components/form/range/dual_range.js +14 -7
- package/lib/components/form/range/range.js +10 -3
- package/lib/components/form/super_select/super_select.js +21 -18
- package/lib/components/form/super_select/super_select_control.js +7 -16
- package/lib/components/selectable/selectable.js +59 -36
- package/lib/components/selectable/selectable_list/selectable_list.js +1 -1
- package/lib/components/suggest/suggest.js +3 -12
- package/optimize/es/components/datagrid/body/data_grid_body.js +17 -387
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +176 -0
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +311 -0
- package/optimize/es/components/datagrid/body/data_grid_cell.js +12 -9
- package/optimize/es/components/datagrid/body/data_grid_cell_popover.js +30 -12
- package/optimize/es/components/datagrid/body/data_grid_cell_wrapper.js +127 -0
- package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +3 -2
- package/optimize/es/components/datagrid/data_grid.js +8 -5
- package/optimize/es/components/datagrid/data_grid_types.js +18 -1
- package/optimize/es/components/datagrid/utils/row_heights.js +100 -31
- package/optimize/es/components/date_picker/auto_refresh/auto_refresh.js +2 -1
- package/optimize/es/components/form/range/dual_range.js +14 -7
- package/optimize/es/components/form/range/range.js +10 -3
- package/optimize/es/components/form/super_select/super_select.js +16 -12
- package/optimize/es/components/form/super_select/super_select_control.js +7 -14
- package/optimize/es/components/selectable/selectable.js +50 -34
- package/optimize/es/components/selectable/selectable_list/selectable_list.js +1 -1
- package/optimize/es/components/suggest/suggest.js +3 -10
- package/optimize/lib/components/datagrid/body/data_grid_body.js +16 -409
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +198 -0
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +342 -0
- package/optimize/lib/components/datagrid/body/data_grid_cell.js +12 -9
- package/optimize/lib/components/datagrid/body/data_grid_cell_popover.js +33 -19
- package/optimize/lib/components/datagrid/body/data_grid_cell_wrapper.js +144 -0
- package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +4 -2
- package/optimize/lib/components/datagrid/data_grid.js +8 -4
- package/optimize/lib/components/datagrid/data_grid_types.js +22 -1
- package/optimize/lib/components/datagrid/utils/row_heights.js +103 -37
- package/optimize/lib/components/date_picker/auto_refresh/auto_refresh.js +2 -1
- package/optimize/lib/components/form/range/dual_range.js +14 -7
- package/optimize/lib/components/form/range/range.js +10 -3
- package/optimize/lib/components/form/super_select/super_select.js +16 -11
- package/optimize/lib/components/form/super_select/super_select_control.js +7 -16
- package/optimize/lib/components/selectable/selectable.js +50 -35
- package/optimize/lib/components/selectable/selectable_list/selectable_list.js +1 -1
- package/optimize/lib/components/suggest/suggest.js +3 -12
- package/package.json +1 -1
- package/src/components/datagrid/_data_grid.scss +7 -0
- package/src/components/datagrid/_data_grid_data_row.scss +1 -0
- package/src/components/datagrid/body/footer/_data_grid_footer_row.scss +1 -0
- package/src/components/datagrid/body/header/_data_grid_header_row.scss +1 -0
- package/src/components/form/super_select/_super_select_control.scss +4 -0
- package/src/components/selectable/selectable_list/_selectable_list.scss +10 -3
- package/src/themes/amsterdam/global_styling/mixins/_states.scss +17 -8
- package/test-env/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
- package/test-env/components/datagrid/body/data_grid_body.js +18 -415
- package/test-env/components/datagrid/body/data_grid_body_custom.js +908 -0
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +1057 -0
- package/test-env/components/datagrid/body/data_grid_cell.js +16 -12
- package/test-env/components/datagrid/body/data_grid_cell_popover.js +33 -19
- package/test-env/components/datagrid/body/data_grid_cell_wrapper.js +144 -0
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +4 -2
- package/test-env/components/datagrid/data_grid.js +21 -4
- package/test-env/components/datagrid/data_grid_types.js +22 -1
- package/test-env/components/datagrid/utils/row_heights.js +103 -37
- package/test-env/components/date_picker/auto_refresh/auto_refresh.js +2 -1
- package/test-env/components/form/range/dual_range.js +14 -7
- package/test-env/components/form/range/range.js +10 -3
- package/test-env/components/form/super_select/super_select.js +21 -17
- package/test-env/components/form/super_select/super_select_control.js +7 -16
- package/test-env/components/selectable/selectable.js +58 -36
- package/test-env/components/selectable/selectable_list/selectable_list.js +1 -1
- package/test-env/components/suggest/suggest.js +3 -12
|
@@ -584,7 +584,7 @@ EuiDataGridCellContent.propTypes = {
|
|
|
584
584
|
*/
|
|
585
585
|
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
586
586
|
}),
|
|
587
|
-
rowHeightUtils: PropTypes.any,
|
|
587
|
+
rowHeightUtils: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.any.isRequired]),
|
|
588
588
|
pagination: PropTypes.shape({
|
|
589
589
|
/**
|
|
590
590
|
* The index of the current page, starts at 0 for the first page
|
|
@@ -871,7 +871,8 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
871
871
|
if (_this.isPopoverOpen()) {
|
|
872
872
|
var _this$props$popoverCo2 = _this.props.popoverContext,
|
|
873
873
|
setPopoverAnchor = _this$props$popoverCo2.setPopoverAnchor,
|
|
874
|
-
setPopoverContent = _this$props$popoverCo2.setPopoverContent
|
|
874
|
+
setPopoverContent = _this$props$popoverCo2.setPopoverContent,
|
|
875
|
+
setCellPopoverProps = _this$props$popoverCo2.setCellPopoverProps; // Set popover anchor
|
|
875
876
|
|
|
876
877
|
var cellAnchorEl = _this.popoverAnchorRef.current;
|
|
877
878
|
setPopoverAnchor(cellAnchorEl); // Set popover contents with cell content
|
|
@@ -898,7 +899,8 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
898
899
|
cellActions: ___EmotionJSX(EuiDataGridCellPopoverActions, _extends({}, sharedProps, {
|
|
899
900
|
column: column
|
|
900
901
|
})),
|
|
901
|
-
DefaultCellPopover: DefaultCellPopover
|
|
902
|
+
DefaultCellPopover: DefaultCellPopover,
|
|
903
|
+
setCellPopoverProps: setCellPopoverProps
|
|
902
904
|
}), ___EmotionJSX(CellElement, _extends({}, sharedProps, {
|
|
903
905
|
setCellProps: _this.setCellProps,
|
|
904
906
|
isExpandable: true,
|
|
@@ -953,7 +955,7 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
953
955
|
}, {
|
|
954
956
|
key: "componentDidUpdate",
|
|
955
957
|
value: function componentDidUpdate(prevProps) {
|
|
956
|
-
var _this$props$rowHeight, _prevProps$rowHeights, _this$props$rowHeight2, _this$props$style, _prevProps$style;
|
|
958
|
+
var _this$props$rowHeight, _prevProps$rowHeights, _this$props$rowHeight2, _this$props$rowHeight3, _this$props$style, _prevProps$style;
|
|
957
959
|
|
|
958
960
|
this.recalculateAutoHeight();
|
|
959
961
|
|
|
@@ -961,16 +963,17 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
961
963
|
this.recalculateLineHeight();
|
|
962
964
|
}
|
|
963
965
|
|
|
964
|
-
if ((_this$props$rowHeight2 = this.props.
|
|
966
|
+
if ((_this$props$rowHeight2 = this.props.rowHeightUtils) !== null && _this$props$rowHeight2 !== void 0 && _this$props$rowHeight2.compensateForLayoutShift && (_this$props$rowHeight3 = this.props.rowHeightsOptions) !== null && _this$props$rowHeight3 !== void 0 && _this$props$rowHeight3.scrollAnchorRow && this.props.colIndex === 0 && // once per row
|
|
965
967
|
this.props.columnId === prevProps.columnId && // if this is still the same column
|
|
966
968
|
this.props.rowIndex === prevProps.rowIndex && // if this is still the same row
|
|
967
969
|
((_this$props$style = this.props.style) === null || _this$props$style === void 0 ? void 0 : _this$props$style.top) !== ((_prevProps$style = prevProps.style) === null || _prevProps$style === void 0 ? void 0 : _prevProps$style.top) // if the top position has changed
|
|
968
970
|
) {
|
|
969
|
-
var _prevProps$style2, _this$props$style2, _this$props$
|
|
971
|
+
var _prevProps$style2, _this$props$style2, _this$props$rowHeight4;
|
|
970
972
|
|
|
971
973
|
var previousTop = parseFloat((_prevProps$style2 = prevProps.style) === null || _prevProps$style2 === void 0 ? void 0 : _prevProps$style2.top);
|
|
972
|
-
var currentTop = parseFloat((_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.top);
|
|
973
|
-
|
|
974
|
+
var currentTop = parseFloat((_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.top); // @ts-ignore We've already checked that this virtualization util is available above
|
|
975
|
+
|
|
976
|
+
this.props.rowHeightUtils.compensateForLayoutShift(this.props.rowIndex, currentTop - previousTop, (_this$props$rowHeight4 = this.props.rowHeightsOptions) === null || _this$props$rowHeight4 === void 0 ? void 0 : _this$props$rowHeight4.scrollAnchorRow);
|
|
974
977
|
}
|
|
975
978
|
|
|
976
979
|
if (this.props.popoverContext.popoverIsOpen !== prevProps.popoverContext.popoverIsOpen || this.props.popoverContext.cellLocation !== prevProps.popoverContext.cellLocation || this.props.renderCellPopover !== prevProps.renderCellPopover) {
|
|
@@ -1060,8 +1063,8 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1060
1063
|
});
|
|
1061
1064
|
|
|
1062
1065
|
cellProps.style = _objectSpread(_objectSpread({}, style), {}, {
|
|
1063
|
-
//
|
|
1064
|
-
top: 0,
|
|
1066
|
+
// set by react-window or the custom renderer
|
|
1067
|
+
top: style !== null && style !== void 0 && style.top ? 0 : undefined,
|
|
1065
1068
|
// The cell's row will handle top positioning
|
|
1066
1069
|
width: width,
|
|
1067
1070
|
// column width, can be undefined
|
|
@@ -1612,7 +1615,8 @@ EuiDataGridCell.propTypes = {
|
|
|
1612
1615
|
openCellPopover: PropTypes.func.isRequired,
|
|
1613
1616
|
closeCellPopover: PropTypes.func.isRequired,
|
|
1614
1617
|
setPopoverAnchor: PropTypes.func.isRequired,
|
|
1615
|
-
setPopoverContent: PropTypes.func.isRequired
|
|
1618
|
+
setPopoverContent: PropTypes.func.isRequired,
|
|
1619
|
+
setCellPopoverProps: PropTypes.func.isRequired
|
|
1616
1620
|
}).isRequired,
|
|
1617
1621
|
renderCellValue: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.func.isRequired]).isRequired,
|
|
1618
1622
|
renderCellPopover: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.func.isRequired]),
|
|
@@ -1655,7 +1659,7 @@ EuiDataGridCell.propTypes = {
|
|
|
1655
1659
|
*/
|
|
1656
1660
|
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
1657
1661
|
}),
|
|
1658
|
-
rowHeightUtils: PropTypes.any,
|
|
1662
|
+
rowHeightUtils: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.any.isRequired]),
|
|
1659
1663
|
rowManager: PropTypes.shape({
|
|
1660
1664
|
getRow: PropTypes.func.isRequired
|
|
1661
1665
|
}),
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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."); }
|
|
@@ -18,6 +26,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
18
26
|
* Side Public License, v 1.
|
|
19
27
|
*/
|
|
20
28
|
import React, { createContext, useState, useCallback } from 'react';
|
|
29
|
+
import classNames from 'classnames';
|
|
21
30
|
import { keys } from '../../../services';
|
|
22
31
|
import { EuiWrappingPopover } from '../../popover';
|
|
23
32
|
export var DataGridCellPopoverContext = /*#__PURE__*/createContext({
|
|
@@ -29,9 +38,12 @@ export var DataGridCellPopoverContext = /*#__PURE__*/createContext({
|
|
|
29
38
|
openCellPopover: function openCellPopover() {},
|
|
30
39
|
closeCellPopover: function closeCellPopover() {},
|
|
31
40
|
setPopoverAnchor: function setPopoverAnchor() {},
|
|
32
|
-
setPopoverContent: function setPopoverContent() {}
|
|
41
|
+
setPopoverContent: function setPopoverContent() {},
|
|
42
|
+
setCellPopoverProps: function setCellPopoverProps() {}
|
|
33
43
|
});
|
|
34
44
|
export var useCellPopover = function useCellPopover() {
|
|
45
|
+
var _cellPopoverProps$pan;
|
|
46
|
+
|
|
35
47
|
// Current open state & cell location are handled here
|
|
36
48
|
var _useState = useState(false),
|
|
37
49
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -55,7 +67,13 @@ export var useCellPopover = function useCellPopover() {
|
|
|
55
67
|
var _useState7 = useState(),
|
|
56
68
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
57
69
|
popoverContent = _useState8[0],
|
|
58
|
-
setPopoverContent = _useState8[1];
|
|
70
|
+
setPopoverContent = _useState8[1]; // Allow customization of most (not all) popover props by consumers
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var _useState9 = useState({}),
|
|
74
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
75
|
+
cellPopoverProps = _useState10[0],
|
|
76
|
+
setCellPopoverProps = _useState10[1];
|
|
59
77
|
|
|
60
78
|
var closeCellPopover = useCallback(function () {
|
|
61
79
|
return setPopoverIsOpen(false);
|
|
@@ -85,20 +103,20 @@ export var useCellPopover = function useCellPopover() {
|
|
|
85
103
|
openCellPopover: openCellPopover,
|
|
86
104
|
cellLocation: cellLocation,
|
|
87
105
|
setPopoverAnchor: setPopoverAnchor,
|
|
88
|
-
setPopoverContent: setPopoverContent
|
|
106
|
+
setPopoverContent: setPopoverContent,
|
|
107
|
+
setCellPopoverProps: setCellPopoverProps
|
|
89
108
|
}; // Note that this popover is rendered once at the top grid level, rather than one popover per cell
|
|
90
109
|
|
|
91
|
-
var cellPopover = popoverIsOpen && popoverAnchor && ___EmotionJSX(EuiWrappingPopover, {
|
|
110
|
+
var cellPopover = popoverIsOpen && popoverAnchor && ___EmotionJSX(EuiWrappingPopover, _extends({
|
|
92
111
|
isOpen: popoverIsOpen,
|
|
93
|
-
button: popoverAnchor,
|
|
94
112
|
display: "block",
|
|
95
113
|
hasArrow: false,
|
|
96
|
-
panelPaddingSize: "s"
|
|
97
|
-
|
|
98
|
-
panelProps: {
|
|
114
|
+
panelPaddingSize: "s"
|
|
115
|
+
}, cellPopoverProps, {
|
|
116
|
+
panelProps: _objectSpread({
|
|
99
117
|
'data-test-subj': 'euiDataGridExpansionPopover'
|
|
100
|
-
},
|
|
101
|
-
|
|
118
|
+
}, cellPopoverProps.panelProps || {}),
|
|
119
|
+
panelClassName: classNames('euiDataGridRowCell__popover', cellPopoverProps.panelClassName, (_cellPopoverProps$pan = cellPopoverProps.panelProps) === null || _cellPopoverProps$pan === void 0 ? void 0 : _cellPopoverProps$pan.className),
|
|
102
120
|
onKeyDown: function onKeyDown(event) {
|
|
103
121
|
if (event.key === keys.F2 || event.key === keys.ESCAPE) {
|
|
104
122
|
event.preventDefault();
|
|
@@ -109,8 +127,10 @@ export var useCellPopover = function useCellPopover() {
|
|
|
109
127
|
return popoverAnchor.parentElement.focus();
|
|
110
128
|
});
|
|
111
129
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
130
|
+
},
|
|
131
|
+
button: popoverAnchor,
|
|
132
|
+
closePopover: closeCellPopover
|
|
133
|
+
}), popoverContent);
|
|
114
134
|
|
|
115
135
|
return {
|
|
116
136
|
cellPopoverContext: cellPopoverContext,
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var _excluded = ["colIndex", "visibleRowIndex", "style", "schema", "schemaDetectors", "pagination", "columns", "leadingControlColumns", "trailingControlColumns", "visibleColCount", "columnWidths", "defaultColumnWidth", "renderCellValue", "renderCellPopover", "interactiveCellId", "setRowHeight", "rowHeightsOptions", "rowHeightUtils", "rowManager"];
|
|
2
|
+
|
|
3
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
8
|
+
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
13
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
14
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
15
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
16
|
+
* Side Public License, v 1.
|
|
17
|
+
*/
|
|
18
|
+
import React, { useContext, useMemo } from 'react';
|
|
19
|
+
import classNames from 'classnames';
|
|
20
|
+
import { DataGridSortingContext } from '../utils/sorting';
|
|
21
|
+
import { DataGridCellPopoverContext } from './data_grid_cell_popover';
|
|
22
|
+
import { EuiDataGridCell } from './data_grid_cell';
|
|
23
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A DRY wrapper used by both custom and virtualized grid cells.
|
|
27
|
+
* It grabs context, determines the type of cell being rendered
|
|
28
|
+
* (e.g. control vs data cell), & sets shared props between all cells
|
|
29
|
+
*/
|
|
30
|
+
export var Cell = function Cell(_ref) {
|
|
31
|
+
var colIndex = _ref.colIndex,
|
|
32
|
+
visibleRowIndex = _ref.visibleRowIndex,
|
|
33
|
+
style = _ref.style,
|
|
34
|
+
schema = _ref.schema,
|
|
35
|
+
schemaDetectors = _ref.schemaDetectors,
|
|
36
|
+
pagination = _ref.pagination,
|
|
37
|
+
columns = _ref.columns,
|
|
38
|
+
leadingControlColumns = _ref.leadingControlColumns,
|
|
39
|
+
trailingControlColumns = _ref.trailingControlColumns,
|
|
40
|
+
visibleColCount = _ref.visibleColCount,
|
|
41
|
+
columnWidths = _ref.columnWidths,
|
|
42
|
+
defaultColumnWidth = _ref.defaultColumnWidth,
|
|
43
|
+
renderCellValue = _ref.renderCellValue,
|
|
44
|
+
renderCellPopover = _ref.renderCellPopover,
|
|
45
|
+
interactiveCellId = _ref.interactiveCellId,
|
|
46
|
+
setRowHeight = _ref.setRowHeight,
|
|
47
|
+
rowHeightsOptions = _ref.rowHeightsOptions,
|
|
48
|
+
rowHeightUtils = _ref.rowHeightUtils,
|
|
49
|
+
rowManager = _ref.rowManager,
|
|
50
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
51
|
+
|
|
52
|
+
var popoverContext = useContext(DataGridCellPopoverContext);
|
|
53
|
+
|
|
54
|
+
var _useContext = useContext(DataGridSortingContext),
|
|
55
|
+
getCorrectRowIndex = _useContext.getCorrectRowIndex;
|
|
56
|
+
|
|
57
|
+
var cellContent;
|
|
58
|
+
var isFirstColumn = colIndex === 0;
|
|
59
|
+
var isLastColumn = colIndex === visibleColCount - 1;
|
|
60
|
+
var isLeadingControlColumn = colIndex < leadingControlColumns.length;
|
|
61
|
+
var isTrailingControlColumn = colIndex >= leadingControlColumns.length + columns.length;
|
|
62
|
+
var datacolIndex = colIndex - leadingControlColumns.length;
|
|
63
|
+
var column = columns[datacolIndex];
|
|
64
|
+
var columnId = column === null || column === void 0 ? void 0 : column.id;
|
|
65
|
+
var textTransform = useMemo(function () {
|
|
66
|
+
var _schemaDetectors$filt;
|
|
67
|
+
|
|
68
|
+
return (_schemaDetectors$filt = schemaDetectors.filter(function (row) {
|
|
69
|
+
return column !== null && column !== void 0 && column.schema ? (column === null || column === void 0 ? void 0 : column.schema) === row.type : columnId === row.type;
|
|
70
|
+
})[0]) === null || _schemaDetectors$filt === void 0 ? void 0 : _schemaDetectors$filt.textTransform;
|
|
71
|
+
}, [columnId, column === null || column === void 0 ? void 0 : column.schema, schemaDetectors]);
|
|
72
|
+
var classes = classNames(_defineProperty({
|
|
73
|
+
'euiDataGridRowCell--firstColumn': isFirstColumn,
|
|
74
|
+
'euiDataGridRowCell--lastColumn': isLastColumn,
|
|
75
|
+
'euiDataGridRowCell--controlColumn': isLeadingControlColumn || isTrailingControlColumn
|
|
76
|
+
}, "euiDataGridRowCell--".concat(textTransform), textTransform));
|
|
77
|
+
var sharedCellProps = {
|
|
78
|
+
rowIndex: getCorrectRowIndex(visibleRowIndex),
|
|
79
|
+
visibleRowIndex: visibleRowIndex,
|
|
80
|
+
colIndex: colIndex,
|
|
81
|
+
interactiveCellId: interactiveCellId,
|
|
82
|
+
className: classes,
|
|
83
|
+
style: style,
|
|
84
|
+
rowHeightsOptions: rowHeightsOptions,
|
|
85
|
+
rowHeightUtils: rowHeightUtils,
|
|
86
|
+
setRowHeight: isFirstColumn ? setRowHeight : undefined,
|
|
87
|
+
rowManager: rowManager,
|
|
88
|
+
popoverContext: popoverContext,
|
|
89
|
+
pagination: pagination
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
if (isLeadingControlColumn) {
|
|
93
|
+
var leadingColumn = leadingControlColumns[colIndex];
|
|
94
|
+
var id = leadingColumn.id,
|
|
95
|
+
rowCellRender = leadingColumn.rowCellRender;
|
|
96
|
+
cellContent = ___EmotionJSX(EuiDataGridCell, _extends({}, sharedCellProps, {
|
|
97
|
+
columnId: id,
|
|
98
|
+
width: leadingColumn.width,
|
|
99
|
+
renderCellValue: rowCellRender,
|
|
100
|
+
isExpandable: false
|
|
101
|
+
}, rest));
|
|
102
|
+
} else if (isTrailingControlColumn) {
|
|
103
|
+
var columnOffset = columns.length + leadingControlColumns.length;
|
|
104
|
+
var trailingcolIndex = colIndex - columnOffset;
|
|
105
|
+
var trailingColumn = trailingControlColumns[trailingcolIndex];
|
|
106
|
+
var _id = trailingColumn.id,
|
|
107
|
+
_rowCellRender = trailingColumn.rowCellRender;
|
|
108
|
+
cellContent = ___EmotionJSX(EuiDataGridCell, _extends({}, sharedCellProps, {
|
|
109
|
+
columnId: _id,
|
|
110
|
+
width: trailingColumn.width,
|
|
111
|
+
renderCellValue: _rowCellRender,
|
|
112
|
+
isExpandable: false
|
|
113
|
+
}, rest));
|
|
114
|
+
} else {
|
|
115
|
+
// this is a normal data cell
|
|
116
|
+
var columnType = schema[columnId] ? schema[columnId].columnType : null;
|
|
117
|
+
var isExpandable = column.isExpandable !== undefined ? column.isExpandable : true;
|
|
118
|
+
var width = columnWidths[columnId] || defaultColumnWidth;
|
|
119
|
+
cellContent = ___EmotionJSX(EuiDataGridCell, _extends({}, sharedCellProps, {
|
|
120
|
+
columnId: columnId,
|
|
121
|
+
column: column,
|
|
122
|
+
columnType: columnType,
|
|
123
|
+
width: width || undefined,
|
|
124
|
+
renderCellValue: renderCellValue,
|
|
125
|
+
renderCellPopover: renderCellPopover,
|
|
126
|
+
interactiveCellId: interactiveCellId,
|
|
127
|
+
isExpandable: isExpandable
|
|
128
|
+
}, rest));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return cellContent;
|
|
132
|
+
};
|
|
@@ -18,12 +18,13 @@ import PropTypes from "prop-types";
|
|
|
18
18
|
import React, { forwardRef } from 'react';
|
|
19
19
|
import { EuiDataGridControlHeaderCell } from './data_grid_control_header_cell';
|
|
20
20
|
import { EuiDataGridHeaderCell } from './data_grid_header_cell';
|
|
21
|
+
import { emptyControlColumns } from '../../data_grid_types';
|
|
21
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
23
|
var EuiDataGridHeaderRow = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
24
|
var _props$leadingControl = props.leadingControlColumns,
|
|
24
|
-
leadingControlColumns = _props$leadingControl === void 0 ?
|
|
25
|
+
leadingControlColumns = _props$leadingControl === void 0 ? emptyControlColumns : _props$leadingControl,
|
|
25
26
|
_props$trailingContro = props.trailingControlColumns,
|
|
26
|
-
trailingControlColumns = _props$trailingContro === void 0 ?
|
|
27
|
+
trailingControlColumns = _props$trailingContro === void 0 ? emptyControlColumns : _props$trailingContro,
|
|
27
28
|
columns = props.columns,
|
|
28
29
|
schema = props.schema,
|
|
29
30
|
schemaDetectors = props.schemaDetectors,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["leadingControlColumns", "trailingControlColumns", "columns", "columnVisibility", "schemaDetectors", "rowCount", "renderCellValue", "renderCellPopover", "renderFooterCellValue", "className", "gridStyle", "toolbarVisibility", "pagination", "sorting", "inMemory", "onColumnResize", "minSizeForControls", "height", "width", "rowHeightsOptions", "virtualizationOptions"],
|
|
1
|
+
var _excluded = ["leadingControlColumns", "trailingControlColumns", "columns", "columnVisibility", "schemaDetectors", "rowCount", "renderCellValue", "renderCellPopover", "renderFooterCellValue", "className", "gridStyle", "toolbarVisibility", "pagination", "sorting", "inMemory", "onColumnResize", "minSizeForControls", "height", "width", "rowHeightsOptions", "virtualizationOptions", "renderCustomGridBody"],
|
|
2
2
|
_excluded2 = ["focusProps"];
|
|
3
3
|
|
|
4
4
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
@@ -59,8 +59,9 @@ import { computeVisibleRows } from './utils/row_count';
|
|
|
59
59
|
import { EuiDataGridPaginationRenderer } from './utils/data_grid_pagination';
|
|
60
60
|
import { schemaDetectors as providedSchemaDetectors, useMergedSchema } from './utils/data_grid_schema';
|
|
61
61
|
import { useImperativeGridRef } from './utils/ref';
|
|
62
|
+
import { emptyControlColumns } from './data_grid_types'; // Each gridStyle object above sets a specific CSS select to .euiGrid
|
|
63
|
+
|
|
62
64
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
63
|
-
// Each gridStyle object above sets a specific CSS select to .euiGrid
|
|
64
65
|
var fontSizesToClassMap = {
|
|
65
66
|
s: 'euiDataGrid--fontSizeSmall',
|
|
66
67
|
m: '',
|
|
@@ -93,9 +94,9 @@ export var EuiDataGrid = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
93
94
|
var _gridItemsRendered$cu;
|
|
94
95
|
|
|
95
96
|
var _props$leadingControl = props.leadingControlColumns,
|
|
96
|
-
leadingControlColumns = _props$leadingControl === void 0 ?
|
|
97
|
+
leadingControlColumns = _props$leadingControl === void 0 ? emptyControlColumns : _props$leadingControl,
|
|
97
98
|
_props$trailingContro = props.trailingControlColumns,
|
|
98
|
-
trailingControlColumns = _props$trailingContro === void 0 ?
|
|
99
|
+
trailingControlColumns = _props$trailingContro === void 0 ? emptyControlColumns : _props$trailingContro,
|
|
99
100
|
columns = props.columns,
|
|
100
101
|
columnVisibility = props.columnVisibility,
|
|
101
102
|
schemaDetectors = props.schemaDetectors,
|
|
@@ -116,6 +117,7 @@ export var EuiDataGrid = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
116
117
|
width = props.width,
|
|
117
118
|
_rowHeightsOptions = props.rowHeightsOptions,
|
|
118
119
|
virtualizationOptions = props.virtualizationOptions,
|
|
120
|
+
renderCustomGridBody = props.renderCustomGridBody,
|
|
119
121
|
rest = _objectWithoutProperties(props, _excluded);
|
|
120
122
|
/**
|
|
121
123
|
* Merge consumer settings with defaults
|
|
@@ -393,7 +395,8 @@ export var EuiDataGrid = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
393
395
|
gridWidth: gridWidth,
|
|
394
396
|
gridRef: gridRef,
|
|
395
397
|
gridItemsRendered: gridItemsRendered,
|
|
396
|
-
wrapperRef: contentRef
|
|
398
|
+
wrapperRef: contentRef,
|
|
399
|
+
renderCustomGridBody: renderCustomGridBody
|
|
397
400
|
})), pagination && props['aria-labelledby'] && ___EmotionJSX("p", {
|
|
398
401
|
id: ariaLabelledById,
|
|
399
402
|
hidden: true
|
|
@@ -1048,6 +1051,19 @@ EuiDataGrid.propTypes = {
|
|
|
1048
1051
|
*/
|
|
1049
1052
|
renderFooterCellValue: PropTypes.oneOfType([PropTypes.func.isRequired, PropTypes.func.isRequired]),
|
|
1050
1053
|
|
|
1054
|
+
/**
|
|
1055
|
+
* An optional function called to completely customize and control the rendering of
|
|
1056
|
+
* EuiDataGrid's body and cell placement. This can be used to, e.g. remove EuiDataGrid's
|
|
1057
|
+
* virtualization library, or roll your own.
|
|
1058
|
+
*
|
|
1059
|
+
* This component is **only** meant as an escape hatch for extremely custom use cases.
|
|
1060
|
+
*
|
|
1061
|
+
* Behind the scenes, this function is treated as a React component,
|
|
1062
|
+
* allowing hooks, context, and other React concepts to be used.
|
|
1063
|
+
* It receives #EuiDataGridCustomBodyProps as its only argument.
|
|
1064
|
+
*/
|
|
1065
|
+
renderCustomGridBody: PropTypes.func,
|
|
1066
|
+
|
|
1051
1067
|
/**
|
|
1052
1068
|
* Defines the initial style of the grid. Accepts a partial #EuiDataGridStyle object.
|
|
1053
1069
|
* Settings provided may be overwritten or merged with user defined preferences if `toolbarVisibility.showDisplaySelector.allowDensity = true` (which is the default).
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
// since react-window doesn't export a type with the imperative api only we can
|
|
9
|
+
// use this to omit the react-specific class component methods
|
|
10
|
+
// An array of [x,y] coordinates. Note that the `y` value expected internally is a `visibleRowIndex`
|
|
11
|
+
// Force either aria-label or aria-labelledby to be defined
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props shared between renderCellValue and renderCellPopover
|
|
15
|
+
*/
|
|
16
|
+
// The empty control column array fallbacks need to be cached, or
|
|
17
|
+
// they'll cause rerendering/remount issues in memoized dependencies
|
|
18
|
+
export var emptyControlColumns = [];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
1
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
4
|
|
|
3
5
|
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."); }
|
|
@@ -6,6 +8,24 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
6
8
|
|
|
7
9
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
10
|
|
|
11
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
12
|
+
|
|
13
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
14
|
+
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
+
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
|
+
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
|
+
|
|
21
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
|
+
|
|
23
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
24
|
+
|
|
25
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
|
+
|
|
27
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
|
|
9
29
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
30
|
|
|
11
31
|
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."); }
|
|
@@ -46,16 +66,11 @@ export var cellPaddingsMap = {
|
|
|
46
66
|
export var AUTO_HEIGHT = 'auto';
|
|
47
67
|
export var DEFAULT_ROW_HEIGHT = 34;
|
|
48
68
|
export var RowHeightUtils = /*#__PURE__*/function () {
|
|
49
|
-
function RowHeightUtils(
|
|
69
|
+
function RowHeightUtils() {
|
|
50
70
|
var _this = this;
|
|
51
71
|
|
|
52
72
|
_classCallCheck(this, RowHeightUtils);
|
|
53
73
|
|
|
54
|
-
this.gridRef = gridRef;
|
|
55
|
-
this.outerGridElementRef = outerGridElementRef;
|
|
56
|
-
this.gridItemsRenderedRef = gridItemsRenderedRef;
|
|
57
|
-
this.rerenderGridBodyRef = rerenderGridBodyRef;
|
|
58
|
-
|
|
59
74
|
_defineProperty(this, "styles", {
|
|
60
75
|
paddingTop: 0,
|
|
61
76
|
paddingBottom: 0
|
|
@@ -87,10 +102,6 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
87
102
|
});
|
|
88
103
|
|
|
89
104
|
_defineProperty(this, "heightsCache", new Map());
|
|
90
|
-
|
|
91
|
-
_defineProperty(this, "timerId", void 0);
|
|
92
|
-
|
|
93
|
-
_defineProperty(this, "lastUpdatedRow", Infinity);
|
|
94
105
|
}
|
|
95
106
|
|
|
96
107
|
_createClass(RowHeightUtils, [{
|
|
@@ -176,6 +187,11 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
176
187
|
|
|
177
188
|
return false;
|
|
178
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Heights cache utils
|
|
192
|
+
* This cache is primarily used by auto heights & secondarily used by lineCount row overrides
|
|
193
|
+
*/
|
|
194
|
+
|
|
179
195
|
}, {
|
|
180
196
|
key: "getRowHeight",
|
|
181
197
|
value: function getRowHeight(rowIndex) {
|
|
@@ -188,23 +204,20 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
188
204
|
}, {
|
|
189
205
|
key: "setRowHeight",
|
|
190
206
|
value: function setRowHeight(rowIndex, colId) {
|
|
191
|
-
var _this$rerenderGridBod, _this$rerenderGridBod2;
|
|
192
|
-
|
|
193
207
|
var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_ROW_HEIGHT;
|
|
194
|
-
|
|
208
|
+
|
|
209
|
+
var _visibleRowIndex = arguments.length > 3 ? arguments[3] : undefined;
|
|
210
|
+
|
|
195
211
|
var rowHeights = this.heightsCache.get(rowIndex) || new Map();
|
|
196
212
|
var adaptedHeight = Math.ceil(height + this.styles.paddingTop + this.styles.paddingBottom);
|
|
197
213
|
|
|
198
214
|
if (rowHeights.get(colId) === adaptedHeight) {
|
|
199
|
-
return;
|
|
215
|
+
return false;
|
|
216
|
+
} else {
|
|
217
|
+
rowHeights.set(colId, adaptedHeight);
|
|
218
|
+
this.heightsCache.set(rowIndex, rowHeights);
|
|
219
|
+
return true;
|
|
200
220
|
}
|
|
201
|
-
|
|
202
|
-
rowHeights.set(colId, adaptedHeight);
|
|
203
|
-
this.heightsCache.set(rowIndex, rowHeights);
|
|
204
|
-
this.resetRow(visibleRowIndex); // When an auto row height is updated, force a re-render
|
|
205
|
-
// of the grid body to update the unconstrained height
|
|
206
|
-
|
|
207
|
-
(_this$rerenderGridBod = (_this$rerenderGridBod2 = this.rerenderGridBodyRef).current) === null || _this$rerenderGridBod === void 0 ? void 0 : _this$rerenderGridBod.call(_this$rerenderGridBod2);
|
|
208
221
|
}
|
|
209
222
|
}, {
|
|
210
223
|
key: "pruneHiddenColumnHeights",
|
|
@@ -223,22 +236,84 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
223
236
|
}
|
|
224
237
|
});
|
|
225
238
|
});
|
|
239
|
+
return didModify;
|
|
240
|
+
}
|
|
241
|
+
}]);
|
|
242
|
+
|
|
243
|
+
return RowHeightUtils;
|
|
244
|
+
}();
|
|
245
|
+
/**
|
|
246
|
+
* Row height utils with virtualization library-specific APIs
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
export var RowHeightVirtualizationUtils = /*#__PURE__*/function (_RowHeightUtils) {
|
|
250
|
+
_inherits(RowHeightVirtualizationUtils, _RowHeightUtils);
|
|
251
|
+
|
|
252
|
+
var _super = _createSuper(RowHeightVirtualizationUtils);
|
|
253
|
+
|
|
254
|
+
function RowHeightVirtualizationUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, rerenderGridBodyRef) {
|
|
255
|
+
var _this2;
|
|
256
|
+
|
|
257
|
+
_classCallCheck(this, RowHeightVirtualizationUtils);
|
|
258
|
+
|
|
259
|
+
_this2 = _super.call(this);
|
|
260
|
+
_this2.gridRef = gridRef;
|
|
261
|
+
_this2.outerGridElementRef = outerGridElementRef;
|
|
262
|
+
_this2.gridItemsRenderedRef = gridItemsRenderedRef;
|
|
263
|
+
_this2.rerenderGridBodyRef = rerenderGridBodyRef;
|
|
264
|
+
|
|
265
|
+
_defineProperty(_assertThisInitialized(_this2), "timerId", void 0);
|
|
266
|
+
|
|
267
|
+
_defineProperty(_assertThisInitialized(_this2), "lastUpdatedRow", Infinity);
|
|
268
|
+
|
|
269
|
+
return _this2;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Virtualization workarounds for auto height rows
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
_createClass(RowHeightVirtualizationUtils, [{
|
|
277
|
+
key: "setRowHeight",
|
|
278
|
+
value: function setRowHeight(rowIndex, colId) {
|
|
279
|
+
var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_ROW_HEIGHT;
|
|
280
|
+
var visibleRowIndex = arguments.length > 3 ? arguments[3] : undefined;
|
|
281
|
+
|
|
282
|
+
var didModify = _get(_getPrototypeOf(RowHeightVirtualizationUtils.prototype), "setRowHeight", this).call(this, rowIndex, colId, height, visibleRowIndex); // When an auto row height is updated, force a re-render
|
|
283
|
+
// of the grid body to update the unconstrained height
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
if (didModify) {
|
|
287
|
+
var _this$rerenderGridBod, _this$rerenderGridBod2;
|
|
288
|
+
|
|
289
|
+
(_this$rerenderGridBod = (_this$rerenderGridBod2 = this.rerenderGridBodyRef).current) === null || _this$rerenderGridBod === void 0 ? void 0 : _this$rerenderGridBod.call(_this$rerenderGridBod2);
|
|
290
|
+
this.resetRow(visibleRowIndex);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return didModify; // Mostly just here for typing
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "pruneHiddenColumnHeights",
|
|
297
|
+
value: function pruneHiddenColumnHeights(visibleColumns) {
|
|
298
|
+
var didModify = _get(_getPrototypeOf(RowHeightVirtualizationUtils.prototype), "pruneHiddenColumnHeights", this).call(this, visibleColumns);
|
|
226
299
|
|
|
227
300
|
if (didModify) {
|
|
228
301
|
this.resetRow(0);
|
|
229
302
|
}
|
|
303
|
+
|
|
304
|
+
return didModify; // Mostly just here for typing
|
|
230
305
|
}
|
|
231
306
|
}, {
|
|
232
307
|
key: "resetRow",
|
|
233
308
|
value: function resetRow(visibleRowIndex) {
|
|
234
|
-
var
|
|
309
|
+
var _this3 = this;
|
|
235
310
|
|
|
236
311
|
// save the first row index of batch, reassigning it only
|
|
237
312
|
// if this visible row index less than lastUpdatedRow
|
|
238
313
|
this.lastUpdatedRow = Math.min(this.lastUpdatedRow, visibleRowIndex);
|
|
239
314
|
clearTimeout(this.timerId);
|
|
240
315
|
this.timerId = window.setTimeout(function () {
|
|
241
|
-
return
|
|
316
|
+
return _this3.resetGrid();
|
|
242
317
|
}, 0);
|
|
243
318
|
}
|
|
244
319
|
}, {
|
|
@@ -276,24 +351,29 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
276
351
|
}
|
|
277
352
|
}]);
|
|
278
353
|
|
|
279
|
-
return
|
|
280
|
-
}();
|
|
354
|
+
return RowHeightVirtualizationUtils;
|
|
355
|
+
}(RowHeightUtils);
|
|
281
356
|
/**
|
|
282
357
|
* Hook for instantiating RowHeightUtils, setting internal class vars,
|
|
283
358
|
* and setting up various row-height-related side effects
|
|
284
359
|
*/
|
|
285
360
|
|
|
286
361
|
export var useRowHeightUtils = function useRowHeightUtils(_ref2) {
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
gridItemsRenderedRef = _ref2.gridItemsRenderedRef,
|
|
362
|
+
var virtualization = _ref2.virtualization,
|
|
363
|
+
rowHeightsOptions = _ref2.rowHeightsOptions,
|
|
290
364
|
gridStyles = _ref2.gridStyles,
|
|
291
|
-
columns = _ref2.columns
|
|
292
|
-
rowHeightsOptions = _ref2.rowHeightsOptions;
|
|
365
|
+
columns = _ref2.columns;
|
|
293
366
|
var forceRenderRef = useLatest(useForceRender());
|
|
294
367
|
|
|
295
368
|
var _useState = useState(function () {
|
|
296
|
-
|
|
369
|
+
if (virtualization) {
|
|
370
|
+
var _gridRef = virtualization.gridRef,
|
|
371
|
+
_outerGridElementRef = virtualization.outerGridElementRef,
|
|
372
|
+
_gridItemsRenderedRef = virtualization.gridItemsRenderedRef;
|
|
373
|
+
return new RowHeightVirtualizationUtils(_gridRef, _outerGridElementRef, _gridItemsRenderedRef, forceRenderRef);
|
|
374
|
+
} else {
|
|
375
|
+
return new RowHeightUtils();
|
|
376
|
+
}
|
|
297
377
|
}),
|
|
298
378
|
_useState2 = _slicedToArray(_useState, 1),
|
|
299
379
|
rowHeightUtils = _useState2[0]; // Forces a rerender whenever the row heights change, as this can cause the
|
|
@@ -157,7 +157,8 @@ export var EuiAutoRefreshButton = function EuiAutoRefreshButton(_ref2) {
|
|
|
157
157
|
isOpen: isPopoverOpen,
|
|
158
158
|
closePopover: function closePopover() {
|
|
159
159
|
setIsPopoverOpen(false);
|
|
160
|
-
}
|
|
160
|
+
},
|
|
161
|
+
popoverScreenReaderText: isPaused ? autoRefeshLabelOff : autoRefeshLabelOn
|
|
161
162
|
}, ___EmotionJSX(EuiRefreshInterval, {
|
|
162
163
|
onRefreshChange: onRefreshChange,
|
|
163
164
|
isPaused: isPaused,
|