@elastic/eui 87.0.0 → 87.1.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 (126) hide show
  1. package/es/components/accordion/accordion.js +82 -35
  2. package/es/components/auto_sizer/index.js +1 -1
  3. package/es/components/breadcrumbs/breadcrumb.js +2 -3
  4. package/es/components/breadcrumbs/breadcrumbs.js +2 -3
  5. package/es/components/code/code_block_virtualized.js +25 -17
  6. package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +14 -1
  7. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +8 -7
  8. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +6 -6
  9. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +7 -7
  10. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +6 -6
  11. package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +9 -9
  12. package/es/components/color_picker/color_palette_picker/color_palette_picker.js +1 -1
  13. package/es/components/control_bar/control_bar.js +2 -3
  14. package/es/components/date_picker/date_picker_range.js +5 -2
  15. package/es/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  16. package/es/components/date_picker/super_date_picker/super_update_button.js +1 -1
  17. package/es/components/empty_prompt/empty_prompt.js +0 -1
  18. package/es/components/flyout/flyout.js +9 -7
  19. package/es/components/flyout/flyout_body.js +15 -3
  20. package/es/components/form/range/dual_range.js +33 -6
  21. package/es/components/form/range/range.js +31 -6
  22. package/es/components/form/super_select/super_select.js +1 -1
  23. package/es/components/header/header_breadcrumbs/header_breadcrumbs.js +2 -3
  24. package/es/components/header/header_links/header_links.js +2 -3
  25. package/es/components/page/page_header/page_header_content.js +2 -3
  26. package/es/components/page/page_sidebar/page_sidebar.js +2 -2
  27. package/es/components/page_template/page_template.js +12 -4
  28. package/es/components/popover/input_popover.js +24 -9
  29. package/es/components/popover/popover.js +4 -6
  30. package/es/components/selectable/selectable_list/selectable_list.js +97 -79
  31. package/es/components/tool_tip/icon_tip.js +1 -1
  32. package/es/components/tool_tip/tool_tip.js +4 -14
  33. package/es/components/tool_tip/tool_tip_anchor.js +5 -14
  34. package/es/components/tour/tour_step.js +2 -3
  35. package/eui.d.ts +85 -37
  36. package/i18ntokens.json +54 -36
  37. package/lib/components/accordion/accordion.js +82 -35
  38. package/lib/components/auto_sizer/index.js +11 -7
  39. package/lib/components/breadcrumbs/breadcrumb.js +2 -3
  40. package/lib/components/code/code_block_virtualized.js +25 -17
  41. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +14 -1
  42. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +8 -7
  43. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +6 -6
  44. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +7 -7
  45. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +6 -6
  46. package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +9 -9
  47. package/lib/components/color_picker/color_palette_picker/color_palette_picker.js +1 -1
  48. package/lib/components/date_picker/date_picker_range.js +5 -2
  49. package/lib/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  50. package/lib/components/date_picker/super_date_picker/super_update_button.js +1 -1
  51. package/lib/components/empty_prompt/empty_prompt.js +0 -1
  52. package/lib/components/flyout/flyout.js +9 -7
  53. package/lib/components/flyout/flyout_body.js +15 -3
  54. package/lib/components/form/range/dual_range.js +33 -6
  55. package/lib/components/form/range/range.js +14 -6
  56. package/lib/components/form/super_select/super_select.js +1 -1
  57. package/lib/components/page/page_sidebar/page_sidebar.js +1 -1
  58. package/lib/components/page_template/page_template.js +12 -4
  59. package/lib/components/popover/input_popover.js +23 -8
  60. package/lib/components/popover/popover.js +4 -6
  61. package/lib/components/selectable/selectable_list/selectable_list.js +97 -79
  62. package/lib/components/tool_tip/icon_tip.js +1 -1
  63. package/lib/components/tool_tip/tool_tip.js +4 -14
  64. package/lib/components/tool_tip/tool_tip_anchor.js +5 -13
  65. package/optimize/es/components/accordion/accordion.js +82 -35
  66. package/optimize/es/components/auto_sizer/index.js +1 -1
  67. package/optimize/es/components/code/code_block_virtualized.js +25 -17
  68. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +5 -1
  69. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +2 -1
  70. package/optimize/es/components/date_picker/date_picker_range.js +5 -2
  71. package/optimize/es/components/flyout/flyout.js +9 -7
  72. package/optimize/es/components/flyout/flyout_body.js +4 -2
  73. package/optimize/es/components/form/range/dual_range.js +7 -4
  74. package/optimize/es/components/form/range/range.js +5 -4
  75. package/optimize/es/components/page/page_sidebar/page_sidebar.js +2 -2
  76. package/optimize/es/components/page_template/page_template.js +12 -4
  77. package/optimize/es/components/popover/input_popover.js +13 -8
  78. package/optimize/es/components/popover/popover.js +2 -3
  79. package/optimize/es/components/selectable/selectable_list/selectable_list.js +97 -79
  80. package/optimize/es/components/tool_tip/tool_tip.js +3 -13
  81. package/optimize/es/components/tool_tip/tool_tip_anchor.js +4 -8
  82. package/optimize/lib/components/accordion/accordion.js +82 -35
  83. package/optimize/lib/components/auto_sizer/index.js +11 -7
  84. package/optimize/lib/components/code/code_block_virtualized.js +25 -17
  85. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +5 -1
  86. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +2 -1
  87. package/optimize/lib/components/date_picker/date_picker_range.js +5 -2
  88. package/optimize/lib/components/flyout/flyout.js +9 -7
  89. package/optimize/lib/components/flyout/flyout_body.js +4 -2
  90. package/optimize/lib/components/form/range/dual_range.js +7 -4
  91. package/optimize/lib/components/form/range/range.js +5 -4
  92. package/optimize/lib/components/page/page_sidebar/page_sidebar.js +1 -1
  93. package/optimize/lib/components/page_template/page_template.js +12 -4
  94. package/optimize/lib/components/popover/input_popover.js +12 -7
  95. package/optimize/lib/components/popover/popover.js +2 -3
  96. package/optimize/lib/components/selectable/selectable_list/selectable_list.js +97 -79
  97. package/optimize/lib/components/tool_tip/tool_tip.js +3 -13
  98. package/optimize/lib/components/tool_tip/tool_tip_anchor.js +4 -8
  99. package/package.json +7 -9
  100. package/test-env/components/accordion/accordion.js +82 -35
  101. package/test-env/components/auto_sizer/index.js +11 -7
  102. package/test-env/components/breadcrumbs/breadcrumb.js +2 -3
  103. package/test-env/components/code/code_block_virtualized.js +25 -17
  104. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +14 -1
  105. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +8 -7
  106. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +6 -6
  107. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +7 -7
  108. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +6 -6
  109. package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +9 -9
  110. package/test-env/components/color_picker/color_palette_picker/color_palette_picker.js +1 -1
  111. package/test-env/components/date_picker/date_picker_range.js +5 -2
  112. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  113. package/test-env/components/date_picker/super_date_picker/super_update_button.js +1 -1
  114. package/test-env/components/empty_prompt/empty_prompt.js +0 -1
  115. package/test-env/components/flyout/flyout_body.js +15 -3
  116. package/test-env/components/form/range/dual_range.js +33 -6
  117. package/test-env/components/form/range/range.js +14 -6
  118. package/test-env/components/form/super_select/super_select.js +1 -1
  119. package/test-env/components/page/page_sidebar/page_sidebar.js +1 -1
  120. package/test-env/components/page_template/page_template.js +12 -4
  121. package/test-env/components/popover/input_popover.js +23 -8
  122. package/test-env/components/popover/popover.js +4 -6
  123. package/test-env/components/selectable/selectable_list/selectable_list.js +97 -79
  124. package/test-env/components/tool_tip/icon_tip.js +1 -1
  125. package/test-env/components/tool_tip/tool_tip.js +4 -14
  126. package/test-env/components/tool_tip/tool_tip_anchor.js +5 -11
