@elastic/eui 116.3.0 → 116.3.1-snapshot.1782218964187

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 (218) hide show
  1. package/es/components/avatar/avatar.js +4 -0
  2. package/es/components/avatar/avatar.styles.js +16 -16
  3. package/es/components/banner/banner.js +1 -2
  4. package/es/components/banner/banner.styles.js +1 -1
  5. package/es/components/basic_table/basic_table.js +35 -5
  6. package/es/components/basic_table/basic_table.styles.js +19 -1
  7. package/es/components/basic_table/in_memory_table.js +17 -0
  8. package/es/components/basic_table/index.js +2 -1
  9. package/es/components/basic_table/pagination_bar.js +19 -4
  10. package/es/components/basic_table/pagination_bar.styles.js +21 -0
  11. package/es/components/basic_table/panel.styles.js +14 -0
  12. package/es/components/basic_table/use_panel_props.js +28 -0
  13. package/es/components/date_picker/auto_refresh/refresh_interval.js +176 -229
  14. package/es/components/flyout/flyout.component.js +10 -6
  15. package/es/components/flyout/flyout_menu.js +122 -19
  16. package/es/components/flyout/flyout_menu.styles.js +2 -1
  17. package/es/components/flyout/manager/actions.js +20 -0
  18. package/es/components/flyout/manager/flyout_child.js +23 -1
  19. package/es/components/flyout/manager/flyout_managed.js +65 -19
  20. package/es/components/flyout/manager/hooks.js +1 -1
  21. package/es/components/flyout/manager/index.js +2 -2
  22. package/es/components/flyout/manager/reducer.js +32 -8
  23. package/es/components/flyout/manager/selectors.js +8 -2
  24. package/es/components/flyout/manager/store.js +35 -2
  25. package/es/components/flyout/use_flyout_menu.js +2 -2
  26. package/es/components/form/form_control_layout/form_control_layout_icons.js +95 -143
  27. package/es/components/notification_icon/assets/info_fill.js +34 -0
  28. package/es/components/notification_icon/assets/warning_static.js +40 -0
  29. package/es/components/notification_icon/notification_icon.js +87 -0
  30. package/es/components/notification_icon/notification_icon.styles.js +22 -0
  31. package/es/components/table/mobile/table_sort_mobile.js +64 -103
  32. package/es/components/table/store/use_unique_column_id.js +25 -0
  33. package/es/components/table/table_header_cell.js +7 -8
  34. package/es/components/table/table_header_cell_checkbox.js +5 -6
  35. package/es/components/toast/global_toast_list.js +132 -6
  36. package/es/components/toast/global_toast_list.styles.js +31 -7
  37. package/es/components/toast/toast.js +242 -47
  38. package/es/components/toast/toast.styles.js +35 -47
  39. package/es/components/toast/toast_action.js +34 -0
  40. package/es/components/toast/types.js +9 -0
  41. package/es/components/tool_tip/tool_tip.js +61 -30
  42. package/es/components/tool_tip/tool_tip_anchor.js +5 -5
  43. package/es/components/tool_tip/tool_tip_manager.js +27 -2
  44. package/eui.d.ts +811 -552
  45. package/i18ntokens.json +981 -927
  46. package/lib/components/avatar/avatar.js +4 -0
  47. package/lib/components/avatar/avatar.styles.js +16 -16
  48. package/lib/components/banner/banner.js +1 -2
  49. package/lib/components/banner/banner.styles.js +1 -1
  50. package/lib/components/basic_table/basic_table.js +34 -4
  51. package/lib/components/basic_table/basic_table.styles.js +19 -1
  52. package/lib/components/basic_table/in_memory_table.js +17 -0
  53. package/lib/components/basic_table/index.js +8 -1
  54. package/lib/components/basic_table/pagination_bar.js +19 -4
  55. package/lib/components/basic_table/pagination_bar.styles.js +26 -0
  56. package/lib/components/basic_table/panel.styles.js +20 -0
  57. package/lib/components/basic_table/use_panel_props.js +33 -0
  58. package/lib/components/date_picker/auto_refresh/refresh_interval.js +175 -229
  59. package/lib/components/flyout/flyout.component.js +10 -6
  60. package/lib/components/flyout/flyout_menu.js +120 -19
  61. package/lib/components/flyout/flyout_menu.styles.js +2 -1
  62. package/lib/components/flyout/manager/actions.js +21 -1
  63. package/lib/components/flyout/manager/flyout_child.js +23 -1
  64. package/lib/components/flyout/manager/flyout_managed.js +41 -17
  65. package/lib/components/flyout/manager/hooks.js +6 -0
  66. package/lib/components/flyout/manager/index.js +12 -0
  67. package/lib/components/flyout/manager/reducer.js +31 -7
  68. package/lib/components/flyout/manager/selectors.js +9 -3
  69. package/lib/components/flyout/manager/store.js +34 -1
  70. package/lib/components/flyout/use_flyout_menu.js +2 -2
  71. package/lib/components/form/form_control_layout/form_control_layout_icons.js +95 -145
  72. package/lib/components/notification_icon/assets/info_fill.js +41 -0
  73. package/lib/components/notification_icon/assets/warning_static.js +47 -0
  74. package/lib/components/notification_icon/notification_icon.js +93 -0
  75. package/lib/components/notification_icon/notification_icon.styles.js +28 -0
  76. package/lib/components/notification_icon/svgs/info_fill.svg +3 -0
  77. package/lib/components/notification_icon/svgs/warning_static.svg +5 -0
  78. package/lib/components/table/mobile/table_sort_mobile.js +71 -108
  79. package/lib/components/table/store/use_unique_column_id.js +34 -0
  80. package/lib/components/table/table_header_cell.js +7 -8
  81. package/lib/components/table/table_header_cell_checkbox.js +5 -6
  82. package/lib/components/toast/global_toast_list.js +132 -6
  83. package/lib/components/toast/global_toast_list.styles.js +31 -8
  84. package/lib/components/toast/toast.js +244 -47
  85. package/lib/components/toast/toast.styles.js +32 -45
  86. package/lib/components/toast/toast_action.js +40 -0
  87. package/lib/components/toast/types.js +15 -0
  88. package/lib/components/tool_tip/tool_tip.js +59 -29
  89. package/lib/components/tool_tip/tool_tip_anchor.js +5 -5
  90. package/lib/components/tool_tip/tool_tip_manager.js +27 -2
  91. package/optimize/es/components/avatar/avatar.js +4 -0
  92. package/optimize/es/components/avatar/avatar.styles.js +16 -16
  93. package/optimize/es/components/banner/banner.js +1 -2
  94. package/optimize/es/components/banner/banner.styles.js +1 -1
  95. package/optimize/es/components/basic_table/basic_table.js +18 -5
  96. package/optimize/es/components/basic_table/basic_table.styles.js +19 -1
  97. package/optimize/es/components/basic_table/index.js +2 -1
  98. package/optimize/es/components/basic_table/pagination_bar.js +19 -4
  99. package/optimize/es/components/basic_table/pagination_bar.styles.js +21 -0
  100. package/optimize/es/components/basic_table/panel.styles.js +14 -0
  101. package/optimize/es/components/basic_table/use_panel_props.js +28 -0
  102. package/optimize/es/components/date_picker/auto_refresh/refresh_interval.js +172 -196
  103. package/optimize/es/components/flyout/flyout.component.js +10 -6
  104. package/optimize/es/components/flyout/flyout_menu.js +99 -18
  105. package/optimize/es/components/flyout/flyout_menu.styles.js +2 -1
  106. package/optimize/es/components/flyout/manager/actions.js +20 -0
  107. package/optimize/es/components/flyout/manager/flyout_managed.js +42 -18
  108. package/optimize/es/components/flyout/manager/hooks.js +1 -1
  109. package/optimize/es/components/flyout/manager/index.js +2 -2
  110. package/optimize/es/components/flyout/manager/reducer.js +32 -8
  111. package/optimize/es/components/flyout/manager/selectors.js +8 -2
  112. package/optimize/es/components/flyout/manager/store.js +35 -2
  113. package/optimize/es/components/flyout/use_flyout_menu.js +2 -2
  114. package/optimize/es/components/form/form_control_layout/form_control_layout_icons.js +96 -115
  115. package/optimize/es/components/notification_icon/assets/info_fill.js +33 -0
  116. package/optimize/es/components/notification_icon/assets/warning_static.js +39 -0
  117. package/optimize/es/components/notification_icon/notification_icon.js +77 -0
  118. package/optimize/es/components/notification_icon/notification_icon.styles.js +22 -0
  119. package/optimize/es/components/table/mobile/table_sort_mobile.js +59 -82
  120. package/optimize/es/components/table/store/use_unique_column_id.js +25 -0
  121. package/optimize/es/components/table/table_header_cell.js +7 -8
  122. package/optimize/es/components/table/table_header_cell_checkbox.js +5 -6
  123. package/optimize/es/components/toast/global_toast_list.js +31 -6
  124. package/optimize/es/components/toast/global_toast_list.styles.js +31 -7
  125. package/optimize/es/components/toast/toast.js +143 -47
  126. package/optimize/es/components/toast/toast.styles.js +35 -47
  127. package/optimize/es/components/toast/toast_action.js +33 -0
  128. package/optimize/es/components/toast/types.js +9 -0
  129. package/optimize/es/components/tool_tip/tool_tip.js +58 -30
  130. package/optimize/es/components/tool_tip/tool_tip_anchor.js +5 -5
  131. package/optimize/es/components/tool_tip/tool_tip_manager.js +27 -2
  132. package/optimize/lib/components/avatar/avatar.js +4 -0
  133. package/optimize/lib/components/avatar/avatar.styles.js +16 -16
  134. package/optimize/lib/components/banner/banner.js +1 -2
  135. package/optimize/lib/components/banner/banner.styles.js +1 -1
  136. package/optimize/lib/components/basic_table/basic_table.js +17 -4
  137. package/optimize/lib/components/basic_table/basic_table.styles.js +19 -1
  138. package/optimize/lib/components/basic_table/index.js +8 -1
  139. package/optimize/lib/components/basic_table/pagination_bar.js +19 -4
  140. package/optimize/lib/components/basic_table/pagination_bar.styles.js +26 -0
  141. package/optimize/lib/components/basic_table/panel.styles.js +20 -0
  142. package/optimize/lib/components/basic_table/use_panel_props.js +33 -0
  143. package/optimize/lib/components/date_picker/auto_refresh/refresh_interval.js +170 -194
  144. package/optimize/lib/components/flyout/flyout.component.js +10 -6
  145. package/optimize/lib/components/flyout/flyout_menu.js +98 -18
  146. package/optimize/lib/components/flyout/flyout_menu.styles.js +2 -1
  147. package/optimize/lib/components/flyout/manager/actions.js +21 -1
  148. package/optimize/lib/components/flyout/manager/flyout_managed.js +41 -17
  149. package/optimize/lib/components/flyout/manager/hooks.js +6 -0
  150. package/optimize/lib/components/flyout/manager/index.js +12 -0
  151. package/optimize/lib/components/flyout/manager/reducer.js +31 -7
  152. package/optimize/lib/components/flyout/manager/selectors.js +9 -3
  153. package/optimize/lib/components/flyout/manager/store.js +34 -1
  154. package/optimize/lib/components/flyout/use_flyout_menu.js +2 -2
  155. package/optimize/lib/components/form/form_control_layout/form_control_layout_icons.js +96 -117
  156. package/optimize/lib/components/notification_icon/assets/info_fill.js +41 -0
  157. package/optimize/lib/components/notification_icon/assets/warning_static.js +47 -0
  158. package/optimize/lib/components/notification_icon/notification_icon.js +83 -0
  159. package/optimize/lib/components/notification_icon/notification_icon.styles.js +28 -0
  160. package/optimize/lib/components/notification_icon/svgs/info_fill.svg +3 -0
  161. package/optimize/lib/components/notification_icon/svgs/warning_static.svg +5 -0
  162. package/optimize/lib/components/table/mobile/table_sort_mobile.js +61 -83
  163. package/optimize/lib/components/table/store/use_unique_column_id.js +34 -0
  164. package/optimize/lib/components/table/table_header_cell.js +7 -8
  165. package/optimize/lib/components/table/table_header_cell_checkbox.js +5 -6
  166. package/optimize/lib/components/toast/global_toast_list.js +31 -6
  167. package/optimize/lib/components/toast/global_toast_list.styles.js +30 -7
  168. package/optimize/lib/components/toast/toast.js +146 -47
  169. package/optimize/lib/components/toast/toast.styles.js +33 -45
  170. package/optimize/lib/components/toast/toast_action.js +39 -0
  171. package/optimize/lib/components/toast/types.js +15 -0
  172. package/optimize/lib/components/tool_tip/tool_tip.js +57 -29
  173. package/optimize/lib/components/tool_tip/tool_tip_anchor.js +5 -5
  174. package/optimize/lib/components/tool_tip/tool_tip_manager.js +27 -2
  175. package/package.json +9 -6
  176. package/test-env/components/avatar/avatar.js +4 -0
  177. package/test-env/components/avatar/avatar.styles.js +16 -16
  178. package/test-env/components/banner/banner.js +1 -2
  179. package/test-env/components/banner/banner.styles.js +1 -1
  180. package/test-env/components/basic_table/basic_table.js +34 -4
  181. package/test-env/components/basic_table/basic_table.styles.js +19 -1
  182. package/test-env/components/basic_table/in_memory_table.js +17 -0
  183. package/test-env/components/basic_table/index.js +8 -1
  184. package/test-env/components/basic_table/pagination_bar.js +19 -4
  185. package/test-env/components/basic_table/pagination_bar.styles.js +26 -0
  186. package/test-env/components/basic_table/panel.styles.js +20 -0
  187. package/test-env/components/basic_table/use_panel_props.js +33 -0
  188. package/test-env/components/date_picker/auto_refresh/refresh_interval.js +170 -220
  189. package/test-env/components/flyout/flyout.component.js +10 -6
  190. package/test-env/components/flyout/flyout_menu.js +121 -19
  191. package/test-env/components/flyout/flyout_menu.styles.js +2 -1
  192. package/test-env/components/flyout/manager/actions.js +21 -1
  193. package/test-env/components/flyout/manager/flyout_child.js +23 -1
  194. package/test-env/components/flyout/manager/flyout_managed.js +41 -17
  195. package/test-env/components/flyout/manager/hooks.js +6 -0
  196. package/test-env/components/flyout/manager/index.js +12 -0
  197. package/test-env/components/flyout/manager/reducer.js +31 -7
  198. package/test-env/components/flyout/manager/selectors.js +9 -3
  199. package/test-env/components/flyout/manager/store.js +34 -1
  200. package/test-env/components/flyout/use_flyout_menu.js +2 -2
  201. package/test-env/components/form/form_control_layout/form_control_layout_icons.js +95 -139
  202. package/test-env/components/notification_icon/assets/info_fill.js +41 -0
  203. package/test-env/components/notification_icon/assets/warning_static.js +47 -0
  204. package/test-env/components/notification_icon/notification_icon.js +46 -0
  205. package/test-env/components/notification_icon/notification_icon.styles.js +28 -0
  206. package/test-env/components/table/mobile/table_sort_mobile.js +61 -98
  207. package/test-env/components/table/store/use_unique_column_id.js +34 -0
  208. package/test-env/components/table/table_header_cell.js +7 -8
  209. package/test-env/components/table/table_header_cell_checkbox.js +5 -6
  210. package/test-env/components/toast/global_toast_list.js +132 -6
  211. package/test-env/components/toast/global_toast_list.styles.js +30 -7
  212. package/test-env/components/toast/toast.js +242 -47
  213. package/test-env/components/toast/toast.styles.js +33 -45
  214. package/test-env/components/toast/toast_action.js +39 -0
  215. package/test-env/components/toast/types.js +15 -0
  216. package/test-env/components/tool_tip/tool_tip.js +57 -29
  217. package/test-env/components/tool_tip/tool_tip_anchor.js +5 -5
  218. package/test-env/components/tool_tip/tool_tip_manager.js +27 -2
