@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.
- package/es/components/basic_table/basic_table.js +3 -6
- package/es/components/basic_table/collapsed_item_actions.js +1 -3
- package/es/components/basic_table/default_item_action.js +0 -1
- package/es/components/basic_table/in_memory_table.js +3 -6
- package/es/components/color_picker/color_picker_swatch.js +1 -2
- package/es/components/datagrid/controls/display_selector.js +1 -2
- package/es/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/es/components/datagrid/utils/scrolling.js +7 -1
- package/es/components/filter_group/filter_select_item.js +36 -17
- package/es/components/flyout/flyout.component.js +8 -7
- package/es/components/flyout/hooks.js +11 -3
- package/es/components/flyout/manager/flyout_main.js +4 -2
- package/es/components/icon/assets/chart_pie.js +1 -2
- package/es/components/icon/assets/product_dashboard.js +5 -3
- package/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/es/components/list_group/list_group_item.js +1 -2
- package/es/components/markdown_editor/markdown_editor.js +1 -1
- package/es/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/es/components/markdown_editor/markdown_editor_toolbar.js +14 -10
- package/es/components/portal/portal.js +72 -117
- package/es/components/search_bar/filters/field_value_toggle_group_filter.js +42 -91
- package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/es/components/steps/step_horizontal.js +8 -5
- package/es/components/table/table_header_cell.js +1 -2
- package/es/components/tool_tip/icon_tip.js +4 -8
- package/es/components/tool_tip/tool_tip.js +233 -261
- package/es/components/tool_tip/tool_tip.styles.js +10 -18
- package/es/components/tool_tip/tool_tip_anchor.js +3 -3
- package/es/components/tool_tip/tool_tip_manager.js +1 -0
- package/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/es/test/rtl/component_helpers.d.ts +0 -3
- package/es/test/rtl/component_helpers.js +40 -62
- package/eui.d.ts +29 -98
- package/lib/components/basic_table/basic_table.js +3 -6
- package/lib/components/basic_table/collapsed_item_actions.js +1 -3
- package/lib/components/basic_table/default_item_action.js +0 -1
- package/lib/components/basic_table/in_memory_table.js +3 -6
- package/lib/components/color_picker/color_picker_swatch.js +1 -2
- package/lib/components/datagrid/controls/display_selector.js +1 -2
- package/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/lib/components/datagrid/utils/scrolling.js +7 -1
- package/lib/components/filter_group/filter_select_item.js +35 -16
- package/lib/components/flyout/flyout.component.js +8 -7
- package/lib/components/flyout/hooks.js +10 -2
- package/lib/components/flyout/manager/flyout_main.js +3 -1
- package/lib/components/icon/assets/chart_pie.js +1 -2
- package/lib/components/icon/assets/product_dashboard.js +5 -3
- package/lib/components/icon/svgs/chart_pie.svg +1 -1
- package/lib/components/icon/svgs/product_dashboard.svg +4 -5
- package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/lib/components/list_group/list_group_item.js +1 -2
- package/lib/components/markdown_editor/markdown_editor.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_toolbar.js +12 -10
- package/lib/components/portal/portal.js +73 -118
- package/lib/components/search_bar/filters/field_value_toggle_group_filter.js +44 -93
- package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/lib/components/steps/step_horizontal.js +8 -5
- package/lib/components/table/table_header_cell.js +1 -2
- package/lib/components/tool_tip/icon_tip.js +4 -8
- package/lib/components/tool_tip/tool_tip.js +240 -266
- package/lib/components/tool_tip/tool_tip.styles.js +8 -16
- package/lib/components/tool_tip/tool_tip_anchor.js +2 -2
- package/lib/components/tool_tip/tool_tip_manager.js +1 -0
- package/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/lib/test/rtl/component_helpers.d.ts +0 -3
- package/lib/test/rtl/component_helpers.js +41 -63
- package/optimize/es/components/basic_table/collapsed_item_actions.js +1 -3
- package/optimize/es/components/basic_table/default_item_action.js +0 -1
- package/optimize/es/components/datagrid/controls/display_selector.js +1 -2
- package/optimize/es/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/optimize/es/components/datagrid/utils/scrolling.js +7 -1
- package/optimize/es/components/filter_group/filter_select_item.js +36 -17
- package/optimize/es/components/flyout/flyout.component.js +8 -7
- package/optimize/es/components/flyout/hooks.js +11 -3
- package/optimize/es/components/flyout/manager/flyout_main.js +4 -2
- package/optimize/es/components/icon/assets/chart_pie.js +1 -2
- package/optimize/es/components/icon/assets/product_dashboard.js +5 -3
- package/optimize/es/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/optimize/es/components/list_group/list_group_item.js +1 -2
- package/optimize/es/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
- package/optimize/es/components/markdown_editor/markdown_editor_toolbar.js +13 -9
- package/optimize/es/components/portal/portal.js +65 -91
- package/optimize/es/components/search_bar/filters/field_value_toggle_group_filter.js +43 -66
- package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/optimize/es/components/steps/step_horizontal.js +8 -5
- package/optimize/es/components/tool_tip/icon_tip.js +3 -5
- package/optimize/es/components/tool_tip/tool_tip.js +227 -250
- package/optimize/es/components/tool_tip/tool_tip.styles.js +10 -18
- package/optimize/es/components/tool_tip/tool_tip_anchor.js +3 -3
- package/optimize/es/components/tool_tip/tool_tip_manager.js +1 -0
- package/optimize/es/components/tool_tip/tool_tip_popover.js +7 -7
- package/optimize/es/test/rtl/component_helpers.d.ts +0 -3
- package/optimize/es/test/rtl/component_helpers.js +40 -62
- package/optimize/lib/components/basic_table/collapsed_item_actions.js +1 -3
- package/optimize/lib/components/basic_table/default_item_action.js +0 -1
- package/optimize/lib/components/datagrid/controls/display_selector.js +1 -2
- package/optimize/lib/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/optimize/lib/components/datagrid/utils/scrolling.js +7 -1
- package/optimize/lib/components/filter_group/filter_select_item.js +35 -16
- package/optimize/lib/components/flyout/flyout.component.js +8 -7
- package/optimize/lib/components/flyout/hooks.js +10 -2
- package/optimize/lib/components/flyout/manager/flyout_main.js +3 -1
- package/optimize/lib/components/icon/assets/chart_pie.js +1 -2
- package/optimize/lib/components/icon/assets/product_dashboard.js +5 -3
- package/optimize/lib/components/icon/svgs/chart_pie.svg +1 -1
- package/optimize/lib/components/icon/svgs/product_dashboard.svg +4 -5
- package/optimize/lib/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/optimize/lib/components/list_group/list_group_item.js +1 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_drop_zone.js +5 -2
- package/optimize/lib/components/markdown_editor/markdown_editor_toolbar.js +13 -9
- package/optimize/lib/components/portal/portal.js +68 -93
- package/optimize/lib/components/search_bar/filters/field_value_toggle_group_filter.js +45 -69
- package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/optimize/lib/components/steps/step_horizontal.js +8 -5
- package/optimize/lib/components/tool_tip/icon_tip.js +3 -5
- package/optimize/lib/components/tool_tip/tool_tip.js +229 -251
- package/optimize/lib/components/tool_tip/tool_tip.styles.js +8 -16
- package/optimize/lib/components/tool_tip/tool_tip_anchor.js +2 -2
- package/optimize/lib/components/tool_tip/tool_tip_manager.js +1 -0
- package/optimize/lib/components/tool_tip/tool_tip_popover.js +6 -6
- package/optimize/lib/test/rtl/component_helpers.d.ts +0 -3
- package/optimize/lib/test/rtl/component_helpers.js +41 -63
- package/package.json +2 -10
- package/test-env/components/basic_table/basic_table.js +3 -6
- package/test-env/components/basic_table/collapsed_item_actions.js +1 -3
- package/test-env/components/basic_table/default_item_action.js +0 -1
- package/test-env/components/basic_table/in_memory_table.js +3 -6
- package/test-env/components/color_picker/color_picker_swatch.js +1 -2
- package/test-env/components/datagrid/controls/display_selector.js +1 -2
- package/test-env/components/datagrid/controls/fullscreen_selector.js +1 -2
- package/test-env/components/datagrid/controls/keyboard_shortcuts.js +1 -2
- package/test-env/components/datagrid/utils/scrolling.js +7 -1
- package/test-env/components/filter_group/filter_select_item.js +35 -16
- package/test-env/components/flyout/flyout.component.js +8 -7
- package/test-env/components/flyout/hooks.js +10 -2
- package/test-env/components/flyout/manager/flyout_main.js +3 -1
- package/test-env/components/icon/assets/chart_pie.js +1 -2
- package/test-env/components/icon/assets/product_dashboard.js +5 -3
- package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -2
- package/test-env/components/list_group/list_group_item.js +1 -2
- package/test-env/components/markdown_editor/markdown_editor.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +6 -3
- package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_toolbar.js +14 -10
- package/test-env/components/portal/portal.js +70 -113
- package/test-env/components/search_bar/filters/field_value_toggle_group_filter.js +44 -88
- package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/test-env/components/steps/step_horizontal.js +8 -5
- package/test-env/components/table/table_header_cell.js +1 -2
- package/test-env/components/tool_tip/icon_tip.js +4 -8
- package/test-env/components/tool_tip/tool_tip.js +230 -256
- package/test-env/components/tool_tip/tool_tip.styles.js +8 -16
- package/test-env/components/tool_tip/tool_tip_anchor.js +2 -2
- package/test-env/components/tool_tip/tool_tip_manager.js +1 -0
- package/test-env/components/tool_tip/tool_tip_popover.js +6 -6
- package/test-env/test/rtl/component_helpers.js +41 -63
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "
|
|
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, {
|
|
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 {
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
188
|
+
hideToolTip();
|
|
82
189
|
} else {
|
|
83
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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"])
|
|
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
|
|
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
|
|
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
|
|
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, '
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
});
|