@@ -29,6 +29,14 @@ export var TemplateContext = /*#__PURE__*/createContext({
29
29
  emptyPrompt: {},
30
30
  bottomBar: {}
31
31
  });
32
+ var calculateOffset = function calculateOffset(base) {
33
+ var _document$body$datase;
34
+ if (typeof document === 'undefined') return 0; // SSR catch
35
+
36
+ var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
37
+ return base * 3 * euiHeaderFixedCounter;
38
+ };
39
+
32
40
  /**
33
41
  * Consumed via `EuiPageTemplate`,
34
42
  * it controls and propogates most of the shared props per direct child
@@ -55,7 +63,9 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
55
63
  rest = _objectWithoutProperties(_ref, _excluded);
56
64
  var _useEuiTheme = useEuiTheme(),
57
65
  euiTheme = _useEuiTheme.euiTheme;
58
- var _useState = useState(_offset),
66
+ var _useState = useState(function () {
67
+ return _offset !== null && _offset !== void 0 ? _offset : calculateOffset(euiTheme.base);
68
+ }),
59
69
  _useState2 = _slicedToArray(_useState, 2),
60
70
  offset = _useState2[0],
61
71
  setOffset = _useState2[1];
@@ -68,9 +78,7 @@ export var _EuiPageTemplate = function _EuiPageTemplate(_ref) {
68
78
  });
69
79
  useEffect(function () {
70
80
  if (_offset === undefined) {
71
- var _document$body$datase;
72
- var euiHeaderFixedCounter = Number((_document$body$datase = document.body.dataset.fixedHeaders) !== null && _document$body$datase !== void 0 ? _document$body$datase : 0);
73
- setOffset(euiTheme.base * 3 * euiHeaderFixedCounter);
81
+ setOffset(calculateOffset(euiTheme.base));
74
82
  }
75
83
  }, [_offset, euiTheme.base]);
76
84
 
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "onPanelResize", "inputRef", "panelRef"];
4
+ var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
5
5
  /*
6
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
7
  * or more contributor license agreements. Licensed under the Elastic License
@@ -10,7 +10,7 @@ var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps",
10
10
  * Side Public License, v 1.
11
11
  */
12
12
 
13
- import React, { useState, useEffect, useCallback } from 'react';
13
+ import React, { useState, useEffect, useCallback, useRef } from 'react';
14
14
  import classnames from 'classnames';
15
15
  import { tabbable } from 'tabbable';
16
16
  import { EuiFocusTrap } from '../focus_trap';
@@ -30,6 +30,8 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
30
30
  input = _ref.input,
