@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,14 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "delay", "display", "repositionOnScroll", "disableScreenReaderOutput"];
|
|
10
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
4
|
+
var _excluded = ["children", "className", "anchorClassName", "anchorProps", "content", "title", "display", "repositionOnScroll", "disableScreenReaderOutput", "position", "offset", "id", "onMouseOut"];
|
|
12
5
|
/*
|
|
13
6
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
14
7
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -17,11 +10,10 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
17
10
|
* Side Public License, v 1.
|
|
18
11
|
*/
|
|
19
12
|
|
|
20
|
-
import React, {
|
|
13
|
+
import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
21
14
|
import classNames from 'classnames';
|
|
22
15
|
import { findPopoverPosition, htmlIdGenerator, keys } from '../../services';
|
|
23
|
-
import {
|
|
24
|
-
import { enqueueStateChange } from '../../services/react';
|
|
16
|
+
import { getRepositionOnScroll } from '../../services/popover/reposition_on_scroll';
|
|
25
17
|
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
26
18
|
import { EuiPortal } from '../portal';
|
|
27
19
|
import { EuiComponentDefaultsContext } from '../provider/component_defaults';
|
|
@@ -33,9 +25,17 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
33
25
|
export var POSITIONS = ['top', 'right', 'bottom', 'left'];
|
|
34
26
|
var DISPLAYS = ['inlineBlock', 'block'];
|
|
35
27
|
export var DEFAULT_TOOLTIP_OFFSET = 16;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `:focus-visible` may throw in browsers that don't support the selector,
|
|
31
|
+
* fall back to treating all focus as visible so tooltips still appear.
|
|
32
|
+
*/
|
|
33
|
+
var isFocusVisible = function isFocusVisible(element) {
|
|
34
|
+
try {
|
|
35
|
+
return element.matches(':focus-visible');
|
|
36
|
+
} catch (_unused) {
|
|
37
|
+
return element.matches(':focus');
|
|
38
|
+
}
|
|
39
39
|
};
|
|
40
40
|
var DEFAULT_TOOLTIP_STYLES = {
|
|
41
41
|
// position the tooltip content near the top-left
|
|
@@ -49,249 +49,226 @@ var DEFAULT_TOOLTIP_STYLES = {
|
|
|
49
49
|
// prevent accidental mouse interaction while positioning
|
|
50
50
|
visibility: 'hidden'
|
|
51
51
|
};
|
|
52
|
-
export var EuiToolTip = /*#__PURE__*/function (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
export var EuiToolTip = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
53
|
+
var children = _ref.children,
|
|
54
|
+
className = _ref.className,
|
|
55
|
+
anchorClassName = _ref.anchorClassName,
|
|
56
|
+
anchorProps = _ref.anchorProps,
|
|
57
|
+
content = _ref.content,
|
|
58
|
+
title = _ref.title,
|
|
59
|
+
_ref$display = _ref.display,
|
|
60
|
+
display = _ref$display === void 0 ? 'inlineBlock' : _ref$display,
|
|
61
|
+
repositionOnScroll = _ref.repositionOnScroll,
|
|
62
|
+
_ref$disableScreenRea = _ref.disableScreenReaderOutput,
|
|
63
|
+
disableScreenReaderOutput = _ref$disableScreenRea === void 0 ? false : _ref$disableScreenRea,
|
|
64
|
+
_ref$position = _ref.position,
|
|
65
|
+
positionProp = _ref$position === void 0 ? 'top' : _ref$position,
|
|
66
|
+
offset = _ref.offset,
|
|
67
|
+
idProp = _ref.id,
|
|
68
|
+
onMouseOutProp = _ref.onMouseOut,
|
|
69
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
70
|
+
var componentDefaultsContext = useContext(EuiComponentDefaultsContext);
|
|
71
|
+
var _useState = useState(false),
|
|
72
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
73
|
+
visible = _useState2[0],
|
|
74
|
+
setVisible = _useState2[1];
|
|
75
|
+
var _useState3 = useState(false),
|
|
76
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
+
hasFocus = _useState4[0],
|
|
78
|
+
setHasFocus = _useState4[1];
|
|
79
|
+
var _useState5 = useState(positionProp),
|
|
80
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
81
|
+
calculatedPosition = _useState6[0],
|
|
82
|
+
setCalculatedPosition = _useState6[1];
|
|
83
|
+
var _useState7 = useState(DEFAULT_TOOLTIP_STYLES),
|
|
84
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
85
|
+
toolTipStyles = _useState8[0],
|
|
86
|
+
setToolTipStyles = _useState8[1];
|
|
87
|
+
var _useState9 = useState(undefined),
|
|
88
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
89
|
+
arrowStyles = _useState10[0],
|
|
90
|
+
setArrowStyles = _useState10[1];
|
|
91
|
+
var generatedId = useRef(htmlIdGenerator()());
|
|
92
|
+
var id = idProp !== null && idProp !== void 0 ? idProp : generatedId.current;
|
|
93
|
+
var anchorRef = useRef(null);
|
|
94
|
+
var popoverRef = useRef(null);
|
|
95
|
+
var positionToolTip = useCallback(function () {
|
|
96
|
+
if (!anchorRef.current || !popoverRef.current) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var _findPopoverPosition = findPopoverPosition({
|
|
100
|
+
anchor: anchorRef.current,
|
|
101
|
+
popover: popoverRef.current,
|
|
102
|
+
position: positionProp,
|
|
103
|
+
offset: offset !== null && offset !== void 0 ? offset : DEFAULT_TOOLTIP_OFFSET,
|
|
104
|
+
arrowConfig: {
|
|
105
|
+
arrowWidth: 12,
|
|
106
|
+
arrowBuffer: 4
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
position = _findPopoverPosition.position,
|
|
110
|
+
left = _findPopoverPosition.left,
|
|
111
|
+
top = _findPopoverPosition.top,
|
|
112
|
+
arrow = _findPopoverPosition.arrow;
|
|
113
|
+
|
|
114
|
+
// If encroaching the right edge of the window:
|
|
115
|
+
// When `props.content` changes and is longer than `prevProps.content`, the tooltip width remains and
|
|
116
|
+
// the resizeObserver callback will fire twice (once for vertical resize caused by text line wrapping,
|
|
117
|
+
// once for a subsequent position correction) and cause a flash rerender and reposition.
|
|
118
|
+
// To prevent this, we can orient from the right so that text line wrapping does not occur, negating
|
|
119
|
+
// the second resizeObserver callback call.
|
|
120
|
+
var windowWidth = document.documentElement.clientWidth || window.innerWidth;
|
|
121
|
+
var useRightValue = windowWidth / 2 < left;
|
|
122
|
+
var newToolTipStyles = {
|
|
123
|
+
top: top,
|
|
124
|
+
left: useRightValue ? 'auto' : left,
|
|
125
|
+
right: useRightValue ? windowWidth - left - popoverRef.current.offsetWidth : 'auto'
|
|
126
|
+
};
|
|
127
|
+
setCalculatedPosition(position);
|
|
128
|
+
setToolTipStyles(newToolTipStyles);
|
|
129
|
+
setArrowStyles(arrow);
|
|
130
|
+
}, [positionProp, offset]);
|
|
131
|
+
var setAnchorRef = useCallback(function (el) {
|
|
132
|
+
anchorRef.current = el;
|
|
133
|
+
}, []);
|
|
134
|
+
var setPopoverRef = useCallback(function (el) {
|
|
135
|
+
popoverRef.current = el;
|
|
136
|
+
if (el) positionToolTip();
|
|
137
|
+
}, [positionToolTip]);
|
|
138
|
+
var hideToolTip = useCallback(function () {
|
|
139
|
+
setVisible(false);
|
|
140
|
+
setToolTipStyles(DEFAULT_TOOLTIP_STYLES);
|
|
141
|
+
setArrowStyles(undefined);
|
|
142
|
+
toolTipManager.deregisterToolTip(hideToolTip);
|
|
143
|
+
}, []);
|
|
144
|
+
var showToolTip = useCallback(function () {
|
|
145
|
+
if (!content && !title) return;
|
|
146
|
+
setVisible(true);
|
|
147
|
+
toolTipManager.registerTooltip(hideToolTip);
|
|
148
|
+
}, [content, title, hideToolTip]);
|
|
149
|
+
useImperativeHandle(ref, function () {
|
|
150
|
+
return {
|
|
151
|
+
showToolTip: showToolTip,
|
|
152
|
+
hideToolTip: hideToolTip,
|
|
153
|
+
id: id
|
|
154
|
+
};
|
|
155
|
+
}, [showToolTip, hideToolTip, id]);
|
|
156
|
+
|
|
157
|
+
// If the anchor already has focus on mount (e.g. `autoFocus`), show the tooltip.
|
|
158
|
+
// Important for StrictMode double-mount.
|
|
159
|
+
useEffect(function () {
|
|
160
|
+
var _anchorRef$current;
|
|
161
|
+
if ((_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(document.activeElement) && document.activeElement != null && isFocusVisible(document.activeElement)) {
|
|
162
|
+
setHasFocus(true);
|
|
163
|
+
showToolTip();
|
|
164
|
+
}
|
|
165
|
+
}, [showToolTip]);
|
|
166
|
+
useEffect(function () {
|
|
167
|
+
return function () {
|
|
168
|
+
toolTipManager.deregisterToolTip(hideToolTip);
|
|
169
|
+
};
|
|
170
|
+
}, [hideToolTip]);
|
|
171
|
+
|
|
172
|
+
// When the tooltip is visible, this checks if the anchor is still part of document.
|
|
173
|
+
// This fixes when the react root is removed from the DOM without unmounting
|
|
174
|
+
// See: https://github.com/elastic/eui/issues/1105
|
|
175
|
+
useEffect(function () {
|
|
176
|
+
if (!visible) return;
|
|
177
|
+
var rafId;
|
|
178
|
+
var testAnchor = function testAnchor() {
|
|
179
|
+
if (document.body.contains(anchorRef.current) === false) {
|
|
72
180
|
// the anchor is no longer part of `document`
|
|
73
|
-
|
|
181
|
+
hideToolTip();
|
|
74
182
|
} else {
|
|
75
|
-
|
|
76
|
-
// if still visible, keep checking
|
|
77
|
-
requestAnimationFrame(_this.testAnchor);
|
|
78
|
-
}
|
|
183
|
+
rafId = requestAnimationFrame(testAnchor);
|
|
79
184
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
_defineProperty(_this, "showToolTip", function () {
|
|
88
|
-
if (!_this.timeoutId) {
|
|
89
|
-
_this.timeoutId = setTimeout(function () {
|
|
90
|
-
enqueueStateChange(function () {
|
|
91
|
-
_this.setState({
|
|
92
|
-
visible: true
|
|
93
|
-
});
|
|
94
|
-
toolTipManager.registerTooltip(_this.hideToolTip);
|
|
95
|
-
});
|
|
96
|
-
}, delayToMsMap[_this.props.delay]);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
_defineProperty(_this, "positionToolTip", function () {
|
|
100
|
-
var _this$props$offset;
|
|
101
|
-
var requestedPosition = _this.props.position;
|
|
102
|
-
var offset = (_this$props$offset = _this.props.offset) !== null && _this$props$offset !== void 0 ? _this$props$offset : DEFAULT_TOOLTIP_OFFSET;
|
|
103
|
-
if (!_this.anchor || !_this.popover) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
var _findPopoverPosition = findPopoverPosition({
|
|
107
|
-
anchor: _this.anchor,
|
|
108
|
-
popover: _this.popover,
|
|
109
|
-
position: requestedPosition,
|
|
110
|
-
offset: 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;
|
|
185
|
+
};
|
|
186
|
+
rafId = requestAnimationFrame(testAnchor);
|
|
187
|
+
return function () {
|
|
188
|
+
cancelAnimationFrame(rafId);
|
|
189
|
+
};
|
|
190
|
+
}, [visible, hideToolTip]);
|
|
120
191
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var windowWidth = document.documentElement.clientWidth || window.innerWidth;
|
|
128
|
-
var useRightValue = windowWidth / 2 < left;
|
|
129
|
-
var toolTipStyles = {
|
|
130
|
-
top: top,
|
|
131
|
-
left: useRightValue ? 'auto' : left,
|
|
132
|
-
right: useRightValue ? windowWidth - left - _this.popover.offsetWidth : 'auto'
|
|
133
|
-
};
|
|
134
|
-
_this.setState({
|
|
135
|
-
visible: true,
|
|
136
|
-
calculatedPosition: position,
|
|
137
|
-
toolTipStyles: toolTipStyles,
|
|
138
|
-
arrowStyles: arrow
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
_defineProperty(_this, "hideToolTip", function () {
|
|
142
|
-
_this.clearAnimationTimeout();
|
|
143
|
-
enqueueStateChange(function () {
|
|
144
|
-
if (_this._isMounted) {
|
|
145
|
-
_this.setState({
|
|
146
|
-
visible: false,
|
|
147
|
-
toolTipStyles: DEFAULT_TOOLTIP_STYLES,
|
|
148
|
-
arrowStyles: undefined
|
|
149
|
-
});
|
|
150
|
-
toolTipManager.deregisterToolTip(_this.hideToolTip);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
_defineProperty(_this, "onFocus", function () {
|
|
155
|
-
_this.setState({
|
|
156
|
-
hasFocus: true
|
|
157
|
-
});
|
|
158
|
-
_this.showToolTip();
|
|
159
|
-
});
|
|
160
|
-
_defineProperty(_this, "onBlur", function () {
|
|
161
|
-
_this.setState({
|
|
162
|
-
hasFocus: false
|
|
163
|
-
});
|
|
164
|
-
_this.hideToolTip();
|
|
165
|
-
});
|
|
166
|
-
_defineProperty(_this, "onEscapeKey", function (event) {
|
|
167
|
-
if (event.key === keys.ESCAPE) {
|
|
168
|
-
// when the tooltip is only visual, we don't want it to add an additional key stop
|
|
169
|
-
if (!_this.props.disableScreenReaderOutput) {
|
|
170
|
-
if (_this.state.visible) event.stopPropagation();
|
|
171
|
-
}
|
|
172
|
-
_this.setState({
|
|
173
|
-
hasFocus: false
|
|
174
|
-
}); // Allows mousing over back into the tooltip to work correctly
|
|
175
|
-
_this.hideToolTip();
|
|
176
|
-
}
|
|
192
|
+
// update scroll listener
|
|
193
|
+
useEffect(function () {
|
|
194
|
+
var shouldReposition = getRepositionOnScroll({
|
|
195
|
+
repositionOnScroll: repositionOnScroll,
|
|
196
|
+
repositionFn: positionToolTip,
|
|
197
|
+
componentDefaults: componentDefaultsContext.EuiToolTip
|
|
177
198
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
_this.hideToolTip();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (_this.props.onMouseOut) {
|
|
187
|
-
_this.props.onMouseOut(event);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
_this.state = {
|
|
191
|
-
visible: false,
|
|
192
|
-
hasFocus: false,
|
|
193
|
-
calculatedPosition: _this.props.position,
|
|
194
|
-
toolTipStyles: DEFAULT_TOOLTIP_STYLES,
|
|
195
|
-
arrowStyles: undefined,
|
|
196
|
-
id: _this.props.id || htmlIdGenerator()()
|
|
199
|
+
if (shouldReposition) {
|
|
200
|
+
window.addEventListener('scroll', positionToolTip, true);
|
|
201
|
+
}
|
|
202
|
+
return function () {
|
|
203
|
+
window.removeEventListener('scroll', positionToolTip, true);
|
|
197
204
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
};
|
|
204
|
-
});
|
|
205
|
-
return _this;
|
|
206
|
-
}
|
|
207
|
-
_inherits(EuiToolTip, _Component);
|
|
208
|
-
return _createClass(EuiToolTip, [{
|
|
209
|
-
key: "componentDidMount",
|
|
210
|
-
value: function componentDidMount() {
|
|
211
|
-
this._isMounted = true;
|
|
212
|
-
this.repositionOnScroll.subscribe();
|
|
205
|
+
}, [repositionOnScroll, positionToolTip, componentDefaultsContext.EuiToolTip]);
|
|
206
|
+
var onFocus = useCallback(function (e) {
|
|
207
|
+
if (isFocusVisible(e.target)) {
|
|
208
|
+
setHasFocus(true);
|
|
209
|
+
showToolTip();
|
|
213
210
|
}
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
}, [showToolTip]);
|
|
212
|
+
var onBlur = useCallback(function () {
|
|
213
|
+
setHasFocus(false);
|
|
214
|
+
hideToolTip();
|
|
215
|
+
}, [hideToolTip]);
|
|
216
|
+
var onEscapeKey = useCallback(function (event) {
|
|
217
|
+
if (event.key === keys.ESCAPE) {
|
|
218
|
+
// when the tooltip is only visual, we don't want it to add an additional key stop
|
|
219
|
+
if (!disableScreenReaderOutput) {
|
|
220
|
+
if (visible) event.stopPropagation();
|
|
221
|
+
}
|
|
222
|
+
setHasFocus(false); // Allows mousing over back into the tooltip to work correctly
|
|
223
|
+
hideToolTip();
|
|
220
224
|
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
}, [disableScreenReaderOutput, visible, hideToolTip]);
|
|
226
|
+
var onMouseOut = useCallback(function (event) {
|
|
227
|
+
// Prevent mousing over children from hiding the tooltip by testing for whether the mouse has
|
|
228
|
+
// left the anchor for a non-child.
|
|
229
|
+
if (anchorRef.current === event.relatedTarget || anchorRef.current != null && !anchorRef.current.contains(event.relatedTarget)) {
|
|
230
|
+
if (!hasFocus) {
|
|
231
|
+
hideToolTip();
|
|
226
232
|
}
|
|
227
|
-
|
|
228
|
-
// update scroll listener
|
|
229
|
-
this.repositionOnScroll.update();
|
|
230
233
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
value: function render() {
|
|
234
|
-
var _this$props = this.props,
|
|
235
|
-
children = _this$props.children,
|
|
236
|
-
className = _this$props.className,
|
|
237
|
-
anchorClassName = _this$props.anchorClassName,
|
|
238
|
-
anchorProps = _this$props.anchorProps,
|
|
239
|
-
content = _this$props.content,
|
|
240
|
-
title = _this$props.title,
|
|
241
|
-
delay = _this$props.delay,
|
|
242
|
-
display = _this$props.display,
|
|
243
|
-
repositionOnScroll = _this$props.repositionOnScroll,
|
|
244
|
-
_this$props$disableSc = _this$props.disableScreenReaderOutput,
|
|
245
|
-
disableScreenReaderOutput = _this$props$disableSc === void 0 ? false : _this$props$disableSc,
|
|
246
|
-
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
247
|
-
var _this$state = this.state,
|
|
248
|
-
arrowStyles = _this$state.arrowStyles,
|
|
249
|
-
id = _this$state.id,
|
|
250
|
-
toolTipStyles = _this$state.toolTipStyles,
|
|
251
|
-
visible = _this$state.visible,
|
|
252
|
-
calculatedPosition = _this$state.calculatedPosition;
|
|
253
|
-
var classes = classNames('euiToolTip', className);
|
|
254
|
-
var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
|
|
255
|
-
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
|
|
256
|
-
ref: this.setAnchorRef,
|
|
257
|
-
onBlur: this.onBlur,
|
|
258
|
-
onFocus: this.onFocus,
|
|
259
|
-
onKeyDown: this.onEscapeKey,
|
|
260
|
-
onMouseOver: this.showToolTip,
|
|
261
|
-
onMouseOut: this.onMouseOut
|
|
262
|
-
// `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
|
|
263
|
-
,
|
|
264
|
-
id: !disableScreenReaderOutput ? id : undefined,
|
|
265
|
-
className: anchorClasses,
|
|
266
|
-
display: display,
|
|
267
|
-
isVisible: visible
|
|
268
|
-
}), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
|
|
269
|
-
className: classes,
|
|
270
|
-
style: toolTipStyles,
|
|
271
|
-
positionToolTip: this.positionToolTip,
|
|
272
|
-
popoverRef: this.setPopoverRef,
|
|
273
|
-
title: title,
|
|
274
|
-
id: id,
|
|
275
|
-
role: "tooltip",
|
|
276
|
-
calculatedPosition: calculatedPosition
|
|
277
|
-
}, rest), ___EmotionJSX(EuiToolTipArrow, {
|
|
278
|
-
style: arrowStyles,
|
|
279
|
-
className: "euiToolTip__arrow",
|
|
280
|
-
position: calculatedPosition
|
|
281
|
-
}), ___EmotionJSX(EuiResizeObserver, {
|
|
282
|
-
onResize: this.positionToolTip
|
|
283
|
-
}, function (resizeRef) {
|
|
284
|
-
return ___EmotionJSX("div", {
|
|
285
|
-
ref: resizeRef
|
|
286
|
-
}, content);
|
|
287
|
-
}))));
|
|
234
|
+
if (onMouseOutProp) {
|
|
235
|
+
onMouseOutProp(event);
|
|
288
236
|
}
|
|
289
|
-
}]);
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
237
|
+
}, [hasFocus, hideToolTip, onMouseOutProp]);
|
|
238
|
+
var classes = classNames('euiToolTip', className);
|
|
239
|
+
var anchorClasses = classNames(anchorClassName, anchorProps === null || anchorProps === void 0 ? void 0 : anchorProps.className);
|
|
240
|
+
return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiToolTipAnchor, _extends({}, anchorProps, {
|
|
241
|
+
ref: setAnchorRef,
|
|
242
|
+
onBlur: onBlur,
|
|
243
|
+
onFocus: onFocus,
|
|
244
|
+
onKeyDown: onEscapeKey,
|
|
245
|
+
onMouseOver: showToolTip,
|
|
246
|
+
onMouseOut: onMouseOut
|
|
247
|
+
// `id` defines if the trigger and tooltip are automatically linked via `aria-describedby`.
|
|
248
|
+
,
|
|
249
|
+
id: !disableScreenReaderOutput ? id : undefined,
|
|
250
|
+
className: anchorClasses,
|
|
251
|
+
display: display,
|
|
252
|
+
isVisible: visible
|
|
253
|
+
}), children), visible && (content || title) && ___EmotionJSX(EuiPortal, null, ___EmotionJSX(EuiToolTipPopover, _extends({
|
|
254
|
+
className: classes,
|
|
255
|
+
style: toolTipStyles,
|
|
256
|
+
positionToolTip: positionToolTip,
|
|
257
|
+
popoverRef: setPopoverRef,
|
|
258
|
+
title: title,
|
|
259
|
+
id: id,
|
|
260
|
+
role: "tooltip",
|
|
261
|
+
calculatedPosition: calculatedPosition
|
|
262
|
+
}, rest), ___EmotionJSX(EuiToolTipArrow, {
|
|
263
|
+
style: arrowStyles,
|
|
264
|
+
className: "euiToolTip__arrow",
|
|
265
|
+
position: calculatedPosition
|
|
266
|
+
}), ___EmotionJSX(EuiResizeObserver, {
|
|
267
|
+
onResize: positionToolTip
|
|
268
|
+
}, function (resizeRef) {
|
|
269
|
+
return ___EmotionJSX("div", {
|
|
270
|
+
ref: resizeRef
|
|
271
|
+
}, content);
|
|
272
|
+
}))));
|
|
273
|
+
});
|
|
274
|
+
EuiToolTip.displayName = 'EuiToolTip';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject
|
|
2
|
+
var _templateObject;
|
|
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
|
/*
|
|
5
5
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -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,
|
|
@@ -11,7 +11,7 @@ var _excluded = ["onBlur", "onFocus", "onMouseOver", "onMouseOut", "id", "classN
|
|
|
11
11
|
|
|
12
12
|
import React, { cloneElement, forwardRef } from 'react';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
|
-
import { useGeneratedHtmlId } from '../../services';
|
|
14
|
+
import { useGeneratedHtmlId, useEuiMemoizedStyles } from '../../services';
|
|
15
15
|
import { euiToolTipAnchorStyles } from './tool_tip.styles';
|
|
16
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
17
17
|
export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
@@ -25,7 +25,7 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
25
25
|
display = _ref.display,
|
|
26
26
|
isVisible = _ref.isVisible,
|
|
27
27
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
-
var anchorCss = euiToolTipAnchorStyles
|
|
28
|
+
var anchorCss = useEuiMemoizedStyles(euiToolTipAnchorStyles);
|
|
29
29
|
var cssStyles = [anchorCss.euiToolTipAnchor, anchorCss[display]];
|
|
30
30
|
var classes = classNames('euiToolTipAnchor', className);
|
|
31
31
|
var anchorId = useGeneratedHtmlId({
|
|
@@ -46,7 +46,7 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
46
46
|
onMouseOut: onMouseOut
|
|
47
47
|
}), /*#__PURE__*/cloneElement(children, {
|
|
48
48
|
onFocus: function onFocus(e) {
|
|
49
|
-
_onFocus();
|
|
49
|
+
_onFocus(e);
|
|
50
50
|
children.props.onFocus && children.props.onFocus(e);
|
|
51
51
|
},
|
|
52
52
|
onBlur: function onBlur(e) {
|
|
@@ -22,6 +22,7 @@ var ToolTipManager = /*#__PURE__*/_createClass(function ToolTipManager() {
|
|
|
22
22
|
// multiple tooltips are registered via async shenanigans
|
|
23
23
|
_defineProperty(this, "toolTipsToHide", new Set());
|
|
24
24
|
_defineProperty(this, "registerTooltip", function (hideCallback) {
|
|
25
|
+
if (_this.toolTipsToHide.has(hideCallback)) return;
|
|
25
26
|
_this.toolTipsToHide.forEach(function (hide) {
|
|
26
27
|
return hide();
|
|
27
28
|
});
|
|
@@ -11,7 +11,7 @@ var _excluded = ["children", "title", "className", "positionToolTip", "popoverRe
|
|
|
11
11
|
|
|
12
12
|
import React, { useEffect, useRef, useCallback } from 'react';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
|
-
import {
|
|
14
|
+
import { useEuiMemoizedStyles } from '../../services';
|
|
15
15
|
import { euiToolTipStyles } from './tool_tip.styles';
|
|
16
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
17
17
|
export var EuiToolTipPopover = function EuiToolTipPopover(_ref) {
|
|
@@ -22,23 +22,23 @@ export var EuiToolTipPopover = function EuiToolTipPopover(_ref) {
|
|
|
22
22
|
popoverRef = _ref.popoverRef,
|
|
23
23
|
calculatedPosition = _ref.calculatedPosition,
|
|
24
24
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
-
var popover = useRef();
|
|
26
|
-
var
|
|
27
|
-
var styles = euiToolTipStyles(euiTheme);
|
|
25
|
+
var popover = useRef(null);
|
|
26
|
+
var styles = useEuiMemoizedStyles(euiToolTipStyles);
|
|
28
27
|
var cssStyles = [styles.euiToolTip, calculatedPosition && styles[calculatedPosition]];
|
|
29
28
|
var updateDimensions = useCallback(function () {
|
|
30
29
|
requestAnimationFrame(function () {
|
|
31
|
-
// Because of this delay,
|
|
30
|
+
// Because of this delay, the popover may have unmounted by the time the RAF fires.
|
|
32
31
|
if (popover.current) {
|
|
33
32
|
positionToolTip();
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
}, [positionToolTip]);
|
|
37
|
-
var setPopoverRef = function
|
|
36
|
+
var setPopoverRef = useCallback(function (ref) {
|
|
37
|
+
popover.current = ref;
|
|
38
38
|
if (popoverRef) {
|
|
39
39
|
popoverRef(ref);
|
|
40
40
|
}
|
|
41
|
-
};
|
|
41
|
+
}, [popoverRef]);
|
|
42
42
|
useEffect(function () {
|
|
43
43
|
document.body.classList.add('euiBody-hasPortalContent');
|
|
44
44
|
window.addEventListener('resize', updateDimensions);
|
|
@@ -6,9 +6,6 @@
|
|
|
6
6
|
export declare const waitForEuiPopoverOpen: () => Promise<void>;
|
|
7
7
|
export declare const waitForEuiPopoverClose: () => Promise<void>;
|
|
8
8
|
|
|
9
|
-
export declare const waitForEuiToolTipVisible: () => Promise<void>;
|
|
10
|
-
export declare const waitForEuiToolTipHidden: () => Promise<void>;
|
|
11
|
-
|
|
12
9
|
export declare const showEuiComboBoxOptions: () => Promise<void>;
|
|
13
10
|
|
|
14
11
|
export declare const waitForEuiContextMenuPanelTransition: () => Promise<void>;
|