@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.
- package/dist/eui-icons.json +94 -94
- package/es/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/es/components/datagrid/utils/row_heights.js +4 -1
- package/es/components/flyout/flyout.component.js +129 -55
- package/es/components/flyout/flyout_menu/action_button.js +15 -21
- package/es/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/es/components/flyout/manager/flyout_managed.js +24 -6
- package/es/components/form/described_form_group/described_form_group.js +17 -4
- package/es/components/tabs/tabbed_content/tabbed_content.js +93 -138
- package/es/components/text_truncate/text_truncate.js +9 -4
- package/eui.d.ts +32 -58
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/lib/components/datagrid/utils/row_heights.js +4 -1
- package/lib/components/flyout/flyout.component.js +134 -62
- package/lib/components/flyout/flyout_menu/action_button.js +18 -23
- package/lib/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/lib/components/flyout/manager/flyout_managed.js +23 -5
- package/lib/components/form/described_form_group/described_form_group.js +19 -3
- package/lib/components/tabs/tabbed_content/tabbed_content.js +98 -142
- package/lib/components/text_truncate/text_truncate.js +9 -4
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +116 -36
- package/optimize/es/components/datagrid/utils/row_heights.js +4 -1
- package/optimize/es/components/flyout/flyout.component.js +124 -50
- package/optimize/es/components/flyout/flyout_menu/action_button.js +14 -21
- package/optimize/es/components/flyout/manager/flyout_managed.js +24 -6
- package/optimize/es/components/form/described_form_group/described_form_group.js +17 -4
- package/optimize/es/components/tabs/tabbed_content/tabbed_content.js +87 -131
- package/optimize/es/components/text_truncate/text_truncate.js +4 -3
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +116 -36
- package/optimize/lib/components/datagrid/utils/row_heights.js +4 -1
- package/optimize/lib/components/flyout/flyout.component.js +123 -49
- package/optimize/lib/components/flyout/flyout_menu/action_button.js +14 -22
- package/optimize/lib/components/flyout/manager/flyout_managed.js +23 -5
- package/optimize/lib/components/form/described_form_group/described_form_group.js +19 -3
- package/optimize/lib/components/tabs/tabbed_content/tabbed_content.js +87 -131
- package/optimize/lib/components/text_truncate/text_truncate.js +4 -3
- package/package.json +2 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/test-env/components/datagrid/utils/row_heights.js +4 -1
- package/test-env/components/flyout/flyout.component.js +123 -49
- package/test-env/components/flyout/flyout_menu/action_button.js +14 -22
- package/test-env/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/test-env/components/flyout/manager/flyout_managed.js +23 -5
- package/test-env/components/form/described_form_group/described_form_group.js +19 -3
- package/test-env/components/tabs/tabbed_content/tabbed_content.js +88 -132
- package/test-env/components/text_truncate/text_truncate.js +9 -4
|
@@ -28,22 +28,10 @@ var _flyout_parent_context = require("./flyout_parent_context");
|
|
|
28
28
|
var _use_flyout_menu = require("./use_flyout_menu");
|
|
29
29
|
var _react2 = require("@emotion/react");
|
|
30
30
|
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"];
|
|
31
|
-
/*
|
|
32
|
-
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
33
|
-
* or more contributor license agreements. Licensed under the Elastic License
|
|
34
|
-
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
35
|
-
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
36
|
-
* Side Public License, v 1.
|
|
37
|
-
*/
|
|
38
|
-
/* eslint-disable local/i18n */
|
|
39
31
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
40
32
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
41
33
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
42
34
|
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); }
|
|
43
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
44
|
-
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."); }
|
|
45
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
46
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
47
35
|
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; }
|
|
48
36
|
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; }
|
|
49
37
|
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; }
|
|
@@ -51,12 +39,22 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
51
39
|
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); }
|
|
52
40
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
53
41
|
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."); }
|
|
54
|
-
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; } }
|
|
55
|
-
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; }
|
|
56
42
|
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; } }
|
|
57
43
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
58
44
|
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; }
|
|
59
45
|
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; }
|
|
46
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
47
|
+
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."); }
|
|
48
|
+
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; } }
|
|
49
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
50
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
51
|
+
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; } /*
|
|
52
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
53
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
54
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
55
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
56
|
+
* Side Public License, v 1.
|
|
57
|
+
*/ /* eslint-disable local/i18n */
|
|
60
58
|
/**
|
|
61
59
|
* Resolves the container prop (element, getter, or selector string) to an
|
|
62
60
|
* HTMLElement, or null if not found / invalid.
|
|
@@ -72,6 +70,52 @@ var resolveContainer = function resolveContainer(raw) {
|
|
|
72
70
|
if (typeof HTMLElement === 'undefined') return null;
|
|
73
71
|
return raw instanceof HTMLElement ? raw : null;
|
|
74
72
|
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Per-target push-flyout offset bookkeeping, shared across every flyout React root (they all
|
|
76
|
+
* render from this one module). Keyed by the element the offset is applied to — a `container` or
|
|
77
|
+
* `document.body` — so flyouts targeting different elements never contend.
|
|
78
|
+
*
|
|
79
|
+
* Instead of a single owner per side, every currently-pushed flyout records its width as a
|
|
80
|
+
* contribution and the applied offset is derived from the set (the widest contribution). Closing,
|
|
81
|
+
* resizing, or backgrounding any one flyout just updates its own entry, so the result no longer
|
|
82
|
+
* depends on open/close order or on cross-root effect ordering. The target's base (pre-flyout)
|
|
83
|
+
* inline padding is captured when the first contribution arrives and restored when the last one
|
|
84
|
+
* leaves. See https://github.com/elastic/eui/issues/9788.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
var euiPushPaddingRegistry = new WeakMap();
|
|
88
|
+
var euiSideStyleKey = function euiSideStyleKey(side) {
|
|
89
|
+
return side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
|
|
90
|
+
};
|
|
91
|
+
var euiSideCssVarKey = function euiSideCssVarKey(side) {
|
|
92
|
+
return side === 'left' ? '--euiPushFlyoutOffsetInlineStart' : '--euiPushFlyoutOffsetInlineEnd';
|
|
93
|
+
};
|
|
94
|
+
var euiGetPushPaddingSideState = function euiGetPushPaddingSideState(target, side) {
|
|
95
|
+
var state = euiPushPaddingRegistry.get(target);
|
|
96
|
+
if (!state) {
|
|
97
|
+
state = {
|
|
98
|
+
left: {
|
|
99
|
+
base: '',
|
|
100
|
+
contributions: new Map()
|
|
101
|
+
},
|
|
102
|
+
right: {
|
|
103
|
+
base: '',
|
|
104
|
+
contributions: new Map()
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
euiPushPaddingRegistry.set(target, state);
|
|
108
|
+
}
|
|
109
|
+
return state[side];
|
|
110
|
+
};
|
|
111
|
+
var euiMaxContribution = function euiMaxContribution(contributions) {
|
|
112
|
+
var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {
|
|
113
|
+
return true;
|
|
114
|
+
};
|
|
115
|
+
return Math.max.apply(Math, [0].concat(_toConsumableArray(Array.from(contributions.values(), function (contribution) {
|
|
116
|
+
return filter(contribution) ? contribution.width : 0;
|
|
117
|
+
}))));
|
|
118
|
+
};
|
|
75
119
|
var defaultElement = 'div';
|
|
76
120
|
var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
77
121
|
var _maskProps$headerZind, _managerSessions, _managerState$layoutM, _managerState$current, _managerState$flyouts, _managerState$pushPad;
|
|
@@ -126,8 +170,6 @@ var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.fo
|
|
|
126
170
|
var container = resolveContainer(containerProp);
|
|
127
171
|
var hasAnimationDefault = type === 'overlay';
|
|
128
172
|
var hasAnimation = _hasAnimation !== null && _hasAnimation !== void 0 ? _hasAnimation : hasAnimationDefault;
|
|
129
|
-
var _useEuiThemeCSSVariab = (0, _services.useEuiThemeCSSVariables)(),
|
|
130
|
-
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
131
173
|
var Element = as || defaultElement;
|
|
132
174
|
var maskRef = (0, _react.useRef)(null);
|
|
133
175
|
|
|
@@ -144,10 +186,6 @@ var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.fo
|
|
|
144
186
|
pushMinBreakpoint: pushMinBreakpoint,
|
|
145
187
|
containerWidth: containerReferenceWidth
|
|
146
188
|
});
|
|
147
|
-
// When no explicit container is provided, push padding targets
|
|
148
|
-
// document.body and global push-offset CSS vars are set. When a
|
|
149
|
-
// container is provided, only that element receives padding.
|
|
150
|
-
var shouldSetGlobalPushVars = container == null;
|
|
151
189
|
if ('container' in props && ('maskProps' in props || 'includeFixedHeadersInFocusTrap' in props) && process.env.NODE_ENV === 'development') {
|
|
152
190
|
if ('maskProps' in props) {
|
|
153
191
|
console.warn('EuiFlyout: `maskProps` is deprecated. Prefer using the `container` prop to scope flyouts.');
|
|
@@ -218,22 +256,33 @@ var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.fo
|
|
|
218
256
|
}
|
|
219
257
|
}, [isInManagedContext, flyoutId]);
|
|
220
258
|
|
|
221
|
-
// Derive flyout identity and sibling info from the
|
|
259
|
+
// Derive flyout identity and sibling info from the session this flyout
|
|
260
|
+
// belongs to. Not the current (top-most) session: a newly opened main
|
|
261
|
+
// renders once before it registers its own session, and a backgrounded
|
|
262
|
+
// main is not in the current session at all. Reading the current session
|
|
263
|
+
// in those cases would treat the other session's main as this flyout's
|
|
264
|
+
// sibling and clamp the resizable width against it.
|
|
265
|
+
var ownSession = (0, _react.useMemo)(function () {
|
|
266
|
+
var _managerSessions$find;
|
|
267
|
+
return (_managerSessions$find = managerSessions === null || managerSessions === void 0 ? void 0 : managerSessions.find(function (session) {
|
|
268
|
+
return session.mainFlyoutId === flyoutId || session.childFlyoutId === flyoutId;
|
|
269
|
+
})) !== null && _managerSessions$find !== void 0 ? _managerSessions$find : null;
|
|
270
|
+
}, [managerSessions, flyoutId]);
|
|
222
271
|
var flyoutIdentity = (0, _react.useMemo)(function () {
|
|
223
|
-
if (!flyoutId || !
|
|
272
|
+
if (!flyoutId || !ownSession) {
|
|
224
273
|
return {
|
|
225
274
|
isMainFlyout: false,
|
|
226
275
|
siblingFlyoutId: null,
|
|
227
276
|
hasValidSession: false
|
|
228
277
|
};
|
|
229
278
|
}
|
|
230
|
-
var siblingFlyoutId =
|
|
279
|
+
var siblingFlyoutId = ownSession.mainFlyoutId === flyoutId ? ownSession.childFlyoutId : ownSession.mainFlyoutId;
|
|
231
280
|
return {
|
|
232
|
-
isMainFlyout:
|
|
281
|
+
isMainFlyout: ownSession.mainFlyoutId === flyoutId,
|
|
233
282
|
siblingFlyoutId: siblingFlyoutId,
|
|
234
283
|
hasValidSession: true
|
|
235
284
|
};
|
|
236
|
-
}, [flyoutId,
|
|
285
|
+
}, [flyoutId, ownSession]);
|
|
237
286
|
|
|
238
287
|
// Destructure for easier use
|
|
239
288
|
var siblingFlyoutId = flyoutIdentity.siblingFlyoutId,
|
|
@@ -314,17 +363,24 @@ var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.fo
|
|
|
314
363
|
// the document element so that the child (fill) flyout can track it
|
|
315
364
|
// synchronously during drag resize, avoiding the 1-frame lag that
|
|
316
365
|
// results from the async ResizeObserver → manager-state pipeline.
|
|
366
|
+
// Only the active session's main publishes: a backgrounded main keeps its
|
|
367
|
+
// `isMainFlyout` role but must not leave its width behind for the new
|
|
368
|
+
// session's child to read.
|
|
317
369
|
(0, _react.useLayoutEffect)(function () {
|
|
318
|
-
if (!isMainFlyout) return;
|
|
370
|
+
if (!isMainFlyout || !isActiveManagedFlyout) return;
|
|
319
371
|
|
|
320
372
|
// Only set when we have a computed percentage (during active resize)
|
|
321
|
-
if (typeof size
|
|
322
|
-
|
|
323
|
-
|
|
373
|
+
if (typeof size !== 'string' || !size.endsWith('%')) return;
|
|
374
|
+
var style = document.documentElement.style;
|
|
375
|
+
style.setProperty('--euiFlyoutMainWidth', size);
|
|
324
376
|
return function () {
|
|
325
|
-
|
|
377
|
+
// Flyouts in separate React roots can run this cleanup after another
|
|
378
|
+
// main has already published its own width; leave that value alone.
|
|
379
|
+
if (style.getPropertyValue('--euiFlyoutMainWidth') === size) {
|
|
380
|
+
style.removeProperty('--euiFlyoutMainWidth');
|
|
381
|
+
}
|
|
326
382
|
};
|
|
327
|
-
}, [isMainFlyout, size]);
|
|
383
|
+
}, [isMainFlyout, isActiveManagedFlyout, size]);
|
|
328
384
|
|
|
329
385
|
/**
|
|
330
386
|
* Setting up the refs on the actual flyout element in order to
|
|
@@ -344,45 +400,61 @@ var EuiFlyoutComponent = exports.EuiFlyoutComponent = /*#__PURE__*/(0, _react.fo
|
|
|
344
400
|
* Uses useLayoutEffect so padding is applied before child render.
|
|
345
401
|
*/
|
|
346
402
|
(0, _react.useLayoutEffect)(function () {
|
|
347
|
-
if (!isPushed) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
403
|
var paddingTarget = container !== null && container !== void 0 ? container : document.body;
|
|
351
|
-
var shouldApplyPadding = !isInManagedContext || isActiveManagedFlyout;
|
|
352
|
-
var paddingSide = side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
|
|
353
|
-
var cssVarName = "--euiPushFlyoutOffset".concat(side === 'left' ? 'InlineStart' : 'InlineEnd');
|
|
354
404
|
var managerSide = side === 'left' ? 'left' : 'right';
|
|
405
|
+
var styleKey = euiSideStyleKey(managerSide);
|
|
406
|
+
var state = euiGetPushPaddingSideState(paddingTarget, managerSide);
|
|
355
407
|
|
|
356
|
-
//
|
|
357
|
-
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
408
|
+
// Write the offset derived from all current contributions: the widest pushed flyout on
|
|
409
|
+
// this target.
|
|
410
|
+
var apply = function apply() {
|
|
411
|
+
var total = euiMaxContribution(state.contributions);
|
|
412
|
+
var isPushing = state.contributions.size > 0;
|
|
413
|
+
paddingTarget.style[styleKey] = isPushing ? "".concat(total, "px") : state.base;
|
|
414
|
+
// Without a `container` the offset is also exposed as a global CSS variable. It is
|
|
415
|
+
// written inline on `<html>` rather than through `EuiProvider`, because every React root
|
|
416
|
+
// has its own provider rendering its own `:root` block and the last one inserted would
|
|
417
|
+
// win regardless of which root's flyouts are still open.
|
|
418
|
+
if (container == null) {
|
|
419
|
+
var cssVar = euiSideCssVarKey(managerSide);
|
|
420
|
+
if (isPushing) {
|
|
421
|
+
document.documentElement.style.setProperty(cssVar, "".concat(total, "px"));
|
|
422
|
+
} else {
|
|
423
|
+
document.documentElement.style.removeProperty(cssVar);
|
|
424
|
+
}
|
|
371
425
|
}
|
|
372
|
-
|
|
373
|
-
|
|
426
|
+
// The manager only learns about managed flyouts, so it must not be told about a standalone
|
|
427
|
+
// flyout's width: nothing would ever reset it once that flyout closes.
|
|
428
|
+
if (isInManagedContext) {
|
|
429
|
+
var _flyoutManagerRef$cur5;
|
|
430
|
+
(_flyoutManagerRef$cur5 = flyoutManagerRef.current) === null || _flyoutManagerRef$cur5 === void 0 || _flyoutManagerRef$cur5.setPushPadding(managerSide, euiMaxContribution(state.contributions, function (c) {
|
|
431
|
+
return c.managed;
|
|
432
|
+
}));
|
|
374
433
|
}
|
|
434
|
+
};
|
|
435
|
+
var paddingWidth = layoutMode === _const.LAYOUT_MODE_STACKED && isMainFlyout && _siblingFlyoutWidth ? _siblingFlyoutWidth : width;
|
|
436
|
+
|
|
437
|
+
// A standalone flyout pushes whenever it is in push mode. A managed flyout only pushes while
|
|
438
|
+
// it is the active session's flyout; a backgrounded push flyout (e.g. under a new overlay
|
|
439
|
+
// session) withdraws its contribution so the page is not left pushed for it.
|
|
440
|
+
var shouldPush = isPushed && (!isInManagedContext || isActiveManagedFlyout);
|
|
441
|
+
if (!shouldPush) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
if (state.contributions.size === 0) {
|
|
445
|
+
// First pushed flyout on this side: capture the app's own inline padding to restore later.
|
|
446
|
+
state.base = paddingTarget.style[styleKey];
|
|
375
447
|
}
|
|
448
|
+
state.contributions.set(flyoutId, {
|
|
449
|
+
width: paddingWidth,
|
|
450
|
+
managed: isInManagedContext
|
|
451
|
+
});
|
|
452
|
+
apply();
|
|
376
453
|
return function () {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
|
|
380
|
-
}
|
|
381
|
-
if (isInManagedContext && flyoutManagerRef.current) {
|
|
382
|
-
flyoutManagerRef.current.setPushPadding(managerSide, 0);
|
|
383
|
-
}
|
|
454
|
+
state.contributions.delete(flyoutId);
|
|
455
|
+
apply();
|
|
384
456
|
};
|
|
385
|
-
}, [isPushed, isInManagedContext, isActiveManagedFlyout,
|
|
457
|
+
}, [isPushed, isInManagedContext, isActiveManagedFlyout, side, width, layoutMode, isMainFlyout, _siblingFlyoutWidth, container, flyoutId]);
|
|
386
458
|
|
|
387
459
|
/**
|
|
388
460
|
* This class doesn't actually do anything by EUI, but is nice to add for consumers (JIC)
|
|
@@ -8,39 +8,34 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _button = require("../../button");
|
|
9
9
|
var _tool_tip = require("../../tool_tip");
|
|
10
10
|
var _react2 = require("@emotion/react");
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var _excluded = ["toolTipContent", "toolTipProps"];
|
|
12
|
+
/*
|
|
13
13
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
14
14
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
15
15
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
16
16
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
17
17
|
* Side Public License, v 1.
|
|
18
18
|
*/
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
19
23
|
var MenuActionButton = exports.MenuActionButton = function MenuActionButton(_ref) {
|
|
20
24
|
var action = _ref.action;
|
|
21
|
-
var
|
|
22
|
-
onClick = action.onClick,
|
|
23
|
-
ariaLabel = action['aria-label'],
|
|
24
|
-
toolTipContent = action.toolTipContent,
|
|
25
|
+
var toolTipContent = action.toolTipContent,
|
|
25
26
|
toolTipProps = action.toolTipProps,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
isDisabled: isDisabled,
|
|
37
|
-
// Keeps the button focusable so tooltip-on-disabled works for keyboard users
|
|
38
|
-
isLoading: isLoading,
|
|
39
|
-
href: href,
|
|
40
|
-
target: target
|
|
41
|
-
};
|
|
27
|
+
buttonProps = _objectWithoutProperties(action, _excluded);
|
|
28
|
+
var button = (0, _react2.jsx)(_button.EuiButtonIcon, _extends({}, buttonProps, {
|
|
29
|
+
// The menu bar sets these props itself so every action looks the same.
|
|
30
|
+
// Anything set here also belongs in `EuiFlyoutMenuOwnedActionProps`.
|
|
31
|
+
color: "text",
|
|
32
|
+
size: "xs",
|
|
33
|
+
display: "empty",
|
|
34
|
+
iconSize: "m",
|
|
35
|
+
isSelected: undefined
|
|
36
|
+
}));
|
|
42
37
|
return toolTipContent ? (0, _react2.jsx)(_tool_tip.EuiToolTip, _extends({
|
|
43
38
|
content: toolTipContent,
|
|
44
39
|
disableScreenReaderOutput: true
|
|
45
|
-
}, toolTipProps),
|
|
40
|
+
}, toolTipProps), button) : button;
|
|
46
41
|
};
|
|
@@ -252,97 +252,91 @@ EuiFlyoutMenu.propTypes = {
|
|
|
252
252
|
/**
|
|
253
253
|
* List of action items rendered at the start (inline-start) of the menu bar.
|
|
254
254
|
*/
|
|
255
|
-
leadingActions: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
255
|
+
leadingActions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({
|
|
256
256
|
/**
|
|
257
|
-
*
|
|
257
|
+
* Aria label for the action button
|
|
258
258
|
*/
|
|
259
|
-
|
|
259
|
+
"aria-label": _propTypes.default.string.isRequired,
|
|
260
260
|
/**
|
|
261
261
|
* onClick handler for the action button
|
|
262
262
|
*/
|
|
263
263
|
onClick: _propTypes.default.func,
|
|
264
264
|
/**
|
|
265
|
-
*
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Optional tooltip content shown on hover/focus of the action button.
|
|
270
|
-
* When `isDisabled` is `true`, the action uses `aria-disabled` so the tooltip
|
|
271
|
-
* remains reachable via hover/focus (unless overridden via `toolTipProps`).
|
|
265
|
+
* Tooltip text shown on hover or focus.
|
|
266
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
267
|
+
* the button focusable so the tooltip remains reachable.
|
|
272
268
|
*/
|
|
273
269
|
toolTipContent: _propTypes.default.node,
|
|
274
270
|
/**
|
|
275
271
|
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
276
272
|
* Only used when `toolTipContent` is also provided.
|
|
277
273
|
*/
|
|
278
|
-
toolTipProps: _propTypes.default.any
|
|
274
|
+
toolTipProps: _propTypes.default.any
|
|
275
|
+
}).isRequired, _propTypes.default.shape({
|
|
279
276
|
/**
|
|
280
|
-
*
|
|
281
|
-
* the action is unavailable.
|
|
277
|
+
* Aria label for the action button
|
|
282
278
|
*/
|
|
283
|
-
|
|
279
|
+
"aria-label": _propTypes.default.string.isRequired,
|
|
284
280
|
/**
|
|
285
|
-
*
|
|
281
|
+
* onClick handler for the action button
|
|
286
282
|
*/
|
|
287
|
-
|
|
283
|
+
onClick: _propTypes.default.func,
|
|
288
284
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
285
|
+
* Tooltip text shown on hover or focus.
|
|
286
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
287
|
+
* the button focusable so the tooltip remains reachable.
|
|
292
288
|
*/
|
|
293
|
-
|
|
289
|
+
toolTipContent: _propTypes.default.node,
|
|
294
290
|
/**
|
|
295
|
-
*
|
|
291
|
+
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
292
|
+
* Only used when `toolTipContent` is also provided.
|
|
296
293
|
*/
|
|
297
|
-
|
|
298
|
-
}).isRequired),
|
|
294
|
+
toolTipProps: _propTypes.default.any
|
|
295
|
+
}).isRequired]).isRequired),
|
|
299
296
|
/**
|
|
300
297
|
* List of action items rendered at the end (inline-end) of the menu bar.
|
|
301
298
|
*/
|
|
302
|
-
trailingActions: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
299
|
+
trailingActions: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.shape({
|
|
303
300
|
/**
|
|
304
|
-
*
|
|
301
|
+
* Aria label for the action button
|
|
305
302
|
*/
|
|
306
|
-
|
|
303
|
+
"aria-label": _propTypes.default.string.isRequired,
|
|
307
304
|
/**
|
|
308
305
|
* onClick handler for the action button
|
|
309
306
|
*/
|
|
310
307
|
onClick: _propTypes.default.func,
|
|
311
308
|
/**
|
|
312
|
-
*
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Optional tooltip content shown on hover/focus of the action button.
|
|
317
|
-
* When `isDisabled` is `true`, the action uses `aria-disabled` so the tooltip
|
|
318
|
-
* remains reachable via hover/focus (unless overridden via `toolTipProps`).
|
|
309
|
+
* Tooltip text shown on hover or focus.
|
|
310
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
311
|
+
* the button focusable so the tooltip remains reachable.
|
|
319
312
|
*/
|
|
320
313
|
toolTipContent: _propTypes.default.node,
|
|
321
314
|
/**
|
|
322
315
|
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
323
316
|
* Only used when `toolTipContent` is also provided.
|
|
324
317
|
*/
|
|
325
|
-
toolTipProps: _propTypes.default.any
|
|
318
|
+
toolTipProps: _propTypes.default.any
|
|
319
|
+
}).isRequired, _propTypes.default.shape({
|
|
326
320
|
/**
|
|
327
|
-
*
|
|
328
|
-
* the action is unavailable.
|
|
321
|
+
* Aria label for the action button
|
|
329
322
|
*/
|
|
330
|
-
|
|
323
|
+
"aria-label": _propTypes.default.string.isRequired,
|
|
331
324
|
/**
|
|
332
|
-
*
|
|
325
|
+
* onClick handler for the action button
|
|
333
326
|
*/
|
|
334
|
-
|
|
327
|
+
onClick: _propTypes.default.func,
|
|
335
328
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
329
|
+
* Tooltip text shown on hover or focus.
|
|
330
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
331
|
+
* the button focusable so the tooltip remains reachable.
|
|
339
332
|
*/
|
|
340
|
-
|
|
333
|
+
toolTipContent: _propTypes.default.node,
|
|
341
334
|
/**
|
|
342
|
-
*
|
|
335
|
+
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
336
|
+
* Only used when `toolTipContent` is also provided.
|
|
343
337
|
*/
|
|
344
|
-
|
|
345
|
-
}).isRequired),
|
|
338
|
+
toolTipProps: _propTypes.default.any
|
|
339
|
+
}).isRequired]).isRequired),
|
|
346
340
|
/**
|
|
347
341
|
* List of custom action items for the menu component
|
|
348
342
|
* @deprecated Use `trailingActions` instead. If both are supplied, `trailingActions` takes precedence.
|
|
@@ -181,6 +181,24 @@ var EuiManagedFlyout = exports.EuiManagedFlyout = /*#__PURE__*/(0, _react.forwar
|
|
|
181
181
|
flyoutExistsInManagerRef.current = flyoutExistsInManager;
|
|
182
182
|
}, [flyoutExistsInManager]);
|
|
183
183
|
|
|
184
|
+
// Closing a main closes its whole history group via `closeAllFlyouts`, which always targets
|
|
185
|
+
// the *current* session. A main that has been backgrounded by a newer session (e.g. closed
|
|
186
|
+
// programmatically from another React root) must only remove its own session, otherwise it
|
|
187
|
+
// tears down the foreground session and leaves its own stale session behind.
|
|
188
|
+
var closeOwnFlyouts = (0, _react.useCallback)(function () {
|
|
189
|
+
if (level !== _const.LEVEL_MAIN) {
|
|
190
|
+
closeFlyout(flyoutId);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
var _getFlyoutManagerStor = (0, _store.getFlyoutManagerStore)().getState(),
|
|
194
|
+
sessions = _getFlyoutManagerStor.sessions;
|
|
195
|
+
var ownSession = sessions.find(function (session) {
|
|
196
|
+
return session.mainFlyoutId === flyoutId;
|
|
197
|
+
});
|
|
198
|
+
var isBackgroundedMain = ownSession != null && ownSession !== sessions[sessions.length - 1];
|
|
199
|
+
isBackgroundedMain ? closeFlyout(flyoutId) : closeAllFlyouts();
|
|
200
|
+
}, [level, flyoutId, closeFlyout, closeAllFlyouts]);
|
|
201
|
+
|
|
184
202
|
// Register with flyout manager context when open, remove when closed
|
|
185
203
|
// Using useLayoutEffect to run synchronously before DOM updates
|
|
186
204
|
(0, _react.useLayoutEffect)(function () {
|
|
@@ -192,7 +210,7 @@ var EuiManagedFlyout = exports.EuiManagedFlyout = /*#__PURE__*/(0, _react.forwar
|
|
|
192
210
|
});
|
|
193
211
|
if (stillInStore) {
|
|
194
212
|
// Normal cleanup (deps changed or explicit close via isOpen=false)
|
|
195
|
-
|
|
213
|
+
closeOwnFlyouts();
|
|
196
214
|
} else if (wasRegisteredRef.current) {
|
|
197
215
|
var _onCloseCallbackRef$c, _store$consumeCloseMe;
|
|
198
216
|
// Removed externally while mounted: forward the store-stamped reason
|
|
@@ -203,7 +221,7 @@ var EuiManagedFlyout = exports.EuiManagedFlyout = /*#__PURE__*/(0, _react.forwar
|
|
|
203
221
|
}
|
|
204
222
|
wasRegisteredRef.current = false;
|
|
205
223
|
};
|
|
206
|
-
}, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout,
|
|
224
|
+
}, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout, closeOwnFlyouts]);
|
|
207
225
|
|
|
208
226
|
// Detect when flyout has been removed from manager state (e.g., via Back button)
|
|
209
227
|
// and trigger onClose callback to notify the parent component
|
|
@@ -218,8 +236,8 @@ var EuiManagedFlyout = exports.EuiManagedFlyout = /*#__PURE__*/(0, _react.forwar
|
|
|
218
236
|
// any other removal (e.g. a closeAllFlyouts cascade reaching a backgrounded
|
|
219
237
|
// flyout) defaults to `navigation-cascade`.
|
|
220
238
|
if (wasRegisteredRef.current && !flyoutExistsInManager) {
|
|
221
|
-
var _onCloseCallbackRef$c2,
|
|
222
|
-
(_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'), (
|
|
239
|
+
var _onCloseCallbackRef$c2, _getFlyoutManagerStor2;
|
|
240
|
+
(_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'), (_getFlyoutManagerStor2 = (0, _store.getFlyoutManagerStore)().consumeCloseMeta(flyoutId)) !== null && _getFlyoutManagerStor2 !== void 0 ? _getFlyoutManagerStor2 : {
|
|
223
241
|
reason: 'navigation-cascade'
|
|
224
242
|
});
|
|
225
243
|
wasRegisteredRef.current = false; // Reset to avoid repeated calls
|
|
@@ -256,7 +274,7 @@ var EuiManagedFlyout = exports.EuiManagedFlyout = /*#__PURE__*/(0, _react.forwar
|
|
|
256
274
|
// and ensures cascade close logic runs before DOM cleanup begins
|
|
257
275
|
// Using flushSync to force synchronous state update completion
|
|
258
276
|
(0, _reactDom.flushSync)(function () {
|
|
259
|
-
|
|
277
|
+
closeOwnFlyouts();
|
|
260
278
|
});
|
|
261
279
|
if (onCloseCallbackRef.current) {
|
|
262
280
|
var event = e || new MouseEvent('click');
|