@elastic/eui 122.1.0 → 123.0.0-snapshot.1790779107273

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 (56) hide show
  1. package/dist/eui-icons.json +95 -95
  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_close_button.styles.js +1 -1
  5. package/es/components/flyout/flyout.component.js +129 -55
  6. package/es/components/flyout/flyout_menu/action_button.js +15 -21
  7. package/es/components/flyout/flyout_menu/flyout_menu.js +40 -46
  8. package/es/components/flyout/flyout_menu/flyout_menu.styles.js +10 -4
  9. package/es/components/flyout/manager/flyout_managed.js +24 -6
  10. package/es/components/form/described_form_group/described_form_group.js +17 -4
  11. package/es/components/tabs/tabbed_content/tabbed_content.js +93 -138
  12. package/es/components/text_truncate/text_truncate.js +9 -4
  13. package/eui.d.ts +32 -58
  14. package/lib/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  15. package/lib/components/datagrid/utils/row_heights.js +4 -1
  16. package/lib/components/flyout/_flyout_close_button.styles.js +1 -1
  17. package/lib/components/flyout/flyout.component.js +134 -62
  18. package/lib/components/flyout/flyout_menu/action_button.js +18 -23
  19. package/lib/components/flyout/flyout_menu/flyout_menu.js +40 -46
  20. package/lib/components/flyout/flyout_menu/flyout_menu.styles.js +10 -4
  21. package/lib/components/flyout/manager/flyout_managed.js +23 -5
  22. package/lib/components/form/described_form_group/described_form_group.js +19 -3
  23. package/lib/components/tabs/tabbed_content/tabbed_content.js +98 -142
  24. package/lib/components/text_truncate/text_truncate.js +9 -4
  25. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  26. package/optimize/es/components/datagrid/utils/row_heights.js +4 -1
  27. package/optimize/es/components/flyout/_flyout_close_button.styles.js +1 -1
  28. package/optimize/es/components/flyout/flyout.component.js +124 -50
  29. package/optimize/es/components/flyout/flyout_menu/action_button.js +14 -21
  30. package/optimize/es/components/flyout/flyout_menu/flyout_menu.styles.js +10 -4
  31. package/optimize/es/components/flyout/manager/flyout_managed.js +24 -6
  32. package/optimize/es/components/form/described_form_group/described_form_group.js +17 -4
  33. package/optimize/es/components/tabs/tabbed_content/tabbed_content.js +87 -131
  34. package/optimize/es/components/text_truncate/text_truncate.js +4 -3
  35. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  36. package/optimize/lib/components/datagrid/utils/row_heights.js +4 -1
  37. package/optimize/lib/components/flyout/_flyout_close_button.styles.js +1 -1
  38. package/optimize/lib/components/flyout/flyout.component.js +123 -49
  39. package/optimize/lib/components/flyout/flyout_menu/action_button.js +14 -22
  40. package/optimize/lib/components/flyout/flyout_menu/flyout_menu.styles.js +10 -4
  41. package/optimize/lib/components/flyout/manager/flyout_managed.js +23 -5
  42. package/optimize/lib/components/form/described_form_group/described_form_group.js +19 -3
  43. package/optimize/lib/components/tabs/tabbed_content/tabbed_content.js +87 -131
  44. package/optimize/lib/components/text_truncate/text_truncate.js +4 -3
  45. package/package.json +8 -7
  46. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  47. package/test-env/components/datagrid/utils/row_heights.js +4 -1
  48. package/test-env/components/flyout/_flyout_close_button.styles.js +1 -1
  49. package/test-env/components/flyout/flyout.component.js +123 -49
  50. package/test-env/components/flyout/flyout_menu/action_button.js +14 -22
  51. package/test-env/components/flyout/flyout_menu/flyout_menu.js +40 -46
  52. package/test-env/components/flyout/flyout_menu/flyout_menu.styles.js +10 -4
  53. package/test-env/components/flyout/manager/flyout_managed.js +23 -5
  54. package/test-env/components/form/described_form_group/described_form_group.js +19 -3
  55. package/test-env/components/tabs/tabbed_content/tabbed_content.js +88 -132
  56. package/test-env/components/text_truncate/text_truncate.js +9 -4
