@elastic/eui 70.1.0 → 70.2.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 (111) hide show
  1. package/dist/eui_theme_dark.css +11 -1
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +11 -1
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/accessibility/screen_reader_only/screen_reader_only.js +1 -1
  6. package/es/components/accessibility/screen_reader_only/screen_reader_only.styles.js +1 -1
  7. package/es/components/accordion/accordion.a11y.js +35 -0
  8. package/es/components/card/card.js +13 -31
  9. package/es/components/card/card.styles.js +15 -3
  10. package/es/components/card/card_select/card_select.styles.js +4 -4
  11. package/es/components/card/checkable_card/checkable_card.js +3 -2
  12. package/es/components/context_menu/context_menu_panel.a11y.js +34 -0
  13. package/es/components/datagrid/controls/data_grid_toolbar.js +6 -2
  14. package/es/components/datagrid/controls/index.js +1 -0
  15. package/es/components/datagrid/controls/keyboard_shortcuts.js +191 -0
  16. package/es/components/datagrid/data_grid.js +12 -2
  17. package/es/components/date_picker/super_date_picker/super_date_picker.js +22 -4
  18. package/es/components/selectable/selectable.a11y.js +118 -0
  19. package/es/components/selectable/selectable.js +9 -6
  20. package/es/components/tabs/tab.js +7 -3
  21. package/es/components/tabs/tab.styles.js +29 -16
  22. package/es/components/tabs/tabbed_content/tabbed_content.js +1 -1
  23. package/es/components/tabs/tabs.js +3 -3
  24. package/es/components/tabs/tabs.styles.js +2 -4
  25. package/es/services/string/to_initials.js +1 -1
  26. package/eui.d.ts +208 -164
  27. package/i18ntokens.json +438 -6
  28. package/lib/components/accessibility/screen_reader_only/screen_reader_only.js +1 -1
  29. package/lib/components/accessibility/screen_reader_only/screen_reader_only.styles.js +1 -1
  30. package/lib/components/accordion/accordion.a11y.js +44 -0
  31. package/lib/components/card/card.js +14 -33
  32. package/lib/components/card/card.styles.js +15 -3
  33. package/lib/components/card/card_select/card_select.styles.js +4 -4
  34. package/lib/components/card/checkable_card/checkable_card.js +3 -2
  35. package/lib/components/context_menu/context_menu_panel.a11y.js +42 -0
  36. package/lib/components/datagrid/controls/data_grid_toolbar.js +7 -2
  37. package/lib/components/datagrid/controls/index.js +8 -0
  38. package/lib/components/datagrid/controls/keyboard_shortcuts.js +208 -0
  39. package/lib/components/datagrid/data_grid.js +11 -1
  40. package/lib/components/date_picker/super_date_picker/super_date_picker.js +22 -4
  41. package/lib/components/selectable/selectable.a11y.js +122 -0
  42. package/lib/components/selectable/selectable.js +9 -6
  43. package/lib/components/tabs/tab.js +7 -3
  44. package/lib/components/tabs/tab.styles.js +29 -16
  45. package/lib/components/tabs/tabbed_content/tabbed_content.js +1 -1
  46. package/lib/components/tabs/tabs.js +3 -3
  47. package/lib/components/tabs/tabs.styles.js +1 -3
  48. package/lib/services/string/to_initials.js +1 -1
  49. package/optimize/es/components/accessibility/screen_reader_only/screen_reader_only.styles.js +1 -1
  50. package/optimize/es/components/accordion/accordion.a11y.js +35 -0
  51. package/optimize/es/components/card/card.js +12 -30
  52. package/optimize/es/components/card/card.styles.js +15 -3
  53. package/optimize/es/components/card/card_select/card_select.styles.js +4 -4
  54. package/optimize/es/components/card/checkable_card/checkable_card.js +3 -2
  55. package/optimize/es/components/context_menu/context_menu_panel.a11y.js +34 -0
  56. package/optimize/es/components/datagrid/controls/data_grid_toolbar.js +6 -2
  57. package/optimize/es/components/datagrid/controls/index.js +1 -0
  58. package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +181 -0
  59. package/optimize/es/components/datagrid/data_grid.js +6 -2
  60. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +12 -4
  61. package/optimize/es/components/selectable/selectable.a11y.js +107 -0
  62. package/optimize/es/components/selectable/selectable.js +9 -6
  63. package/optimize/es/components/tabs/tab.js +7 -3
  64. package/optimize/es/components/tabs/tab.styles.js +29 -16
  65. package/optimize/es/components/tabs/tabs.js +3 -3
  66. package/optimize/es/components/tabs/tabs.styles.js +2 -4
  67. package/optimize/es/services/string/to_initials.js +1 -1
  68. package/optimize/lib/components/accessibility/screen_reader_only/screen_reader_only.styles.js +1 -1
  69. package/optimize/lib/components/accordion/accordion.a11y.js +44 -0
  70. package/optimize/lib/components/card/card.js +13 -32
  71. package/optimize/lib/components/card/card.styles.js +15 -3
  72. package/optimize/lib/components/card/card_select/card_select.styles.js +4 -4
  73. package/optimize/lib/components/card/checkable_card/checkable_card.js +3 -2
  74. package/optimize/lib/components/context_menu/context_menu_panel.a11y.js +42 -0
  75. package/optimize/lib/components/datagrid/controls/data_grid_toolbar.js +7 -2
  76. package/optimize/lib/components/datagrid/controls/index.js +8 -0
  77. package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +207 -0
  78. package/optimize/lib/components/datagrid/data_grid.js +5 -1
  79. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +12 -4
  80. package/optimize/lib/components/selectable/selectable.a11y.js +122 -0
  81. package/optimize/lib/components/selectable/selectable.js +9 -6
  82. package/optimize/lib/components/tabs/tab.js +7 -3
  83. package/optimize/lib/components/tabs/tab.styles.js +29 -16
  84. package/optimize/lib/components/tabs/tabs.js +3 -3
  85. package/optimize/lib/components/tabs/tabs.styles.js +1 -3
  86. package/optimize/lib/services/string/to_initials.js +1 -1
  87. package/package.json +3 -2
  88. package/src/components/datagrid/_index.scss +1 -0
  89. package/src/components/datagrid/controls/_data_grid_keyboard_shortcuts.scss +17 -0
  90. package/src/components/modal/_modal.scss +3 -1
  91. package/test-env/components/accessibility/screen_reader_only/screen_reader_only.js +1 -1
  92. package/test-env/components/accessibility/screen_reader_only/screen_reader_only.styles.js +1 -1
  93. package/test-env/components/accordion/accordion.a11y.js +44 -0
  94. package/test-env/components/card/card.js +14 -33
  95. package/test-env/components/card/card.styles.js +15 -3
  96. package/test-env/components/card/card_select/card_select.styles.js +4 -4
  97. package/test-env/components/card/checkable_card/checkable_card.js +3 -2
  98. package/test-env/components/context_menu/context_menu_panel.a11y.js +42 -0
  99. package/test-env/components/datagrid/controls/data_grid_toolbar.js +7 -2
  100. package/test-env/components/datagrid/controls/index.js +8 -0
  101. package/test-env/components/datagrid/controls/keyboard_shortcuts.js +207 -0
  102. package/test-env/components/datagrid/data_grid.js +11 -1
  103. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +22 -4
  104. package/test-env/components/selectable/selectable.a11y.js +122 -0
  105. package/test-env/components/selectable/selectable.js +9 -6
  106. package/test-env/components/tabs/tab.js +7 -3
  107. package/test-env/components/tabs/tab.styles.js +29 -16
  108. package/test-env/components/tabs/tabbed_content/tabbed_content.js +1 -1
  109. package/test-env/components/tabs/tabs.js +3 -3
  110. package/test-env/components/tabs/tabs.styles.js +1 -3
  111. package/test-env/services/string/to_initials.js +1 -1