31
31
  _ref$fullWidth = _ref.fullWidth,
32
32
  fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
33
+ _ref$panelMinWidth = _ref.panelMinWidth,
34
+ panelMinWidth = _ref$panelMinWidth === void 0 ? 0 : _ref$panelMinWidth,
33
35
  onPanelResize = _ref.onPanelResize,
34
36
  _inputRef = _ref.inputRef,
35
37
  _panelRef = _ref.panelRef,
@@ -47,22 +49,24 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
47
49
  _useState6 = _slicedToArray(_useState5, 2),
48
50
  panelEl = _useState6[0],
49
51
  setPanelEl = _useState6[1];
52
+ var popoverClassRef = useRef(null);
50
53
  var inputRef = useCombinedRefs([setInputEl, _inputRef]);
51
54
  var panelRef = useCombinedRefs([setPanelEl, _panelRef]);
52
55
  var setPanelWidth = useCallback(function (width) {
53
56
  if (panelEl && (!!inputElWidth || !!width)) {
54
57
  var newWidth = !!width ? width : inputElWidth;
55
- panelEl.style.width = "".concat(newWidth, "px");
56
- if (onPanelResize) {
57
- onPanelResize(newWidth);
58
- }
58
+ var widthToSet = newWidth && newWidth > panelMinWidth ? newWidth : panelMinWidth;
59
+ panelEl.style.width = "".concat(widthToSet, "px");
60
+ onPanelResize === null || onPanelResize === void 0 ? void 0 : onPanelResize(widthToSet);
59
61
  }
60
- }, [panelEl, inputElWidth, onPanelResize]);
62
+ }, [panelEl, inputElWidth, onPanelResize, panelMinWidth]);
61
63
  var onResize = useCallback(function () {
62
64
  if (inputEl) {
65
+ var _popoverClassRef$curr;
63
66
  var _width = inputEl.getBoundingClientRect().width;
64
67
  setInputElWidth(_width);
65
68
  setPanelWidth(_width);
69
+ (_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
66
70
  }
67
71
  }, [inputEl, setPanelWidth]);
68
72
  useEffect(function () {
@@ -97,7 +101,8 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
97
101
  }),
98
102
  buttonRef: inputRef,
99
103
  panelRef: panelRef,
100
- className: classes
104
+ className: classes,
105
+ ref: popoverClassRef
101
106
  }, props), ___EmotionJSX(EuiFocusTrap, _extends({
102
107
  clickOutsideDisables: true,
103
108
  disabled: disableFocusTrap
@@ -206,8 +206,7 @@ export var EuiPopover = /*#__PURE__*/function (_Component) {
206
206
  top = _findPopoverPosition.top,
207
207
  left = _findPopoverPosition.left,
208
208
  foundPosition = _findPopoverPosition.position,
209
- arrow = _findPopoverPosition.arrow,
210
- anchorBoundingBox = _findPopoverPosition.anchorBoundingBox;
209
+ arrow = _findPopoverPosition.arrow;
211
210
 
212
211
  // the popover's z-index must inherit from the button
213
212
  // this keeps a button's popover under a flyout that would cover the button
@@ -216,7 +215,7 @@ export var EuiPopover = /*#__PURE__*/function (_Component) {
216
215
  var zIndex = zIndexProp == null ? getElementZIndex(_this.button, _this.panel) + 2000 : zIndexProp;
217
216
  var popoverStyles = _objectSpread(_objectSpread({}, _this.props.panelStyle), {}, {
218
217
  top: top,
219
- left: _this.props.attachToAnchor && anchorBoundingBox ? anchorBoundingBox.left : left,
218
+ left: left,
220
219
  zIndex: zIndex
221
220
  });
222
221
  var willRenderArrow = !_this.props.attachToAnchor && _this.props.hasArrow;
@@ -164,17 +164,67 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
164
164
  search: searchValue
165
165
  }, label));
166
166
  }, areEqual));
