@elastic/eui 122.1.0 → 123.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 (46) hide show
  1. package/dist/eui-icons.json +94 -94
  2. package/es/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  3. package/es/components/datagrid/utils/row_heights.js +4 -1
  4. package/es/components/flyout/flyout.component.js +129 -55
  5. package/es/components/flyout/flyout_menu/action_button.js +15 -21
  6. package/es/components/flyout/flyout_menu/flyout_menu.js +40 -46
  7. package/es/components/flyout/manager/flyout_managed.js +24 -6
  8. package/es/components/form/described_form_group/described_form_group.js +17 -4
  9. package/es/components/tabs/tabbed_content/tabbed_content.js +93 -138
  10. package/es/components/text_truncate/text_truncate.js +9 -4
  11. package/eui.d.ts +32 -58
  12. package/lib/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  13. package/lib/components/datagrid/utils/row_heights.js +4 -1
  14. package/lib/components/flyout/flyout.component.js +134 -62
  15. package/lib/components/flyout/flyout_menu/action_button.js +18 -23
  16. package/lib/components/flyout/flyout_menu/flyout_menu.js +40 -46
  17. package/lib/components/flyout/manager/flyout_managed.js +23 -5
  18. package/lib/components/form/described_form_group/described_form_group.js +19 -3
  19. package/lib/components/tabs/tabbed_content/tabbed_content.js +98 -142
  20. package/lib/components/text_truncate/text_truncate.js +9 -4
  21. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  22. package/optimize/es/components/datagrid/utils/row_heights.js +4 -1
  23. package/optimize/es/components/flyout/flyout.component.js +124 -50
  24. package/optimize/es/components/flyout/flyout_menu/action_button.js +14 -21
  25. package/optimize/es/components/flyout/manager/flyout_managed.js +24 -6
  26. package/optimize/es/components/form/described_form_group/described_form_group.js +17 -4
  27. package/optimize/es/components/tabs/tabbed_content/tabbed_content.js +87 -131
  28. package/optimize/es/components/text_truncate/text_truncate.js +4 -3
  29. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  30. package/optimize/lib/components/datagrid/utils/row_heights.js +4 -1
  31. package/optimize/lib/components/flyout/flyout.component.js +123 -49
  32. package/optimize/lib/components/flyout/flyout_menu/action_button.js +14 -22
  33. package/optimize/lib/components/flyout/manager/flyout_managed.js +23 -5
  34. package/optimize/lib/components/form/described_form_group/described_form_group.js +19 -3
  35. package/optimize/lib/components/tabs/tabbed_content/tabbed_content.js +87 -131
  36. package/optimize/lib/components/text_truncate/text_truncate.js +4 -3
  37. package/package.json +2 -2
  38. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  39. package/test-env/components/datagrid/utils/row_heights.js +4 -1
  40. package/test-env/components/flyout/flyout.component.js +123 -49
  41. package/test-env/components/flyout/flyout_menu/action_button.js +14 -22
  42. package/test-env/components/flyout/flyout_menu/flyout_menu.js +40 -46
  43. package/test-env/components/flyout/manager/flyout_managed.js +23 -5
  44. package/test-env/components/form/described_form_group/described_form_group.js +19 -3
  45. package/test-env/components/tabs/tabbed_content/tabbed_content.js +88 -132
  46. package/test-env/components/text_truncate/text_truncate.js +9 -4
@@ -1,4 +1,5 @@
1
- var _excluded = ["children", "style"];
1
+ var _excluded = ["children", "style"],
2
+ _excluded2 = ["onScroll"];
2
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
5
  import PropTypes from "prop-types";
@@ -81,40 +82,96 @@ var InnerElement = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, r
81
82
  }, rest), headerRow, children), footerRow);
82
83
  }));
83
84
  InnerElement.displayName = 'EuiDataGridInnerElement';
