@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
@@ -1 +1,18 @@
1
- export {};
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
+ // since react-window doesn't export a type with the imperative api only we can
9
+ // use this to omit the react-specific class component methods
10
+ // An array of [x,y] coordinates. Note that the `y` value expected internally is a `visibleRowIndex`
11
+ // Force either aria-label or aria-labelledby to be defined
12
+
13
+ /**
14
+ * Props shared between renderCellValue and renderCellPopover
15
+ */
16
+ // The empty control column array fallbacks need to be cached, or
17
+ // they'll cause rerendering/remount issues in memoized dependencies
18
+ export var emptyControlColumns = [];
@@ -1,9 +1,18 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
3
+ import _get from "@babel/runtime/helpers/get";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
2
7
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
8
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
9
  import _createClass from "@babel/runtime/helpers/createClass";
5
10
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
11
 
12
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
13
+
14
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
+
7
16
  /*
8
17
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
9
18
  * or more contributor license agreements. Licensed under the Elastic License
@@ -24,16 +33,11 @@ export var cellPaddingsMap = {
24
33
  export var AUTO_HEIGHT = 'auto';
25
34
  export var DEFAULT_ROW_HEIGHT = 34;
26
35
  export var RowHeightUtils = /*#__PURE__*/function () {
27
- function RowHeightUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, rerenderGridBodyRef) {
36
+ function RowHeightUtils() {
28
37
  var _this = this;
29
38
 
30
39
  _classCallCheck(this, RowHeightUtils);
31
40
 
32
- this.gridRef = gridRef;
33
- this.outerGridElementRef = outerGridElementRef;
34
- this.gridItemsRenderedRef = gridItemsRenderedRef;
35
- this.rerenderGridBodyRef = rerenderGridBodyRef;
36
-
37
41
  _defineProperty(this, "styles", {
38
42
  paddingTop: 0,
39
43
  paddingBottom: 0
@@ -65,10 +69,6 @@ export var RowHeightUtils = /*#__PURE__*/function () {
65
69
  });
66
70
 
67
71
  _defineProperty(this, "heightsCache", new Map());
68
-
69
- _defineProperty(this, "timerId", void 0);
70
-
71
- _defineProperty(this, "lastUpdatedRow", Infinity);
72
72
  }
73
73
 
74
74
  _createClass(RowHeightUtils, [{
@@ -154,6 +154,11 @@ export var RowHeightUtils = /*#__PURE__*/function () {
154
154
 
155
155
  return false;
156
156
  }
157
+ /**
158
+ * Heights cache utils
159
+ * This cache is primarily used by auto heights & secondarily used by lineCount row overrides
160
+ */
161
+
157
162
  }, {
158
163
  key: "getRowHeight",
159
164
  value: function getRowHeight(rowIndex) {
@@ -166,23 +171,20 @@ export var RowHeightUtils = /*#__PURE__*/function () {
166
171
  }, {
167
172
  key: "setRowHeight",
168
173
  value: function setRowHeight(rowIndex, colId) {
169
- var _this$rerenderGridBod, _this$rerenderGridBod2;
170
-
171
174
  var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_ROW_HEIGHT;
172
- var visibleRowIndex = arguments.length > 3 ? arguments[3] : undefined;
175
+
176
+ var _visibleRowIndex = arguments.length > 3 ? arguments[3] : undefined;
177
+
173
178
  var rowHeights = this.heightsCache.get(rowIndex) || new Map();
174
179
  var adaptedHeight = Math.ceil(height + this.styles.paddingTop + this.styles.paddingBottom);
175
180
 
176
181
  if (rowHeights.get(colId) === adaptedHeight) {
177
- return;
182
+ return false;
183
+ } else {
184
+ rowHeights.set(colId, adaptedHeight);
185
+ this.heightsCache.set(rowIndex, rowHeights);
186
+ return true;
178
187
  }
179
-
180
- rowHeights.set(colId, adaptedHeight);
181
- this.heightsCache.set(rowIndex, rowHeights);
182
- this.resetRow(visibleRowIndex); // When an auto row height is updated, force a re-render
183
- // of the grid body to update the unconstrained height
184
-
185
- (_this$rerenderGridBod = (_this$rerenderGridBod2 = this.rerenderGridBodyRef).current) === null || _this$rerenderGridBod === void 0 ? void 0 : _this$rerenderGridBod.call(_this$rerenderGridBod2);
186
188
  }
187
189
  }, {
188
190
  key: "pruneHiddenColumnHeights",
@@ -201,22 +203,84 @@ export var RowHeightUtils = /*#__PURE__*/function () {
201
203
  }
202
204
  });
203
205
  });
206
+ return didModify;
207
+ }
208
+ }]);
209
+
210
+ return RowHeightUtils;
211
+ }();
212
+ /**
213
+ * Row height utils with virtualization library-specific APIs
214
+ */
215
+
216
+ export var RowHeightVirtualizationUtils = /*#__PURE__*/function (_RowHeightUtils) {
217
+ _inherits(RowHeightVirtualizationUtils, _RowHeightUtils);
218
+
219
+ var _super = _createSuper(RowHeightVirtualizationUtils);
220
+
221
+ function RowHeightVirtualizationUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, rerenderGridBodyRef) {
222
+ var _this2;
223
+
224
+ _classCallCheck(this, RowHeightVirtualizationUtils);
225
+
226
+ _this2 = _super.call(this);
227
+ _this2.gridRef = gridRef;
228
+ _this2.outerGridElementRef = outerGridElementRef;
229
+ _this2.gridItemsRenderedRef = gridItemsRenderedRef;
230
+ _this2.rerenderGridBodyRef = rerenderGridBodyRef;
231
+
232
+ _defineProperty(_assertThisInitialized(_this2), "timerId", void 0);
233
+
234
+ _defineProperty(_assertThisInitialized(_this2), "lastUpdatedRow", Infinity);
235
+
236
+ return _this2;
237
+ }
238
+ /**
239
+ * Virtualization workarounds for auto height rows
240
+ */
241
+
242
+
243
+ _createClass(RowHeightVirtualizationUtils, [{
244
+ key: "setRowHeight",
245
+ value: function setRowHeight(rowIndex, colId) {
246
+ var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DEFAULT_ROW_HEIGHT;
247
+ var visibleRowIndex = arguments.length > 3 ? arguments[3] : undefined;
248
+
249
+ var didModify = _get(_getPrototypeOf(RowHeightVirtualizationUtils.prototype), "setRowHeight", this).call(this, rowIndex, colId, height, visibleRowIndex); // When an auto row height is updated, force a re-render
250
+ // of the grid body to update the unconstrained height
251
+
252
+
253
+ if (didModify) {
254
+ var _this$rerenderGridBod, _this$rerenderGridBod2;
255
+
256
+ (_this$rerenderGridBod = (_this$rerenderGridBod2 = this.rerenderGridBodyRef).current) === null || _this$rerenderGridBod === void 0 ? void 0 : _this$rerenderGridBod.call(_this$rerenderGridBod2);
257
+ this.resetRow(visibleRowIndex);
258
+ }
259
+
260
+ return didModify; // Mostly just here for typing
261
+ }
262
+ }, {
263
+ key: "pruneHiddenColumnHeights",
264
+ value: function pruneHiddenColumnHeights(visibleColumns) {
265
+ var didModify = _get(_getPrototypeOf(RowHeightVirtualizationUtils.prototype), "pruneHiddenColumnHeights", this).call(this, visibleColumns);
204
266
 
205
267
  if (didModify) {
206
268
  this.resetRow(0);
207
269
  }
270
+
271
+ return didModify; // Mostly just here for typing
208
272
  }
209
273
  }, {
210
274
  key: "resetRow",
211
275
  value: function resetRow(visibleRowIndex) {
212
- var _this2 = this;
276
+ var _this3 = this;
213
277
 
214
278
  // save the first row index of batch, reassigning it only
215
279
  // if this visible row index less than lastUpdatedRow
216
280
  this.lastUpdatedRow = Math.min(this.lastUpdatedRow, visibleRowIndex);
217
281
  clearTimeout(this.timerId);
218
282
  this.timerId = window.setTimeout(function () {
219
- return _this2.resetGrid();
283
+ return _this3.resetGrid();
220
284
  }, 0);
221
285
  }
222
286
  }, {
@@ -254,24 +318,29 @@ export var RowHeightUtils = /*#__PURE__*/function () {
254
318
  }
255
319
  }]);
