@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
|
@@ -243,97 +243,91 @@ EuiFlyoutMenu.propTypes = {
|
|
|
243
243
|
/**
|
|
244
244
|
* List of action items rendered at the start (inline-start) of the menu bar.
|
|
245
245
|
*/
|
|
246
|
-
leadingActions: PropTypes.arrayOf(PropTypes.shape({
|
|
246
|
+
leadingActions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
|
|
247
247
|
/**
|
|
248
|
-
*
|
|
248
|
+
* Aria label for the action button
|
|
249
249
|
*/
|
|
250
|
-
|
|
250
|
+
"aria-label": PropTypes.string.isRequired,
|
|
251
251
|
/**
|
|
252
252
|
* onClick handler for the action button
|
|
253
253
|
*/
|
|
254
254
|
onClick: PropTypes.func,
|
|
255
255
|
/**
|
|
256
|
-
*
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Optional tooltip content shown on hover/focus of the action button.
|
|
261
|
-
* When `isDisabled` is `true`, the action uses `aria-disabled` so the tooltip
|
|
262
|
-
* remains reachable via hover/focus (unless overridden via `toolTipProps`).
|
|
256
|
+
* Tooltip text shown on hover or focus.
|
|
257
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
258
|
+
* the button focusable so the tooltip remains reachable.
|
|
263
259
|
*/
|
|
264
260
|
toolTipContent: PropTypes.node,
|
|
265
261
|
/**
|
|
266
262
|
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
267
263
|
* Only used when `toolTipContent` is also provided.
|
|
268
264
|
*/
|
|
269
|
-
toolTipProps: PropTypes.any
|
|
265
|
+
toolTipProps: PropTypes.any
|
|
266
|
+
}).isRequired, PropTypes.shape({
|
|
270
267
|
/**
|
|
271
|
-
*
|
|
272
|
-
* the action is unavailable.
|
|
268
|
+
* Aria label for the action button
|
|
273
269
|
*/
|
|
274
|
-
|
|
270
|
+
"aria-label": PropTypes.string.isRequired,
|
|
275
271
|
/**
|
|
276
|
-
*
|
|
272
|
+
* onClick handler for the action button
|
|
277
273
|
*/
|
|
278
|
-
|
|
274
|
+
onClick: PropTypes.func,
|
|
279
275
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
276
|
+
* Tooltip text shown on hover or focus.
|
|
277
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
278
|
+
* the button focusable so the tooltip remains reachable.
|
|
283
279
|
*/
|
|
284
|
-
|
|
280
|
+
toolTipContent: PropTypes.node,
|
|
285
281
|
/**
|
|
286
|
-
*
|
|
282
|
+
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
283
|
+
* Only used when `toolTipContent` is also provided.
|
|
287
284
|
*/
|
|
288
|
-
|
|
289
|
-
}).isRequired),
|
|
285
|
+
toolTipProps: PropTypes.any
|
|
286
|
+
}).isRequired]).isRequired),
|
|
290
287
|
/**
|
|
291
288
|
* List of action items rendered at the end (inline-end) of the menu bar.
|
|
292
289
|
*/
|
|
293
|
-
trailingActions: PropTypes.arrayOf(PropTypes.shape({
|
|
290
|
+
trailingActions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
|
|
294
291
|
/**
|
|
295
|
-
*
|
|
292
|
+
* Aria label for the action button
|
|
296
293
|
*/
|
|
297
|
-
|
|
294
|
+
"aria-label": PropTypes.string.isRequired,
|
|
298
295
|
/**
|
|
299
296
|
* onClick handler for the action button
|
|
300
297
|
*/
|
|
301
298
|
onClick: PropTypes.func,
|
|
302
299
|
/**
|
|
303
|
-
*
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Optional tooltip content shown on hover/focus of the action button.
|
|
308
|
-
* When `isDisabled` is `true`, the action uses `aria-disabled` so the tooltip
|
|
309
|
-
* remains reachable via hover/focus (unless overridden via `toolTipProps`).
|
|
300
|
+
* Tooltip text shown on hover or focus.
|
|
301
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
302
|
+
* the button focusable so the tooltip remains reachable.
|
|
310
303
|
*/
|
|
311
304
|
toolTipContent: PropTypes.node,
|
|
312
305
|
/**
|
|
313
306
|
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
314
307
|
* Only used when `toolTipContent` is also provided.
|
|
315
308
|
*/
|
|
316
|
-
toolTipProps: PropTypes.any
|
|
309
|
+
toolTipProps: PropTypes.any
|
|
310
|
+
}).isRequired, PropTypes.shape({
|
|
317
311
|
/**
|
|
318
|
-
*
|
|
319
|
-
* the action is unavailable.
|
|
312
|
+
* Aria label for the action button
|
|
320
313
|
*/
|
|
321
|
-
|
|
314
|
+
"aria-label": PropTypes.string.isRequired,
|
|
322
315
|
/**
|
|
323
|
-
*
|
|
316
|
+
* onClick handler for the action button
|
|
324
317
|
*/
|
|
325
|
-
|
|
318
|
+
onClick: PropTypes.func,
|
|
326
319
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
320
|
+
* Tooltip text shown on hover or focus.
|
|
321
|
+
* When the action is disabled, also set `hasAriaDisabled`. This keeps
|
|
322
|
+
* the button focusable so the tooltip remains reachable.
|
|
330
323
|
*/
|
|
331
|
-
|
|
324
|
+
toolTipContent: PropTypes.node,
|
|
332
325
|
/**
|
|
333
|
-
*
|
|
326
|
+
* Optional props to pass to the underlying {@link EuiToolTip}.
|
|
327
|
+
* Only used when `toolTipContent` is also provided.
|
|
334
328
|
*/
|
|
335
|
-
|
|
336
|
-
}).isRequired),
|
|
329
|
+
toolTipProps: PropTypes.any
|
|
330
|
+
}).isRequired]).isRequired),
|
|
337
331
|
/**
|
|
338
332
|
* List of custom action items for the menu component
|
|
339
333
|
* @deprecated Use `trailingActions` instead. If both are supplied, `trailingActions` takes precedence.
|
|
@@ -24,7 +24,7 @@ import PropTypes from "prop-types";
|
|
|
24
24
|
* Side Public License, v 1.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState, forwardRef } from 'react';
|
|
27
|
+
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, forwardRef } from 'react';
|
|
28
28
|
import { css } from '@emotion/react';
|
|
29
29
|
import { flushSync } from 'react-dom';
|
|
30
30
|
import { useCombinedRefs, useEuiMemoizedStyles } from '../../../services';
|
|
@@ -177,6 +177,24 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
177
177
|
flyoutExistsInManagerRef.current = flyoutExistsInManager;
|
|
178
178
|
}, [flyoutExistsInManager]);
|
|
179
179
|
|
|
180
|
+
// Closing a main closes its whole history group via `closeAllFlyouts`, which always targets
|
|
181
|
+
// the *current* session. A main that has been backgrounded by a newer session (e.g. closed
|
|
182
|
+
// programmatically from another React root) must only remove its own session, otherwise it
|
|
183
|
+
// tears down the foreground session and leaves its own stale session behind.
|
|
184
|
+
var closeOwnFlyouts = useCallback(function () {
|
|
185
|
+
if (level !== LEVEL_MAIN) {
|
|
186
|
+
closeFlyout(flyoutId);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
var _getFlyoutManagerStor = getFlyoutManagerStore().getState(),
|
|
190
|
+
sessions = _getFlyoutManagerStor.sessions;
|
|
191
|
+
var ownSession = sessions.find(function (session) {
|
|
192
|
+
return session.mainFlyoutId === flyoutId;
|
|
193
|
+
});
|
|
194
|
+
var isBackgroundedMain = ownSession != null && ownSession !== sessions[sessions.length - 1];
|
|
195
|
+
isBackgroundedMain ? closeFlyout(flyoutId) : closeAllFlyouts();
|
|
196
|
+
}, [level, flyoutId, closeFlyout, closeAllFlyouts]);
|
|
197
|
+
|
|
180
198
|
// Register with flyout manager context when open, remove when closed
|
|
181
199
|
// Using useLayoutEffect to run synchronously before DOM updates
|
|
182
200
|
useLayoutEffect(function () {
|
|
@@ -188,7 +206,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
188
206
|
});
|
|
189
207
|
if (stillInStore) {
|
|
190
208
|
// Normal cleanup (deps changed or explicit close via isOpen=false)
|
|
191
|
-
|
|
209
|
+
closeOwnFlyouts();
|
|
192
210
|
} else if (wasRegisteredRef.current) {
|
|
193
211
|
var _onCloseCallbackRef$c, _store$consumeCloseMe;
|
|
194
212
|
// Removed externally while mounted: forward the store-stamped reason
|
|
@@ -199,7 +217,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
199
217
|
}
|
|
200
218
|
wasRegisteredRef.current = false;
|
|
201
219
|
};
|
|
202
|
-
}, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout,
|
|
220
|
+
}, [flyoutId, title, level, size, minWidth, historyKey, _flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.iconType, addFlyout, closeOwnFlyouts]);
|
|
203
221
|
|
|
204
222
|
// Detect when flyout has been removed from manager state (e.g., via Back button)
|
|
205
223
|
// and trigger onClose callback to notify the parent component
|
|
@@ -214,8 +232,8 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
214
232
|
// any other removal (e.g. a closeAllFlyouts cascade reaching a backgrounded
|
|
215
233
|
// flyout) defaults to `navigation-cascade`.
|
|
216
234
|
if (wasRegisteredRef.current && !flyoutExistsInManager) {
|
|
217
|
-
var _onCloseCallbackRef$c2,
|
|
218
|
-
(_onCloseCallbackRef$c2 = onCloseCallbackRef.current) === null || _onCloseCallbackRef$c2 === void 0 || _onCloseCallbackRef$c2.call(onCloseCallbackRef, new MouseEvent('navigation'), (
|
|
235
|
+
var _onCloseCallbackRef$c2, _getFlyoutManagerStor2;
|
|
236
|
+
(_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 : {
|
|
219
237
|
reason: 'navigation-cascade'
|
|
220
238
|
});
|
|
221
239
|
wasRegisteredRef.current = false; // Reset to avoid repeated calls
|
|
@@ -252,7 +270,7 @@ export var EuiManagedFlyout = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
252
270
|
// and ensures cascade close logic runs before DOM cleanup begins
|
|
253
271
|
// Using flushSync to force synchronous state update completion
|
|
254
272
|
flushSync(function () {
|
|
255
|
-
|
|
273
|
+
closeOwnFlyouts();
|
|
256
274
|
});
|
|
257
275
|
if (onCloseCallbackRef.current) {
|
|
258
276
|
var event = e || new MouseEvent('click');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["children", "className", "gutterSize", "fullWidth", "ratio", "titleSize", "title", "description", "descriptionFlexItemProps", "fieldFlexItemProps"];
|
|
1
|
+
var _excluded = ["children", "className", "gutterSize", "fullWidth", "ratio", "titleSize", "title", "description", "descriptionFlexItemProps", "fieldFlexItemProps", "aria-label", "aria-labelledby"];
|
|
2
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
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
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; }
|
|
@@ -10,10 +10,10 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
10
10
|
* Side Public License, v 1.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import React from 'react';
|
|
13
|
+
import React, { isValidElement } from 'react';
|
|
14
14
|
import PropTypes from "prop-types";
|
|
15
15
|
import classNames from 'classnames';
|
|
16
|
-
import { useEuiMemoizedStyles } from '../../../services';
|
|
16
|
+
import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../services';
|
|
17
17
|
import { EuiTitle } from '../../title';
|
|
18
18
|
import { EuiText } from '../../text';
|
|
19
19
|
import { EuiFlexGroup, EuiFlexItem } from '../../flex';
|
|
@@ -40,7 +40,15 @@ export var EuiDescribedFormGroup = function EuiDescribedFormGroup(props) {
|
|
|
40
40
|
description = props.description,
|
|
41
41
|
descriptionFlexItemProps = props.descriptionFlexItemProps,
|
|
42
42
|
fieldFlexItemProps = props.fieldFlexItemProps,
|
|
43
|
+
ariaLabel = props['aria-label'],
|
|
44
|
+
ariaLabelledby = props['aria-labelledby'],
|
|
43
45
|
rest = _objectWithoutProperties(props, _excluded);
|
|
46
|
+
var generatedTitleId = useGeneratedHtmlId({
|
|
47
|
+
prefix: 'euiDescribedFormGroupTitle'
|
|
48
|
+
});
|
|
49
|
+
// Reuse an `id` already set on the title element, so that consumers
|
|
50
|
+
// referencing it from their own `aria-labelledby` keep working
|
|
51
|
+
var titleId = /*#__PURE__*/isValidElement(title) && title.props.id || generatedTitleId;
|
|
44
52
|
var styles = useEuiMemoizedStyles(euiDescribedFormGroupStyles);
|
|
45
53
|
var cssStyles = [styles.euiDescribedFormGroup, fullWidth ? styles.fullWidth : styles.formWidth];
|
|
46
54
|
var descriptionColumnStyles = [styles.euiDescribedFormGroup__descriptionColumn, descriptionFlexItemProps === null || descriptionFlexItemProps === void 0 ? void 0 : descriptionFlexItemProps.css];
|
|
@@ -74,7 +82,11 @@ export var EuiDescribedFormGroup = function EuiDescribedFormGroup(props) {
|
|
|
74
82
|
break;
|
|
75
83
|
}
|
|
76
84
|
return ___EmotionJSX(EuiFlexGroup, _extends({
|
|
77
|
-
role: "group"
|
|
85
|
+
role: "group",
|
|
86
|
+
"aria-label": ariaLabel
|
|
87
|
+
// The title names the group, unless the consumer provides their own label
|
|
88
|
+
,
|
|
89
|
+
"aria-labelledby": ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : ariaLabel == null ? titleId : undefined
|
|
78
90
|
}, rest, {
|
|
79
91
|
css: cssStyles,
|
|
80
92
|
className: classes,
|
|
@@ -86,6 +98,7 @@ export var EuiDescribedFormGroup = function EuiDescribedFormGroup(props) {
|
|
|
86
98
|
css: descriptionColumnStyles,
|
|
87
99
|
className: classNames('euiDescribedFormGroup__descriptionColumn', descriptionFlexItemProps === null || descriptionFlexItemProps === void 0 ? void 0 : descriptionFlexItemProps.className)
|
|
88
100
|
}), ___EmotionJSX(EuiTitle, {
|
|
101
|
+
id: titleId,
|
|
89
102
|
size: titleSize,
|
|
90
103
|
className: "euiDescribedFormGroup__title"
|
|
91
104
|
}, title), renderedDescription), ___EmotionJSX(EuiFlexItem, _extends({
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
var _excluded = ["className", "expand", "initialSelectedTab", "onTabClick", "selectedTab", "size", "tabs"
|
|
1
|
+
var _excluded = ["autoFocus", "className", "expand", "initialSelectedTab", "onTabClick", "selectedTab", "size", "tabs"],
|
|
2
2
|
_excluded2 = ["id", "name", "content"];
|
|
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); }
|
|
4
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); }
|
|
5
|
-
function
|
|
6
|
-
function
|
|
4
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
5
|
+
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."); }
|
|
6
|
+
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; } }
|
|
7
|
+
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; }
|
|
8
|
+
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; } }
|
|
9
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
10
|
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; }
|
|
8
11
|
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; }
|
|
9
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
10
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
11
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
12
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
13
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
14
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
15
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
17
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
18
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
19
|
-
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; }
|
|
20
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
-
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); }
|
|
22
12
|
/*
|
|
23
13
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
24
14
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -27,138 +17,102 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
17
|
* Side Public License, v 1.
|
|
28
18
|
*/
|
|
29
19
|
|
|
30
|
-
import React, {
|
|
20
|
+
import React, { useRef, useState } from 'react';
|
|
31
21
|
import PropTypes from "prop-types";
|
|
32
|
-
import { htmlIdGenerator } from '../../../services';
|
|
33
22
|
import { EuiTabs } from '../tabs';
|
|
34
23
|
import { EuiTab } from '../tab';
|
|
35
|
-
import {
|
|
24
|
+
import { useGeneratedHtmlId } from '../../../services';
|
|
25
|
+
|
|
36
26
|
/**
|
|
37
27
|
* Marked as const so type is `['initial', 'selected']` instead of `string[]`
|
|
38
28
|
*/
|
|
29
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
39
30
|
export var AUTOFOCUS = ['initial', 'selected'];
|
|
40
|
-
export var EuiTabbedContent =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (!externalSelectedTab) {
|
|
82
|
-
_this.setState({
|
|
83
|
-
selectedTabId: selectedTab.id
|
|
84
|
-
}, function () {
|
|
85
|
-
_this.focusTab();
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
var initialSelectedTab = props.initialSelectedTab,
|
|
90
|
-
_selectedTab = props.selectedTab,
|
|
91
|
-
tabs = props.tabs;
|
|
31
|
+
export var EuiTabbedContent = function EuiTabbedContent(_ref) {
|
|
32
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
33
|
+
autoFocus = _ref$autoFocus === void 0 ? 'initial' : _ref$autoFocus,
|
|
34
|
+
className = _ref.className,
|
|
35
|
+
expand = _ref.expand,
|
|
36
|
+
initialSelectedTab = _ref.initialSelectedTab,
|
|
37
|
+
onTabClick = _ref.onTabClick,
|
|
38
|
+
externalSelectedTab = _ref.selectedTab,
|
|
39
|
+
size = _ref.size,
|
|
40
|
+
tabs = _ref.tabs,
|
|
41
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
42
|
+
var rootId = useGeneratedHtmlId();
|
|
43
|
+
var tabsRef = useRef(null);
|
|
44
|
+
var inFocusRef = useRef(false);
|
|
45
|
+
var _useState = useState(function () {
|
|
46
|
+
return externalSelectedTab ? undefined : (initialSelectedTab === null || initialSelectedTab === void 0 ? void 0 : initialSelectedTab.id) || tabs[0].id;
|
|
47
|
+
}),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
selectedTabId = _useState2[0],
|
|
50
|
+
setSelectedTabId = _useState2[1];
|
|
51
|
+
var focusTab = function focusTab(id) {
|
|
52
|
+
var _tabsRef$current;
|
|
53
|
+
var targetTab = (_tabsRef$current = tabsRef.current) === null || _tabsRef$current === void 0 ? void 0 : _tabsRef$current.querySelector("#".concat(id));
|
|
54
|
+
targetTab === null || targetTab === void 0 || targetTab.focus();
|
|
55
|
+
};
|
|
56
|
+
var initializeFocus = function initializeFocus() {
|
|
57
|
+
if (!inFocusRef.current && autoFocus === 'selected') {
|
|
58
|
+
inFocusRef.current = true;
|
|
59
|
+
focusTab(selectedTabId);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var removeFocus = function removeFocus(blurEvent) {
|
|
63
|
+
// only set inFocus to false if the wrapping div doesn't contain the now-focusing element
|
|
64
|
+
var currentTarget = blurEvent.currentTarget;
|
|
65
|
+
var relatedTarget = blurEvent.relatedTarget;
|
|
66
|
+
if (currentTarget.contains(relatedTarget) === false) {
|
|
67
|
+
inFocusRef.current = false;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var handleTabClick = function handleTabClick(tab) {
|
|
71
|
+
onTabClick === null || onTabClick === void 0 || onTabClick(tab);
|
|
92
72
|
|
|
93
73
|
// Only track selection state if it's not controlled externally.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
74
|
+
if (!externalSelectedTab) {
|
|
75
|
+
setSelectedTabId(tab.id);
|
|
76
|
+
focusTab(tab.id);
|
|
97
77
|
}
|
|
98
|
-
|
|
99
|
-
selectedTabId: selectedTabId,
|
|
100
|
-
inFocus: false
|
|
101
|
-
};
|
|
102
|
-
return _this;
|
|
103
|
-
}
|
|
104
|
-
_inherits(EuiTabbedContent, _Component);
|
|
105
|
-
return _createClass(EuiTabbedContent, [{
|
|
106
|
-
key: "render",
|
|
107
|
-
value: function render() {
|
|
108
|
-
var _this2 = this;
|
|
109
|
-
var _this$props2 = this.props,
|
|
110
|
-
className = _this$props2.className,
|
|
111
|
-
expand = _this$props2.expand,
|
|
112
|
-
initialSelectedTab = _this$props2.initialSelectedTab,
|
|
113
|
-
onTabClick = _this$props2.onTabClick,
|
|
114
|
-
externalSelectedTab = _this$props2.selectedTab,
|
|
115
|
-
size = _this$props2.size,
|
|
116
|
-
tabs = _this$props2.tabs,
|
|
117
|
-
autoFocus = _this$props2.autoFocus,
|
|
118
|
-
rest = _objectWithoutProperties(_this$props2, _excluded);
|
|
78
|
+
};
|
|
119
79
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
80
|
+
// Allow the consumer to control tab selection.
|
|
81
|
+
var selectedTab = externalSelectedTab || tabs.find(function (tab) {
|
|
82
|
+
return tab.id === selectedTabId;
|
|
83
|
+
}) || tabs[0]; // Fall back to the first tab if a selected tab can't be found
|
|
124
84
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
}]);
|
|
158
|
-
}(Component);
|
|
159
|
-
_defineProperty(EuiTabbedContent, "defaultProps", {
|
|
160
|
-
autoFocus: 'initial'
|
|
161
|
-
});
|
|
85
|
+
var selectedTabContent = selectedTab.content,
|
|
86
|
+
selectedTabContentId = selectedTab.id;
|
|
87
|
+
return ___EmotionJSX("div", _extends({
|
|
88
|
+
className: className
|
|
89
|
+
}, rest), ___EmotionJSX(EuiTabs, {
|
|
90
|
+
ref: tabsRef,
|
|
91
|
+
expand: expand,
|
|
92
|
+
size: size,
|
|
93
|
+
onFocus: initializeFocus,
|
|
94
|
+
onBlur: removeFocus
|
|
95
|
+
}, tabs.map(function (tab) {
|
|
96
|
+
var id = tab.id,
|
|
97
|
+
name = tab.name,
|
|
98
|
+
content = tab.content,
|
|
99
|
+
tabProps = _objectWithoutProperties(tab, _excluded2);
|
|
100
|
+
return ___EmotionJSX(EuiTab, _extends({
|
|
101
|
+
key: id,
|
|
102
|
+
id: id
|
|
103
|
+
}, tabProps, {
|
|
104
|
+
onClick: function onClick() {
|
|
105
|
+
return handleTabClick(tab);
|
|
106
|
+
},
|
|
107
|
+
isSelected: tab === selectedTab,
|
|
108
|
+
"aria-controls": rootId
|
|
109
|
+
}), name);
|
|
110
|
+
})), ___EmotionJSX("div", {
|
|
111
|
+
role: "tabpanel",
|
|
112
|
+
id: rootId,
|
|
113
|
+
"aria-labelledby": selectedTabContentId
|
|
114
|
+
}, selectedTabContent));
|
|
115
|
+
};
|
|
162
116
|
EuiTabbedContent.propTypes = {
|
|
163
117
|
className: PropTypes.string,
|
|
164
118
|
"aria-label": PropTypes.string,
|
|
@@ -234,4 +188,5 @@ EuiTabbedContent.propTypes = {
|
|
|
234
188
|
"data-test-subj": PropTypes.string,
|
|
235
189
|
css: PropTypes.any
|
|
236
190
|
}).isRequired).isRequired
|
|
237
|
-
};
|
|
191
|
+
};
|
|
192
|
+
EuiTabbedContent.displayName = 'EuiTabbedContent';
|