@elastic/eui 72.2.0 → 73.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +6185 -0
  2. package/dist/eui_theme_dark.css +15 -12
  3. package/dist/eui_theme_dark.min.css +1 -1
  4. package/dist/eui_theme_light.css +15 -12
  5. package/dist/eui_theme_light.min.css +1 -1
  6. package/es/components/datagrid/controls/column_selector.js +23 -7
  7. package/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
  8. package/es/components/datagrid/data_grid.a11y.js +3 -2
  9. package/es/components/notification/notification_event.a11y.js +113 -0
  10. package/es/components/page/page_header/page_header.a11y.js +32 -0
  11. package/es/components/portal/portal.a11y.js +70 -0
  12. package/es/components/tool_tip/tool_tip.js +10 -5
  13. package/es/components/tool_tip/tool_tip_manager.js +42 -0
  14. package/eui.d.ts +11 -0
  15. package/i18ntokens.json +36 -20
  16. package/lib/components/datagrid/controls/column_selector.js +21 -6
  17. package/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
  18. package/lib/components/datagrid/data_grid.a11y.js +3 -2
  19. package/lib/components/notification/notification_event.a11y.js +117 -0
  20. package/lib/components/page/page_header/page_header.a11y.js +40 -0
  21. package/lib/components/portal/portal.a11y.js +73 -0
  22. package/lib/components/tool_tip/tool_tip.js +13 -7
  23. package/lib/components/tool_tip/tool_tip_manager.js +50 -0
  24. package/optimize/es/components/datagrid/controls/column_selector.js +22 -7
  25. package/optimize/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
  26. package/optimize/es/components/datagrid/data_grid.a11y.js +3 -2
  27. package/optimize/es/components/notification/notification_event.a11y.js +103 -0
  28. package/optimize/es/components/page/page_header/page_header.a11y.js +32 -0
  29. package/optimize/es/components/portal/portal.a11y.js +60 -0
  30. package/optimize/es/components/tool_tip/tool_tip.js +10 -5
  31. package/optimize/es/components/tool_tip/tool_tip_manager.js +41 -0
  32. package/optimize/lib/components/datagrid/controls/column_selector.js +21 -6
  33. package/optimize/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
  34. package/optimize/lib/components/datagrid/data_grid.a11y.js +3 -2
  35. package/optimize/lib/components/notification/notification_event.a11y.js +117 -0
  36. package/optimize/lib/components/page/page_header/page_header.a11y.js +40 -0
  37. package/optimize/lib/components/portal/portal.a11y.js +73 -0
  38. package/optimize/lib/components/tool_tip/tool_tip.js +13 -7
  39. package/optimize/lib/components/tool_tip/tool_tip_manager.js +49 -0
  40. package/package.json +1 -1
  41. package/src/components/datagrid/controls/_data_grid_column_sorting.scss +14 -13
  42. package/src/components/date_picker/react-datepicker/LICENSE +21 -0
  43. package/src/components/date_picker/react-datepicker/README.md +168 -0
  44. package/src/services/theme/README.md +153 -0
  45. package/src/test/README.md +59 -0
  46. package/test-env/components/datagrid/controls/column_selector.js +21 -6
  47. package/test-env/components/datagrid/controls/column_sorting_draggable.js +17 -8
  48. package/test-env/components/datagrid/data_grid.a11y.js +3 -2
  49. package/test-env/components/notification/notification_event.a11y.js +117 -0
  50. package/test-env/components/page/page_header/page_header.a11y.js +40 -0
  51. package/test-env/components/portal/portal.a11y.js +73 -0
  52. package/test-env/components/tool_tip/tool_tip.js +13 -7
  53. package/test-env/components/tool_tip/tool_tip_manager.js +49 -0
@@ -45,6 +45,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
45
45
 
46
46
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
47
47
 
48
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
49
+
48
50
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
49
51
 
50
52
  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."); }
@@ -116,6 +118,7 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
116
118
  }, [sortedColumns, columnSearchText, displayValues]);
117
119
  var isDragEnabled = allowColumnReorder && columnSearchText.length === 0; // only allow drag-and-drop when not filtering columns
118
120
 
