@elastic/eui 114.2.0 → 115.0.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 (163) hide show
  1. package/es/components/basic_table/basic_table.js +3 -6
  2. package/es/components/basic_table/collapsed_item_actions.js +1 -3
  3. package/es/components/basic_table/default_item_action.js +0 -1
  4. package/es/components/basic_table/in_memory_table.js +3 -6
  5. package/es/components/color_picker/color_picker_swatch.js +1 -2
  6. package/es/components/datagrid/controls/display_selector.js +1 -2
  7. package/es/components/datagrid/controls/fullscreen_selector.js +1 -2
  8. package/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
  9. package/es/components/datagrid/utils/scrolling.js +7 -1
  10. package/es/components/filter_group/filter_select_item.js +36 -17
  11. package/es/components/flyout/flyout.component.js +8 -7
  12. package/es/components/flyout/hooks.js +11 -3
  13. package/es/components/flyout/manager/flyout_main.js +4 -2
  14. package/es/components/icon/assets/chart_pie.js +1 -2
  15. package/es/components/icon/assets/product_dashboard.js +5 -3
  16. package/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
  17. package/es/components/list_group/list_group_item.js +1 -2
  18. package/es/components/markdown_editor/markdown_editor.js +1 -1
  19. package/es/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
  20. package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
  21. package/es/components/markdown_editor/markdown_editor_toolbar.js +14 -10
  22. package/es/components/portal/portal.js +72 -117
  23. package/es/components/search_bar/filters/field_value_toggle_group_filter.js +42 -91
  24. package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
  25. package/es/components/steps/step_horizontal.js +8 -5
  26. package/es/components/table/table_header_cell.js +1 -2
  27. package/es/components/tool_tip/icon_tip.js +4 -8
  28. package/es/components/tool_tip/tool_tip.js +233 -261
  29. package/es/components/tool_tip/tool_tip.styles.js +10 -18
  30. package/es/components/tool_tip/tool_tip_anchor.js +3 -3
  31. package/es/components/tool_tip/tool_tip_manager.js +1 -0
  32. package/es/components/tool_tip/tool_tip_popover.js +7 -7
  33. package/es/test/rtl/component_helpers.d.ts +0 -3
  34. package/es/test/rtl/component_helpers.js +40 -62
  35. package/eui.d.ts +29 -98
  36. package/lib/components/basic_table/basic_table.js +3 -6
  37. package/lib/components/basic_table/collapsed_item_actions.js +1 -3
  38. package/lib/components/basic_table/default_item_action.js +0 -1
  39. package/lib/components/basic_table/in_memory_table.js +3 -6
  40. package/lib/components/color_picker/color_picker_swatch.js +1 -2
  41. package/lib/components/datagrid/controls/display_selector.js +1 -2
  42. package/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
  43. package/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
  44. package/lib/components/datagrid/utils/scrolling.js +7 -1
  45. package/lib/components/filter_group/filter_select_item.js +35 -16
  46. package/lib/components/flyout/flyout.component.js +8 -7
  47. package/lib/components/flyout/hooks.js +10 -2
  48. package/lib/components/flyout/manager/flyout_main.js +3 -1
  49. package/lib/components/icon/assets/chart_pie.js +1 -2
  50. package/lib/components/icon/assets/product_dashboard.js +5 -3
  51. package/lib/components/icon/svgs/chart_pie.svg +1 -1
  52. package/lib/components/icon/svgs/product_dashboard.svg +4 -5
  53. package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
  54. package/lib/components/list_group/list_group_item.js +1 -2
  55. package/lib/components/markdown_editor/markdown_editor.js +1 -1
  56. package/lib/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
  57. package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
  58. package/lib/components/markdown_editor/markdown_editor_toolbar.js +12 -10
  59. package/lib/components/portal/portal.js +73 -118
  60. package/lib/components/search_bar/filters/field_value_toggle_group_filter.js +44 -93
  61. package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
  62. package/lib/components/steps/step_horizontal.js +8 -5
  63. package/lib/components/table/table_header_cell.js +1 -2
  64. package/lib/components/tool_tip/icon_tip.js +4 -8
  65. package/lib/components/tool_tip/tool_tip.js +240 -266
  66. package/lib/components/tool_tip/tool_tip.styles.js +8 -16
  67. package/lib/components/tool_tip/tool_tip_anchor.js +2 -2
  68. package/lib/components/tool_tip/tool_tip_manager.js +1 -0
  69. package/lib/components/tool_tip/tool_tip_popover.js +6 -6
  70. package/lib/test/rtl/component_helpers.d.ts +0 -3
  71. package/lib/test/rtl/component_helpers.js +41 -63
  72. package/optimize/es/components/basic_table/collapsed_item_actions.js +1 -3
  73. package/optimize/es/components/basic_table/default_item_action.js +0 -1
  74. package/optimize/es/components/datagrid/controls/display_selector.js +1 -2
  75. package/optimize/es/components/datagrid/controls/fullscreen_selector.js +1 -2
  76. package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
  77. package/optimize/es/components/datagrid/utils/scrolling.js +7 -1
  78. package/optimize/es/components/filter_group/filter_select_item.js +36 -17
  79. package/optimize/es/components/flyout/flyout.component.js +8 -7
  80. package/optimize/es/components/flyout/hooks.js +11 -3
  81. package/optimize/es/components/flyout/manager/flyout_main.js +4 -2
  82. package/optimize/es/components/icon/assets/chart_pie.js +1 -2
  83. package/optimize/es/components/icon/assets/product_dashboard.js +5 -3
  84. package/optimize/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
  85. package/optimize/es/components/list_group/list_group_item.js +1 -2
  86. package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
  87. package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +13 -9
  88. package/optimize/es/components/portal/portal.js +65 -91
  89. package/optimize/es/components/search_bar/filters/field_value_toggle_group_filter.js +43 -66
  90. package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
  91. package/optimize/es/components/steps/step_horizontal.js +8 -5
  92. package/optimize/es/components/tool_tip/icon_tip.js +3 -5
  93. package/optimize/es/components/tool_tip/tool_tip.js +227 -250
  94. package/optimize/es/components/tool_tip/tool_tip.styles.js +10 -18
  95. package/optimize/es/components/tool_tip/tool_tip_anchor.js +3 -3
  96. package/optimize/es/components/tool_tip/tool_tip_manager.js +1 -0
  97. package/optimize/es/components/tool_tip/tool_tip_popover.js +7 -7
  98. package/optimize/es/test/rtl/component_helpers.d.ts +0 -3
  99. package/optimize/es/test/rtl/component_helpers.js +40 -62
  100. package/optimize/lib/components/basic_table/collapsed_item_actions.js +1 -3
  101. package/optimize/lib/components/basic_table/default_item_action.js +0 -1
  102. package/optimize/lib/components/datagrid/controls/display_selector.js +1 -2
  103. package/optimize/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
  104. package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
  105. package/optimize/lib/components/datagrid/utils/scrolling.js +7 -1
  106. package/optimize/lib/components/filter_group/filter_select_item.js +35 -16
  107. package/optimize/lib/components/flyout/flyout.component.js +8 -7
  108. package/optimize/lib/components/flyout/hooks.js +10 -2
  109. package/optimize/lib/components/flyout/manager/flyout_main.js +3 -1
  110. package/optimize/lib/components/icon/assets/chart_pie.js +1 -2
  111. package/optimize/lib/components/icon/assets/product_dashboard.js +5 -3
  112. package/optimize/lib/components/icon/svgs/chart_pie.svg +1 -1
  113. package/optimize/lib/components/icon/svgs/product_dashboard.svg +4 -5
  114. package/optimize/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
  115. package/optimize/lib/components/list_group/list_group_item.js +1 -2
  116. package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
  117. package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +13 -9
  118. package/optimize/lib/components/portal/portal.js +68 -93
  119. package/optimize/lib/components/search_bar/filters/field_value_toggle_group_filter.js +45 -69
  120. package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
  121. package/optimize/lib/components/steps/step_horizontal.js +8 -5
  122. package/optimize/lib/components/tool_tip/icon_tip.js +3 -5
  123. package/optimize/lib/components/tool_tip/tool_tip.js +229 -251
  124. package/optimize/lib/components/tool_tip/tool_tip.styles.js +8 -16
  125. package/optimize/lib/components/tool_tip/tool_tip_anchor.js +2 -2
  126. package/optimize/lib/components/tool_tip/tool_tip_manager.js +1 -0
  127. package/optimize/lib/components/tool_tip/tool_tip_popover.js +6 -6
  128. package/optimize/lib/test/rtl/component_helpers.d.ts +0 -3
  129. package/optimize/lib/test/rtl/component_helpers.js +41 -63
  130. package/package.json +2 -10
  131. package/test-env/components/basic_table/basic_table.js +3 -6
  132. package/test-env/components/basic_table/collapsed_item_actions.js +1 -3
  133. package/test-env/components/basic_table/default_item_action.js +0 -1
  134. package/test-env/components/basic_table/in_memory_table.js +3 -6
  135. package/test-env/components/color_picker/color_picker_swatch.js +1 -2
  136. package/test-env/components/datagrid/controls/display_selector.js +1 -2
  137. package/test-env/components/datagrid/controls/fullscreen_selector.js +1 -2
  138. package/test-env/components/datagrid/controls/keyboard_shortcuts.js +1 -2
  139. package/test-env/components/datagrid/utils/scrolling.js +7 -1
  140. package/test-env/components/filter_group/filter_select_item.js +35 -16
  141. package/test-env/components/flyout/flyout.component.js +8 -7
  142. package/test-env/components/flyout/hooks.js +10 -2
  143. package/test-env/components/flyout/manager/flyout_main.js +3 -1
  144. package/test-env/components/icon/assets/chart_pie.js +1 -2
  145. package/test-env/components/icon/assets/product_dashboard.js +5 -3
  146. package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -2
  147. package/test-env/components/list_group/list_group_item.js +1 -2
  148. package/test-env/components/markdown_editor/markdown_editor.js +1 -1
  149. package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
  150. package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
  151. package/test-env/components/markdown_editor/markdown_editor_toolbar.js +14 -10
  152. package/test-env/components/portal/portal.js +70 -113
  153. package/test-env/components/search_bar/filters/field_value_toggle_group_filter.js +44 -88
  154. package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
  155. package/test-env/components/steps/step_horizontal.js +8 -5
  156. package/test-env/components/table/table_header_cell.js +1 -2
  157. package/test-env/components/tool_tip/icon_tip.js +4 -8
  158. package/test-env/components/tool_tip/tool_tip.js +230 -256
  159. package/test-env/components/tool_tip/tool_tip.styles.js +8 -16
  160. package/test-env/components/tool_tip/tool_tip_anchor.js +2 -2
  161. package/test-env/components/tool_tip/tool_tip_manager.js +1 -0
  162. package/test-env/components/tool_tip/tool_tip_popover.js +6 -6
  163. package/test-env/test/rtl/component_helpers.js +41 -63