84
- export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
85
- var leadingControlColumns = _ref3.leadingControlColumns,
86
- trailingControlColumns = _ref3.trailingControlColumns,
87
- columns = _ref3.columns,
88
- visibleColCount = _ref3.visibleColCount,
89
- schema = _ref3.schema,
90
- schemaDetectors = _ref3.schemaDetectors,
91
- rowCount = _ref3.rowCount,
92
- _ref3$visibleRows = _ref3.visibleRows,
93
- startRow = _ref3$visibleRows.startRow,
94
- endRow = _ref3$visibleRows.endRow,
95
- visibleRowCount = _ref3$visibleRows.visibleRowCount,
96
- renderCellValue = _ref3.renderCellValue,
97
- cellContext = _ref3.cellContext,
98
- renderCellPopover = _ref3.renderCellPopover,
99
- renderFooterCellValue = _ref3.renderFooterCellValue,
100
- interactiveCellId = _ref3.interactiveCellId,
101
- pagination = _ref3.pagination,
102
- sorting = _ref3.sorting,
103
- setVisibleColumns = _ref3.setVisibleColumns,
104
- switchColumnPos = _ref3.switchColumnPos,
105
- onColumnResize = _ref3.onColumnResize,
106
- rowHeightsOptions = _ref3.rowHeightsOptions,
107
- virtualizationOptions = _ref3.virtualizationOptions,
108
- isFullScreen = _ref3.isFullScreen,
109
- gridStyles = _ref3.gridStyles,
110
- gridWidth = _ref3.gridWidth,
111
- gridRef = _ref3.gridRef,
112
- gridItemsRendered = _ref3.gridItemsRendered,
113
- wrapperRef = _ref3.wrapperRef,
114
- className = _ref3.className,
115
- canDragAndDropColumns = _ref3.canDragAndDropColumns,
116
- _ref3$showHeader = _ref3.showHeader,
117
- showHeader = _ref3$showHeader === void 0 ? true : _ref3$showHeader;
85
+ var DataGridOuterElementContext = /*#__PURE__*/createContext({
86
+ scrollPositionRef: {
87
+ current: null
88
+ }
89
+ });
90
+ var clampScrollOffset = function clampScrollOffset(offset, max) {
91
+ return Math.max(0, Math.min(offset, max));
92
+ };
93
+ var OuterElement = /*#__PURE__*/forwardRef(function (_ref3, ref) {
94
+ var onScroll = _ref3.onScroll,
95
+ rest = _objectWithoutProperties(_ref3, _excluded2);
96
+ var _useContext2 = useContext(DataGridOuterElementContext),
97
+ _useContext2$outerEle = _useContext2.outerElementType,
98
+ Element = _useContext2$outerEle === void 0 ? 'div' : _useContext2$outerEle,
99
+ direction = _useContext2.direction,
100
+ scrollPositionRef = _useContext2.scrollPositionRef;
101
+
102
+ // react-window compares the raw scroll offsets against its own clamped
103
+ // offsets, and flags the grid as scrolling (setting `pointer-events: none`
104
+ // on the inner element) whenever they differ. Firefox can report a
105
+ // `scrollTop` above the maximum at fractional device pixel ratios, which
106
+ // makes every scroll event at the bottom of the grid look like a scroll,
107
+ // so hovered cells lose the pointer and tooltips repeatedly open and close.
108
+ var onScrollIfMoved = useCallback(function (event) {
109
+ if (direction !== 'rtl') {
110
+ var _event$currentTarget = event.currentTarget,
111
+ scrollTop = _event$currentTarget.scrollTop,
112
+ scrollLeft = _event$currentTarget.scrollLeft,
113
+ scrollHeight = _event$currentTarget.scrollHeight,
114
+ scrollWidth = _event$currentTarget.scrollWidth,
115
+ clientHeight = _event$currentTarget.clientHeight,
116
+ clientWidth = _event$currentTarget.clientWidth;
117
+ var scrollPosition = {
118
+ scrollTop: clampScrollOffset(scrollTop, scrollHeight - clientHeight),
119
+ scrollLeft: clampScrollOffset(scrollLeft, scrollWidth - clientWidth)
120
+ };
121
+ var previousScrollPosition = scrollPositionRef.current;
122
+ if (previousScrollPosition && scrollPosition.scrollTop === previousScrollPosition.scrollTop && scrollPosition.scrollLeft === previousScrollPosition.scrollLeft) {
123
+ return;
124
+ }
125
+ // react-window may not have rendered the previous event's position
126
+ // yet, so the ref must reflect every forwarded event, not only the
127
+ // positions react-window reports back through its `onScroll` prop.
128
+ scrollPositionRef.current = scrollPosition;
129
+ }
130
+ onScroll(event);
131
+ }, [onScroll, direction, scrollPositionRef]);
132
+ return ___EmotionJSX(Element, _extends({
133
+ ref: ref,
134
+ onScroll: onScrollIfMoved
135
+ }, rest));
136
+ });
137
+ OuterElement.propTypes = {
138
+ onScroll: PropTypes.any.isRequired
139
+ };
140
+ OuterElement.displayName = 'EuiDataGridOuterElement';
141
+ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref4) {
142
+ var leadingControlColumns = _ref4.leadingControlColumns,
143
+ trailingControlColumns = _ref4.trailingControlColumns,
144
+ columns = _ref4.columns,
145
+ visibleColCount = _ref4.visibleColCount,
146
+ schema = _ref4.schema,
147
+ schemaDetectors = _ref4.schemaDetectors,
148
+ rowCount = _ref4.rowCount,
149
+ _ref4$visibleRows = _ref4.visibleRows,
150
+ startRow = _ref4$visibleRows.startRow,
151
+ endRow = _ref4$visibleRows.endRow,
152
+ visibleRowCount = _ref4$visibleRows.visibleRowCount,
153
+ renderCellValue = _ref4.renderCellValue,
154
+ cellContext = _ref4.cellContext,
155
+ renderCellPopover = _ref4.renderCellPopover,
156
+ renderFooterCellValue = _ref4.renderFooterCellValue,
157
+ interactiveCellId = _ref4.interactiveCellId,
158
+ pagination = _ref4.pagination,
159
+ sorting = _ref4.sorting,
160
+ setVisibleColumns = _ref4.setVisibleColumns,
161
+ switchColumnPos = _ref4.switchColumnPos,
162
+ onColumnResize = _ref4.onColumnResize,
163
+ rowHeightsOptions = _ref4.rowHeightsOptions,
164
+ virtualizationOptions = _ref4.virtualizationOptions,
165
+ isFullScreen = _ref4.isFullScreen,
166
+ gridStyles = _ref4.gridStyles,
167
+ gridWidth = _ref4.gridWidth,
168
+ gridRef = _ref4.gridRef,
169
+ gridItemsRendered = _ref4.gridItemsRendered,
170
+ wrapperRef = _ref4.wrapperRef,
171
+ className = _ref4.className,
172
+ canDragAndDropColumns = _ref4.canDragAndDropColumns,
173
+ _ref4$showHeader = _ref4.showHeader,
174
+ showHeader = _ref4$showHeader === void 0 ? true : _ref4$showHeader;
118
175
  /**
119
176
  * Grid refs & observers
120
177
  */
@@ -310,7 +367,30 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
310
367
  footerRow: footerRow
311
368
  };
