@elastic/eui 76.0.2 → 76.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 (107) hide show
  1. package/dist/eui_theme_dark.css +37 -6
  2. package/dist/eui_theme_dark.min.css +1 -1
  3. package/dist/eui_theme_light.css +37 -6
  4. package/dist/eui_theme_light.min.css +1 -1
  5. package/es/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
  6. package/es/components/datagrid/body/data_grid_body.js +19 -395
  7. package/es/components/datagrid/body/data_grid_body_custom.js +908 -0
  8. package/es/components/datagrid/body/data_grid_body_virtualized.js +1031 -0
  9. package/es/components/datagrid/body/data_grid_cell.js +16 -12
  10. package/es/components/datagrid/body/data_grid_cell_popover.js +32 -12
  11. package/es/components/datagrid/body/data_grid_cell_wrapper.js +132 -0
  12. package/es/components/datagrid/body/header/data_grid_header_row.js +3 -2
  13. package/es/components/datagrid/data_grid.js +21 -5
  14. package/es/components/datagrid/data_grid_types.js +18 -1
  15. package/es/components/datagrid/utils/row_heights.js +111 -31
  16. package/es/components/date_picker/auto_refresh/auto_refresh.js +2 -1
  17. package/es/components/form/range/dual_range.js +14 -7
  18. package/es/components/form/range/range.js +10 -3
  19. package/es/components/form/super_select/super_select.js +21 -18
  20. package/es/components/form/super_select/super_select_control.js +7 -14
  21. package/es/components/selectable/selectable.js +59 -36
  22. package/es/components/selectable/selectable_list/selectable_list.js +1 -1
  23. package/es/components/suggest/suggest.js +3 -10
  24. package/eui.d.ts +253 -146
  25. package/i18ntokens.json +89 -57
  26. package/lib/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
  27. package/lib/components/datagrid/body/data_grid_body.js +19 -416
  28. package/lib/components/datagrid/body/data_grid_body_custom.js +927 -0
  29. package/lib/components/datagrid/body/data_grid_body_virtualized.js +1059 -0
  30. package/lib/components/datagrid/body/data_grid_cell.js +16 -12
  31. package/lib/components/datagrid/body/data_grid_cell_popover.js +35 -12
  32. package/lib/components/datagrid/body/data_grid_cell_wrapper.js +147 -0
  33. package/lib/components/datagrid/body/header/data_grid_header_row.js +4 -2
  34. package/lib/components/datagrid/data_grid.js +21 -4
  35. package/lib/components/datagrid/data_grid_types.js +22 -1
  36. package/lib/components/datagrid/utils/row_heights.js +116 -33
  37. package/lib/components/date_picker/auto_refresh/auto_refresh.js +2 -1
  38. package/lib/components/form/range/dual_range.js +14 -7
  39. package/lib/components/form/range/range.js +10 -3
  40. package/lib/components/form/super_select/super_select.js +21 -18
  41. package/lib/components/form/super_select/super_select_control.js +7 -16
  42. package/lib/components/selectable/selectable.js +59 -36
  43. package/lib/components/selectable/selectable_list/selectable_list.js +1 -1
  44. package/lib/components/suggest/suggest.js +3 -12
  45. package/optimize/es/components/datagrid/body/data_grid_body.js +17 -387
  46. package/optimize/es/components/datagrid/body/data_grid_body_custom.js +176 -0
  47. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +311 -0
  48. package/optimize/es/components/datagrid/body/data_grid_cell.js +12 -9
  49. package/optimize/es/components/datagrid/body/data_grid_cell_popover.js +30 -12
  50. package/optimize/es/components/datagrid/body/data_grid_cell_wrapper.js +127 -0
  51. package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +3 -2
  52. package/optimize/es/components/datagrid/data_grid.js +8 -5
  53. package/optimize/es/components/datagrid/data_grid_types.js +18 -1
  54. package/optimize/es/components/datagrid/utils/row_heights.js +100 -31
  55. package/optimize/es/components/date_picker/auto_refresh/auto_refresh.js +2 -1
  56. package/optimize/es/components/form/range/dual_range.js +14 -7
  57. package/optimize/es/components/form/range/range.js +10 -3
  58. package/optimize/es/components/form/super_select/super_select.js +16 -12
  59. package/optimize/es/components/form/super_select/super_select_control.js +7 -14
  60. package/optimize/es/components/selectable/selectable.js +50 -34
  61. package/optimize/es/components/selectable/selectable_list/selectable_list.js +1 -1
  62. package/optimize/es/components/suggest/suggest.js +3 -10
  63. package/optimize/lib/components/datagrid/body/data_grid_body.js +16 -409
  64. package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +198 -0
  65. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +342 -0
  66. package/optimize/lib/components/datagrid/body/data_grid_cell.js +12 -9
  67. package/optimize/lib/components/datagrid/body/data_grid_cell_popover.js +33 -19
  68. package/optimize/lib/components/datagrid/body/data_grid_cell_wrapper.js +144 -0
  69. package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +4 -2
  70. package/optimize/lib/components/datagrid/data_grid.js +8 -4
  71. package/optimize/lib/components/datagrid/data_grid_types.js +22 -1
  72. package/optimize/lib/components/datagrid/utils/row_heights.js +103 -37
  73. package/optimize/lib/components/date_picker/auto_refresh/auto_refresh.js +2 -1
  74. package/optimize/lib/components/form/range/dual_range.js +14 -7
  75. package/optimize/lib/components/form/range/range.js +10 -3
  76. package/optimize/lib/components/form/super_select/super_select.js +16 -11
  77. package/optimize/lib/components/form/super_select/super_select_control.js +7 -16
  78. package/optimize/lib/components/selectable/selectable.js +50 -35
  79. package/optimize/lib/components/selectable/selectable_list/selectable_list.js +1 -1
  80. package/optimize/lib/components/suggest/suggest.js +3 -12
  81. package/package.json +1 -1
  82. package/src/components/datagrid/_data_grid.scss +7 -0
  83. package/src/components/datagrid/_data_grid_data_row.scss +1 -0
  84. package/src/components/datagrid/body/footer/_data_grid_footer_row.scss +1 -0
  85. package/src/components/datagrid/body/header/_data_grid_header_row.scss +1 -0
  86. package/src/components/form/super_select/_super_select_control.scss +4 -0
  87. package/src/components/selectable/selectable_list/_selectable_list.scss +10 -3
  88. package/src/themes/amsterdam/global_styling/mixins/_states.scss +17 -8
  89. package/test-env/components/color_picker/color_palette_picker/color_palette_picker.js +5 -6
  90. package/test-env/components/datagrid/body/data_grid_body.js +18 -415
  91. package/test-env/components/datagrid/body/data_grid_body_custom.js +908 -0
  92. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +1057 -0
  93. package/test-env/components/datagrid/body/data_grid_cell.js +16 -12
  94. package/test-env/components/datagrid/body/data_grid_cell_popover.js +33 -19
  95. package/test-env/components/datagrid/body/data_grid_cell_wrapper.js +144 -0
  96. package/test-env/components/datagrid/body/header/data_grid_header_row.js +4 -2
  97. package/test-env/components/datagrid/data_grid.js +21 -4
  98. package/test-env/components/datagrid/data_grid_types.js +22 -1
  99. package/test-env/components/datagrid/utils/row_heights.js +103 -37
  100. package/test-env/components/date_picker/auto_refresh/auto_refresh.js +2 -1
  101. package/test-env/components/form/range/dual_range.js +14 -7
  102. package/test-env/components/form/range/range.js +10 -3
  103. package/test-env/components/form/super_select/super_select.js +21 -17
  104. package/test-env/components/form/super_select/super_select_control.js +7 -16
  105. package/test-env/components/selectable/selectable.js +58 -36
  106. package/test-env/components/selectable/selectable_list/selectable_list.js +1 -1
  107. package/test-env/components/suggest/suggest.js +3 -12