@@ -1,6 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["title", "color", "iconType", "onClose", "children", "className"];
4
+ var _excluded = ["title", "text", "color", "iconType", "children", "className", "actionProps", "style", "onClose", "animationMs"];
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; }
6
+ 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
7
  /*
5
8
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
9
  * or more contributor license agreements. Licensed under the Elastic License
@@ -9,68 +12,161 @@ var _excluded = ["title", "color", "iconType", "onClose", "children", "className
9
12
  * Side Public License, v 1.
10
13
  */
11
14
 
12
- import React from 'react';
15
+ import React, { useMemo } from 'react';
13
16
  import classNames from 'classnames';
14
- import { useEuiMemoizedStyles } from '../../services';
17
+ import { getTokenName } from '@elastic/eui-theme-common';
18
+ import { useEuiMemoizedStyles, useEuiTheme } from '../../services';
15
19
  import { EuiScreenReaderOnly } from '../accessibility';
16
20
  import { EuiButtonIcon } from '../button';
17
21
  import { EuiI18n } from '../i18n';
18
22
  import { EuiIcon } from '../icon';
19
23
  import { EuiText } from '../text';
20
24
  import { euiToastStyles, euiToastHeaderStyles } from './toast.styles';
25
+ import { EuiNotificationIcon } from '../notification_icon/notification_icon';
26
+ import { euiNotificationIconStyles } from '../notification_icon/notification_icon.styles';
27
+ import { EuiToastAction } from './toast_action';
28
+ import { EuiTitle } from '../title';
21
29
  import { jsx as ___EmotionJSX } from "@emotion/react";