312
369
  }, [headerRowHeight, headerRow, footerRow, showHeader]);
370
+ var scrollPositionRef = useRef(null);
371
+ var outerElementContextValue = useMemo(function () {
372
+ return {
373
+ outerElementType: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType,
374
+ direction: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction,
375
+ scrollPositionRef: scrollPositionRef
376
+ };
377
+ }, [virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction]);
313
378
  var onScroll = useCallback(function (args) {
379
+ var element = outerGridRef.current;
380
+ // `scrollTo` reports the requested offset, which can sit past the
381
+ // end. Storing that would replace the clamped position already
382
+ // taken from the DOM. Leave the ref unchanged instead of writing
383
+ // the clamped value: a scroll event that has not arrived yet still
384
+ // differs from the previous position and is forwarded.
385
+ var topInRange = element == null || args.scrollTop === clampScrollOffset(args.scrollTop, element.scrollHeight - element.clientHeight);
386
+ var leftInRange = element == null || args.scrollLeft === clampScrollOffset(args.scrollLeft, element.scrollWidth - element.clientWidth);
387
+ if (topInRange && leftInRange) {
388
+ scrollPositionRef.current = {
389
+ scrollTop: args.scrollTop,
390
+ scrollLeft: args.scrollLeft
391
+ };
392
+ }
393
+
314
394
  // check only if a callback is passed
315
395
  if (typeof (virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.onScroll) !== 'function') return;
316
396
  var enhancedArgs = _objectSpread(_objectSpread({}, args), {}, {
@@ -354,10 +434,13 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
354
434
  }, [outerGridRef, virtualizationOptions]);
355
435
  return IS_JEST_ENVIRONMENT || finalWidth > 0 ? ___EmotionJSX(DataGridWrapperRowsContext.Provider, {
356
436
  value: rowWrapperContextValue
437
+ }, ___EmotionJSX(DataGridOuterElementContext.Provider, {
438
+ value: outerElementContextValue
357
439
  }, ___EmotionJSX(Grid, _extends({}, virtualizationOptions, {
358
440
  ref: gridRef,
359
441
  className: classNames('euiDataGrid__virtualized', className, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.className),
360
442
  onItemsRendered: onItemsRendered,
443
+ outerElementType: OuterElement,
361
444
  innerElementType: InnerElement,
362
445
  outerRef: outerGridRef,
363
446
  innerRef: innerGridRef,
@@ -369,7 +452,7 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
369
452
  itemData: itemData,
370
453
  rowCount: IS_JEST_ENVIRONMENT || headerRowHeight > 0 || showHeader === false && innerGridRef.current ? visibleRowCount : 0,
371
454
  onScroll: onScroll
372
- }), Cell), scrollBorderOverlay) : null;
455
+ }), Cell)), scrollBorderOverlay) : null;
373
456
  });
