@elastic/eui 93.2.0 → 93.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 (189) hide show
  1. package/dist/eui_theme_dark.css +3 -0
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +3 -0
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/breadcrumbs/breadcrumb.js +9 -6
  6. package/es/components/breadcrumbs/breadcrumbs.js +4 -2
  7. package/es/components/button/button_display/_button_display.js +2 -3
  8. package/es/components/button/button_empty/button_empty.js +2 -3
  9. package/es/components/button/button_group/button_group.js +3 -5
  10. package/es/components/button/button_group/button_group.styles.js +10 -13
  11. package/es/components/button/button_icon/button_icon.js +4 -5
  12. package/es/components/button/button_icon/button_icon.styles.js +11 -3
  13. package/es/components/datagrid/body/cell/data_grid_cell.js +7 -3
  14. package/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  15. package/es/components/datagrid/body/data_grid_body.js +1 -0
  16. package/es/components/datagrid/body/data_grid_body_custom.js +3 -0
  17. package/es/components/datagrid/body/data_grid_body_virtualized.js +3 -0
  18. package/es/components/datagrid/body/data_grid_row_manager.js +1 -1
  19. package/es/components/datagrid/data_grid.js +3 -1
  20. package/es/components/facet/facet_button.styles.js +1 -2
  21. package/es/components/header/header_breadcrumbs/header_breadcrumbs.js +4 -2
  22. package/es/components/icon/icon.js +13 -16
  23. package/es/components/icon/icon.styles.js +6 -9
  24. package/es/components/link/external_link_icon.js +11 -8
  25. package/es/components/link/link.js +2 -3
  26. package/es/components/link/link.styles.js +4 -10
  27. package/es/components/page/page_header/page_header_content.js +4 -2
  28. package/es/components/progress/progress.styles.js +2 -2
  29. package/es/components/skeleton/skeleton_circle.js +2 -3
  30. package/es/components/skeleton/skeleton_rectangle.js +2 -3
  31. package/es/components/skeleton/skeleton_text.js +16 -12
  32. package/es/components/skeleton/skeleton_title.js +2 -3
  33. package/es/components/text/text.js +2 -3
  34. package/es/components/text/text_align.js +1 -2
  35. package/es/components/text/text_align.styles.js +5 -7
  36. package/es/components/text/text_color.js +2 -3
  37. package/es/components/title/title.js +2 -3
  38. package/es/components/title/title.styles.js +0 -7
  39. package/es/global_styling/mixins/_typography.js +17 -6
  40. package/es/services/theme/index.js +1 -1
  41. package/es/services/theme/style_memoization.js +47 -14
  42. package/es/themes/amsterdam/global_styling/mixins/button.js +47 -24
  43. package/eui.d.ts +46 -37
  44. package/i18ntokens.json +36 -36
  45. package/lib/components/breadcrumbs/breadcrumb.js +9 -6
  46. package/lib/components/breadcrumbs/breadcrumbs.js +4 -2
  47. package/lib/components/button/button_display/_button_display.js +1 -2
  48. package/lib/components/button/button_empty/button_empty.js +1 -2
  49. package/lib/components/button/button_group/button_group.js +2 -4
  50. package/lib/components/button/button_group/button_group.styles.js +10 -13
  51. package/lib/components/button/button_icon/button_icon.js +3 -4
  52. package/lib/components/button/button_icon/button_icon.styles.js +10 -2
  53. package/lib/components/datagrid/body/cell/data_grid_cell.js +7 -3
  54. package/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  55. package/lib/components/datagrid/body/data_grid_body.js +1 -0
  56. package/lib/components/datagrid/body/data_grid_body_custom.js +3 -0
  57. package/lib/components/datagrid/body/data_grid_body_virtualized.js +3 -0
  58. package/lib/components/datagrid/body/data_grid_row_manager.js +1 -1
  59. package/lib/components/datagrid/data_grid.js +3 -1
  60. package/lib/components/facet/facet_button.styles.js +1 -2
  61. package/lib/components/header/header_breadcrumbs/header_breadcrumbs.js +4 -2
  62. package/lib/components/icon/icon.js +12 -15
  63. package/lib/components/icon/icon.styles.js +5 -8
  64. package/lib/components/link/external_link_icon.js +10 -7
  65. package/lib/components/link/link.js +1 -2
  66. package/lib/components/link/link.styles.js +6 -14
  67. package/lib/components/page/page_header/page_header_content.js +4 -2
  68. package/lib/components/progress/progress.styles.js +1 -1
  69. package/lib/components/skeleton/skeleton_circle.js +1 -2
  70. package/lib/components/skeleton/skeleton_rectangle.js +1 -2
  71. package/lib/components/skeleton/skeleton_text.js +18 -11
  72. package/lib/components/skeleton/skeleton_title.js +1 -2
  73. package/lib/components/text/text.js +1 -2
  74. package/lib/components/text/text_align.js +1 -2
  75. package/lib/components/text/text_align.styles.js +5 -7
  76. package/lib/components/text/text_color.js +1 -2
  77. package/lib/components/title/title.js +1 -2
  78. package/lib/components/title/title.styles.js +2 -10
  79. package/lib/global_styling/mixins/_typography.js +27 -19
  80. package/lib/services/theme/index.js +6 -0
  81. package/lib/services/theme/style_memoization.js +49 -16
  82. package/lib/themes/amsterdam/global_styling/mixins/button.js +49 -25
  83. package/optimize/es/components/breadcrumbs/breadcrumb.js +5 -4
  84. package/optimize/es/components/button/button_display/_button_display.js +2 -3
  85. package/optimize/es/components/button/button_empty/button_empty.js +2 -3
  86. package/optimize/es/components/button/button_group/button_group.js +3 -5
  87. package/optimize/es/components/button/button_group/button_group.styles.js +10 -13
  88. package/optimize/es/components/button/button_icon/button_icon.js +4 -5
  89. package/optimize/es/components/button/button_icon/button_icon.styles.js +8 -3
  90. package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +5 -3
  91. package/optimize/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  92. package/optimize/es/components/datagrid/body/data_grid_body_custom.js +2 -0
  93. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +2 -0
  94. package/optimize/es/components/datagrid/body/data_grid_row_manager.js +1 -1
  95. package/optimize/es/components/datagrid/data_grid.js +3 -1
  96. package/optimize/es/components/facet/facet_button.styles.js +1 -2
  97. package/optimize/es/components/icon/icon.js +13 -16
  98. package/optimize/es/components/icon/icon.styles.js +6 -9
  99. package/optimize/es/components/link/external_link_icon.js +11 -8
  100. package/optimize/es/components/link/link.js +2 -3
  101. package/optimize/es/components/link/link.styles.js +4 -10
  102. package/optimize/es/components/progress/progress.styles.js +2 -2
  103. package/optimize/es/components/skeleton/skeleton_circle.js +2 -3
  104. package/optimize/es/components/skeleton/skeleton_rectangle.js +2 -3
  105. package/optimize/es/components/skeleton/skeleton_text.js +16 -12
  106. package/optimize/es/components/skeleton/skeleton_title.js +2 -3
  107. package/optimize/es/components/text/text.js +2 -3
  108. package/optimize/es/components/text/text_align.js +1 -2
  109. package/optimize/es/components/text/text_align.styles.js +5 -7
  110. package/optimize/es/components/text/text_color.js +2 -3
  111. package/optimize/es/components/title/title.js +2 -3
  112. package/optimize/es/components/title/title.styles.js +0 -7
  113. package/optimize/es/global_styling/mixins/_typography.js +14 -6
  114. package/optimize/es/services/theme/index.js +1 -1
  115. package/optimize/es/services/theme/style_memoization.js +47 -14
  116. package/optimize/es/themes/amsterdam/global_styling/mixins/button.js +47 -24
  117. package/optimize/lib/components/breadcrumbs/breadcrumb.js +5 -4
  118. package/optimize/lib/components/button/button_display/_button_display.js +1 -2
  119. package/optimize/lib/components/button/button_empty/button_empty.js +1 -2
  120. package/optimize/lib/components/button/button_group/button_group.js +2 -4
  121. package/optimize/lib/components/button/button_group/button_group.styles.js +10 -13
  122. package/optimize/lib/components/button/button_icon/button_icon.js +3 -4
  123. package/optimize/lib/components/button/button_icon/button_icon.styles.js +8 -2
  124. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +5 -3
  125. package/optimize/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  126. package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +2 -0
  127. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +2 -0
  128. package/optimize/lib/components/datagrid/body/data_grid_row_manager.js +1 -1
  129. package/optimize/lib/components/datagrid/data_grid.js +3 -1
  130. package/optimize/lib/components/facet/facet_button.styles.js +1 -2
  131. package/optimize/lib/components/icon/icon.js +12 -15
  132. package/optimize/lib/components/icon/icon.styles.js +5 -8
  133. package/optimize/lib/components/link/external_link_icon.js +10 -7
  134. package/optimize/lib/components/link/link.js +1 -2
  135. package/optimize/lib/components/link/link.styles.js +6 -14
  136. package/optimize/lib/components/progress/progress.styles.js +1 -1
  137. package/optimize/lib/components/skeleton/skeleton_circle.js +1 -2
  138. package/optimize/lib/components/skeleton/skeleton_rectangle.js +1 -2
  139. package/optimize/lib/components/skeleton/skeleton_text.js +18 -11
  140. package/optimize/lib/components/skeleton/skeleton_title.js +1 -2
  141. package/optimize/lib/components/text/text.js +1 -2
  142. package/optimize/lib/components/text/text_align.js +1 -2
  143. package/optimize/lib/components/text/text_align.styles.js +5 -7
  144. package/optimize/lib/components/text/text_color.js +1 -2
  145. package/optimize/lib/components/title/title.js +1 -2
  146. package/optimize/lib/components/title/title.styles.js +2 -10
  147. package/optimize/lib/global_styling/mixins/_typography.js +25 -19
  148. package/optimize/lib/services/theme/index.js +6 -0
  149. package/optimize/lib/services/theme/style_memoization.js +49 -16
  150. package/optimize/lib/themes/amsterdam/global_styling/mixins/button.js +49 -26
  151. package/package.json +3 -3
  152. package/src/components/datagrid/_data_grid_data_row.scss +4 -0
  153. package/test-env/components/breadcrumbs/breadcrumb.js +9 -6
  154. package/test-env/components/breadcrumbs/breadcrumbs.js +4 -2
  155. package/test-env/components/button/button_display/_button_display.js +1 -2
  156. package/test-env/components/button/button_empty/button_empty.js +1 -2
  157. package/test-env/components/button/button_group/button_group.js +2 -4
  158. package/test-env/components/button/button_group/button_group.styles.js +10 -13
  159. package/test-env/components/button/button_icon/button_icon.js +3 -4
  160. package/test-env/components/button/button_icon/button_icon.styles.js +8 -2
  161. package/test-env/components/datagrid/body/cell/data_grid_cell.js +7 -3
  162. package/test-env/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  163. package/test-env/components/datagrid/body/data_grid_body.js +1 -0
  164. package/test-env/components/datagrid/body/data_grid_body_custom.js +3 -0
  165. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +3 -0
  166. package/test-env/components/datagrid/body/data_grid_row_manager.js +1 -1
  167. package/test-env/components/datagrid/data_grid.js +3 -1
  168. package/test-env/components/facet/facet_button.styles.js +1 -2
  169. package/test-env/components/header/header_breadcrumbs/header_breadcrumbs.js +4 -2
  170. package/test-env/components/icon/icon.styles.js +5 -8
  171. package/test-env/components/link/external_link_icon.js +10 -7
  172. package/test-env/components/link/link.js +1 -2
  173. package/test-env/components/link/link.styles.js +6 -14
  174. package/test-env/components/page/page_header/page_header_content.js +4 -2
  175. package/test-env/components/progress/progress.styles.js +1 -1
  176. package/test-env/components/skeleton/skeleton_circle.js +1 -2
  177. package/test-env/components/skeleton/skeleton_rectangle.js +1 -2
  178. package/test-env/components/skeleton/skeleton_text.js +18 -11
  179. package/test-env/components/skeleton/skeleton_title.js +1 -2
  180. package/test-env/components/text/text.js +1 -2
  181. package/test-env/components/text/text_align.js +1 -2
  182. package/test-env/components/text/text_align.styles.js +5 -7
  183. package/test-env/components/text/text_color.js +1 -2
  184. package/test-env/components/title/title.js +1 -2
  185. package/test-env/components/title/title.styles.js +2 -10
  186. package/test-env/global_styling/mixins/_typography.js +25 -19
  187. package/test-env/services/theme/index.js +6 -0
  188. package/test-env/services/theme/style_memoization.js +49 -16
  189. package/test-env/themes/amsterdam/global_styling/mixins/button.js +49 -26