22
- export var COLORS = ['primary', 'success', 'warning', 'danger'];
30
+ export var COLOR_TO_NOTIFICATION_ICON_MAP = {
31
+ primary: 'info',
32
+ success: 'success',
33
+ warning: 'warning',
34
+ danger: 'error'
35
+ };
23
36
  export var EuiToast = function EuiToast(_ref) {
24
37
  var title = _ref.title,
25
- color = _ref.color,
38
+ text = _ref.text,
39
+ _ref$color = _ref.color,
40
+ color = _ref$color === void 0 ? 'primary' : _ref$color,
26
41
  iconType = _ref.iconType,
27
- onClose = _ref.onClose,
28
42
  children = _ref.children,
29
43
  className = _ref.className,
44
+ actionProps = _ref.actionProps,
45
+ style = _ref.style,
46
+ onClose = _ref.onClose,
47
+ animationMs = _ref.animationMs,
30
48
  rest = _objectWithoutProperties(_ref, _excluded);
31
- var baseStyles = useEuiMemoizedStyles(euiToastStyles);
32
- var baseCss = [baseStyles.euiToast, color && baseStyles.colors[color]];
49
+ var _useEuiTheme = useEuiTheme(),
50
+ euiTheme = _useEuiTheme.euiTheme;
51
+ var styles = useEuiMemoizedStyles(euiToastStyles);
52
+ var iconStyles = useEuiMemoizedStyles(euiNotificationIconStyles);
33
53
  var headerStyles = useEuiMemoizedStyles(euiToastHeaderStyles);
34
- var headerCss = [headerStyles.euiToastHeader, children && headerStyles.withBody];
35
- var classes = classNames('euiToast', className);
54
+ var cssStyles = [styles.euiToast];
55
+ var decorCssStyles = [styles.decor, animationMs && styles.hasAnimation];
56
+ var classes = classNames('euiToast', className, _defineProperty({}, "euiToast--".concat(color), color));
57
+ var highlightColorToken = getTokenName('borderStrong', color);
58
+ var typeColor = euiTheme.colors[highlightColorToken];
59
+ var backgroundLightToken = getTokenName('backgroundLight', color);
60
+ var backgroundLightColor = euiTheme.colors[backgroundLightToken];
61
+ var cssVariables = useMemo(function () {
62
+ return _objectSpread({
63
+ '--euiToastTypeColor': typeColor,
64
+ '--euiToastTypeBackgroundColor': backgroundLightColor
65
+ }, animationMs && {
66
+ '--euiToastAnimationMs': "".concat(animationMs, "ms")
67
+ });
68
+ }, [typeColor, backgroundLightColor, animationMs]);
69
+ var dismissButton = useMemo(function () {
70
+ if (!onClose) return;
71
+ return ___EmotionJSX(EuiI18n, {
72
+ token: "euiToast.dismissToast",
73
+ default: "Dismiss toast"
74
+ }, function (dismissToast) {
75
+ return ___EmotionJSX(EuiButtonIcon, {
76
+ css: styles.dismissButton,
77
+ iconType: "cross",
78
+ color: "text",
79
+ size: "xs",
80
+ "aria-label": dismissToast,
81
+ onClick: onClose,
82
+ "data-test-subj": "toastCloseButton"
83
+ });
84
+ });
85
+ }, [onClose, styles]);
86
+ var header = useMemo(function () {
87
+ if (!title) return;
88
+ var headerCssStyles = [headerStyles.euiToastHeader, onClose && headerStyles.hasDismissButton];
89
+ return ___EmotionJSX(EuiTitle, {
90
+ size: "xs",
91
+ css: headerCssStyles,
92
+ "data-test-subj": "euiToastHeader__title"
93
+ }, ___EmotionJSX("p", null, title));
94
+ }, [title, headerStyles, onClose]);
95
+ var icon = useMemo(function () {
96
+ if (!iconType) {
97
+ var _COLOR_TO_NOTIFICATIO;
98
+ var defaultIconType = (_COLOR_TO_NOTIFICATIO = COLOR_TO_NOTIFICATION_ICON_MAP[color]) !== null && _COLOR_TO_NOTIFICATIO !== void 0 ? _COLOR_TO_NOTIFICATIO : 'info';
99
+ return ___EmotionJSX(EuiNotificationIcon, {
100
+ css: styles.icon,
101
+ type: defaultIconType,
102
+ size: "l"
103
+ });
104
+ }
105
+ return ___EmotionJSX(EuiIcon, {
106
+ css: [styles.icon, iconStyles.size.l, ";label:icon;"],
107
+ type: iconType,
108
+ size: "l",
109
+ "aria-hidden": "true",
110
+ color: typeColor
111
+ });
112
+ }, [iconType, color, typeColor, styles, iconStyles]);
113
+ var optionalChildren = useMemo(function () {
114
+ if (!text && !children) return null;
115
+ return ___EmotionJSX("div", {
116
+ css: styles.text,
117
+ "data-test-subj": "euiToastBody"
118
+ }, text && ___EmotionJSX(EuiText, {
119
+ size: "s",
120
+ color: "default",
121
+ className: "euiToast__text",
122
+ "data-test-subj": "euiToastText"
123
+ }, text), children && ___EmotionJSX(EuiText, {
124
+ className: "euiToast__additionalContent",
125
+ size: "s",
126
+ color: "default",
127
+ "data-test-subj": "euiToastAdditionalContent"
128
+ }, children));
129
+ }, [text, children, styles]);
130
+ var actionControls = useMemo(function () {
131
+ var actionPrimaryProps = _objectSpread(_objectSpread({}, actionProps === null || actionProps === void 0 ? void 0 : actionProps.primary), {}, {
132
+ color: color
133
+ });
134
+ var actionSecondaryProps = _objectSpread(_objectSpread({}, actionProps === null || actionProps === void 0 ? void 0 : actionProps.secondary), {}, {
135
+ color: color
136
+ });
137
+ var hasActionPrimary = Boolean(actionProps === null || actionProps === void 0 ? void 0 : actionProps.primary);
138
+ var hasActionSecondary = Boolean(actionProps === null || actionProps === void 0 ? void 0 : actionProps.secondary);
139
+ if (!hasActionPrimary && !hasActionSecondary) return null;
140
+ var actionPrimary = hasActionPrimary && ___EmotionJSX(EuiToastAction, _extends({
141
+ actionType: "primary"
142
+ }, actionPrimaryProps));
143
+ var actionSecondary = hasActionSecondary && ___EmotionJSX(EuiToastAction, _extends({
144
+ actionType: "secondary"
145
+ }, actionSecondaryProps));
146
+ return ___EmotionJSX("div", {
147
+ css: styles.actions
148
+ }, actionPrimary, actionSecondary);
149
+ }, [actionProps, color, styles]);
36
150
  return ___EmotionJSX("div", _extends({
37
- css: baseCss,
38
- className: classes
39
- }, rest), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", null, ___EmotionJSX(EuiI18n, {
151
+ css: cssStyles,
152
+ className: classes,
153
+ style: _objectSpread(_objectSpread({}, cssVariables), style)
154
+ }, rest), ___EmotionJSX("div", {
155
+ className: "euiToastDecor",
156
+ css: decorCssStyles,
157
+ role: "presentation"
158
+ }), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", null, ___EmotionJSX(EuiI18n, {
40
159
  token: "euiToast.newNotification",
