@elastic/eui 121.0.0 → 122.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 (87) hide show
  1. package/dist/eui-icons.json +37 -37
  2. package/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
  3. package/es/components/datagrid/body/cell/data_grid_cell.js +8 -5
  4. package/es/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
  5. package/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  6. package/es/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
  7. package/es/components/datagrid/body/header/column_resizer.js +74 -87
  8. package/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
  9. package/es/components/datagrid/body/header/data_grid_header_cell.js +1 -0
  10. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
  11. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
  12. package/es/components/datagrid/controls/keyboard_shortcuts.js +17 -1
  13. package/es/components/datagrid/data_grid.js +2 -0
  14. package/es/components/datagrid/utils/copy_focused_cell.js +34 -0
  15. package/es/components/filter_group/filter_group.a11y.js +1 -1
  16. package/es/components/form/super_select/super_select.js +247 -351
  17. package/es/components/list_item_layout/_list_item_layout.js +12 -0
  18. package/es/components/selectable/selectable_list/selectable_list_item.js +9 -7
  19. package/eui.d.ts +69 -95
  20. package/i18ntokens.json +608 -554
  21. package/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
  22. package/lib/components/datagrid/body/cell/data_grid_cell.js +8 -5
  23. package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
  24. package/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  25. package/lib/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
  26. package/lib/components/datagrid/body/header/column_resizer.js +73 -85
  27. package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
  28. package/lib/components/datagrid/body/header/data_grid_header_cell.js +1 -0
  29. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
  30. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
  31. package/lib/components/datagrid/controls/keyboard_shortcuts.js +17 -1
  32. package/lib/components/datagrid/data_grid.js +2 -0
  33. package/lib/components/datagrid/utils/copy_focused_cell.js +39 -0
  34. package/lib/components/filter_group/filter_group.a11y.js +1 -1
  35. package/lib/components/form/super_select/super_select.js +253 -355
  36. package/lib/components/list_item_layout/_list_item_layout.js +12 -0
  37. package/lib/components/selectable/selectable_list/selectable_list_item.js +9 -7
  38. package/optimize/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
  39. package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +5 -4
  40. package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
  41. package/optimize/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  42. package/optimize/es/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
  43. package/optimize/es/components/datagrid/body/header/column_resizer.js +69 -81
  44. package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
  45. package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +1 -0
  46. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +7 -3
  47. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
  48. package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +17 -1
  49. package/optimize/es/components/datagrid/data_grid.js +2 -0
  50. package/optimize/es/components/datagrid/utils/copy_focused_cell.js +34 -0
  51. package/optimize/es/components/filter_group/filter_group.a11y.js +1 -1
  52. package/optimize/es/components/form/super_select/super_select.js +242 -265
  53. package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +9 -7
  54. package/optimize/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
  55. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +5 -4
  56. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
  57. package/optimize/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  58. package/optimize/lib/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
  59. package/optimize/lib/components/datagrid/body/header/column_resizer.js +69 -79
  60. package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
  61. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +1 -0
  62. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +7 -3
  63. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
  64. package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +17 -1
  65. package/optimize/lib/components/datagrid/data_grid.js +2 -0
  66. package/optimize/lib/components/datagrid/utils/copy_focused_cell.js +39 -0
  67. package/optimize/lib/components/filter_group/filter_group.a11y.js +1 -1
  68. package/optimize/lib/components/form/super_select/super_select.js +243 -265
  69. package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +9 -7
  70. package/package.json +2 -2
  71. package/test-env/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
  72. package/test-env/components/datagrid/body/cell/data_grid_cell.js +8 -5
  73. package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
  74. package/test-env/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
  75. package/test-env/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
  76. package/test-env/components/datagrid/body/header/column_resizer.js +69 -79
  77. package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
  78. package/test-env/components/datagrid/body/header/data_grid_header_cell.js +1 -0
  79. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
  80. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
  81. package/test-env/components/datagrid/controls/keyboard_shortcuts.js +17 -1
  82. package/test-env/components/datagrid/data_grid.js +2 -0
  83. package/test-env/components/datagrid/utils/copy_focused_cell.js +16 -0
  84. package/test-env/components/filter_group/filter_group.a11y.js +1 -1
  85. package/test-env/components/form/super_select/super_select.js +243 -345
  86. package/test-env/components/list_item_layout/_list_item_layout.js +12 -0
  87. package/test-env/components/selectable/selectable_list/selectable_list_item.js +9 -7