256
320
 
257
- return RowHeightUtils;
258
- }();
321
+ return RowHeightVirtualizationUtils;
322
+ }(RowHeightUtils);
259
323
  /**
260
324
  * Hook for instantiating RowHeightUtils, setting internal class vars,
261
325
  * and setting up various row-height-related side effects
262
326
  */
263
327
 
264
328
  export var useRowHeightUtils = function useRowHeightUtils(_ref2) {
265
- var gridRef = _ref2.gridRef,
266
- outerGridElementRef = _ref2.outerGridElementRef,
267
- gridItemsRenderedRef = _ref2.gridItemsRenderedRef,
329
+ var virtualization = _ref2.virtualization,
330
+ rowHeightsOptions = _ref2.rowHeightsOptions,
268
331
  gridStyles = _ref2.gridStyles,
269
- columns = _ref2.columns,
270
- rowHeightsOptions = _ref2.rowHeightsOptions;
332
+ columns = _ref2.columns;
271
333
  var forceRenderRef = useLatest(useForceRender());
272
334
 
273
335
  var _useState = useState(function () {
274
- return new RowHeightUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, forceRenderRef);
336
+ if (virtualization) {
337
+ var _gridRef = virtualization.gridRef,
338
+ _outerGridElementRef = virtualization.outerGridElementRef,
339
+ _gridItemsRenderedRef = virtualization.gridItemsRenderedRef;
340
+ return new RowHeightVirtualizationUtils(_gridRef, _outerGridElementRef, _gridItemsRenderedRef, forceRenderRef);
341
+ } else {
342
+ return new RowHeightUtils();
343
+ }
275
344
  }),