41
160
  default: "A new notification appears"
42
- }))), ___EmotionJSX(EuiI18n, {
43
- token: "euiToast.notification",
44
- default: "Notification"
45
- }, function (notification) {
46
- return ___EmotionJSX("div", {
47
- css: headerCss,
48
- "aria-label": notification,
49
- "data-test-subj": "euiToastHeader"
50
- }, iconType && ___EmotionJSX(EuiIcon, {
51
- css: headerStyles.euiToastHeader__icon,
52
- type: iconType,
53
- size: "m",
54
- "aria-hidden": "true"
55
- }), ___EmotionJSX("span", {
56
- css: headerStyles.euiToastHeader__title,
57
- "data-test-subj": "euiToastHeader__title"
58
- }, title));
59
- }), onClose && ___EmotionJSX(EuiI18n, {
60
- token: "euiToast.dismissToast",
61
- default: "Dismiss toast"
62
- }, function (dismissToast) {
63
- return ___EmotionJSX(EuiButtonIcon, {
64
- css: baseStyles.euiToast__closeButton,
65
- iconType: "cross",
66
- color: "text",
67
- size: "xs",
68
- "aria-label": dismissToast,
69
- onClick: onClose,
70
- "data-test-subj": "toastCloseButton"
71
- });
72
- }), children && ___EmotionJSX(EuiText, {
73
- size: "s",
74
- "data-test-subj": "euiToastBody"
75
- }, children));
161
+ }))), ___EmotionJSX("div", {
162
+ css: styles.wrapper
163
+ }, ___EmotionJSX("div", {
164
+ css: styles.body
165
+ }, icon, ___EmotionJSX("div", {
166
+ css: styles.content
167
+ },
168
+ // Note: the DOM position of the dismiss button matters to screen reader users.
169
+ // We generally want them to have some context of _what_ they're dismissing,
170
+ // instead of navigating to the dismiss button first before the content
171
+ header && optionalChildren ? ___EmotionJSX(React.Fragment, null, header, dismissButton, optionalChildren) : ___EmotionJSX(React.Fragment, null, header || optionalChildren, dismissButton))), actionControls));
76
172
  };
