@elastic/eui 72.2.0 → 74.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 (99) hide show
  1. package/dist/eui_theme_dark.css +15 -67
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +15 -67
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/basic_table/basic_table.js +56 -101
  6. package/es/components/basic_table/basic_table.styles.js +45 -0
  7. package/es/components/datagrid/controls/column_selector.js +23 -7
  8. package/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
  9. package/es/components/datagrid/data_grid.a11y.js +3 -2
  10. package/es/components/modal/confirm_modal.js +5 -3
  11. package/es/components/modal/modal.a11y.js +1 -1
  12. package/es/components/modal/modal_header_title.js +12 -3
  13. package/es/components/notification/notification_event.a11y.js +113 -0
  14. package/es/components/page/page_header/page_header.a11y.js +32 -0
  15. package/es/components/portal/portal.a11y.js +70 -0
  16. package/es/components/resizable_container/resizable_panel.js +5 -0
  17. package/es/components/tool_tip/tool_tip.js +10 -5
  18. package/es/components/tool_tip/tool_tip_manager.js +42 -0
  19. package/es/services/security/get_secure_rel_for_target.js +2 -8
  20. package/es/services/theme/hooks.js +18 -0
  21. package/es/services/theme/index.js +1 -1
  22. package/eui.d.ts +57 -19
  23. package/i18ntokens.json +54 -38
  24. package/lib/components/basic_table/basic_table.js +56 -100
  25. package/lib/components/basic_table/basic_table.styles.js +54 -0
  26. package/lib/components/datagrid/controls/column_selector.js +21 -6
  27. package/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
  28. package/lib/components/datagrid/data_grid.a11y.js +3 -2
  29. package/lib/components/modal/confirm_modal.js +5 -3
  30. package/lib/components/modal/modal.a11y.js +1 -1
  31. package/lib/components/modal/modal_header_title.js +12 -3
  32. package/lib/components/notification/notification_event.a11y.js +117 -0
  33. package/lib/components/page/page_header/page_header.a11y.js +40 -0
  34. package/lib/components/portal/portal.a11y.js +73 -0
  35. package/lib/components/resizable_container/resizable_panel.js +5 -0
  36. package/lib/components/tool_tip/tool_tip.js +13 -7
  37. package/lib/components/tool_tip/tool_tip_manager.js +50 -0
  38. package/lib/services/security/get_secure_rel_for_target.js +2 -9
  39. package/lib/services/theme/hooks.js +22 -2
  40. package/lib/services/theme/index.js +6 -0
  41. package/optimize/es/components/basic_table/basic_table.js +56 -101
  42. package/optimize/es/components/basic_table/basic_table.styles.js +45 -0
  43. package/optimize/es/components/datagrid/controls/column_selector.js +22 -7
  44. package/optimize/es/components/datagrid/controls/column_sorting_draggable.js +17 -8
  45. package/optimize/es/components/datagrid/data_grid.a11y.js +3 -2
  46. package/optimize/es/components/modal/confirm_modal.js +4 -3
  47. package/optimize/es/components/modal/modal.a11y.js +1 -1
  48. package/optimize/es/components/modal/modal_header_title.js +4 -2
  49. package/optimize/es/components/notification/notification_event.a11y.js +103 -0
  50. package/optimize/es/components/page/page_header/page_header.a11y.js +32 -0
  51. package/optimize/es/components/portal/portal.a11y.js +60 -0
  52. package/optimize/es/components/tool_tip/tool_tip.js +10 -5
  53. package/optimize/es/components/tool_tip/tool_tip_manager.js +41 -0
  54. package/optimize/es/services/security/get_secure_rel_for_target.js +2 -8
  55. package/optimize/es/services/theme/hooks.js +18 -0
  56. package/optimize/es/services/theme/index.js +1 -1
  57. package/optimize/lib/components/basic_table/basic_table.js +56 -95
  58. package/optimize/lib/components/basic_table/basic_table.styles.js +56 -0
  59. package/optimize/lib/components/datagrid/controls/column_selector.js +21 -6
  60. package/optimize/lib/components/datagrid/controls/column_sorting_draggable.js +17 -8
  61. package/optimize/lib/components/datagrid/data_grid.a11y.js +3 -2
  62. package/optimize/lib/components/modal/confirm_modal.js +4 -3
  63. package/optimize/lib/components/modal/modal.a11y.js +1 -1
  64. package/optimize/lib/components/modal/modal_header_title.js +4 -2
  65. package/optimize/lib/components/notification/notification_event.a11y.js +117 -0
  66. package/optimize/lib/components/page/page_header/page_header.a11y.js +40 -0
  67. package/optimize/lib/components/portal/portal.a11y.js +73 -0
  68. package/optimize/lib/components/tool_tip/tool_tip.js +13 -7
  69. package/optimize/lib/components/tool_tip/tool_tip_manager.js +49 -0
  70. package/optimize/lib/services/security/get_secure_rel_for_target.js +2 -9
  71. package/optimize/lib/services/theme/hooks.js +22 -2
  72. package/optimize/lib/services/theme/index.js +6 -0
  73. package/package.json +1 -1
  74. package/src/components/datagrid/controls/_data_grid_column_sorting.scss +14 -13
  75. package/src/components/index.scss +0 -1
  76. package/test-env/components/basic_table/basic_table.js +56 -95
  77. package/test-env/components/basic_table/basic_table.styles.js +56 -0
  78. package/test-env/components/datagrid/controls/column_selector.js +21 -6
  79. package/test-env/components/datagrid/controls/column_sorting_draggable.js +17 -8
  80. package/test-env/components/datagrid/data_grid.a11y.js +3 -2
  81. package/test-env/components/modal/confirm_modal.js +5 -3
  82. package/test-env/components/modal/modal.a11y.js +1 -1
  83. package/test-env/components/modal/modal_header_title.js +12 -3
  84. package/test-env/components/notification/notification_event.a11y.js +117 -0
  85. package/test-env/components/page/page_header/page_header.a11y.js +40 -0
  86. package/test-env/components/portal/portal.a11y.js +73 -0
  87. package/test-env/components/resizable_container/resizable_panel.js +5 -0
  88. package/test-env/components/tool_tip/tool_tip.js +13 -7
  89. package/test-env/components/tool_tip/tool_tip_manager.js +49 -0
  90. package/test-env/services/security/get_secure_rel_for_target.js +2 -9
  91. package/test-env/services/theme/hooks.js +22 -2
  92. package/test-env/services/theme/index.js +6 -0
  93. package/es/services/url.js +0 -23
  94. package/lib/services/url.js +0 -32
  95. package/optimize/es/services/url.js +0 -23
  96. package/optimize/lib/services/url.js +0 -32
  97. package/src/components/basic_table/_basic_table.scss +0 -41
  98. package/src/components/basic_table/_index.scss +0 -1
  99. package/test-env/services/url.js +0 -32