@@ -1,7 +1,8 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
- var _excluded = ["children", "style"];
4
+ var _excluded = ["children", "style"],
5
+ _excluded2 = ["onScroll"];
5
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
8
  /*
@@ -76,40 +77,93 @@ var InnerElement = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, r
76
77
  }, rest), headerRow, children), footerRow);
77
78
  }));
78
79
  InnerElement.displayName = 'EuiDataGridInnerElement';
79
- export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
80
- var leadingControlColumns = _ref3.leadingControlColumns,
81
- trailingControlColumns = _ref3.trailingControlColumns,
82
- columns = _ref3.columns,
83
- visibleColCount = _ref3.visibleColCount,
84
- schema = _ref3.schema,
85
- schemaDetectors = _ref3.schemaDetectors,
86
- rowCount = _ref3.rowCount,
87
- _ref3$visibleRows = _ref3.visibleRows,
88
- startRow = _ref3$visibleRows.startRow,
89
- endRow = _ref3$visibleRows.endRow,
90
- visibleRowCount = _ref3$visibleRows.visibleRowCount,
91
- renderCellValue = _ref3.renderCellValue,
92
- cellContext = _ref3.cellContext,
93
- renderCellPopover = _ref3.renderCellPopover,
94
- renderFooterCellValue = _ref3.renderFooterCellValue,
95
- interactiveCellId = _ref3.interactiveCellId,
96
- pagination = _ref3.pagination,
97
- sorting = _ref3.sorting,
98
- setVisibleColumns = _ref3.setVisibleColumns,
99
- switchColumnPos = _ref3.switchColumnPos,
100
- onColumnResize = _ref3.onColumnResize,
101
- rowHeightsOptions = _ref3.rowHeightsOptions,
102
- virtualizationOptions = _ref3.virtualizationOptions,
103
- isFullScreen = _ref3.isFullScreen,
104
- gridStyles = _ref3.gridStyles,
105
- gridWidth = _ref3.gridWidth,
106
- gridRef = _ref3.gridRef,
107
- gridItemsRendered = _ref3.gridItemsRendered,
108
- wrapperRef = _ref3.wrapperRef,
109
- className = _ref3.className,
110
- canDragAndDropColumns = _ref3.canDragAndDropColumns,
111
- _ref3$showHeader = _ref3.showHeader,
112
- showHeader = _ref3$showHeader === void 0 ? true : _ref3$showHeader;
80
+ var DataGridOuterElementContext = /*#__PURE__*/createContext({
81
+ scrollPositionRef: {
82
+ current: null
83
+ }
84
+ });
85
+ var clampScrollOffset = function clampScrollOffset(offset, max) {
86
+ return Math.max(0, Math.min(offset, max));
87
+ };
88
+ var OuterElement = /*#__PURE__*/forwardRef(function (_ref3, ref) {
89
+ var onScroll = _ref3.onScroll,
90
+ rest = _objectWithoutProperties(_ref3, _excluded2);
91
+ var _useContext2 = useContext(DataGridOuterElementContext),
92
+ _useContext2$outerEle = _useContext2.outerElementType,
93
+ Element = _useContext2$outerEle === void 0 ? 'div' : _useContext2$outerEle,
94
+ direction = _useContext2.direction,
95
+ scrollPositionRef = _useContext2.scrollPositionRef;
96
+
97
+ // react-window compares the raw scroll offsets against its own clamped
98
+ // offsets, and flags the grid as scrolling (setting `pointer-events: none`
99
+ // on the inner element) whenever they differ. Firefox can report a
100
+ // `scrollTop` above the maximum at fractional device pixel ratios, which
101
+ // makes every scroll event at the bottom of the grid look like a scroll,
102
+ // so hovered cells lose the pointer and tooltips repeatedly open and close.
103
+ var onScrollIfMoved = useCallback(function (event) {
104
+ if (direction !== 'rtl') {
105
+ var _event$currentTarget = event.currentTarget,
106
+ scrollTop = _event$currentTarget.scrollTop,
107
+ scrollLeft = _event$currentTarget.scrollLeft,
108
+ scrollHeight = _event$currentTarget.scrollHeight,
109
+ scrollWidth = _event$currentTarget.scrollWidth,
110
+ clientHeight = _event$currentTarget.clientHeight,
111
+ clientWidth = _event$currentTarget.clientWidth;
112
+ var scrollPosition = {
113
+ scrollTop: clampScrollOffset(scrollTop, scrollHeight - clientHeight),
114
+ scrollLeft: clampScrollOffset(scrollLeft, scrollWidth - clientWidth)
115
+ };
116
+ var previousScrollPosition = scrollPositionRef.current;
117
+ if (previousScrollPosition && scrollPosition.scrollTop === previousScrollPosition.scrollTop && scrollPosition.scrollLeft === previousScrollPosition.scrollLeft) {
118
+ return;
119
+ }
120
+ // react-window may not have rendered the previous event's position
121
+ // yet, so the ref must reflect every forwarded event, not only the
122
+ // positions react-window reports back through its `onScroll` prop.
123
+ scrollPositionRef.current = scrollPosition;
124
+ }
125
+ onScroll(event);
126
+ }, [onScroll, direction, scrollPositionRef]);
127
+ return ___EmotionJSX(Element, _extends({
128
+ ref: ref,
129
+ onScroll: onScrollIfMoved
130
+ }, rest));
131
+ });
132
+ OuterElement.displayName = 'EuiDataGridOuterElement';
133
+ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref4) {
134
+ var leadingControlColumns = _ref4.leadingControlColumns,
135
+ trailingControlColumns = _ref4.trailingControlColumns,
136
+ columns = _ref4.columns,
137
+ visibleColCount = _ref4.visibleColCount,
138
+ schema = _ref4.schema,
139
+ schemaDetectors = _ref4.schemaDetectors,
140
+ rowCount = _ref4.rowCount,
141
+ _ref4$visibleRows = _ref4.visibleRows,
142
+ startRow = _ref4$visibleRows.startRow,
143
+ endRow = _ref4$visibleRows.endRow,
144
+ visibleRowCount = _ref4$visibleRows.visibleRowCount,
145
+ renderCellValue = _ref4.renderCellValue,
146
+ cellContext = _ref4.cellContext,
147
+ renderCellPopover = _ref4.renderCellPopover,
148
+ renderFooterCellValue = _ref4.renderFooterCellValue,
149
+ interactiveCellId = _ref4.interactiveCellId,
150
+ pagination = _ref4.pagination,
151
+ sorting = _ref4.sorting,
152
+ setVisibleColumns = _ref4.setVisibleColumns,
153
+ switchColumnPos = _ref4.switchColumnPos,
154
+ onColumnResize = _ref4.onColumnResize,
155
+ rowHeightsOptions = _ref4.rowHeightsOptions,
156
+ virtualizationOptions = _ref4.virtualizationOptions,
157
+ isFullScreen = _ref4.isFullScreen,
158
+ gridStyles = _ref4.gridStyles,
159
+ gridWidth = _ref4.gridWidth,
160
+ gridRef = _ref4.gridRef,
161
+ gridItemsRendered = _ref4.gridItemsRendered,
162
+ wrapperRef = _ref4.wrapperRef,
163
+ className = _ref4.className,
164
+ canDragAndDropColumns = _ref4.canDragAndDropColumns,
165
+ _ref4$showHeader = _ref4.showHeader,
166
+ showHeader = _ref4$showHeader === void 0 ? true : _ref4$showHeader;
113
167
  /**
114
168
  * Grid refs & observers
115
169
  */
@@ -305,7 +359,30 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
305
359
  footerRow: footerRow
306
360
  };