@@ -62,6 +62,7 @@ import { EuiRangeWrapper } from './range_wrapper';
62
62
  import { calculateThumbPosition } from './utils';
63
63
  import { euiRangeStyles } from './range.styles';
64
64
  import { euiDualRangeStyles } from './dual_range.styles';
65
+ import { EuiI18n } from '../../i18n';
65
66
  import { jsx as ___EmotionJSX } from "@emotion/react";
66
67
  export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
67
68
  _inherits(EuiDualRangeClass, _Component);
@@ -571,6 +572,11 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
571
572
  backgroundColor: euiRangeLevelColor(rightThumbColor, theme.euiTheme)
572
573
  }) : rightThumbPosition;
573
574
 
575
+ var dualSliderScreenReaderInstructions = ___EmotionJSX(EuiI18n, {
576
+ token: "euiDualRange.sliderScreenReaderInstructions",
577
+ default: "You are in a custom range slider. Use the Up and Down arrow keys to change the minimum value. Press Tab to interact with the maximum value."
578
+ });
579
+
574
580
  var theRange = ___EmotionJSX(EuiRangeWrapper, {
575
581
  css: cssStyles,
576
582
  className: classes,
@@ -626,8 +632,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
626
632
  onFocus: _this2.onThumbFocus,
627
633
  onBlur: _this2.onThumbBlur,
628
634
  onKeyDown: _this2.handleDraggableKeyDown,
629
- "aria-describedby": _this2.props['aria-describedby'],
630
- "aria-label": _this2.props['aria-label']
635
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
636
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
631
637
  }), ___EmotionJSX(EuiRangeThumb, {
632
638
  min: min,
633
639
  max: Number(_this2.upperValue),
@@ -639,8 +645,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
639
645
  onFocus: _this2.onThumbFocus,
640
646
  onBlur: _this2.onThumbBlur,
641
647
  style: logicalStyles(leftThumbStyles),
642
- "aria-describedby": _this2.props['aria-describedby'],
643
- "aria-label": _this2.props['aria-label']
648
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
649
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
644
650
  }), ___EmotionJSX(EuiRangeThumb, {
645
651
  min: Number(_this2.lowerValue),
646
652
  max: max,
@@ -652,8 +658,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
652
658
  onFocus: _this2.onThumbFocus,
653
659
  onBlur: _this2.onThumbBlur,
654
660
  style: logicalStyles(rightThumbStyles),
655
- "aria-describedby": _this2.props['aria-describedby'],
656
- "aria-label": _this2.props['aria-label']
661
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
662
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
657
663
  })), showRange && _this2.isValid && ___EmotionJSX(EuiRangeHighlight, {
658
664
  showTicks: showTicks,
659
665
  min: Number(min),
@@ -687,7 +693,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
687
693
  isOpen: this.state.isPopoverOpen,
688
694
  closePopover: this.closePopover,
689
695
  disableFocusTrap: true,
690
- onPanelResize: this.onResize
696
+ onPanelResize: this.onResize,
697
+ popoverScreenReaderText: dualSliderScreenReaderInstructions
691
698
  }, theRange) : undefined;
