@elastic/eui 102.0.0 → 102.1.0-snapshot.1746441787383

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