@elastic/eui 102.2.0 → 102.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 (162) hide show
  1. package/dist/eui_theme_borealis_dark.json +1 -1
  2. package/es/components/badge/color_utils.js +1 -3
  3. package/es/components/badge/notification_badge/badge_notification.styles.js +6 -1
  4. package/es/components/basic_table/basic_table.js +4 -1
  5. package/es/components/basic_table/in_memory_table.js +4 -1
  6. package/es/components/breadcrumbs/_breadcrumb_content.styles.js +6 -3
  7. package/es/components/button/button_display/_button_display.js +1 -1
  8. package/es/components/button/button_display/_button_display.styles.js +11 -2
  9. package/es/components/button/button_display/_button_display_content.styles.js +6 -3
  10. package/es/components/button/button_empty/button_empty.styles.js +9 -12
  11. package/es/components/button/button_group/button_group.styles.js +5 -3
  12. package/es/components/button/button_group/button_group_button.js +19 -9
  13. package/es/components/button/button_group/button_group_button.styles.js +43 -19
  14. package/es/components/button/button_icon/button_icon.js +4 -2
  15. package/es/components/collapsible_nav/collapsible_nav.js +1 -0
  16. package/es/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
  17. package/es/components/datagrid/utils/focus.js +2 -2
  18. package/es/components/filter_group/filter_button.js +88 -23
  19. package/es/components/filter_group/filter_button.styles.js +51 -15
  20. package/es/components/filter_group/filter_group.styles.js +18 -6
  21. package/es/components/markdown_editor/markdown_editor_footer.js +9 -4
  22. package/es/components/search_bar/filters/field_value_selection_filter.js +1 -0
  23. package/es/components/search_bar/filters/field_value_toggle_filter.js +3 -1
  24. package/es/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
  25. package/es/components/search_bar/filters/is_filter.js +3 -1
  26. package/es/components/search_bar/search_bar.a11y.js +3 -3
  27. package/es/global_styling/mixins/_button.js +95 -28
  28. package/es/services/theme/index.js +2 -1
  29. package/es/services/theme/provider.js +28 -2
  30. package/es/services/theme/theme_variant.js +22 -0
  31. package/es/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
  32. package/es/themes/amsterdam/global_styling/variables/_components.js +229 -224
  33. package/es/themes/amsterdam/theme.js +2 -1
  34. package/es/themes/json/eui_theme_borealis_dark.json +1 -1
  35. package/eui.d.ts +194 -161
  36. package/lib/components/badge/color_utils.js +1 -3
  37. package/lib/components/badge/notification_badge/badge_notification.styles.js +6 -1
  38. package/lib/components/basic_table/basic_table.js +4 -1
  39. package/lib/components/basic_table/in_memory_table.js +4 -1
  40. package/lib/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
  41. package/lib/components/button/button_display/_button_display.js +1 -1
  42. package/lib/components/button/button_display/_button_display.styles.js +11 -2
  43. package/lib/components/button/button_display/_button_display_content.styles.js +6 -3
  44. package/lib/components/button/button_empty/button_empty.styles.js +10 -11
  45. package/lib/components/button/button_group/button_group.styles.js +5 -3
  46. package/lib/components/button/button_group/button_group_button.js +18 -8
  47. package/lib/components/button/button_group/button_group_button.styles.js +41 -17
  48. package/lib/components/button/button_icon/button_icon.js +3 -1
  49. package/lib/components/collapsible_nav/collapsible_nav.js +1 -0
  50. package/lib/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
  51. package/lib/components/datagrid/utils/focus.js +1 -1
  52. package/lib/components/filter_group/filter_button.js +86 -21
  53. package/lib/components/filter_group/filter_button.styles.js +51 -15
  54. package/lib/components/filter_group/filter_group.styles.js +18 -6
  55. package/lib/components/markdown_editor/markdown_editor_footer.js +8 -3
  56. package/lib/components/search_bar/filters/field_value_selection_filter.js +1 -0
  57. package/lib/components/search_bar/filters/field_value_toggle_filter.js +3 -1
  58. package/lib/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
  59. package/lib/components/search_bar/filters/is_filter.js +3 -1
  60. package/lib/components/search_bar/search_bar.a11y.js +3 -3
  61. package/lib/global_styling/mixins/_button.js +94 -27
  62. package/lib/services/theme/index.js +42 -1
  63. package/lib/services/theme/provider.js +28 -2
  64. package/lib/services/theme/theme_variant.js +28 -0
  65. package/lib/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
  66. package/lib/themes/amsterdam/global_styling/variables/_components.js +229 -224
  67. package/lib/themes/amsterdam/theme.js +2 -1
  68. package/lib/themes/json/eui_theme_borealis_dark.json +1 -1
  69. package/optimize/es/components/badge/color_utils.js +1 -3
  70. package/optimize/es/components/badge/notification_badge/badge_notification.styles.js +6 -1
  71. package/optimize/es/components/breadcrumbs/_breadcrumb_content.styles.js +6 -3
  72. package/optimize/es/components/button/button_display/_button_display.js +1 -1
  73. package/optimize/es/components/button/button_display/_button_display.styles.js +11 -2
  74. package/optimize/es/components/button/button_display/_button_display_content.styles.js +6 -3
  75. package/optimize/es/components/button/button_empty/button_empty.styles.js +9 -12
  76. package/optimize/es/components/button/button_group/button_group.styles.js +5 -3
  77. package/optimize/es/components/button/button_group/button_group_button.js +12 -8
  78. package/optimize/es/components/button/button_group/button_group_button.styles.js +43 -19
  79. package/optimize/es/components/button/button_icon/button_icon.js +4 -2
  80. package/optimize/es/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
  81. package/optimize/es/components/datagrid/utils/focus.js +2 -2
  82. package/optimize/es/components/filter_group/filter_button.js +78 -21
  83. package/optimize/es/components/filter_group/filter_button.styles.js +51 -15
  84. package/optimize/es/components/filter_group/filter_group.styles.js +18 -6
  85. package/optimize/es/components/markdown_editor/markdown_editor_footer.js +9 -4
  86. package/optimize/es/components/search_bar/filters/field_value_selection_filter.js +1 -0
  87. package/optimize/es/components/search_bar/filters/field_value_toggle_filter.js +3 -1
  88. package/optimize/es/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
  89. package/optimize/es/components/search_bar/filters/is_filter.js +3 -1
  90. package/optimize/es/components/search_bar/search_bar.a11y.js +3 -3
  91. package/optimize/es/global_styling/mixins/_button.js +95 -28
  92. package/optimize/es/services/theme/index.js +2 -1
  93. package/optimize/es/services/theme/provider.js +28 -2
  94. package/optimize/es/services/theme/theme_variant.js +22 -0
  95. package/optimize/es/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
  96. package/optimize/es/themes/amsterdam/global_styling/variables/_components.js +229 -224
  97. package/optimize/es/themes/amsterdam/theme.js +2 -1
  98. package/optimize/es/themes/json/eui_theme_borealis_dark.json +1 -1
  99. package/optimize/lib/components/badge/color_utils.js +1 -3
  100. package/optimize/lib/components/badge/notification_badge/badge_notification.styles.js +6 -1
  101. package/optimize/lib/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
  102. package/optimize/lib/components/button/button_display/_button_display.js +1 -1
  103. package/optimize/lib/components/button/button_display/_button_display.styles.js +11 -2
  104. package/optimize/lib/components/button/button_display/_button_display_content.styles.js +6 -3
  105. package/optimize/lib/components/button/button_empty/button_empty.styles.js +10 -11
  106. package/optimize/lib/components/button/button_group/button_group.styles.js +5 -3
  107. package/optimize/lib/components/button/button_group/button_group_button.js +11 -7
  108. package/optimize/lib/components/button/button_group/button_group_button.styles.js +41 -17
  109. package/optimize/lib/components/button/button_icon/button_icon.js +3 -1
  110. package/optimize/lib/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
  111. package/optimize/lib/components/datagrid/utils/focus.js +1 -1
  112. package/optimize/lib/components/filter_group/filter_button.js +76 -19
  113. package/optimize/lib/components/filter_group/filter_button.styles.js +51 -15
  114. package/optimize/lib/components/filter_group/filter_group.styles.js +18 -6
  115. package/optimize/lib/components/markdown_editor/markdown_editor_footer.js +8 -3
  116. package/optimize/lib/components/search_bar/filters/field_value_selection_filter.js +1 -0
  117. package/optimize/lib/components/search_bar/filters/field_value_toggle_filter.js +3 -1
  118. package/optimize/lib/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
  119. package/optimize/lib/components/search_bar/filters/is_filter.js +3 -1
  120. package/optimize/lib/components/search_bar/search_bar.a11y.js +3 -3
  121. package/optimize/lib/global_styling/mixins/_button.js +94 -27
  122. package/optimize/lib/services/theme/index.js +42 -1
  123. package/optimize/lib/services/theme/provider.js +28 -2
  124. package/optimize/lib/services/theme/theme_variant.js +28 -0
  125. package/optimize/lib/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
  126. package/optimize/lib/themes/amsterdam/global_styling/variables/_components.js +229 -224
  127. package/optimize/lib/themes/amsterdam/theme.js +2 -1
  128. package/optimize/lib/themes/json/eui_theme_borealis_dark.json +1 -1
  129. package/package.json +4 -4
  130. package/test-env/components/badge/color_utils.js +1 -3
  131. package/test-env/components/badge/notification_badge/badge_notification.styles.js +6 -1
  132. package/test-env/components/basic_table/basic_table.js +4 -1
  133. package/test-env/components/basic_table/in_memory_table.js +4 -1
  134. package/test-env/components/breadcrumbs/_breadcrumb_content.styles.js +5 -2
  135. package/test-env/components/button/button_display/_button_display.js +1 -1
  136. package/test-env/components/button/button_display/_button_display.styles.js +11 -2
  137. package/test-env/components/button/button_display/_button_display_content.styles.js +6 -3
  138. package/test-env/components/button/button_empty/button_empty.styles.js +10 -11
  139. package/test-env/components/button/button_group/button_group.styles.js +5 -3
  140. package/test-env/components/button/button_group/button_group_button.js +18 -8
  141. package/test-env/components/button/button_group/button_group_button.styles.js +41 -17
  142. package/test-env/components/button/button_icon/button_icon.js +3 -1
  143. package/test-env/components/collapsible_nav/collapsible_nav.js +1 -0
  144. package/test-env/components/datagrid/controls/data_grid_toolbar_control.js +11 -1
  145. package/test-env/components/datagrid/utils/focus.js +1 -1
  146. package/test-env/components/filter_group/filter_button.js +86 -21
  147. package/test-env/components/filter_group/filter_button.styles.js +51 -15
  148. package/test-env/components/filter_group/filter_group.styles.js +18 -6
  149. package/test-env/components/markdown_editor/markdown_editor_footer.js +8 -3
  150. package/test-env/components/search_bar/filters/field_value_selection_filter.js +1 -0
  151. package/test-env/components/search_bar/filters/field_value_toggle_filter.js +3 -1
  152. package/test-env/components/search_bar/filters/field_value_toggle_group_filter.js +3 -1
  153. package/test-env/components/search_bar/filters/is_filter.js +3 -1
  154. package/test-env/components/search_bar/search_bar.a11y.js +3 -3
  155. package/test-env/global_styling/mixins/_button.js +94 -27
  156. package/test-env/services/theme/index.js +42 -1
  157. package/test-env/services/theme/provider.js +28 -2
  158. package/test-env/services/theme/theme_variant.js +28 -0
  159. package/test-env/themes/amsterdam/global_styling/variables/_buttons.js +348 -147
  160. package/test-env/themes/amsterdam/global_styling/variables/_components.js +229 -224
  161. package/test-env/themes/amsterdam/theme.js +2 -1
  162. package/test-env/themes/json/eui_theme_borealis_dark.json +1 -1