@@ -29,7 +29,7 @@ EuiScreenReaderOnly.propTypes = {
29
29
  children: PropTypes.element.isRequired,
30
30
 
31
31
  /**
32
- * For keyboard navigation, force content to display visually upon focus.
32
+ * For keyboard navigation, force content to display visually upon focus/focus-within.
33
33
  */
34
34
  showOnFocus: PropTypes.bool,
35
35
  className: PropTypes.string
@@ -21,6 +21,6 @@ export var euiScreenReaderOnly = function euiScreenReaderOnly() {
21
21
 
22
22
  export var euiScreenReaderOnlyStyles = function euiScreenReaderOnlyStyles(showOnFocus) {
23
23
  return {
24
- euiScreenReaderOnly: showOnFocus ? /*#__PURE__*/css("&:not(:focus):not(:active){", euiScreenReaderOnly(), ";};label:euiScreenReaderOnly;") : /*#__PURE__*/css(euiScreenReaderOnly(), ";label:euiScreenReaderOnly;")
24
+ euiScreenReaderOnly: showOnFocus ? /*#__PURE__*/css("&:not(:focus):not(:active):not(:focus-within){", euiScreenReaderOnly(), ";};label:euiScreenReaderOnly;") : /*#__PURE__*/css(euiScreenReaderOnly(), ";label:euiScreenReaderOnly;")
25
25
  };
26
26
  };
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ /// <reference types="../../../cypress/support"/>
9
+ import React from 'react';
10
+ import { EuiAccordion } from './index';
11
+ import { EuiPanel } from '../../components/panel';
12
+ import { htmlIdGenerator } from '../../services';
13
+ import { jsx as ___EmotionJSX } from "@emotion/react";
14
+ var baseProps = {
15
+ buttonContent: 'Click me to toggle',
16
+ id: htmlIdGenerator()(),
17
+ initialIsOpen: false
18
+ };
19
+ var noArrow = {
20
+ arrowDisplay: 'none'
21
+ };
22
+ var noArrowProps = Object.assign(baseProps, noArrow);
23
+ describe('EuiAccordion', function () {
24
+ describe('Automated accessibility check', function () {
25
+ it('has zero violations when expanded', function () {
26
+ cy.mount(___EmotionJSX(EuiAccordion, noArrowProps, ___EmotionJSX(EuiPanel, {
27
+ color: "subdued"
28
+ }, "Any content inside of ", ___EmotionJSX("strong", null, "EuiAccordion"), " will appear here. We will include ", ___EmotionJSX("a", {
29
+ href: "#"
30
+ }, "a link"), " to confirm focus.")));
31
+ cy.get('button.euiAccordion__button').click();
32
+ cy.checkAxe();
33
+ });
34
+ });
35
+ });
@@ -23,33 +23,19 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
23
23
  import React, { isValidElement } from 'react';
24
24
  import PropTypes from "prop-types";
25
25
  import classNames from 'classnames';
26
- import { keysOf } from '../common';
27
26
  import { getSecureRelForTarget, useEuiTheme } from '../../services';
27
+ import { cloneElementWithCss } from '../../services/theme/clone_element';
28
28
  import { EuiText } from '../text';
29
29
  import { EuiTitle } from '../title';
30
30
  import { EuiBetaBadge } from '../badge/beta_badge';
31
- import { EuiCardSelect, euiCardSelectableColor } from './card_select';
31
+ import { EuiCardSelect } from './card_select';
32
32
  import { useGeneratedHtmlId } from '../../services/accessibility';
33
33
  import { validateHref } from '../../services/security/href_validator';
34
34
  import { EuiPanel } from '../panel';
35
35
  import { EuiSpacer } from '../spacer';
36
36
  import { euiCardBetaBadgeStyles, euiCardStyles, euiCardTextStyles } from './card.styles';
37
37
  import { jsx as ___EmotionJSX } from "@emotion/react";
38
- var textAlignToClassNameMap = {
39
- left: 'euiCard--leftAligned',
40
- center: 'euiCard--centerAligned',
41
- right: 'euiCard--rightAligned'
42
- };
43
- export var ALIGNMENTS = keysOf(textAlignToClassNameMap);
44
- var layoutToClassNameMap = {
45
- vertical: '',
46
- horizontal: 'euiCard--horizontal'
47
- };
48
- export var LAYOUT_ALIGNMENTS = keysOf(layoutToClassNameMap);
49
- /**
50
- * Certain props are only allowed when the layout is vertical
51
- */
52
-
38
+ export var ALIGNMENTS = ['left', 'center', 'right'];
53
39
  export var EuiCard = function EuiCard(_ref) {
54
40
  var className = _ref.className,
55
41
  description = _ref.description,
@@ -84,8 +70,9 @@ export var EuiCard = function EuiCard(_ref) {
84
70
  var euiThemeContext = useEuiTheme();
85
71
  var styles = euiCardStyles(euiThemeContext, paddingSize);
86
72
  var cardStyles = [styles.card.euiCard, // Text alignment should always be left when horizontal
87
- styles.card.aligned[layout === 'horizontal' ? 'left' : textAlign], styles.card.layout[layout], isDisabled && styles.card.disabled];
73
+ styles.card.aligned[layout === 'horizontal' ? 'left' : textAlign], isDisabled && styles.card.disabled];
88
74
  var contentStyles = [styles.content.euiCard__content, styles.content.layout[layout]];
75
+ var mainStyles = [styles.main.euiCard__main, styles.main.layout[layout]];
89
76
  var textStyles = euiCardTextStyles(euiThemeContext);
90
77
  var textCSS = [textStyles.euiCard__text, // Text alignment should always be left when horizontal
91
78
  textStyles.aligned[layout === 'horizontal' ? 'left' : textAlign], isClickable && textStyles.interactive, isDisabled && textStyles.disabled];
@@ -109,15 +96,7 @@ export var EuiCard = function EuiCard(_ref) {
109
96
  }
110
97
  }
111
98
 
112
- var selectableColorClass = selectable ? "euiCard--isSelectable--".concat(euiCardSelectableColor(selectable.color, selectable.isSelected)) : undefined;
113
- var classes = classNames('euiCard', textAlignToClassNameMap[textAlign], layoutToClassNameMap[layout], {
114
- 'euiCard--isClickable': isClickable,
115
- 'euiCard--hasBetaBadge': betaBadgeProps === null || betaBadgeProps === void 0 ? void 0 : betaBadgeProps.label,
116
- 'euiCard--hasIcon': icon,
117
- 'euiCard--isSelectable': selectable,
118
- 'euiCard-isSelected': selectable === null || selectable === void 0 ? void 0 : selectable.isSelected,
119
- 'euiCard-isDisabled': isDisabled
120
- }, selectableColorClass, className);
99
+ var classes = classNames('euiCard', className);
121
100
  var ariaId = useGeneratedHtmlId();
122
101
  var ariaDesc = description ? "".concat(ariaId, "Description") : '';
123
102
  /**
@@ -145,7 +124,7 @@ export var EuiCard = function EuiCard(_ref) {
145
124
 
146
125
  if (icon) {
147
126
  var iconStyles = [styles.icon.euiCard__icon, styles.icon.layout[layout], imageNode && styles.icon.withImage];
148
- iconNode = /*#__PURE__*/React.cloneElement(icon, {
127
+ iconNode = cloneElementWithCss(icon, {
149
128
  className: classNames(icon.props.className, 'euiCard__icon'),
150
129
  css: iconStyles
151
130
  });
@@ -301,14 +280,17 @@ export var EuiCard = function EuiCard(_ref) {
301
280
  hasShadow: isDisabled || display ? false : true,
302
281
  hasBorder: display ? false : undefined,
303
282
  paddingSize: paddingSize
304
- }, rest), optionalCardTop, ___EmotionJSX("div", {
283
+ }, rest), ___EmotionJSX("div", {
284
+ className: "euiCard__main",
285
+ css: mainStyles
286
+ }, optionalCardTop, ___EmotionJSX("div", {
305
287
  className: "euiCard__content",
306
288
  css: contentStyles
307
289
  }, ___EmotionJSX(EuiTitle, {
308
290
  id: "".concat(ariaId, "Title"),
309
291
  className: "euiCard__title",
310
292
  size: titleSize
311
- }, ___EmotionJSX(TitleElement, null, theTitle)), optionalDescription, optionalChildren), optionalBetaBadge, optionalFooter, optionalSelectButton);
293
+ }, ___EmotionJSX(TitleElement, null, theTitle)), optionalDescription, optionalChildren), optionalBetaBadge, optionalFooter), optionalSelectButton);
312
294
  };