307
361
  }, [headerRowHeight, headerRow, footerRow, showHeader]);
362
+ var scrollPositionRef = useRef(null);
363
+ var outerElementContextValue = useMemo(function () {
364
+ return {
365
+ outerElementType: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType,
366
+ direction: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction,
367
+ scrollPositionRef: scrollPositionRef
368
+ };
369
+ }, [virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction]);
308
370
  var onScroll = useCallback(function (args) {
371
+ var element = outerGridRef.current;
372
+ // `scrollTo` reports the requested offset, which can sit past the
373
+ // end. Storing that would replace the clamped position already
374
+ // taken from the DOM. Leave the ref unchanged instead of writing
375
+ // the clamped value: a scroll event that has not arrived yet still
376
+ // differs from the previous position and is forwarded.
377
+ var topInRange = element == null || args.scrollTop === clampScrollOffset(args.scrollTop, element.scrollHeight - element.clientHeight);
378
+ var leftInRange = element == null || args.scrollLeft === clampScrollOffset(args.scrollLeft, element.scrollWidth - element.clientWidth);
379
+ if (topInRange && leftInRange) {
380
+ scrollPositionRef.current = {
381
+ scrollTop: args.scrollTop,
382
+ scrollLeft: args.scrollLeft
383
+ };
384
+ }
385
+
309
386
  // check only if a callback is passed
310
387
  if (typeof (virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.onScroll) !== 'function') return;
311
388
  var enhancedArgs = _objectSpread(_objectSpread({}, args), {}, {
@@ -349,10 +426,13 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
349
426
  }, [outerGridRef, virtualizationOptions]);
350
427
  return IS_JEST_ENVIRONMENT || finalWidth > 0 ? ___EmotionJSX(DataGridWrapperRowsContext.Provider, {
351
428
  value: rowWrapperContextValue
429
+ }, ___EmotionJSX(DataGridOuterElementContext.Provider, {
430
+ value: outerElementContextValue
352
431
  }, ___EmotionJSX(Grid, _extends({}, virtualizationOptions, {
353
432
  ref: gridRef,
354
433
  className: classNames('euiDataGrid__virtualized', className, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.className),
355
434
  onItemsRendered: onItemsRendered,
435
+ outerElementType: OuterElement,
356
436
  innerElementType: InnerElement,
357
437
  outerRef: outerGridRef,
358
438
  innerRef: innerGridRef,
@@ -364,6 +444,6 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
364
444
  itemData: itemData,
365
445
  rowCount: IS_JEST_ENVIRONMENT || headerRowHeight > 0 || showHeader === false && innerGridRef.current ? visibleRowCount : 0,
366
446
  onScroll: onScroll
367
- }), Cell), scrollBorderOverlay) : null;
447
+ }), Cell)), scrollBorderOverlay) : null;
368
448
  });