121
+ var dragHandleAriaLabel = (0, _i18n.useEuiI18n)('euiColumnSelector.dragHandleAriaLabel', 'Drag handle');
119
122
  var buttonText = (0, _react2.jsx)(_i18n.EuiI18n, {
120
123
  token: "euiColumnSelector.button",
121
124
  default: "Columns"
@@ -188,18 +191,23 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
188
191
  key: id,
189
192
  draggableId: id,
190
193
  index: index,
191
- isDragDisabled: !isDragEnabled
194
+ isDragDisabled: !isDragEnabled,
195
+ hasInteractiveChildren: true,
196
+ customDragHandle: true
192
197
  }, function (provided, state) {
193
198
  return (0, _react2.jsx)("div", {
194
199
  className: "euiDataGridColumnSelector__item ".concat(state.isDragging && 'euiDataGridColumnSelector__item-isDragging'),
195
200
  "data-test-subj": "dataGridColumnSelectorColumnItem-".concat(id)
196
201
  }, (0, _react2.jsx)(_flex.EuiFlexGroup, {
197
202
  responsive: false,
198
- gutterSize: "m",
203
+ gutterSize: "s",
199
204
  alignItems: "center"
200
- }, (0, _react2.jsx)(_flex.EuiFlexItem, null, allowColumnHiding ? (0, _react2.jsx)(_form.EuiSwitch, {
205
+ }, allowColumnHiding && (0, _react2.jsx)(_flex.EuiFlexItem, {
206
+ grow: false
207
+ }, (0, _react2.jsx)(_form.EuiSwitch, {
201
208
  name: id,
202
209
  label: displayValues[id] || id,
210
+ showLabel: false,
203
211
  checked: visibleColumnIds.has(id),
204
212
  compressed: true,
205
213
  className: "euiSwitch--mini",
@@ -211,11 +219,18 @@ var useDataGridColumnSelector = function useDataGridColumnSelector(availableColu
211
219
  setVisibleColumns(nextVisibleColumns);
212
220
  },
213
221
  "data-test-subj": "dataGridColumnSelectorToggleColumnVisibility-".concat(id)
214
- }) : (0, _react2.jsx)("span", {
222
+ })), (0, _react2.jsx)(_flex.EuiFlexItem // This extra column name flex item affords the column more grabbable real estate
223
+ // for mouse users, while hiding repetition for keyboard/screen reader users
224
+ , _extends({}, provided.dragHandleProps, {
225
+ "aria-hidden": true,
226
+ tabIndex: -1
227
+ }), (0, _react2.jsx)("span", {
215
228
  className: "euiDataGridColumnSelector__itemLabel"
216
- }, id)), isDragEnabled && (0, _react2.jsx)(_flex.EuiFlexItem, {
229
+ }, displayValues[id] || id)), isDragEnabled && (0, _react2.jsx)(_flex.EuiFlexItem, _extends({
217
230
  grow: false
218
- }, (0, _react2.jsx)(_icon.EuiIcon, {
231
+ }, provided.dragHandleProps, {
232
+ "aria-label": dragHandleAriaLabel
233
+ }), (0, _react2.jsx)(_icon.EuiIcon, {
219
234
  type: "grab",
220
235
  color: "subdued"
221
236
  }))));
@@ -89,7 +89,9 @@ var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSortingDraggab
89
89
  var dragHandleAriaLabel = (0, _i18n.useEuiI18n)('euiColumnSortingDraggable.dragHandleAriaLabel', 'Drag handle');
90
90
  return (0, _react2.jsx)(_drag_and_drop.EuiDraggable, _extends({
91
91
  draggableId: id,
92
- index: index
92
+ index: index,
93
+ hasInteractiveChildren: true,
94
+ customDragHandle: true
93
95
  }, rest), function (provided, state) {
94
96
  return (0, _react2.jsx)("div", {
95
97
  className: "euiDataGridColumnSorting__item ".concat(state.isDragging && 'euiDataGridColumnSorting__item-isDragging')
@@ -131,18 +133,25 @@ var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSortingDraggab
131
133
  sorting.onSort(nextColumns);
132
134
  }
133
135
  });
134
- })), (0, _react2.jsx)(_flex.EuiFlexItem, {
136
+ })), (0, _react2.jsx)(_flex.EuiFlexItem, _extends({
137
+ className: "euiDataGridColumnSorting__name" // This extra column name flex item affords the column more grabbable real estate
138
+ // for mouse users, while hiding repetition for keyboard/screen reader users
139
+
140
+ }, provided.dragHandleProps, {
141
+ tabIndex: -1,
142
+ "aria-hidden": true
143
+ }), (0, _react2.jsx)(_flex.EuiFlexGroup, {
144
+ gutterSize: "xs",
145
+ alignItems: "center",
146
+ responsive: false
147
+ }, (0, _react2.jsx)(_flex.EuiFlexItem, {
135
148
  grow: false
136
149
  }, (0, _react2.jsx)(_token.EuiToken, {
137
150
  color: schemaDetails != null ? schemaDetails.color : undefined,
138
151
  iconType: schemaDetails != null ? schemaDetails.icon : 'tokenString'
139
- })), (0, _react2.jsx)(_flex.EuiFlexItem, {
140
- "aria-hidden": true
141
- }, (0, _react2.jsx)(_text.EuiText, {
152
+ })), (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_text.EuiText, {
142
153
  size: "xs"
143
- }, (0, _react2.jsx)("p", null, display))), (0, _react2.jsx)(_flex.EuiFlexItem, {
144
- className: "euiDataGridColumnSorting__orderButtons"
145
- }, (0, _react2.jsx)(_i18n.EuiI18n, {
154
+ }, (0, _react2.jsx)("p", null, display))))), (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_i18n.EuiI18n, {
146
155
  token: "euiColumnSortingDraggable.toggleLegend",
147
156
  default: "Select sorting method for {display}",
148
157
  values: {
@@ -188,7 +188,7 @@ describe('EuiDataGrid', function () {
188
188
  it('has zero violations on first render', function () {
189
189
  cy.checkAxe();
190
190
  });
191
- it('has zero violations when the columns reorder menu is open', function () {
191
+ it('has zero violations when the columns visibility menu is open', function () {
192
192
  cy.get('button[data-test-subj="dataGridColumnSelectorButton"]').realClick();
193
193
  cy.checkAxe();
194
194
  });
@@ -241,9 +241,10 @@ describe('EuiDataGrid', function () {
241
241
  cy.get('div[data-gridcell-visible-row-index="0"][data-gridcell-column-index="1"]').find('button.euiButtonIcon').last().realClick();
242
242
  cy.checkAxe();
243
243
  });
244
- it('has zero violations when the Favorite Distro column has been sorted', function () {
244
+ it('has zero violations on sort and when the columns sorting menu is open', function () {
245
245
  cy.get('button.euiDataGridHeaderCell__button').last().realClick();
246
246
  cy.get('button.euiListGroupItem__button').contains('Sort Alma to Debian').should('exist').realClick();
247
+ cy.get('button[data-test-subj="dataGridColumnSortingPopover"]').realClick();
247
248
  cy.checkAxe();
248
249
  });
249
250
  it('has zero violations when fullscreen is open', function () {
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ var _react = _interopRequireWildcard(require("react"));
6
+
7
+ var _context_menu = require("../context_menu");
8
+
9
+ var _notification_event = require("./notification_event");
10
+
11
+ var _panel = require("../panel");
12
+
13
+ var _react2 = require("@emotion/react");
14
+
15
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
+
17
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+
19
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
+
21
+ 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."); }
22
+
23
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
+
25
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
26
+
27
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
28
+
29
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
+
31
+ var NotificationEvent = function NotificationEvent() {
32
+ var _useState = (0, _react.useState)(false),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ isRead = _useState2[0],
35
+ setIsRead = _useState2[1];
36
+
37
+ var onRead = function onRead(id, isRead) {
38
+ setIsRead(!isRead);
39
+ };
40
+
41
+ var onOpenContextMenu = function onOpenContextMenu(id) {
42
+ return [(0, _react2.jsx)(_context_menu.EuiContextMenuItem, {
43
+ key: "contextMenuItemA",
44
+ onClick: function onClick() {
45
+ return onRead(id, isRead);
46
+ }
47
+ }, isRead ? 'Mark as unread' : 'Mark as read'), (0, _react2.jsx)(_context_menu.EuiContextMenuItem, {
48
+ key: "contextMenuItemB",
49
+ onClick: function onClick() {}
50
+ }, "View messages like this"), (0, _react2.jsx)(_context_menu.EuiContextMenuItem, {
51
+ key: "contextMenuItemC",
52
+ onClick: function onClick() {}
53
+ }, "Don\u2019t notify me about this")];
54
+ };
55
+
56
+ return (0, _react2.jsx)(_panel.EuiPanel, {
57
+ paddingSize: "none",
58
+ hasShadow: true,
59
+ style: {
60
+ maxWidth: '540px'
61
+ }
62
+ }, (0, _react2.jsx)(_notification_event.EuiNotificationEvent, {
63
+ id: "cy-eui-notification-1",
64
+ type: "Report",
65
+ iconType: "logoKibana",
66
+ iconAriaLabel: "Kibana",
67
+ time: "1 min ago",
68
+ title: "[Error Monitoring Report] is generated",
69
+ primaryAction: "Download",
70
+ primaryActionProps: {
71
+ iconType: 'download'
72
+ },
73
+ messages: ['The reported was generated at 17:12:16 GMT+4'],
74
+ isRead: isRead,
75
+ onRead: onRead,
76
+ onOpenContextMenu: onOpenContextMenu,
77
+ onClickPrimaryAction: function onClickPrimaryAction() {},
78
+ onClickTitle: function onClickTitle() {}
79
+ }));
80
+ };
81
+
82
+ describe('EuiNotificationEvent', function () {
83
+ beforeEach(function () {
84
+ cy.viewport(1024, 768); // medium breakpoint
85
+
86
+ cy.realMount((0, _react2.jsx)(NotificationEvent, null));
87
+ cy.get('article.euiNotificationEvent').should('exist');
88
+ });
89
+ describe('Automated accessibility check', function () {
90
+ it('has zero violations on first render', function () {
91
+ cy.checkAxe();
92
+ });
93
+ it('has zero violations when popover is open', function () {
94
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').realClick();
95
+ cy.get('div.euiPopover__panel').should('exist');
96
+ cy.checkAxe();
97
+ });
98
+ it('has zero violations after the Mark as read button is clicked', function () {
99
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').realClick();
100
+ cy.get('div.euiPopover__panel').should('exist');
101
+ cy.get('div.euiPopover__panel button').first().realClick();
102
+ cy.checkAxe();
103
+ });
104
+ });
105
+ describe('Keyboard accessibility', function () {
106
+ it('has zero violations when the popover is opened by keyboard', function () {
107
+ cy.repeatRealPress('Tab');
108
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').should('have.focus');
109
+ cy.realPress('Enter');
110
+ cy.get('div.euiPopover__panel').should('exist');
111
+ cy.checkAxe();
112
+ cy.realPress('Escape');
113
+ cy.get('div.euiPopover__panel').should('not.exist');
114
+ cy.checkAxe();
115
+ });
116
+ });
117
+ });
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _button = require("../../button");
6
+
7
+ var _page_header = require("./page_header");
8
+
9
+ var _react2 = require("@emotion/react");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ /*
14
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
15
+ * or more contributor license agreements. Licensed under the Elastic License
16
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
17
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
18
+ * Side Public License, v 1.
19
+ */
20
+ /// <reference types="../../../../cypress/support"/>
21
+ describe('EuiPageHeader', function () {
22
+ beforeEach(function () {
23
+ cy.viewport(1024, 768); // medium breakpoint
24
+
25
+ cy.realMount((0, _react2.jsx)(_page_header.EuiPageHeader, {
26
+ pageTitle: "Page title",
27
+ iconType: "logoKibana",
28
+ description: "This description should be describing the current page as depicted by the page title. It will never extend beneath the right side content.",
29
+ rightSideItems: [(0, _react2.jsx)(_button.EuiButton, {
30
+ fill: true
31
+ }, "Add something"), (0, _react2.jsx)(_button.EuiButton, null, "Do something")]
32
+ }));
33
+ cy.get('h1.euiTitle').should('exist');
34
+ });
35
+ describe('Automated accessibility check', function () {
36
+ it('has zero violations on first render', function () {
37
+ cy.checkAxe();
38
+ });
39
+ });
40
+ });
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ var _react = _interopRequireWildcard(require("react"));
6
+
7
+ var _button = require("../button");
8
+
9
+ var _portal = require("./portal");
10
+
11
+ var _react2 = require("@emotion/react");
12
+
13
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
+
15
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+
17
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
+
19
+ 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."); }
20
+
21
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
+
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+
25
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
26
+
27
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
+
29
+ var Portal = function Portal() {
30
+ var _useState = (0, _react.useState)(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ isPortalVisible = _useState2[0],
33
+ setIsPortalVisible = _useState2[1];
34
+
35
+ var togglePortal = function togglePortal() {
36
+ setIsPortalVisible(!isPortalVisible);
37
+ };
38
+
39
+ var closePortal = function closePortal() {
40
+ setIsPortalVisible(false);
41
+ };
42
+
43
+ var customPortal;
44
+
45
+ if (isPortalVisible) {
46
+ customPortal = (0, _react2.jsx)(_portal.EuiPortal, null, (0, _react2.jsx)("div", null, "This is the portal. Click anywhere to close."), (0, _react2.jsx)(_button.EuiButton, {
47
+ onClick: closePortal
48
+ }, "Close portal"));
49
+ }
50
+
51
+ return (0, _react2.jsx)("div", null, (0, _react2.jsx)(_button.EuiButton, {
52
+ onClick: togglePortal
53
+ }, "View guide"), customPortal);
54
+ };
55
+
56
+ describe('EuiPortal', function () {
57
+ beforeEach(function () {
58
+ cy.viewport(1024, 768); // medium breakpoint
59
+
60
+ cy.realMount((0, _react2.jsx)(Portal, null));
61
+ cy.get('div[data-relative-to-header="above"]').should('not.exist');
62
+ });
63
+ describe('Automated accessibility check', function () {
64
+ it('has zero violations on first render', function () {
65
+ cy.checkAxe();
66
+ });
67
+ it('has zero violations after the portal is activated', function () {
68
+ cy.get('button[type="button"]').contains('View guide').realClick();
69
+ cy.get('div[data-euiportal="true"]').should('exist');
70
+ cy.checkAxe();
71
+ });
72
+ });
73
+ });
@@ -15,19 +15,21 @@ var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
16
  var _common = require("../common");
17
17
 
18
- var _portal = require("../portal");
18
+ var _services = require("../../services");
19
19
 
20
- var _tool_tip_anchor = require("./tool_tip_anchor");
20
+ var _react2 = require("../../services/react");
21
21
 
22
- var _tool_tip_arrow = require("./tool_tip_arrow");
22
+ var _resize_observer = require("../observer/resize_observer");
23
+
24
+ var _portal = require("../portal");
23
25
 
24
26
  var _tool_tip_popover = require("./tool_tip_popover");
25
27
 
26
- var _react2 = require("../../services/react");
28
+ var _tool_tip_anchor = require("./tool_tip_anchor");
27
29
 
28
- var _services = require("../../services");
30
+ var _tool_tip_arrow = require("./tool_tip_arrow");
29
31
 
30
- var _resize_observer = require("../observer/resize_observer");
32
+ var _tool_tip_manager = require("./tool_tip_manager");
31
33
 
32
34
  var _react3 = require("@emotion/react");
33
35
 
@@ -162,9 +164,11 @@ var EuiToolTip = /*#__PURE__*/function (_Component) {
162
164
  if (!_this.timeoutId) {
163
165
  _this.timeoutId = setTimeout(function () {
164
166
  (0, _react2.enqueueStateChange)(function () {
165
- return _this.setState({
167
+ _this.setState({
166
168
  visible: true
167
169
  });
170
+
171
+ _tool_tip_manager.toolTipManager.registerTooltip(_this.hideToolTip);
168
172
  });
169
173
  }, delayToMsMap[_this.props.delay]);
170
174
  }
@@ -225,6 +229,8 @@ var EuiToolTip = /*#__PURE__*/function (_Component) {
225
229
  toolTipStyles: DEFAULT_TOOLTIP_STYLES,
226
230
  arrowStyles: undefined
227
231
  });
232
+
233
+ _tool_tip_manager.toolTipManager.deregisterToolTip(_this.hideToolTip);
228
234
  }
229
235
  });
230
236
  });
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toolTipManager = void 0;
7
+
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
19
+
20
+ /**
21
+ * Manager utility that ensures only one tooltip is visible at a time
22
+ *
23
+ * UX rationale (primarily for mouse-only users):
24
+ * @see https://github.com/elastic/kibana/issues/144482
25
+ * @see https://github.com/elastic/eui/issues/5883
26
+ */
27
+ var ToolTipManager = function ToolTipManager() {
28
+ var _this = this;
29
+
30
+ _classCallCheck(this, ToolTipManager);
31
+
32
+ _defineProperty(this, "toolTipsToHide", new Set());
33
+
34
+ _defineProperty(this, "registerTooltip", function (hideCallback) {
35
+ _this.toolTipsToHide.forEach(function (hide) {
36
+ return hide();
37
+ });
38
+
39
+ _this.toolTipsToHide.clear();
40
+
41
+ _this.toolTipsToHide.add(hideCallback);
42
+ });
43
+
44
+ _defineProperty(this, "deregisterToolTip", function (hideCallback) {
45
+ _this.toolTipsToHide.delete(hideCallback);
46
+ });
47
+ };
48
+
49
+ var toolTipManager = new ToolTipManager();
50
+ exports.toolTipManager = toolTipManager;
@@ -1,4 +1,5 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _extends from "@babel/runtime/helpers/extends";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
 
4
5
  /*
@@ -11,7 +12,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
11
12
  import React, { Fragment, useState, useMemo, useCallback } from 'react';
12
13
  import classNames from 'classnames';
13
14
  import { EuiPopover, EuiPopoverFooter, EuiPopoverTitle } from '../../popover';
14
- import { EuiI18n } from '../../i18n';
15
+ import { EuiI18n, useEuiI18n } from '../../i18n';
15
16
  import { EuiButtonEmpty } from '../../button';
16
17
  import { EuiFlexGroup, EuiFlexItem } from '../../flex';
17
18
  import { EuiSwitch, EuiFieldText } from '../../form';
@@ -79,6 +80,8 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
79
80
  }, [sortedColumns, columnSearchText, displayValues]);
80
81
  var isDragEnabled = allowColumnReorder && columnSearchText.length === 0; // only allow drag-and-drop when not filtering columns
81
82
 
83
+ var dragHandleAriaLabel = useEuiI18n('euiColumnSelector.dragHandleAriaLabel', 'Drag handle');
84
+
82
85
  var buttonText = ___EmotionJSX(EuiI18n, {
83
86
  token: "euiColumnSelector.button",
84
87
  default: "Columns"
@@ -151,18 +154,23 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
151
154
  key: id,
152
155
  draggableId: id,
153
156
  index: index,
154
- isDragDisabled: !isDragEnabled
157
+ isDragDisabled: !isDragEnabled,
158
+ hasInteractiveChildren: true,
159
+ customDragHandle: true
155
160
  }, function (provided, state) {
156
161
  return ___EmotionJSX("div", {
157
162
  className: "euiDataGridColumnSelector__item ".concat(state.isDragging && 'euiDataGridColumnSelector__item-isDragging'),
158
163
  "data-test-subj": "dataGridColumnSelectorColumnItem-".concat(id)
159
164
  }, ___EmotionJSX(EuiFlexGroup, {
160
165
  responsive: false,
161
- gutterSize: "m",
166
+ gutterSize: "s",
162
167
  alignItems: "center"
163
- }, ___EmotionJSX(EuiFlexItem, null, allowColumnHiding ? ___EmotionJSX(EuiSwitch, {
168
+ }, allowColumnHiding && ___EmotionJSX(EuiFlexItem, {
169
+ grow: false
170
+ }, ___EmotionJSX(EuiSwitch, {
164
171
  name: id,
165
172
  label: displayValues[id] || id,
173
+ showLabel: false,
166
174
  checked: visibleColumnIds.has(id),
167
175
  compressed: true,
168
176
  className: "euiSwitch--mini",
@@ -174,11 +182,18 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
174
182
  setVisibleColumns(nextVisibleColumns);
175
183
  },
176
184
  "data-test-subj": "dataGridColumnSelectorToggleColumnVisibility-".concat(id)
177
- }) : ___EmotionJSX("span", {
185
+ })), ___EmotionJSX(EuiFlexItem // This extra column name flex item affords the column more grabbable real estate
186
+ // for mouse users, while hiding repetition for keyboard/screen reader users
187
+ , _extends({}, provided.dragHandleProps, {
188
+ "aria-hidden": true,
189
+ tabIndex: -1
190
+ }), ___EmotionJSX("span", {
178
191
  className: "euiDataGridColumnSelector__itemLabel"
179
- }, id)), isDragEnabled && ___EmotionJSX(EuiFlexItem, {
192
+ }, displayValues[id] || id)), isDragEnabled && ___EmotionJSX(EuiFlexItem, _extends({
180
193
  grow: false
181
- }, ___EmotionJSX(EuiIcon, {
194
+ }, provided.dragHandleProps, {
195
+ "aria-label": dragHandleAriaLabel
196
+ }), ___EmotionJSX(EuiIcon, {
182
197
  type: "grab",
183
198
  color: "subdued"
184
199
  }))));
@@ -56,7 +56,9 @@ export var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSorting
56
56
  var dragHandleAriaLabel = useEuiI18n('euiColumnSortingDraggable.dragHandleAriaLabel', 'Drag handle');
57
57
  return ___EmotionJSX(EuiDraggable, _extends({
58
58
  draggableId: id,
59
- index: index
59
+ index: index,
60
+ hasInteractiveChildren: true,
61
+ customDragHandle: true
60
62
  }, rest), function (provided, state) {
61
63
  return ___EmotionJSX("div", {
62
64
  className: "euiDataGridColumnSorting__item ".concat(state.isDragging && 'euiDataGridColumnSorting__item-isDragging')
@@ -98,18 +100,25 @@ export var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSorting
98
100
  sorting.onSort(nextColumns);
99
101
  }
100
102
  });
101
- })), ___EmotionJSX(EuiFlexItem, {
103
+ })), ___EmotionJSX(EuiFlexItem, _extends({
104
+ className: "euiDataGridColumnSorting__name" // This extra column name flex item affords the column more grabbable real estate
105
+ // for mouse users, while hiding repetition for keyboard/screen reader users
106
+
107
+ }, provided.dragHandleProps, {
108
+ tabIndex: -1,
109
+ "aria-hidden": true
110
+ }), ___EmotionJSX(EuiFlexGroup, {
111
+ gutterSize: "xs",
112
+ alignItems: "center",
113
+ responsive: false
114
+ }, ___EmotionJSX(EuiFlexItem, {
102
115
  grow: false
103
116
  }, ___EmotionJSX(EuiToken, {
104
117
  color: schemaDetails != null ? schemaDetails.color : undefined,
105
118
  iconType: schemaDetails != null ? schemaDetails.icon : 'tokenString'
106
- })), ___EmotionJSX(EuiFlexItem, {
107
- "aria-hidden": true
108
- }, ___EmotionJSX(EuiText, {
119
+ })), ___EmotionJSX(EuiFlexItem, null, ___EmotionJSX(EuiText, {
109
120
  size: "xs"
110
- }, ___EmotionJSX("p", null, display))), ___EmotionJSX(EuiFlexItem, {
111
- className: "euiDataGridColumnSorting__orderButtons"
112
- }, ___EmotionJSX(EuiI18n, {
121
+ }, ___EmotionJSX("p", null, display))))), ___EmotionJSX(EuiFlexItem, null, ___EmotionJSX(EuiI18n, {
113
122
  token: "euiColumnSortingDraggable.toggleLegend",
114
123
  default: "Select sorting method for {display}",
115
124
  values: {
@@ -167,7 +167,7 @@ describe('EuiDataGrid', function () {
167
167
  it('has zero violations on first render', function () {
168
168
  cy.checkAxe();
169
169
  });
170
- it('has zero violations when the columns reorder menu is open', function () {
170
+ it('has zero violations when the columns visibility menu is open', function () {
171
171
  cy.get('button[data-test-subj="dataGridColumnSelectorButton"]').realClick();
172
172
  cy.checkAxe();
173
173
  });
@@ -220,9 +220,10 @@ describe('EuiDataGrid', function () {
220
220
  cy.get('div[data-gridcell-visible-row-index="0"][data-gridcell-column-index="1"]').find('button.euiButtonIcon').last().realClick();
221
221
  cy.checkAxe();
222
222
  });
223
- it('has zero violations when the Favorite Distro column has been sorted', function () {
223
+ it('has zero violations on sort and when the columns sorting menu is open', function () {
224
224
  cy.get('button.euiDataGridHeaderCell__button').last().realClick();
225
225
  cy.get('button.euiListGroupItem__button').contains('Sort Alma to Debian').should('exist').realClick();
226
+ cy.get('button[data-test-subj="dataGridColumnSortingPopover"]').realClick();
226
227
  cy.checkAxe();
227
228
  });
228
229
  it('has zero violations when fullscreen is open', function () {