@@ -1,21 +1,13 @@
1
- var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "delay", "display", "repositionOnScroll", "disableScreenReaderOutput"];
2
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
1
+ var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "display", "repositionOnScroll", "disableScreenReaderOutput", "position", "offset", "id", "onMouseOut"];
3
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
4
9
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
5
10
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
6
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
8
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
9
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
11
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
14
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
15
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
16
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
11
  /*
20
12
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
21
13
  * or more contributor license agreements. Licensed under the Elastic License
@@ -24,12 +16,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
24
16
  * Side Public License, v 1.
25
17
  */
26
18
 
27
- import React, { Component } from 'react';
19
+ import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
28
20
  import PropTypes from "prop-types";
29
21
  import classNames from 'classnames';
30
22
  import { findPopoverPosition, htmlIdGenerator, keys } from '../../services';
31
- import { createRepositionOnScroll } from '../../services/popover/reposition_on_scroll';
32
- import { enqueueStateChange } from '../../services/react';
23
+ import { getRepositionOnScroll } from '../../services/popover/reposition_on_scroll';
33
24
  import { EuiResizeObserver } from '../observer/resize_observer';
34
25
  import { EuiPortal } from '../portal';
35
26
  import { EuiComponentDefaultsContext } from '../provider/component_defaults';