276
345
  _useState2 = _slicedToArray(_useState, 1),
277
346
  rowHeightUtils = _useState2[0]; // Forces a rerender whenever the row heights change, as this can cause the
@@ -119,7 +119,8 @@ export var EuiAutoRefreshButton = function EuiAutoRefreshButton(_ref2) {
119
119
  isOpen: isPopoverOpen,
120
120
  closePopover: function closePopover() {
121
121
  setIsPopoverOpen(false);
122
- }
122
+ },
123
+ popoverScreenReaderText: isPaused ? autoRefeshLabelOff : autoRefeshLabelOn
123
124
  }, ___EmotionJSX(EuiRefreshInterval, {
124
125
  onRefreshChange: onRefreshChange,
125
126
  isPaused: isPaused,
@@ -44,6 +44,7 @@ import { EuiRangeWrapper } from './range_wrapper';
44
44
  import { calculateThumbPosition } from './utils';
45
45
  import { euiRangeStyles } from './range.styles';
46
46
  import { euiDualRangeStyles } from './dual_range.styles';
47
+ import { EuiI18n } from '../../i18n';
47
48
  import { jsx as ___EmotionJSX } from "@emotion/react";
48
49
  export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
49
50
  _inherits(EuiDualRangeClass, _Component);
@@ -553,6 +554,11 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
553
554
  backgroundColor: euiRangeLevelColor(rightThumbColor, theme.euiTheme)
554
555
  }) : rightThumbPosition;
555
556
 