692
699
  return thePopover || theRange;
693
700
  }
@@ -53,6 +53,7 @@ import { EuiRangeTooltip } from './range_tooltip';
53
53
  import { EuiRangeTrack } from './range_track';
54
54
  import { EuiRangeWrapper } from './range_wrapper';
55
55
  import { euiRangeStyles } from './range.styles';
56
+ import { EuiI18n } from '../../i18n';
56
57
  import { jsx as ___EmotionJSX } from "@emotion/react";
57
58
  export var EuiRangeClass = /*#__PURE__*/function (_Component) {
58
59
  _inherits(EuiRangeClass, _Component);
@@ -198,6 +199,11 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
198
199
  var cssStyles = [styles.euiRange, showInput && styles.hasInput];
199
200
  var thumbColor = levels && getLevelColor(levels, Number(value));
200
201
 
202
+ var sliderScreenReaderInstructions = ___EmotionJSX(EuiI18n, {
203
+ token: "euiRange.sliderScreenReaderInstructions",
204
+ default: "You are in a custom range slider. Use the Up and Down arrow keys to change the value."
205
+ });
206
+
201
207
  var theRange = ___EmotionJSX(EuiRangeWrapper, {
202
208
  className: classes,
203
209
  css: cssStyles,
@@ -218,7 +224,7 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
218
224
  levels: levels,
219
225
  onChange: this.handleOnChange,
220
226
  value: value,
221
- "aria-hidden": showInput === true,
227
+ "aria-hidden": !!showInput,
222
228
  showRange: showRange
223
229
  }, function (trackWidth) {
224
230
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiRangeSlider, _extends({
@@ -239,7 +245,7 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
239
245
  } : undefined,
240
246
  onFocus: showInput === true ? undefined : onFocus,
241
247
  onBlur: showInputOnly ? _this2.onInputBlur : onBlur,
242
- "aria-hidden": showInput === true ? true : false,
248
+ "aria-hidden": !!showInput,
243
249
  thumbColor: thumbColor
244
250
  }, rest)), showRange && _this2.isValid && ___EmotionJSX(EuiRangeHighlight, {
245
251
  showTicks: showTicks,
@@ -273,7 +279,8 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
273
279
  fullWidth: fullWidth,
274
280
  isOpen: this.state.isPopoverOpen,
275
281
  closePopover: this.closePopover,
276
- disableFocusTrap: true
282
+ disableFocusTrap: true,
283
+ popoverScreenReaderText: sliderScreenReaderInstructions
277
284
  }, theRange) : undefined;
278
285
  return thePopover ? thePopover : theRange;
279
286
  }