369
449
  EuiDataGridBodyVirtualized.displayName = 'EuiDataGridBodyVirtualized';
@@ -295,7 +295,10 @@ export var useRowHeightUtils = function useRowHeightUtils(_ref3) {
295
295
  if (forceRenderRef.current == null) {
296
296
  return;
297
297
  }
298
- requestAnimationFrame(forceRenderRef.current);
298
+ var frameId = requestAnimationFrame(forceRenderRef.current);
299
+ return function () {
300
+ return cancelAnimationFrame(frameId);
301
+ };
299
302
  }, [// Effects that should cause rerendering
300
303
  rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight, rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.rowHeights,
301
304
  // Dependencies
@@ -22,7 +22,7 @@ var _ref = process.env.NODE_ENV === "production" ? {
22
22
  export var euiFlyoutCloseButtonStyles = function euiFlyoutCloseButtonStyles(euiThemeContext) {
23
23
  var euiTheme = euiThemeContext.euiTheme;
24
24
  return {
25
- euiFlyout__closeButton: /*#__PURE__*/css("position:absolute;", logicalCSS('right', euiTheme.size.s), " ", logicalCSS('top', euiTheme.size.s), " z-index:3;;label:euiFlyout__closeButton;"),
25
+ euiFlyout__closeButton: /*#__PURE__*/css("position:absolute;", logicalCSS('right', euiTheme.size.s), " ", logicalCSS('top', euiTheme.size.m), " z-index:3;;label:euiFlyout__closeButton;"),
26
26
  inside: _ref,
27
27
  outside: /*#__PURE__*/css(euiShadowXLarge(euiThemeContext, {
28
28
  borderAllInHighContrastMode: true
@@ -1,8 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
6
6
  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"];
7
7
  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; }
8
8
  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; }
@@ -18,7 +18,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
18
18
 
19
19
  import React, { useEffect, useLayoutEffect, useRef, useMemo, useCallback, useState, forwardRef } from 'react';
20
20
  import classnames from 'classnames';
21
- import { keys, EuiWindowEvent, useCombinedRefs, useEuiTheme, useEuiMemoizedStyles, useGeneratedHtmlId, useEuiThemeCSSVariables, focusTrapPubSub } from '../../services';
21
+ import { keys, EuiWindowEvent, useCombinedRefs, useEuiTheme, useEuiMemoizedStyles, useGeneratedHtmlId, focusTrapPubSub } from '../../services';
22
22
  import { useIsInManagedFlyout, useFlyoutId, useFlyoutManager } from './manager';
23
23
  import { LAYOUT_MODE_SIDE_BY_SIDE, LAYOUT_MODE_STACKED, LEVEL_MAIN, PROPERTY_LEVEL } from './manager/const';
24
24
  import { EuiFocusTrap } from '../focus_trap';
@@ -53,6 +53,52 @@ var resolveContainer = function resolveContainer(raw) {
53
53
  if (typeof HTMLElement === 'undefined') return null;
54
54
  return raw instanceof HTMLElement ? raw : null;
55
55
  };
56
+
57
+ /**
58
+ * Per-target push-flyout offset bookkeeping, shared across every flyout React root (they all
59
+ * render from this one module). Keyed by the element the offset is applied to — a `container` or
60
+ * `document.body` — so flyouts targeting different elements never contend.
61
+ *
62
+ * Instead of a single owner per side, every currently-pushed flyout records its width as a
63
+ * contribution and the applied offset is derived from the set (the widest contribution). Closing,
64
+ * resizing, or backgrounding any one flyout just updates its own entry, so the result no longer
65
+ * depends on open/close order or on cross-root effect ordering. The target's base (pre-flyout)
66
+ * inline padding is captured when the first contribution arrives and restored when the last one
67
+ * leaves. See https://github.com/elastic/eui/issues/9788.
68
+ */
69
+
70
+ var euiPushPaddingRegistry = new WeakMap();
71
+ var euiSideStyleKey = function euiSideStyleKey(side) {
72
+ return side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
73
+ };
74
+ var euiSideCssVarKey = function euiSideCssVarKey(side) {
75
+ return side === 'left' ? '--euiPushFlyoutOffsetInlineStart' : '--euiPushFlyoutOffsetInlineEnd';
76
+ };
77
+ var euiGetPushPaddingSideState = function euiGetPushPaddingSideState(target, side) {
78
+ var state = euiPushPaddingRegistry.get(target);
79
+ if (!state) {
80
+ state = {
81
+ left: {
82
+ base: '',
83
+ contributions: new Map()
84
+ },
85
+ right: {
86
+ base: '',
87
+ contributions: new Map()
88
+ }
89
+ };
90
+ euiPushPaddingRegistry.set(target, state);
91
+ }
92
+ return state[side];
93
+ };
94
+ var euiMaxContribution = function euiMaxContribution(contributions) {
95
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
96
+ return true;
97
+ };
98
+ return Math.max.apply(Math, [0].concat(_toConsumableArray(Array.from(contributions.values(), function (contribution) {
99
+ return filter(contribution) ? contribution.width : 0;
100
+ }))));
101
+ };
56
102
  var defaultElement = 'div';
57
103
  export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
58
104
  var _maskProps$headerZind, _managerSessions, _managerState$layoutM, _managerState$current, _managerState$flyouts, _managerState$pushPad;
@@ -107,8 +153,6 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
107
153
  var container = resolveContainer(containerProp);
108
154
  var hasAnimationDefault = type === 'overlay';
109
155
  var hasAnimation = _hasAnimation !== null && _hasAnimation !== void 0 ? _hasAnimation : hasAnimationDefault;
110
- var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
111
- setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
112
156
  var Element = as || defaultElement;
113
157
  var maskRef = useRef(null);
114
158
 
@@ -125,10 +169,6 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
125
169
  pushMinBreakpoint: pushMinBreakpoint,
126
170
  containerWidth: containerReferenceWidth
127
171
  });
128
- // When no explicit container is provided, push padding targets
129
- // document.body and global push-offset CSS vars are set. When a
130
- // container is provided, only that element receives padding.
131
- var shouldSetGlobalPushVars = container == null;
132
172
  if ('container' in props && ('maskProps' in props || 'includeFixedHeadersInFocusTrap' in props) && process.env.NODE_ENV === 'development') {
133
173
  if ('maskProps' in props) {
134
174
  console.warn('EuiFlyout: `maskProps` is deprecated. Prefer using the `container` prop to scope flyouts.');
@@ -199,22 +239,33 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
199
239
  }
200
240
  }, [isInManagedContext, flyoutId]);
201
241
 
202
- // Derive flyout identity and sibling info from the single context read
242
+ // Derive flyout identity and sibling info from the session this flyout
243
+ // belongs to. Not the current (top-most) session: a newly opened main
244
+ // renders once before it registers its own session, and a backgrounded
245
+ // main is not in the current session at all. Reading the current session
246
+ // in those cases would treat the other session's main as this flyout's
247
+ // sibling and clamp the resizable width against it.
248
+ var ownSession = useMemo(function () {
249
+ var _managerSessions$find;
250
+ return (_managerSessions$find = managerSessions === null || managerSessions === void 0 ? void 0 : managerSessions.find(function (session) {
251
+ return session.mainFlyoutId === flyoutId || session.childFlyoutId === flyoutId;
252
+ })) !== null && _managerSessions$find !== void 0 ? _managerSessions$find : null;
253
+ }, [managerSessions, flyoutId]);
203
254
  var flyoutIdentity = useMemo(function () {
204
- if (!flyoutId || !currentSession) {
255
+ if (!flyoutId || !ownSession) {
205
256
  return {
206
257
  isMainFlyout: false,
207
258
  siblingFlyoutId: null,
208
259
  hasValidSession: false
209
260
  };
210
261
  }
211
- var siblingFlyoutId = currentSession.mainFlyoutId === flyoutId ? currentSession.childFlyoutId : currentSession.mainFlyoutId;
262
+ var siblingFlyoutId = ownSession.mainFlyoutId === flyoutId ? ownSession.childFlyoutId : ownSession.mainFlyoutId;
212
263
  return {
213
- isMainFlyout: currentSession.mainFlyoutId === flyoutId,
264
+ isMainFlyout: ownSession.mainFlyoutId === flyoutId,
214
265
  siblingFlyoutId: siblingFlyoutId,
215
266
  hasValidSession: true
216
267
  };
217
- }, [flyoutId, currentSession]);
268
+ }, [flyoutId, ownSession]);
218
269
 
