@elastic/eui 114.3.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/filter_group/filter_select_item.js +36 -17
- 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/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 +25 -96
- 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/filter_group/filter_select_item.js +35 -16
- 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/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/filter_group/filter_select_item.js +36 -17
- 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/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/filter_group/filter_select_item.js +35 -16
- 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/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/filter_group/filter_select_item.js +35 -16
- 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/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
|
@@ -33,23 +33,23 @@ var EuiToolTipPopover = exports.EuiToolTipPopover = function EuiToolTipPopover(_
|
|
|
33
33
|
popoverRef = _ref.popoverRef,
|
|
34
34
|
calculatedPosition = _ref.calculatedPosition,
|
|
35
35
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
-
var popover = (0, _react.useRef)();
|
|
37
|
-
var
|
|
38
|
-
var styles = (0, _tool_tip.euiToolTipStyles)(euiTheme);
|
|
36
|
+
var popover = (0, _react.useRef)(null);
|
|
37
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_tool_tip.euiToolTipStyles);
|
|
39
38
|
var cssStyles = [styles.euiToolTip, calculatedPosition && styles[calculatedPosition]];
|
|
40
39
|
var updateDimensions = (0, _react.useCallback)(function () {
|
|
41
40
|
requestAnimationFrame(function () {
|
|
42
|
-
// Because of this delay,
|
|
41
|
+
// Because of this delay, the popover may have unmounted by the time the RAF fires.
|
|
43
42
|
if (popover.current) {
|
|
44
43
|
positionToolTip();
|
|
45
44
|
}
|
|
46
45
|
});
|
|
47
46
|
}, [positionToolTip]);
|
|
48
|
-
var setPopoverRef = function
|
|
47
|
+
var setPopoverRef = (0, _react.useCallback)(function (ref) {
|
|
48
|
+
popover.current = ref;
|
|
49
49
|
if (popoverRef) {
|
|
50
50
|
popoverRef(ref);
|
|
51
51
|
}
|
|
52
|
-
};
|
|
52
|
+
}, [popoverRef]);
|
|
53
53
|
(0, _react.useEffect)(function () {
|
|
54
54
|
document.body.classList.add('euiBody-hasPortalContent');
|
|
55
55
|
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>;
|
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.waitForEuiPopoverOpen = exports.waitForEuiPopoverClose = exports.waitForEuiContextMenuPanelTransition = exports.simulateFocusVisible = exports.showEuiComboBoxOptions = exports.focusEuiToolTipTrigger = void 0;
|
|
8
8
|
require("@testing-library/jest-dom");
|
|
9
9
|
var _react = require("@testing-library/react");
|
|
10
10
|
var _custom_render = require("./custom_render");
|
|
@@ -68,81 +68,59 @@ var waitForEuiPopoverClose = exports.waitForEuiPopoverClose = /*#__PURE__*/funct
|
|
|
68
68
|
}();
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* jsdom does not track keyboard vs. mouse input modality, so `:focus-visible`
|
|
72
|
+
* always returns false. Call this before `fireEvent.focus()` on an element that
|
|
73
|
+
* should be treated as keyboard-focused.
|
|
74
|
+
*
|
|
75
|
+
* Returns a cleanup function, call it after test assertions to restore the spy.
|
|
72
76
|
*/
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var tooltip = document.querySelector('.euiToolTipPopover');
|
|
81
|
-
expect(tooltip).toBeVisible();
|
|
82
|
-
}, {
|
|
83
|
-
timeout: 3000
|
|
84
|
-
} // Account for long delay on tooltips
|
|
85
|
-
);
|
|
86
|
-
case 2:
|
|
87
|
-
return _context3.abrupt("return", _context3.sent);
|
|
88
|
-
case 3:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context3.stop();
|
|
91
|
-
}
|
|
92
|
-
}, _callee3);
|
|
93
|
-
}));
|
|
94
|
-
return function waitForEuiToolTipVisible() {
|
|
95
|
-
return _ref3.apply(this, arguments);
|
|
77
|
+
var simulateFocusVisible = exports.simulateFocusVisible = function simulateFocusVisible(element) {
|
|
78
|
+
var originalMatches = Element.prototype.matches.bind(element);
|
|
79
|
+
var spy = jest.spyOn(element, 'matches').mockImplementation(function (selector) {
|
|
80
|
+
return selector === ':focus-visible' ? true : originalMatches(selector);
|
|
81
|
+
});
|
|
82
|
+
return function () {
|
|
83
|
+
return spy.mockRestore();
|
|
96
84
|
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
case 3:
|
|
111
|
-
case "end":
|
|
112
|
-
return _context4.stop();
|
|
113
|
-
}
|
|
114
|
-
}, _callee4);
|
|
115
|
-
}));
|
|
116
|
-
return function waitForEuiToolTipHidden() {
|
|
117
|
-
return _ref4.apply(this, arguments);
|
|
118
|
-
};
|
|
119
|
-
}();
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Prefer this over `fireEvent.focus()` in tooltip tests. Plain `fireEvent.focus`
|
|
89
|
+
* does not set `:focus-visible` in jsdom and will not trigger the tooltip.
|
|
90
|
+
*
|
|
91
|
+
* Returns a cleanup function to restore the mock after assertions.
|
|
92
|
+
*/
|
|
93
|
+
var focusEuiToolTipTrigger = exports.focusEuiToolTipTrigger = function focusEuiToolTipTrigger(element) {
|
|
94
|
+
var cleanup = simulateFocusVisible(element);
|
|
95
|
+
_react.fireEvent.focus(element);
|
|
96
|
+
return cleanup;
|
|
97
|
+
};
|
|
120
98
|
|
|
121
99
|
/**
|
|
122
100
|
* EuiComboBox
|
|
123
101
|
*/
|
|
124
102
|
|
|
125
103
|
var showEuiComboBoxOptions = exports.showEuiComboBoxOptions = /*#__PURE__*/function () {
|
|
126
|
-
var
|
|
127
|
-
return _regeneratorRuntime().wrap(function
|
|
128
|
-
while (1) switch (
|
|
104
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
105
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
106
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
129
107
|
case 0:
|
|
130
108
|
_react.fireEvent.click(_custom_render.screen.getByTestSubject('comboBoxToggleListButton'));
|
|
131
|
-
|
|
109
|
+
_context3.next = 3;
|
|
132
110
|
return waitForEuiPopoverOpen();
|
|
133
111
|
case 3:
|
|
134
|
-
|
|
112
|
+
_context3.next = 5;
|
|
135
113
|
return (0, _react.waitFor)(function () {
|
|
136
114
|
expect(_custom_render.screen.getByRole('listbox')).toBeInTheDocument();
|
|
137
115
|
});
|
|
138
116
|
case 5:
|
|
139
117
|
case "end":
|
|
140
|
-
return
|
|
118
|
+
return _context3.stop();
|
|
141
119
|
}
|
|
142
|
-
},
|
|
120
|
+
}, _callee3);
|
|
143
121
|
}));
|
|
144
122
|
return function showEuiComboBoxOptions() {
|
|
145
|
-
return
|
|
123
|
+
return _ref3.apply(this, arguments);
|
|
146
124
|
};
|
|
147
125
|
}();
|
|
148
126
|
|
|
@@ -151,16 +129,16 @@ var showEuiComboBoxOptions = exports.showEuiComboBoxOptions = /*#__PURE__*/funct
|
|
|
151
129
|
*/
|
|
152
130
|
|
|
153
131
|
var waitForEuiContextMenuPanelTransition = exports.waitForEuiContextMenuPanelTransition = /*#__PURE__*/function () {
|
|
154
|
-
var
|
|
132
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
155
133
|
var getPanels;
|
|
156
|
-
return _regeneratorRuntime().wrap(function
|
|
157
|
-
while (1) switch (
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
135
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
158
136
|
case 0:
|
|
159
137
|
// Used document instead of container or screen due to context menus living in portals
|
|
160
138
|
getPanels = function getPanels() {
|
|
161
139
|
return document.querySelectorAll('.euiContextMenuPanel');
|
|
162
140
|
}; // 2 panels will appear for the transition animation
|
|
163
|
-
|
|
141
|
+
_context4.next = 3;
|
|
164
142
|
return (0, _react.waitFor)(function () {
|
|
165
143
|
expect(getPanels().length).toEqual(2);
|
|
166
144
|
});
|
|
@@ -175,11 +153,11 @@ var waitForEuiContextMenuPanelTransition = exports.waitForEuiContextMenuPanelTra
|
|
|
175
153
|
expect(getPanels().length).toEqual(1);
|
|
176
154
|
case 6:
|
|
177
155
|
case "end":
|
|
178
|
-
return
|
|
156
|
+
return _context4.stop();
|
|
179
157
|
}
|
|
180
|
-
},
|
|
158
|
+
}, _callee4);
|
|
181
159
|
}));
|
|
182
160
|
return function waitForEuiContextMenuPanelTransition() {
|
|
183
|
-
return
|
|
161
|
+
return _ref4.apply(this, arguments);
|
|
184
162
|
};
|
|
185
163
|
}();
|
|
@@ -79,7 +79,6 @@ export var CollapsedItemActions = function CollapsedItemActions(_ref) {
|
|
|
79
79
|
},
|
|
80
80
|
toolTipContent: toolTipContent,
|
|
81
81
|
toolTipProps: {
|
|
82
|
-
delay: 'long',
|
|
83
82
|
// Avoid screen-readers announcing the same text twice
|
|
84
83
|
disableScreenReaderOutput: typeof buttonContent === 'string' && buttonContent === toolTipContent
|
|
85
84
|
}
|
|
@@ -103,8 +102,7 @@ export var CollapsedItemActions = function CollapsedItemActions(_ref) {
|
|
|
103
102
|
"data-test-subj": "euiCollapsedItemActionsButton"
|
|
104
103
|
});
|
|
105
104
|
var withTooltip = !actionsDisabled && ___EmotionJSX(EuiToolTip, {
|
|
106
|
-
content: allActionsTooltip
|
|
107
|
-
delay: "long"
|
|
105
|
+
content: allActionsTooltip
|
|
108
106
|
}, popoverButton);
|
|
109
107
|
return ___EmotionJSX(EuiPopover, {
|
|
110
108
|
className: className,
|
|
@@ -32,7 +32,6 @@ export var DefaultItemAction = function DefaultItemAction(_ref) {
|
|
|
32
32
|
var tooltipContent = callWithItemIfFunction(item)(action.description);
|
|
33
33
|
var tooltipProps = {
|
|
34
34
|
content: tooltipContent,
|
|
35
|
-
delay: 'long',
|
|
36
35
|
// Avoid screen-readers announcing the same text twice
|
|
37
36
|
disableScreenReaderOutput: typeof actionContent === 'string' && actionContent === tooltipContent
|
|
38
37
|
};
|
|
@@ -353,8 +353,7 @@ export var useDataGridDisplaySelector = function useDataGridDisplaySelector(show
|
|
|
353
353
|
},
|
|
354
354
|
panelClassName: "euiDataGrid__displayPopoverPanel",
|
|
355
355
|
button: ___EmotionJSX(EuiToolTip, {
|
|
356
|
-
content: buttonLabel
|
|
357
|
-
delay: "long"
|
|
356
|
+
content: buttonLabel
|
|
358
357
|
}, ___EmotionJSX(EuiButtonIcon, {
|
|
359
358
|
size: "xs",
|
|
360
359
|
iconType: "controls",
|
|
@@ -32,8 +32,7 @@ export var useDataGridFullScreenSelector = function useDataGridFullScreenSelecto
|
|
|
32
32
|
fullScreenButtonActive = _useEuiI18n2[1];
|
|
33
33
|
var fullScreenSelector = useMemo(function () {
|
|
34
34
|
return ___EmotionJSX(EuiToolTip, {
|
|
35
|
-
content: isFullScreen ? ___EmotionJSX(React.Fragment, null, fullScreenButtonActive, " (", ___EmotionJSX("kbd", null, "esc"), ")") : fullScreenButton
|
|
36
|
-
delay: "long"
|
|
35
|
+
content: isFullScreen ? ___EmotionJSX(React.Fragment, null, fullScreenButtonActive, " (", ___EmotionJSX("kbd", null, "esc"), ")") : fullScreenButton
|
|
37
36
|
}, ___EmotionJSX(EuiButtonIcon, {
|
|
38
37
|
size: "xs",
|
|
39
38
|
iconType: isFullScreen ? 'fullScreenExit' : 'fullScreen',
|
|
@@ -35,8 +35,7 @@ export var useDataGridKeyboardShortcuts = function useDataGridKeyboardShortcuts(
|
|
|
35
35
|
anchorPosition: "downRight",
|
|
36
36
|
panelPaddingSize: "none",
|
|
37
37
|
button: ___EmotionJSX(EuiToolTip, {
|
|
38
|
-
content: title
|
|
39
|
-
delay: "long"
|
|
38
|
+
content: title
|
|
40
39
|
}, ___EmotionJSX(EuiButtonIcon, {
|
|
41
40
|
size: "xs",
|
|
42
41
|
iconType: "keyboard",
|
|
@@ -19,7 +19,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
19
19
|
* Side Public License, v 1.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import React, { Component, createRef } from 'react';
|
|
22
|
+
import React, { Component, createRef, isValidElement } from 'react';
|
|
23
23
|
import classNames from 'classnames';
|
|
24
24
|
import { withEuiTheme } from '../../services';
|
|
25
25
|
import { EuiFlexGroup, EuiFlexItem } from '../flex';
|
|
@@ -87,6 +87,18 @@ export var EuiFilterSelectItemClass = /*#__PURE__*/function (_Component) {
|
|
|
87
87
|
}
|
|
88
88
|
_inherits(EuiFilterSelectItemClass, _Component);
|
|
89
89
|
return _createClass(EuiFilterSelectItemClass, [{
|
|
90
|
+
key: "componentDidMount",
|
|
91
|
+
value: function componentDidMount() {
|
|
92
|
+
var _this$props2 = this.props,
|
|
93
|
+
isFocused = _this$props2.isFocused,
|
|
94
|
+
toolTipContent = _this$props2.toolTipContent,
|
|
95
|
+
disabled = _this$props2.disabled,
|
|
96
|
+
children = _this$props2.children;
|
|
97
|
+
if ( /*#__PURE__*/isValidElement(children) && !disabled && toolTipContent) {
|
|
98
|
+
this.toggleToolTip(isFocused !== null && isFocused !== void 0 ? isFocused : false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
90
102
|
key: "componentDidUpdate",
|
|
91
103
|
value: function componentDidUpdate(prevProps) {
|
|
92
104
|
if (this.props.isFocused && !prevProps.isFocused) {
|
|
@@ -95,31 +107,39 @@ export var EuiFilterSelectItemClass = /*#__PURE__*/function (_Component) {
|
|
|
95
107
|
block: 'nearest'
|
|
96
108
|
});
|
|
97
109
|
}
|
|
110
|
+
var _this$props3 = this.props,
|
|
111
|
+
isFocused = _this$props3.isFocused,
|
|
112
|
+
toolTipContent = _this$props3.toolTipContent,
|
|
113
|
+
disabled = _this$props3.disabled,
|
|
114
|
+
children = _this$props3.children;
|
|
115
|
+
if ( /*#__PURE__*/isValidElement(children) && !disabled && toolTipContent && isFocused !== prevProps.isFocused) {
|
|
116
|
+
this.toggleToolTip(isFocused !== null && isFocused !== void 0 ? isFocused : false);
|
|
117
|
+
}
|
|
98
118
|
}
|
|
99
119
|
}, {
|
|
100
120
|
key: "render",
|
|
101
121
|
value: function render() {
|
|
102
|
-
var _this$
|
|
103
|
-
theme = _this$
|
|
104
|
-
children = _this$
|
|
105
|
-
className = _this$
|
|
106
|
-
disabled = _this$
|
|
107
|
-
checked = _this$
|
|
108
|
-
isFocused = _this$
|
|
109
|
-
showIcons = _this$
|
|
110
|
-
toolTipContent = _this$
|
|
111
|
-
toolTipProps = _this$
|
|
112
|
-
style = _this$
|
|
113
|
-
truncateContent = _this$
|
|
114
|
-
forwardRef = _this$
|
|
115
|
-
rest = _objectWithoutProperties(_this$
|
|
122
|
+
var _this$props4 = this.props,
|
|
123
|
+
theme = _this$props4.theme,
|
|
124
|
+
children = _this$props4.children,
|
|
125
|
+
className = _this$props4.className,
|
|
126
|
+
disabled = _this$props4.disabled,
|
|
127
|
+
checked = _this$props4.checked,
|
|
128
|
+
isFocused = _this$props4.isFocused,
|
|
129
|
+
showIcons = _this$props4.showIcons,
|
|
130
|
+
toolTipContent = _this$props4.toolTipContent,
|
|
131
|
+
toolTipProps = _this$props4.toolTipProps,
|
|
132
|
+
style = _this$props4.style,
|
|
133
|
+
truncateContent = _this$props4.truncateContent,
|
|
134
|
+
forwardRef = _this$props4.forwardRef,
|
|
135
|
+
rest = _objectWithoutProperties(_this$props4, _excluded);
|
|
116
136
|
var styles = euiFilterSelectItemStyles(theme);
|
|
117
137
|
var cssStyles = [styles.euiFilterSelectItem, isFocused && styles.isFocused];
|
|
118
138
|
var classes = classNames('euiFilterSelectItem', className);
|
|
119
139
|
var hasToolTip =
|
|
120
140
|
// we're using isValidElement here as EuiToolTipAnchor uses
|
|
121
141
|
// cloneElement to enhance the element with required attributes
|
|
122
|
-
/*#__PURE__*/
|
|
142
|
+
/*#__PURE__*/isValidElement(children) && !disabled && toolTipContent;
|
|
123
143
|
var anchorProps = undefined;
|
|
124
144
|
if (hasToolTip) {
|
|
125
145
|
var _toolTipProps$anchorP, _toolTipProps$anchorP2;
|
|
@@ -129,7 +149,6 @@ export var EuiFilterSelectItemClass = /*#__PURE__*/function (_Component) {
|
|
|
129
149
|
}) : {
|
|
130
150
|
style: style
|
|
131
151
|
};
|
|
132
|
-
this.toggleToolTip(isFocused !== null && isFocused !== void 0 ? isFocused : false);
|
|
133
152
|
}
|
|
134
153
|
var iconNode;
|
|
135
154
|
if (showIcons) {
|
|
@@ -126,7 +126,6 @@ export var EuiKeyPadMenuItem = function EuiKeyPadMenuItem(_ref) {
|
|
|
126
126
|
}, label)));
|
|
127
127
|
return betaBadgeLabel ? ___EmotionJSX(EuiToolTip, _extends({}, betaBadgeTooltipProps, {
|
|
128
128
|
title: betaBadgeLabel,
|
|
129
|
-
content: betaBadgeTooltipContent
|
|
130
|
-
delay: "long"
|
|
129
|
+
content: betaBadgeTooltipContent
|
|
131
130
|
}), button) : button;
|
|
132
131
|
};
|
|
@@ -171,8 +171,7 @@ export var EuiListGroupItem = function EuiListGroupItem(_ref) {
|
|
|
171
171
|
style: style
|
|
172
172
|
}, ___EmotionJSX(EuiToolTip, _extends({
|
|
173
173
|
content: toolTipText !== null && toolTipText !== void 0 ? toolTipText : label,
|
|
174
|
-
position: "right"
|
|
175
|
-
delay: "long"
|
|
174
|
+
position: "right"
|
|
176
175
|
}, toolTipProps, {
|
|
177
176
|
anchorClassName: anchorClasses,
|
|
178
177
|
anchorProps: anchorPropsAndCss
|
|
@@ -163,8 +163,11 @@ export var EuiMarkdownEditorDropZone = function EuiMarkdownEditorDropZone(props)
|
|
|
163
163
|
getInputProps = _useDropzone.getInputProps,
|
|
164
164
|
open = _useDropzone.open;
|
|
165
165
|
var rootProps = _objectSpread({}, getRootProps());
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
/* Unset the default `role="button"` attribute to prevent invalid nested interactive elements.
|
|
167
|
+
The dropzone has `noClick=true` and `noKeyboard=true` set via `useDropzone`.
|
|
168
|
+
Keyboard drop interactions expect the drop zone element to have `role="button` but we're supporting
|
|
169
|
+
adding files via a standalone footer button instead." */
|
|
170
|
+
rootProps.role = undefined;
|
|
168
171
|
return ___EmotionJSX("div", _extends({}, rootProps, {
|
|
169
172
|
css: cssStyles,
|
|
170
173
|
className: classes
|
|
@@ -16,6 +16,11 @@ import { EuiToolTip } from '../tool_tip';
|
|
|
16
16
|
import { MODE_VIEWING } from './markdown_modes';
|
|
17
17
|
import { EuiMarkdownContext } from './markdown_context';
|
|
18
18
|
import { euiMarkdownEditorToolbarStyles } from './markdown_editor_toolbar.styles';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A helper type to ensure the `button` property is defined
|
|
22
|
+
* on an ` EuiMarkdownEditorUiPlugin ` object.
|
|
23
|
+
*/
|
|
19
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
20
25
|
var boldItalicButtons = [{
|
|
21
26
|
id: 'mdBold',
|
|
@@ -91,7 +96,7 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
91
96
|
markdownActions = _ref2.markdownActions,
|
|
92
97
|
viewMode = _ref2.viewMode,
|
|
93
98
|
onClickPreview = _ref2.onClickPreview,
|
|
94
|
-
|
|
99
|
+
_uiPlugins = _ref2.uiPlugins,
|
|
95
100
|
selectedNode = _ref2.selectedNode,
|
|
96
101
|
right = _ref2.right;
|
|
97
102
|
var _useContext = useContext(EuiMarkdownContext),
|
|
@@ -105,6 +110,9 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
105
110
|
var isPreviewing = viewMode === MODE_VIEWING;
|
|
106
111
|
var isEditable = !isPreviewing && !readOnly;
|
|
107
112
|
var styles = useEuiMemoizedStyles(euiMarkdownEditorToolbarStyles);
|
|
113
|
+
var uiPlugins = _uiPlugins.filter(function (uiPlugin) {
|
|
114
|
+
return !!uiPlugin.button;
|
|
115
|
+
});
|
|
108
116
|
return ___EmotionJSX("div", {
|
|
109
117
|
ref: ref,
|
|
110
118
|
css: styles.euiMarkdownEditorToolbar,
|
|
@@ -116,8 +124,7 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
116
124
|
}, boldItalicButtons.map(function (item) {
|
|
117
125
|
return ___EmotionJSX(EuiToolTip, {
|
|
118
126
|
key: item.id,
|
|
119
|
-
content: item.label
|
|
120
|
-
delay: "long"
|
|
127
|
+
content: item.label
|
|
121
128
|
}, ___EmotionJSX(EuiMarkdownEditorToolbarButton, {
|
|
122
129
|
selectedNode: selectedNode,
|
|
123
130
|
handleMdButtonClick: handleMdButtonClick,
|
|
@@ -133,8 +140,7 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
133
140
|
}), listButtons.map(function (item) {
|
|
134
141
|
return ___EmotionJSX(EuiToolTip, {
|
|
135
142
|
key: item.id,
|
|
136
|
-
content: item.label
|
|
137
|
-
delay: "long"
|
|
143
|
+
content: item.label
|
|
138
144
|
}, ___EmotionJSX(EuiMarkdownEditorToolbarButton, {
|
|
139
145
|
selectedNode: selectedNode,
|
|
140
146
|
handleMdButtonClick: handleMdButtonClick,
|
|
@@ -150,8 +156,7 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
150
156
|
}), quoteCodeLinkButtons.map(function (item) {
|
|
151
157
|
return ___EmotionJSX(EuiToolTip, {
|
|
152
158
|
key: item.id,
|
|
153
|
-
content: item.label
|
|
154
|
-
delay: "long"
|
|
159
|
+
content: item.label
|
|
155
160
|
}, ___EmotionJSX(EuiMarkdownEditorToolbarButton, {
|
|
156
161
|
selectedNode: selectedNode,
|
|
157
162
|
handleMdButtonClick: handleMdButtonClick,
|
|
@@ -169,8 +174,7 @@ export var EuiMarkdownEditorToolbar = /*#__PURE__*/forwardRef(function (_ref2, r
|
|
|
169
174
|
button = _ref3.button;
|
|
170
175
|
return ___EmotionJSX(EuiToolTip, {
|
|
171
176
|
key: name,
|
|
172
|
-
content: button.label
|
|
173
|
-
delay: "long"
|
|
177
|
+
content: button.label
|
|
174
178
|
}, ___EmotionJSX(EuiMarkdownEditorToolbarButton, {
|
|
175
179
|
selectedNode: selectedNode,
|
|
176
180
|
handleMdButtonClick: handleMdButtonClick,
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
9
2
|
/*
|
|
10
3
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
11
4
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -14,99 +7,80 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
14
7
|
* Side Public License, v 1.
|
|
15
8
|
*/
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
19
|
-
* into portals.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import React, { Component } from 'react';
|
|
10
|
+
import { memo, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
23
11
|
import { createPortal } from 'react-dom';
|
|
24
12
|
import { EuiNestedThemeContext } from '../../services';
|
|
25
13
|
import { usePropsWithComponentDefaults } from '../provider/component_defaults';
|
|
26
|
-
|
|
14
|
+
var usePortalEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
|
|
27
15
|
var INSERT_POSITIONS = ['after', 'before'];
|
|
28
16
|
var insertPositions = {
|
|
29
17
|
after: 'afterend',
|
|
30
18
|
before: 'beforebegin'
|
|
31
19
|
};
|
|
32
|
-
export var EuiPortal = function
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
_inherits(EuiPortalClass, _Component);
|
|
47
|
-
return _createClass(EuiPortalClass, [{
|
|
48
|
-
key: "componentDidMount",
|
|
49
|
-
value: function componentDidMount() {
|
|
50
|
-
var insert = this.props.insert;
|
|
51
|
-
var portalNode = document.createElement('div');
|
|
52
|
-
portalNode.dataset.euiportal = 'true';
|
|
53
|
-
if (insert == null) {
|
|
54
|
-
// no insertion defined, append to body
|
|
55
|
-
document.body.appendChild(portalNode);
|
|
56
|
-
} else {
|
|
57
|
-
// inserting before or after an element
|
|
58
|
-
var sibling = insert.sibling,
|
|
59
|
-
position = insert.position;
|
|
60
|
-
sibling.insertAdjacentElement(insertPositions[position], portalNode);
|
|
61
|
-
}
|
|
62
|
-
this.setThemeColor(portalNode);
|
|
63
|
-
this.updatePortalRef(portalNode);
|
|
20
|
+
export var EuiPortal = /*#__PURE__*/memo(function (_props) {
|
|
21
|
+
var props = usePropsWithComponentDefaults('EuiPortal', _props);
|
|
22
|
+
var children = props.children,
|
|
23
|
+
insert = props.insert,
|
|
24
|
+
setPortalRef = props.portalRef;
|
|
25
|
+
var portalRef = useRef(setPortalRef);
|
|
26
|
+
var _useContext = useContext(EuiNestedThemeContext),
|
|
27
|
+
hasDifferentColorFromGlobalTheme = _useContext.hasDifferentColorFromGlobalTheme,
|
|
28
|
+
colorClassName = _useContext.colorClassName;
|
|
29
|
+
var _useState = useState(null),
|
|
30
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
+
portalNode = _useState2[0],
|
|
32
|
+
setPortalNode = _useState2[1];
|
|
64
33
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
key: "componentWillUnmount",
|
|
73
|
-
value: function componentWillUnmount() {
|
|
74
|
-
var portalNode = this.state.portalNode;
|
|
75
|
-
if (portalNode !== null && portalNode !== void 0 && portalNode.parentNode) {
|
|
76
|
-
portalNode.parentNode.removeChild(portalNode);
|
|
77
|
-
}
|
|
78
|
-
this.updatePortalRef(null);
|
|
34
|
+
// Set the inherited color of the portal based on the wrapping EuiThemeProvider
|
|
35
|
+
var setThemeColor = function setThemeColor(portalNode) {
|
|
36
|
+
if (hasDifferentColorFromGlobalTheme && insert == null) {
|
|
37
|
+
portalNode.classList.add(colorClassName);
|
|
79
38
|
}
|
|
39
|
+
};
|
|
40
|
+
var updatePortalRef = function updatePortalRef(ref) {
|
|
41
|
+
var _portalRef$current;
|
|
42
|
+
(_portalRef$current = portalRef.current) === null || _portalRef$current === void 0 || _portalRef$current.call(portalRef, ref);
|
|
43
|
+
};
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
portalRef.current = setPortalRef;
|
|
46
|
+
}, [setPortalRef]);
|
|
80
47
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
48
|
+
/* Uses `useLayoutEffect` on client-side instead of `useEffect` to ensure the portal
|
|
49
|
+
node is created and inserted into the DOM synchronously. This matches the same timing
|
|
50
|
+
as the previous class component `componentDidMount` behavior.
|
|
51
|
+
Using `useEffect` would add an additional render cycle that would break expected
|
|
52
|
+
behavior of e.g. `@hello-pangea/dnd` which handles keyboard focus and doesn't expect
|
|
53
|
+
a rerender. This falls back to `useEffect` for SSR to avoid console errors. `useEffect` will
|
|
54
|
+
be a no-op, same as `componentDidMount` */
|
|
55
|
+
usePortalEffect(function () {
|
|
56
|
+
var node = document.createElement('div');
|
|
57
|
+
node.dataset.euiportal = 'true';
|
|
58
|
+
if (insert == null) {
|
|
59
|
+
// no insertion defined, append to body
|
|
60
|
+
document.body.appendChild(node);
|
|
61
|
+
} else {
|
|
62
|
+
// inserting before or after an element
|
|
63
|
+
var sibling = insert.sibling,
|
|
64
|
+
position = insert.position;
|
|
65
|
+
sibling.insertAdjacentElement(insertPositions[position], node);
|
|
100
66
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
67
|
+
setThemeColor(node);
|
|
68
|
+
updatePortalRef(node);
|
|
69
|
+
|
|
70
|
+
// Update state with portalNode to intentionally trigger component rerender
|
|
71
|
+
// and call createPortal with the correct root element
|
|
72
|
+
setPortalNode(node);
|
|
73
|
+
return function () {
|
|
74
|
+
if (node !== null && node !== void 0 && node.parentNode) {
|
|
75
|
+
node.parentNode.removeChild(node);
|
|
107
76
|
}
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
77
|
+
updatePortalRef(null);
|
|
78
|
+
};
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- on mount only
|
|
80
|
+
}, []);
|
|
81
|
+
if (!portalNode) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return /*#__PURE__*/createPortal(children, portalNode);
|
|
85
|
+
});
|
|
86
|
+
EuiPortal.displayName = 'EuiPortal';
|