@elastic/eui 92.0.0 → 92.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eui_theme_dark.css +3 -18
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +3 -18
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/aspect_ratio/aspect_ratio.js +1 -1
- package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +7 -3
- package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +4 -4
- package/es/components/datagrid/body/{data_grid_cell.js → cell/data_grid_cell.js} +56 -209
- package/es/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js} +5 -5
- package/es/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js} +4 -4
- package/es/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js} +1 -1
- package/es/components/datagrid/body/cell/focus_utils.js +166 -0
- package/es/components/datagrid/body/cell/index.js +11 -0
- package/es/components/datagrid/body/data_grid_body.js +0 -2
- package/es/components/datagrid/body/data_grid_body_custom.js +1 -7
- package/es/components/datagrid/body/data_grid_body_virtualized.js +1 -7
- package/es/components/datagrid/body/footer/data_grid_footer_row.js +1 -2
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -6
- package/es/components/datagrid/body/header/data_grid_header_cell.js +27 -12
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +45 -116
- package/es/components/datagrid/body/header/data_grid_header_row.js +5 -10
- package/es/components/datagrid/body/header/use_data_grid_header.js +3 -14
- package/es/components/datagrid/data_grid.js +2 -12
- package/es/components/datagrid/utils/focus.js +25 -54
- package/es/components/datagrid/utils/scrolling.js +1 -1
- package/es/components/flyout/flyout_resizable.js +10 -10
- package/es/components/flyout/flyout_resizable.styles.js +12 -6
- package/es/components/resizable_container/helpers.js +5 -6
- package/es/components/resizable_container/resizable_button.js +13 -4
- package/es/components/resizable_container/resizable_button.styles.js +18 -8
- package/es/components/resizable_container/resizable_container.js +28 -22
- package/es/components/steps/step_number.styles.js +6 -7
- package/es/components/tree_view/tree_view.js +9 -2
- package/eui.d.ts +125 -90
- package/i18ntokens.json +108 -72
- package/lib/components/aspect_ratio/aspect_ratio.js +1 -1
- package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +7 -3
- package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +4 -4
- package/lib/components/datagrid/body/{data_grid_cell.js → cell/data_grid_cell.js} +56 -209
- package/lib/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js} +5 -5
- package/lib/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js} +4 -4
- package/lib/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js} +1 -1
- package/lib/components/datagrid/body/cell/focus_utils.js +174 -0
- package/lib/components/datagrid/body/cell/index.js +32 -0
- package/lib/components/datagrid/body/data_grid_body.js +0 -2
- package/lib/components/datagrid/body/data_grid_body_custom.js +2 -8
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +2 -8
- package/lib/components/datagrid/body/footer/data_grid_footer_row.js +5 -6
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -6
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +35 -20
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +47 -119
- package/lib/components/datagrid/body/header/data_grid_header_row.js +5 -10
- package/lib/components/datagrid/body/header/use_data_grid_header.js +10 -24
- package/lib/components/datagrid/data_grid.js +4 -14
- package/lib/components/datagrid/utils/focus.js +26 -56
- package/lib/components/datagrid/utils/scrolling.js +2 -2
- package/lib/components/flyout/flyout_resizable.js +10 -10
- package/lib/components/flyout/flyout_resizable.styles.js +12 -6
- package/lib/components/resizable_container/helpers.js +7 -7
- package/lib/components/resizable_container/resizable_button.js +13 -4
- package/lib/components/resizable_container/resizable_button.styles.js +18 -8
- package/lib/components/resizable_container/resizable_container.js +28 -22
- package/lib/components/steps/step_number.styles.js +6 -7
- package/lib/components/tree_view/tree_view.js +9 -2
- package/optimize/es/components/aspect_ratio/aspect_ratio.js +1 -1
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +7 -3
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +4 -4
- package/optimize/es/components/datagrid/body/{data_grid_cell.js → cell/data_grid_cell.js} +56 -209
- package/optimize/es/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js} +5 -5
- package/optimize/es/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js} +4 -4
- package/optimize/es/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js} +1 -1
- package/optimize/es/components/datagrid/body/cell/focus_utils.js +153 -0
- package/optimize/es/components/datagrid/body/cell/index.js +11 -0
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +1 -5
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +1 -5
- package/optimize/es/components/datagrid/body/footer/data_grid_footer_row.js +1 -2
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -4
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +25 -10
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +41 -115
- package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +4 -8
- package/optimize/es/components/datagrid/body/header/use_data_grid_header.js +3 -13
- package/optimize/es/components/datagrid/data_grid.js +2 -12
- package/optimize/es/components/datagrid/utils/focus.js +25 -54
- package/optimize/es/components/datagrid/utils/scrolling.js +1 -1
- package/optimize/es/components/flyout/flyout_resizable.js +10 -10
- package/optimize/es/components/flyout/flyout_resizable.styles.js +12 -6
- package/optimize/es/components/resizable_container/helpers.js +5 -6
- package/optimize/es/components/resizable_container/resizable_button.js +5 -2
- package/optimize/es/components/resizable_container/resizable_button.styles.js +18 -8
- package/optimize/es/components/resizable_container/resizable_container.js +28 -22
- package/optimize/es/components/steps/step_number.styles.js +6 -7
- package/optimize/es/components/tree_view/tree_view.js +9 -2
- package/optimize/lib/components/aspect_ratio/aspect_ratio.js +1 -1
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +7 -3
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +4 -4
- package/optimize/lib/components/datagrid/body/{data_grid_cell.js → cell/data_grid_cell.js} +56 -209
- package/optimize/lib/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js} +5 -5
- package/optimize/lib/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js} +4 -4
- package/optimize/lib/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js} +1 -1
- package/optimize/lib/components/datagrid/body/cell/focus_utils.js +163 -0
- package/optimize/lib/components/datagrid/body/cell/index.js +32 -0
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +2 -6
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +2 -6
- package/optimize/lib/components/datagrid/body/footer/data_grid_footer_row.js +5 -6
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -4
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +25 -10
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +41 -115
- package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +4 -8
- package/optimize/lib/components/datagrid/body/header/use_data_grid_header.js +4 -14
- package/optimize/lib/components/datagrid/data_grid.js +4 -14
- package/optimize/lib/components/datagrid/utils/focus.js +26 -56
- package/optimize/lib/components/datagrid/utils/scrolling.js +2 -2
- package/optimize/lib/components/flyout/flyout_resizable.js +10 -10
- package/optimize/lib/components/flyout/flyout_resizable.styles.js +12 -6
- package/optimize/lib/components/resizable_container/helpers.js +7 -7
- package/optimize/lib/components/resizable_container/resizable_button.js +5 -2
- package/optimize/lib/components/resizable_container/resizable_button.styles.js +18 -8
- package/optimize/lib/components/resizable_container/resizable_container.js +28 -22
- package/optimize/lib/components/steps/step_number.styles.js +6 -7
- package/optimize/lib/components/tree_view/tree_view.js +9 -2
- package/package.json +1 -1
- package/src/components/datagrid/body/header/_data_grid_header_row.scss +8 -7
- package/test-env/components/aspect_ratio/aspect_ratio.js +1 -1
- package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.js +7 -3
- package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +4 -4
- package/test-env/components/datagrid/body/{data_grid_cell.js → cell/data_grid_cell.js} +56 -209
- package/test-env/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js} +5 -5
- package/test-env/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js} +4 -4
- package/test-env/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js} +1 -1
- package/test-env/components/datagrid/body/cell/focus_utils.js +172 -0
- package/test-env/components/datagrid/body/cell/index.js +32 -0
- package/test-env/components/datagrid/body/data_grid_body.js +0 -2
- package/test-env/components/datagrid/body/data_grid_body_custom.js +2 -8
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +2 -8
- package/test-env/components/datagrid/body/footer/data_grid_footer_row.js +5 -6
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -6
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +25 -10
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +44 -116
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +5 -10
- package/test-env/components/datagrid/body/header/use_data_grid_header.js +4 -14
- package/test-env/components/datagrid/data_grid.js +4 -14
- package/test-env/components/datagrid/utils/focus.js +26 -56
- package/test-env/components/datagrid/utils/scrolling.js +2 -2
- package/test-env/components/flyout/flyout_resizable.js +10 -10
- package/test-env/components/flyout/flyout_resizable.styles.js +12 -6
- package/test-env/components/resizable_container/helpers.js +7 -7
- package/test-env/components/resizable_container/resizable_button.js +13 -4
- package/test-env/components/resizable_container/resizable_button.styles.js +18 -8
- package/test-env/components/resizable_container/resizable_container.js +28 -22
- package/test-env/components/steps/step_number.styles.js +6 -7
- package/test-env/components/tree_view/tree_view.js +9 -2
- package/es/components/datagrid/body/header/header_is_interactive.js +0 -58
- package/lib/components/datagrid/body/header/header_is_interactive.js +0 -63
- package/optimize/es/components/datagrid/body/header/header_is_interactive.js +0 -53
- package/optimize/lib/components/datagrid/body/header/header_is_interactive.js +0 -61
- package/test-env/components/datagrid/body/header/header_is_interactive.js +0 -61
|
@@ -27,7 +27,7 @@ export var EuiAspectRatio = function EuiAspectRatio(_ref) {
|
|
|
27
27
|
style = _ref.style,
|
|
28
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
29
|
var classes = classNames('euiAspectRatio', className);
|
|
30
|
-
var euiAspectRatioStyle = _objectSpread({
|
|
30
|
+
var euiAspectRatioStyle = _objectSpread(_objectSpread({}, children.props.style), {}, {
|
|
31
31
|
aspectRatio: "".concat(width, " / ").concat(height),
|
|
32
32
|
height: 'auto',
|
|
33
33
|
width: '100%',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _excluded = ["className"],
|
|
2
|
-
_excluded2 = ["className"];
|
|
2
|
+
_excluded2 = ["className", "children"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -45,6 +45,7 @@ export var EuiCollapsibleNavBody = function EuiCollapsibleNavBody(_ref) {
|
|
|
45
45
|
};
|
|
46
46
|
export var EuiCollapsibleNavFooter = function EuiCollapsibleNavFooter(_ref2) {
|
|
47
47
|
var className = _ref2.className,
|
|
48
|
+
children = _ref2.children,
|
|
48
49
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
49
50
|
var classes = classNames('euiCollapsibleNav__footer', className);
|
|
50
51
|
var _useContext2 = useContext(EuiCollapsibleNavContext),
|
|
@@ -52,9 +53,12 @@ export var EuiCollapsibleNavFooter = function EuiCollapsibleNavFooter(_ref2) {
|
|
|
52
53
|
isPush = _useContext2.isPush;
|
|
53
54
|
var euiTheme = useEuiTheme();
|
|
54
55
|
var styles = euiCollapsibleNavFooterStyles(euiTheme);
|
|
55
|
-
var cssStyles =
|
|
56
|
+
var cssStyles = styles.euiCollapsibleNav__footer;
|
|
57
|
+
var overflowWrapperStyles = [styles.euiFlyoutFooter__overflow, isCollapsed && isPush && styles.isPushCollapsed];
|
|
56
58
|
return ___EmotionJSX(EuiFlyoutFooter, _extends({
|
|
57
59
|
className: classes,
|
|
58
60
|
css: cssStyles
|
|
59
|
-
}, props)
|
|
61
|
+
}, props), ___EmotionJSX("div", {
|
|
62
|
+
css: overflowWrapperStyles
|
|
63
|
+
}, children));
|
|
60
64
|
};
|
|
@@ -13,16 +13,16 @@ import { logicalCSS, euiYScrollWithShadows } from '../../global_styling';
|
|
|
13
13
|
// Otherwise if scrollbars are visible, button icon visibility suffers.
|
|
14
14
|
export var hideScrollbars = "\n scrollbar-width: none; /* Firefox */\n\n &::-webkit-scrollbar {\n display: none; /* Chrome, Edge, & Safari */\n }\n";
|
|
15
15
|
export var euiCollapsibleNavBodyStyles = {
|
|
16
|
-
|
|
17
|
-
euiCollapsibleNav__body: /*#__PURE__*/css(logicalCSS('min-height', '50%'), ";;label:euiCollapsibleNav__body;"),
|
|
16
|
+
euiCollapsibleNav__body: /*#__PURE__*/css(";label:euiCollapsibleNav__body;"),
|
|
18
17
|
isPushCollapsed: /*#__PURE__*/css(".euiFlyoutBody__overflow{", hideScrollbars, ";};label:isPushCollapsed;")
|
|
19
18
|
};
|
|
20
19
|
export var euiCollapsibleNavFooterStyles = function euiCollapsibleNavFooterStyles(euiThemeContext) {
|
|
21
20
|
var euiTheme = euiThemeContext.euiTheme;
|
|
22
21
|
return {
|
|
23
|
-
euiCollapsibleNav__footer: /*#__PURE__*/css("background-color:", euiTheme.colors.emptyShade, ";", logicalCSS('border-top', euiTheme.border.thin), "
|
|
22
|
+
euiCollapsibleNav__footer: /*#__PURE__*/css(logicalCSS('max-height', '50%'), " background-color:", euiTheme.colors.emptyShade, ";", logicalCSS('border-top', euiTheme.border.thin), ";;label:euiCollapsibleNav__footer;"),
|
|
23
|
+
euiFlyoutFooter__overflow: /*#__PURE__*/css(euiYScrollWithShadows(euiThemeContext, {
|
|
24
24
|
side: 'end'
|
|
25
|
-
}), ";;label:
|
|
25
|
+
}), ";;label:euiFlyoutFooter__overflow;"),
|
|
26
26
|
isPushCollapsed: /*#__PURE__*/css(hideScrollbars, ";;label:isPushCollapsed;")
|
|
27
27
|
};
|
|
28
28
|
};
|
|
@@ -32,17 +32,16 @@ import classNames from 'classnames';
|
|
|
32
32
|
import PropTypes from "prop-types";
|
|
33
33
|
import React, { Component, createRef, memo } from 'react';
|
|
34
34
|
import { createPortal } from 'react-dom';
|
|
35
|
-
import {
|
|
36
|
-
import { keys } from '
|
|
37
|
-
import { EuiScreenReaderOnly } from '
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import { DataGridFocusContext } from '../utils/focus';
|
|
35
|
+
import { IS_JEST_ENVIRONMENT } from '../../../../utils';
|
|
36
|
+
import { keys } from '../../../../services';
|
|
37
|
+
import { EuiScreenReaderOnly } from '../../../accessibility';
|
|
38
|
+
import { EuiI18n } from '../../../i18n';
|
|
39
|
+
import { EuiTextBlockTruncate } from '../../../text_truncate';
|
|
40
|
+
import { hasResizeObserver } from '../../../observer/resize_observer/resize_observer';
|
|
41
|
+
import { DataGridFocusContext } from '../../utils/focus';
|
|
43
42
|
import { EuiDataGridCellActions, EuiDataGridCellPopoverActions } from './data_grid_cell_actions';
|
|
44
43
|
import { DefaultCellPopover } from './data_grid_cell_popover';
|
|
45
|
-
import {
|
|
44
|
+
import { HandleInteractiveChildren } from './focus_utils';
|
|
46
45
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
47
46
|
var EuiDataGridCellContent = /*#__PURE__*/memo(function (_ref) {
|
|
48
47
|
var renderCellValue = _ref.renderCellValue,
|
|
@@ -92,7 +91,10 @@ var EuiDataGridCellContent = /*#__PURE__*/memo(function (_ref) {
|
|
|
92
91
|
col: colIndex + 1,
|
|
93
92
|
row: ariaRowIndex
|
|
94
93
|
}
|
|
95
|
-
})
|
|
94
|
+
}), cellActions && ___EmotionJSX(React.Fragment, null, '. ', ___EmotionJSX(EuiI18n, {
|
|
95
|
+
token: "euiDataGridCell.expansionEnterPrompt",
|
|
96
|
+
default: "Press the Enter key to expand this cell."
|
|
97
|
+
}))));
|
|
96
98
|
return ___EmotionJSX(React.Fragment, null, cellContent, screenReaderText, cellActions);
|
|
97
99
|
});
|
|
98
100
|
EuiDataGridCellContent.propTypes = {
|
|
@@ -595,43 +597,20 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
595
597
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
596
598
|
cellProps: {},
|
|
597
599
|
isFocused: false,
|
|
598
|
-
isEntered: false,
|
|
599
|
-
enableInteractions: false,
|
|
600
|
-
disableCellTabIndex: false,
|
|
601
600
|
cellTextAlign: 'Left'
|
|
602
601
|
});
|
|
603
602
|
_defineProperty(_assertThisInitialized(_this), "unsubscribeCell", void 0);
|
|
604
|
-
_defineProperty(_assertThisInitialized(_this), "focusTimeout", void 0);
|
|
605
603
|
_defineProperty(_assertThisInitialized(_this), "style", null);
|
|
606
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
607
|
-
|
|
608
|
-
if (tabbingRef) {
|
|
609
|
-
return tabbingRef.querySelectorAll('[data-datagrid-interactable=true]');
|
|
610
|
-
}
|
|
611
|
-
return [];
|
|
604
|
+
_defineProperty(_assertThisInitialized(_this), "updateCellFocusContext", function () {
|
|
605
|
+
_this.context.setFocusedCell([_this.props.colIndex, _this.props.visibleRowIndex]);
|
|
612
606
|
});
|
|
613
607
|
_defineProperty(_assertThisInitialized(_this), "takeFocus", function (preventScroll) {
|
|
614
608
|
var cell = _this.cellRef.current;
|
|
615
|
-
if
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}
|
|
621
|
-
var doFocusUpdate = element !== cell;
|
|
622
|
-
if (doFocusUpdate) {
|
|
623
|
-
var interactables = _this.getInteractables();
|
|
624
|
-
if (_this.isExpandable() === false && interactables.length === 1) {
|
|
625
|
-
// Only one element can be interacted with
|
|
626
|
-
interactables[0].focus({
|
|
627
|
-
preventScroll: preventScroll
|
|
628
|
-
});
|
|
629
|
-
} else {
|
|
630
|
-
cell.focus({
|
|
631
|
-
preventScroll: preventScroll
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
}
|
|
609
|
+
// Only focus the cell if not already focused on something in the cell
|
|
610
|
+
if (cell && !cell.contains(document.activeElement)) {
|
|
611
|
+
cell.focus({
|
|
612
|
+
preventScroll: preventScroll
|
|
613
|
+
});
|
|
635
614
|
}
|
|
636
615
|
});
|
|
637
616
|
_defineProperty(_assertThisInitialized(_this), "recalculateAutoHeight", function () {
|
|
@@ -700,61 +679,8 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
700
679
|
} else if (_this.contentObserver) {
|
|
701
680
|
_this.contentObserver.disconnect();
|
|
702
681
|
}
|
|
703
|
-
_this.preventTabbing();
|
|
704
682
|
_this.setCellTextAlign();
|
|
705
683
|
});
|
|
706
|
-
_defineProperty(_assertThisInitialized(_this), "onFocus", function (e) {
|
|
707
|
-
// only perform this logic when the event's originating element (e.target) is
|
|
708
|
-
// the wrapping element with the onFocus logic
|
|
709
|
-
// reasons:
|
|
710
|
-
// * the outcome is only meaningful when the focus shifts to the wrapping element
|
|
711
|
-
// * if the cell children include portalled content React will bubble the focus
|
|
712
|
-
// event up, which can trigger the focus() call below, causing focus lock fighting
|
|
713
|
-
if (_this.cellRef.current === e.target) {
|
|
714
|
-
var _this$props5 = _this.props,
|
|
715
|
-
colIndex = _this$props5.colIndex,
|
|
716
|
-
visibleRowIndex = _this$props5.visibleRowIndex;
|
|
717
|
-
// focus in next tick to give potential focus capturing mechanisms time to release their traps
|
|
718
|
-
// also clear any previous focus timeout that may still be queued
|
|
719
|
-
if (EuiDataGridCell.activeFocusTimeoutId) {
|
|
720
|
-
window.clearTimeout(EuiDataGridCell.activeFocusTimeoutId);
|
|
721
|
-
}
|
|
722
|
-
EuiDataGridCell.activeFocusTimeoutId = _this.focusTimeout = window.setTimeout(function () {
|
|
723
|
-
_this.context.setFocusedCell([colIndex, visibleRowIndex]);
|
|
724
|
-
var interactables = _this.getInteractables();
|
|
725
|
-
if (interactables.length === 1 && _this.isExpandable() === false) {
|
|
726
|
-
interactables[0].focus();
|
|
727
|
-
_this.setState({
|
|
728
|
-
disableCellTabIndex: true
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
}, 0);
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
_defineProperty(_assertThisInitialized(_this), "onBlur", function () {
|
|
735
|
-
_this.setState({
|
|
736
|
-
disableCellTabIndex: false
|
|
737
|
-
});
|
|
738
|
-
});
|
|
739
|
-
_defineProperty(_assertThisInitialized(_this), "preventTabbing", function () {
|
|
740
|
-
if (_this.cellContentsRef) {
|
|
741
|
-
var tabbables = tabbable(_this.cellContentsRef);
|
|
742
|
-
for (var i = 0; i < tabbables.length; i++) {
|
|
743
|
-
var element = tabbables[i];
|
|
744
|
-
element.setAttribute('tabIndex', '-1');
|
|
745
|
-
element.setAttribute('data-datagrid-interactable', 'true');
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
});
|
|
749
|
-
_defineProperty(_assertThisInitialized(_this), "enableTabbing", function () {
|
|
750
|
-
if (_this.cellContentsRef) {
|
|
751
|
-
var interactables = _this.getInteractables();
|
|
752
|
-
for (var i = 0; i < interactables.length; i++) {
|
|
753
|
-
var element = interactables[i];
|
|
754
|
-
element.removeAttribute('tabIndex');
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
684
|
_defineProperty(_assertThisInitialized(_this), "setCellTextAlign", function () {
|
|
759
685
|
if (_this.cellContentsRef) {
|
|
760
686
|
var columnType = _this.props.columnType;
|
|
@@ -807,14 +733,14 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
807
733
|
setPopoverAnchorPosition("down".concat(_this.state.cellTextAlign));
|
|
808
734
|
|
|
809
735
|
// Set popover contents with cell content
|
|
810
|
-
var _this$
|
|
811
|
-
renderCellPopover = _this$
|
|
812
|
-
renderCellValue = _this$
|
|
813
|
-
rowIndex = _this$
|
|
814
|
-
colIndex = _this$
|
|
815
|
-
column = _this$
|
|
816
|
-
columnId = _this$
|
|
817
|
-
columnType = _this$
|
|
736
|
+
var _this$props5 = _this.props,
|
|
737
|
+
renderCellPopover = _this$props5.renderCellPopover,
|
|
738
|
+
renderCellValue = _this$props5.renderCellValue,
|
|
739
|
+
rowIndex = _this$props5.rowIndex,
|
|
740
|
+
colIndex = _this$props5.colIndex,
|
|
741
|
+
column = _this$props5.column,
|
|
742
|
+
columnId = _this$props5.columnId,
|
|
743
|
+
columnType = _this$props5.columnType;
|
|
818
744
|
var PopoverElement = renderCellPopover || DefaultCellPopover;
|
|
819
745
|
var CellElement = renderCellValue;
|
|
820
746
|
var sharedProps = {
|
|
@@ -844,9 +770,9 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
844
770
|
_createClass(EuiDataGridCell, [{
|
|
845
771
|
key: "componentDidMount",
|
|
846
772
|
value: function componentDidMount() {
|
|
847
|
-
var _this$
|
|
848
|
-
colIndex = _this$
|
|
849
|
-
visibleRowIndex = _this$
|
|
773
|
+
var _this$props6 = this.props,
|
|
774
|
+
colIndex = _this$props6.colIndex,
|
|
775
|
+
visibleRowIndex = _this$props6.visibleRowIndex;
|
|
850
776
|
this.unsubscribeCell = this.context.onFocusUpdate([colIndex, visibleRowIndex], this.onFocusUpdate);
|
|
851
777
|
|
|
852
778
|
// Account for virtualization - when a cell unmounts when scrolled out of view
|
|
@@ -865,7 +791,6 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
865
791
|
}, {
|
|
866
792
|
key: "componentWillUnmount",
|
|
867
793
|
value: function componentWillUnmount() {
|
|
868
|
-
window.clearTimeout(this.focusTimeout);
|
|
869
794
|
if (this.unsubscribeCell) {
|
|
870
795
|
this.unsubscribeCell();
|
|
871
796
|
}
|
|
@@ -932,39 +857,33 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
932
857
|
if (nextProps.style.width !== this.props.style.width) return true;
|
|
933
858
|
}
|
|
934
859
|
if (nextState.cellProps !== this.state.cellProps) return true;
|
|
935
|
-
if (nextState.isEntered !== this.state.isEntered) return true;
|
|
936
860
|
if (nextState.isFocused !== this.state.isFocused) return true;
|
|
937
|
-
if (nextState.enableInteractions !== this.state.enableInteractions) return true;
|
|
938
|
-
if (nextState.disableCellTabIndex !== this.state.disableCellTabIndex) return true;
|
|
939
861
|
return false;
|
|
940
862
|
}
|
|
941
863
|
}, {
|
|
942
864
|
key: "render",
|
|
943
865
|
value: function render() {
|
|
944
|
-
var _classNames,
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
pagination = _this$props8.pagination,
|
|
961
|
-
rest = _objectWithoutProperties(_this$props8, _excluded2);
|
|
866
|
+
var _classNames, _rowHeightsOptions$li;
|
|
867
|
+
var _this$props7 = this.props,
|
|
868
|
+
width = _this$props7.width,
|
|
869
|
+
_this$props7$popoverC = _this$props7.popoverContext,
|
|
870
|
+
closeCellPopover = _this$props7$popoverC.closeCellPopover,
|
|
871
|
+
openCellPopover = _this$props7$popoverC.openCellPopover,
|
|
872
|
+
interactiveCellId = _this$props7.interactiveCellId,
|
|
873
|
+
columnType = _this$props7.columnType,
|
|
874
|
+
className = _this$props7.className,
|
|
875
|
+
column = _this$props7.column,
|
|
876
|
+
style = _this$props7.style,
|
|
877
|
+
rowHeightUtils = _this$props7.rowHeightUtils,
|
|
878
|
+
rowHeightsOptions = _this$props7.rowHeightsOptions,
|
|
879
|
+
rowManager = _this$props7.rowManager,
|
|
880
|
+
pagination = _this$props7.pagination,
|
|
881
|
+
rest = _objectWithoutProperties(_this$props7, _excluded2);
|
|
962
882
|
var rowIndex = rest.rowIndex,
|
|
963
883
|
visibleRowIndex = rest.visibleRowIndex,
|
|
964
884
|
colIndex = rest.colIndex;
|
|
965
885
|
var isExpandable = this.isExpandable();
|
|
966
886
|
var popoverIsOpen = this.isPopoverOpen();
|
|
967
|
-
var showCellActions = this.state.isFocused || this.state.isEntered || this.state.enableInteractions || popoverIsOpen;
|
|
968
887
|
var cellClasses = classNames('euiDataGridRowCell', "euiDataGridRowCell--align".concat(this.state.cellTextAlign), (_classNames = {}, _defineProperty(_classNames, "euiDataGridRowCell--".concat(columnType), columnType), _defineProperty(_classNames, 'euiDataGridRowCell--open', popoverIsOpen), _classNames), className);
|
|
969
888
|
var ariaRowIndex = pagination ? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex : visibleRowIndex + 1;
|
|
970
889
|
var _this$state$cellProps2 = this.state.cellProps,
|
|
@@ -1000,51 +919,6 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1000
919
|
});
|
|
1001
920
|
break;
|
|
1002
921
|
}
|
|
1003
|
-
} else {
|
|
1004
|
-
if (event.key === keys.ENTER || event.key === keys.F2 || event.key === keys.ESCAPE) {
|
|
1005
|
-
var interactables = _this2.getInteractables();
|
|
1006
|
-
if (interactables.length >= 2) {
|
|
1007
|
-
switch (event.key) {
|
|
1008
|
-
case keys.ENTER:
|
|
1009
|
-
// `Enter` only activates the trap
|
|
1010
|
-
if (_this2.state.isEntered === false) {
|
|
1011
|
-
_this2.enableTabbing();
|
|
1012
|
-
_this2.setState({
|
|
1013
|
-
isEntered: true
|
|
1014
|
-
});
|
|
1015
|
-
|
|
1016
|
-
// result of this keypress is focus shifts to the first interactive element
|
|
1017
|
-
// and then the browser fires the onClick event because that's how [Enter] works
|
|
1018
|
-
// so we need to prevent that default action otherwise entering the trap triggers the first element
|
|
1019
|
-
event.preventDefault();
|
|
1020
|
-
}
|
|
1021
|
-
break;
|
|
1022
|
-
case keys.F2:
|
|
1023
|
-
// toggle interactives' focus trap
|
|
1024
|
-
_this2.setState(function (_ref2) {
|
|
1025
|
-
var isEntered = _ref2.isEntered;
|
|
1026
|
-
if (isEntered) {
|
|
1027
|
-
_this2.preventTabbing();
|
|
1028
|
-
} else {
|
|
1029
|
-
_this2.enableTabbing();
|
|
1030
|
-
}
|
|
1031
|
-
return {
|
|
1032
|
-
isEntered: !isEntered
|
|
1033
|
-
};
|
|
1034
|
-
});
|
|
1035
|
-
break;
|
|
1036
|
-
case keys.ESCAPE:
|
|
1037
|
-
// `Escape` only de-activates the trap
|
|
1038
|
-
_this2.preventTabbing();
|
|
1039
|
-
if (_this2.state.isEntered === true) {
|
|
1040
|
-
_this2.setState({
|
|
1041
|
-
isEntered: false
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
break;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
922
|
}
|
|
1049
923
|
};
|
|
1050
924
|
var rowHeight = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
|
|
@@ -1062,7 +936,7 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1062
936
|
isControlColumn: cellClasses.includes('euiDataGridRowCell--controlColumn'),
|
|
1063
937
|
ariaRowIndex: ariaRowIndex
|
|
1064
938
|
});
|
|
1065
|
-
var cellActions =
|
|
939
|
+
var cellActions = isExpandable ? ___EmotionJSX(React.Fragment, null, ___EmotionJSX(EuiDataGridCellActions, {
|
|
1066
940
|
rowIndex: rowIndex,
|
|
1067
941
|
colIndex: colIndex,
|
|
1068
942
|
column: column,
|
|
@@ -1079,23 +953,18 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1079
953
|
}), ___EmotionJSX("div", {
|
|
1080
954
|
ref: this.popoverAnchorRef,
|
|
1081
955
|
"data-test-subject": "cellPopoverAnchor"
|
|
1082
|
-
}));
|
|
1083
|
-
var cellContent =
|
|
956
|
+
})) : undefined;
|
|
957
|
+
var cellContent = ___EmotionJSX(HandleInteractiveChildren, {
|
|
958
|
+
cellEl: this.cellRef.current,
|
|
959
|
+
updateCellFocusContext: this.updateCellFocusContext,
|
|
960
|
+
renderFocusTrap: !isExpandable
|
|
961
|
+
}, ___EmotionJSX(EuiDataGridCellContent, _extends({}, cellContentProps, {
|
|
1084
962
|
cellActions: cellActions
|
|
1085
|
-
}))
|
|
1086
|
-
disabled: !this.state.isEntered,
|
|
1087
|
-
autoFocus: true,
|
|
1088
|
-
onDeactivation: function onDeactivation() {
|
|
1089
|
-
_this2.setState({
|
|
1090
|
-
isEntered: false
|
|
1091
|
-
}, _this2.preventTabbing);
|
|
1092
|
-
},
|
|
1093
|
-
clickOutsideDisables: true
|
|
1094
|
-
}, ___EmotionJSX(EuiDataGridCellContent, cellContentProps));
|
|
963
|
+
})));
|
|
1095
964
|
var cell = ___EmotionJSX("div", _extends({
|
|
1096
965
|
role: "gridcell",
|
|
1097
966
|
"aria-rowindex": ariaRowIndex,
|
|
1098
|
-
tabIndex: this.state.isFocused
|
|
967
|
+
tabIndex: this.state.isFocused ? 0 : -1,
|
|
1099
968
|
ref: this.cellRef
|
|
1100
969
|
}, cellProps, {
|
|
1101
970
|
"data-test-subj": "dataGridRowCell"
|
|
@@ -1109,19 +978,7 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1109
978
|
,
|
|
1110
979
|
"data-gridcell-visible-row-index": this.props.visibleRowIndex // Affected by sorting & pagination
|
|
1111
980
|
,
|
|
1112
|
-
onKeyDown: handleCellKeyDown
|
|
1113
|
-
onFocus: this.onFocus,
|
|
1114
|
-
onMouseEnter: function onMouseEnter() {
|
|
1115
|
-
_this2.setState({
|
|
1116
|
-
enableInteractions: true
|
|
1117
|
-
});
|
|
1118
|
-
},
|
|
1119
|
-
onMouseLeave: function onMouseLeave() {
|
|
1120
|
-
_this2.setState({
|
|
1121
|
-
enableInteractions: false
|
|
1122
|
-
});
|
|
1123
|
-
},
|
|
1124
|
-
onBlur: this.onBlur
|
|
981
|
+
onKeyDown: handleCellKeyDown
|
|
1125
982
|
}), cellContent);
|
|
1126
983
|
return rowManager && !IS_JEST_ENVIRONMENT ? /*#__PURE__*/createPortal(cell, rowManager.getRow({
|
|
1127
984
|
rowIndex: rowIndex,
|
|
@@ -1134,16 +991,6 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1134
991
|
}]);
|
|
1135
992
|
return EuiDataGridCell;
|
|
1136
993
|
}(Component);
|
|
1137
|
-
// focus tracking is split between the entire grid & individual cells,
|
|
1138
|
-
// the parent grid owns which cell is focused,
|
|
1139
|
-
// but individual cells need to react to changes and also report that
|
|
1140
|
-
// they are focused in response to user actions like clicking on the cell
|
|
1141
|
-
// to avoid focus trap fighting, cells wait a tick after being clicked to allow
|
|
1142
|
-
// any existing traps to disconnect before the cell reports the new focus state to the parent grid
|
|
1143
|
-
// but because of this small delay, multiple cells could queue up focus and
|
|
1144
|
-
// create an infinite loop as the cells activate->deactivate->...
|
|
1145
|
-
// so we track the last timeout id and clear that request if superseded
|
|
1146
|
-
_defineProperty(EuiDataGridCell, "activeFocusTimeoutId", undefined);
|
|
1147
994
|
_defineProperty(EuiDataGridCell, "contextType", DataGridFocusContext);
|
|
1148
995
|
EuiDataGridCell.propTypes = {
|
|
1149
996
|
rowIndex: PropTypes.number.isRequired,
|
package/es/components/datagrid/body/{data_grid_cell_actions.js → cell/data_grid_cell_actions.js}
RENAMED
|
@@ -18,11 +18,11 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import React, { useMemo, useCallback } from 'react';
|
|
21
|
-
import { EuiI18n } from '
|
|
22
|
-
import { EuiButtonIcon } from '
|
|
23
|
-
import { EuiButtonEmpty } from '
|
|
24
|
-
import { EuiFlexGroup, EuiFlexItem } from '
|
|
25
|
-
import { EuiPopoverFooter } from '
|
|
21
|
+
import { EuiI18n } from '../../../i18n';
|
|
22
|
+
import { EuiButtonIcon } from '../../../button/button_icon';
|
|
23
|
+
import { EuiButtonEmpty } from '../../../button/button_empty';
|
|
24
|
+
import { EuiFlexGroup, EuiFlexItem } from '../../../flex';
|
|
25
|
+
import { EuiPopoverFooter } from '../../../popover';
|
|
26
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
27
27
|
export var EuiDataGridCellActions = function EuiDataGridCellActions(_ref) {
|
|
28
28
|
var onExpandClick = _ref.onExpandClick,
|
package/es/components/datagrid/body/{data_grid_cell_popover.js → cell/data_grid_cell_popover.js}
RENAMED
|
@@ -21,8 +21,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
21
21
|
|
|
22
22
|
import React, { createContext, useState, useCallback } from 'react';
|
|
23
23
|
import classNames from 'classnames';
|
|
24
|
-
import { keys } from '
|
|
25
|
-
import { EuiWrappingPopover } from '
|
|
24
|
+
import { keys } from '../../../../services';
|
|
25
|
+
import { EuiWrappingPopover } from '../../../popover';
|
|
26
26
|
export var DataGridCellPopoverContext = /*#__PURE__*/createContext({
|
|
27
27
|
popoverIsOpen: false,
|
|
28
28
|
cellLocation: {
|
|
@@ -160,8 +160,8 @@ export var useCellPopover = function useCellPopover() {
|
|
|
160
160
|
/**
|
|
161
161
|
* Popover content renderers
|
|
162
162
|
*/
|
|
163
|
-
import { EuiText } from '
|
|
164
|
-
import { EuiCodeBlock } from '
|
|
163
|
+
import { EuiText } from '../../../text';
|
|
164
|
+
import { EuiCodeBlock } from '../../../code';
|
|
165
165
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
166
166
|
export var DefaultCellPopover = function DefaultCellPopover(_ref2) {
|
|
167
167
|
var schema = _ref2.schema,
|
package/es/components/datagrid/body/{data_grid_cell_wrapper.js → cell/data_grid_cell_wrapper.js}
RENAMED
|
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
16
|
|
|
17
17
|
import React, { useContext, useMemo } from 'react';
|
|
18
18
|
import classNames from 'classnames';
|
|
19
|
-
import { DataGridSortingContext } from '
|
|
19
|
+
import { DataGridSortingContext } from '../../utils/sorting';
|
|
20
20
|
import { DataGridCellPopoverContext } from './data_grid_cell_popover';
|
|
21
21
|
import { EuiDataGridCell } from './data_grid_cell';
|
|
22
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import React, { useEffect, useState, useMemo } from 'react';
|
|
16
|
+
import PropTypes from "prop-types";
|
|
17
|
+
import { tabbable } from 'tabbable';
|
|
18
|
+
import { keys } from '../../../../services';
|
|
19
|
+
import { EuiFocusTrap } from '../../../focus_trap';
|
|
20
|
+
import { EuiScreenReaderOnly } from '../../../accessibility';
|
|
21
|
+
import { EuiI18n } from '../../../i18n';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This internal utility component is used by all cells, both header and body/footer cells.
|
|
25
|
+
* It always handles:
|
|
26
|
+
* 1. Removing any interactive children from keyboard tab order on cell mount
|
|
27
|
+
* 2. Listening for focus on any interactive children and updating the cell focus context
|
|
28
|
+
*
|
|
29
|
+
* It should *only* render focus traps for:
|
|
30
|
+
* 1. Header cells that are `actions: false` but still have interactive children
|
|
31
|
+
* 2. Body cells that are `isExpandable: false` but still have interactive children
|
|
32
|
+
*/
|
|
33
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
34
|
+
export var HandleInteractiveChildren = function HandleInteractiveChildren(_ref) {
|
|
35
|
+
var cellEl = _ref.cellEl,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
38
|
+
renderFocusTrap = _ref.renderFocusTrap;
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
hasInteractiveChildren = _useState2[0],
|
|
42
|
+
setHasInteractiveChildren = _useState2[1];
|
|
43
|
+
|
|
44
|
+
// On mount, disable all interactive children
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (cellEl) {
|
|
47
|
+
var interactiveChildren = disableInteractives(cellEl);
|
|
48
|
+
if (renderFocusTrap) {
|
|
49
|
+
setHasInteractiveChildren(interactiveChildren.length > 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, [cellEl, renderFocusTrap]);
|
|
53
|
+
|
|
54
|
+
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
if (cellEl) {
|
|
57
|
+
var onFocus = function onFocus() {
|
|
58
|
+
return updateCellFocusContext();
|
|
59
|
+
};
|
|
60
|
+
cellEl.addEventListener('focus', onFocus, true); // useCapture listens for focus on children
|
|
61
|
+
return function () {
|
|
62
|
+
cellEl.removeEventListener('focus', onFocus, true);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, [cellEl, updateCellFocusContext]);
|
|
66
|
+
var _children = useMemo(function () {
|
|
67
|
+
return ___EmotionJSX(React.Fragment, null, children);
|
|
68
|
+
}, [children]);
|
|
69
|
+
if (!cellEl) return _children; // Do nothing if cell has yet to mount or is unmounting
|
|
70
|
+
if (!renderFocusTrap) return _children; // Cells with default actions / expansion popovers do not need to trap
|
|
71
|
+
if (!hasInteractiveChildren) return _children; // No need to focus trap if no children are interactive
|
|
72
|
+
|
|
73
|
+
return ___EmotionJSX(FocusTrappedChildren, {
|
|
74
|
+
cellEl: cellEl
|
|
75
|
+
}, children);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Cells with interactive children but no cell popover expansion should render a
|
|
80
|
+
* focus trap that can be entered with the Enter key, which cycles keyboard tabs
|
|
81
|
+
* through the cell contents only, and exited with the Escape key
|
|
82
|
+
*/
|
|
83
|
+
HandleInteractiveChildren.propTypes = {
|
|
84
|
+
cellEl: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.oneOf([null])]),
|
|
85
|
+
updateCellFocusContext: PropTypes.func.isRequired,
|
|
86
|
+
renderFocusTrap: PropTypes.bool
|
|
87
|
+
};
|
|
88
|
+
export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
89
|
+
var cellEl = _ref2.cellEl,
|
|
90
|
+
children = _ref2.children;
|
|
91
|
+
var _useState3 = useState(false),
|
|
92
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
|
+
isCellEntered = _useState4[0],
|
|
94
|
+
setIsCellEntered = _useState4[1];
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
if (isCellEntered) {
|
|
97
|
+
enableAndFocusInteractives(cellEl);
|
|
98
|
+
} else {
|
|
99
|
+
disableInteractives(cellEl);
|
|
100
|
+
}
|
|
101
|
+
}, [isCellEntered, cellEl]);
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
var onKeyUp = function onKeyUp(event) {
|
|
104
|
+
switch (event.key) {
|
|
105
|
+
case keys.ENTER:
|
|
106
|
+
case keys.F2:
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
setIsCellEntered(true);
|
|
109
|
+
break;
|
|
110
|
+
case keys.ESCAPE:
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
setIsCellEntered(function (isCellEntered) {
|
|
113
|
+
if (isCellEntered === true) {
|
|
114
|
+
requestAnimationFrame(function () {
|
|
115
|
+
return cellEl.focus();
|
|
116
|
+
}); // move focus to cell
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return isCellEntered;
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
cellEl.addEventListener('keyup', onKeyUp);
|
|
125
|
+
return function () {
|
|
126
|
+
cellEl.removeEventListener('keyup', onKeyUp);
|
|
127
|
+
};
|
|
128
|
+
}, [cellEl]);
|
|
129
|
+
return ___EmotionJSX(EuiFocusTrap, {
|
|
130
|
+
disabled: !isCellEntered,
|
|
131
|
+
onDeactivation: function onDeactivation() {
|
|
132
|
+
return setIsCellEntered(false);
|
|
133
|
+
},
|
|
134
|
+
clickOutsideDisables: true
|
|
135
|
+
}, children, ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", null, ' - ', ___EmotionJSX(EuiI18n
|
|
136
|
+
// eslint-disable-next-line local/i18n
|
|
137
|
+
, {
|
|
138
|
+
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
139
|
+
default: "Press the Enter key to interact with this cell's contents."
|
|
140
|
+
}))));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Utility fns for managing child interactive tabIndex state
|
|
145
|
+
*/
|
|
146
|
+
FocusTrappedChildren.propTypes = {
|
|
147
|
+
cellEl: PropTypes.any.isRequired
|
|
148
|
+
};
|
|
149
|
+
var disableInteractives = function disableInteractives(cell) {
|
|
150
|
+
var interactives = tabbable(cell);
|
|
151
|
+
interactives.forEach(function (element) {
|
|
152
|
+
element.setAttribute('data-euigrid-tab-managed', 'true');
|
|
153
|
+
element.setAttribute('tabIndex', '-1');
|
|
154
|
+
});
|
|
155
|
+
return interactives;
|
|
156
|
+
};
|
|
157
|
+
var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
158
|
+
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
159
|
+
interactives.forEach(function (element, i) {
|
|
160
|
+
element.setAttribute('tabIndex', '0');
|
|
161
|
+
if (i === 0) {
|
|
162
|
+
element.focus();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return interactives;
|
|
166
|
+
};
|