374
457
  EuiDataGridBodyVirtualized.propTypes = {
375
458
  leadingControlColumns: PropTypes.arrayOf(PropTypes.shape({
@@ -307,7 +307,10 @@ export var useRowHeightUtils = function useRowHeightUtils(_ref3) {
307
307
  if (forceRenderRef.current == null) {
308
308
  return;
309
309
  }
310
- requestAnimationFrame(forceRenderRef.current);
310
+ var frameId = requestAnimationFrame(forceRenderRef.current);
311
+ return function () {
312
+ return cancelAnimationFrame(frameId);
313
+ };
311
314
  }, [// Effects that should cause rerendering
312
315
  rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight, rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.rowHeights,
313
316
  // Dependencies
@@ -1,10 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  var _excluded = ["className", "children", "as", "hideCloseButton", "flyoutMenuProps", "flyoutMenuDisplayMode", "closeButtonProps", "closeButtonPosition", "onClose", "ownFocus", "side", "size", "paddingSize", "maxWidth", "style", "hasChildBackground", "maskProps", "type", "outsideClickCloses", "pushMinBreakpoint", "pushAnimation", "hasAnimation", "focusTrapProps", "includeFixedHeadersInFocusTrap", "includeSelectorInFocusTrap", "aria-describedby", "aria-labelledby", "id", "resizable", "minWidth", "onResize", "onAnimationEnd", "container"];
3
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
- function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
- function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
7
- function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
8
4
  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; }
9
5
  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; }
10
6
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -12,12 +8,16 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
12
8
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
9
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
14
10
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
16
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
17
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
18
12
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
19
13
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
20
14
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
15
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
16
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
18
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
19
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
20
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
21
21
  /*
22
22
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
23
  * or more contributor license agreements. Licensed under the Elastic License
@@ -30,7 +30,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
30
30
 
31
31
  import React, { useEffect, useLayoutEffect, useRef, useMemo, useCallback, useState, forwardRef } from 'react';
32
32
  import classnames from 'classnames';
33
- import { keys, EuiWindowEvent, useCombinedRefs, useEuiTheme, useEuiMemoizedStyles, useGeneratedHtmlId, useEuiThemeCSSVariables, focusTrapPubSub } from '../../services';
33
+ import { keys, EuiWindowEvent, useCombinedRefs, useEuiTheme, useEuiMemoizedStyles, useGeneratedHtmlId, focusTrapPubSub } from '../../services';
34
34
  import { useIsInManagedFlyout, useFlyoutId, useFlyoutManager } from './manager';
35
35
  import { LAYOUT_MODE_SIDE_BY_SIDE, LAYOUT_MODE_STACKED, LEVEL_MAIN, PROPERTY_LEVEL } from './manager/const';
36
36
  import { EuiFocusTrap } from '../focus_trap';
@@ -65,6 +65,52 @@ var resolveContainer = function resolveContainer(raw) {
65
65
  if (typeof HTMLElement === 'undefined') return null;
66
66
  return raw instanceof HTMLElement ? raw : null;
67
67
  };
68
+
69
+ /**
70
+ * Per-target push-flyout offset bookkeeping, shared across every flyout React root (they all
71
+ * render from this one module). Keyed by the element the offset is applied to — a `container` or
72
+ * `document.body` — so flyouts targeting different elements never contend.
73
+ *
74
+ * Instead of a single owner per side, every currently-pushed flyout records its width as a
75
+ * contribution and the applied offset is derived from the set (the widest contribution). Closing,
76
+ * resizing, or backgrounding any one flyout just updates its own entry, so the result no longer
77
+ * depends on open/close order or on cross-root effect ordering. The target's base (pre-flyout)
78
+ * inline padding is captured when the first contribution arrives and restored when the last one
79
+ * leaves. See https://github.com/elastic/eui/issues/9788.
80
+ */
81
+
82
+ var euiPushPaddingRegistry = new WeakMap();
83
+ var euiSideStyleKey = function euiSideStyleKey(side) {
84
+ return side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
85
+ };
86
+ var euiSideCssVarKey = function euiSideCssVarKey(side) {
87
+ return side === 'left' ? '--euiPushFlyoutOffsetInlineStart' : '--euiPushFlyoutOffsetInlineEnd';
88
+ };
89
+ var euiGetPushPaddingSideState = function euiGetPushPaddingSideState(target, side) {
90
+ var state = euiPushPaddingRegistry.get(target);
91
+ if (!state) {
92
+ state = {
93
+ left: {
94
+ base: '',
95
+ contributions: new Map()
96
+ },
97
+ right: {
98
+ base: '',
99
+ contributions: new Map()
100
+ }
101
+ };
102
+ euiPushPaddingRegistry.set(target, state);
103
+ }
104
+ return state[side];
105
+ };
106
+ var euiMaxContribution = function euiMaxContribution(contributions) {
107
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
108
+ return true;
109
+ };
110
+ return Math.max.apply(Math, [0].concat(_toConsumableArray(Array.from(contributions.values(), function (contribution) {
111
+ return filter(contribution) ? contribution.width : 0;
112
+ }))));
113
+ };
68
114
  var defaultElement = 'div';
69
115
  export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
70
116
  var _maskProps$headerZind, _managerSessions, _managerState$layoutM, _managerState$current, _managerState$flyouts, _managerState$pushPad;
@@ -119,8 +165,6 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
119
165
  var container = resolveContainer(containerProp);
120
166
  var hasAnimationDefault = type === 'overlay';
121
167
  var hasAnimation = _hasAnimation !== null && _hasAnimation !== void 0 ? _hasAnimation : hasAnimationDefault;
122
- var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
123
- setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
124
168
  var Element = as || defaultElement;
125
169
  var maskRef = useRef(null);
126
170
 
@@ -137,10 +181,6 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
137
181
  pushMinBreakpoint: pushMinBreakpoint,
138
182
  containerWidth: containerReferenceWidth
139
183
  });