@@ -1,6 +1,6 @@
1
1
  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); }
2
2
 
3
- var _excluded = ["className", "options", "valueOfSelected", "onChange", "isOpen", "isInvalid", "hasDividers", "itemClassName", "itemLayoutAlign", "fullWidth", "popoverProps", "compressed"],
3
+ var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "hasDividers", "itemClassName", "itemLayoutAlign", "fullWidth", "popoverProps", "compressed"],
4
4
  _excluded2 = ["value", "dropdownDisplay", "inputDisplay"];
5
5
 
6
6
  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); }
@@ -77,8 +77,6 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
77
77
 
78
78
  _defineProperty(_assertThisInitialized(_this), "describedById", htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId'));
79
79
 
80
- _defineProperty(_assertThisInitialized(_this), "labelledById", htmlIdGenerator('euiSuperSelect_')('_screenreaderLabelId'));
81
-
82
80
  _defineProperty(_assertThisInitialized(_this), "state", {
83
81
  isPopoverOpen: _this.props.isOpen || false
84
82
  });
@@ -244,6 +242,7 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
244
242
  className = _this$props.className,
245
243
  options = _this$props.options,
246
244
  valueOfSelected = _this$props.valueOfSelected,
245
+ placeholder = _this$props.placeholder,
247
246
  onChange = _this$props.onChange,
248
247
  isOpen = _this$props.isOpen,
249
248
  isInvalid = _this$props.isInvalid,
@@ -264,9 +263,9 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
264
263
  }, itemClassName);
265
264
 
266
265
  var button = ___EmotionJSX(EuiSuperSelectControl, _extends({
267
- screenReaderId: this.labelledById,
268
266
  options: options,
269
267
  value: valueOfSelected,
268
+ placeholder: placeholder,
270
269
  onClick: this.state.isPopoverOpen ? this.closePopover : this.openPopover,
271
270
  onKeyDown: this.onSelectKeyDown,
272
271
  className: buttonClasses,
@@ -311,14 +310,19 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
311
310
  }, ___EmotionJSX(EuiI18n, {
312
311
  token: "euiSuperSelect.screenReaderAnnouncement",
313
312
  default: "You are in a form selector and must select a single option. Use the Up and Down arrow keys to navigate or Escape to close."
314
- }))), ___EmotionJSX("div", {
315
- "aria-labelledby": this.labelledById,
316
- "aria-describedby": this.describedById,
317
- className: "euiSuperSelect__listbox",
318
- role: "listbox",
319
- "aria-activedescendant": valueOfSelected,
320
- tabIndex: 0
321
- }, items));
313
+ }))), ___EmotionJSX(EuiI18n, {
314
+ token: "euiSuperSelect.ariaLabel",
315
+ default: "Select listbox"
316
+ }, function (ariaLabel) {
317
+ return ___EmotionJSX("div", {
318
+ "aria-label": ariaLabel,
319
+ "aria-describedby": _this2.describedById,
320
+ className: "euiSuperSelect__listbox",
321
+ role: "listbox",
322
+ "aria-activedescendant": valueOfSelected,
323
+ tabIndex: 0
324
+ }, items);
325
+ }));
322
326
  }
323
327
  }]);
324
328
 