557
+ var dualSliderScreenReaderInstructions = ___EmotionJSX(EuiI18n, {
558
+ token: "euiDualRange.sliderScreenReaderInstructions",
559
+ 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."
560
+ });
561
+
556
562
  var theRange = ___EmotionJSX(EuiRangeWrapper, {
557
563
  css: cssStyles,
558
564
  className: classes,
@@ -608,8 +614,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
608
614
  onFocus: _this2.onThumbFocus,
609
615
  onBlur: _this2.onThumbBlur,
610
616
  onKeyDown: _this2.handleDraggableKeyDown,
611
- "aria-describedby": _this2.props['aria-describedby'],
612
- "aria-label": _this2.props['aria-label']
617
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
618
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
613
619
  }), ___EmotionJSX(EuiRangeThumb, {
614
620
  min: min,
615
621
  max: Number(_this2.upperValue),
@@ -621,8 +627,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
621
627
  onFocus: _this2.onThumbFocus,
622
628
  onBlur: _this2.onThumbBlur,
623
629
  style: logicalStyles(leftThumbStyles),
624
- "aria-describedby": _this2.props['aria-describedby'],
625
- "aria-label": _this2.props['aria-label']
630
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
631
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
626
632
  }), ___EmotionJSX(EuiRangeThumb, {
627
633
  min: Number(_this2.lowerValue),
628
634
  max: max,
@@ -634,8 +640,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
634
640
  onFocus: _this2.onThumbFocus,
635
641
  onBlur: _this2.onThumbBlur,
636
642
  style: logicalStyles(rightThumbStyles),
637
- "aria-describedby": _this2.props['aria-describedby'],
638
- "aria-label": _this2.props['aria-label']
643
+ "aria-describedby": showInputOnly ? undefined : _this2.props['aria-describedby'],
644
+ "aria-label": showInputOnly ? undefined : _this2.props['aria-label']
639
645
  })), showRange && _this2.isValid && ___EmotionJSX(EuiRangeHighlight, {
640
646
  showTicks: showTicks,
641
647
  min: Number(min),
@@ -669,7 +675,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
669
675
  isOpen: this.state.isPopoverOpen,
670
676
  closePopover: this.closePopover,
671
677
  disableFocusTrap: true,
672
- onPanelResize: this.onResize
678
+ onPanelResize: this.onResize,
679
+ popoverScreenReaderText: dualSliderScreenReaderInstructions
673
680
  }, theRange) : undefined;
674
681
  return thePopover || theRange;
675
682
  }
@@ -35,6 +35,7 @@ import { EuiRangeTooltip } from './range_tooltip';
35
35
  import { EuiRangeTrack } from './range_track';
36
36
  import { EuiRangeWrapper } from './range_wrapper';
37
37
  import { euiRangeStyles } from './range.styles';
38
+ import { EuiI18n } from '../../i18n';
38
39
  import { jsx as ___EmotionJSX } from "@emotion/react";
39
40
  export var EuiRangeClass = /*#__PURE__*/function (_Component) {
40
41
  _inherits(EuiRangeClass, _Component);
@@ -180,6 +181,11 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
180
181
  var cssStyles = [styles.euiRange, showInput && styles.hasInput];
181
182
  var thumbColor = levels && getLevelColor(levels, Number(value));
182
183
 
184
+ var sliderScreenReaderInstructions = ___EmotionJSX(EuiI18n, {
185
+ token: "euiRange.sliderScreenReaderInstructions",
186
+ default: "You are in a custom range slider. Use the Up and Down arrow keys to change the value."
187
+ });
188
+
183
189
  var theRange = ___EmotionJSX(EuiRangeWrapper, {
184
190
  className: classes,
185
191
  css: cssStyles,
@@ -200,7 +206,7 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
200
206
  levels: levels,
201
207
  onChange: this.handleOnChange,
202
208
  value: value,
203
- "aria-hidden": showInput === true,
209
+ "aria-hidden": !!showInput,
204
210
  showRange: showRange
205
211
  }, function (trackWidth) {
206
212
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiRangeSlider, _extends({
@@ -221,7 +227,7 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
221
227
  } : undefined,
222
228
  onFocus: showInput === true ? undefined : onFocus,
223
229
  onBlur: showInputOnly ? _this2.onInputBlur : onBlur,
224
- "aria-hidden": showInput === true ? true : false,
230
+ "aria-hidden": !!showInput,
225
231
  thumbColor: thumbColor
226
232
  }, rest)), showRange && _this2.isValid && ___EmotionJSX(EuiRangeHighlight, {
227
233
  showTicks: showTicks,
@@ -255,7 +261,8 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
255
261
  fullWidth: fullWidth,
256
262
  isOpen: this.state.isPopoverOpen,
257
263
  closePopover: this.closePopover,
258
- disableFocusTrap: true
264
+ disableFocusTrap: true,
265
+ popoverScreenReaderText: sliderScreenReaderInstructions
259
266
  }, theRange) : undefined;
260
267
  return thePopover ? thePopover : theRange;
261
268
  }