@@ -78,7 +78,7 @@ export var useRowManager = function useRowManager(_ref) {
78
78
  if (rowClasses) {
79
79
  rowIdToElements.current.forEach(function (rowElement, rowIndex) {
80
80
  var euiClasses = Array.from(rowElement.classList).filter(function (className) {
81
- return className.startsWith('euiDataGridRow');
81
+ return ['euiDataGridRow', 'euiDataGridRow--striped'].includes(className);
82
82
  }).join(' ');
83
83
  if (rowClasses[rowIndex]) {
84
84
  rowElement.classList.value = "".concat(euiClasses, " ").concat(rowClasses[rowIndex]);
@@ -3,7 +3,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
6
- var _excluded = ["leadingControlColumns", "trailingControlColumns", "columns", "columnVisibility", "schemaDetectors", "rowCount", "renderCellValue", "renderCellPopover", "renderFooterCellValue", "className", "gridStyle", "toolbarVisibility", "pagination", "sorting", "inMemory", "onColumnResize", "minSizeForControls", "height", "width", "rowHeightsOptions", "virtualizationOptions", "renderCustomGridBody", "renderCustomToolbar"],
6
+ var _excluded = ["leadingControlColumns", "trailingControlColumns", "columns", "columnVisibility", "schemaDetectors", "rowCount", "renderCellValue", "cellContext", "renderCellPopover", "renderFooterCellValue", "className", "gridStyle", "toolbarVisibility", "pagination", "sorting", "inMemory", "onColumnResize", "minSizeForControls", "height", "width", "rowHeightsOptions", "virtualizationOptions", "renderCustomGridBody", "renderCustomToolbar"],
7
7
  _excluded2 = ["focusProps"];
8
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -76,6 +76,7 @@ export var EuiDataGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (pr
76
76
  schemaDetectors = props.schemaDetectors,
77
77
  rowCount = props.rowCount,
78
78
  renderCellValue = props.renderCellValue,
79
+ cellContext = props.cellContext,
79
80
  renderCellPopover = props.renderCellPopover,
80
81
  renderFooterCellValue = props.renderFooterCellValue,
81
82
  className = props.className,
@@ -345,6 +346,7 @@ export var EuiDataGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (pr
345
346
  schemaDetectors: allSchemaDetectors,
346
347
  pagination: pagination,
347
348
  renderCellValue: renderCellValue,
349
+ cellContext: cellContext,
348
350
  renderCellPopover: renderCellPopover,
349
351
  renderFooterCellValue: renderFooterCellValue,
350
352
  rowCount: rowCount,
@@ -9,12 +9,11 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
9
9
 
10
10
  import { css } from '@emotion/react';
11
11
  import { euiTextTruncate, euiTextShift, logicalTextAlignCSS } from '../../global_styling';
12
- import { euiLinkFocusCSS } from '../link/link.styles';
13
12
  export var euiFacetButtonStyles = function euiFacetButtonStyles(_ref3) {
14
13
  var euiTheme = _ref3.euiTheme;
15
14
  return {
16
15
  // Base
17
- euiFacetButton: /*#__PURE__*/css(logicalTextAlignCSS('left'), " &:hover,&:focus{&:not(:disabled) [class*='euiFacetButton__text']{text-decoration:underline;}}&:focus:not(:disabled) [class*='euiFacetButton__text']{", euiLinkFocusCSS(euiTheme), ";}&:disabled{color:", euiTheme.colors.disabledText, ";pointer-events:none;&:hover,&:focus{text-decoration:none;}};label:euiFacetButton;")
16
+ euiFacetButton: /*#__PURE__*/css(logicalTextAlignCSS('left'), " &:not(:disabled){&:hover,&:focus{text-decoration:none;.euiFacetButton__text{text-decoration:underline;}}&:focus .euiFacetButton__text{text-decoration-thickness:", euiTheme.border.width.thick, ";}}&:disabled{color:", euiTheme.colors.disabledText, ";pointer-events:none;};label:euiFacetButton;")
18
17
  };
19
18
  };
20
19
  export var euiFacetButtonTextStyles = function euiFacetButtonTextStyles(_ref4) {
@@ -7,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
- var _excluded = ["type", "size", "color", "className", "tabIndex", "title", "onIconLoad", "theme", "style"];
10
+ var _excluded = ["type", "size", "color", "className", "tabIndex", "title", "onIconLoad", "style", "stylesMemoizer"];
11
11
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
13
  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); }; }
@@ -26,7 +26,7 @@ import { keysOf } from '../common';
26
26
  import { typeToPathMap } from './icon_map';
27
27
  import { icon as empty } from './assets/empty';
28
28
  import { enqueueStateChange } from '../../services/react';
29
- import { htmlIdGenerator, withEuiTheme } from '../../services';
29
+ import { htmlIdGenerator, withEuiStylesMemoizer } from '../../services';
30
30
  export { COLORS } from './named_colors';
31
31
  import { isNamedColor } from './named_colors';
32
32
  import { euiIconStyles } from './icon.styles';
@@ -178,8 +178,8 @@ export var EuiIconClass = /*#__PURE__*/function (_PureComponent) {
178
178
  tabIndex = _this$props.tabIndex,
179
179
  title = _this$props.title,
180
180
  onIconLoad = _this$props.onIconLoad,
181
- theme = _this$props.theme,
182
181
  style = _this$props.style,
182
+ stylesMemoizer = _this$props.stylesMemoizer,
183
183
  rest = _objectWithoutProperties(_this$props, _excluded);
184
184
  var _this$state = this.state,
185
185
  isLoading = _this$state.isLoading,
@@ -201,7 +201,7 @@ export var EuiIconClass = /*#__PURE__*/function (_PureComponent) {
201
201
  var classes = classNames('euiIcon', className);
202
202
 
203
203
  // Emotion styles
204
- var styles = euiIconStyles(theme);
204
+ var styles = stylesMemoizer(euiIconStyles);
205
205
  var cssStyles = [styles.euiIcon, styles[size], color && isNamedColor(color) && styles[color], isCustomColor && styles.customColor, isElasticLogoOutline && styles.logoElasticOutline, isAppIcon && !appIconHasColor && styles.app, isLoading && styles.isLoading, !isLoading && neededLoading && styles.isLoaded];
206
206
  var icon = this.state.icon || empty;
207
207
  if (typeof icon === 'string') {
@@ -218,33 +218,30 @@ export var EuiIconClass = /*#__PURE__*/function (_PureComponent) {
218
218
 
219
219
  // If it's an empty icon, or if there is no aria-label, aria-labelledby, or title it gets aria-hidden true
220
220
  var isAriaHidden = icon === empty || !(this.props['aria-label'] || this.props['aria-labelledby'] || this.props.title);
221
- var hideIconEmpty = isAriaHidden && {
222
- 'aria-hidden': true
223
- };
224
- var titleId;
225
221
 
226
222
  // If no aria-label or aria-labelledby is provided but there's a title, a titleId is generated
227
223
  // The svg aria-labelledby attribute gets this titleId
228
224
  // The svg title element gets this titleId as an id
229
- if (!this.props['aria-label'] && !this.props['aria-labelledby'] && title) {
230
- titleId = {
231
- titleId: generateId()
232
- };
233
- }
225
+ var titleId = !this.props['aria-label'] && !this.props['aria-labelledby'] && title ? {
226
+ titleId: generateId()
227
+ } : undefined;
234
228
  return ___EmotionJSX(Svg, _extends({
235
229
  className: classes,
236
230
  style: optionalCustomStyles,
237
231
  css: cssStyles,
238
232
  tabIndex: tabIndex,
239
233
  role: "img",
240
- title: title,
234
+ title: title
235
+ }, titleId, {
241
236
  "data-icon-type": iconTitle,
242
237
  "data-is-loaded": isLoaded || undefined,
243
238
  "data-is-loading": isLoading || undefined
244
- }, titleId, rest, hideIconEmpty));
239
+ }, rest, {
240
+ "aria-hidden": isAriaHidden || undefined
241
+ }));
245
242
  }
246
243
  }
247
244
  }]);
248
245
  return EuiIconClass;
249
246
  }(PureComponent);