@@ -21,14 +21,34 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
21
21
  */
22
22
 
23
23
  import { css, keyframes } from '@emotion/react';
24
- import { getTokenName, euiCanAnimate } from '@elastic/eui-theme-common';
25
- import { makeHighContrastColor, useEuiMemoizedStyles } from '../../services';
24
+ import { getTokenName, euiCanAnimate, mathWithUnits } from '@elastic/eui-theme-common';
25
+ import { makeHighContrastColor, useEuiMemoizedStyles, isEuiThemeRefreshVariant } from '../../services';
26
+ import { highContrastModeStyles, logicalCSS } from '../functions';
26
27
 
27
28
  /** Tentative usage; these exist only to be used as button directly when used within other components */
28
29
  export var SEVERITY_COLORS = ['neutral', 'risk'];
29
30
  export var BUTTON_COLORS = ['text', 'accent', 'accentSecondary', 'primary', 'success', 'warning', 'danger'];
30
31
  export var EXTENDED_BUTTON_COLORS = [].concat(BUTTON_COLORS, SEVERITY_COLORS);
31
32
  export var BUTTON_DISPLAYS = ['base', 'fill', 'empty'];
33
+ var getButtonVariantTokenValues = function getButtonVariantTokenValues(_ref, color, variant) {
34
+ var euiTheme = _ref.euiTheme,
35
+ highContrastMode = _ref.highContrastMode;
36
+ var backgroundTokenBase = variant === 'base' ? 'background' : "background".concat(variant.charAt(0).toUpperCase() + variant.slice(1));
37
+ var textTokenBase = variant === 'filled' ? 'textColorFilled' : 'textColor';
38
+ var backgroundTokenName = getTokenName(backgroundTokenBase, color);
39
+ var textTokenName = getTokenName(textTokenBase, color);
40
+ var backgroundHoverTokenName = getTokenName(backgroundTokenBase, color, 'hover');
41
+ var backgroundActiveTokenName = getTokenName(backgroundTokenBase, color, 'active');
42
+ var highContrastForeground = ['warning', 'neutral', 'risk'].includes(color) ? euiTheme.colors.ink : color === 'disabled' ? euiTheme.components.buttons[textTokenName] : euiTheme.colors.textInverse;
43
+ var foreground = variant === 'filled' ? highContrastMode ? highContrastForeground : euiTheme.components.buttons[textTokenName] : euiTheme.components.buttons[textTokenName];
44
+ return {
45
+ color: foreground,
46
+ background: euiTheme.components.buttons[backgroundTokenName],
47
+ backgroundHover: euiTheme.components.buttons[backgroundHoverTokenName],
48
+ backgroundActive: euiTheme.components.buttons[backgroundActiveTokenName]
49
+ };
50
+ };
51
+
32
52
  /**
33
53
  * Creates the `base` version of button styles with proper text contrast.
34
54
  * @param euiThemeContext
@@ -36,11 +56,9 @@ export var BUTTON_DISPLAYS = ['base', 'fill', 'empty'];
36
56
  * @returns Style object `{ backgroundColor, color }`
37
57
  */