@@ -1,3 +1,5 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
1
3
  /*
2
4
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
5
  * or more contributor license agreements. Licensed under the Elastic License
@@ -6,65 +8,51 @@
6
8
  * Side Public License, v 1.
7
9
  */
8
10
 
9
- import { css } from '@emotion/react';
10
- import { euiShadowLarge, mathWithUnits } from '@elastic/eui-theme-common';
11
+ import { css, keyframes } from '@emotion/react';
12
+ import { euiCanAnimate, euiShadowLarge, mathWithUnits } from '@elastic/eui-theme-common';
11
13
  import { euiTextBreakWord, logicalCSS } from '../../global_styling';
12
- import { highContrastModeStyles, preventForcedColors } from '../../global_styling/functions/high_contrast';
14
+ import { preventForcedColors } from '../../global_styling/functions/high_contrast';
13
15
  import { euiTitle } from '../title/title.styles';
14
16
  import { euiPanelBorderStyles } from '../panel/panel.styles';
17
+ var TEXT_MAX_WIDTH = 1200;
18
+ var CONTAINER_NAME = 'euiToast';
19
+ var CQC_BREAKPOINT_NARROWEST = '(max-width: 320px)';
20
+ var euiToastAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n transform: scaleX(1);\n }\n to {\n transform: scaleX(0);\n }\n"])));
15
21
  export var euiToastStyles = function euiToastStyles(euiThemeContext) {
16
- var euiTheme = euiThemeContext.euiTheme,
17
- highContrastMode = euiThemeContext.highContrastMode;
18
- var highlightStyles = function highlightStyles(color, width) {
19
- return "\n &:before {\n content: '';\n position: absolute;\n /* ensure highlight border is on top of panel border */\n z-index: 1;\n inset: 0;\n border-radius: inherit;\n ".concat(logicalCSS('border-top', "".concat(width, " solid ").concat(color)), "\n pointer-events: none;\n }\n ");
20
- };
22
+ var euiTheme = euiThemeContext.euiTheme;
23
+ var highlightSize = mathWithUnits([euiTheme.border.width.thin, euiTheme.border.width.thick], function (x, y) {
24
+ return x + y;
25
+ });
26
+ var paddingTop = mathWithUnits([euiTheme.size.base, highlightSize], function (x, y) {
27
+ return x + y;
28
+ });
29
+ var offsetTop = mathWithUnits([euiTheme.size.s, highlightSize], function (x, y) {
30
+ return x + y;
31
+ });
21
32
  return {
22
33
  // Base
23
- euiToast: /*#__PURE__*/css("border-radius:", euiTheme.border.radius.medium, ";", euiShadowLarge(euiThemeContext, {
34
+ euiToast: /*#__PURE__*/css("container-type:inline-size;container-name:", CONTAINER_NAME, ";position:relative;overflow:hidden;border-radius:", euiTheme.border.radius.medium, ";", euiShadowLarge(euiThemeContext, {
24
35
  borderAllInHighContrastMode: true
25
- }), " position:relative;", logicalCSS('padding-horizontal', euiTheme.size.base), " ", logicalCSS('padding-vertical', euiTheme.size.base), " background-color:", euiTheme.colors.emptyShade, ";", logicalCSS('width', '100%'), " ", euiTextBreakWord(), euiPanelBorderStyles(euiThemeContext), " &:hover,&:focus{[class*='euiToast__closeButton']{opacity:1;}};label:euiToast;"),
26
- // Elements
27
- euiToast__closeButton: /*#__PURE__*/css("position:absolute;", logicalCSS('top', euiTheme.size.base), " ", logicalCSS('right', euiTheme.size.base), ";;label:euiToast__closeButton;"),
28
- // Variants
29
- colors: {
30
- _getStyles: function _getStyles(color) {
31
- // Increase color/border thickness for all high contrast modes
32
- var borderWidth = highContrastMode ? mathWithUnits(euiTheme.border.width.thick, function (x) {
33
- return x * 2;
34
- }) : euiTheme.border.width.thick;
35
- return highContrastModeStyles(euiThemeContext, {
36
- none: highlightStyles(color, borderWidth),
37
- preferred: "\n ".concat(highlightStyles(color, borderWidth), "\n \n &::before {\n ").concat(logicalCSS('width', "calc(100% + ".concat(mathWithUnits(euiTheme.border.width.thin, function (x) {
38
- return x * 2;
39
- }), ")")), "\n ").concat(logicalCSS('margin-top', "-".concat(euiTheme.border.width.thin)), "\n ").concat(logicalCSS('margin-left', "-".concat(euiTheme.border.width.thin)), "\n }\n "),
40
- // Windows high contrast mode ignores/overrides border colors, which have semantic meaning here. To get around this, we'll use a pseudo element that ignores forced colors
41
- forced: "\n overflow: hidden;\n\n &::before {\n content: '';\n position: absolute;\n ".concat(logicalCSS('top', 0), "\n ").concat(logicalCSS('horizontal', 0), "\n ").concat(logicalCSS('height', borderWidth), "\n background-color: ").concat(color, ";\n ").concat(preventForcedColors(euiThemeContext), "\n pointer-events: none;\n }\n ")
42
- });
43
- },
44
- get primary() {
45
- return /*#__PURE__*/css(this._getStyles(euiTheme.colors.primary), ";label:primary;");
46
- },
47
- get success() {
48
- return /*#__PURE__*/css(this._getStyles(euiTheme.colors.success), ";label:success;");
49
- },
50
- get warning() {
51
- return /*#__PURE__*/css(this._getStyles(euiTheme.colors.warning), ";label:warning;");
52
- },
53
- get danger() {
54
- return /*#__PURE__*/css(this._getStyles(euiTheme.colors.danger), ";label:danger;");
55
- }
56
- }
36
+ }), " ", logicalCSS('padding-top', paddingTop), " ", logicalCSS('padding-bottom', euiTheme.size.base), " ", logicalCSS('padding-horizontal', euiTheme.size.base), " background-color:", euiTheme.colors.backgroundBasePlain, ";", logicalCSS('width', '100%'), " ", euiTextBreakWord(), euiPanelBorderStyles(euiThemeContext), ";;label:euiToast;"),
37
+ decor: /*#__PURE__*/css("position:absolute;inset-block-start:0;inset-inline:0;", logicalCSS('height', highlightSize), " background-color:var(--euiToastTypeBackgroundColor);", preventForcedColors(euiThemeContext), " &::before{content:'';position:absolute;z-index:", euiTheme.levels.content, ";inset-block-start:0;inset-inline:0;", logicalCSS('height', '100%'), " background-color:var(--euiToastTypeColor);pointer-events:none;", preventForcedColors(euiThemeContext), " transform-origin:left center;[dir='rtl'] &{transform-origin:right center;}};label:decor;"),
38
+ // handles content + actions layout
39
+ wrapper: /*#__PURE__*/css("display:flex;flex-direction:column;gap:", euiTheme.size.m, ";inline-size:100%;;label:wrapper;"),
40
+ // handles icon + text layout
41
+ body: /*#__PURE__*/css("display:flex;flex-direction:row;align-self:center;gap:", euiTheme.size.m, ";inline-size:100%;;label:body;"),
42
+ // handles text layout
43
+ content: /*#__PURE__*/css("display:flex;flex-direction:column;gap:", euiTheme.size.xs, ";align-self:center;inline-size:100%;max-inline-size:", TEXT_MAX_WIDTH, "px;.euiToast__text+.euiToast__additionalContent{", logicalCSS('margin-top', euiTheme.size.s), ";};label:content;"),
44
+ text: /*#__PURE__*/css("display:flex;flex-direction:column;gap:", euiTheme.size.xs, ";;label:text;"),
45
+ icon: /*#__PURE__*/css("grid-area:icon;position:relative;", logicalCSS('margin-vertical', euiTheme.size.xxs), ";;label:icon;"),
46
+ actions: /*#__PURE__*/css("grid-area:actions;display:flex;gap:", euiTheme.size.s, ";", logicalCSS('margin-left', euiTheme.size.xl), "@container ", CONTAINER_NAME, " ", CQC_BREAKPOINT_NARROWEST, "{flex-wrap:wrap;>*{inline-size:100%;}};label:actions;"),
47
+ dismissButton: /*#__PURE__*/css("position:absolute;", logicalCSS('top', offsetTop), ";", logicalCSS('right', euiTheme.size.s), ";;label:dismissButton;"),
48
+ hasAnimation: /*#__PURE__*/css("&::before{", euiCanAnimate, "{animation:", euiToastAnimation, " var(--euiToastAnimationMs) linear forwards;}};label:hasAnimation;")
57
49
  };
58
50
  };