167
+ _defineProperty(_assertThisInitialized(_this), "renderVirtualizedList", function (heightIsFull, optionArray) {
168
+ if (!_this.props.isVirtualized) return null;
169
+ var _this$props3 = _this.props,
170
+ windowProps = _this$props3.windowProps,
171
+ forcedHeight = _this$props3.height,
172
+ rowHeight = _this$props3.rowHeight;
173
+ var virtualizationProps = _objectSpread({
174
+ className: 'euiSelectableList__list',
175
+ ref: _this.setListRef,
176
+ outerRef: _this.removeScrollableTabStop,
177
+ innerRef: _this.setListBoxRef,
178
+ innerElementType: 'ul',
179
+ itemCount: optionArray.length,
180
+ itemData: optionArray,
181
+ itemSize: rowHeight,
182
+ 'data-skip-axe': 'scrollable-region-focusable'
183
+ }, windowProps);
184
+
185
+ // Calculated height is only used if height is not full
186
+ var calculatedHeight = !heightIsFull ? forcedHeight || 0 : 0;
187
+
188
+ // If calculatedHeight is still falsy, then calculate it
189
+ if (!heightIsFull && !calculatedHeight) {
190
+ var maxVisibleOptions = 7;
191
+ var numVisibleOptions = optionArray.length;
192
+ var numVisibleMoreThanMax = optionArray.length > maxVisibleOptions;
193
+ if (numVisibleMoreThanMax) {
194
+ // Show only half of the last one to indicate there's more to scroll to
195
+ calculatedHeight = (maxVisibleOptions - 0.5) * rowHeight;
196
+ } else {
197
+ calculatedHeight = numVisibleOptions * rowHeight;
198
+ }
199
+ }
200
+ return heightIsFull ? ___EmotionJSX(EuiAutoSizer, null, function (_ref2) {
201
+ var width = _ref2.width,
202
+ height = _ref2.height;
203
+ return ___EmotionJSX(FixedSizeList, _extends({
204
+ width: width,
205
+ height: height
206
+ }, virtualizationProps), _this.ListRow);
207
+ }) : ___EmotionJSX(EuiAutoSizer, {
208
+ disableHeight: true
209
+ }, function (_ref3) {
210
+ var width = _ref3.width;
211
+ return ___EmotionJSX(FixedSizeList, _extends({
212
+ width: width,
213
+ height: calculatedHeight
214
+ }, virtualizationProps), _this.ListRow);
215
+ });
216
+ });
167
217
  _defineProperty(_assertThisInitialized(_this), "onAddOrRemoveOption", function (option, event) {
168
218
  if (option.disabled) {
169
219
  return;
170
220
  }
171
- var _this$props3 = _this.props,
172
- allowExclusions = _this$props3.allowExclusions,
173
- options = _this$props3.options,
174
- _this$props3$visibleO = _this$props3.visibleOptions,
175
- visibleOptions = _this$props3$visibleO === void 0 ? options : _this$props3$visibleO;
176
- _this.props.setActiveOptionIndex(visibleOptions.findIndex(function (_ref2) {
177
- var label = _ref2.label;
221
+ var _this$props4 = _this.props,
222
+ allowExclusions = _this$props4.allowExclusions,
223
+ options = _this$props4.options,
224
+ _this$props4$visibleO = _this$props4.visibleOptions,
225
+ visibleOptions = _this$props4$visibleO === void 0 ? options : _this$props4$visibleO;
226
+ _this.props.setActiveOptionIndex(visibleOptions.findIndex(function (_ref4) {
227
+ var label = _ref4.label;
178
228
  return label === option.label;
179
229
  }), function () {
180
230
  if (option.checked === 'on' && allowExclusions) {
@@ -187,10 +237,10 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
187
237
  });
188
238
  });
189
239
  _defineProperty(_assertThisInitialized(_this), "onAddOption", function (addedOption, event) {
190
- var _this$props4 = _this.props,
191
- onOptionClick = _this$props4.onOptionClick,
192
- options = _this$props4.options,
193
- singleSelection = _this$props4.singleSelection;
240
+ var _this$props5 = _this.props,
241
+ onOptionClick = _this$props5.onOptionClick,
242
+ options = _this$props5.options,
243
+ singleSelection = _this$props5.singleSelection;
194
244
  var changedOption = _objectSpread({}, addedOption);
195
245
  var updatedOptions = options.map(function (option) {
196
246
  // if singleSelection is enabled, uncheck any selected option(s)
@@ -209,10 +259,10 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
209
259
  onOptionClick(updatedOptions, event, changedOption);
210
260
  });
211
261
  _defineProperty(_assertThisInitialized(_this), "onRemoveOption", function (removedOption, event) {
212
- var _this$props5 = _this.props,
213
- onOptionClick = _this$props5.onOptionClick,
214
- singleSelection = _this$props5.singleSelection,
215
- options = _this$props5.options;
262
+ var _this$props6 = _this.props,
263
+ onOptionClick = _this$props6.onOptionClick,
264
+ singleSelection = _this$props6.singleSelection,
265
+ options = _this$props6.options;
216
266
  var changedOption = _objectSpread({}, removedOption);
217
267
  var updatedOptions = options.map(function (option) {
218
268
  var updatedOption = _objectSpread({}, option);
@@ -225,9 +275,9 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
225
275
  onOptionClick(updatedOptions, event, changedOption);
226
276
  });
227
277
  _defineProperty(_assertThisInitialized(_this), "onExcludeOption", function (excludedOption, event) {
228
- var _this$props6 = _this.props,
229
- onOptionClick = _this$props6.onOptionClick,
230
- options = _this$props6.options;
278
+ var _this$props7 = _this.props,
279
+ onOptionClick = _this$props7.onOptionClick,
280
+ options = _this$props7.options;
231
281
  var changedOption = _objectSpread({}, excludedOption);
232
282
  var updatedOptions = options.map(function (option) {
233
283
  var updatedOption = _objectSpread({}, option);
@@ -256,76 +306,44 @@ export var EuiSelectableList = /*#__PURE__*/function (_Component) {
256
306
  key: "render",
257
307
  value: function render() {
258
308
  var _this2 = this;
259
- var _this$props7 = this.props,
260
- className = _this$props7.className,
261
- options = _this$props7.options,
262
- searchValue = _this$props7.searchValue,
263
- onOptionClick = _this$props7.onOptionClick,
264
- renderOption = _this$props7.renderOption,
265
- forcedHeight = _this$props7.height,
266
- windowProps = _this$props7.windowProps,
267
- rowHeight = _this$props7.rowHeight,
268
- activeOptionIndex = _this$props7.activeOptionIndex,
269
- makeOptionId = _this$props7.makeOptionId,
270
- showIcons = _this$props7.showIcons,
271
- singleSelection = _this$props7.singleSelection,
272
- visibleOptions = _this$props7.visibleOptions,
273
- allowExclusions = _this$props7.allowExclusions,
274
- bordered = _this$props7.bordered,
275
- paddingSize = _this$props7.paddingSize,
276
- searchable = _this$props7.searchable,
277
- onFocusBadge = _this$props7.onFocusBadge,
278
- listId = _this$props7.listId,
279
- setActiveOptionIndex = _this$props7.setActiveOptionIndex,
280
- ariaLabel = _this$props7['aria-label'],
281
- ariaLabelledby = _this$props7['aria-labelledby'],
282
- ariaDescribedby = _this$props7['aria-describedby'],
283
- role = _this$props7.role,
284
- isVirtualized = _this$props7.isVirtualized,
285
- textWrap = _this$props7.textWrap,
286
- rest = _objectWithoutProperties(_this$props7, _excluded3);
309
+ var _this$props8 = this.props,
310
+ className = _this$props8.className,
311
+ options = _this$props8.options,
312
+ searchValue = _this$props8.searchValue,
313
+ onOptionClick = _this$props8.onOptionClick,
314
+ renderOption = _this$props8.renderOption,
315
+ forcedHeight = _this$props8.height,
316
+ windowProps = _this$props8.windowProps,
317
+ rowHeight = _this$props8.rowHeight,
318
+ activeOptionIndex = _this$props8.activeOptionIndex,
319
+ makeOptionId = _this$props8.makeOptionId,
320
+ showIcons = _this$props8.showIcons,
321
+ singleSelection = _this$props8.singleSelection,
322
+ visibleOptions = _this$props8.visibleOptions,
323
+ allowExclusions = _this$props8.allowExclusions,
324
+ bordered = _this$props8.bordered,
325
+ paddingSize = _this$props8.paddingSize,
326
+ searchable = _this$props8.searchable,
327
+ onFocusBadge = _this$props8.onFocusBadge,
328
+ listId = _this$props8.listId,
329
+ setActiveOptionIndex = _this$props8.setActiveOptionIndex,
330
+ ariaLabel = _this$props8['aria-label'],
331
+ ariaLabelledby = _this$props8['aria-labelledby'],
332
+ ariaDescribedby = _this$props8['aria-describedby'],
333
+ role = _this$props8.role,
334
+ isVirtualized = _this$props8.isVirtualized,
335
+ textWrap = _this$props8.textWrap,
336
+ rest = _objectWithoutProperties(_this$props8, _excluded3);
287
337
  var optionArray = visibleOptions || options;
288
338
  this.calculateAriaSetAttrs(optionArray);
289
339
  var heightIsFull = forcedHeight === 'full';
290
- var calculatedHeight = heightIsFull ? false : forcedHeight;
291
-
292
- // If calculatedHeight is still undefined, then calculate it
293
- if (calculatedHeight === undefined) {
294
- var maxVisibleOptions = 7;
295
- var numVisibleOptions = optionArray.length;
296
- var numVisibleMoreThanMax = optionArray.length > maxVisibleOptions;
297
- if (numVisibleMoreThanMax) {
298
- // Show only half of the last one to indicate there's more to scroll to
299
- calculatedHeight = (maxVisibleOptions - 0.5) * rowHeight;
300
- } else {
301
- calculatedHeight = numVisibleOptions * rowHeight;
302
- }
303
- }
304
340
  var classes = classNames('euiSelectableList', {
305
341
  'euiSelectableList-fullHeight': heightIsFull,
306
342
  'euiSelectableList-bordered': bordered
307
343
  }, className);
308
344
  return ___EmotionJSX("div", _extends({
309
345
  className: classes
310
- }, rest), isVirtualized ? ___EmotionJSX(EuiAutoSizer, {
311
- disableHeight: !heightIsFull
312
- }, function (_ref3) {
313
- var width = _ref3.width,
314
- height = _ref3.height;
315
- return ___EmotionJSX(FixedSizeList, _extends({
316
- ref: _this2.setListRef,
317
- outerRef: _this2.removeScrollableTabStop,
318
- className: "euiSelectableList__list",
319
- "data-skip-axe": "scrollable-region-focusable",
320
- width: width,
321
- height: calculatedHeight || height,
322
- itemCount: optionArray.length,
323
- itemData: optionArray,
324
- itemSize: rowHeight,
325
- innerElementType: "ul",
326
- innerRef: _this2.setListBoxRef
327
- }, windowProps), _this2.ListRow);
328
- }) : ___EmotionJSX("div", {
346
+ }, rest), isVirtualized ? this.renderVirtualizedList(heightIsFull, optionArray) : ___EmotionJSX("div", {
329
347
  className: "euiSelectableList__list",
330
348
  ref: this.removeScrollableTabStop
331
349
  }, ___EmotionJSX("ul", {
@@ -20,7 +20,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
20
20
 
21
21
  import React, { Component } from 'react';
22
22
  import classNames from 'classnames';
23
- import { keysOf } from '../common';
24
23
  import { findPopoverPosition, htmlIdGenerator } from '../../services';
25
24
  import { enqueueStateChange } from '../../services/react';
26
25
  import { EuiResizeObserver } from '../observer/resize_observer';
@@ -30,21 +29,12 @@ import { EuiToolTipAnchor } from './tool_tip_anchor';
30
29
  import { EuiToolTipArrow } from './tool_tip_arrow';
31
30
  import { toolTipManager } from './tool_tip_manager';
32
31
  import { jsx as ___EmotionJSX } from "@emotion/react";
33
- var positionsToClassNameMap = {
34
- top: 'euiToolTip--top',
35
- right: 'euiToolTip--right',
36
- bottom: 'euiToolTip--bottom',
37
- left: 'euiToolTip--left'
38
- };
39
- export var POSITIONS = keysOf(positionsToClassNameMap);
32
+ export var POSITIONS = ['top', 'right', 'bottom', 'left'];
33
+ var DISPLAYS = ['inlineBlock', 'block'];
40
34
  var delayToMsMap = {
41
35
  regular: 250,
42
36
  long: 250 * 5
43
37
  };
44
- var displayToClassNameMap = {
45
- inlineBlock: undefined,
46
- block: 'euiToolTipAnchor--displayBlock'
47
- };
48
38
  var DEFAULT_TOOLTIP_STYLES = {
49
39
  // position the tooltip content near the top-left
50
40
  // corner of the window so it can't create scrollbars
@@ -255,7 +245,7 @@ export var EuiToolTip = /*#__PURE__*/function (_Component) {
255
245
  onFocus: this.onFocus,
256
246
  onMouseOver: this.showToolTip,
257
247
  onMouseOut: this.onMouseOut,
258
- id: this.state.id,
248
+ id: id,
259
249
  className: anchorClasses,
260
250
  display: display,
261
251
  isVisible: visible
@@ -1,9 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
3
  var _excluded = ["onBlur", "onFocus", "onMouseOver", "onMouseOut", "id", "className", "children", "display", "isVisible"];
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
4
  /*
8
5
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
9
6
  * or more contributor license agreements. Licensed under the Elastic License
@@ -39,7 +36,7 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
36
  className: classes,
40
37
  onMouseOver: onMouseOver,
41
38
  onMouseOut: onMouseOut
42
- }), /*#__PURE__*/cloneElement(children, _objectSpread({
39
+ }), /*#__PURE__*/cloneElement(children, {
43
40
  onFocus: function onFocus(e) {
44
41
  _onFocus();
45
42
  children.props.onFocus && children.props.onFocus(e);
@@ -47,10 +44,9 @@ export var EuiToolTipAnchor = /*#__PURE__*/forwardRef(function (_ref, ref) {
47
44
  onBlur: function onBlur(e) {
48
45
  _onBlur();
49
46
  children.props.onBlur && children.props.onBlur(e);
50
- }
51
- }, isVisible && {
52
- 'aria-describedby': id
53
- })))
47
+ },
48
+ 'aria-describedby': isVisible ? classNames(id, children.props['aria-describedby']) : children.props['aria-describedby']
49
+ }))
54
50
  );
55
51
  });
56
52
  EuiToolTipAnchor.displayName = 'EuiToolTipAnchor';
@@ -17,6 +17,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
17
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
18
  var _react = _interopRequireWildcard(require("react"));
19
19
  var _classnames = _interopRequireDefault(require("classnames"));
20
+ var _tabbable = require("tabbable");
20
21
  var _loading = require("../loading");
21
22
  var _resize_observer = require("../observer/resize_observer");
22
23
  var _text = require("../text");
@@ -51,33 +52,68 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
51
52
  _this = _super.call.apply(_super, [this].concat(args));
52
53
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "childContent", null);
53
54
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "childWrapper", null);
55
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tabbableChildren", null);
54
56
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
55
57
  isOpen: _this.props.forceState ? _this.props.forceState === 'open' : _this.props.initialIsOpen
56
58
  });
57
59
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setChildContentHeight", function () {
58
- var forceState = _this.props.forceState;
59
60
  requestAnimationFrame(function () {
60
- var height = _this.childContent && (forceState ? forceState === 'open' : _this.state.isOpen) ? _this.childContent.clientHeight : 0;
61
+ var height = _this.childContent && _this.isOpen ? _this.childContent.clientHeight : 0;
61
62
  _this.childWrapper && _this.childWrapper.setAttribute('style', (0, _global_styling.logicalCSS)('height', "".concat(height, "px")));
62
63
  });
63
64
  });
64
65
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onToggle", function () {
65
66
  var forceState = _this.props.forceState;
66
67
  if (forceState) {
67
- _this.props.onToggle && _this.props.onToggle(forceState === 'open' ? false : true);
68
+ var _this$props$onToggle, _this$props;
69
+ (_this$props$onToggle = (_this$props = _this.props).onToggle) === null || _this$props$onToggle === void 0 ? void 0 : _this$props$onToggle.call(_this$props, forceState === 'open' ? false : true);
68
70
  } else {
69
71
  _this.setState(function (prevState) {
70
72
  return {
71
73
  isOpen: !prevState.isOpen
72
74
  };
73
75
  }, function () {
76
+ var _this$props$onToggle2, _this$props2;
74
77
  if (_this.state.isOpen && _this.childWrapper) {
75
78
  _this.childWrapper.focus();
76
79
  }
77
- _this.props.onToggle && _this.props.onToggle(_this.state.isOpen);
80
+ (_this$props$onToggle2 = (_this$props2 = _this.props).onToggle) === null || _this$props$onToggle2 === void 0 ? void 0 : _this$props$onToggle2.call(_this$props2, _this.state.isOpen);
78
81
  });
79
82
  }
80
83
  });
84
+ // When accordions are closed, tabbable children should not be present in the tab order
85
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preventTabbing", function () {
86
+ if (_this.childContent) {
87
+ // Re-check for children on every close - content can change dynamically
88
+ _this.tabbableChildren = (0, _tabbable.tabbable)(_this.childContent);
89
+ _this.tabbableChildren.forEach(function (element) {
90
+ // If the element has an existing `tabIndex` set, make sure we can restore it
91
+ var originalTabIndex = element.getAttribute('tabIndex');
92
+ if (originalTabIndex) {
93
+ element.setAttribute('data-original-tabindex', originalTabIndex);
94
+ }
95
+ element.setAttribute('tabIndex', '-1');
96
+ });
97
+ }
98
+ });
99
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableTabbing", function () {
100
+ // If no tabbable children were set, we don't need to re-enable anything
101
+ if (_this.tabbableChildren) {
102
+ _this.tabbableChildren.forEach(function (element) {
103
+ var originalTabIndex = element.getAttribute('data-original-tabindex');
104
+ if (originalTabIndex) {
105
+ // If the element originally had an existing `tabIndex` set, restore it
106
+ element.setAttribute('tabIndex', originalTabIndex);
107
+ element.removeAttribute('data-original-tabindex');
108
+ } else {
109
+ // If not, remove the tabIndex property
110
+ element.removeAttribute('tabIndex');
111
+ }
112
+ });
113
+ // Cleanup - unset the list of children
114
+ _this.tabbableChildren = null;
115
+ }
116
+ });
81
117
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setChildContentRef", function (node) {
82
118
  _this.childContent = node;
83
119
  });
@@ -92,44 +128,55 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
92
128
  return _this;
93
129
  }