@@ -1,15 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed"],
4
+ var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "onFocus", "onBlur", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed", "isLoading"],
10
5
  _excluded2 = ["value", "dropdownDisplay", "inputDisplay", "disabled"];
11
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
13
6
  /*
14
7
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
15
8
  * or more contributor license agreements. Licensed under the Elastic License
@@ -18,9 +11,9 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
18
11
  * Side Public License, v 1.
19
12
  */
20
13
 
21
- import React, { Component, createRef } from 'react';
14
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
22
15
  import classNames from 'classnames';
23
- import { htmlIdGenerator, keys, RenderWithEuiStylesMemoizer } from '../../../services';
16
+ import { htmlIdGenerator, keys, useEuiMemoizedStyles } from '../../../services';
24
17
  import { EuiI18n } from '../../i18n';
25
18
  import { EuiScreenReaderOnly } from '../../accessibility';
26
19
  import { EuiInputPopover } from '../../popover';
@@ -32,272 +25,256 @@ var ShiftDirection = /*#__PURE__*/function (ShiftDirection) {
32
25
  ShiftDirection["BACK"] = "back";
33
26
  ShiftDirection["FORWARD"] = "forward";
34
27
  return ShiftDirection;
35
- }(ShiftDirection || {});
36
- export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
37
- function EuiSuperSelect() {
38
- var _this;
39
- _classCallCheck(this, EuiSuperSelect);
40
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
41
- args[_key] = arguments[_key];
42
- }
43
- _this = _callSuper(this, EuiSuperSelect, [].concat(args));
44
- _defineProperty(_this, "itemNodes", []);
45
- _defineProperty(_this, "_isMounted", false);
46
- _defineProperty(_this, "controlButtonRef", /*#__PURE__*/createRef());
47
- _defineProperty(_this, "describedById", htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId'));
48
- _defineProperty(_this, "state", {
49
- isPopoverOpen: _this.props.isOpen || false,
50
- currentIndex: 0
51
- });
52
- _defineProperty(_this, "setItemNode", function (node, index) {
53
- _this.itemNodes[index] = node;
28
+ }(ShiftDirection || {}); // Runs synchronously on the client before paint, so the mount flag is always
29
+ // set before an interaction can schedule the deferred focus in `openPopover`.
30
+ var useMountEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;
31
+ var EuiSuperSelectInner = function EuiSuperSelectInner(_ref, ref) {
32
+ var _options$currentIndex;
33
+ var className = _ref.className,
34
+ options = _ref.options,
35
+ valueOfSelected = _ref.valueOfSelected,
36
+ placeholder = _ref.placeholder,
37
+ onChange = _ref.onChange,
38
+ onFocus = _ref.onFocus,
39
+ onBlur = _ref.onBlur,
40
+ isOpen = _ref.isOpen,
41
+ _ref$isInvalid = _ref.isInvalid,
42
+ isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
43
+ itemClassName = _ref.itemClassName,
44
+ _ref$fullWidth = _ref.fullWidth,
45
+ fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
46
+ popoverProps = _ref.popoverProps,
47
+ _ref$compressed = _ref.compressed,
48
+ compressed = _ref$compressed === void 0 ? false : _ref$compressed,
49
+ _ref$isLoading = _ref.isLoading,
50
+ isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
51
+ rest = _objectWithoutProperties(_ref, _excluded);
52
+ var styles = useEuiMemoizedStyles(euiSuperSelectStyles);
53
+ var itemNodes = useRef([]);
54
+ var isMounted = useRef(false);
55
+ var controlButtonRef = useRef(null);
56
+ var _useState = useState(function () {
57
+ return htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId');
58
+ }),
59
+ _useState2 = _slicedToArray(_useState, 1),
60
+ describedById = _useState2[0];
61
+ var _useState3 = useState(isOpen || false),
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ isPopoverOpen = _useState4[0],
64
+ setIsPopoverOpen = _useState4[1];
65
+ var _useState5 = useState(0),
66
+ _useState6 = _slicedToArray(_useState5, 2),
67
+ currentIndex = _useState6[0],
68
+ setCurrentIndex = _useState6[1];
69
+ var setItemNode = function setItemNode(node, index) {
70
+ itemNodes.current[index] = node;
71
+ };
72
+ var focusItemAt = useCallback(function (index) {
73
+ var _itemNodes$current$in;
74
+ (_itemNodes$current$in = itemNodes.current[index]) === null || _itemNodes$current$in === void 0 || _itemNodes$current$in.focus();
75
+ }, []);
76
+ var openPopover = useCallback(function () {
77
+ var indexOfSelected = options.findIndex(function (option) {
78
+ return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
54
79
  });
55
- _defineProperty(_this, "openPopover", function () {
56
- var _this$props = _this.props,
57
- options = _this$props.options,
58
- valueOfSelected = _this$props.valueOfSelected;
59
- var indexOfSelected = options.findIndex(function (option) {
60
- return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
61
- });
62
- var candidateIndex = valueOfSelected != null && indexOfSelected >= 0 ? indexOfSelected : 0;
63
- var initialIndex = candidateIndex;
80
+ var candidateIndex = valueOfSelected != null && indexOfSelected >= 0 ? indexOfSelected : 0;
81
+ var initialIndex = candidateIndex;
64
82
 
65
- // If the item is disabled, find the first focusable item going forward
66
- while (initialIndex < options.length && (_options$initialIndex = options[initialIndex]) !== null && _options$initialIndex !== void 0 && _options$initialIndex.disabled) {
67
- var _options$initialIndex;
68
- initialIndex++;
69
- }
70
- if (initialIndex >= options.length) {
71
- initialIndex = candidateIndex;
72
- }
73
- _this.setState({
74
- isPopoverOpen: options.length > 0,
75
- currentIndex: initialIndex
76
- });
83
+ // If the item is disabled, find the first focusable item going forward
84
+ while (initialIndex < options.length && (_options$initialIndex = options[initialIndex]) !== null && _options$initialIndex !== void 0 && _options$initialIndex.disabled) {
85
+ var _options$initialIndex;
86
+ initialIndex++;
87
+ }
88
+ if (initialIndex >= options.length) {
89
+ initialIndex = candidateIndex;
90
+ }
91
+ setIsPopoverOpen(options.length > 0);
92
+ setCurrentIndex(initialIndex);
93
+ requestAnimationFrame(function () {
77
94
  requestAnimationFrame(function () {
78
- requestAnimationFrame(function () {
79
- if (!_this._isMounted) {
80
- return;
81
- }
82
- _this.focusItemAt(initialIndex);
83
- if (_this.props.onFocus) {
84
- _this.props.onFocus();
85
- }
86
- });
95
+ if (!isMounted.current) {
96
+ return;
97
+ }
98
+ focusItemAt(initialIndex);
99
+ if (onFocus) {
100
+ onFocus();
101
+ }
87
102
  });
88
103
  });
89
- _defineProperty(_this, "closePopover", function () {
90
- _this.setState({
91
- isPopoverOpen: false,
92
- currentIndex: -1
93
- });
104
+ }, [options, valueOfSelected, onFocus, focusItemAt]);
105
+ var closePopover = useCallback(function () {
106
+ setIsPopoverOpen(false);
107
+ setCurrentIndex(-1);
94
108
 
95
- // Refocus back to the toggling control button on popover close
96
- requestAnimationFrame(function () {
97
- var _this$controlButtonRe;
98
- (_this$controlButtonRe = _this.controlButtonRef.current) === null || _this$controlButtonRe === void 0 || _this$controlButtonRe.focus();
99
- });
100
- if (_this.props.onBlur) {
101
- _this.props.onBlur();
102
- }
109
+ // Refocus back to the toggling control button on popover close
110
+ requestAnimationFrame(function () {
111
+ var _controlButtonRef$cur;
112
+ (_controlButtonRef$cur = controlButtonRef.current) === null || _controlButtonRef$cur === void 0 || _controlButtonRef$cur.focus();
103
113
  });
104
- _defineProperty(_this, "itemClicked", function (value) {
105
- _this.closePopover();
106
- if (_this.props.onChange) {
107
- _this.props.onChange(value);
108
- }
109
- });
110
- _defineProperty(_this, "onSelectKeyDown", function (event) {
111
- // Mimic the ways native `<select>`s can be opened via keypress
112
- if (event.key === keys.ARROW_UP || event.key === keys.ARROW_DOWN || event.key === keys.SPACE) {
114
+ if (onBlur) {
115
+ onBlur();
116
+ }
117
+ }, [onBlur]);
118
+ useImperativeHandle(ref, function () {
119
+ return {
120
+ openPopover: openPopover,
121
+ closePopover: closePopover
122
+ };
123
+ }, [openPopover, closePopover]);
124
+ var itemClicked = function itemClicked(value) {
125
+ closePopover();
126
+ if (onChange) {
127
+ onChange(value);
128
+ }
129
+ };
130
+ var onSelectKeyDown = function onSelectKeyDown(event) {
131
+ // Mimic the ways native `<select>`s can be opened via keypress
132
+ if (event.key === keys.ARROW_UP || event.key === keys.ARROW_DOWN || event.key === keys.SPACE) {
133
+ event.preventDefault();
134
+ event.stopPropagation();
135
+ openPopover();
136
+ }
137
+ };
138
+ var onItemKeyDown = function onItemKeyDown(event) {
139
+ switch (event.key) {
140
+ case keys.ESCAPE:
141
+ // close the popover and prevent ancestors from handling
113
142
  event.preventDefault();
114
143
  event.stopPropagation();
115
- _this.openPopover();
116
- }
117
- });
118
- _defineProperty(_this, "onItemKeyDown", function (event) {
119
- switch (event.key) {
120
- case keys.ESCAPE:
121
- // close the popover and prevent ancestors from handling
122
- event.preventDefault();
123
- event.stopPropagation();
124
- _this.closePopover();
125
- break;
126
- case keys.TAB:
127
- // Mimic native `<select>` behavior, which selects an item on tab press
128
- event.preventDefault();
129
- event.stopPropagation();
130
- event.target.click();
131
- break;
132
- case keys.ARROW_UP:
133
- event.preventDefault();
134
- event.stopPropagation();
135
- _this.shiftFocus(ShiftDirection.BACK);
136
- break;
137
- case keys.ARROW_DOWN:
138
- event.preventDefault();
139
- event.stopPropagation();
140
- _this.shiftFocus(ShiftDirection.FORWARD);
141
- break;
142
- }
143
- });
144
- return _this;
145
- }
146
- _inherits(EuiSuperSelect, _Component);
147
- return _createClass(EuiSuperSelect, [{
148
- key: "componentDidMount",
149
- value: function componentDidMount() {
150
- this._isMounted = true;
151
- if (this.props.isOpen) {
152
- this.openPopover();
153
- }
154
- }
155
- }, {
156
- key: "componentWillUnmount",
157
- value: function componentWillUnmount() {
158
- this._isMounted = false;
144
+ closePopover();
145
+ break;
146
+ case keys.TAB:
147
+ // Mimic native `<select>` behavior, which selects an item on tab press
148
+ event.preventDefault();
149
+ event.stopPropagation();
150
+ event.target.click();
151
+ break;
152
+ case keys.ARROW_UP:
153
+ event.preventDefault();
154
+ event.stopPropagation();
155
+ shiftFocus(ShiftDirection.BACK);
156
+ break;
157
+ case keys.ARROW_DOWN:
158
+ event.preventDefault();
159
+ event.stopPropagation();
160
+ shiftFocus(ShiftDirection.FORWARD);
161
+ break;
159
162
  }
160
- }, {
161
- key: "focusItemAt",
162
- value: function focusItemAt(index) {
163
- var _this$itemNodes$index;
164
- (_this$itemNodes$index = this.itemNodes[index]) === null || _this$itemNodes$index === void 0 || _this$itemNodes$index.focus();
163
+ };
164
+ var shiftFocus = function shiftFocus(direction) {
165
+ if (currentIndex === -1) {
166
+ // somehow the select options has lost focus
167
+ focusItemAt(0);
168
+ setCurrentIndex(0);
169
+ return;
165
170
  }
166
- }, {
167
- key: "shiftFocus",
168
- value: function shiftFocus(direction) {
169
- var options = this.props.options;
170
- var currentIndex = this.state.currentIndex;
171
- if (currentIndex === -1) {
172
- // somehow the select options has lost focus
173
- this.focusItemAt(0);
174
- this.setState({
175
- currentIndex: 0
176
- });
177
- return;
178
- }
179
171
 
180
- // Note: this component purposely does not cycle arrow key navigation
181
- // to match native <select> elements
182
- var step = direction === ShiftDirection.BACK ? -1 : 1;
183
- var nextIndex = currentIndex + step;
184
- while (nextIndex >= 0 && nextIndex < options.length) {
185
- var _options$nextIndex;
186
- if (!((_options$nextIndex = options[nextIndex]) !== null && _options$nextIndex !== void 0 && _options$nextIndex.disabled)) {
187
- this.focusItemAt(nextIndex);
188
- this.setState({
189
- currentIndex: nextIndex
190
- });
191
- return;
192
- }
193
- nextIndex += step;
172
+ // Note: this component purposely does not cycle arrow key navigation
173
+ // to match native <select> elements
174
+ var step = direction === ShiftDirection.BACK ? -1 : 1;
175
+ var nextIndex = currentIndex + step;
176
+ while (nextIndex >= 0 && nextIndex < options.length) {
177
+ var _options$nextIndex;
178
+ if (!((_options$nextIndex = options[nextIndex]) !== null && _options$nextIndex !== void 0 && _options$nextIndex.disabled)) {
179
+ focusItemAt(nextIndex);
180
+ setCurrentIndex(nextIndex);
181
+ return;
194
182
  }
183
+ nextIndex += step;
195
184
  }
196
- }, {
197
- key: "render",
198
- value: function render() {
199
- var _this2 = this,
200
- _options$this$state$c;
201
- var _this$props2 = this.props,
202
- className = _this$props2.className,
203
- options = _this$props2.options,
204
- valueOfSelected = _this$props2.valueOfSelected,
205
- placeholder = _this$props2.placeholder,
206
- onChange = _this$props2.onChange,
207
- isOpen = _this$props2.isOpen,
208
- isInvalid = _this$props2.isInvalid,
209
- itemClassName = _this$props2.itemClassName,
210
- fullWidth = _this$props2.fullWidth,
211
- popoverProps = _this$props2.popoverProps,
212
- compressed = _this$props2.compressed,
213
- rest = _objectWithoutProperties(_this$props2, _excluded);
214
- var popoverClasses = classNames('euiSuperSelect', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className);
215
- var button = ___EmotionJSX(EuiSuperSelectControl, _extends({
216
- options: options,
217
- value: valueOfSelected,
218
- placeholder: placeholder,
219
- onClick: this.state.isPopoverOpen ? this.closePopover : this.openPopover,
220
- onKeyDown: this.onSelectKeyDown,
221
- className: className,
222
- fullWidth: fullWidth,
223
- isInvalid: isInvalid,
224
- compressed: compressed
225
- }, rest, {
226
- buttonRef: this.controlButtonRef,
227
- isDropdownOpen: this.state.isPopoverOpen
228
- }));
229
- var items = options.map(function (option, index) {
230
- var value = option.value,
231
- dropdownDisplay = option.dropdownDisplay,
232
- inputDisplay = option.inputDisplay,
233
- disabled = option.disabled,
234
- optionRest = _objectWithoutProperties(option, _excluded2);
235
- if (value == null) return;
236
- return ___EmotionJSX(EuiSuperSelectItem, _extends({
237
- key: index
238
- /* NOTE: This should rather use "li" to align select-like behavior. But the current
239
- implementation relies on the interactive and focusable item for the navigation.
240
- This will require additional refactoring to adjust but we might want to decide first
241
- if the effort is worth it, considering the unification plans for selection components
242
- as part of OneSelect (https://github.com/elastic/eui/issues/8808).
243
- */,
244
- element: "button",
245
- id: String(value),
246
- className: itemClassName,
247
- checked: valueOfSelected === value ? 'on' : undefined,
248
- isSelected: valueOfSelected === value,
249
- isFocused: _this2.state.currentIndex === index,
250
- isSingleSelection: true,
251
- isDisabled: disabled,
252
- textWrap: "wrap",
253
- onClick: function onClick() {
254
- return _this2.itemClicked(value);
255
- },
256
- onKeyDown: _this2.onItemKeyDown,
257
- ref: function ref(node) {
258
- return _this2.setItemNode(node, index);
259
- },
260
- "aria-selected": valueOfSelected === value
261
- }, optionRest), dropdownDisplay || inputDisplay);
262
- });
263
- var ariaActiveDescendant = ((_options$this$state$c = options[this.state.currentIndex]) === null || _options$this$state$c === void 0 ? void 0 : _options$this$state$c.value) != null ? String(options[this.state.currentIndex].value) : undefined;
264
- return ___EmotionJSX(RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
265
- var styles = stylesMemoizer(euiSuperSelectStyles);
266
- return ___EmotionJSX(EuiInputPopover, _extends({
267
- closePopover: _this2.closePopover,
268
- panelPaddingSize: "none"
269
- }, popoverProps, {
270
- className: popoverClasses,
271
- isOpen: isOpen || _this2.state.isPopoverOpen,
272
- input: button,
273
- fullWidth: fullWidth,
274
- disableFocusTrap: true // This component handles its own focus manually
275
- }), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
276
- id: _this2.describedById
277
- }, ___EmotionJSX(EuiI18n, {
278
- token: "euiSuperSelect.screenReaderAnnouncement",
279
- 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."
280
- }))), ___EmotionJSX(EuiI18n, {
281
- token: "euiSuperSelect.ariaLabel",
282
- default: "Select listbox"
283
- }, function (ariaLabel) {
284
- return ___EmotionJSX("div", {
285
- "aria-label": ariaLabel,
286
- "aria-describedby": _this2.describedById,
287
- css: styles.euiSuperSelect__listbox,
288
- className: "euiSuperSelect__listbox eui-scrollBar",
289
- role: "listbox",
290
- "aria-activedescendant": ariaActiveDescendant,
291
- tabIndex: 0
292
- }, items);
293
- }));
294
- });
185
+ };
186
+ useMountEffect(function () {
187
+ isMounted.current = true;
188
+ if (isOpen) {
189
+ openPopover();
295
190
  }
296
- }]);
297
- }(Component);
298
- _defineProperty(EuiSuperSelect, "defaultProps", {
299
- fullWidth: false,
300
- compressed: false,
301
- isInvalid: false,
302
- isLoading: false
303
- });
191
+ return function () {
192
+ isMounted.current = false;
193
+ };
194
+ // The class lifecycle this replaces only ran when the component mounted.
195
+ // eslint-disable-next-line react-hooks/exhaustive-deps
196
+ }, []);
197
+ var popoverClasses = classNames('euiSuperSelect', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className);
198
+ var button = ___EmotionJSX(EuiSuperSelectControl, _extends({
199
+ options: options,
200
+ value: valueOfSelected,
201
+ placeholder: placeholder,
202
+ onClick: isPopoverOpen ? closePopover : openPopover,
203
+ onKeyDown: onSelectKeyDown,
204
+ onFocus: onFocus,
205
+ onBlur: onBlur,
206
+ className: className,
207
+ fullWidth: fullWidth,
208
+ isInvalid: isInvalid,
209
+ compressed: compressed,
210
+ isLoading: isLoading
211
+ }, rest, {
212
+ buttonRef: controlButtonRef,
213
+ isDropdownOpen: isPopoverOpen
214
+ }));
215
+ var items = options.map(function (option, index) {
216
+ var value = option.value,
217
+ dropdownDisplay = option.dropdownDisplay,
218
+ inputDisplay = option.inputDisplay,
219
+ disabled = option.disabled,
220
+ optionRest = _objectWithoutProperties(option, _excluded2);
221
+ if (value == null) return;
222
+ return ___EmotionJSX(EuiSuperSelectItem, _extends({
223
+ key: index
224
+ /* NOTE: This should rather use "li" to align select-like behavior. But the current
225
+ implementation relies on the interactive and focusable item for the navigation.
226
+ This will require additional refactoring to adjust but we might want to decide first
227
+ if the effort is worth it, considering the unification plans for selection components
228
+ as part of OneSelect (https://github.com/elastic/eui/issues/8808).
229
+ */,
230
+ element: "button",
231
+ id: String(value),
232
+ className: itemClassName,
233
+ checked: valueOfSelected === value ? 'on' : undefined,
234
+ isSelected: valueOfSelected === value,
235
+ isFocused: currentIndex === index,
236
+ isSingleSelection: true,
237
+ isDisabled: disabled,
238
+ textWrap: "wrap",
239
+ onClick: function onClick() {
240
+ return itemClicked(value);
241
+ },
242
+ onKeyDown: onItemKeyDown,
243
+ ref: function ref(node) {
244
+ return setItemNode(node, index);
245
+ },
246
+ "aria-selected": valueOfSelected === value
247
+ }, optionRest), dropdownDisplay || inputDisplay);
248
+ });
249
+ var ariaActiveDescendant = ((_options$currentIndex = options[currentIndex]) === null || _options$currentIndex === void 0 ? void 0 : _options$currentIndex.value) != null ? String(options[currentIndex].value) : undefined;
250
+ return ___EmotionJSX(EuiInputPopover, _extends({
251
+ closePopover: closePopover,
252
+ panelPaddingSize: "none"
253
+ }, popoverProps, {
254
+ className: popoverClasses,
255
+ isOpen: isOpen || isPopoverOpen,
256
+ input: button,
257
+ fullWidth: fullWidth,
258
+ disableFocusTrap: true // This component handles its own focus manually
259
+ }), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
260
+ id: describedById
261
+ }, ___EmotionJSX(EuiI18n, {
262
+ token: "euiSuperSelect.screenReaderAnnouncement",
263
+ 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."
264
+ }))), ___EmotionJSX(EuiI18n, {
265
+ token: "euiSuperSelect.ariaLabel",
266
+ default: "Select listbox"
267
+ }, function (ariaLabel) {
268
+ return ___EmotionJSX("div", {
269
+ "aria-label": ariaLabel,
270
+ "aria-describedby": describedById,
271
+ css: styles.euiSuperSelect__listbox,
272
+ className: "euiSuperSelect__listbox eui-scrollBar",
273
+ role: "listbox",
274
+ "aria-activedescendant": ariaActiveDescendant,
275
+ tabIndex: 0
276
+ }, items);
277
+ }));
278
+ };
279
+ export var EuiSuperSelect = /*#__PURE__*/forwardRef(EuiSuperSelectInner);
280
+ EuiSuperSelect.displayName = 'EuiSuperSelect';
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "className", "disabled", "checked", "isFocused", "showIcons", "prepend", "append", "allowExclusions", "singleSelection", "onFocusBadge", "role", "searchable", "toolTipContent", "toolTipProps"],
4
+ var _excluded = ["children", "className", "disabled", "checked", "isFocused", "showIcons", "prepend", "append", "allowExclusions", "singleSelection", "onFocusBadge", "role", "searchable", "toolTipContent", "toolTipProps", "title"],
5
5
  _excluded2 = ["children", "className"];
6
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -40,6 +40,7 @@ export var EuiSelectableListItem = function EuiSelectableListItem(_ref) {
40
40
  searchable = _ref.searchable,
41
41
  toolTipContent = _ref.toolTipContent,
42
42
  toolTipProps = _ref.toolTipProps,
43
+ title = _ref.title,
43
44
  rest = _objectWithoutProperties(_ref, _excluded);
44
45
  var classes = classNames('euiSelectableListItem', {
45
46
  'euiSelectableListItem-isFocused': isFocused
@@ -69,10 +70,6 @@ export var EuiSelectableListItem = function EuiSelectableListItem(_ref) {
69
70
  var instructions;
70
71
  var screenReaderStrings = {
71
72
  checked: {
72
- state: ___EmotionJSX(EuiI18n, {
73
- token: "euiSelectableListItem.checkedOption",
74
- default: "Checked option."
75
- }),
76
73
  instructions: ___EmotionJSX(EuiI18n, {
77
74
  token: "euiSelectableListItem.checkOptionInstructions",
78
75
  default: "To check this option, press Enter."
@@ -115,7 +112,8 @@ export var EuiSelectableListItem = function EuiSelectableListItem(_ref) {
115
112
  };
116
113
  switch (checked) {
117
114
  case 'on':
118
- state = screenReaderStrings.checked.state;
115
+ // the checked state is already announced natively via `aria-checked`/
116
+ // `aria-selected`; additional state text would duplicate the announcement
119
117
  instructions = allowExclusions ? screenReaderStrings.excluded.instructions : searchable ? screenReaderStrings.unchecked.instructions : undefined;
120
118
  break;
121
119
  case 'off':
@@ -158,7 +156,11 @@ export var EuiSelectableListItem = function EuiSelectableListItem(_ref) {
158
156
  className: 'euiSelectableListItem__content'
159
157
  },
160
158
  textProps: {
161
- className: 'euiSelectableListItem__text'
159
+ className: 'euiSelectableListItem__text',
160
+ // `title` must not be set on the option element itself - it would become
161
+ // the option's accessible description, causing screen readers to
162
+ // announce the option name twice
163
+ title: title
162
164
  },
163
165
  tooltipProps: hasToolTip ? _objectSpread({
164
166
  content: toolTipContent,
@@ -33,7 +33,7 @@ var _list_item_layout = require("../../list_item_layout");
33
33
  var _combo_box_options_list = require("./combo_box_options_list.styles");
34
34
  var _react2 = require("@emotion/react");
35
35
  var _excluded = ["children"],
36
- _excluded2 = ["key", "className", "isGroupLabelOption", "label", "value", "prepend", "append", "truncationProps", "toolTipContent", "toolTipProps"],
36
+ _excluded2 = ["key", "className", "isGroupLabelOption", "label", "value", "prepend", "append", "truncationProps", "toolTipContent", "toolTipProps", "title"],
37
37
  _excluded3 = ["data-test-subj", "activeOptionIndex", "areAllOptionsSelected", "customOptionText", "fullWidth", "getSelectedOptionForSearchValue", "isCaseSensitive", "isLoading", "listRef", "matchingOptions", "onCloseList", "onCreateOption", "onOptionClick", "onOptionEnterKey", "onScroll", "options", "renderOption", "rootId", "rowHeight", "scrollToIndex", "searchValue", "selectedOptions", "singleSelection", "delimiter", "onFocusBadge", "truncationProps", "listboxAriaLabel", "setListOptionRefs"];
38
38
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
39
39
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -93,6 +93,7 @@ var EuiComboBoxOptionsList = exports.EuiComboBoxOptionsList = /*#__PURE__*/funct
93
93
  _truncationProps = option.truncationProps,
94
94
  toolTipContent = option.toolTipContent,
95
95
  toolTipProps = option.toolTipProps,
96
+ title = option.title,
96
97
  rest = (0, _objectWithoutProperties2.default)(option, _excluded2);
97
98
  var _this$props2 = _this.props,
98
99
  options = _this$props2.options,
@@ -144,7 +145,6 @@ var EuiComboBoxOptionsList = exports.EuiComboBoxOptionsList = /*#__PURE__*/funct
144
145
  // loses focus on selecting an option (due to actively removing it from the list)
145
146
  ,
146
147
  id: rootId("_option-".concat(options.indexOf(option))),
147
- title: hasNativeTruncation && !toolTipContent ? label : undefined,
148
148
  key: (_option$key = option.key) !== null && _option$key !== void 0 ? _option$key : option.label,
149
149
  prepend: option.prepend,
150
150
  append: hasOnFocusBadge ? (0, _react2.jsx)(_react.default.Fragment, null, option.append, hitEnterBadge) : option.append,
@@ -164,6 +164,12 @@ var EuiComboBoxOptionsList = exports.EuiComboBoxOptionsList = /*#__PURE__*/funct
164
164
  contentProps: {
165
165
  className: 'euiComboBoxOption__content'
166
166
  },
167
+ textProps: {
168
+ // `title` must not be set on the option element itself - it would
169
+ // become the option's accessible description, causing screen readers
170
+ // to announce the option name twice
171
+ title: title !== null && title !== void 0 ? title : hasNativeTruncation && !toolTipContent ? label : undefined
172
+ },
167
173
  onClick: function onClick() {
168
174
  if (onOptionClick) {
169
175
  onOptionClick(option);