59
51
  export var euiToastHeaderStyles = function euiToastHeaderStyles(euiThemeContext) {
60
52
  var euiTheme = euiThemeContext.euiTheme;
61
53
  return {
62
54
  // Base
63
- euiToastHeader: /*#__PURE__*/css("display:flex;align-items:baseline;", logicalCSS('padding-right', euiTheme.size.l), ">*+*{", logicalCSS('margin-left', euiTheme.size.s), ";};label:euiToastHeader;"),
64
- // Elements
65
- euiToastHeader__icon: /*#__PURE__*/css("flex:0 0 auto;fill:", euiTheme.colors.textHeading, ";transform:translateY(2px);;label:euiToastHeader__icon;"),
66
- euiToastHeader__title: /*#__PURE__*/css(euiTitle(euiThemeContext, 'xs'), " font-weight:", euiTheme.font.weight.bold, ";;label:euiToastHeader__title;"),
67
- // Variants
68
- withBody: /*#__PURE__*/css(logicalCSS('margin-bottom', euiTheme.size.s), ";;label:withBody;")
55
+ euiToastHeader: /*#__PURE__*/css("display:flex;align-items:baseline;", euiTitle(euiThemeContext, 'xs'), " font-weight:", euiTheme.font.weight.bold, ";;label:euiToastHeader;"),
56
+ hasDismissButton: /*#__PURE__*/css("padding-inline-end:", euiTheme.size.l, ";;label:hasDismissButton;")
69
57
  };
70
58
  };
@@ -0,0 +1,33 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["children", "actionType", "color"];
4
+ /*
5
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
+ * or more contributor license agreements. Licensed under the Elastic License
7
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
8
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
9
+ * Side Public License, v 1.
10
+ */
11
+
12
+ import React from 'react';
13
+ import { EuiButton, EuiButtonEmpty } from '../button';
14
+ import { jsx as ___EmotionJSX } from "@emotion/react";
15
+ export var EuiToastAction = function EuiToastAction(_ref) {
16
+ var children = _ref.children,
17
+ _ref$actionType = _ref.actionType,
18
+ actionType = _ref$actionType === void 0 ? 'primary' : _ref$actionType,
19
+ _ref$color = _ref.color,
20
+ color = _ref$color === void 0 ? 'primary' : _ref$color,
21
+ rest = _objectWithoutProperties(_ref, _excluded);
22
+ if (actionType === 'primary') {
23
+ return ___EmotionJSX(EuiButton, _extends({
24
+ size: "s",
25
+ color: color
26
+ }, rest), children);
27
+ } else {
28
+ return ___EmotionJSX(EuiButtonEmpty, _extends({
29
+ size: "s",
30
+ color: color
31
+ }, rest), children);
32
+ }
33
+ };
@@ -0,0 +1,9 @@
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
+ export var COLORS = ['primary', 'success', 'warning', 'danger'];
@@ -1,7 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
5
  var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "display", "repositionOnScroll", "disableScreenReaderOutput", "position", "offset", "id", "onMouseOut", "onBlur"];
