@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
@@ -67,7 +67,7 @@ var RowHeightUtils = exports.RowHeightUtils = /*#__PURE__*/function () {
67
67
  }
68
68
  }, {
69
69
  key: "getCalculatedHeight",
70
- value: function getCalculatedHeight(heightOption, defaultHeight, rowIndex, isRowHeightOverride) {
70
+ value: function getCalculatedHeight(heightOption, defaultHeight, rowIndex, rowHeightsOptions) {
71
71
  if ((0, _predicate.isObject)(heightOption) && heightOption.height) {
72
72
  return Math.max(heightOption.height, defaultHeight);
73
73
  }
@@ -75,8 +75,13 @@ var RowHeightUtils = exports.RowHeightUtils = /*#__PURE__*/function () {
75
75
  return Math.max(heightOption, defaultHeight);
76
76
  }
77
77
  if ((0, _predicate.isObject)(heightOption) && heightOption.lineCount) {
78
- if (isRowHeightOverride) {
79
- return this.getRowHeight(rowIndex) || defaultHeight; // lineCount overrides are stored in the heights cache
78
+ var _ref = rowHeightsOptions || {},
79
+ autoBelowLineCount = _ref.autoBelowLineCount; // uses auto height cache
80
+ var isRowHeightOverride =
81
+ // lineCount overrides are stored in the heights cache
82
+ rowIndex != null && this.isRowHeightOverride(rowIndex, rowHeightsOptions);
83
+ if (autoBelowLineCount || isRowHeightOverride) {
84
+ return this.getRowHeight(rowIndex) || defaultHeight;
80
85
  } else {
81
86
  return defaultHeight; // default lineCount height is set in minRowHeight state in grid_row_body
82
87
  }
@@ -107,6 +112,14 @@ var RowHeightUtils = exports.RowHeightUtils = /*#__PURE__*/function () {
107
112
  // Assumes both padding-top and bottom are the same
108
113
  return contentHeight + padding * 2;
109
114
  }
115
+ }, {
116
+ key: "isAutoBelowLineCount",
117
+ value: function isAutoBelowLineCount(options, option) {
118
+ var _this$getLineCount;
119
+ if (!(options !== null && options !== void 0 && options.autoBelowLineCount)) return false;
120
+ if (((_this$getLineCount = this.getLineCount(option)) !== null && _this$getLineCount !== void 0 ? _this$getLineCount : 0) > 1) return true;
121
+ return false;
122
+ }
110
123
 
111
124
  /**
112
125
  * Auto height utils
@@ -118,6 +131,9 @@ var RowHeightUtils = exports.RowHeightUtils = /*#__PURE__*/function () {
118
131
  if (height === AUTO_HEIGHT) {
119
132
  return true;
120
133
  }
134
+ if (this.isAutoBelowLineCount(rowHeightsOptions, height)) {
135
+ return true;
136
+ }
121
137
  return false;
122
138
  }
123
139
  }, {
@@ -147,8 +163,8 @@ var RowHeightUtils = exports.RowHeightUtils = /*#__PURE__*/function () {
147
163
  }, {
148
164
  key: "pruneHiddenColumnHeights",
149
165
  value: function pruneHiddenColumnHeights(visibleColumns) {
150
- var visibleColumnIds = new Set(visibleColumns.map(function (_ref) {
151
- var id = _ref.id;
166
+ var visibleColumnIds = new Set(visibleColumns.map(function (_ref2) {
167
+ var id = _ref2.id;
152
168
  return id;
153
169
  }));
154
170
  var didModify = false;
@@ -258,10 +274,10 @@ var RowHeightVirtualizationUtils = exports.RowHeightVirtualizationUtils = /*#__P
258
274
  * Hook for instantiating RowHeightUtils, setting internal class vars,
259
275
  * and setting up various row-height-related side effects
260
276
  */
261
- var useRowHeightUtils = exports.useRowHeightUtils = function useRowHeightUtils(_ref2) {
262
- var virtualization = _ref2.virtualization,
263
- rowHeightsOptions = _ref2.rowHeightsOptions,
264
- columns = _ref2.columns;
277
+ var useRowHeightUtils = exports.useRowHeightUtils = function useRowHeightUtils(_ref3) {
278
+ var virtualization = _ref3.virtualization,
279
+ rowHeightsOptions = _ref3.rowHeightsOptions,
280
+ columns = _ref3.columns;
265
281
  var forceRenderRef = (0, _services.useLatest)((0, _services.useForceRender)());
266
282
  var _useState = (0, _react.useState)(function () {
267
283
  if (virtualization) {
@@ -294,9 +310,9 @@ var useRowHeightUtils = exports.useRowHeightUtils = function useRowHeightUtils(_
294
310
  }, [rowHeightUtils, columns]);
295
311
  return rowHeightUtils;
296
312
  };
297
- var useDefaultRowHeight = exports.useDefaultRowHeight = function useDefaultRowHeight(_ref3) {
298
- var rowHeightsOptions = _ref3.rowHeightsOptions,
299
- rowHeightUtils = _ref3.rowHeightUtils;
313
+ var useDefaultRowHeight = exports.useDefaultRowHeight = function useDefaultRowHeight(_ref4) {
314
+ var rowHeightsOptions = _ref4.rowHeightsOptions,
315
+ rowHeightUtils = _ref4.rowHeightUtils;
300
316
  var _useContext = (0, _react.useContext)(_sorting.DataGridSortedContext),
301
317
  getCorrectRowIndex = _useContext.getCorrectRowIndex;
302
318
 
@@ -320,7 +336,7 @@ var useDefaultRowHeight = exports.useDefaultRowHeight = function useDefaultRowHe
320
336
  // Account for row-specific height overrides
321
337
  var rowHeightOption = rowHeightUtils.getRowHeightOption(correctRowIndex, rowHeightsOptions);
322
338
  if (rowHeightOption) {
323
- rowHeight = rowHeightUtils.getCalculatedHeight(rowHeightOption, minRowHeight, correctRowIndex, rowHeightUtils.isRowHeightOverride(correctRowIndex, rowHeightsOptions));
339
+ rowHeight = rowHeightUtils.getCalculatedHeight(rowHeightOption, minRowHeight, correctRowIndex, rowHeightsOptions);
324
340
  }
325
341
 
326
342
  // Use the row-specific height if it exists, if not, fall back to the default
@@ -57,5 +57,12 @@ var euiHeaderDarkStyles = function euiHeaderDarkStyles(euiThemeContext) {
57
57
  var _euiFormVariables = (0, _form.euiFormVariables)(euiThemeContext),
58
58
  controlPlaceholderText = _euiFormVariables.controlPlaceholderText;
59
59
  var backgroundColor = colorMode === 'DARK' ? (0, _services.shade)(euiTheme.colors.lightestShade, 0.5) : (0, _services.shade)(euiTheme.colors.darkestShade, 0.28);
60
- return "\n background-color: ".concat(backgroundColor, ";\n\n .euiHeaderLogo__text,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n color: ").concat(euiTheme.colors.ghost, ";\n }\n\n .euiHeaderLink-isActive {\n color: ").concat((0, _services.makeHighContrastColor)(euiTheme.colors.primary)(backgroundColor), ";\n }\n\n .euiHeaderLogo,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n &:focus {\n background-color: ").concat((0, _services.shade)(euiTheme.colors.primary, 0.5), ";\n }\n }\n\n .euiHeaderSectionItemButton__notification--badge {\n box-shadow: 0 0 0 ").concat(euiTheme.border.width.thin, " ").concat(backgroundColor, ";\n }\n\n .euiHeaderSectionItemButton__notification--dot {\n stroke: ").concat(backgroundColor, ";\n }\n\n .euiSelectableTemplateSitewide .euiFormControlLayout {\n background-color: transparent;\n\n &--group {\n border-color: ").concat((0, _services.transparentize)(euiTheme.colors.ghost, 0.3), ";\n }\n\n &:not(:focus-within) {\n /* Increase contrast of filled text to be more than placeholder text */\n color: ").concat(euiTheme.colors.ghost, ";\n\n input {\n /* Increase contrast of placeholder text */\n &::placeholder {\n color: ").concat((0, _services.makeHighContrastColor)(controlPlaceholderText, 8)(backgroundColor), ";\n }\n\n /* Inherit color from form control layout */\n color: inherit;\n background-color: transparent;\n }\n\n .euiFormControlLayout__append,\n .euiFormControlLayout__prepend {\n background-color: transparent;\n }\n\n .euiFormLabel {\n color: inherit;\n }\n }\n }\n ");
60
+
61
+ // Specific color overrides for EuiSelectableTemplateSitewide
62
+ var selectableSitewide = {
63
+ color: euiTheme.colors.ghost,
64
+ borderColor: (0, _services.transparentize)(euiTheme.colors.ghost, 0.3),
65
+ placeholderColor: (0, _services.makeHighContrastColor)(controlPlaceholderText, 8)(backgroundColor)
66
+ };
67
+ return "\n background-color: ".concat(backgroundColor, ";\n\n .euiHeaderLogo__text,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n color: ").concat(euiTheme.colors.ghost, ";\n }\n\n .euiHeaderLink-isActive {\n color: ").concat((0, _services.makeHighContrastColor)(euiTheme.colors.primary)(backgroundColor), ";\n }\n\n .euiHeaderLogo,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n &:focus {\n background-color: ").concat((0, _services.shade)(euiTheme.colors.primary, 0.5), ";\n }\n }\n\n .euiHeaderSectionItemButton__notification--badge {\n box-shadow: 0 0 0 ").concat(euiTheme.border.width.thin, " ").concat(backgroundColor, ";\n }\n\n .euiHeaderSectionItemButton__notification--dot {\n stroke: ").concat(backgroundColor, ";\n }\n\n .euiSelectableTemplateSitewide .euiFormControlLayout {\n background-color: transparent;\n\n input {\n box-shadow: inset 0 0 0 ").concat(euiTheme.border.width.thin, " ").concat(selectableSitewide.borderColor, ";\n }\n\n &--group {\n border-color: ").concat(selectableSitewide.borderColor, ";\n\n input {\n box-shadow: none;\n }\n }\n\n &:not(:focus-within) {\n /* Increase contrast of filled text to be more than placeholder text */\n color: ").concat(selectableSitewide.color, ";\n\n input {\n /* Increase contrast of placeholder text */\n &::placeholder {\n color: ").concat(selectableSitewide.placeholderColor, ";\n }\n\n /* Inherit color from form control layout */\n color: inherit;\n background-color: transparent;\n }\n\n .euiFormControlLayout__append,\n .euiFormControlLayout__prepend {\n background-color: transparent;\n }\n\n .euiFormLabel {\n color: inherit;\n }\n }\n }\n ");
61
68
  };
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useDeepEqual = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
9
  var _react = require("react");
9
10
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
11
+ var _useUpdateEffect = require("./useUpdateEffect");
10
12
  /*
11
13
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
14
  * or more contributor license agreements. Licensed under the Elastic License
@@ -21,9 +23,14 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
21
23
  * reference on every rerender unless passed through this hook).
22
24
  */
23
25
  var useDeepEqual = exports.useDeepEqual = function useDeepEqual(object) {
24
- var ref = (0, _react.useRef)(object);
25
- if (!(0, _isEqual.default)(object, ref.current)) {
26
- ref.current = object;
27
- }
28
- return ref.current;
26
+ var _useState = (0, _react.useState)(object),
27
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
28
+ memoizedObject = _useState2[0],
29
+ setMemoizedObject = _useState2[1];
30
+ (0, _useUpdateEffect.useUpdateEffect)(function () {
31
+ if (!(0, _isEqual.default)(object, memoizedObject)) {
32
+ setMemoizedObject(object);
33
+ }
34
+ }, [object]);
35
+ return memoizedObject;
29
36
  };