@@ -363,6 +367,11 @@ EuiSuperSelect.propTypes = {
363
367
  readOnly: PropTypes.bool,
364
368
  name: PropTypes.string,
365
369
 
370
+ /**
371
+ * Placeholder to display when the current selected value is empty.
372
+ */
373
+ placeholder: PropTypes.node,
374
+
366
375
  /**
367
376
  * Creates an input group with element(s) coming before input.
368
377
  * `string` | `ReactElement` or an array of these
@@ -375,12 +384,6 @@ EuiSuperSelect.propTypes = {
375
384
  */
376
385
  append: PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.element.isRequired]).isRequired, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string.isRequired, PropTypes.element.isRequired]).isRequired).isRequired]),
377
386
 
378
- /**
379
- * Creates a semantic label ID for the `div[role="listbox"]` that's opened on click or keypress.
380
- * __Generated and passed down by `EuiSuperSelect`.__
381
- */
382
- screenReaderId: PropTypes.string,
383
-
384
387
  /**
385
388
  * Pass an array of options that must at least include:
386
389
  * `value`: storing unique value of item,
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "options", "id", "name", "fullWidth", "isLoading", "isInvalid", "readOnly", "defaultValue", "compressed", "value", "prepend", "append", "screenReaderId", "disabled"];
1
+ var _excluded = ["className", "options", "id", "name", "fullWidth", "isLoading", "isInvalid", "readOnly", "defaultValue", "compressed", "value", "placeholder", "prepend", "append", "disabled"];
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
 
@@ -15,9 +15,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
15
15
  */
16
16
  import React, { Fragment } from 'react';
17
17
  import classNames from 'classnames';
18
- import { EuiScreenReaderOnly } from '../../accessibility';
19
18
  import { EuiFormControlLayout } from '../form_control_layout';
20
- import { EuiI18n } from '../../i18n';
21
19
  import { getFormControlClassNameForIconCount } from '../form_control_layout/_num_icons';
22
20
  import { useFormContext } from '../eui_form_context';
23
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -41,9 +39,9 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
41
39
  _props$compressed = props.compressed,
42
40
  compressed = _props$compressed === void 0 ? false : _props$compressed,
43
41
  value = props.value,
42
+ placeholder = props.placeholder,
44
43
  prepend = props.prepend,
45
44
  append = props.append,
46
- screenReaderId = props.screenReaderId,
47
45
  disabled = props.disabled,
48
46
  rest = _objectWithoutProperties(props, _excluded);
49
47
 
@@ -76,6 +74,7 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
76
74
  selectedValue = selectedOption ? selectedOption.inputDisplay : selectedValue;
77
75
  }
78
76
 
77
+ var showPlaceholder = !!placeholder && !selectedValue;
79
78
  return ___EmotionJSX(Fragment, null, ___EmotionJSX("input", {
80
79
  type: "hidden",
81
80
  id: id,
@@ -93,20 +92,14 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
93
92
  compressed: compressed,
94
93
  prepend: prepend,
95
94
  append: append
96
- }, ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("span", {
97
- id: screenReaderId
98
- }, ___EmotionJSX(EuiI18n, {
99
- token: "euiSuperSelectControl.selectAnOption",
100
- default: "Select an option: {selectedValue}, is selected",
101
- values: {
102
- selectedValue: selectedValue
103
- }
104
- }))), ___EmotionJSX("button", _extends({
95
+ }, ___EmotionJSX("button", _extends({
105
96
  type: "button",
106
97
  className: classes,
107
98
  "aria-haspopup": "listbox",
108
99
  disabled: disabled || readOnly // @ts-ignore Using as a selector only for mixin use
109
100
  ,
110
101
  readOnly: readOnly
111
- }, rest), selectedValue)));
102
+ }, rest), showPlaceholder ? ___EmotionJSX("span", {
103
+ className: "euiSuperSelectControl__placeholder"
104
+ }, placeholder) : selectedValue)));
112
105
  };
@@ -1,9 +1,11 @@
1
1
  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); }
2
2
 
3
- var _excluded = ["children", "className", "options", "onChange", "onActiveOptionChange", "searchable", "searchProps", "singleSelection", "isLoading", "listProps", "renderOption", "height", "allowExclusions", "aria-label", "aria-describedby", "loadingMessage", "noMatchesMessage", "emptyMessage", "errorMessage", "isPreFiltered"],
3
+ var _excluded = ["children", "className", "options", "onChange", "onActiveOptionChange", "searchable", "searchProps", "singleSelection", "isLoading", "listProps", "renderOption", "height", "allowExclusions", "aria-label", "aria-describedby", "loadingMessage", "noMatchesMessage", "emptyMessage", "errorMessage", "selectableScreenReaderText", "isPreFiltered"],
4
4
  _excluded2 = ["aria-label", "aria-describedby", "onChange", "defaultValue", "inputRef"],