@@ -57,7 +57,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
57
57
  import React, { Component, Fragment } from 'react';
58
58
  import PropTypes from "prop-types";
59
59
  import classNames from 'classnames';
60
- import { formatAuto, formatBoolean, formatDate, formatNumber, formatText, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, SortDirection } from '../../services';
60
+ import { formatAuto, formatBoolean, formatDate, formatNumber, formatText, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, SortDirection, RenderWithEuiTheme } from '../../services';
61
61
  import { isFunction } from '../../services/predicate';
62
62
  import { get } from '../../services/objects';
63
63
  import { EuiFlexGroup, EuiFlexItem } from '../flex';
@@ -71,6 +71,7 @@ import { EuiScreenReaderOnly } from '../accessibility';
71
71
  import { EuiI18n } from '../i18n';
72
72
  import { EuiDelayRender } from '../delay_render';
73
73
  import { htmlIdGenerator } from '../../services/accessibility';
74
+ import { euiBasicTableBodyLoading, safariLoadingWorkaround, euiBasicTableActionsWrapper } from './basic_table.styles';
74
75
  import { jsx as ___EmotionJSX } from "@emotion/react";
75
76
  var dataTypesProfiles = {
76
77
  auto: {
@@ -176,45 +177,6 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
176
177
 
177
178
  _this = _super.call(this, props);
178
179
 
179
- _defineProperty(_assertThisInitialized(_this), "cleanups", []);
180
-
181
- _defineProperty(_assertThisInitialized(_this), "tbody", null);
182
-
183
- _defineProperty(_assertThisInitialized(_this), "setTbody", function (tbody) {
184
- // remove listeners from an existing element
185
- _this.removeLoadingListeners(); // update the ref
186
-
187
-
188
- _this.tbody = tbody; // if loading, add listeners
189
-
190
- if (_this.props.loading === true && tbody) {
191
- _this.addLoadingListeners(tbody);
192
- }
193
- });
194
-
195
- _defineProperty(_assertThisInitialized(_this), "addLoadingListeners", function (tbody) {
196
- var listener = function listener(event) {
197
- event.stopPropagation();
198
- event.preventDefault();
199
- };
200
-
201
- ['mousedown', 'mouseup', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'click', 'dblclick', 'keydown', 'keyup', 'keypress'].forEach(function (event) {
202
- tbody.addEventListener(event, listener, true);
203
-
204
- _this.cleanups.push(function () {
205
- tbody.removeEventListener(event, listener, true);
206
- });
207
- });
208
- });
209
-
210
- _defineProperty(_assertThisInitialized(_this), "removeLoadingListeners", function () {
211
- _this.cleanups.forEach(function (cleanup) {
212
- return cleanup();
213
- });
214
-
215
- _this.cleanups.length = 0;
216
- });
217
-
218
180
  _defineProperty(_assertThisInitialized(_this), "tableId", htmlIdGenerator('__table')());
219
181
 
220
182
  _defineProperty(_assertThisInitialized(_this), "selectAllIdGenerator", htmlIdGenerator('_selection_column-checkbox'));
@@ -306,27 +268,13 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
306
268
  _createClass(EuiBasicTable, [{
307
269
  key: "componentDidMount",
308
270
  value: function componentDidMount() {
309
- if (this.props.loading && this.tbody) this.addLoadingListeners(this.tbody);
310
271
  this.getInitialSelection();
311
272
  }
312
273
  }, {
313
274
  key: "componentDidUpdate",
314
- value: function componentDidUpdate(prevProps) {
315
- if (prevProps.loading !== this.props.loading) {
316
- if (this.props.loading && this.tbody) {
317
- this.addLoadingListeners(this.tbody);
318
- } else {
319
- this.removeLoadingListeners();
320
- }
321
- }
322
-
275
+ value: function componentDidUpdate() {
323
276
  this.getInitialSelection();
324
277
  }
325
- }, {
326
- key: "componentWillUnmount",
327
- value: function componentWillUnmount() {
328
- this.removeLoadingListeners();
329
- }
330
278
  }, {
331
279
  key: "getInitialSelection",
332
280
  value: function getInitialSelection() {
@@ -487,7 +435,8 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
487
435
  var _this$props3 = this.props,
488
436
  compressed = _this$props3.compressed,
489
437
  responsive = _this$props3.responsive,
490
- tableLayout = _this$props3.tableLayout;
438
+ tableLayout = _this$props3.tableLayout,
439
+ loading = _this$props3.loading;
491
440
  var mobileHeader = responsive ? ___EmotionJSX(EuiTableHeaderMobile, null, ___EmotionJSX(EuiFlexGroup, {
492
441
  responsive: false,
493
442
  justifyContent: "spaceBetween",
@@ -505,7 +454,8 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
505
454
  id: this.tableId,
506
455
  tableLayout: tableLayout,
507
456
  responsive: responsive,
508
- compressed: compressed
457
+ compressed: compressed,
458
+ css: loading && safariLoadingWorkaround
509
459
  }, caption, head, body, footer));
510
460
  }
511
461
  }, {
@@ -768,30 +718,35 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
768
718
  value: function renderTableBody() {
769
719
  var _this4 = this;
770
720
 
771
- if (this.props.error) {
772
- return this.renderErrorBody(this.props.error);
773
- }
774
-
775
- var items = this.props.items;
776
-
777
- if (items.length === 0) {
778
- return this.renderEmptyBody();
721
+ var _this$props8 = this.props,
722
+ error = _this$props8.error,
723
+ loading = _this$props8.loading,
724
+ items = _this$props8.items;
725
+ var content;
726
+
727
+ if (error) {
728
+ content = this.renderErrorMessage(error);
729
+ } else if (items.length === 0) {
730
+ content = this.renderEmptyMessage();
731
+ } else {
732
+ content = items.map(function (item, index) {
733
+ // if there's pagination the item's index must be adjusted to the where it is in the whole dataset
734
+ var tableItemIndex = hasPagination(_this4.props) && _this4.props.pagination.pageSize > 0 ? _this4.props.pagination.pageIndex * _this4.props.pagination.pageSize + index : index;
735
+ return _this4.renderItemRow(item, tableItemIndex);
736
+ });
779
737
  }
780
738
 
781
- var rows = items.map(function (item, index) {
782
- // if there's pagination the item's index must be adjusted to the where it is in the whole dataset
783
- var tableItemIndex = hasPagination(_this4.props) && _this4.props.pagination.pageSize > 0 ? _this4.props.pagination.pageIndex * _this4.props.pagination.pageSize + index : index;
784
- return _this4.renderItemRow(item, tableItemIndex);
739
+ return ___EmotionJSX(RenderWithEuiTheme, null, function (theme) {
740
+ return ___EmotionJSX(EuiTableBody, {
741
+ css: loading && euiBasicTableBodyLoading(theme)
742
+ }, content);
785
743
  });
786
- return ___EmotionJSX(EuiTableBody, {
787
- bodyRef: this.setTbody
788
- }, rows);
789
744
  }
790
745
  }, {
791
- key: "renderErrorBody",
792
- value: function renderErrorBody(error) {
746
+ key: "renderErrorMessage",
747
+ value: function renderErrorMessage(error) {
793
748
  var colSpan = this.props.columns.length + (this.props.selection ? 1 : 0);
794
- return ___EmotionJSX(EuiTableBody, null, ___EmotionJSX(EuiTableRow, null, ___EmotionJSX(EuiTableRowCell, {
749
+ return ___EmotionJSX(EuiTableRow, null, ___EmotionJSX(EuiTableRowCell, {
795
750
  align: "center",
796
751
  colSpan: colSpan,
797
752
  mobileOptions: {
@@ -800,38 +755,38 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
800
755
  }, ___EmotionJSX(EuiIcon, {
801
756
  type: "minusInCircle",
802
757
  color: "danger"
803
- }), " ", error)));
758
+ }), " ", error));
804
759
  }
805
760
  }, {
806
- key: "renderEmptyBody",
807
- value: function renderEmptyBody() {
808
- var _this$props8 = this.props,
809
- columns = _this$props8.columns,
810
- selection = _this$props8.selection,
811
- noItemsMessage = _this$props8.noItemsMessage;
761
+ key: "renderEmptyMessage",
762
+ value: function renderEmptyMessage() {
763
+ var _this$props9 = this.props,
764
+ columns = _this$props9.columns,
765
+ selection = _this$props9.selection,
766
+ noItemsMessage = _this$props9.noItemsMessage;
812
767
  var colSpan = columns.length + (selection ? 1 : 0);
813
- return ___EmotionJSX(EuiTableBody, null, ___EmotionJSX(EuiTableRow, null, ___EmotionJSX(EuiTableRowCell, {
768
+ return ___EmotionJSX(EuiTableRow, null, ___EmotionJSX(EuiTableRowCell, {
814
769
  align: "center",
815
770
  colSpan: colSpan,
816
771
  mobileOptions: {
817
772
  width: '100%'
818
773
  }
819
- }, noItemsMessage)));
774
+ }, noItemsMessage));
820
775
  }
821
776
  }, {
822
777
  key: "renderItemRow",
823
778
  value: function renderItemRow(item, rowIndex) {
824
779
  var _this5 = this;
825
780
 
826
- var _this$props9 = this.props,
827
- columns = _this$props9.columns,
828
- selection = _this$props9.selection,
829
- isSelectable = _this$props9.isSelectable,
830
- hasActions = _this$props9.hasActions,
831
- rowHeader = _this$props9.rowHeader,
832
- _this$props9$itemIdTo = _this$props9.itemIdToExpandedRowMap,
833
- itemIdToExpandedRowMap = _this$props9$itemIdTo === void 0 ? {} : _this$props9$itemIdTo,
834
- isExpandable = _this$props9.isExpandable;
781
+ var _this$props10 = this.props,
782
+ columns = _this$props10.columns,
783
+ selection = _this$props10.selection,
784
+ isSelectable = _this$props10.isSelectable,
785
+ hasActions = _this$props10.hasActions,
786
+ rowHeader = _this$props10.rowHeader,
787
+ _this$props10$itemIdT = _this$props10.itemIdToExpandedRowMap,
788
+ itemIdToExpandedRowMap = _this$props10$itemIdT === void 0 ? {} : _this$props10$itemIdT,
789
+ isExpandable = _this$props10.isExpandable;
835
790
  var cells = [];
836
791
  var itemIdCallback = this.props.itemId;
837
792
  var itemId = getItemId(item, itemIdCallback) != null ? getItemId(item, itemIdCallback) : rowIndex;
@@ -986,7 +941,8 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
986
941
  key: key,
987
942
  align: "right",
988
943
  textOnly: false,
989
- hasActions: true
944
+ hasActions: true,
945
+ css: euiBasicTableActionsWrapper
990
946
  }, tools);
991
947
  }
992
948
  }, {
@@ -1071,11 +1027,11 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
1071
1027
  value: function renderPaginationBar() {
1072
1028
  var _this8 = this;
1073
1029
 
1074
- var _this$props10 = this.props,
1075
- error = _this$props10.error,
1076
- pagination = _this$props10.pagination,
1077
- tableCaption = _this$props10.tableCaption,
1078
- onChange = _this$props10.onChange;
1030
+ var _this$props11 = this.props,
1031
+ error = _this$props11.error,
1032
+ pagination = _this$props11.pagination,
1033
+ tableCaption = _this$props11.tableCaption,
1034
+ onChange = _this$props11.onChange;
1079
1035
 
1080
1036
  if (!error && pagination && pagination.totalItemCount > 0) {
1081
1037
  if (!onChange) {
@@ -1127,8 +1083,7 @@ export var EuiBasicTable = /*#__PURE__*/function (_Component) {
1127
1083
  }
1128
1084
 
1129
1085
  return null;
1130
- } // used for moving in & out of `loading` state
1131
-
1086
+ }
1132
1087
  }]);
1133
1088
 
1134
1089
  return EuiBasicTable;
@@ -0,0 +1,45 @@
1
+ var _templateObject;
2
+
3
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
4
+
5
+ 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)."; }
6
+
7
+ /*
8
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
9
+ * or more contributor license agreements. Licensed under the Elastic License
10
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
11
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
12
+ * Side Public License, v 1.
13
+ */
14
+ import { css, keyframes } from '@emotion/react';
15
+ import { logicalCSS, euiCantAnimate } from '../../global_styling';
16
+ var tableLoadingLine = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n ", "\n ", "\n }\n\n 20% {\n ", "\n ", "\n }\n\n 80% {\n ", "\n ", "\n }\n\n 100% {\n ", "\n ", "\n }\n"])), logicalCSS('left', 0), logicalCSS('width', 0), logicalCSS('left', 0), logicalCSS('width', '40%'), logicalCSS('left', '60%'), logicalCSS('width', '40%'), logicalCSS('left', '100%'), logicalCSS('width', 0));
17
+ export var euiBasicTableBodyLoading = function euiBasicTableBodyLoading(_ref2) {
18
+ var euiTheme = _ref2.euiTheme;
19
+ return /*#__PURE__*/css("position:relative;overflow:hidden;&::before{position:absolute;content:'';", logicalCSS('width', '100%'), " ", logicalCSS('height', euiTheme.border.width.thick), " background-color:", euiTheme.colors.primary, ";animation:", tableLoadingLine, " 1s linear infinite;", euiCantAnimate, "{animation-duration:2s;}};label:euiBasicTableBodyLoading;");
20
+ }; // Fix to make the loading indicator position correctly in Safari
21
+ // For whatever annoying reason, Safari doesn't respect `position: relative;`
22
+ // on `tbody` without `position: relative` on the parent `table`
23
+
24
+ var _ref = process.env.NODE_ENV === "production" ? {
25
+ name: "6xbnw4-safariLoadingWorkaround",
26
+ styles: "position:relative;label:safariLoadingWorkaround;"
27
+ } : {
28
+ name: "6xbnw4-safariLoadingWorkaround",
29
+ styles: "position:relative;label:safariLoadingWorkaround;",
30
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
31
+ };
32
+
33
+ export var safariLoadingWorkaround = function safariLoadingWorkaround() {
34
+ return _ref;
35
+ }; // Unsets the extra height caused by tooltip/popover wrappers around table action buttons
36
+ // Without this, the row height jumps whenever actions are disabled
37
+
38
+ export var euiBasicTableActionsWrapper = process.env.NODE_ENV === "production" ? {
39
+ name: "1mshepa-euiBasicTableActionsWrapper",
40
+ styles: "line-height:1;label:euiBasicTableActionsWrapper;"
41
+ } : {
42
+ name: "1mshepa-euiBasicTableActionsWrapper",
43
+ styles: "line-height:1;label:euiBasicTableActionsWrapper;",
44
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
45
+ };
@@ -6,6 +6,8 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
6
6
 
7
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
8
 
9
+ 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); }
10
+
9
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
12
 
11
13
  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."); }
@@ -28,7 +30,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
30
  import React, { Fragment, useState, useMemo, useCallback } from 'react';
29
31
  import classNames from 'classnames';
30
32
  import { EuiPopover, EuiPopoverFooter, EuiPopoverTitle } from '../../popover';
31
- import { EuiI18n } from '../../i18n';
33
+ import { EuiI18n, useEuiI18n } from '../../i18n';
32
34
  import { EuiButtonEmpty } from '../../button';
33
35
  import { EuiFlexGroup, EuiFlexItem } from '../../flex';
34
36
  import { EuiSwitch, EuiFieldText } from '../../form';
@@ -96,6 +98,8 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
96
98
  }, [sortedColumns, columnSearchText, displayValues]);
97
99
  var isDragEnabled = allowColumnReorder && columnSearchText.length === 0; // only allow drag-and-drop when not filtering columns
98
100
 
101
+ var dragHandleAriaLabel = useEuiI18n('euiColumnSelector.dragHandleAriaLabel', 'Drag handle');
102
+
99
103
  var buttonText = ___EmotionJSX(EuiI18n, {
100
104
  token: "euiColumnSelector.button",
101
105
  default: "Columns"
@@ -168,18 +172,23 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
168
172
  key: id,
169
173
  draggableId: id,
170
174
  index: index,
171
- isDragDisabled: !isDragEnabled
175
+ isDragDisabled: !isDragEnabled,
176
+ hasInteractiveChildren: true,
177
+ customDragHandle: true
172
178
  }, function (provided, state) {
173
179
  return ___EmotionJSX("div", {
174
180
  className: "euiDataGridColumnSelector__item ".concat(state.isDragging && 'euiDataGridColumnSelector__item-isDragging'),
175
181
  "data-test-subj": "dataGridColumnSelectorColumnItem-".concat(id)
176
182
  }, ___EmotionJSX(EuiFlexGroup, {
177
183
  responsive: false,
178
- gutterSize: "m",
184
+ gutterSize: "s",
179
185
  alignItems: "center"
180
- }, ___EmotionJSX(EuiFlexItem, null, allowColumnHiding ? ___EmotionJSX(EuiSwitch, {
186
+ }, allowColumnHiding && ___EmotionJSX(EuiFlexItem, {
187
+ grow: false
188
+ }, ___EmotionJSX(EuiSwitch, {
181
189
  name: id,
182
190
  label: displayValues[id] || id,
191
+ showLabel: false,
183
192
  checked: visibleColumnIds.has(id),
184
193
  compressed: true,
185
194
  className: "euiSwitch--mini",
@@ -191,11 +200,18 @@ export var useDataGridColumnSelector = function useDataGridColumnSelector(availa
191
200
  setVisibleColumns(nextVisibleColumns);
192
201
  },
193
202
  "data-test-subj": "dataGridColumnSelectorToggleColumnVisibility-".concat(id)
194
- }) : ___EmotionJSX("span", {
203
+ })), ___EmotionJSX(EuiFlexItem // This extra column name flex item affords the column more grabbable real estate
204
+ // for mouse users, while hiding repetition for keyboard/screen reader users
205
+ , _extends({}, provided.dragHandleProps, {
206
+ "aria-hidden": true,
207
+ tabIndex: -1
208
+ }), ___EmotionJSX("span", {
195
209
  className: "euiDataGridColumnSelector__itemLabel"
196
- }, id)), isDragEnabled && ___EmotionJSX(EuiFlexItem, {
210
+ }, displayValues[id] || id)), isDragEnabled && ___EmotionJSX(EuiFlexItem, _extends({
197
211
  grow: false
198
- }, ___EmotionJSX(EuiIcon, {
212
+ }, provided.dragHandleProps, {
213
+ "aria-label": dragHandleAriaLabel
214
+ }), ___EmotionJSX(EuiIcon, {
199
215
  type: "grab",
200
216
  color: "subdued"
201
217
  }))));
@@ -72,7 +72,9 @@ export var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSorting
72
72
  var dragHandleAriaLabel = useEuiI18n('euiColumnSortingDraggable.dragHandleAriaLabel', 'Drag handle');
73
73
  return ___EmotionJSX(EuiDraggable, _extends({
74
74
  draggableId: id,
75
- index: index
75
+ index: index,
76
+ hasInteractiveChildren: true,
77
+ customDragHandle: true
76
78
  }, rest), function (provided, state) {
77
79
  return ___EmotionJSX("div", {
78
80
  className: "euiDataGridColumnSorting__item ".concat(state.isDragging && 'euiDataGridColumnSorting__item-isDragging')
@@ -114,18 +116,25 @@ export var EuiDataGridColumnSortingDraggable = function EuiDataGridColumnSorting
114
116
  sorting.onSort(nextColumns);
115
117
  }
116
118
  });
117
- })), ___EmotionJSX(EuiFlexItem, {
119
+ })), ___EmotionJSX(EuiFlexItem, _extends({
120
+ className: "euiDataGridColumnSorting__name" // This extra column name flex item affords the column more grabbable real estate
121
+ // for mouse users, while hiding repetition for keyboard/screen reader users
122
+
123
+ }, provided.dragHandleProps, {
124
+ tabIndex: -1,
125
+ "aria-hidden": true
126
+ }), ___EmotionJSX(EuiFlexGroup, {
127
+ gutterSize: "xs",
128
+ alignItems: "center",
129
+ responsive: false
130
+ }, ___EmotionJSX(EuiFlexItem, {
118
131
  grow: false
119
132
  }, ___EmotionJSX(EuiToken, {
120
133
  color: schemaDetails != null ? schemaDetails.color : undefined,
121
134
  iconType: schemaDetails != null ? schemaDetails.icon : 'tokenString'
122
- })), ___EmotionJSX(EuiFlexItem, {
123
- "aria-hidden": true
124
- }, ___EmotionJSX(EuiText, {
135
+ })), ___EmotionJSX(EuiFlexItem, null, ___EmotionJSX(EuiText, {
125
136
  size: "xs"
126
- }, ___EmotionJSX("p", null, display))), ___EmotionJSX(EuiFlexItem, {
127
- className: "euiDataGridColumnSorting__orderButtons"
128
- }, ___EmotionJSX(EuiI18n, {
137
+ }, ___EmotionJSX("p", null, display))))), ___EmotionJSX(EuiFlexItem, null, ___EmotionJSX(EuiI18n, {
129
138
  token: "euiColumnSortingDraggable.toggleLegend",
130
139
  default: "Select sorting method for {display}",
131
140
  values: {
@@ -184,7 +184,7 @@ describe('EuiDataGrid', function () {
184
184
  it('has zero violations on first render', function () {
185
185
  cy.checkAxe();
186
186
  });
187
- it('has zero violations when the columns reorder menu is open', function () {
187
+ it('has zero violations when the columns visibility menu is open', function () {
188
188
  cy.get('button[data-test-subj="dataGridColumnSelectorButton"]').realClick();
189
189
  cy.checkAxe();
190
190
  });
@@ -237,9 +237,10 @@ describe('EuiDataGrid', function () {
237
237
  cy.get('div[data-gridcell-visible-row-index="0"][data-gridcell-column-index="1"]').find('button.euiButtonIcon').last().realClick();
238
238
  cy.checkAxe();
239
239
  });
240
- it('has zero violations when the Favorite Distro column has been sorted', function () {
240
+ it('has zero violations on sort and when the columns sorting menu is open', function () {
241
241
  cy.get('button.euiDataGridHeaderCell__button').last().realClick();
242
242
  cy.get('button.euiListGroupItem__button').contains('Sort Alma to Debian').should('exist').realClick();
243
+ cy.get('button[data-test-subj="dataGridColumnSortingPopover"]').realClick();
243
244
  cy.checkAxe();
244
245
  });
245
246
  it('has zero violations when fullscreen is open', function () {
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "title", "onCancel", "onConfirm", "cancelButtonText", "confirmButtonText", "confirmButtonDisabled", "className", "buttonColor", "defaultFocusedButton", "isLoading"];
1
+ var _excluded = ["children", "title", "titleProps", "onCancel", "onConfirm", "cancelButtonText", "confirmButtonText", "confirmButtonDisabled", "className", "buttonColor", "defaultFocusedButton", "isLoading"];
2
2
 
3
3
  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); }
4
4
 
@@ -43,6 +43,7 @@ export var CANCEL_BUTTON = 'cancel';
43
43
  export var EuiConfirmModal = function EuiConfirmModal(_ref) {
44
44
  var children = _ref.children,
45
45
  title = _ref.title,
46
+ titleProps = _ref.titleProps,
46
47
  onCancel = _ref.onCancel,
47
48
  onConfirm = _ref.onConfirm,
48
49
  cancelButtonText = _ref.cancelButtonText,
@@ -94,9 +95,9 @@ export var EuiConfirmModal = function EuiConfirmModal(_ref) {
94
95
  var modalTitle;
95
96
 
96
97
  if (title) {
97
- modalTitle = ___EmotionJSX(EuiModalHeader, null, ___EmotionJSX(EuiModalHeaderTitle, {
98
+ modalTitle = ___EmotionJSX(EuiModalHeader, null, ___EmotionJSX(EuiModalHeaderTitle, _extends({
98
99
  "data-test-subj": "confirmModalTitleText"
99
- }, title));
100
+ }, titleProps), title));
100
101
  }
101
102
 
102
103
  var message;
@@ -133,6 +134,7 @@ EuiConfirmModal.propTypes = {
133
134
  */
134
135
  children: PropTypes.node,
135
136
  title: PropTypes.node,
137
+ titleProps: PropTypes.any,
136
138
  cancelButtonText: PropTypes.node,
137
139
  confirmButtonText: PropTypes.node,
138
140
  onCancel: PropTypes.func.isRequired,
@@ -44,7 +44,7 @@ var Modal = function Modal() {
44
44
  };
45
45
  return ___EmotionJSX("div", null, ___EmotionJSX(EuiButton, {
46
46
  onClick: showModal
47
- }, "Show confirm modal"), isModalVisible && ___EmotionJSX(EuiModal, modalProps, ___EmotionJSX(EuiModalHeader, null, ___EmotionJSX(EuiModalHeaderTitle, null, ___EmotionJSX("h1", null, "Title of modal"))), ___EmotionJSX(EuiModalBody, null, ___EmotionJSX("p", null, "This is a simple modal body")), ___EmotionJSX(EuiModalFooter, null, ___EmotionJSX(EuiButton, {
47
+ }, "Show confirm modal"), isModalVisible && ___EmotionJSX(EuiModal, modalProps, ___EmotionJSX(EuiModalHeader, null, ___EmotionJSX(EuiModalHeaderTitle, null, "Title of modal")), ___EmotionJSX(EuiModalBody, null, ___EmotionJSX("p", null, "This is a simple modal body")), ___EmotionJSX(EuiModalFooter, null, ___EmotionJSX(EuiButton, {
48
48
  onClick: closeModal,
49
49
  fill: true
50
50
  }, "Close"))));
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "children"];
1
+ var _excluded = ["className", "children", "component"];
2
2
 
3
3
  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); }
4
4
 
@@ -21,17 +21,26 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
21
21
  export var EuiModalHeaderTitle = function EuiModalHeaderTitle(_ref) {
22
22
  var className = _ref.className,
23
23
  children = _ref.children,
24
+ _ref$component = _ref.component,
25
+ Component = _ref$component === void 0 ? 'h1' : _ref$component,
24
26
  rest = _objectWithoutProperties(_ref, _excluded);
25
27
 
26
28
  var classes = classnames('euiModalHeader__title', className);
27
29
  return ___EmotionJSX(EuiTitle, _extends({
28
30
  size: "m",
29
31
  className: classes
30
- }, rest), /*#__PURE__*/React.isValidElement(children) ? children : ___EmotionJSX("h1", null, children));
32
+ }, rest), ___EmotionJSX(Component, null, children));
31
33
  };
32
34
  EuiModalHeaderTitle.propTypes = {
33
35
  className: PropTypes.string,
34
36
  "aria-label": PropTypes.string,
35
37
  "data-test-subj": PropTypes.string,
36
- css: PropTypes.any
38
+ css: PropTypes.any,
39
+
40
+ /**
41
+ * The tag to render. Can be changed to a lower heading
42
+ * level like `h2` or a container `div`.
43
+ * @default h1
44
+ */
45
+ component: PropTypes.any
37
46
  };
@@ -0,0 +1,113 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ 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."); }
4
+
5
+ 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); }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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
+ import React, { useState } from 'react';
22
+ import { EuiContextMenuItem } from '../context_menu';
23
+ import { EuiNotificationEvent } from './notification_event';
24
+ import { EuiPanel } from '../panel';
25
+ import { jsx as ___EmotionJSX } from "@emotion/react";
26
+
27
+ var NotificationEvent = function NotificationEvent() {
28
+ var _useState = useState(false),
29
+ _useState2 = _slicedToArray(_useState, 2),
30
+ isRead = _useState2[0],
31
+ setIsRead = _useState2[1];
32
+
33
+ var onRead = function onRead(id, isRead) {
34
+ setIsRead(!isRead);
35
+ };
36
+
37
+ var onOpenContextMenu = function onOpenContextMenu(id) {
38
+ return [___EmotionJSX(EuiContextMenuItem, {
39
+ key: "contextMenuItemA",
40
+ onClick: function onClick() {
41
+ return onRead(id, isRead);
42
+ }
43
+ }, isRead ? 'Mark as unread' : 'Mark as read'), ___EmotionJSX(EuiContextMenuItem, {
44
+ key: "contextMenuItemB",
45
+ onClick: function onClick() {}
46
+ }, "View messages like this"), ___EmotionJSX(EuiContextMenuItem, {
47
+ key: "contextMenuItemC",
48
+ onClick: function onClick() {}
49
+ }, "Don\u2019t notify me about this")];
50
+ };
51
+
52
+ return ___EmotionJSX(EuiPanel, {
53
+ paddingSize: "none",
54
+ hasShadow: true,
55
+ style: {
56
+ maxWidth: '540px'
57
+ }
58
+ }, ___EmotionJSX(EuiNotificationEvent, {
59
+ id: "cy-eui-notification-1",
60
+ type: "Report",
61
+ iconType: "logoKibana",
62
+ iconAriaLabel: "Kibana",
63
+ time: "1 min ago",
64
+ title: "[Error Monitoring Report] is generated",
65
+ primaryAction: "Download",
66
+ primaryActionProps: {
67
+ iconType: 'download'
68
+ },
69
+ messages: ['The reported was generated at 17:12:16 GMT+4'],
70
+ isRead: isRead,
71
+ onRead: onRead,
72
+ onOpenContextMenu: onOpenContextMenu,
73
+ onClickPrimaryAction: function onClickPrimaryAction() {},
74
+ onClickTitle: function onClickTitle() {}
75
+ }));
76
+ };
77
+
78
+ describe('EuiNotificationEvent', function () {
79
+ beforeEach(function () {
80
+ cy.viewport(1024, 768); // medium breakpoint
81
+
82
+ cy.realMount(___EmotionJSX(NotificationEvent, null));
83
+ cy.get('article.euiNotificationEvent').should('exist');
84
+ });
85
+ describe('Automated accessibility check', function () {
86
+ it('has zero violations on first render', function () {
87
+ cy.checkAxe();
88
+ });
89
+ it('has zero violations when popover is open', function () {
90
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').realClick();
91
+ cy.get('div.euiPopover__panel').should('exist');
92
+ cy.checkAxe();
93
+ });
94
+ it('has zero violations after the Mark as read button is clicked', function () {
95
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').realClick();
96
+ cy.get('div.euiPopover__panel').should('exist');
97
+ cy.get('div.euiPopover__panel button').first().realClick();
98
+ cy.checkAxe();
99
+ });
100
+ });
101
+ describe('Keyboard accessibility', function () {
102
+ it('has zero violations when the popover is opened by keyboard', function () {
103
+ cy.repeatRealPress('Tab');
104
+ cy.get('button[data-test-subj="cy-eui-notification-1-notificationEventMetaButton"]').should('have.focus');
105
+ cy.realPress('Enter');
106
+ cy.get('div.euiPopover__panel').should('exist');
107
+ cy.checkAxe();
108
+ cy.realPress('Escape');
109
+ cy.get('div.euiPopover__panel').should('not.exist');
110
+ cy.checkAxe();
111
+ });
112
+ });
113
+ });