140
- // When no explicit container is provided, push padding targets
141
- // document.body and global push-offset CSS vars are set. When a
142
- // container is provided, only that element receives padding.
143
- var shouldSetGlobalPushVars = container == null;
144
184
  if ('container' in props && ('maskProps' in props || 'includeFixedHeadersInFocusTrap' in props) && process.env.NODE_ENV === 'development') {
145
185
  if ('maskProps' in props) {
146
186
  console.warn('EuiFlyout: `maskProps` is deprecated. Prefer using the `container` prop to scope flyouts.');
@@ -211,22 +251,33 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
211
251
  }
212
252
  }, [isInManagedContext, flyoutId]);
213
253
 
214
- // Derive flyout identity and sibling info from the single context read
254
+ // Derive flyout identity and sibling info from the session this flyout
255
+ // belongs to. Not the current (top-most) session: a newly opened main
256
+ // renders once before it registers its own session, and a backgrounded
257
+ // main is not in the current session at all. Reading the current session
258
+ // in those cases would treat the other session's main as this flyout's
259
+ // sibling and clamp the resizable width against it.
260
+ var ownSession = useMemo(function () {
261
+ var _managerSessions$find;
262
+ return (_managerSessions$find = managerSessions === null || managerSessions === void 0 ? void 0 : managerSessions.find(function (session) {
263
+ return session.mainFlyoutId === flyoutId || session.childFlyoutId === flyoutId;
264
+ })) !== null && _managerSessions$find !== void 0 ? _managerSessions$find : null;
265
+ }, [managerSessions, flyoutId]);
215
266
  var flyoutIdentity = useMemo(function () {
216
- if (!flyoutId || !currentSession) {
267
+ if (!flyoutId || !ownSession) {
217
268
  return {
218
269
  isMainFlyout: false,
219
270
  siblingFlyoutId: null,
220
271
  hasValidSession: false
221
272
  };
222
273
  }
223
- var siblingFlyoutId = currentSession.mainFlyoutId === flyoutId ? currentSession.childFlyoutId : currentSession.mainFlyoutId;
274
+ var siblingFlyoutId = ownSession.mainFlyoutId === flyoutId ? ownSession.childFlyoutId : ownSession.mainFlyoutId;
224
275
  return {
225
- isMainFlyout: currentSession.mainFlyoutId === flyoutId,
276
+ isMainFlyout: ownSession.mainFlyoutId === flyoutId,
226
277
  siblingFlyoutId: siblingFlyoutId,
227
278
  hasValidSession: true
228
279
  };
229
- }, [flyoutId, currentSession]);
280
+ }, [flyoutId, ownSession]);
230
281
 