313
295
  EuiCard.propTypes = {
314
296
  /**
@@ -320,7 +302,7 @@ EuiCard.propTypes = {
320
302
  /**
321
303
  * Changes alignment of the title and description
322
304
  */
323
- textAlign: PropTypes.oneOf(["left", "center", "right"]),
305
+ textAlign: PropTypes.any,
324
306
 
325
307
  /**
326
308
  * Accepts any combination of elements
@@ -54,6 +54,15 @@ var _ref5 = process.env.NODE_ENV === "production" ? {
54
54
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
55
55
  };
56
56
 
57
+ var _ref6 = process.env.NODE_ENV === "production" ? {
58
+ name: "z24364-euiCard__main",
59
+ styles: "display:flex;label:euiCard__main;"
60
+ } : {
61
+ name: "z24364-euiCard__main",
62
+ styles: "display:flex;label:euiCard__main;",
63
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
64
+ };
65
+
57
66
  export var euiCardStyles = function euiCardStyles(euiThemeContext, paddingSize) {
58
67
  var euiTheme = euiThemeContext.euiTheme;
59
68
  var paddingAmount = euiPaddingSize(euiThemeContext, paddingSize);
@@ -61,17 +70,20 @@ export var euiCardStyles = function euiCardStyles(euiThemeContext, paddingSize)
61
70
  var halfSpacing = euiPaddingSize(euiThemeContext, halfPaddingKey);
62
71
  return {
63
72
  card: {
64
- euiCard: /*#__PURE__*/css("display:flex;&:has([class*='euiCard__text'][class*='-interactive']:focus:focus-visible){outline:", euiTheme.focus.width, " solid currentColor;};label:euiCard;"),
73
+ euiCard: /*#__PURE__*/css("display:flex;align-items:flex-start;justify-content:space-between;flex-direction:column;&:has([class*='euiCard__text'][class*='-interactive']:focus:focus-visible){outline:", euiTheme.focus.width, " solid currentColor;};label:euiCard;"),
65
74
  aligned: {
66
75
  center: /*#__PURE__*/css(logicalTextAlignCSS('center'), ";align-items:center;;label:center;"),
67
76
  left: /*#__PURE__*/css(logicalTextAlignCSS('left'), ";align-items:flex-start;;label:left;"),
68
77
  right: /*#__PURE__*/css(logicalTextAlignCSS('right'), ";align-items:flex-end;;label:right;")
69
78
  },
79
+ disabled: /*#__PURE__*/css("cursor:not-allowed;background-color:", euiButtonColor(euiThemeContext, 'disabled'), ";color:", euiTheme.colors.disabledText, ";;label:disabled;")
80
+ },
81
+ main: {
82
+ euiCard__main: _ref6,
70
83
  layout: {
71
84
  vertical: _ref5,
72
85
  horizontal: _ref4
73
- },
74
- disabled: /*#__PURE__*/css("cursor:not-allowed;background-color:", euiButtonColor(euiThemeContext, 'disabled'), ";color:", euiTheme.colors.disabledText, ";;label:disabled;")
86
+ }
75
87
  },