219
270
  // Destructure for easier use
220
271
  var siblingFlyoutId = flyoutIdentity.siblingFlyoutId,
@@ -295,17 +346,24 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
295
346
  // the document element so that the child (fill) flyout can track it
296
347
  // synchronously during drag resize, avoiding the 1-frame lag that
297
348
  // results from the async ResizeObserver → manager-state pipeline.
349
+ // Only the active session's main publishes: a backgrounded main keeps its
350
+ // `isMainFlyout` role but must not leave its width behind for the new
351
+ // session's child to read.
298
352
  useLayoutEffect(function () {
299
- if (!isMainFlyout) return;
353
+ if (!isMainFlyout || !isActiveManagedFlyout) return;
300
354
 
301
355
  // Only set when we have a computed percentage (during active resize)
302
- if (typeof size === 'string' && size.endsWith('%')) {
303
- document.documentElement.style.setProperty('--euiFlyoutMainWidth', size);
304
- }
356
+ if (typeof size !== 'string' || !size.endsWith('%')) return;
357
+ var style = document.documentElement.style;
358
+ style.setProperty('--euiFlyoutMainWidth', size);
305
359
  return function () {
306
- document.documentElement.style.removeProperty('--euiFlyoutMainWidth');
360
+ // Flyouts in separate React roots can run this cleanup after another
361
+ // main has already published its own width; leave that value alone.
362
+ if (style.getPropertyValue('--euiFlyoutMainWidth') === size) {
363
+ style.removeProperty('--euiFlyoutMainWidth');
364
+ }
307
365
  };
308
- }, [isMainFlyout, size]);
366
+ }, [isMainFlyout, isActiveManagedFlyout, size]);
309
367
 