250
- export var EuiIcon = withEuiTheme(EuiIconClass);
247
+ export var EuiIcon = withEuiStylesMemoizer(EuiIconClass);
@@ -10,10 +10,7 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
10
10
  */
11
11
 
12
12
  import { css, keyframes } from '@emotion/react';
13
- import { logicalCSS, euiCanAnimate } from '../../global_styling';
14
- var iconSize = function iconSize(size) {
15
- return "\n ".concat(logicalCSS('width', size), ";\n ").concat(logicalCSS('height', size), ";\n ");
16
- };
13
+ import { logicalSizeCSS, euiCanAnimate } from '../../global_styling';
17
14
  export var iconLoadingOpacity = 0.05;
18
15
  var iconLoading = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n opacity: ", ";\n }\n\n 100% {\n opacity: 1;\n }\n"])), iconLoadingOpacity);
19
16
  var _ref = process.env.NODE_ENV === "production" ? {
@@ -52,11 +49,11 @@ export var euiIconStyles = function euiIconStyles(_ref3) {
52
49
  logoElasticOutline: _ref,
53
50
  // Sizes
54
51
  original: /*#__PURE__*/css(";label:original;"),
55
- s: /*#__PURE__*/css(iconSize(euiTheme.size.m), ";label:s;"),
56
- m: /*#__PURE__*/css(iconSize(euiTheme.size.base), ";label:m;"),
57
- l: /*#__PURE__*/css(iconSize(euiTheme.size.l), ";label:l;"),
58
- xl: /*#__PURE__*/css(iconSize(euiTheme.size.xl), ";label:xl;"),
59
- xxl: /*#__PURE__*/css(iconSize(euiTheme.size.xxl), ";label:xxl;"),
52
+ s: /*#__PURE__*/css(logicalSizeCSS(euiTheme.size.m), ";label:s;"),
53
+ m: /*#__PURE__*/css(logicalSizeCSS(euiTheme.size.base), ";label:m;"),
54
+ l: /*#__PURE__*/css(logicalSizeCSS(euiTheme.size.l), ";label:l;"),
55
+ xl: /*#__PURE__*/css(logicalSizeCSS(euiTheme.size.xl), ";label:xl;"),
56
+ xxl: /*#__PURE__*/css(logicalSizeCSS(euiTheme.size.xxl), ";label:xxl;"),
60
57
  // Variants
61
58
  // App icons are two-toned. This provides the base color.
62
59
  app: /*#__PURE__*/css("fill:", euiTheme.colors.text, ";.euiIcon__fillSecondary{fill:", euiTheme.colors.successText, ";};label:app;"),
@@ -10,7 +10,7 @@ var _excluded = ["target", "external"];
10
10
  */
11
11
 
12
12
  import React from 'react';
13
- import { useEuiTheme } from '../../services';
13
+ import { useEuiMemoizedStyles } from '../../services';
14
14
  import { logicalStyle } from '../../global_styling';
15
15
  import { EuiIcon } from '../icon';
16
16
  import { EuiI18n, useEuiI18n } from '../i18n';
@@ -21,16 +21,19 @@ import { EuiScreenReaderOnly } from '../accessibility';
21
21
  * screen readers. Used internally by at EuiLink and EuiListGroupItem
22
22
  */
23
23
  import { jsx as ___EmotionJSX } from "@emotion/react";
24
- export var EuiExternalLinkIcon = function EuiExternalLinkIcon(_ref) {
25
- var target = _ref.target,
26
- external = _ref.external,
27
- rest = _objectWithoutProperties(_ref, _excluded);
28
- var _useEuiTheme = useEuiTheme(),
29
- euiTheme = _useEuiTheme.euiTheme;
24
+ var iconStyle = function iconStyle(_ref) {
25
+ var euiTheme = _ref.euiTheme;
26
+ return logicalStyle('margin-left', euiTheme.size.xs);
27
+ };
28
+ export var EuiExternalLinkIcon = function EuiExternalLinkIcon(_ref2) {
29
+ var target = _ref2.target,
30
+ external = _ref2.external,
31
+ rest = _objectWithoutProperties(_ref2, _excluded);
32
+ var iconCssStyle = useEuiMemoizedStyles(iconStyle);
30
33
  var showExternalLinkIcon = target === '_blank' && external !== false || external === true;
31
34
  var iconAriaLabel = useEuiI18n('euiExternalLinkIcon.ariaLabel', 'External link');
32
35
  return ___EmotionJSX(React.Fragment, null, showExternalLinkIcon && ___EmotionJSX(EuiIcon, _extends({
33
- css: logicalStyle('margin-left', euiTheme.size.xs),
36
+ css: iconCssStyle,
34
37
  "aria-label": iconAriaLabel,
35
38
  size: "s",
36
39
  type: "popout"
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14
14
 
15
15
  import React, { forwardRef } from 'react';
16
16
  import classNames from 'classnames';
17
- import { getSecureRelForTarget, useEuiTheme } from '../../services';
17
+ import { getSecureRelForTarget, useEuiMemoizedStyles } from '../../services';
18
18
  import { validateHref } from '../../services/security/href_validator';
19
19
  import { EuiExternalLinkIcon } from './external_link_icon';
20
20
  import { euiLinkStyles } from './link.styles';
@@ -34,8 +34,7 @@ var EuiLink = /*#__PURE__*/forwardRef(function (_ref, ref) {
34
34
  onClick = _ref.onClick,
35
35
  _disabled = _ref.disabled,
36
36
  rest = _objectWithoutProperties(_ref, _excluded);
37
- var euiTheme = useEuiTheme();
38
- var styles = euiLinkStyles(euiTheme);
37
+ var styles = useEuiMemoizedStyles(euiLinkStyles);
39
38
  var cssStyles = [styles.euiLink];
40
39
  var isHrefValid = !href || validateHref(href);
41
40
  var disabled = _disabled || !isHrefValid;
@@ -9,18 +9,9 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
9
9
 
10
10
  import { css } from '@emotion/react';
11
11
  import { euiFocusRing, logicalTextAlignCSS } from '../../global_styling';
12
- var _colorCSS = function _colorCSS(color) {
13
- return "\n color: ".concat(color, ";\n\n &:target {\n color: darken(").concat(color, ", 10%);\n }\n ");
14
- };
15
- export var euiLinkHoverCSS = function euiLinkHoverCSS() {
16
- return "\n text-decoration: underline;\n ";
17
- };
18
- export var euiLinkFocusCSS = function euiLinkFocusCSS(euiTheme) {
19
- return "\n text-decoration: underline;\n text-decoration-thickness: ".concat(euiTheme.border.width.thick, ";\n ");
20
- };
21
12
  export var euiLinkCSS = function euiLinkCSS(euiThemeContext) {
22
13
  var euiTheme = euiThemeContext.euiTheme;
23
- return "\n font-weight: ".concat(euiTheme.font.weight.medium, ";\n ").concat(logicalTextAlignCSS('left'), "\n\n &:hover {\n ").concat(euiLinkHoverCSS(), "\n }\n\n &:focus {\n ").concat(euiFocusRing(euiThemeContext, 'outset'), "\n ").concat(euiLinkFocusCSS(euiTheme), "\n }\n ");
14
+ return "\n font-weight: ".concat(euiTheme.font.weight.medium, ";\n ").concat(logicalTextAlignCSS('left'), "\n\n &:hover {\n text-decoration: underline;\n }\n\n &:focus {\n ").concat(euiFocusRing(euiThemeContext, 'outset'), "\n text-decoration: underline;\n text-decoration-thickness: ").concat(euiTheme.border.width.thick, ";\n }\n ");
24
15
  };
25
16
  var _ref = process.env.NODE_ENV === "production" ? {
26
17
  name: "9njbi5-disabled",
@@ -45,4 +36,7 @@ export var euiLinkStyles = function euiLinkStyles(euiThemeContext) {
45
36
  ghost: /*#__PURE__*/css(_colorCSS(euiTheme.colors.ghost), ";label:ghost;"),
46
37
  text: /*#__PURE__*/css(_colorCSS(euiTheme.colors.text), ";label:text;")
47
38
  };
39
+ };
40
+ var _colorCSS = function _colorCSS(color) {
41
+ return "\n color: ".concat(color, ";\n\n &:target {\n color: darken(").concat(color, ", 10%);\n }\n ");
48
42
  };
@@ -10,7 +10,7 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
10
10
  */
11
11
 
12
12
  import { css, keyframes } from '@emotion/react';
13
- import { logicalCSS, logicalTextAlignCSS, euiCantAnimate, euiFontSize, euiTextTruncate } from '../../global_styling';
13
+ import { logicalCSS, logicalTextAlignCSS, euiCanAnimate, euiCantAnimate, euiFontSize, euiTextTruncate } from '../../global_styling';
14
14
  import { euiPaletteColorBlind, makeHighContrastColor } from '../../services';
15
15
  import { euiText } from '../text/text.styles';
16
16
 
@@ -63,7 +63,7 @@ export var euiProgressStyles = function euiProgressStyles(_ref3, isNative) {
63
63
  // https://css-tricks.com/html5-progress-element/
64
64
  // Good resource if you need to work in here. There's some gotchas with
65
65
  // dealing with cross-browser progress bars.
66
- native: /*#__PURE__*/css("display:block;", logicalCSS('width', '100%'), " appearance:none;border:none;border-radius:", euiTheme.size.s, ";&::-webkit-progress-bar{background-color:", euiTheme.colors.lightShade, ";}", crossBrowserProgressValue('transition: width ${euiTheme.animation.normal} linear;'), ";;label:native;"),
66
+ native: /*#__PURE__*/css("display:block;", logicalCSS('width', '100%'), " appearance:none;border:none;border-radius:", euiTheme.size.s, ";&::-webkit-progress-bar{background-color:", euiTheme.colors.lightShade, ";}", euiCanAnimate, "{/* Note: FF/Mozilla doesn't actually support animating the native progress bar\n @see https://bugzilla.mozilla.org/show_bug.cgi?id=662351 */", crossBrowserProgressValue("transition: width ".concat(euiTheme.animation.normal, " linear")), ";};label:native;"),
67
67
  // An indeterminate bar has an unreliable end time. Because of a Firefox animation issue,
68
68
  // we apply this style to a <div> instead of a <progress> element.
69
69
  // See https://css-tricks.com/html5-progress-element/ for more info.
@@ -11,7 +11,7 @@ var _excluded = ["isLoading", "size", "className", "contentAriaLabel", "announce
11
11
 
12
12
  import React from 'react';
13
13
  import classNames from 'classnames';
14
- import { useEuiTheme } from '../../services';
14
+ import { useEuiMemoizedStyles } from '../../services';
15
15
  import { EuiSkeletonLoading } from './skeleton_loading';
16
16
  import { euiSkeletonCircleStyles } from './skeleton_circle.styles';
17
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -29,8 +29,7 @@ export var EuiSkeletonCircle = function EuiSkeletonCircle(_ref) {
29
29
  ariaWrapperProps = _ref.ariaWrapperProps,
30
30
  children = _ref.children,
31
31
  rest = _objectWithoutProperties(_ref, _excluded);
32
- var euiTheme = useEuiTheme();
33
- var styles = euiSkeletonCircleStyles(euiTheme);
32
+ var styles = useEuiMemoizedStyles(euiSkeletonCircleStyles);
34
33
  var cssStyles = [styles.euiSkeletonCircle, styles[size]];
35
34
  return ___EmotionJSX(EuiSkeletonLoading, _extends({
36
35
  isLoading: isLoading,
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14
14
 
15
15
  import React from 'react';
16
16
  import classNames from 'classnames';
17
- import { useEuiTheme } from '../../services';
17
+ import { useEuiMemoizedStyles } from '../../services';
18
18
  import { logicalStyles } from '../../global_styling';
19
19
  import { EuiSkeletonLoading } from './skeleton_loading';
20
20
  import { euiSkeletonRectangleStyles } from './skeleton_rectangle.styles';
@@ -38,8 +38,7 @@ export var EuiSkeletonRectangle = function EuiSkeletonRectangle(_ref) {
38
38
  ariaWrapperProps = _ref.ariaWrapperProps,
39
39
  children = _ref.children,
40
40
  rest = _objectWithoutProperties(_ref, _excluded);
41
- var euiTheme = useEuiTheme();
42
- var styles = euiSkeletonRectangleStyles(euiTheme);
41
+ var styles = useEuiMemoizedStyles(euiSkeletonRectangleStyles);
43
42
  var cssStyles = [styles.euiSkeletonRectangle, styles[borderRadius]];
44
43
  return ___EmotionJSX(EuiSkeletonLoading, _extends({
45
44
  isLoading: isLoading,
@@ -9,9 +9,9 @@ var _excluded = ["isLoading", "lines", "size", "className", "contentAriaLabel",
9
9
  * Side Public License, v 1.
10
10
  */
11
11
 
12
- import React from 'react';
12
+ import React, { useMemo } from 'react';
13
13
  import classNames from 'classnames';
14
- import { useEuiTheme } from '../../services';
14
+ import { useEuiMemoizedStyles } from '../../services';
15
15
  import { EuiSkeletonLoading } from './skeleton_loading';
16
16
  import { euiSkeletonTextStyles } from './skeleton_text.styles';
17
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -31,16 +31,20 @@ export var EuiSkeletonText = function EuiSkeletonText(_ref) {
31
31
  ariaWrapperProps = _ref.ariaWrapperProps,
32
32
  children = _ref.children,
33
33
  rest = _objectWithoutProperties(_ref, _excluded);
34
- var euiTheme = useEuiTheme();
35
- var styles = euiSkeletonTextStyles(euiTheme);
36
- var lineCssStyles = [styles.euiSkeletonText, styles[size]];
37
- var lineElements = [];
38
- for (var i = 0; i < lines; i++) {
39
- lineElements.push(___EmotionJSX("span", {
40
- key: i,
41
- css: lineCssStyles
42
- }));
43
- }
34
+ var styles = useEuiMemoizedStyles(euiSkeletonTextStyles);
35
+ var cssStyles = useMemo(function () {
36
+ return [styles.euiSkeletonText, styles[size]];
37
+ }, [styles, size]);
38
+ var lineElements = useMemo(function () {
39
+ var lineElements = [];
40
+ for (var i = 0; i < lines; i++) {
41
+ lineElements.push(___EmotionJSX("span", {
42
+ key: i,
43
+ css: cssStyles
44
+ }));
45
+ }
46
+ return lineElements;
47
+ }, [lines, cssStyles]);
44
48
  return ___EmotionJSX(EuiSkeletonLoading, _extends({
45
49
  isLoading: isLoading,
46
50
  loadingContent: ___EmotionJSX("span", _extends({
@@ -11,7 +11,7 @@ var _excluded = ["isLoading", "size", "className", "contentAriaLabel", "announce
11
11
 
12
12
  import React from 'react';
13
13
  import classNames from 'classnames';
14
- import { useEuiTheme } from '../../services';
14
+ import { useEuiMemoizedStyles } from '../../services';
15
15
  import { EuiSkeletonLoading } from './skeleton_loading';
16
16
  import { euiSkeletonTitleStyles } from './skeleton_title.styles';
17
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -28,8 +28,7 @@ export var EuiSkeletonTitle = function EuiSkeletonTitle(_ref) {
28
28
  ariaWrapperProps = _ref.ariaWrapperProps,
29
29
  children = _ref.children,
30
30
  rest = _objectWithoutProperties(_ref, _excluded);
31
- var euiTheme = useEuiTheme();
32
- var styles = euiSkeletonTitleStyles(euiTheme);
31
+ var styles = useEuiMemoizedStyles(euiSkeletonTitleStyles);
33
32
  var cssStyles = [styles.euiSkeletonTitle, styles[size]];
34
33
  return ___EmotionJSX(EuiSkeletonLoading, _extends({
35
34
  isLoading: isLoading,
@@ -11,7 +11,7 @@ var _excluded = ["size", "color", "grow", "textAlign", "children", "className"];
11
11
 
12
12
  import React from 'react';
13
13
  import classNames from 'classnames';
14
- import { useEuiTheme } from '../../services';
14
+ import { useEuiMemoizedStyles } from '../../services';
15
15
  import { euiTextStyles } from './text.styles';
16
16
  import { EuiTextColor } from './text_color';
17
17
  import { EuiTextAlign } from './text_align';
@@ -27,8 +27,7 @@ export var EuiText = function EuiText(_ref) {
27
27
  children = _ref.children,
28
28
  className = _ref.className,
29
29
  rest = _objectWithoutProperties(_ref, _excluded);
30
- var euiTheme = useEuiTheme();
31
- var styles = euiTextStyles(euiTheme);
30
+ var styles = useEuiMemoizedStyles(euiTextStyles);
32
31
  var cssStyles = [styles.euiText, !grow ? styles.constrainedWidth : undefined, styles[size]];
33
32
  var classes = classNames('euiText', className);
34
33
  var text = ___EmotionJSX("div", _extends({
@@ -13,7 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
13
 
14
14
  import React, { isValidElement } from 'react';
15
15
  import { cloneElementWithCss } from '../../services';
16
- import { euiTextAlignStyles } from './text_align.styles';
16
+ import { euiTextAlignStyles as styles } from './text_align.styles';
17
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
18
18
  export var ALIGNMENTS = ['left', 'right', 'center'];
19
19
  export var EuiTextAlign = function EuiTextAlign(_ref) {
@@ -23,7 +23,6 @@ export var EuiTextAlign = function EuiTextAlign(_ref) {
23
23
  _ref$cloneElement = _ref.cloneElement,
24
24
  cloneElement = _ref$cloneElement === void 0 ? false : _ref$cloneElement,
25
25
  rest = _objectWithoutProperties(_ref, _excluded);
26
- var styles = euiTextAlignStyles();
27
26
  var cssStyles = [styles.euiTextAlign, styles[textAlign]];
28
27
  var props = _objectSpread({
29
28
  css: cssStyles
@@ -8,11 +8,9 @@
8
8
 
9
9
  import { css } from '@emotion/react';
10
10
  import { logicalTextAlignCSS } from '../../global_styling';
11
- export var euiTextAlignStyles = function euiTextAlignStyles() {
12
- return {
13
- euiTextAlign: /*#__PURE__*/css(";label:euiTextAlign;"),
14
- left: /*#__PURE__*/css(logicalTextAlignCSS('left'), ";;label:left;"),
15
- right: /*#__PURE__*/css(logicalTextAlignCSS('right'), ";;label:right;"),
16
- center: /*#__PURE__*/css(logicalTextAlignCSS('center'), ";;label:center;")
17
- };
11
+ export var euiTextAlignStyles = {
12
+ euiTextAlign: /*#__PURE__*/css(";label:euiTextAlign;"),
13
+ left: /*#__PURE__*/css(logicalTextAlignCSS('left'), ";;label:left;"),
14
+ right: /*#__PURE__*/css(logicalTextAlignCSS('right'), ";;label:right;"),
15
+ center: /*#__PURE__*/css(logicalTextAlignCSS('center'), ";;label:center;")
18
16
  };
@@ -12,7 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
  */
13
13
 
14
14
  import React, { isValidElement } from 'react';
15
- import { useEuiTheme, cloneElementWithCss } from '../../services';
15
+ import { useEuiMemoizedStyles, cloneElementWithCss } from '../../services';
16
16
  import { euiTextColorStyles } from './text_color.styles';
17
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
18
18
  export var COLORS = ['default', 'subdued', 'success', 'accent', 'danger', 'warning', 'ghost', 'inherit'];
@@ -27,8 +27,7 @@ export var EuiTextColor = function EuiTextColor(_ref) {
27
27
  style = _ref.style,
28
28
  rest = _objectWithoutProperties(_ref, _excluded);
29
29
  var isNamedColor = COLORS.includes(color);
30
- var euiTheme = useEuiTheme();
31
- var styles = euiTextColorStyles(euiTheme);
30
+ var styles = useEuiMemoizedStyles(euiTextColorStyles);
32
31
  var cssStyles = [styles.euiTextColor, isNamedColor ? styles[color] : styles.customColor];
33
32
 
34
33
  // We're checking if is a custom color.
@@ -12,7 +12,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
  */
13
13
 
14
14
  import classNames from 'classnames';
15
- import { useEuiTheme, cloneElementWithCss } from '../../services';
15
+ import { useEuiMemoizedStyles, cloneElementWithCss } from '../../services';
16
16
  import { euiTitleStyles } from './title.styles';
17
17
  export var TITLE_SIZES = ['xxxs', 'xxs', 'xs', 's', 'm', 'l'];
18
18
  export var TEXT_TRANSFORM = ['uppercase'];
@@ -23,8 +23,7 @@ export var EuiTitle = function EuiTitle(_ref) {
23
23
  className = _ref.className,
24
24
  textTransform = _ref.textTransform,
25
25
  rest = _objectWithoutProperties(_ref, _excluded);
26
- var euiTheme = useEuiTheme();
27
- var styles = euiTitleStyles(euiTheme);
26
+ var styles = useEuiMemoizedStyles(euiTitleStyles);
28
27
  var cssStyles = [styles.euiTitle, textTransform ? styles[textTransform] : undefined, styles[size]];
29
28
  var classes = classNames('euiTitle', className, children.props.className);
30
29
  var props = _objectSpread({
@@ -11,7 +11,6 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
11
11
  */
12
12
 
13
13
  import { css } from '@emotion/react';
14
- import { useEuiTheme } from '../../services';
15
14
  import { euiTextBreakWord, euiFontSize, logicalCSS } from '../../global_styling';
16
15
 
17
16
  /**
@@ -36,12 +35,6 @@ export var euiTitle = function euiTitle(euiThemeContext) {
36
35
  });
37
36
  };
38
37
 
39
- // Hook version
40
- export var useEuiTitle = function useEuiTitle(scale, options) {
41
- var euiTheme = useEuiTheme();
42
- return euiTitle(euiTheme, scale, options);
43
- };
44
-
45
38
  /**
46
39
  * Styles
47
40
  */
@@ -1,3 +1,6 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
4
  /*
2
5
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
6
  * or more contributor license agreements. Licensed under the Elastic License
@@ -7,7 +10,8 @@
7
10
  */
8
11
 
9
12
  import { euiLineHeightFromBaseline, euiFontSizeFromScale } from '../functions/typography';
10
- import { useEuiTheme } from '../../services/theme/hooks';
13
+ import { useEuiMemoizedStyles, useEuiTheme } from '../../services/theme';
14
+ import { EuiThemeFontScales } from '../variables/typography';
11
15
  import { logicalCSS } from '../functions';
12
16
  /**
13
17
  * Returns font-size and line-height
@@ -21,7 +25,15 @@ export var euiFontSize = function euiFontSize(_ref, scale, options) {
21
25
  };
22
26
  export var useEuiFontSize = function useEuiFontSize(scale, options) {
23
27
  var euiTheme = useEuiTheme();
24
- return euiFontSize(euiTheme, scale, options);
28
+ var memoizedFontSizes = useEuiMemoizedStyles(euiFontSizes);
29
+ return !options ? memoizedFontSizes[scale] : euiFontSize(euiTheme, scale, options);
30
+ };
31
+ // Memomize a basic set of font sizes. We unfortunately can't
32
+ // memoize all possible options, there's too many permutations
33
+ var euiFontSizes = function euiFontSizes(euiThemeContext) {
34
+ return EuiThemeFontScales.reduce(function (map, scale) {
35
+ return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, scale, euiFontSize(euiThemeContext, scale)));
36
+ }, {});
25
37
  };
26
38
 
27
39
  /**
@@ -47,8 +59,4 @@ export var euiTextTruncate = function euiTextTruncate() {
47
59
  export var euiNumberFormat = function euiNumberFormat(_ref2) {
48
60
  var euiTheme = _ref2.euiTheme;
49
61
  return "\n font-feature-settings: ".concat(euiTheme.font.featureSettings, ", 'tnum' 1;\n");
50
- };
51
- export var useEuiNumberFormat = function useEuiNumberFormat() {
52
- var euiTheme = useEuiTheme();
53
- return euiNumberFormat(euiTheme);
54
62
  };
@@ -9,7 +9,7 @@
9
9
  export { EuiSystemContext, EuiThemeContext, EuiNestedThemeContext, EuiModificationsContext, EuiColorModeContext } from './context';
10
10
  export { useEuiTheme, withEuiTheme, RenderWithEuiTheme, useEuiThemeCSSVariables } from './hooks';
11
11
  export { EuiThemeProvider } from './provider';
12
- export { useEuiMemoizedStyles } from './style_memoization';
12
+ export { useEuiMemoizedStyles, withEuiStylesMemoizer } from './style_memoization';
13
13
  export { getEuiDevProviderWarning, setEuiDevProviderWarning } from './warning';
14
14
  export { buildTheme, computed, isInverseColorMode, getColorMode, getComputed, getOn, mergeDeep, setOn, Computed } from './utils';
15
15
  export { COLOR_MODES_STANDARD } from './types';
@@ -1,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  /*
3
4
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -7,7 +8,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
7
8
  * Side Public License, v 1.
8
9
  */
9
10
 
10
- import React, { createContext, useContext, useState, useMemo } from 'react';
11
+ import React, { createContext, useContext, useState, useMemo, useCallback, forwardRef } from 'react';
11
12
  import { useUpdateEffect } from '../hooks';
12
13
  import { useEuiTheme } from './hooks';
13
14
 
@@ -36,25 +37,57 @@ export var EuiThemeMemoizedStylesProvider = function EuiThemeMemoizedStylesProvi
36
37
  }, children);
37
38
  };
38
39
 
40
+ /**
41
+ * Internal util primarily responsible for getting the memoized styles (if they exist)
42
+ * and if not, generating and setting the styles. DRYed out to facilitate usage
43
+ * between both hook/function components and HOC/class components
44
+ */
45
+ var getMemoizedStyles = function getMemoizedStyles(stylesGenerator, stylesMap, euiThemeContext) {
46
+ if (!stylesGenerator.name) {
47
+ throw new Error('Styles are memoized per function. Your style functions must be statically defined in order to not create a new map entry every rerender.');
48
+ }
49
+ var existingStyles = stylesMap.get(stylesGenerator);
50
+ if (existingStyles) {
51
+ return existingStyles;
52
+ } else {
53
+ var generatedStyles = stylesGenerator(euiThemeContext);
54
+ stylesMap.set(stylesGenerator, generatedStyles);
55
+ return generatedStyles;
56
+ }
57
+ };
58
+
39
59
  /**
40
60
  * Hook that memoizes the returned values of components style fns/generators
41
61
  * per-theme
42
62
  */
43
- export var useEuiMemoizedStyles = function useEuiMemoizedStyles(styleGenerator) {
63
+ export var useEuiMemoizedStyles = function useEuiMemoizedStyles(stylesGenerator) {
44
64
  var memoizedStyles = useContext(EuiThemeMemoizedStylesContext);
45
65
  var euiThemeContext = useEuiTheme();
46
66
  var memoizedComponentStyles = useMemo(function () {
47
- if (!styleGenerator.name) {
48
- throw new Error('Styles are memoized per function. Your style functions must be statically defined in order to not create a new map entry every rerender.');
49
- }
50
- var existingStyles = memoizedStyles.get(styleGenerator);
51
- if (existingStyles) {
52
- return existingStyles;
53
- } else {
54
- var generatedStyles = styleGenerator(euiThemeContext);
55
- memoizedStyles.set(styleGenerator, generatedStyles);
56
- return generatedStyles;
57
- }
58
- }, [styleGenerator, memoizedStyles, euiThemeContext]);
67
+ return getMemoizedStyles(stylesGenerator, memoizedStyles, euiThemeContext);
68
+ }, [stylesGenerator, memoizedStyles, euiThemeContext]);
59
69
  return memoizedComponentStyles;
70
+ };
71
+
72
+ /**
73
+ * HOC for class components
74
+ * Syntax is mostly copied from withEuiTheme HOC
75
+ */
76
+
77
+ export var withEuiStylesMemoizer = function withEuiStylesMemoizer(Component) {
78
+ var componentName = Component.displayName || Component.name || 'ComponentWithStylesMemoizer';
79
+ var Render = function Render(props, ref) {
80
+ var memoizedStyles = useContext(EuiThemeMemoizedStylesContext);
81
+ var euiThemeContext = useEuiTheme();
82
+ var stylesMemoizer = useCallback(function (stylesGenerator) {
83
+ return getMemoizedStyles(stylesGenerator, memoizedStyles, euiThemeContext);
84
+ }, [memoizedStyles, euiThemeContext]);
85
+ return ___EmotionJSX(Component, _extends({
86
+ stylesMemoizer: stylesMemoizer,
87
+ ref: ref
88
+ }, props));
89
+ };
90
+ var WithEuiStylesMemoizer = /*#__PURE__*/forwardRef(Render);
91
+ WithEuiStylesMemoizer.displayName = componentName;
92
+ return WithEuiStylesMemoizer;
60
93
  };