@@ -41,9 +32,17 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
41
32
  export var POSITIONS = ['top', 'right', 'bottom', 'left'];
42
33
  var DISPLAYS = ['inlineBlock', 'block'];
43
34
  export var DEFAULT_TOOLTIP_OFFSET = 16;
44
- var delayToMsMap = {
45
- regular: 250,
46
- long: 250 * 5
35
+
36
+ /**
37
+ * `:focus-visible` may throw in browsers that don't support the selector,
38
+ * fall back to treating all focus as visible so tooltips still appear.
39
+ */
40
+ var isFocusVisible = function isFocusVisible(element) {
41
+ try {
42
+ return element.matches(':focus-visible');
43
+ } catch (_unused) {
44
+ return element.matches(':focus');
45
+ }
47
46
  };
48
47
  var DEFAULT_TOOLTIP_STYLES = {
49
48
  // position the tooltip content near the top-left
@@ -57,251 +56,227 @@ var DEFAULT_TOOLTIP_STYLES = {
57
56
  // prevent accidental mouse interaction while positioning
58
57
  visibility: 'hidden'
59
58
  };
60
- export var EuiToolTip = /*#__PURE__*/function (_Component) {
61
- function EuiToolTip(props) {
62
- var _this;
63
- _classCallCheck(this, EuiToolTip);
64
- _this = _callSuper(this, EuiToolTip, [props]);
65
- _defineProperty(_this, "repositionOnScroll", void 0);
66
- _defineProperty(_this, "_isMounted", false);
67
- _defineProperty(_this, "anchor", null);
68
- _defineProperty(_this, "popover", null);
69
- _defineProperty(_this, "timeoutId", void 0);
70
- _defineProperty(_this, "clearAnimationTimeout", function () {
71
- if (_this.timeoutId) {
72
- _this.timeoutId = clearTimeout(_this.timeoutId);
73
- }
74
- });
75
- _defineProperty(_this, "testAnchor", function () {
76
- // when the tooltip is visible, this checks if the anchor is still part of document
77
- // this fixes when the react root is removed from the dom without unmounting
78
- // https://github.com/elastic/eui/issues/1105
79
- if (document.body.contains(_this.anchor) === false) {
59
+ export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
60
+ var children = _ref.children,
61
+ className = _ref.className,
62
+ anchorClassName = _ref.anchorClassName,
63
+ anchorProps = _ref.anchorProps,
64
+ content = _ref.content,
65
+ title = _ref.title,
66
+ _ref$display = _ref.display,
67
+ display = _ref$display === void 0 ? 'inlineBlock' : _ref$display,
68
+ repositionOnScroll = _ref.repositionOnScroll,
69
+ _ref$disableScreenRea = _ref.disableScreenReaderOutput,
70
+ disableScreenReaderOutput = _ref$disableScreenRea === void 0 ? false : _ref$disableScreenRea,
71
+ _ref$position = _ref.position,
72
+ positionProp = _ref$position === void 0 ? 'top' : _ref$position,
73
+ offset = _ref.offset,
74
+ idProp = _ref.id,
75
+ onMouseOutProp = _ref.onMouseOut,
76
+ rest = _objectWithoutProperties(_ref, _excluded);
77
+ var componentDefaultsContext = useContext(EuiComponentDefaultsContext);
78
+ var _useState = useState(false),
79
+ _useState2 = _slicedToArray(_useState, 2),
80
+ visible = _useState2[0],
81
+ setVisible = _useState2[1];
82
+ var _useState3 = useState(false),
83
+ _useState4 = _slicedToArray(_useState3, 2),
84
+ hasFocus = _useState4[0],
85
+ setHasFocus = _useState4[1];
86
+ var _useState5 = useState(positionProp),
87
+ _useState6 = _slicedToArray(_useState5, 2),
88
+ calculatedPosition = _useState6[0],
89
+ setCalculatedPosition = _useState6[1];
90
+ var _useState7 = useState(DEFAULT_TOOLTIP_STYLES),
91
+ _useState8 = _slicedToArray(_useState7, 2),
92
+ toolTipStyles = _useState8[0],
93
+ setToolTipStyles = _useState8[1];
94
+ var _useState9 = useState(undefined),
95
+ _useState10 = _slicedToArray(_useState9, 2),
96
+ arrowStyles = _useState10[0],
97
+ setArrowStyles = _useState10[1];
98
+ var generatedId = useRef(htmlIdGenerator()());
99
+ var id = idProp !== null && idProp !== void 0 ? idProp : generatedId.current;
100
+ var anchorRef = useRef(null);
101
+ var popoverRef = useRef(null);
102
+ var positionToolTip = useCallback(function () {
103
+ if (!anchorRef.current || !popoverRef.current) {
104
+ return;
105
+ }
106
+ var _findPopoverPosition = findPopoverPosition({
107
+ anchor: anchorRef.current,
108
+ popover: popoverRef.current,
109
+ position: positionProp,
110
+ offset: offset !== null && offset !== void 0 ? offset : DEFAULT_TOOLTIP_OFFSET,
111
+ arrowConfig: {
112
+ arrowWidth: 12,
113
+ arrowBuffer: 4
114
+ }
115
+ }),
116
+ position = _findPopoverPosition.position,
117
+ left = _findPopoverPosition.left,
118
+ top = _findPopoverPosition.top,
119
+ arrow = _findPopoverPosition.arrow;
120
+
121
+ // If encroaching the right edge of the window:
122
+ // When `props.content` changes and is longer than `prevProps.content`, the tooltip width remains and
123
+ // the resizeObserver callback will fire twice (once for vertical resize caused by text line wrapping,
124
+ // once for a subsequent position correction) and cause a flash rerender and reposition.
125
+ // To prevent this, we can orient from the right so that text line wrapping does not occur, negating
126
+ // the second resizeObserver callback call.
127
+ var windowWidth = document.documentElement.clientWidth || window.innerWidth;
128
+ var useRightValue = windowWidth / 2 < left;
129
+ var newToolTipStyles = {
130
+ top: top,
131
+ left: useRightValue ? 'auto' : left,
132
+ right: useRightValue ? windowWidth - left - popoverRef.current.offsetWidth : 'auto'
133
+ };
134
+ setCalculatedPosition(position);
135
+ setToolTipStyles(newToolTipStyles);
136
+ setArrowStyles(arrow);
137
+ }, [positionProp, offset]);
138
+ var setAnchorRef = useCallback(function (el) {
139
+ anchorRef.current = el;
140
+ }, []);
141
+ var setPopoverRef = useCallback(function (el) {
142
+ popoverRef.current = el;
143
+ if (el) positionToolTip();
144
+ }, [positionToolTip]);
145
+ var hideToolTip = useCallback(function () {
146
+ setVisible(false);
147
+ setToolTipStyles(DEFAULT_TOOLTIP_STYLES);
148
+ setArrowStyles(undefined);
149
+ toolTipManager.deregisterToolTip(hideToolTip);
150
+ }, []);
151
+ var showToolTip = useCallback(function () {
152
+ if (!content && !title) return;
153
+ setVisible(true);
154
+ toolTipManager.registerTooltip(hideToolTip);
155
+ }, [content, title, hideToolTip]);
156
+ useImperativeHandle(ref, function () {
157
+ return {
158
+ showToolTip: showToolTip,
159
+ hideToolTip: hideToolTip,
160
+ id: id
161
+ };
162
+ }, [showToolTip, hideToolTip, id]);
163
+
164
+ // If the anchor already has focus on mount (e.g. `autoFocus`), show the tooltip.
165
+ // Important for StrictMode double-mount.
166
+ useEffect(function () {
167
+ var _anchorRef$current;
168
+ if ((_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(document.activeElement) && document.activeElement != null && isFocusVisible(document.activeElement)) {
169
+ setHasFocus(true);
170
+ showToolTip();
171
+ }
172
+ }, [showToolTip]);
173
+ useEffect(function () {
174
+ return function () {
175
+ toolTipManager.deregisterToolTip(hideToolTip);
176
+ };
177
+ }, [hideToolTip]);
178
+
179
+ // When the tooltip is visible, this checks if the anchor is still part of document.
180
+ // This fixes when the react root is removed from the DOM without unmounting
181
+ // See: https://github.com/elastic/eui/issues/1105
182
+ useEffect(function () {
183
+ if (!visible) return;
184
+ var rafId;
185
+ var testAnchor = function testAnchor() {
186
+ if (document.body.contains(anchorRef.current) === false) {
80
187
  // the anchor is no longer part of `document`
81
- _this.hideToolTip();
188
+ hideToolTip();
82
189
  } else {
83
- if (_this.state.visible) {
84
- // if still visible, keep checking
85
- requestAnimationFrame(_this.testAnchor);
86
- }
87
- }
88
- });
89
- _defineProperty(_this, "setAnchorRef", function (ref) {
90
- return _this.anchor = ref;
91
- });
92
- _defineProperty(_this, "setPopoverRef", function (ref) {
93
- return _this.popover = ref;
94
- });
95
- _defineProperty(_this, "showToolTip", function () {
96
- if (!_this.timeoutId) {
97
- _this.timeoutId = setTimeout(function () {
98
- enqueueStateChange(function () {
99
- _this.setState({
100
- visible: true
101
- });
102
- toolTipManager.registerTooltip(_this.hideToolTip);
103
- });
104
- }, delayToMsMap[_this.props.delay]);
105
- }
106
- });
107
- _defineProperty(_this, "positionToolTip", function () {
108
- var _this$props$offset;
109
- var requestedPosition = _this.props.position;
110
- var offset = (_this$props$offset = _this.props.offset) !== null && _this$props$offset !== void 0 ? _this$props$offset : DEFAULT_TOOLTIP_OFFSET;
111
- if (!_this.anchor || !_this.popover) {
112
- return;
190
+ rafId = requestAnimationFrame(testAnchor);
113
191
  }
114
- var _findPopoverPosition = findPopoverPosition({
115
- anchor: _this.anchor,
116
- popover: _this.popover,
117
- position: requestedPosition,
118
- offset: offset,
119
- arrowConfig: {
120
- arrowWidth: 12,
121
- arrowBuffer: 4
122
- }
123
- }),
124
- position = _findPopoverPosition.position,
125
- left = _findPopoverPosition.left,
126
- top = _findPopoverPosition.top,
127
- arrow = _findPopoverPosition.arrow;
192
+ };
193
+ rafId = requestAnimationFrame(testAnchor);
194
+ return function () {
195
+ cancelAnimationFrame(rafId);
196
+ };
197
+ }, [visible, hideToolTip]);
128
198
 
129
- // If encroaching the right edge of the window:
130
- // When `props.content` changes and is longer than `prevProps.content`, the tooltip width remains and
131
- // the resizeObserver callback will fire twice (once for vertical resize caused by text line wrapping,
132
- // once for a subsequent position correction) and cause a flash rerender and reposition.
133
- // To prevent this, we can orient from the right so that text line wrapping does not occur, negating
134
- // the second resizeObserver callback call.
135
- var windowWidth = document.documentElement.clientWidth || window.innerWidth;
136
- var useRightValue = windowWidth / 2 < left;
137
- var toolTipStyles = {
138
- top: top,
139
- left: useRightValue ? 'auto' : left,
140
- right: useRightValue ? windowWidth - left - _this.popover.offsetWidth : 'auto'
141
- };
142
- _this.setState({
143
- visible: true,
144
- calculatedPosition: position,
145
- toolTipStyles: toolTipStyles,
146
- arrowStyles: arrow
147
- });
148
- });
149
- _defineProperty(_this, "hideToolTip", function () {
150
- _this.clearAnimationTimeout();
151
- enqueueStateChange(function () {
152
- if (_this._isMounted) {
153
- _this.setState({
154
- visible: false,
155
- toolTipStyles: DEFAULT_TOOLTIP_STYLES,
156
- arrowStyles: undefined
157
- });
158
- toolTipManager.deregisterToolTip(_this.hideToolTip);
159
- }
160
- });
161
- });
162
- _defineProperty(_this, "onFocus", function () {
163
- _this.setState({
164
- hasFocus: true
165
- });
166
- _this.showToolTip();
167
- });
168
- _defineProperty(_this, "onBlur", function () {
169
- _this.setState({
170
- hasFocus: false
171
- });
172
- _this.hideToolTip();
199
+ // update scroll listener
200
+ useEffect(function () {
201
+ var shouldReposition = getRepositionOnScroll({
202
+ repositionOnScroll: repositionOnScroll,
203
+ repositionFn: positionToolTip,
204
+ componentDefaults: componentDefaultsContext.EuiToolTip
173
205
  });
174
- _defineProperty(_this, "onEscapeKey", function (event) {
175
- if (event.key === keys.ESCAPE) {
176
- // when the tooltip is only visual, we don't want it to add an additional key stop
177
- if (!_this.props.disableScreenReaderOutput) {
178
- if (_this.state.visible) event.stopPropagation();
179
- }
180
- _this.setState({
181
- hasFocus: false
182
- }); // Allows mousing over back into the tooltip to work correctly
183
- _this.hideToolTip();
184
- }
185
- });
186
- _defineProperty(_this, "onMouseOut", function (event) {
187
- // Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
188
- // left the anchor for a non-child.
189
- if (_this.anchor === event.relatedTarget || _this.anchor != null && !_this.anchor.contains(event.relatedTarget)) {
190
- if (!_this.state.hasFocus) {
191
- _this.hideToolTip();
192
- }
193
- }
194
- if (_this.props.onMouseOut) {
195
- _this.props.onMouseOut(event);
196
- }
197
- });
198
- _this.state = {
199
- visible: false,
200
- hasFocus: false,
201
- calculatedPosition: _this.props.position,
202
- toolTipStyles: DEFAULT_TOOLTIP_STYLES,
203
- arrowStyles: undefined,
204
- id: _this.props.id || htmlIdGenerator()()
206
+ if (shouldReposition) {
207
+ window.addEventListener('scroll', positionToolTip, true);
208
+ }
209
+ return function () {
210
+ window.removeEventListener('scroll', positionToolTip, true);
205
211
  };
206
- _this.repositionOnScroll = createRepositionOnScroll(function () {
207
- return {
208
- repositionOnScroll: _this.props.repositionOnScroll,
209
- componentDefaults: _this.context.EuiToolTip,
210
- repositionFn: _this.positionToolTip
211
- };
212
- });
213
- return _this;
214
- }
215
- _inherits(EuiToolTip, _Component);
216
- return _createClass(EuiToolTip, [{
217
- key: "componentDidMount",
218
- value: function componentDidMount() {
219
- this._isMounted = true;
220
- this.repositionOnScroll.subscribe();
212
+ }, [repositionOnScroll, positionToolTip, componentDefaultsContext.EuiToolTip]);
213
+ var onFocus = useCallback(function (e) {
214
+ if (isFocusVisible(e.target)) {
215
+ setHasFocus(true);
216
+ showToolTip();
221
217
  }
222
- }, {
223
- key: "componentWillUnmount",
224
- value: function componentWillUnmount() {
225
- this.clearAnimationTimeout();
226
- this._isMounted = false;
227
- this.repositionOnScroll.cleanup();
218
+ }, [showToolTip]);
219
+ var onBlur = useCallback(function () {
220
+ setHasFocus(false);
221
+ hideToolTip();
222
+ }, [hideToolTip]);
223
+ var onEscapeKey = useCallback(function (event) {
224
+ if (event.key === keys.ESCAPE) {
225
+ // when the tooltip is only visual, we don't want it to add an additional key stop
226
+ if (!disableScreenReaderOutput) {
227
+ if (visible) event.stopPropagation();
228
+ }
229
+ setHasFocus(false); // Allows mousing over back into the tooltip to work correctly
230
+ hideToolTip();
228
231
  }
229
- }, {
230
- key: "componentDidUpdate",
231
- value: function componentDidUpdate(prevProps, prevState) {
232
- if (prevState.visible === false && this.state.visible === true) {
233
- requestAnimationFrame(this.testAnchor);
232
+ }, [disableScreenReaderOutput, visible, hideToolTip]);
233
+ var onMouseOut = useCallback(function (event) {
234
+ // Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
235
+ // left the anchor for a non-child.
236
+ if (anchorRef.current === event.relatedTarget || anchorRef.current != null && !anchorRef.current.contains(event.relatedTarget)) {
237
+ if (!hasFocus) {
238
+ hideToolTip();
234
239
  }
235
-
236
- // update scroll listener
237
- this.repositionOnScroll.update();
238
240
  }
239
- }, {
240
- key: "render",
241
- value: function render() {
242
- var _this$props = this.props,
243
- children = _this$props.children,
244
- className = _this$props.className,
245
- anchorClassName = _this$props.anchorClassName,
246
- anchorProps = _this$props.anchorProps,
247
- content = _this$props.content,
248
- title = _this$props.title,
249
- delay = _this$props.delay,
250
- display = _this$props.display,
251
- repositionOnScroll = _this$props.repositionOnScroll,
252
- _this$props$disableSc = _this$props.disableScreenReaderOutput,
253
- disableScreenReaderOutput = _this$props$disableSc === void 0 ? false : _this$props$disableSc,
254
- rest = _objectWithoutProperties(_this$props, _excluded);
255
- var _this$state = this.state,
256
- arrowStyles = _this$state.arrowStyles,
257
- id = _this$state.id,
258
- toolTipStyles = _this$state.toolTipStyles,
259
- visible = _this$state.visible,
260
- calculatedPosition = _this$state.calculatedPosition;
261
- var classes = classNames('euiToolTip', className);
262
- var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
263
- return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
264
- ref: this.setAnchorRef,
265
- onBlur: this.onBlur,
266
- onFocus: this.onFocus,
267
- onKeyDown: this.onEscapeKey,
268
- onMouseOver: this.showToolTip,
269
- onMouseOut: this.onMouseOut
270
- // `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
271
- ,
272
- id: !disableScreenReaderOutput ? id : undefined,
273
- className: anchorClasses,
274
- display: display,
275
- isVisible: visible
276
- }), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
277
- className: classes,
278
- style: toolTipStyles,
279
- positionToolTip: this.positionToolTip,
280
- popoverRef: this.setPopoverRef,
281
- title: title,
282
- id: id,
283
- role: "tooltip",
284
- calculatedPosition: calculatedPosition
285
- }, rest), ___EmotionJSX(EuiToolTipArrow, {
286
- style: arrowStyles,
287
- className: "euiToolTip__arrow",
288
- position: calculatedPosition
289
- }), ___EmotionJSX(EuiResizeObserver, {
290
- onResize: this.positionToolTip
291
- }, function (resizeRef) {
292
- return ___EmotionJSX("div", {
293
- ref: resizeRef
294
- }, content);
295
- }))));
241
+ if (onMouseOutProp) {
242
+ onMouseOutProp(event);
296
243
  }
297
- }]);
298
- }(Component);
299
- _defineProperty(EuiToolTip, "contextType", EuiComponentDefaultsContext);
300
- _defineProperty(EuiToolTip, "defaultProps", {
301
- position: 'top',
302
- delay: 'regular',
303
- display: 'inlineBlock',
304
- disableScreenReaderOutput: false
244
+ }, [hasFocus, hideToolTip, onMouseOutProp]);
245
+ var classes = classNames('euiToolTip', className);
246
+ var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
247
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
248
+ ref: setAnchorRef,
249
+ onBlur: onBlur,
250
+ onFocus: onFocus,
251
+ onKeyDown: onEscapeKey,
252
+ onMouseOver: showToolTip,
253
+ onMouseOut: onMouseOut
254
+ // `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
255
+ ,
256
+ id: !disableScreenReaderOutput ? id : undefined,
257
+ className: anchorClasses,
258
+ display: display,
259
+ isVisible: visible
260
+ }), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
261
+ className: classes,
262
+ style: toolTipStyles,
263
+ positionToolTip: positionToolTip,
264
+ popoverRef: setPopoverRef,
265
+ title: title,
266
+ id: id,
267
+ role: "tooltip",
268
+ calculatedPosition: calculatedPosition
269
+ }, rest), ___EmotionJSX(EuiToolTipArrow, {
270
+ style: arrowStyles,
271
+ className: "euiToolTip__arrow",
272
+ position: calculatedPosition
273
+ }), ___EmotionJSX(EuiResizeObserver, {
274
+ onResize: positionToolTip
275
+ }, function (resizeRef) {
276
+ return ___EmotionJSX("div", {
277
+ ref: resizeRef
278
+ }, content);
279
+ }))));
305
280
  });
