@elastic/eui 97.2.0 → 97.3.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.
Files changed (64) hide show
  1. package/es/components/context_menu/context_menu_panel.js +17 -1
  2. package/es/components/datagrid/body/cell/data_grid_cell.js +31 -8
  3. package/es/components/datagrid/body/data_grid_body.js +8 -0
  4. package/es/components/datagrid/body/data_grid_body_custom.js +8 -1
  5. package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -1
  6. package/es/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
  7. package/es/components/datagrid/controls/display_selector.js +277 -207
  8. package/es/components/datagrid/data_grid.stories.utils.js +28 -2
  9. package/es/components/datagrid/data_grid.styles.js +1 -1
  10. package/es/components/datagrid/utils/grid_height_width.js +1 -1
  11. package/es/components/datagrid/utils/row_heights.js +29 -13
  12. package/es/components/header/header.styles.js +8 -1
  13. package/es/services/hooks/useDeepEqual.js +18 -6
  14. package/eui.d.ts +38 -10
  15. package/i18ntokens.json +88 -106
  16. package/lib/components/context_menu/context_menu_panel.js +17 -1
  17. package/lib/components/datagrid/body/cell/data_grid_cell.js +31 -8
  18. package/lib/components/datagrid/body/data_grid_body.js +8 -0
  19. package/lib/components/datagrid/body/data_grid_body_custom.js +8 -1
  20. package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -1
  21. package/lib/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
  22. package/lib/components/datagrid/controls/display_selector.js +275 -204
  23. package/lib/components/datagrid/data_grid.stories.utils.js +28 -2
  24. package/lib/components/datagrid/data_grid.styles.js +1 -1
  25. package/lib/components/datagrid/utils/grid_height_width.js +1 -1
  26. package/lib/components/datagrid/utils/row_heights.js +29 -13
  27. package/lib/components/header/header.styles.js +8 -1
  28. package/lib/services/hooks/useDeepEqual.js +17 -7
  29. package/optimize/es/components/context_menu/context_menu_panel.js +11 -1
  30. package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +15 -8
  31. package/optimize/es/components/datagrid/body/data_grid_body_custom.js +0 -1
  32. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +0 -1
  33. package/optimize/es/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
  34. package/optimize/es/components/datagrid/controls/display_selector.js +277 -207
  35. package/optimize/es/components/datagrid/data_grid.styles.js +1 -1
  36. package/optimize/es/components/datagrid/utils/grid_height_width.js +1 -1
  37. package/optimize/es/components/datagrid/utils/row_heights.js +29 -13
  38. package/optimize/es/components/header/header.styles.js +8 -1
  39. package/optimize/es/services/hooks/useDeepEqual.js +13 -6
  40. package/optimize/lib/components/context_menu/context_menu_panel.js +11 -1
  41. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +15 -8
  42. package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +0 -1
  43. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +0 -1
  44. package/optimize/lib/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
  45. package/optimize/lib/components/datagrid/controls/display_selector.js +274 -204
  46. package/optimize/lib/components/datagrid/data_grid.styles.js +1 -1
  47. package/optimize/lib/components/datagrid/utils/grid_height_width.js +1 -1
  48. package/optimize/lib/components/datagrid/utils/row_heights.js +29 -13
  49. package/optimize/lib/components/header/header.styles.js +8 -1
  50. package/optimize/lib/services/hooks/useDeepEqual.js +12 -5
  51. package/package.json +1 -1
  52. package/test-env/components/context_menu/context_menu_panel.js +17 -1
  53. package/test-env/components/datagrid/body/cell/data_grid_cell.js +31 -8
  54. package/test-env/components/datagrid/body/data_grid_body.js +8 -0
  55. package/test-env/components/datagrid/body/data_grid_body_custom.js +8 -1
  56. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -1
  57. package/test-env/components/datagrid/controls/data_grid_toolbar.styles.js +2 -2
  58. package/test-env/components/datagrid/controls/display_selector.js +274 -204
  59. package/test-env/components/datagrid/data_grid.stories.utils.js +28 -2
  60. package/test-env/components/datagrid/data_grid.styles.js +1 -1
  61. package/test-env/components/datagrid/utils/grid_height_width.js +1 -1
  62. package/test-env/components/datagrid/utils/row_heights.js +29 -13
  63. package/test-env/components/header/header.styles.js +8 -1
  64. package/test-env/services/hooks/useDeepEqual.js +12 -5