76
88
  content: {
77
89
  euiCard__content: _ref3,
@@ -10,11 +10,11 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
10
10
  import { css } from '@emotion/react';
11
11
 
12
12
  var _ref = process.env.NODE_ENV === "production" ? {
13
- name: "g3lgnd-euiCardSelect",
14
- styles: "transform:none!important;label:euiCardSelect;"
13
+ name: "aogl4-euiCardSelect",
14
+ styles: "transform:none!important;align-self:flex-end;label:euiCardSelect;"
15
15
  } : {
16
- name: "g3lgnd-euiCardSelect",
17
- styles: "transform:none!important;label:euiCardSelect;",
16
+ name: "aogl4-euiCardSelect",
17
+ styles: "transform:none!important;align-self:flex-end;label:euiCardSelect;",
18
18
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
19
19
  };
20
20
 
@@ -1,4 +1,4 @@
1
- var _excluded = ["children", "className", "checkableType", "label", "checked", "disabled", "hasShadow", "hasBorder"];
1
+ var _excluded = ["children", "className", "css", "checkableType", "label", "checked", "disabled", "hasShadow", "hasBorder"];
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
 
@@ -24,6 +24,7 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
24
24
  export var EuiCheckableCard = function EuiCheckableCard(_ref) {
25
25
  var children = _ref.children,
26
26
  className = _ref.className,
27
+ css = _ref.css,
27
28
  _ref$checkableType = _ref.checkableType,
28
29
  checkableType = _ref$checkableType === void 0 ? 'radio' : _ref$checkableType,
29
30
  label = _ref.label,
@@ -36,7 +37,7 @@ export var EuiCheckableCard = function EuiCheckableCard(_ref) {
36
37
 
37
38
  var euiThemeContext = useEuiTheme();
38
39
  var styles = euiCheckableCardStyles(euiThemeContext);
39
- var baseStyles = [styles.euiCheckableCard, checked && !disabled && styles.isChecked];
40
+ var baseStyles = [styles.euiCheckableCard, checked && !disabled && styles.isChecked, css];
40
41
  var labelStyles = [styles.label.euiCheckableCard__label, disabled && styles.label.isDisabled];
41
42
  var childStyles = [styles.euiCheckableCard__children];
42
43
  var id = rest.id;
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+ /// <reference types="../../../cypress/support"/>
9
+ import React from 'react';
10
+ import { EuiContextMenuItem } from './context_menu_item';
11
+ import { EuiContextMenuPanel } from './context_menu_panel';
12
+ import { jsx as ___EmotionJSX } from "@emotion/react";
13
+ var items = [___EmotionJSX(EuiContextMenuItem, {
14
+ key: "A",
15
+ "data-test-subj": "itemA"
16
+ }, "Option A"), ___EmotionJSX(EuiContextMenuItem, {
17
+ key: "B",
18
+ "data-test-subj": "itemB"
19
+ }, "Option B"), ___EmotionJSX(EuiContextMenuItem, {
20
+ key: "C",
21
+ "data-test-subj": "itemC"
22
+ }, "Option C")];
23
+ describe('EuiContextMenuPanel', function () {
24
+ describe('Automated accessibility check', function () {
25
+ it('has zero violations', function () {
26
+ var showNextPanelHandler = cy.stub();
27
+ cy.mount(___EmotionJSX(EuiContextMenuPanel, {
28
+ items: items,
29
+ showNextPanel: showNextPanelHandler
30
+ }));
31
+ cy.checkAxe();
32
+ });
33
+ });
34
+ });
@@ -6,6 +6,7 @@
6
6
  * Side Public License, v 1.
7
7
  */
8
8
  import React from 'react';
9
+ import { EuiScreenReaderOnly } from '../../accessibility';
9
10
  import { IS_JEST_ENVIRONMENT } from '../../../utils'; // When below this number the grid only shows the right control icon buttons
10
11
 
11
12
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -17,6 +18,7 @@ export var EuiDataGridToolbar = function EuiDataGridToolbar(_ref) {
17
18
  toolbarVisibility = _ref.toolbarVisibility,
18
19
  isFullScreen = _ref.isFullScreen,
19
20
  fullScreenSelector = _ref.fullScreenSelector,
21
+ keyboardShortcuts = _ref.keyboardShortcuts,
20
22
  displaySelector = _ref.displaySelector,
21
23
  columnSelector = _ref.columnSelector,
22
24
  columnSorting = _ref.columnSorting;
@@ -24,12 +26,14 @@ export var EuiDataGridToolbar = function EuiDataGridToolbar(_ref) {
24
26
  var hasRoomForGridControls = IS_JEST_ENVIRONMENT ? true : gridWidth > minSizeForControls || isFullScreen;
25
27
  return ___EmotionJSX("div", {
26
28
  className: "euiDataGrid__controls",
27
- "data-test-sub": "dataGridControls"
29
+ "data-test-subj": "dataGridControls"
28
30
  }, hasRoomForGridControls && ___EmotionJSX("div", {
29
31
  className: "euiDataGrid__leftControls"
30
32
  }, renderAdditionalControls(toolbarVisibility, 'left.prepend'), checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showColumnSelector') ? columnSelector : null, checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showSortSelector') ? columnSorting : null, renderAdditionalControls(toolbarVisibility, 'left.append')), ___EmotionJSX("div", {
31
33
  className: "euiDataGrid__rightControls"
32
- }, renderAdditionalControls(toolbarVisibility, 'right'), checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showDisplaySelector') ? displaySelector : null, checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showFullScreenSelector') ? fullScreenSelector : null));
34
+ }, renderAdditionalControls(toolbarVisibility, 'right'), checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showKeyboardShortcuts') ? keyboardShortcuts : ___EmotionJSX(EuiScreenReaderOnly, {
35
+ showOnFocus: true
36
+ }, ___EmotionJSX("span", null, keyboardShortcuts)), checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showDisplaySelector') ? displaySelector : null, checkOrDefaultToolBarDisplayOptions(toolbarVisibility, 'showFullScreenSelector') ? fullScreenSelector : null));
33
37
  };