5
5
  _excluded3 = ["aria-label", "aria-describedby", "isVirtualized", "rowHeight"];
6
6
 
7
+ 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); }
8
+
7
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
10
 
9
11
  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."); }
@@ -16,8 +18,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
18
 
17
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
20
 
19
- 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); }
20
-
21
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
22
22
 
23
23
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
@@ -96,6 +96,16 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
96
96
 
97
97
  _defineProperty(_assertThisInitialized(_this), "listId", void 0);
98
98
 
99
+ _defineProperty(_assertThisInitialized(_this), "isFocusOnSearchOrListBox", function (target) {
100
+ var _this$optionsListRef$, _this$optionsListRef$2;
101
+
102
+ var searchHasFocus = _this.props.searchable && target === _this.inputRef;
103
+ var listBox = (_this$optionsListRef$ = _this.optionsListRef.current) === null || _this$optionsListRef$ === void 0 ? void 0 : (_this$optionsListRef$2 = _this$optionsListRef$.listBoxRef) === null || _this$optionsListRef$2 === void 0 ? void 0 : _this$optionsListRef$2.parentElement;
104
+ var listBoxContainsFocus = target instanceof Node && (listBox === null || listBox === void 0 ? void 0 : listBox.contains(target));
105
+ var listBoxHasFocus = target === listBox || listBoxContainsFocus;
106
+ return searchHasFocus || listBoxHasFocus;
107
+ });
108
+
99
109
  _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
100
110
  // Bypass onFocus when a click event originates from this.containerRef.
101
111
  // Prevents onFocus from scrolling away from a clicked option and negating the selection event.
@@ -103,7 +113,7 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
103
113
  _this.preventOnFocus = true;
104
114
  });
105
115
 
106
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
116
+ _defineProperty(_assertThisInitialized(_this), "onFocus", function (event) {
107
117
  if (_this.preventOnFocus) {
108
118
  _this.preventOnFocus = false;
109
119
  return;
@@ -113,6 +123,10 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
113
123
  return;
114
124
  }
115
125
 
126
+ if (event && !_this.isFocusOnSearchOrListBox(event.target)) {
127
+ return;
128
+ }
129
+
116
130
  var firstSelected = _this.state.visibleOptions.findIndex(function (option) {
117
131
  return option.checked && !option.disabled && !option.isGroupLabel;
118
132
  });
@@ -133,7 +147,19 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
133
147
  });
134
148
 
135
149
  _defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
136
- var optionsList = _this.optionsListRef.current;
150
+ var optionsList = _this.optionsListRef.current; // Check if the user is interacting with something other than the
151
+ // searchbox or selection list. If so, the user may be attempting to
152
+ // interact with the search clear button or a totally custom button,
153
+ // and listbox keyboard navigation/selection should not be triggered.
154
+
155
+ if (!_this.isFocusOnSearchOrListBox(event.target)) {
156
+ _this.setState({
157
+ activeOptionIndex: undefined,
158
+ isFocused: false
159
+ });
160
+
161
+ return;
162
+ }
137
163
 
138
164
  switch (event.key) {
139
165
  case keys.ARROW_UP:
@@ -158,20 +184,10 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
158
184
  case keys.ENTER:
159
185
  case keys.SPACE:
160
186
  if (_this.props.searchable) {
161
- var _this$optionsListRef$, _this$optionsListRef$2;
162
-
163
187
  // For searchable instances, SPACE is reserved as a character for filtering
164
188
  // via the input box, and as such only ENTER will toggle selection.
165
189
  if (event.target === _this.inputRef && event.key === keys.SPACE) {
166
190
  return;
167
- } // Check if the user is interacting with something other than the
168
- // searchbox or selection list. If not, the user is attempting to
169
- // interact with an internal button such as the clear button,
170
- // and the event should not be altered.
171
-
172
-
173
- if (!(event.target === _this.inputRef || event.target === ((_this$optionsListRef$ = _this.optionsListRef.current) === null || _this$optionsListRef$ === void 0 ? void 0 : (_this$optionsListRef$2 = _this$optionsListRef$.listBoxRef) === null || _this$optionsListRef$2 === void 0 ? void 0 : _this$optionsListRef$2.parentElement))) {
174
- return;
175
191
  }
176
192
  }
177
193
 
@@ -262,10 +278,8 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
262
278
  });