@@ -21,7 +21,7 @@ var _data_grid_cell_popover = require("./data_grid_cell_popover");
21
21
  var _focus_utils = require("./focus_utils");
22
22
  var _data_grid_cell = require("./data_grid_cell.styles");
23
23
  var _react2 = require("@emotion/react");
24
- var _excluded = ["renderCellValue", "cellContext", "column", "setCellContentsRef", "rowIndex", "colIndex", "rowHeight", "rowHeightUtils", "isControlColumn"],
24
+ var _excluded = ["renderCellValue", "cellContext", "column", "setCellContentsRef", "rowIndex", "colIndex", "rowHeightsOptions", "rowHeightUtils", "isControlColumn"],
25
25
  _excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
26
26
  _excluded3 = ["isExpandable", "style", "className", "data-test-subj"],
27
27
  _excluded4 = ["columnId", "columnIndex", "rowIndex", "visibleRowIndex"];
@@ -66,15 +66,20 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
66
66
  setCellContentsRef = _ref.setCellContentsRef,
67
67
  rowIndex = _ref.rowIndex,
68
68
  colIndex = _ref.colIndex,
69
- rowHeight = _ref.rowHeight,
69
+ rowHeightsOptions = _ref.rowHeightsOptions,
70
70
  rowHeightUtils = _ref.rowHeightUtils,
71
71
  isControlColumn = _ref.isControlColumn,
72
72
  rest = _objectWithoutProperties(_ref, _excluded);
73
73
  // React is more permissive than the TS types indicate
74
74
  var CellElement = renderCellValue;