306
281
  EuiToolTip.propTypes = {
307
282
  /**
@@ -333,10 +308,6 @@ EuiToolTip.propTypes = {
333
308
  * Common display alternatives for the anchor wrapper
334
309
  */
335
310
  display: PropTypes.any,
336
- /**
337
- * Delay before showing tooltip. Good for repeatable items.
338
- */
339
- delay: PropTypes.oneOf(["regular", "long"]).isRequired,
340
311
  /**
341
312
  * An optional title for your tooltip.
342
313
  */
@@ -348,7 +319,7 @@ EuiToolTip.propTypes = {
348
319
  /**
349
320
  * Suggested position. If there is not enough room for it this will be changed.
350
321
  */
351
- position: PropTypes.oneOf(["top", "right", "bottom", "left"]).isRequired,
322
+ position: PropTypes.oneOf(["top", "right", "bottom", "left"]),
352
323
  /**
353
324
  * When `true`, the tooltip's position is re-calculated when the user
354
325
  * scrolls. This supports having fixed-position tooltip anchors.
@@ -377,4 +348,5 @@ EuiToolTip.propTypes = {
377
348
  "aria-label": PropTypes.string,
378
349
  "data-test-subj": PropTypes.string,
379
350
  css: PropTypes.any
380
- };
351
+ };
352
+ EuiToolTip.displayName = 'EuiToolTip';
@@ -1,4 +1,4 @@
1
- var _templateObject, _templateObject2;
1
+ var _templateObject;
2
2
  function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
3
  function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
4
4
  /*
@@ -10,8 +10,8 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
10
10
  */
11
11
 
12
12
  import { css, keyframes } from '@emotion/react';
13
- import { euiShadow } from '@elastic/eui-theme-common';
14
- import { logicalCSS, euiFontSize, euiCanAnimate } from '../../global_styling';
13
+ import { euiCanAnimate, euiShadow } from '@elastic/eui-theme-common';
14
+ import { logicalCSS, euiFontSize } from '../../global_styling';
15
15
  import { _popoverArrowStyles } from '../../services/popover';
16
16
  import { euiPanelBorderStyles } from '../panel/panel.styles';
17
17
  export var euiToolTipBackgroundColor = function euiToolTipBackgroundColor(euiTheme) {
@@ -20,29 +20,21 @@ export var euiToolTipBackgroundColor = function euiToolTipBackgroundColor(euiThe
20
20
  export var euiToolTipBorderColor = function euiToolTipBorderColor(euiTheme) {
21
21
  return euiTheme.components.tooltipBorder;
22
22
  };
23
- var euiToolTipAnimationVertical = function euiToolTipAnimationVertical(size) {
24
- return keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% {\n opacity: 0;\n transform: translateY(", ");\n }\n\n 100% {\n opacity: 1;\n transform: translateY(0);\n }\n"])), size);
25
- };
26
- var euiToolTipAnimationHorizontal = function euiToolTipAnimationHorizontal(size) {
27
- return keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n 0% {\n opacity: 0;\n transform: translateX(", ");\n }\n\n 100% {\n opacity: 1;\n transform: translateX(0);\n }\n"])), size);
28
- };
23
+ var euiToolTipAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from { opacity: 0; }\n to { opacity: 1; }\n"])));
29
24
  export var euiToolTipStyles = function euiToolTipStyles(euiThemeContext) {
30
25
  var euiTheme = euiThemeContext.euiTheme,
31
26
  highContrastMode = euiThemeContext.highContrastMode;
32
27
  var hasShadow = !highContrastMode;
33
- var animationTiming = "".concat(euiTheme.animation.slow, " ease-out 0s forwards");
34
28
  var arrowSize = euiTheme.size.m;
35
29
  var arrowStyles = _popoverArrowStyles(euiThemeContext, arrowSize);
36
30
  return {
37
31
  // Base
38
- euiToolTip: /*#__PURE__*/css(hasShadow ? euiShadow(euiThemeContext) : '', " border-radius:", euiTheme.border.radius.medium, ";background-color:", euiToolTipBackgroundColor(euiTheme), ";color:", euiTheme.colors.textGhost, ";z-index:", euiTheme.levels.toast, ";", logicalCSS('max-width', '256px'), " overflow-wrap:break-word;padding:", euiTheme.size.s, ";", euiFontSize(euiThemeContext, 's'), " position:absolute;", euiPanelBorderStyles(euiThemeContext), " [class*='euiHorizontalRule']{background-color:", euiToolTipBorderColor(euiTheme), ";};label:euiToolTip;"),
39
- // Sizes
40
- s: /*#__PURE__*/css(euiFontSize(euiThemeContext, 'xs'), ";;label:s;"),
41
- // Positions
42
- top: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationVertical("-".concat(euiTheme.size.base)), " ", animationTiming, ";};label:top;"),
43
- bottom: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationVertical(euiTheme.size.base), " ", animationTiming, ";};label:bottom;"),
44
- left: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationHorizontal("-".concat(euiTheme.size.base)), " ", animationTiming, ";};label:left;"),
45
- right: /*#__PURE__*/css(euiCanAnimate, "{animation:", euiToolTipAnimationHorizontal(euiTheme.size.base), " ", animationTiming, ";};label:right;"),
32
+ euiToolTip: /*#__PURE__*/css(hasShadow ? euiShadow(euiThemeContext) : '', " border-radius:", euiTheme.border.radius.medium, ";background-color:", euiToolTipBackgroundColor(euiTheme), ";color:", euiTheme.colors.textGhost, ";z-index:", euiTheme.levels.toast, ";", logicalCSS('max-width', '256px'), " overflow-wrap:break-word;padding:", euiTheme.size.s, ";", euiFontSize(euiThemeContext, 'xs'), " position:absolute;pointer-events:none;", euiPanelBorderStyles(euiThemeContext), " [class*='euiHorizontalRule']{background-color:", euiToolTipBorderColor(euiTheme), ";}", euiCanAnimate, "{animation:", euiToolTipAnimation, " ", euiTheme.animation.extraFast, " ease-out ", euiTheme.animation.fast, " both;};label:euiToolTip;"),
33
+ // Positions - kept for component compatibility. Animation is in the base style.
34
+ top: /*#__PURE__*/css(";label:top;"),
35
+ bottom: /*#__PURE__*/css(";label:bottom;"),
36
+ left: /*#__PURE__*/css(";label:left;"),
37
+ right: /*#__PURE__*/css(";label:right;"),
46
38
  // Arrow
47
39
  euiToolTip__arrow: /*#__PURE__*/css(arrowStyles._arrowStyles, " background-color:inherit;;label:euiToolTip__arrow;"),
48
40
  arrowPositions: arrowStyles.positions,
@@ -13,7 +13,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
13
13
  import React, { cloneElement, forwardRef } from 'react';
14
14
  import PropTypes from "prop-types";
15
15
  import classNames from 'classnames';
16
- import { useGeneratedHtmlId } from '../../services';
16
+ import { useGeneratedHtmlId, useEuiMemoizedStyles } from '../../services';
17
17
  import { euiToolTipAnchorStyles } from './tool_tip.styles';
18
18
  import { jsx as ___EmotionJSX } from "@emotion/react";
19
19
  export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
@@ -27,7 +27,7 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
27
  display = _ref.display,
28
28
  isVisible = _ref.isVisible,
29
29
  rest = _objectWithoutProperties(_ref, _excluded);
30
- var anchorCss = euiToolTipAnchorStyles();
30
+ var anchorCss = useEuiMemoizedStyles(euiToolTipAnchorStyles);
31
31
  var cssStyles = [anchorCss.euiToolTipAnchor, anchorCss[display]];
32
32
  var classes = classNames('euiToolTipAnchor', className);
33
33
  var anchorId = useGeneratedHtmlId({
@@ -48,7 +48,7 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
48
48
  onMouseOut: onMouseOut
49
49
  }), /*#__PURE__*/cloneElement(children, {
50
50
  onFocus: function onFocus(e) {
51
- _onFocus();
51
+ _onFocus(e);
52
52
  children.props.onFocus && children.props.onFocus(e);
53
53
  },
54
54
  onBlur: function onBlur(e) {
@@ -26,6 +26,7 @@ var ToolTipManager = /*#__PURE__*/_createClass(function ToolTipManager() {
26
26
  // multiple tooltips are registered via async shenanigans
27
27
  _defineProperty(this, "toolTipsToHide", new Set());
28
28
  _defineProperty(this, "registerTooltip", function (hideCallback) {
29
+ if (_this.toolTipsToHide.has(hideCallback)) return;
29
30
  _this.toolTipsToHide.forEach(function (hide) {
30
31
  return hide();
31
32
  });