38
58
  export var euiButtonColor = function euiButtonColor(euiThemeContext, color) {
39
- var euiTheme = euiThemeContext.euiTheme;
40
- var backgroundTokenName = getTokenName('background', color);
41
- var textTokenName = getTokenName('textColor', color);
42
- var foreground = euiTheme.components.buttons[textTokenName];
43
- var background = euiTheme.components.buttons[backgroundTokenName];
59
+ var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'base');
60
+ var foreground = buttonColors.color;
61
+ var background = buttonColors.background;
44
62
  return _objectSpread({
45
63
  color: background === 'transparent' || color === 'disabled' ? foreground : makeHighContrastColor(foreground)(background),
46
64
  backgroundColor: background
@@ -54,13 +72,9 @@ export var euiButtonColor = function euiButtonColor(euiThemeContext, color) {
54
72
  * @returns Style object `{ backgroundColor, color }`
55
73
  */
56
74
  export var euiButtonFillColor = function euiButtonFillColor(euiThemeContext, color) {
57
- var euiTheme = euiThemeContext.euiTheme,
58
- highContrastMode = euiThemeContext.highContrastMode;
59
- var backgroundTokenName = getTokenName('backgroundFilled', color);
60
- var textColorTokenName = getTokenName('textColorFilled', color);
61
- var highContrastForeground = ['warning', 'neutral', 'risk'].includes(color) ? euiTheme.colors.ink : color === 'disabled' ? euiTheme.components.buttons[textColorTokenName] : euiTheme.colors.textInverse;
62
- var foreground = highContrastMode ? highContrastForeground : euiTheme.components.buttons[textColorTokenName];
63
- var background = euiTheme.components.buttons[backgroundTokenName];
75
+ var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'filled');
76
+ var foreground = buttonColors.color;
77
+ var background = buttonColors.background;
64
78
  return _objectSpread({
65
79
  color: foreground,
66
80
  backgroundColor: background
@@ -84,9 +98,9 @@ export var euiButtonEmptyColor = function euiButtonEmptyColor(euiThemeContext, c
84
98
  break;
85
99
  default:
86
100
  {
87
- var backgroundToken = getTokenName('backgroundEmpty', color, 'hover');
101
+ var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'empty');
88
102
  foreground = euiButtonColor(euiThemeContext, color).color;
89
- background = euiThemeContext.euiTheme.components.buttons[backgroundToken];
103
+ background = buttonColors.backgroundHover;
90
104
  break;
91
105
  }
92
106
  }
@@ -109,6 +123,8 @@ export var useEuiButtonColorCSS = function useEuiButtonColorCSS() {
109
123
  return colorsDisplaysMap[display];
110
124
  };
111
125
  var euiButtonDisplaysColors = function euiButtonDisplaysColors(euiThemeContext) {
126
+ var euiTheme = euiThemeContext.euiTheme;
127
+ var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
112
128
  var COLORS = [].concat(_toConsumableArray(EXTENDED_BUTTON_COLORS), ['disabled']);
113
129
  var displaysColorsMap = {};
114
130
  BUTTON_DISPLAYS.forEach(function (display) {
@@ -116,14 +132,28 @@ var euiButtonDisplaysColors = function euiButtonDisplaysColors(euiThemeContext)
116
132
  COLORS.forEach(function (color) {
117
133
  switch (display) {
118
134
  case 'base':
119
- displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonColor(euiThemeContext, color), ";;label:displaysColorsMap-display-color;");
120
- break;
135
+ {
136
+ var buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'base');
137
+ var borderStyle = color === 'text' && "\n border: ".concat(euiTheme.border.width.thin, " solid ").concat(euiTheme.colors.borderBasePlain, ";\n ");
138
+ var refreshVariantStyles = isRefreshVariant && "\n ".concat(_interactionStyles(euiThemeContext, buttonColors, 'overlay'), "\n ").concat(borderStyle, "\n ");
139
+ displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonColor(euiThemeContext, color), " ", refreshVariantStyles, ";;label:displaysColorsMap-display-color;");
140
+ break;
141
+ }
121
142
  case 'fill':
122
- displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonFillColor(euiThemeContext, color), "outline-color:", euiThemeContext.colorMode === 'DARK' && color === 'text' ? 'currentColor' : euiThemeContext.euiTheme.colors.fullShade, ";;label:displaysColorsMap-display-color;");
123
- break;
143
+ {
144
+ var _buttonColors = getButtonVariantTokenValues(euiThemeContext, color, 'filled');
145
+ var _refreshVariantStyles = isRefreshVariant && _interactionStyles(euiThemeContext, _buttonColors);
146
+ displaysColorsMap[display][color] = /*#__PURE__*/css(euiButtonFillColor(euiThemeContext, color), "outline-color:", euiThemeContext.colorMode === 'DARK' && color === 'text' ? 'currentColor' : euiThemeContext.euiTheme.colors.fullShade, ";", _refreshVariantStyles, ";;label:displaysColorsMap-display-color;");
147
+ break;
148
+ }
124
149
  case 'empty':
125
- displaysColorsMap[display][color] = /*#__PURE__*/css("color:", euiButtonEmptyColor(euiThemeContext, color).color, ";&:focus,&:active{background-color:", euiButtonEmptyColor(euiThemeContext, color).backgroundColor, ";};label:displaysColorsMap-display-color;");
126
- break;
150
+ {
151
+ var _buttonColors2 = getButtonVariantTokenValues(euiThemeContext, color, 'empty');
152
+ var classicVariantStyles = !isRefreshVariant && "\n &:focus,\n &:active {\n background-color: ".concat(euiButtonEmptyColor(euiThemeContext, color).backgroundColor, ";\n }\n ");
153
+ var _refreshVariantStyles2 = isRefreshVariant && _interactionStyles(euiThemeContext, _buttonColors2, 'overlay');
154
+ displaysColorsMap[display][color] = /*#__PURE__*/css("color:", euiButtonEmptyColor(euiThemeContext, color).color, ";", classicVariantStyles, " ", _refreshVariantStyles2, ";;label:displaysColorsMap-display-color;");
155
+ break;
156
+ }
127
157
  }
128
158
 
129
159
  // Tweak auto-generated Emotion label/className output
@@ -142,9 +172,10 @@ export var useEuiButtonFocusCSS = function useEuiButtonFocusCSS() {
142
172
  return useEuiMemoizedStyles(euiButtonFocusCSS);
143
173
  };
144
174
  var euiButtonFocusAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 50% {\n transform: translateY(1px);\n }\n"])));
145
- var euiButtonFocusCSS = function euiButtonFocusCSS(_ref) {
146
- var euiTheme = _ref.euiTheme;
147
- var focusCSS = /*#__PURE__*/css(euiCanAnimate, "{transition:transform ", euiTheme.animation.normal, " ease-in-out,background-color ", euiTheme.animation.normal, " ease-in-out;&:hover:not(:disabled){transform:translateY(-1px);}&:focus{animation:", euiButtonFocusAnimation, " ", euiTheme.animation.normal, " ", euiTheme.animation.bounce, ";}&:active:not(:disabled){transform:translateY(1px);}};label:focusCSS;");
175
+ var euiButtonFocusCSS = function euiButtonFocusCSS(euiThemeContext) {
176
+ var euiTheme = euiThemeContext.euiTheme;
177
+ var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
178
+ var focusCSS = isRefreshVariant ? /*#__PURE__*/css(";label:focusCSS;") : /*#__PURE__*/css(euiCanAnimate, "{transition:transform ", euiTheme.animation.normal, " ease-in-out,background-color ", euiTheme.animation.normal, " ease-in-out;&:hover:not(:disabled){transform:translateY(-1px);}&:focus{animation:", euiButtonFocusAnimation, " ", euiTheme.animation.normal, " ", euiTheme.animation.bounce, ";}&:active:not(:disabled){transform:translateY(1px);}};label:focusCSS;");
148
179
  // Remove the auto-generated label.
149
180
  // We could typically avoid a label by using a plain string `` instead of css``,
150
181
  // but we need css`` for keyframes`` to work for the focus animation
@@ -156,27 +187,63 @@ var euiButtonFocusCSS = function euiButtonFocusCSS(_ref) {
156
187
  * Map of `size` props to various sizings/scales
157
188
  * that should remain consistent across all buttons
158
189
  */
159
- export var euiButtonSizeMap = function euiButtonSizeMap(_ref2) {
160
- var euiTheme = _ref2.euiTheme;
190
+ export var euiButtonSizeMap = function euiButtonSizeMap(euiThemeContext) {
191
+ var euiTheme = euiThemeContext.euiTheme;
192
+ var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
161
193
  return {
162
194
  xs: {
195
+ minWidth: euiTheme.base * (isRefreshVariant ? 6 : 7),
163
196
  height: euiTheme.size.l,
164
197
  radius: euiTheme.border.radius.small,
165
198
  fontScale: 'xs'
166
199
  },
167
200
  s: {
201
+ minWidth: euiTheme.base * (isRefreshVariant ? 6 : 7),
168
202
  height: euiTheme.size.xl,
169
203
  radius: euiTheme.border.radius.small,
170
204
  fontScale: 's'
171
205
  },
172
206
  m: {
207
+ minWidth: euiTheme.base * 7,
173
208
  height: euiTheme.size.xxl,
174
- radius: euiTheme.border.radius.medium,
209
+ radius: isRefreshVariant ? euiTheme.border.radius.small : euiTheme.border.radius.medium,
175
210
  fontScale: 's'
176
211
  }
177
212
  };
178
213
  };
179
214
 
215
+ /**
216
+ * internal styles util for applying button background color on hover
217
+ */
218
+ var _interactionStyles = function _interactionStyles(euiThemeContext, buttonColors) {
219
+ var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'fill';
220
+ var isRefreshVariant = isEuiThemeRefreshVariant(euiThemeContext, 'buttonVariant');
221
+ if (!isRefreshVariant) return "";
222
+ var baseStyles = function baseStyles() {
223
+ // button hover is applied as pseudo element with a transparent background-color
224
+ if (type === 'overlay') {
225
+ return "\n position: relative;\n overflow: hidden;\n\n &:hover:not(:disabled) {\n &::before {\n content: '';\n position: absolute;\n /* should stay under the content */\n z-index: 0;\n inset: 0;\n background-color: ".concat(buttonColors.backgroundHover, ";\n pointer-events: none;\n }\n }\n\n &:active:not(:disabled) {\n &::before {\n ").concat(logicalCSS('width', '100%'), "\n ").concat(logicalCSS('height', '100%'), "\n\n content: '';\n position: absolute;\n inset: 0;\n background-color: ").concat(buttonColors.backgroundActive, ";\n }\n }\n ");
226
+ }
227
+
228
+ // button hover is applied as opaque color
229
+ return "\n &:hover:not(:disabled) {\n background-color: ".concat(buttonColors.backgroundHover, ";\n }\n\n &:active:not(:disabled) {\n background-color: ").concat(buttonColors.backgroundActive, ";\n }\n ");
230
+ };
231
+ return " \n ".concat(highContrastModeStyles(euiThemeContext, {
232
+ none: baseStyles(),
233
+ forced: "\n position: relative;\n overflow: hidden;\n\n ".concat(highContrastHoverIndicatorStyles(euiThemeContext), "\n ")
234
+ }), "\n ");
235
+ };
236
+
237
+ /**
238
+ * creates a bottom border on hover/focus to ensure a visible change as forced mode removed background colors
239
+ */
240
+ export var highContrastHoverIndicatorStyles = function highContrastHoverIndicatorStyles(_ref2) {
241
+ var euiTheme = _ref2.euiTheme;
242
+ return "\n &:hover:not(:disabled) {\n transition: none;\n\n /* using pseudo border to be able to control the color */\n &::after {\n content: '';\n position: absolute;\n inset: ".concat(euiTheme.border.width.thin, ";\n border: ").concat(euiTheme.border.width.thick, " solid var(--highContrastHoverIndicatorColor, ").concat(euiTheme.border.color, ");\n border-radius: ").concat(mathWithUnits(euiTheme.border.radius.small, function (x) {
243
+ return x / 2;
244
+ }), ";\n background-color: transparent;\n pointer-events: none;\n }\n }\n");
245
+ };
246
+
180
247
  /**
181
248
  * Internal util for high contrast button borders
182
249
  */
@@ -12,4 +12,5 @@ export { EuiThemeProvider } from './provider';
12
12
  export { useEuiMemoizedStyles, withEuiStylesMemoizer, RenderWithEuiStylesMemoizer } 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
- export { COLOR_MODES_STANDARD } from './types';
15
+ export { COLOR_MODES_STANDARD } from './types';
16
+ export * from './theme_variant';
@@ -143,9 +143,35 @@ export var EuiThemeProvider = function EuiThemeProvider(_ref) {
143
143
  }, [highContrastMode]);
144
144
  useEffect(function () {
145
145
  if (!isParentTheme.current) {
146
- setTheme(getComputed(system, buildTheme(modificationsWithHighContrast, "_".concat(system.key)), colorMode, highContrastMode));
146
+ /* Enables recomputation of component colors when flags are overridden on the provider
147
+ by adding the respective key to modifications to trigger a recomputation. */
148
+ // TODO: remove once visual refresh is completed and flags are obsolete
149
+ var flagsToRecompute = [{
150
+ flag: 'buttonVariant',
151
+ componentKey: 'buttons'
152
+ }];
153
+ var keys = {};
154
+ var forceRecomputeComponents = flagsToRecompute.some(function (item) {
155
+ var _modifications$flags, _modifications$compon;
156
+ if (Object.keys((_modifications$flags = modifications.flags) !== null && _modifications$flags !== void 0 ? _modifications$flags : {}).includes(item.flag) && !Object.keys((_modifications$compon = modifications.components) !== null && _modifications$compon !== void 0 ? _modifications$compon : {}).includes(item.componentKey)) {
157
+ keys[item.componentKey] = {
158
+ LIGHT: {},
159
+ DARK: {}
160
+ };
161
+ return true;
162
+ }
163
+ return false;
164
+ });
165
+ var componentModifications = forceRecomputeComponents ? {
166
+ components: keys
167
+ } : {};
168
+
169
+ // force recomputing of color & component tokens based on flag changes
170
+ var enhancedModifications = _objectSpread(_objectSpread({}, modificationsWithHighContrast), componentModifications);
171
+ var rebuiltTheme = getComputed(system, buildTheme(enhancedModifications, "_".concat(system.key)), colorMode, highContrastMode);
172
+ setTheme(rebuiltTheme);
147
173
  }
148
- }, [colorMode, highContrastMode, system, modificationsWithHighContrast]);
174
+ }, [colorMode, highContrastMode, system, modificationsWithHighContrast, modifications]);
149
175
  var _useState9 = useState(),
150
176
  _useState10 = _slicedToArray(_useState9, 2),
151
177
  themeCSSVariables = _useState10[0],
@@ -0,0 +1,22 @@
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
+
9
+ import { useEuiTheme } from './hooks';
10
+ export var isEuiThemeRefreshVariant = function isEuiThemeRefreshVariant(_ref, flag) {
11
+ var euiTheme = _ref.euiTheme;
12
+ return euiTheme.flags[flag] === 'refresh';
13
+ };
14
+
15
+ /**
16
+ * Util to retrieve visual variant for UI elements
17
+ * Note: Temporary only - will be removed once the visual refresh is completed.
18
+ */
19
+ export var useEuiThemeRefreshVariant = function useEuiThemeRefreshVariant(flag) {
20
+ var euiThemeContext = useEuiTheme();
21
+ return isEuiThemeRefreshVariant(euiThemeContext, flag);
22
+ };