310
368
  /**
311
369
  * Setting up the refs on the actual flyout element in order to
@@ -325,45 +383,61 @@ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
325
383
  * Uses useLayoutEffect so padding is applied before child render.
326
384
  */
327
385
  useLayoutEffect(function () {
328
- if (!isPushed) {
329
- return;
330
- }
331
386
  var paddingTarget = container !== null && container !== void 0 ? container : document.body;
332
- var shouldApplyPadding = !isInManagedContext || isActiveManagedFlyout;
333
- var paddingSide = side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
334
- var cssVarName = "--euiPushFlyoutOffset".concat(side === 'left' ? 'InlineStart' : 'InlineEnd');
335
387
  var managerSide = side === 'left' ? 'left' : 'right';
388
+ var styleKey = euiSideStyleKey(managerSide);
389
+ var state = euiGetPushPaddingSideState(paddingTarget, managerSide);
336
390
 
337
- // Capture pre-existing inline padding so it can be restored on cleanup
338
- var previousPadding = paddingTarget.style[paddingSide];
339
- var paddingWidth = layoutMode === LAYOUT_MODE_STACKED && isMainFlyout && _siblingFlyoutWidth ? _siblingFlyoutWidth : width;
340
- if (shouldApplyPadding) {
341
- paddingTarget.style[paddingSide] = "".concat(paddingWidth, "px");
342
- if (shouldSetGlobalPushVars) {
343
- setGlobalCSSVariables(_defineProperty({}, cssVarName, "".concat(paddingWidth, "px")));
344
- }
345
- if (isInManagedContext && flyoutManagerRef.current) {
346
- flyoutManagerRef.current.setPushPadding(managerSide, paddingWidth);
347
- }
348
- } else {
349
- paddingTarget.style[paddingSide] = previousPadding;
350
- if (shouldSetGlobalPushVars) {
351
- setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
391
+ // Write the offset derived from all current contributions: the widest pushed flyout on
392
+ // this target.
393
+ var apply = function apply() {
394
+ var total = euiMaxContribution(state.contributions);
395
+ var isPushing = state.contributions.size > 0;
396
+ paddingTarget.style[styleKey] = isPushing ? "".concat(total, "px") : state.base;
397
+ // Without a `container` the offset is also exposed as a global CSS variable. It is
398
+ // written inline on `<html>` rather than through `EuiProvider`, because every React root
399
+ // has its own provider rendering its own `:root` block and the last one inserted would
400
+ // win regardless of which root's flyouts are still open.
401
+ if (container == null) {
402
+ var cssVar = euiSideCssVarKey(managerSide);
403
+ if (isPushing) {
404
+ document.documentElement.style.setProperty(cssVar, "".concat(total, "px"));
405
+ } else {
406
+ document.documentElement.style.removeProperty(cssVar);
407
+ }
352
408
  }
353
- if (isInManagedContext && flyoutManagerRef.current) {
354
- flyoutManagerRef.current.setPushPadding(managerSide, 0);
409
+ // The manager only learns about managed flyouts, so it must not be told about a standalone
410
+ // flyout's width: nothing would ever reset it once that flyout closes.
411
+ if (isInManagedContext) {
412
+ var _flyoutManagerRef$cur5;
413
+ (_flyoutManagerRef$cur5 = flyoutManagerRef.current) === null || _flyoutManagerRef$cur5 === void 0 || _flyoutManagerRef$cur5.setPushPadding(managerSide, euiMaxContribution(state.contributions, function (c) {
414
+ return c.managed;
415
+ }));
355
416
  }
417
+ };
418
+ var paddingWidth = layoutMode === LAYOUT_MODE_STACKED && isMainFlyout && _siblingFlyoutWidth ? _siblingFlyoutWidth : width;
419
+
420
+ // A standalone flyout pushes whenever it is in push mode. A managed flyout only pushes while
421
+ // it is the active session's flyout; a backgrounded push flyout (e.g. under a new overlay
422
+ // session) withdraws its contribution so the page is not left pushed for it.
423
+ var shouldPush = isPushed && (!isInManagedContext || isActiveManagedFlyout);
424
+ if (!shouldPush) {
425
+ return;
356
426
  }
427
+ if (state.contributions.size === 0) {
428
+ // First pushed flyout on this side: capture the app's own inline padding to restore later.
429
+ state.base = paddingTarget.style[styleKey];
430
+ }
431
+ state.contributions.set(flyoutId, {
432
+ width: paddingWidth,
433
+ managed: isInManagedContext
434
+ });
435
+ apply();
357
436
  return function () {
358
- paddingTarget.style[paddingSide] = previousPadding;
359
- if (shouldSetGlobalPushVars) {
360
- setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
361
- }
362
- if (isInManagedContext && flyoutManagerRef.current) {
363
- flyoutManagerRef.current.setPushPadding(managerSide, 0);
364
- }
437
+ state.contributions.delete(flyoutId);
438
+ apply();
365
439
  };
366
- }, [isPushed, isInManagedContext, isActiveManagedFlyout, setGlobalCSSVariables, side, width, layoutMode, isMainFlyout, _siblingFlyoutWidth, shouldSetGlobalPushVars, container]);
440
+ }, [isPushed, isInManagedContext, isActiveManagedFlyout, side, width, layoutMode, isMainFlyout, _siblingFlyoutWidth, container, flyoutId]);
367
441
 
368
442
  /**
369
443
  * This class doesn't actually do anything by EUI, but is nice to add for consumers (JIC)
@@ -1,4 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["toolTipContent", "toolTipProps"];
2
4
  /*
3
5
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
4
6
  * or more contributor license agreements. Licensed under the Elastic License
@@ -13,29 +15,20 @@ import { EuiToolTip } from '../../tool_tip';
13
15
  import { jsx as ___EmotionJSX } from "@emotion/react";
14
16
  export var MenuActionButton = function MenuActionButton(_ref) {
15
17
  var action = _ref.action;
16
- var iconType = action.iconType,
17
- onClick = action.onClick,
18
- ariaLabel = action['aria-label'],
19
- toolTipContent = action.toolTipContent,
18
+ var toolTipContent = action.toolTipContent,
20
19
  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
- };
20
+ buttonProps = _objectWithoutProperties(action, _excluded);
21
+ var button = ___EmotionJSX(EuiButtonIcon, _extends({}, buttonProps, {
22
+ // The menu bar sets these props itself so every action looks the same.
23
+ // Anything set here also belongs in `EuiFlyoutMenuOwnedActionProps`.
24
+ color: "text",
25
+ size: "xs",
26
+ display: "empty",
27
+ iconSize: "m",
28
+ isSelected: undefined
29
+ }));
37
30
  return toolTipContent ? ___EmotionJSX(EuiToolTip, _extends({
38
31
  content: toolTipContent,
39
32
  disableScreenReaderOutput: true
40
- }, toolTipProps), ___EmotionJSX(EuiButtonIcon, sharedProps)) : ___EmotionJSX(EuiButtonIcon, sharedProps);
33
+ }, toolTipProps), button) : button;
41
34
  };
@@ -18,14 +18,20 @@ var _ref = process.env.NODE_ENV === "production" ? {
18
18
  styles: "align-self:center;label:euiFlyoutMenu__actions;",
19
19
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
20
20
  };
21
+ var _ref2 = process.env.NODE_ENV === "production" ? {
22
+ name: "2o24qf-euiFlyoutMenu__controls",
23
+ styles: "block-size:100%;label:euiFlyoutMenu__controls;"
24
+ } : {
25
+ name: "2o24qf-euiFlyoutMenu__controls",
26
+ styles: "block-size:100%;label:euiFlyoutMenu__controls;",
27
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
28
+ };
21
29
  export var euiFlyoutMenuStyles = function euiFlyoutMenuStyles(euiThemeContext) {
22
30
  var euiTheme = euiThemeContext.euiTheme;
23
31
  return {
24
- euiFlyoutMenu__container: /*#__PURE__*/css("block-size:calc(", euiTheme.size.m, " * 3.5);flex-shrink:0;padding-block:", euiTheme.size.s, ";padding-inline:", euiTheme.size.s, ";border-block-end:", euiTheme.border.width.thin, " solid ", euiTheme.border.color, ";.euiTitle{padding-inline:", euiTheme.size.s, ";};label:euiFlyoutMenu__container;"),
32
+ euiFlyoutMenu__container: /*#__PURE__*/css("block-size:", euiTheme.size.xxxl, ";flex-shrink:0;padding-block:", euiTheme.size.s, ";padding-inline:", euiTheme.size.s, ";border-block-end:", euiTheme.border.width.thin, " solid ", euiTheme.border.color, ";.euiTitle{padding-inline:", euiTheme.size.s, ";};label:euiFlyoutMenu__container;"),
25
33
  // Full height in high contrast mode so dividers can bleed to the container edges.
26
- euiFlyoutMenu__controls: /*#__PURE__*/css(highContrastModeStyles(euiThemeContext, {
27
- preferred: 'block-size: 100%;'
28
- }), ";;label:euiFlyoutMenu__controls;"),
34
+ euiFlyoutMenu__controls: _ref2,
29
35
  euiFlyoutMenu__spacer: /*#__PURE__*/css("padding-inline:", euiTheme.size.m, ";;label:euiFlyoutMenu__spacer;"),
30
36
  euiFlyoutMenu__actions: _ref,
31
37
  euiFlyoutMenu__hiddenTitle: /*#__PURE__*/css(euiScreenReaderOnly(), ";;label:euiFlyoutMenu__hiddenTitle;"),
@@ -14,7 +14,7 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
14
14
  * Side Public License, v 1.
15
15
  */
16
16
 
17
- import React, { useEffect, useLayoutEffect, useMemo, useRef, useState, forwardRef } from 'react';
17
+ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, forwardRef } from 'react';
18
18
  import { css } from '@emotion/react';