@@ -7,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
- var _excluded = ["className", "options", "valueOfSelected", "onChange", "isOpen", "isInvalid", "hasDividers", "itemClassName", "itemLayoutAlign", "fullWidth", "popoverProps", "compressed"],
10
+ var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "hasDividers", "itemClassName", "itemLayoutAlign", "fullWidth", "popoverProps", "compressed"],
11
11
  _excluded2 = ["value", "dropdownDisplay", "inputDisplay"];
12
12
 
13
13
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
@@ -59,8 +59,6 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
59
59
 
60
60
  _defineProperty(_assertThisInitialized(_this), "describedById", htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId'));
61
61
 
62
- _defineProperty(_assertThisInitialized(_this), "labelledById", htmlIdGenerator('euiSuperSelect_')('_screenreaderLabelId'));
63
-
64
62
  _defineProperty(_assertThisInitialized(_this), "state", {
65
63
  isPopoverOpen: _this.props.isOpen || false
66
64
  });
@@ -226,6 +224,7 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
226
224
  className = _this$props.className,
227
225
  options = _this$props.options,
228
226
  valueOfSelected = _this$props.valueOfSelected,
227
+ placeholder = _this$props.placeholder,
229
228
  onChange = _this$props.onChange,
230
229
  isOpen = _this$props.isOpen,
231
230
  isInvalid = _this$props.isInvalid,
@@ -246,9 +245,9 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
246
245
  }, itemClassName);
247
246
 
248
247
  var button = ___EmotionJSX(EuiSuperSelectControl, _extends({
249
- screenReaderId: this.labelledById,
250
248
  options: options,
251
249
  value: valueOfSelected,
250
+ placeholder: placeholder,
252
251
  onClick: this.state.isPopoverOpen ? this.closePopover : this.openPopover,
253
252
  onKeyDown: this.onSelectKeyDown,
254
253
  className: buttonClasses,
@@ -293,14 +292,19 @@ export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
293
292
  }, ___EmotionJSX(EuiI18n, {
294
293
  token: "euiSuperSelect.screenReaderAnnouncement",
295
294
  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."
296
- }))), ___EmotionJSX("div", {
297
- "aria-labelledby": this.labelledById,
298
- "aria-describedby": this.describedById,
299
- className: "euiSuperSelect__listbox",
300
- role: "listbox",
301
- "aria-activedescendant": valueOfSelected,
302
- tabIndex: 0
303
- }, items));
295
+ }))), ___EmotionJSX(EuiI18n, {
296
+ token: "euiSuperSelect.ariaLabel",
297
+ default: "Select listbox"
298
+ }, function (ariaLabel) {
299
+ return ___EmotionJSX("div", {
300
+ "aria-label": ariaLabel,
301
+ "aria-describedby": _this2.describedById,
302
+ className: "euiSuperSelect__listbox",
303
+ role: "listbox",
304
+ "aria-activedescendant": valueOfSelected,
305
+ tabIndex: 0
306
+ }, items);
307
+ }));
304
308
  }
305
309
  }]);