231
282
  // Destructure for easier use
232
283
  var siblingFlyoutId = flyoutIdentity.siblingFlyoutId,
@@ -307,17 +358,24 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
307
358
  // the document element so that the child (fill) flyout can track it
308
359
  // synchronously during drag resize, avoiding the 1-frame lag that
309
360
  // results from the async ResizeObserver → manager-state pipeline.
361
+ // Only the active session's main publishes: a backgrounded main keeps its
362
+ // `isMainFlyout` role but must not leave its width behind for the new
363
+ // session's child to read.
310
364
  useLayoutEffect(function () {
311
- if (!isMainFlyout) return;
365
+ if (!isMainFlyout || !isActiveManagedFlyout) return;
312
366
 
313
367
  // Only set when we have a computed percentage (during active resize)
314
- if (typeof size === 'string' && size.endsWith('%')) {
315
- document.documentElement.style.setProperty('--euiFlyoutMainWidth', size);
316
- }
368
+ if (typeof size !== 'string' || !size.endsWith('%')) return;
369
+ var style = document.documentElement.style;
370
+ style.setProperty('--euiFlyoutMainWidth', size);
317
371
  return function () {
318
- document.documentElement.style.removeProperty('--euiFlyoutMainWidth');
372
+ // Flyouts in separate React roots can run this cleanup after another
373
+ // main has already published its own width; leave that value alone.
374
+ if (style.getPropertyValue('--euiFlyoutMainWidth') === size) {
375
+ style.removeProperty('--euiFlyoutMainWidth');
376
+ }
319
377
  };
320
- }, [isMainFlyout, size]);
378
+ }, [isMainFlyout, isActiveManagedFlyout, size]);
321
379
 