19
19
  import { flushSync } from 'react-dom';
20
20
  import { useCombinedRefs, useEuiMemoizedStyles } from '../../../services';
@@ -167,6 +167,24 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
167
167
  flyoutExistsInManagerRef.current = flyoutExistsInManager;
168
168
  }, [flyoutExistsInManager]);
169
169
 
170
+ // Closing a main closes its whole history group via `closeAllFlyouts`, which always targets
171
+ // the *current* session. A main that has been backgrounded by a newer session (e.g. closed
172
+ // programmatically from another React root) must only remove its own session, otherwise it
173
+ // tears down the foreground session and leaves its own stale session behind.
174
+ var closeOwnFlyouts = useCallback(function () {
175
+ if (level !== LEVEL_MAIN) {
176
+ closeFlyout(flyoutId);
177
+ return;
178
+ }
179
+ var _getFlyoutManagerStor = getFlyoutManagerStore().getState(),
180
+ sessions = _getFlyoutManagerStor.sessions;
181
+ var ownSession = sessions.find(function (session) {
182
+ return session.mainFlyoutId === flyoutId;
183
+ });
184
+ var isBackgroundedMain = ownSession != null && ownSession !== sessions[sessions.length - 1];
185
+ isBackgroundedMain ? closeFlyout(flyoutId) : closeAllFlyouts();
186
+ }, [level, flyoutId, closeFlyout, closeAllFlyouts]);
187
+
170
188
  // Register with flyout manager context when open, remove when closed