6
+ 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; }
7
+ 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; }
5
8
  /*
6
9
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
10
  * or more contributor license agreements. Licensed under the Elastic License
@@ -12,7 +15,7 @@ var _excluded = ["children", "className", "anchorClassName", "anchorProps", "con
12
15
 
13
16
  import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
14
17
  import classNames from 'classnames';
15
- import { findPopoverPosition, htmlIdGenerator, keys } from '../../services';
18
+ import { findPopoverPosition, useGeneratedHtmlId, keys } from '../../services';
16
19
  import { getRepositionOnScroll } from '../../services/popover/reposition_on_scroll';
17
20
  import { EuiResizeObserver } from '../observer/resize_observer';
18
21
  import { EuiPortal } from '../portal';
@@ -75,22 +78,26 @@ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
75
78
  setVisible = _useState2[1];
76
79
  var _useState3 = useState(false),
77
80
  _useState4 = _slicedToArray(_useState3, 2),
78
- hasFocus = _useState4[0],
79
- setHasFocus = _useState4[1];
80
- var _useState5 = useState(positionProp),
81
+ skipAnimation = _useState4[0],
82
+ setSkipAnimation = _useState4[1];
83
+ var _useState5 = useState(false),
81
84
  _useState6 = _slicedToArray(_useState5, 2),
82
- calculatedPosition = _useState6[0],
83
- setCalculatedPosition = _useState6[1];
84
- var _useState7 = useState(DEFAULT_TOOLTIP_STYLES),
85
+ hasFocus = _useState6[0],
86
+ setHasFocus = _useState6[1];
87
+ var _useState7 = useState(positionProp),
85
88
  _useState8 = _slicedToArray(_useState7, 2),
86
- toolTipStyles = _useState8[0],
87
- setToolTipStyles = _useState8[1];
88
- var _useState9 = useState(undefined),
89
+ calculatedPosition = _useState8[0],
90
+ setCalculatedPosition = _useState8[1];
91
+ var _useState9 = useState(DEFAULT_TOOLTIP_STYLES),
89
92
  _useState10 = _slicedToArray(_useState9, 2),
90
- arrowStyles = _useState10[0],
91
- setArrowStyles = _useState10[1];
92
- var generatedId = useRef(htmlIdGenerator()());
93
- var id = idProp !== null && idProp !== void 0 ? idProp : generatedId.current;
93
+ toolTipStyles = _useState10[0],
94
+ setToolTipStyles = _useState10[1];
95
+ var _useState11 = useState(undefined),
96
+ _useState12 = _slicedToArray(_useState11, 2),
97
+ arrowStyles = _useState12[0],
98
+ setArrowStyles = _useState12[1];
99
+ var generatedId = useGeneratedHtmlId();
100
+ var id = idProp !== null && idProp !== void 0 ? idProp : generatedId;
94
101
  var anchorRef = useRef(null);
95
102
  var popoverRef = useRef(null);
96
103
  var positionToolTip = useCallback(function () {
@@ -142,10 +149,19 @@ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
142
149
  setArrowStyles(undefined);
143
150
  toolTipManager.deregisterToolTip(hideToolTip);
144
151
  }, []);
152
+
153
+ /**
154
+ * Show the tooltip.
155
+ *
156
+ * Uses the tooltip manager's `skipAnimation` signal to optionally skip the entry
157
+ * animation when another tooltip is already open or was just closed.
158
+ */
145
159
  var showToolTip = useCallback(function () {
146
160
  if (!content && !title) return;
161
+ var result = toolTipManager.registerTooltip(hideToolTip);
162
+ if (!result) return;
163
+ setSkipAnimation(result.skipAnimation);
147
164
  setVisible(true);
148
- toolTipManager.registerTooltip(hideToolTip);
149
165
  }, [content, title, hideToolTip]);
150
166
  useImperativeHandle(ref, function () {
151
167
  return {
@@ -225,18 +241,24 @@ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
225
241
  hideToolTip();
226
242
  }
227
243
  }, [disableScreenReaderOutput, visible, hideToolTip]);
228
- var onMouseOut = useCallback(function (event) {
229
- // Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
230
- // left the anchor for a non-child.
231
- if (anchorRef.current === event.relatedTarget || anchorRef.current != null && !anchorRef.current.contains(event.relatedTarget)) {
232
- if (!hasFocus) {
233
- hideToolTip();
234
- }
235
- }
236
- if (onMouseOutProp) {
237
- onMouseOutProp(event);
238
- }
239
- }, [hasFocus, hideToolTip, onMouseOutProp]);
244
+
245
+ /**
246
+ * Show the tooltip on enter.
247
+ */
248
+ var onMouseEnter = useCallback(function (event) {
249
+ var _anchorProps$onMouseE;
250
+ showToolTip();
251
+ anchorProps === null || anchorProps === void 0 || (_anchorProps$onMouseE = anchorProps.onMouseEnter) === null || _anchorProps$onMouseE === void 0 || _anchorProps$onMouseE.call(anchorProps, event);
252
+ }, [showToolTip, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.onMouseEnter]);
253
+
254
+ /**
255
+ * Hide the tooltip if the mouse is not over the trigger.
256
+ */
257
+ var onMouseLeave = useCallback(function (event) {
258
+ var _anchorProps$onMouseL;
259
+ if (!hasFocus) hideToolTip();
260
+ anchorProps === null || anchorProps === void 0 || (_anchorProps$onMouseL = anchorProps.onMouseLeave) === null || _anchorProps$onMouseL === void 0 || _anchorProps$onMouseL.call(anchorProps, event);
261
+ }, [hasFocus, hideToolTip, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.onMouseLeave]);
240
262
  var classes = classNames('euiToolTip', className);
241
263
  var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
242
264
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
@@ -244,8 +266,9 @@ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
244
266
  onBlur: onBlur,
245
267
  onFocus: onFocus,
246
268
  onKeyDown: onEscapeKey,