75
+
76
+ // Cell height type
77
+ var rowHeight = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
75
78
  var cellHeightType = (0, _react.useMemo)(function () {
76
- return (rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getHeightType(rowHeight)) || 'default';
77
- }, [rowHeightUtils, rowHeight]);
79
+ return rowHeightUtils !== null && rowHeightUtils !== void 0 && rowHeightUtils.isAutoBelowLineCount(rowHeightsOptions, rowHeight) ? 'autoBelowLineCount' : (rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getHeightType(rowHeight)) || 'default';
80
+ }, [rowHeightUtils, rowHeight, rowHeightsOptions]);
81
+
82
+ // Classes and styles
78
83
  var classes = (0, _react.useMemo)(function () {
79
84
  return (0, _classnames.default)('euiDataGridRowCell__content', "euiDataGridRowCell__content--".concat(cellHeightType, "Height"), !isControlColumn && {
80
85
  'eui-textBreakWord': cellHeightType !== 'default',
@@ -85,9 +90,9 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
85
90
  var cssStyles = [styles.content.euiDataGridRowCell__content].concat(_toConsumableArray(isControlColumn ? [styles.content.controlColumn, styles.content.autoHeight] : [
86
91
  // Regular data cells should always inherit height from the row wrapper,
87
92
  // except for auto height
88
- cellHeightType === 'auto' ? styles.content.autoHeight : styles.content.defaultHeight]));
93
+ cellHeightType === 'auto' || cellHeightType === 'autoBelowLineCount' ? styles.content.autoHeight : styles.content.defaultHeight]));
89
94
  return (0, _react2.jsx)(RenderTruncatedCellContent, {
90
- hasLineCountTruncation: cellHeightType === 'lineCount' && !isControlColumn,
95
+ hasLineCountTruncation: (cellHeightType === 'lineCount' || cellHeightType === 'autoBelowLineCount') && !isControlColumn,
91
96
  rowHeight: rowHeight
92
97
  }, (0, _react2.jsx)("div", {
93
98
  ref: setCellContentsRef,
@@ -520,6 +525,14 @@ EuiDataGridCellContent.propTypes = {
520
525
  lineCount: _propTypes.default.number,
521
526
  height: _propTypes.default.number
522
527
  }).isRequired]),
528
+ /**
529
+ * Feature flag for custom `lineCount` behavior, where `lineCount` acts like a
530
+ * *max* number of lines (instead of a set number of lines for all rows).
531
+ *
532
+ * This functionality is in beta and has performance implications;
533
+ * we do not yet fully recommend/support it for heavy production usage.
534
+ */
535
+ autoBelowLineCount: _propTypes.default.bool,
523
536
  /**
524
537
  * Defines the height for a specific row. It can be line count or just height.
525
538
  *
@@ -660,6 +673,9 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
660
673
  rowHeightsOptions = _this$props3.rowHeightsOptions,
661
674
  rowIndex = _this$props3.rowIndex;
662
675
  var rowHeightOption = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
676
+ if (rowHeightUtils !== null && rowHeightUtils !== void 0 && rowHeightUtils.isAutoBelowLineCount(rowHeightsOptions, rowHeightOption)) {
677
+ return; // Using auto height instead
678
+ }
663
679
  var isSingleLine = rowHeightOption == null; // Undefined rowHeightsOptions default to a single line
664
680
  var lineCount = isSingleLine ? 1 : rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getLineCount(rowHeightOption);
665
681
  if (lineCount) {
@@ -964,7 +980,6 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
964
980
  // column width, can be undefined
965
981
  lineHeight: (_rowHeightsOptions$li = rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.lineHeight) !== null && _rowHeightsOptions$li !== void 0 ? _rowHeightsOptions$li : undefined
966
982
  }, cellPropsStyle);
967
- var rowHeight = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
968
983
  var row = rowManager && !_utils.IS_JEST_ENVIRONMENT ? rowManager.getRow({
969
984
  rowIndex: rowIndex,
970
985
  visibleRowIndex: visibleRowIndex,
@@ -996,7 +1011,7 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
996
1011
  isExpandable: isExpandable,
997
1012
  isExpanded: popoverIsOpen,
998
1013
  setCellContentsRef: this.setCellContentsRef,
999
- rowHeight: rowHeight,
1014
+ rowHeightsOptions: rowHeightsOptions,
1000
1015
  rowHeightUtils: rowHeightUtils,
1001
1016
  isControlColumn: isControlColumn,
1002
1017
  rowIndex: rowIndex,
@@ -1380,6 +1395,14 @@ EuiDataGridCell.propTypes = {
1380
1395
  lineCount: _propTypes.default.number,
1381
1396
  height: _propTypes.default.number
1382
1397
  }).isRequired]),
1398
+ /**
1399
+ * Feature flag for custom `lineCount` behavior, where `lineCount` acts like a
1400
+ * *max* number of lines (instead of a set number of lines for all rows).
1401
+ *
1402
+ * This functionality is in beta and has performance implications;
1403
+ * we do not yet fully recommend/support it for heavy production usage.
1404
+ */
1405
+ autoBelowLineCount: _propTypes.default.bool,
1383
1406
  /**
1384
1407
  * Defines the height for a specific row. It can be line count or just height.
1385
1408
  *
@@ -579,6 +579,14 @@ EuiDataGridBody.propTypes = {
579
579
  lineCount: _propTypes.default.number,
580
580
  height: _propTypes.default.number
581
581
  }).isRequired]),
582
+ /**
583
+ * Feature flag for custom `lineCount` behavior, where `lineCount` acts like a
584
+ * *max* number of lines (instead of a set number of lines for all rows).
585
+ *
586
+ * This functionality is in beta and has performance implications;
587
+ * we do not yet fully recommend/support it for heavy production usage.
588
+ */
589
+ autoBelowLineCount: _propTypes.default.bool,
582
590
  /**
583
591
  * Defines the height for a specific row. It can be line count or just height.
584
592
  *
@@ -90,7 +90,6 @@ var EuiDataGridBodyCustomRender = exports.EuiDataGridBodyCustomRender = /*#__PUR
90
90
  */
91
91
  var rowHeightUtils = (0, _row_heights.useRowHeightUtils)({
92
92
  rowHeightsOptions: rowHeightsOptions,
93
- gridStyles: gridStyles,
94
93
  columns: columns
95
94
  });
96
95
  var _useDefaultRowHeight = (0, _row_heights.useDefaultRowHeight)({
@@ -745,6 +744,14 @@ EuiDataGridBodyCustomRender.propTypes = {
745
744
  lineCount: _propTypes.default.number,
746
745
  height: _propTypes.default.number
747
746
  }).isRequired]),