171
189
  // Using useLayoutEffect to run synchronously before DOM updates
172
190
  useLayoutEffect(function () {
@@ -178,7 +196,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
178
196
  });
179
197
  if (stillInStore) {
180
198
  // Normal cleanup (deps changed or explicit close via isOpen=false)
181
- level === LEVEL_MAIN ? closeAllFlyouts() : closeFlyout(flyoutId);
199
+ closeOwnFlyouts();
182
200
  } else if (wasRegisteredRef.current) {
183
201
  var _onCloseCallbackRef$c, _store$consumeCloseMe;
184
202
  // Removed externally while mounted: forward the store-stamped reason
@@ -189,7 +207,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
189
207
  }
190
208
  wasRegisteredRef.current = false;
191
209
  };
192
- }, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout, closeFlyout, closeAllFlyouts]);
210
+ }, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout, closeOwnFlyouts]);
193
211
 
194
212
  // Detect when flyout has been removed from manager state (e.g., via Back button)
195
213
  // and trigger onClose callback to notify the parent component
@@ -204,8 +222,8 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
204
222
  // any other removal (e.g. a closeAllFlyouts cascade reaching a backgrounded
205
223
  // flyout) defaults to `navigation-cascade`.
206
224
  if (wasRegisteredRef.current && !flyoutExistsInManager) {
207
- var _onCloseCallbackRef$c2, _getFlyoutManagerStor;
208
- (_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'), (_getFlyoutManagerStor = getFlyoutManagerStore().consumeCloseMeta(flyoutId)) !== null && _getFlyoutManagerStor !== void 0 ? _getFlyoutManagerStor : {
225
+ var _onCloseCallbackRef$c2, _getFlyoutManagerStor2;
226
+ (_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'), (_getFlyoutManagerStor2 = getFlyoutManagerStore().consumeCloseMeta(flyoutId)) !== null && _getFlyoutManagerStor2 !== void 0 ? _getFlyoutManagerStor2 : {
209
227
  reason: 'navigation-cascade'
210
228
  });
211
229
  wasRegisteredRef.current = false; // Reset to avoid repeated calls
@@ -242,7 +260,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
242
260
  // and ensures cascade close logic runs before DOM cleanup begins
243
261
  // Using flushSync to force synchronous state update completion
244
262
  flushSync(function () {
245
- level === LEVEL_MAIN ? closeAllFlyouts() : closeFlyout(flyoutId);
263
+ closeOwnFlyouts();
246
264
  });
247
265
  if (onCloseCallbackRef.current) {
248
266
  var event = e || new MouseEvent('click');