306
310
 
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["className", "options", "id", "name", "fullWidth", "isLoading", "isInvalid", "readOnly", "defaultValue", "compressed", "value", "prepend", "append", "screenReaderId", "disabled"];
3
+ var _excluded = ["className", "options", "id", "name", "fullWidth", "isLoading", "isInvalid", "readOnly", "defaultValue", "compressed", "value", "placeholder", "prepend", "append", "disabled"];
4
4
 
5
5
  /*
6
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -11,9 +11,7 @@ var _excluded = ["className", "options", "id", "name", "fullWidth", "isLoading",
11
11
  */
12
12
  import React, { Fragment } from 'react';
13
13
  import classNames from 'classnames';
14
- import { EuiScreenReaderOnly } from '../../accessibility';
15
14
  import { EuiFormControlLayout } from '../form_control_layout';
16
- import { EuiI18n } from '../../i18n';
17
15
  import { getFormControlClassNameForIconCount } from '../form_control_layout/_num_icons';
18
16
  import { useFormContext } from '../eui_form_context';
19
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -37,9 +35,9 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
37
35
  _props$compressed = props.compressed,
38
36
  compressed = _props$compressed === void 0 ? false : _props$compressed,
39
37
  value = props.value,
38
+ placeholder = props.placeholder,
40
39
  prepend = props.prepend,
41
40
  append = props.append,
42
- screenReaderId = props.screenReaderId,
43
41
  disabled = props.disabled,
44
42
  rest = _objectWithoutProperties(props, _excluded);
45
43
 
@@ -72,6 +70,7 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
72
70
  selectedValue = selectedOption ? selectedOption.inputDisplay : selectedValue;
73
71
  }
74
72
 
73
+ var showPlaceholder = !!placeholder && !selectedValue;
75
74
  return ___EmotionJSX(Fragment, null, ___EmotionJSX("input", {
76
75
  type: "hidden",
77
76
  id: id,
@@ -89,20 +88,14 @@ export var EuiSuperSelectControl = function EuiSuperSelectControl(props) {
89
88
  compressed: compressed,
90
89
  prepend: prepend,
91
90
  append: append
92
- }, ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("span", {
93
- id: screenReaderId
94
- }, ___EmotionJSX(EuiI18n, {
95
- token: "euiSuperSelectControl.selectAnOption",
96
- default: "Select an option: {selectedValue}, is selected",
97
- values: {
98
- selectedValue: selectedValue
99
- }
100
- }))), ___EmotionJSX("button", _extends({
91
+ }, ___EmotionJSX("button", _extends({
101
92
  type: "button",
102
93
  className: classes,
103
94
  "aria-haspopup": "listbox",
104
95
  disabled: disabled || readOnly // @ts-ignore Using as a selector only for mixin use
105
96
  ,
106
97
  readOnly: readOnly
107
- }, rest), selectedValue)));
98
+ }, rest), showPlaceholder ? ___EmotionJSX("span", {
99
+ className: "euiSuperSelectControl__placeholder"
100
+ }, placeholder) : selectedValue)));
108
101
  };
@@ -1,5 +1,5 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
5
  import _createClass from "@babel/runtime/helpers/createClass";
@@ -8,7 +8,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
8
8
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
9
9
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
10
10
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
11
- var _excluded = ["children", "className", "options", "onChange", "onActiveOptionChange", "searchable", "searchProps", "singleSelection", "isLoading", "listProps", "renderOption", "height", "allowExclusions", "aria-label", "aria-describedby", "loadingMessage", "noMatchesMessage", "emptyMessage", "errorMessage", "isPreFiltered"],
11
+ 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"],
12
12
  _excluded2 = ["aria-label", "aria-describedby", "onChange", "defaultValue", "inputRef"],
13
13
  _excluded3 = ["aria-label", "aria-describedby", "isVirtualized", "rowHeight"];
14
14
 
@@ -67,6 +67,16 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
67
67
 
68
68
  _defineProperty(_assertThisInitialized(_this), "listId", void 0);
69
69
 