747
+ /**
748
+ * Feature flag for custom `lineCount` behavior, where `lineCount` acts like a
749
+ * *max* number of lines (instead of a set number of lines for all rows).
750
+ *
751
+ * This functionality is in beta and has performance implications;
752
+ * we do not yet fully recommend/support it for heavy production usage.
753
+ */
754
+ autoBelowLineCount: _propTypes.default.bool,
748
755
  /**
749
756
  * Defines the height for a specific row. It can be line count or just height.
750
757
  *
@@ -223,7 +223,6 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
223
223
  gridItemsRenderedRef: gridItemsRendered
224
224
  },
225
225
  rowHeightsOptions: rowHeightsOptions,
226
- gridStyles: gridStyles,
227
226
  columns: columns
228
227
  });
229
228
  var _useDefaultRowHeight = (0, _row_heights.useDefaultRowHeight)({
@@ -870,6 +869,14 @@ EuiDataGridBodyVirtualized.propTypes = {
870
869
  lineCount: _propTypes.default.number,
871
870
  height: _propTypes.default.number
872
871
  }).isRequired]),
872
+ /**
873
+ * Feature flag for custom `lineCount` behavior, where `lineCount` acts like a
874
+ * *max* number of lines (instead of a set number of lines for all rows).
875
+ *
876
+ * This functionality is in beta and has performance implications;
877
+ * we do not yet fully recommend/support it for heavy production usage.
878
+ */
879
+ autoBelowLineCount: _propTypes.default.bool,
873
880
  /**
874
881
  * Defines the height for a specific row. It can be line count or just height.
875
882
  *
@@ -18,7 +18,7 @@ var euiDataGridToolbarStyles = exports.euiDataGridToolbarStyles = function euiDa
18
18
  var euiTheme = _ref.euiTheme;
19
19
  return {
20
20
  euiDataGrid__controls: /*#__PURE__*/(0, _react.css)("z-index:2;position:relative;display:flex;justify-content:space-between;align-items:center;gap:", euiTheme.size.base, ";", (0, _global_styling.logicalCSS)('padding-vertical', euiTheme.size.xs), " background-color:", euiTheme.colors.emptyShade, ";;label:euiDataGrid__controls;"),
21
- euiDataGrid__rightControls: /*#__PURE__*/(0, _react.css)("display:flex;justify-content:flex-end;flex-wrap:wrap;column-gap:", euiTheme.size.s, ";", (0, _global_styling.logicalCSS)('padding-right', euiTheme.size.xs), "&:only-child{", (0, _global_styling.logicalCSS)('margin-left', 'auto'), ";};label:euiDataGrid__rightControls;"),
22
- euiDataGrid__leftControls: /*#__PURE__*/(0, _react.css)("display:flex;flex-wrap:wrap;gap:", euiTheme.size.xxs, ";;label:euiDataGrid__leftControls;")
21
+ euiDataGrid__rightControls: /*#__PURE__*/(0, _react.css)("display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;column-gap:", euiTheme.size.s, ";", (0, _global_styling.logicalCSS)('padding-right', euiTheme.size.xs), "&:only-child{", (0, _global_styling.logicalCSS)('margin-left', 'auto'), ";};label:euiDataGrid__rightControls;"),
22
+ euiDataGrid__leftControls: /*#__PURE__*/(0, _react.css)("display:flex;flex-wrap:wrap;align-items:center;gap:", euiTheme.size.xxs, ";;label:euiDataGrid__leftControls;")
23
23
  };
24
24
  };