34
38
  /**
35
39
  * Toolbar utilities
@@ -8,5 +8,6 @@
8
8
  export { useDataGridColumnSelector } from './column_selector';
9
9
  export { useDataGridColumnSorting } from './column_sorting';
10
10
  export { useDataGridDisplaySelector, startingStyles } from './display_selector';
11
+ export { useDataGridKeyboardShortcuts } from './keyboard_shortcuts';
11
12
  export { useDataGridFullScreenSelector } from './fullscreen_selector';
12
13
  export { checkOrDefaultToolBarDisplayOptions, EuiDataGridToolbar } from './data_grid_toolbar';
@@ -0,0 +1,191 @@
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
+ import React, { useState, useMemo } from 'react';
21
+ import { useGeneratedHtmlId } from '../../../services';
22
+ import { EuiButtonIcon } from '../../button';
23
+ import { EuiToolTip } from '../../tool_tip';
24
+ import { EuiPopover, EuiPopoverTitle } from '../../popover';
25
+ import { EuiDescriptionList } from '../../description_list';
26
+ import { EuiText } from '../../text';
27
+ import { useEuiI18n, EuiI18n } from '../../i18n';
28
+ import { jsx as ___EmotionJSX } from "@emotion/react";
29
+ export var useDataGridKeyboardShortcuts = function useDataGridKeyboardShortcuts() {
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ isOpen = _useState2[0],
33
+ setIsOpen = _useState2[1];
34
+
35
+ var title = useEuiI18n('euiKeyboardShortcuts.title', 'Keyboard shortcuts');
36
+ var titleId = useGeneratedHtmlId();
37
+ var keyboardShortcuts = useMemo(function () {
38
+ return ___EmotionJSX(EuiPopover, {
39
+ "data-test-subj": "dataGridKeyboardShortcutsPopover",
40
+ isOpen: isOpen,
41
+ closePopover: function closePopover() {
42
+ return setIsOpen(false);
43
+ },
44
+ anchorPosition: "downRight",
45
+ button: ___EmotionJSX(EuiToolTip, {
46
+ content: title,
47
+ delay: "long"
48
+ }, ___EmotionJSX(EuiButtonIcon, {
49
+ size: "xs",
50
+ iconType: "keyboard",
51
+ color: "text",
52
+ "data-test-subj": "dataGridKeyboardShortcutsButton",
53
+ onClick: function onClick() {
54
+ return setIsOpen(!isOpen);
55
+ },
56
+ "aria-label": title
57
+ }))
58
+ }, ___EmotionJSX(EuiPopoverTitle, {
59
+ paddingSize: "s"
60
+ }, ___EmotionJSX("h2", {
61
+ id: titleId
62
+ }, title)), ___EmotionJSX(EuiText, {
63
+ className: "euiDataGrid__keyboardShortcuts",
64
+ size: "xs"
65
+ }, ___EmotionJSX(EuiDescriptionList, {
66
+ "aria-labelledby": titleId,
67
+ type: "column",
68
+ align: "center",
69
+ compressed: true,
70
+ gutterSize: "s",
71
+ listItems: [{
72
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
73
+ token: "euiKeyboardShortcuts.upArrowTitle",
74
+ default: "Up arrow"
75
+ })),
76
+ description: ___EmotionJSX(EuiI18n, {
77
+ token: "euiKeyboardShortcuts.upArrowDescription",
78
+ default: "Move one cell up"
79
+ })
80
+ }, {
81
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
82
+ token: "euiKeyboardShortcuts.downArrowTitle",
83
+ default: "Down arrow"
84
+ })),
85
+ description: ___EmotionJSX(EuiI18n, {
86
+ token: "euiKeyboardShortcuts.downArrowDescription",
87
+ default: "Move one cell down"
88
+ })
89
+ }, {
90
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
91
+ token: "euiKeyboardShortcuts.rightArrowTitle",
92
+ default: "Right arrow"
93
+ })),
94
+ description: ___EmotionJSX(EuiI18n, {
95
+ token: "euiKeyboardShortcuts.rightArrowDescription",
96
+ default: "Move one cell right"
97
+ })
98
+ }, {
99
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
100
+ token: "euiKeyboardShortcuts.leftArrowTitle",
101
+ default: "Left arrow"
102
+ })),
103
+ description: ___EmotionJSX(EuiI18n, {
104
+ token: "euiKeyboardShortcuts.leftArrowDescription",
105
+ default: "Move one cell left"
106
+ })
107
+ }, {
108
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
109
+ token: "euiKeyboardShortcuts.homeTitle",
110
+ default: "Home"
111
+ })),
112
+ description: ___EmotionJSX(EuiI18n, {
113
+ token: "euiKeyboardShortcuts.homeDescription",
114
+ default: "Move to the first cell of the current row"
115
+ })
116
+ }, {
117
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
118
+ token: "euiKeyboardShortcuts.endTitle",
119
+ default: "End"
120
+ })),
121
+ description: ___EmotionJSX(EuiI18n, {
122
+ token: "euiKeyboardShortcuts.endDescription",
123
+ default: "Move to the last cell of the current row"
124
+ })
125
+ }, {
126
+ title: ___EmotionJSX(React.Fragment, null, ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
127
+ token: "euiKeyboardShortcuts.ctrl",
128
+ default: "Ctrl"
129
+ })), ' ', ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
130
+ token: "euiKeyboardShortcuts.homeTitle",
131
+ default: "Home"
132
+ }))),
133
+ description: ___EmotionJSX(EuiI18n, {
134
+ token: "euiKeyboardShortcuts.ctrlHomeDescription",
135
+ default: "Move to the first cell of the current page"
136
+ })
137
+ }, {
138
+ title: ___EmotionJSX(React.Fragment, null, ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
139
+ token: "euiKeyboardShortcuts.ctrl",
140
+ default: "Ctrl"
141
+ })), ' ', ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
142
+ token: "euiKeyboardShortcuts.endTitle",
143
+ default: "End"
144
+ }))),
145
+ description: ___EmotionJSX(EuiI18n, {
146
+ token: "euiKeyboardShortcuts.ctrlEndDescription",
147
+ default: "Move to the last cell of the current page"
148
+ })
149
+ }, {
150
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
151
+ token: "euiKeyboardShortcuts.pageUpTitle",
152
+ default: "Page Up"
153
+ })),
154
+ description: ___EmotionJSX(EuiI18n, {
155
+ token: "euiKeyboardShortcuts.pageUpDescription",
156
+ default: "Go to the last row of the previous page"
157
+ })
158
+ }, {
159
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
160
+ token: "euiKeyboardShortcuts.pageDownTitle",
161
+ default: "Page Down"
162
+ })),
163
+ description: ___EmotionJSX(EuiI18n, {
164
+ token: "euiKeyboardShortcuts.pageDownDescription",
165
+ default: "Go to the first row of the next page"
166
+ })
167
+ }, {
168
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
169
+ token: "euiKeyboardShortcuts.enterTitle",
170
+ default: "Enter"
171
+ })),
172
+ description: ___EmotionJSX(EuiI18n, {
173
+ token: "euiKeyboardShortcuts.enterDescription",
174
+ default: "Open cell details and actions"
175
+ })
176
+ }, {
177
+ title: ___EmotionJSX("kbd", null, ___EmotionJSX(EuiI18n, {
178
+ token: "euiKeyboardShortcuts.escapeTitle",
179
+ default: "Escape"
180
+ })),
181
+ description: ___EmotionJSX(EuiI18n, {
182
+ token: "euiKeyboardShortcuts.escapeDescription",
183
+ default: "Close cell details and actions"
184
+ })
185
+ }]
186
+ })));
187
+ }, [isOpen, title, titleId]);
188
+ return {
189
+ keyboardShortcuts: keyboardShortcuts
190
+ };
191
+ };
@@ -49,7 +49,7 @@ import { EuiI18n, useEuiI18n } from '../i18n';
49
49
  import { useMutationObserver } from '../observer/mutation_observer';
50
50
  import { useResizeObserver } from '../observer/resize_observer';
51
51
  import { EuiDataGridBody } from './body';
52
- import { useDataGridColumnSelector, useDataGridColumnSorting, useDataGridDisplaySelector, startingStyles, useDataGridFullScreenSelector, checkOrDefaultToolBarDisplayOptions, EuiDataGridToolbar } from './controls';
52
+ import { useDataGridColumnSelector, useDataGridColumnSorting, useDataGridDisplaySelector, startingStyles, useDataGridFullScreenSelector, useDataGridKeyboardShortcuts, checkOrDefaultToolBarDisplayOptions, EuiDataGridToolbar } from './controls';
53
53
  import { DataGridSortingContext, useSorting } from './utils/sorting';
54
54
  import { DataGridFocusContext, useFocus, createKeyDownHandler, preventTabbing } from './utils/focus';
55
55
  import { useInMemoryValues, EuiDataGridInMemoryRenderer } from './utils/in_memory';
@@ -239,12 +239,15 @@ export var EuiDataGrid = /*#__PURE__*/forwardRef(function (props, ref) {
239
239
  cellPopoverContext = _useCellPopover.cellPopoverContext,
240
240
  cellPopover = _useCellPopover.cellPopover;
241
241
  /**
242
- * Toolbar & fullscreen
242
+ * Toolbar, keyboard shortcuts, & fullscreen
243
243
  */
244
244
 
245
245
 
246
246
  var showToolbar = !!toolbarVisibility;
247
247
 
248
+ var _useDataGridKeyboardS = useDataGridKeyboardShortcuts(),
249
+ keyboardShortcuts = _useDataGridKeyboardS.keyboardShortcuts;
250
+
248
251
  var _useDataGridFullScree = useDataGridFullScreenSelector(),
249
252
  isFullScreen = _useDataGridFullScree.isFullScreen,
250
253
  setIsFullScreen = _useDataGridFullScree.setIsFullScreen,
@@ -333,6 +336,7 @@ export var EuiDataGrid = /*#__PURE__*/forwardRef(function (props, ref) {
333
336
  toolbarVisibility: toolbarVisibility,
334
337
  isFullScreen: isFullScreen,
335
338
  fullScreenSelector: fullScreenSelector,
339
+ keyboardShortcuts: keyboardShortcuts,
336
340
  displaySelector: displaySelector,
337
341
  columnSelector: columnSelector,
338
342
  columnSorting: columnSorting
@@ -1110,6 +1114,12 @@ EuiDataGrid.propTypes = {
1110
1114
  */
1111
1115
  showSortSelector: PropTypes.bool,
1112
1116
 
1117
+ /**
1118
+ * Displays a popover listing all keyboard controls and shortcuts for the data grid.
1119
+ * If set to `false`, the toggle will be visually hidden, but still focusable by keyboard and screen reader users.
1120
+ */
1121
+ showKeyboardShortcuts: PropTypes.bool,
1122
+
1113
1123
  /**
1114
1124
  * Allows user to be able to fullscreen the data grid. If set to `false` make sure your grid fits within a large enough panel to still show the other controls.
1115
1125
  */
@@ -269,7 +269,8 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
269
269
  locale = _this$props2.locale,
270
270
  timeFormat = _this$props2.timeFormat,
271
271
  utcOffset = _this$props2.utcOffset,
272
- compressed = _this$props2.compressed;
272
+ compressed = _this$props2.compressed,
273
+ onFocus = _this$props2.onFocus;
273
274
 
274
275
  if (showPrettyDuration && !isStartDatePopoverOpen && !isEndDatePopoverOpen) {
275
276
  return ___EmotionJSX(EuiDatePickerRange, {
@@ -284,7 +285,8 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
284
285
  }),
285
286
  "data-test-subj": "superDatePickerShowDatesButton",
286
287
  disabled: isDisabled,
287
- onClick: _this.hidePrettyDuration
288
+ onClick: _this.hidePrettyDuration,
289
+ onFocus: onFocus
288
290
  }, ___EmotionJSX(PrettyDuration, {
289
291
  timeFrom: start,
290
292
  timeTo: end,
@@ -317,7 +319,10 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
317
319
  isOpen: _this.state.isStartDatePopoverOpen,
318
320
  onPopoverToggle: _this.onStartDatePopoverToggle,
319
321
  onPopoverClose: _this.onStartDatePopoverClose,
320
- timeOptions: timeOptions
322
+ timeOptions: timeOptions,
323
+ buttonProps: {
324
+ onFocus: onFocus
325
+ }
321
326
  }),
322
327
  endDateControl: ___EmotionJSX(EuiDatePopoverButton, {
323
328
  position: "end",
@@ -335,7 +340,10 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
335
340
  isOpen: _this.state.isEndDatePopoverOpen,
336
341
  onPopoverToggle: _this.onEndDatePopoverToggle,
337
342
  onPopoverClose: _this.onEndDatePopoverClose,
338
- timeOptions: timeOptions
343
+ timeOptions: timeOptions,
344
+ buttonProps: {
345
+ onFocus: onFocus
346
+ }
339
347
  })
340
348
  });
341
349
  });
@@ -552,6 +560,11 @@ EuiSuperDatePickerInternal.propTypes = {
552
560
  */
553
561
  locale: PropTypes.any,
554
562
 
563
+ /**
564
+ * Triggered whenever the EuiSuperDatePicker's dates are focused
565
+ */
566
+ onFocus: PropTypes.any,
567
+
555
568
  /**
556
569
  * Callback for when the refresh interval is fired.
557
570
  * EuiSuperDatePicker will only manage a refresh interval timer when onRefresh callback is supplied
@@ -759,6 +772,11 @@ EuiSuperDatePicker.propTypes = {
759
772
  */
760
773
  locale: PropTypes.any,
761
774
 
775
+ /**
776
+ * Triggered whenever the EuiSuperDatePicker's dates are focused
777
+ */
778
+ onFocus: PropTypes.any,
779
+
762
780
  /**
763
781
  * Callback for when the refresh interval is fired.
764
782
  * EuiSuperDatePicker will only manage a refresh interval timer when onRefresh callback is supplied