70
+ _defineProperty(_assertThisInitialized(_this), "isFocusOnSearchOrListBox", function (target) {
71
+ var _this$optionsListRef$, _this$optionsListRef$2;
72
+
73
+ var searchHasFocus = _this.props.searchable && target === _this.inputRef;
74
+ 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;
75
+ var listBoxContainsFocus = target instanceof Node && (listBox === null || listBox === void 0 ? void 0 : listBox.contains(target));
76
+ var listBoxHasFocus = target === listBox || listBoxContainsFocus;
77
+ return searchHasFocus || listBoxHasFocus;
78
+ });
79
+
70
80
  _defineProperty(_assertThisInitialized(_this), "onMouseDown", function () {
71
81
  // Bypass onFocus when a click event originates from this.containerRef.
72
82
  // Prevents onFocus from scrolling away from a clicked option and negating the selection event.
@@ -74,7 +84,7 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
74
84
  _this.preventOnFocus = true;
75
85
  });
76
86
 
77
- _defineProperty(_assertThisInitialized(_this), "onFocus", function () {
87
+ _defineProperty(_assertThisInitialized(_this), "onFocus", function (event) {
78
88
  if (_this.preventOnFocus) {
79
89
  _this.preventOnFocus = false;
80
90
  return;
@@ -84,6 +94,10 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
84
94
  return;
85
95
  }
86
96
 
97
+ if (event && !_this.isFocusOnSearchOrListBox(event.target)) {
98
+ return;
99
+ }
100
+
87
101
  var firstSelected = _this.state.visibleOptions.findIndex(function (option) {
88
102
  return option.checked && !option.disabled && !option.isGroupLabel;
89
103
  });
@@ -104,7 +118,19 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
104
118
  });
105
119
 
106
120
  _defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
107
- var optionsList = _this.optionsListRef.current;
121
+ var optionsList = _this.optionsListRef.current; // Check if the user is interacting with something other than the
122
+ // searchbox or selection list. If so, the user may be attempting to
123
+ // interact with the search clear button or a totally custom button,
124
+ // and listbox keyboard navigation/selection should not be triggered.
125
+
126
+ if (!_this.isFocusOnSearchOrListBox(event.target)) {
127
+ _this.setState({
128
+ activeOptionIndex: undefined,
129
+ isFocused: false
130
+ });
131
+
132
+ return;
133
+ }
108
134
 
109
135
  switch (event.key) {
110
136
  case keys.ARROW_UP:
@@ -129,20 +155,10 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
129
155
  case keys.ENTER:
130
156
  case keys.SPACE:
131
157
  if (_this.props.searchable) {
132
- var _this$optionsListRef$, _this$optionsListRef$2;
133
-
134
158
  // For searchable instances, SPACE is reserved as a character for filtering
135
159
  // via the input box, and as such only ENTER will toggle selection.
136
160
  if (event.target === _this.inputRef && event.key === keys.SPACE) {
137
161
  return;
138
- } // Check if the user is interacting with something other than the
139
- // searchbox or selection list. If not, the user is attempting to
140
- // interact with an internal button such as the clear button,
141
- // and the event should not be altered.
142
-
143
-
144
- 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))) {
145
- return;
146
162
  }
147
163
  }
148
164
 
@@ -233,10 +249,8 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
233
249
  });
234
250
 