247
- onMouseOver: showToolTip,
248
- onMouseOut: onMouseOut
269
+ onMouseEnter: onMouseEnter,
270
+ onMouseLeave: onMouseLeave,
271
+ onMouseOut: onMouseOutProp
249
272
  // `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
250
273
  ,
251
274
  id: !disableScreenReaderOutput ? id : undefined,
@@ -254,7 +277,12 @@ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
254
277
  isVisible: visible
255
278
  }), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
256
279
  className: classes,
257
- style: toolTipStyles,
280
+ style: _objectSpread(_objectSpread({}, toolTipStyles), {}, {
281
+ // Inline `animation: none` overrides the keyframes fade-in
282
+ // shorthand on the base `.euiToolTip` class, so a tooltip
283
+ // shown right after another closes appears instantly.
284
+ animation: skipAnimation ? 'none' : undefined
285
+ }),
258
286
  positionToolTip: positionToolTip,
259
287
  popoverRef: setPopoverRef,
260
288
  title: title,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["onBlur", "onFocus", "onMouseOver", "onMouseOut", "id", "className", "children", "display", "isVisible"];
3
+ var _excluded = ["onBlur", "onFocus", "onMouseEnter", "onMouseLeave", "id", "className", "children", "display", "isVisible"];
4
4
  /*
5
5
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
6
  * or more contributor license agreements. Licensed under the Elastic License
@@ -17,8 +17,8 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
17
17
  export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
18
  var _onBlur = _ref.onBlur,
19
19
  _onFocus = _ref.onFocus,
20
- onMouseOver = _ref.onMouseOver,
21
- onMouseOut = _ref.onMouseOut,
20
+ onMouseEnter = _ref.onMouseEnter,
21
+ onMouseLeave = _ref.onMouseLeave,
22
22
  id = _ref.id,
23
23
  className = _ref.className,
24
24
  children = _ref.children,
@@ -42,8 +42,8 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
42
42
  id: anchorId
43
43
  }, rest, {
44
44
  className: classes,
45
- onMouseOver: onMouseOver,
46
- onMouseOut: onMouseOut
45
+ onMouseEnter: onMouseEnter,
46
+ onMouseLeave: onMouseLeave
47
47
  }), /*#__PURE__*/cloneElement(children, {
48
48
  onFocus: function onFocus(e) {
49
49
  _onFocus(e);
@@ -8,29 +8,54 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  * in compliance with, at your election, the Elastic License 2.0 or the Server
9
9
  * Side Public License, v 1.
10
10
  */
11
+
11
12
  /**
12
13
  * Manager utility that ensures only one tooltip is visible at a time
14
+ * and lets the next tooltip to open skip its entry animation if another was
15
+ * just opened or just closed.
13
16
  *
14
17
  * UX rationale (primarily for mouse-only users):
15
18
  * @see https://github.com/elastic/kibana/issues/144482
16
19
  * @see https://github.com/elastic/eui/issues/5883
17
20
  */
21
+
22
+ /**
23
+ * Time window in ms after a tooltip closes during which the next one to open
24
+ * skips its entry animation.
25
+ */
26
+ var SKIP_ANIMATION_WINDOW = 300;
18
27
  var ToolTipManager = /*#__PURE__*/_createClass(function ToolTipManager() {
19
28
  var _this = this;
20
29
  _classCallCheck(this, ToolTipManager);
21
30
  // We use a set instead of a single var just in case
22
31
  // multiple tooltips are registered via async shenanigans
23
32
  _defineProperty(this, "toolTipsToHide", new Set());
33
+ // Timestamp of the last hide; `null` means no tooltip has closed yet.
34
+ _defineProperty(this, "lastHiddenAt", null);
24
35
  _defineProperty(this, "registerTooltip", function (hideCallback) {
25
- if (_this.toolTipsToHide.has(hideCallback)) return;
36
+ if (_this.toolTipsToHide.has(hideCallback)) return null;
37
+ var hadOpen = _this.toolTipsToHide.size > 0;
38
+ var recentlyClosed = _this.lastHiddenAt !== null && Date.now() - _this.lastHiddenAt < SKIP_ANIMATION_WINDOW;
26
39
  _this.toolTipsToHide.forEach(function (hide) {
27
40
  return hide();
28
41
  });
29
42
  _this.toolTipsToHide.clear();
30
43
  _this.toolTipsToHide.add(hideCallback);
44
+ return {
45
+ skipAnimation: hadOpen || recentlyClosed
46
+ };
31
47
  });
32
48
  _defineProperty(this, "deregisterToolTip", function (hideCallback) {
33
- _this.toolTipsToHide.delete(hideCallback);
49
+ if (_this.toolTipsToHide.delete(hideCallback)) _this.lastHiddenAt = Date.now();
50
+ });
51
+ /**
52
+ * Resets all internal state. Primarily intended for tests, so that a
53
+ * tooltip shown in one test doesn't leak into the next (the manager is a
54
+ * module-level singleton).
55
+ */
56
+ _defineProperty(this, "reset", function () {
57
+ _this.toolTipsToHide.clear();
58
+ _this.lastHiddenAt = null;
34
59
  });
35
60
  });
36
61
  export var toolTipManager = new ToolTipManager();
@@ -74,6 +74,7 @@ var EuiAvatar = exports.EuiAvatar = function EuiAvatar(_ref) {
74
74
  var classes = (0, _classnames.default)('euiAvatar', (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, "euiAvatar--".concat(size), size), "euiAvatar--".concat(type), type), 'euiAvatar-isDisabled', isDisabled), className);
75
75
  var styles = (0, _services.useEuiMemoizedStyles)(_avatar.euiAvatarStyles);
76
76
  var cssStyles = [styles.euiAvatar, styles[type], styles[size], styles[casing], isPlain && styles.plain, isSubdued && styles.subdued, isDisabled && styles.isDisabled];
77
+ var tooltipCssStyles = [styles.tooltip[type]];
77
78
  var avatarStyle = (0, _react.useMemo)(function () {
78
79
  if (imageUrl) {
79
80
  return {
@@ -128,6 +129,9 @@ var EuiAvatar = exports.EuiAvatar = function EuiAvatar(_ref) {
128
129
  // It already has `aria-label`, the tooltip is only visual.
129
130
  return name ? (0, _react2.jsx)(_tool_tip.EuiToolTip, {
130
131
  content: name,
132
+ anchorProps: {
133
+ css: tooltipCssStyles
134
+ },
131
135
  disableScreenReaderOutput: true
132
136
  }, avatarNode) : avatarNode;
133
137
  };