322
380
  /**
323
381
  * Setting up the refs on the actual flyout element in order to
@@ -337,45 +395,61 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
337
395
  * Uses useLayoutEffect so padding is applied before child render.
338
396
  */
339
397
  useLayoutEffect(function () {
340
- if (!isPushed) {
341
- return;
342
- }
343
398
  var paddingTarget = container !== null && container !== void 0 ? container : document.body;
344
- var shouldApplyPadding = !isInManagedContext || isActiveManagedFlyout;
345
- var paddingSide = side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
346
- var cssVarName = "--euiPushFlyoutOffset".concat(side === 'left' ? 'InlineStart' : 'InlineEnd');
347
399
  var managerSide = side === 'left' ? 'left' : 'right';
400
+ var styleKey = euiSideStyleKey(managerSide);
401
+ var state = euiGetPushPaddingSideState(paddingTarget, managerSide);
348
402
 
349
- // Capture pre-existing inline padding so it can be restored on cleanup
350
- var previousPadding = paddingTarget.style[paddingSide];
351
- var paddingWidth = layoutMode === LAYOUT_MODE_STACKED && isMainFlyout && _siblingFlyoutWidth ? _siblingFlyoutWidth : width;
352
- if (shouldApplyPadding) {
353
- paddingTarget.style[paddingSide] = "".concat(paddingWidth, "px");
354
- if (shouldSetGlobalPushVars) {
355
- setGlobalCSSVariables(_defineProperty({}, cssVarName, "".concat(paddingWidth, "px")));
356
- }
357
- if (isInManagedContext && flyoutManagerRef.current) {
358
- flyoutManagerRef.current.setPushPadding(managerSide, paddingWidth);
359
- }
360
- } else {
361
- paddingTarget.style[paddingSide] = previousPadding;
362
- if (shouldSetGlobalPushVars) {
363
- setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
403
+ // Write the offset derived from all current contributions: the widest pushed flyout on
404
+ // this target.
405
+ var apply = function apply() {
406
+ var total = euiMaxContribution(state.contributions);
407
+ var isPushing = state.contributions.size > 0;
408
+ paddingTarget.style[styleKey] = isPushing ? "".concat(total, "px") : state.base;
409
+ // Without a `container` the offset is also exposed as a global CSS variable. It is
410
+ // written inline on `<html>` rather than through `EuiProvider`, because every React root
411
+ // has its own provider rendering its own `:root` block and the last one inserted would
412
+ // win regardless of which root's flyouts are still open.
413
+ if (container == null) {
414
+ var cssVar = euiSideCssVarKey(managerSide);
415
+ if (isPushing) {
416
+ document.documentElement.style.setProperty(cssVar, "".concat(total, "px"));
417
+ } else {
418
+ document.documentElement.style.removeProperty(cssVar);
419
+ }
364
420
  }
365
- if (isInManagedContext && flyoutManagerRef.current) {
366
- flyoutManagerRef.current.setPushPadding(managerSide, 0);
421
+ // The manager only learns about managed flyouts, so it must not be told about a standalone
422
+ // flyout's width: nothing would ever reset it once that flyout closes.
423
+ if (isInManagedContext) {
424
+ var _flyoutManagerRef$cur5;
425
+ (_flyoutManagerRef$cur5 = flyoutManagerRef.current) === null || _flyoutManagerRef$cur5 === void 0 || _flyoutManagerRef$cur5.setPushPadding(managerSide, euiMaxContribution(state.contributions, function (c) {
426
+ return c.managed;
427
+ }));
367
428
  }
429
+ };
430
+ var paddingWidth = layoutMode === LAYOUT_MODE_STACKED && isMainFlyout && _siblingFlyoutWidth ? _siblingFlyoutWidth : width;
431
+
432
+ // A standalone flyout pushes whenever it is in push mode. A managed flyout only pushes while
433
+ // it is the active session's flyout; a backgrounded push flyout (e.g. under a new overlay
434
+ // session) withdraws its contribution so the page is not left pushed for it.
435
+ var shouldPush = isPushed && (!isInManagedContext || isActiveManagedFlyout);
436
+ if (!shouldPush) {
437
+ return;
438
+ }
439
+ if (state.contributions.size === 0) {
440
+ // First pushed flyout on this side: capture the app's own inline padding to restore later.
441
+ state.base = paddingTarget.style[styleKey];
368
442
  }
443
+ state.contributions.set(flyoutId, {
444
+ width: paddingWidth,
445
+ managed: isInManagedContext
446
+ });
447
+ apply();
369
448
  return function () {
370
- paddingTarget.style[paddingSide] = previousPadding;
371
- if (shouldSetGlobalPushVars) {
372
- setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
373
- }
374
- if (isInManagedContext && flyoutManagerRef.current) {
375
- flyoutManagerRef.current.setPushPadding(managerSide, 0);
376
- }
449
+ state.contributions.delete(flyoutId);
450
+ apply();
377
451
  };
378
- }, [isPushed, isInManagedContext, isActiveManagedFlyout, setGlobalCSSVariables, side, width, layoutMode, isMainFlyout, _siblingFlyoutWidth, shouldSetGlobalPushVars, container]);
452
+ }, [isPushed, isInManagedContext, isActiveManagedFlyout, side, width, layoutMode, isMainFlyout, _siblingFlyoutWidth, container, flyoutId]);
379
453
 
380
454
  /**
381
455
  * This class doesn't actually do anything by EUI, but is nice to add for consumers (JIC)
@@ -1,4 +1,7 @@
1
+ var _excluded = ["toolTipContent", "toolTipProps"];
1
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
2
5
  /*
3
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
7
  * or more contributor license agreements. Licensed under the Elastic License
@@ -13,29 +16,20 @@ import { EuiToolTip } from '../../tool_tip';
13
16
  import { jsx as ___EmotionJSX } from "@emotion/react";
14
17
  export var MenuActionButton = function MenuActionButton(_ref) {
15
18
  var action = _ref.action;
16
- var iconType = action.iconType,
17
- onClick = action.onClick,
18
- ariaLabel = action['aria-label'],
19
- toolTipContent = action.toolTipContent,
19
+ var toolTipContent = action.toolTipContent,
20
20
  toolTipProps = action.toolTipProps,
21
- isDisabled = action.isDisabled,
22
- isLoading = action.isLoading,
23
- href = action.href,
24
- target = action.target;
25
- var sharedProps = {
26
- 'aria-label': ariaLabel,
27
- iconType: iconType,
28
- onClick: onClick,
29
- color: 'text',
30
- size: 'xs',
31
- isDisabled: isDisabled,
32
- // Keeps the button focusable so tooltip-on-disabled works for keyboard users
33
- isLoading: isLoading,
34
- href: href,
35
- target: target
36
- };
21
+ buttonProps = _objectWithoutProperties(action, _excluded);
22
+ var button = ___EmotionJSX(EuiButtonIcon, _extends({}, buttonProps, {
23
+ // The menu bar sets these props itself so every action looks the same.
24
+ // Anything set here also belongs in `EuiFlyoutMenuOwnedActionProps`.
25
+ color: "text",
26
+ size: "xs",
27
+ display: "empty",
28
+ iconSize: "m",
29
+ isSelected: undefined
30
+ }));
37
31
  return toolTipContent ? ___EmotionJSX(EuiToolTip, _extends({
38
32
  content: toolTipContent,
39
33
  disableScreenReaderOutput: true
40
- }, toolTipProps), ___EmotionJSX(EuiButtonIcon, sharedProps)) : ___EmotionJSX(EuiButtonIcon, sharedProps);
34
+ }, toolTipProps), button) : button;
41
35
  };