235
251
  _defineProperty(_assertThisInitialized(_this), "onContainerBlur", function (e) {
236
- var _e$relatedTarget, _e$relatedTarget$firs;
237
-
238
252
  // Ignore blur events when moving from search to option to avoid activeOptionIndex conflicts
239
- 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) {
253
+ if (_this.isFocusOnSearchOrListBox(e.relatedTarget)) {
240
254
  return;
241
255
  }
242
256
 
@@ -343,6 +357,7 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
343
357
  noMatchesMessage = _this$props3.noMatchesMessage,
344
358
  emptyMessage = _this$props3.emptyMessage,
345
359
  errorMessage = _this$props3.errorMessage,
360
+ selectableScreenReaderText = _this$props3.selectableScreenReaderText,
346
361
  isPreFiltered = _this$props3.isPreFiltered,
347
362
  rest = _objectWithoutProperties(_this$props3, _excluded);
348
363
 
@@ -478,10 +493,15 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
478
493
  var searchAccessibleName = getAccessibleName(searchProps, this.messageContentId);
479
494
  var searchHasAccessibleName = Boolean(Object.keys(searchAccessibleName).length);
480
495
  var search = searchable ? ___EmotionJSX(EuiI18n, {
481
- token: "euiSelectable.placeholderName",
482
- default: "Filter options"
483
- }, function (placeholderName) {
484
- return ___EmotionJSX(EuiSelectableSearch, _extends({
496
+ tokens: ['euiSelectable.screenReaderInstructions', 'euiSelectable.placeholderName'],
497
+ defaults: ['Use the Up and Down arrow keys to move focus over options. Press Enter to select. Press Escape to collapse options.', 'Filter options']
498
+ }, function (_ref4) {
499
+ var _ref5 = _slicedToArray(_ref4, 2),
500
+ screenReaderInstructions = _ref5[0],
501
+ placeholderName = _ref5[1];
502
+
503
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiSelectableSearch, _extends({
504
+ "aria-describedby": listAriaDescribedbyId,
485
505
  key: "listSearch",
486
506
  options: options,
487
507
  value: searchValue,
@@ -500,7 +520,9 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
500
520
  }
501
521
  }, searchHasAccessibleName ? searchAccessibleName : {
502
522
  'aria-label': placeholderName
503
- }, cleanedSearchProps));
523
+ }, cleanedSearchProps)), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
524
+ id: listAriaDescribedbyId
525
+ }, selectableScreenReaderText, " ", screenReaderInstructions)));
504
526
  }) : undefined;
505
527
  var resultsLength = visibleOptions.filter(function (option) {
506
528
  return !option.disabled;
@@ -508,8 +530,8 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
508
530
 
509
531
  var listScreenReaderStatus = searchable && ___EmotionJSX(EuiI18n, {
510
532
  token: "euiSelectable.searchResults",
511
- default: function _default(_ref4) {
512
- var resultsLength = _ref4.resultsLength;
533
+ default: function _default(_ref6) {
534
+ var resultsLength = _ref6.resultsLength;
513
535
  return "".concat(resultsLength, " result").concat(resultsLength === 1 ? '' : 's', " available");
514
536
  },
515
537
  values: {
@@ -522,18 +544,12 @@ export var EuiSelectable = /*#__PURE__*/function (_Component) {
522
544
  var listHasAccessibleName = Boolean(Object.keys(listAccessibleName).length);
523
545
 
524
546
  var list = ___EmotionJSX(EuiI18n, {
525
- tokens: ['euiSelectable.screenReaderInstructions', 'euiSelectable.placeholderName'],
526
- defaults: ['Use up and down arrows to move focus over options. Enter to select. Escape to collapse options.', 'Filter options']
527
- }, function (_ref5) {
528
- var _ref6 = _slicedToArray(_ref5, 2),
529
- placeholderName = _ref6[0],
530
- screenReaderInstructions = _ref6[1];
531
-
547
+ token: "euiSelectable.placeholderName",
548
+ default: "Filter options"
549
+ }, function (placeholderName) {
532
550
  return ___EmotionJSX(React.Fragment, null, searchable && ___EmotionJSX(EuiScreenReaderLive, {
533
551
  isActive: messageContent != null || activeOptionIndex != null
534
- }, messageContent || listScreenReaderStatus), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
535
- id: listAriaDescribedbyId
536
- }, screenReaderInstructions)), messageContent ? ___EmotionJSX(EuiSelectableMessage, {
552
+ }, messageContent || listScreenReaderStatus), messageContent ? ___EmotionJSX(EuiSelectableMessage, {
537
553
  "data-test-subj": "euiSelectableMessage",
538
554
  id: _this2.messageContentId,
539
555
  bordered: listProps && listProps.bordered