263
279
 
264
280
  _defineProperty(_assertThisInitialized(_this), "onContainerBlur", function (e) {
265
- var _e$relatedTarget, _e$relatedTarget$firs;
266
-
267
281
  // Ignore blur events when moving from search to option to avoid activeOptionIndex conflicts
268
- if (((_e$relatedTarget = e.relatedTarget) === null || _e$relatedTarget === void 0 ? void 0 : (_e$relatedTarget$firs = _e$relatedTarget.firstChild) === null || _e$relatedTarget$firs === void 0 ? void 0 : _e$relatedTarget$firs.id) === _this.listId) {
282
+ if (_this.isFocusOnSearchOrListBox(e.relatedTarget)) {
269
283
  return;
270
284
  }
271
285
 
@@ -372,6 +386,7 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
372
386
  noMatchesMessage = _this$props3.noMatchesMessage,
373
387
  emptyMessage = _this$props3.emptyMessage,
374
388
  errorMessage = _this$props3.errorMessage,
389
+ selectableScreenReaderText = _this$props3.selectableScreenReaderText,
375
390
  isPreFiltered = _this$props3.isPreFiltered,
376
391
  rest = _objectWithoutProperties(_this$props3, _excluded);
377
392
 
@@ -507,10 +522,15 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
507
522
  var searchAccessibleName = getAccessibleName(searchProps, this.messageContentId);
508
523
  var searchHasAccessibleName = Boolean(Object.keys(searchAccessibleName).length);
509
524
  var search = searchable ? ___EmotionJSX(EuiI18n, {
510
- token: "euiSelectable.placeholderName",
511
- default: "Filter options"
512
- }, function (placeholderName) {
513
- return ___EmotionJSX(EuiSelectableSearch, _extends({
525
+ tokens: ['euiSelectable.screenReaderInstructions', 'euiSelectable.placeholderName'],
526
+ defaults: ['Use the Up and Down arrow keys to move focus over options. Press Enter to select. Press Escape to collapse options.', 'Filter options']
527
+ }, function (_ref4) {
528
+ var _ref5 = _slicedToArray(_ref4, 2),
529
+ screenReaderInstructions = _ref5[0],
530
+ placeholderName = _ref5[1];
531
+
532
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiSelectableSearch, _extends({
533
+ "aria-describedby": listAriaDescribedbyId,
514
534
  key: "listSearch",
515
535
  options: options,
516
536
  value: searchValue,
@@ -529,7 +549,9 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
529
549
  }
530
550
  }, searchHasAccessibleName ? searchAccessibleName : {
531
551
  'aria-label': placeholderName
532
- }, cleanedSearchProps));
552
+ }, cleanedSearchProps)), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
553
+ id: listAriaDescribedbyId
554
+ }, selectableScreenReaderText, " ", screenReaderInstructions)));
533
555
  }) : undefined;