94
130
  (0, _createClass2.default)(EuiAccordionClass, [{
131
+ key: "isOpen",
132
+ get: function get() {
133
+ return this.props.forceState ? this.props.forceState === 'open' : this.state.isOpen;
134
+ }
135
+ }, {
95
136
  key: "componentDidMount",
96
137
  value: function componentDidMount() {
97
138
  this.setChildContentHeight();
139
+ if (!this.isOpen) this.preventTabbing();
98
140
  }
99
141
  }, {
100
142
  key: "componentDidUpdate",
101
- value: function componentDidUpdate() {
143
+ value: function componentDidUpdate(prevProps, prevState) {
102
144
  this.setChildContentHeight();
145
+ if (prevProps.forceState === 'open' && this.props.forceState === 'closed' || prevState.isOpen === true && this.state.isOpen === false) {
146
+ this.preventTabbing();
147
+ }
148
+ if (prevProps.forceState === 'closed' && this.props.forceState === 'open' || prevState.isOpen === false && this.state.isOpen === true) {
149
+ this.enableTabbing();
150
+ }
103
151
  }
104
152
  }, {
105
153
  key: "render",
106
154
  value: function render() {
107
155
  var _buttonProps$id,
108
156
  _this2 = this;
109
- var _this$props = this.props,
110
- children = _this$props.children,
111
- buttonContent = _this$props.buttonContent,
112
- className = _this$props.className,
113
- id = _this$props.id,
114
- _this$props$element = _this$props.element,
115
- Element = _this$props$element === void 0 ? 'div' : _this$props$element,
116
- buttonClassName = _this$props.buttonClassName,
117
- buttonContentClassName = _this$props.buttonContentClassName,
118
- extraAction = _this$props.extraAction,
119
- paddingSize = _this$props.paddingSize,
120
- initialIsOpen = _this$props.initialIsOpen,
121
- arrowDisplay = _this$props.arrowDisplay,
122
- forceState = _this$props.forceState,
123
- isLoading = _this$props.isLoading,
124
- isLoadingMessage = _this$props.isLoadingMessage,
125
- isDisabled = _this$props.isDisabled,
126
- buttonProps = _this$props.buttonProps,
127
- _this$props$buttonEle = _this$props.buttonElement,
128
- _ButtonElement = _this$props$buttonEle === void 0 ? 'button' : _this$props$buttonEle,
129
- arrowProps = _this$props.arrowProps,
130
- theme = _this$props.theme,
131
- rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
132
- var isOpen = forceState ? forceState === 'open' : this.state.isOpen;
157
+ var _this$props3 = this.props,
158
+ children = _this$props3.children,
159
+ buttonContent = _this$props3.buttonContent,
160
+ className = _this$props3.className,
161
+ id = _this$props3.id,
162
+ _this$props3$element = _this$props3.element,
163
+ Element = _this$props3$element === void 0 ? 'div' : _this$props3$element,
164
+ buttonClassName = _this$props3.buttonClassName,
165
+ buttonContentClassName = _this$props3.buttonContentClassName,
166
+ extraAction = _this$props3.extraAction,
167
+ paddingSize = _this$props3.paddingSize,
168
+ initialIsOpen = _this$props3.initialIsOpen,
169
+ arrowDisplay = _this$props3.arrowDisplay,
170
+ forceState = _this$props3.forceState,
171
+ isLoading = _this$props3.isLoading,
172
+ isLoadingMessage = _this$props3.isLoadingMessage,
173
+ isDisabled = _this$props3.isDisabled,
174
+ buttonProps = _this$props3.buttonProps,
175
+ _this$props3$buttonEl = _this$props3.buttonElement,
176
+ _ButtonElement = _this$props3$buttonEl === void 0 ? 'button' : _this$props3$buttonEl,
177
+ arrowProps = _this$props3.arrowProps,
178
+ theme = _this$props3.theme,
179
+ rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
133
180
 
134
181
  // Force button element to be a legend if the element is a fieldset
135
182
  var ButtonElement = Element === 'fieldset' ? 'legend' : _ButtonElement;
@@ -138,7 +185,7 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
138
185
  // Force visibility of arrow button if button element is not focusable
139
186
  var _arrowDisplay = arrowDisplay === 'none' && !buttonElementIsFocusable ? 'left' : arrowDisplay;
140
187
  var classes = (0, _classnames.default)('euiAccordion', {
141
- 'euiAccordion-isOpen': isOpen
188
+ 'euiAccordion-isOpen': this.isOpen
142
189
  }, className);
143
190
  var childrenClasses = (0, _classnames.default)('euiAccordion__children', {
144
191
  'euiAccordion__children-isLoading': isLoading
@@ -146,7 +193,7 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
146
193
  var buttonClasses = (0, _classnames.default)('euiAccordion__button', buttonClassName, buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.className);
147
194
  var buttonContentClasses = (0, _classnames.default)('euiAccordion__buttonContent', buttonContentClassName);
148
195
  var iconButtonClasses = (0, _classnames.default)('euiAccordion__iconButton', {
149
- 'euiAccordion__iconButton-isOpen': isOpen,
196
+ 'euiAccordion__iconButton-isOpen': this.isOpen,
150
197
  'euiAccordion__iconButton--right': _arrowDisplay === 'right'
151
198
  }, arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.className);
152
199
 
@@ -156,9 +203,9 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
156
203
  var childrenStyles = (0, _accordion.euiAccordionChildrenStyles)(theme);
157
204
  var cssChildrenStyles = [childrenStyles.euiAccordion__children, isLoading && childrenStyles.isLoading, paddingSize && paddingSize !== 'none' && childrenStyles[paddingSize]];
158
205
  var childWrapperStyles = (0, _accordion.euiAccordionChildWrapperStyles)(theme);
159
- var cssChildWrapperStyles = [childWrapperStyles.euiAccordion__childWrapper, isOpen && childWrapperStyles.isOpen];
206
+ var cssChildWrapperStyles = [childWrapperStyles.euiAccordion__childWrapper, this.isOpen && childWrapperStyles.isOpen];
160
207
  var iconButtonStyles = (0, _accordion.euiAccordionIconButtonStyles)(theme);
161
- var cssIconButtonStyles = [iconButtonStyles.euiAccordion__iconButton, isOpen && iconButtonStyles.isOpen, _arrowDisplay === 'right' && iconButtonStyles.arrowRight, arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.css];
208
+ var cssIconButtonStyles = [iconButtonStyles.euiAccordion__iconButton, this.isOpen && iconButtonStyles.isOpen, _arrowDisplay === 'right' && iconButtonStyles.arrowRight, arrowProps === null || arrowProps === void 0 ? void 0 : arrowProps.css];
162
209
  var optionalActionStyles = (0, _accordion.euiAccordionOptionalActionStyles)();
163
210
  var cssOptionalActionStyles = [optionalActionStyles.euiAccordion__optionalAction];
164
211
  var spinnerStyles = (0, _accordion.euiAccordionSpinnerStyles)(theme);
@@ -176,7 +223,7 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
176
223
  iconType: "arrowRight",
177
224
  onClick: this.onToggle,
178
225
  "aria-controls": id,
179
- "aria-expanded": isOpen,
226
+ "aria-expanded": this.isOpen,
180
227
  "aria-labelledby": buttonId,
181
228
  tabIndex: buttonElementIsFocusable ? -1 : 0,
182
229
  isDisabled: isDisabled
@@ -210,7 +257,7 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
210
257
  "aria-controls": id
211
258
  // `aria-expanded` is only a valid attribute on interactive controls - axe-core throws a violation otherwise
212
259
  ,
213
- "aria-expanded": ButtonElement === 'button' ? isOpen : undefined,
260
+ "aria-expanded": ButtonElement === 'button' ? this.isOpen : undefined,
214
261
  onClick: isDisabled ? undefined : this.onToggle,
215
262
  type: ButtonElement === 'button' ? 'button' : undefined,
216
263
  disabled: ButtonElement === 'button' ? isDisabled : undefined
@@ -3,10 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "EuiAutoSizer", {
7
- enumerable: true,
8
- get: function get() {
9
- return _auto_sizer.EuiAutoSizer;
10
- }
11
- });
12
- var _auto_sizer = require("./auto_sizer");
6
+ var _auto_sizer = require("./auto_sizer");
7
+ Object.keys(_auto_sizer).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _auto_sizer[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _auto_sizer[key];
14
+ }
15
+ });
16
+ });