534
556
  var resultsLength = visibleOptions.filter(function (option) {
535
557
  return !option.disabled;
@@ -537,8 +559,8 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
537
559
 
538
560
  var listScreenReaderStatus = searchable && ___EmotionJSX(EuiI18n, {
539
561
  token: "euiSelectable.searchResults",
540
- default: function _default(_ref4) {
541
- var resultsLength = _ref4.resultsLength;
562
+ default: function _default(_ref6) {
563
+ var resultsLength = _ref6.resultsLength;
542
564
  return "".concat(resultsLength, " result").concat(resultsLength === 1 ? '' : 's', " available");
543
565
  },
544
566
  values: {
@@ -551,18 +573,12 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
551
573
  var listHasAccessibleName = Boolean(Object.keys(listAccessibleName).length);
552
574
 
553
575
  var list = ___EmotionJSX(EuiI18n, {
554
- tokens: ['euiSelectable.screenReaderInstructions', 'euiSelectable.placeholderName'],
555
- defaults: ['Use up and down arrows to move focus over options. Enter to select. Escape to collapse options.', 'Filter options']
556
- }, function (_ref5) {
557
- var _ref6 = _slicedToArray(_ref5, 2),
558
- placeholderName = _ref6[0],
559
- screenReaderInstructions = _ref6[1];
560
-
576
+ token: "euiSelectable.placeholderName",
577
+ default: "Filter options"
578
+ }, function (placeholderName) {
561
579
  return ___EmotionJSX(React.Fragment, null, searchable && ___EmotionJSX(EuiScreenReaderLive, {
562
580
  isActive: messageContent != null || activeOptionIndex != null
563
- }, messageContent || listScreenReaderStatus), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
564
- id: listAriaDescribedbyId
565
- }, screenReaderInstructions)), messageContent ? ___EmotionJSX(EuiSelectableMessage, {
581
+ }, messageContent || listScreenReaderStatus), messageContent ? ___EmotionJSX(EuiSelectableMessage, {
566
582
  "data-test-subj": "euiSelectableMessage",
567
583
  id: _this2.messageContentId,
568
584
  bordered: listProps && listProps.bordered
@@ -801,5 +817,12 @@ EuiSelectable.propTypes = {
801
817
  * Control whether or not options get filtered internally or if consumer will filter
802
818
  * Default: false
803
819
  */
804
- isPreFiltered: PropTypes.bool
820
+ isPreFiltered: PropTypes.bool,
821
+
822
+ /**
823
+ * Optional screen reader instructions to announce upon focus/interaction. This text is read out
824
+ * after the `EuiSelectable` label and a brief pause, but before the default keyboard instructions for
825
+ * interacting with a selectable are read out.
826
+ */
827
+ selectableScreenReaderText: PropTypes.string
805
828
  };
@@ -112,7 +112,7 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
112
112
  }
113
113
 
114
114
  if (typeof ariaDescribedby === 'string') {
115
- ref.setAttribute('aria-labelledby', ariaDescribedby);
115
+ ref.setAttribute('aria-describedby', ariaDescribedby);
116
116
  }
117
117
  }
118
118
  });
@@ -32,8 +32,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
32
32
  import React, { useState, useCallback } from 'react';
33
33
  import PropTypes from "prop-types";
34
34
  import classNames from 'classnames';
35
- import { useGeneratedHtmlId } from '../../services';
36
- import { EuiScreenReaderOnly } from '../accessibility';
37
35
  import { EuiIcon } from '../icon';
38
36
  import { useEuiI18n } from '../i18n';
39
37
  import { EuiInputPopover } from '../popover';
@@ -128,14 +126,11 @@ export var EuiSuggest = function EuiSuggest(_ref) {
128
126
  var searchOnChange = function searchOnChange(value) {
129
127
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(value);
130
128
  };
131
-
132
- var inputDescribedbyId = useGeneratedHtmlId({
133
- prefix: id
134
- });
135
129
  /**
136
130
  * Status
137
131
  */
138
132
 
133
+
139
134
  var icon = '';
140
135
  var color = '';
141
136
 
@@ -226,6 +221,7 @@ export var EuiSuggest = function EuiSuggest(_ref) {
226
221
  }
227
222
  }, [onItemClick, suggestions]);
228
223
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiSelectable, {
224
+ selectableScreenReaderText: stateMessage,
229
225
  singleSelection: true,
230
226
  height: isVirtualized ? undefined : 'full',
231
227
  options: suggestionList,
@@ -250,7 +246,6 @@ export var EuiSuggest = function EuiSuggest(_ref) {
250
246
  onBlur: searchOnBlur,
251
247
  onInput: searchOnInput,
252
248
  onChange: searchOnChange,
253
- 'aria-describedby': inputDescribedbyId,
254
249
  'aria-label': ariaLabel,
255
250
  'aria-labelledby': labelId
256
251
  }, rest)
@@ -274,9 +269,7 @@ export var EuiSuggest = function EuiSuggest(_ref) {
274
269
  },
275
270
  className: "eui-yScroll"
276
271
  }, list));
277
- }), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
278
- id: inputDescribedbyId
279
- }, stateMessage)));
272
+ }));
280
273
  };
281
274
  EuiSuggest.propTypes = {
282
275
  className: PropTypes.string,