@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
|
@@ -19,17 +19,16 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
19
19
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
var _reactDom = require("react-dom");
|
|
22
|
-
var
|
|
23
|
-
var _services = require("
|
|
24
|
-
var _accessibility = require("
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var _focus = require("../utils/focus");
|
|
22
|
+
var _utils = require("../../../../utils");
|
|
23
|
+
var _services = require("../../../../services");
|
|
24
|
+
var _accessibility = require("../../../accessibility");
|
|
25
|
+
var _i18n = require("../../../i18n");
|
|
26
|
+
var _text_truncate = require("../../../text_truncate");
|
|
27
|
+
var _resize_observer = require("../../../observer/resize_observer/resize_observer");
|
|
28
|
+
var _focus = require("../../utils/focus");
|
|
30
29
|
var _data_grid_cell_actions = require("./data_grid_cell_actions");
|
|
31
30
|
var _data_grid_cell_popover = require("./data_grid_cell_popover");
|
|
32
|
-
var
|
|
31
|
+
var _focus_utils = require("./focus_utils");
|
|
33
32
|
var _react2 = require("@emotion/react");
|
|
34
33
|
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowIndex", "colIndex", "ariaRowIndex", "rowHeight", "rowHeightUtils", "isControlColumn", "isFocused", "cellActions"],
|
|
35
34
|
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
|
|
@@ -95,7 +94,10 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
95
94
|
col: colIndex + 1,
|
|
96
95
|
row: ariaRowIndex
|
|
97
96
|
}
|
|
98
|
-
})))
|
|
97
|
+
}), cellActions && (0, _react2.jsx)(_react.default.Fragment, null, '. ', (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
98
|
+
token: "euiDataGridCell.expansionEnterPrompt",
|
|
99
|
+
default: "Press the Enter key to expand this cell."
|
|
100
|
+
}))));
|
|
99
101
|
return (0, _react2.jsx)(_react.default.Fragment, null, cellContent, screenReaderText, cellActions);
|
|
100
102
|
});
|
|
101
103
|
EuiDataGridCellContent.propTypes = {
|
|
@@ -598,43 +600,20 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
598
600
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
599
601
|
cellProps: {},
|
|
600
602
|
isFocused: false,
|
|
601
|
-
isEntered: false,
|
|
602
|
-
enableInteractions: false,
|
|
603
|
-
disableCellTabIndex: false,
|
|
604
603
|
cellTextAlign: 'Left'
|
|
605
604
|
});
|
|
606
605
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unsubscribeCell", void 0);
|
|
607
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusTimeout", void 0);
|
|
608
606
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "style", null);
|
|
609
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
610
|
-
|
|
611
|
-
if (tabbingRef) {
|
|
612
|
-
return tabbingRef.querySelectorAll('[data-datagrid-interactable=true]');
|
|
613
|
-
}
|
|
614
|
-
return [];
|
|
607
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateCellFocusContext", function () {
|
|
608
|
+
_this.context.setFocusedCell([_this.props.colIndex, _this.props.visibleRowIndex]);
|
|
615
609
|
});
|
|
616
610
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "takeFocus", function (preventScroll) {
|
|
617
611
|
var cell = _this.cellRef.current;
|
|
618
|
-
if
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
var doFocusUpdate = element !== cell;
|
|
625
|
-
if (doFocusUpdate) {
|
|
626
|
-
var interactables = _this.getInteractables();
|
|
627
|
-
if (_this.isExpandable() === false && interactables.length === 1) {
|
|
628
|
-
// Only one element can be interacted with
|
|
629
|
-
interactables[0].focus({
|
|
630
|
-
preventScroll: preventScroll
|
|
631
|
-
});
|
|
632
|
-
} else {
|
|
633
|
-
cell.focus({
|
|
634
|
-
preventScroll: preventScroll
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
}
|
|
612
|
+
// Only focus the cell if not already focused on something in the cell
|
|
613
|
+
if (cell && !cell.contains(document.activeElement)) {
|
|
614
|
+
cell.focus({
|
|
615
|
+
preventScroll: preventScroll
|
|
616
|
+
});
|
|
638
617
|
}
|
|
639
618
|
});
|
|
640
619
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "recalculateAutoHeight", function () {
|
|
@@ -703,61 +682,8 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
703
682
|
} else if (_this.contentObserver) {
|
|
704
683
|
_this.contentObserver.disconnect();
|
|
705
684
|
}
|
|
706
|
-
_this.preventTabbing();
|
|
707
685
|
_this.setCellTextAlign();
|
|
708
686
|
});
|
|
709
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFocus", function (e) {
|
|
710
|
-
// only perform this logic when the event's originating element (e.target) is
|
|
711
|
-
// the wrapping element with the onFocus logic
|
|
712
|
-
// reasons:
|
|
713
|
-
// * the outcome is only meaningful when the focus shifts to the wrapping element
|
|
714
|
-
// * if the cell children include portalled content React will bubble the focus
|
|
715
|
-
// event up, which can trigger the focus() call below, causing focus lock fighting
|
|
716
|
-
if (_this.cellRef.current === e.target) {
|
|
717
|
-
var _this$props5 = _this.props,
|
|
718
|
-
colIndex = _this$props5.colIndex,
|
|
719
|
-
visibleRowIndex = _this$props5.visibleRowIndex;
|
|
720
|
-
// focus in next tick to give potential focus capturing mechanisms time to release their traps
|
|
721
|
-
// also clear any previous focus timeout that may still be queued
|
|
722
|
-
if (EuiDataGridCell.activeFocusTimeoutId) {
|
|
723
|
-
window.clearTimeout(EuiDataGridCell.activeFocusTimeoutId);
|
|
724
|
-
}
|
|
725
|
-
EuiDataGridCell.activeFocusTimeoutId = _this.focusTimeout = window.setTimeout(function () {
|
|
726
|
-
_this.context.setFocusedCell([colIndex, visibleRowIndex]);
|
|
727
|
-
var interactables = _this.getInteractables();
|
|
728
|
-
if (interactables.length === 1 && _this.isExpandable() === false) {
|
|
729
|
-
interactables[0].focus();
|
|
730
|
-
_this.setState({
|
|
731
|
-
disableCellTabIndex: true
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}, 0);
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function () {
|
|
738
|
-
_this.setState({
|
|
739
|
-
disableCellTabIndex: false
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preventTabbing", function () {
|
|
743
|
-
if (_this.cellContentsRef) {
|
|
744
|
-
var tabbables = (0, _tabbable.tabbable)(_this.cellContentsRef);
|
|
745
|
-
for (var i = 0; i < tabbables.length; i++) {
|
|
746
|
-
var element = tabbables[i];
|
|
747
|
-
element.setAttribute('tabIndex', '-1');
|
|
748
|
-
element.setAttribute('data-datagrid-interactable', 'true');
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableTabbing", function () {
|
|
753
|
-
if (_this.cellContentsRef) {
|
|
754
|
-
var interactables = _this.getInteractables();
|
|
755
|
-
for (var i = 0; i < interactables.length; i++) {
|
|
756
|
-
var element = interactables[i];
|
|
757
|
-
element.removeAttribute('tabIndex');
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
});
|
|
761
687
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setCellTextAlign", function () {
|
|
762
688
|
if (_this.cellContentsRef) {
|
|
763
689
|
var columnType = _this.props.columnType;
|
|
@@ -810,14 +736,14 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
810
736
|
setPopoverAnchorPosition("down".concat(_this.state.cellTextAlign));
|
|
811
737
|
|
|
812
738
|
// Set popover contents with cell content
|
|
813
|
-
var _this$
|
|
814
|
-
renderCellPopover = _this$
|
|
815
|
-
renderCellValue = _this$
|
|
816
|
-
rowIndex = _this$
|
|
817
|
-
colIndex = _this$
|
|
818
|
-
column = _this$
|
|
819
|
-
columnId = _this$
|
|
820
|
-
columnType = _this$
|
|
739
|
+
var _this$props5 = _this.props,
|
|
740
|
+
renderCellPopover = _this$props5.renderCellPopover,
|
|
741
|
+
renderCellValue = _this$props5.renderCellValue,
|
|
742
|
+
rowIndex = _this$props5.rowIndex,
|
|
743
|
+
colIndex = _this$props5.colIndex,
|
|
744
|
+
column = _this$props5.column,
|
|
745
|
+
columnId = _this$props5.columnId,
|
|
746
|
+
columnType = _this$props5.columnType;
|
|
821
747
|
var PopoverElement = renderCellPopover || _data_grid_cell_popover.DefaultCellPopover;
|
|
822
748
|
var CellElement = renderCellValue;
|
|
823
749
|
var sharedProps = {
|
|
@@ -847,9 +773,9 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
847
773
|
(0, _createClass2.default)(EuiDataGridCell, [{
|
|
848
774
|
key: "componentDidMount",
|
|
849
775
|
value: function componentDidMount() {
|
|
850
|
-
var _this$
|
|
851
|
-
colIndex = _this$
|
|
852
|
-
visibleRowIndex = _this$
|
|
776
|
+
var _this$props6 = this.props,
|
|
777
|
+
colIndex = _this$props6.colIndex,
|
|
778
|
+
visibleRowIndex = _this$props6.visibleRowIndex;
|
|
853
779
|
this.unsubscribeCell = this.context.onFocusUpdate([colIndex, visibleRowIndex], this.onFocusUpdate);
|
|
854
780
|
|
|
855
781
|
// Account for virtualization - when a cell unmounts when scrolled out of view
|
|
@@ -868,7 +794,6 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
868
794
|
}, {
|
|
869
795
|
key: "componentWillUnmount",
|
|
870
796
|
value: function componentWillUnmount() {
|
|
871
|
-
window.clearTimeout(this.focusTimeout);
|
|
872
797
|
if (this.unsubscribeCell) {
|
|
873
798
|
this.unsubscribeCell();
|
|
874
799
|
}
|
|
@@ -935,39 +860,33 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
935
860
|
if (nextProps.style.width !== this.props.style.width) return true;
|
|
936
861
|
}
|
|
937
862
|
if (nextState.cellProps !== this.state.cellProps) return true;
|
|
938
|
-
if (nextState.isEntered !== this.state.isEntered) return true;
|
|
939
863
|
if (nextState.isFocused !== this.state.isFocused) return true;
|
|
940
|
-
if (nextState.enableInteractions !== this.state.enableInteractions) return true;
|
|
941
|
-
if (nextState.disableCellTabIndex !== this.state.disableCellTabIndex) return true;
|
|
942
864
|
return false;
|
|
943
865
|
}
|
|
944
866
|
}, {
|
|
945
867
|
key: "render",
|
|
946
868
|
value: function render() {
|
|
947
|
-
var _classNames,
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
pagination = _this$props8.pagination,
|
|
964
|
-
rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded2);
|
|
869
|
+
var _classNames, _rowHeightsOptions$li;
|
|
870
|
+
var _this$props7 = this.props,
|
|
871
|
+
width = _this$props7.width,
|
|
872
|
+
_this$props7$popoverC = _this$props7.popoverContext,
|
|
873
|
+
closeCellPopover = _this$props7$popoverC.closeCellPopover,
|
|
874
|
+
openCellPopover = _this$props7$popoverC.openCellPopover,
|
|
875
|
+
interactiveCellId = _this$props7.interactiveCellId,
|
|
876
|
+
columnType = _this$props7.columnType,
|
|
877
|
+
className = _this$props7.className,
|
|
878
|
+
column = _this$props7.column,
|
|
879
|
+
style = _this$props7.style,
|
|
880
|
+
rowHeightUtils = _this$props7.rowHeightUtils,
|
|
881
|
+
rowHeightsOptions = _this$props7.rowHeightsOptions,
|
|
882
|
+
rowManager = _this$props7.rowManager,
|
|
883
|
+
pagination = _this$props7.pagination,
|
|
884
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props7, _excluded2);
|
|
965
885
|
var rowIndex = rest.rowIndex,
|
|
966
886
|
visibleRowIndex = rest.visibleRowIndex,
|
|
967
887
|
colIndex = rest.colIndex;
|
|
968
888
|
var isExpandable = this.isExpandable();
|
|
969
889
|
var popoverIsOpen = this.isPopoverOpen();
|
|
970
|
-
var showCellActions = this.state.isFocused || this.state.isEntered || this.state.enableInteractions || popoverIsOpen;
|
|
971
890
|
var cellClasses = (0, _classnames.default)('euiDataGridRowCell', "euiDataGridRowCell--align".concat(this.state.cellTextAlign), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "euiDataGridRowCell--".concat(columnType), columnType), (0, _defineProperty2.default)(_classNames, 'euiDataGridRowCell--open', popoverIsOpen), _classNames), className);
|
|
972
891
|
var ariaRowIndex = pagination ? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex : visibleRowIndex + 1;
|
|
973
892
|
var _this$state$cellProps2 = this.state.cellProps,
|
|
@@ -1003,51 +922,6 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1003
922
|
});
|
|
1004
923
|
break;
|
|
1005
924
|
}
|
|
1006
|
-
} else {
|
|
1007
|
-
if (event.key === _services.keys.ENTER || event.key === _services.keys.F2 || event.key === _services.keys.ESCAPE) {
|
|
1008
|
-
var interactables = _this2.getInteractables();
|
|
1009
|
-
if (interactables.length >= 2) {
|
|
1010
|
-
switch (event.key) {
|
|
1011
|
-
case _services.keys.ENTER:
|
|
1012
|
-
// `Enter` only activates the trap
|
|
1013
|
-
if (_this2.state.isEntered === false) {
|
|
1014
|
-
_this2.enableTabbing();
|
|
1015
|
-
_this2.setState({
|
|
1016
|
-
isEntered: true
|
|
1017
|
-
});
|
|
1018
|
-
|
|
1019
|
-
// result of this keypress is focus shifts to the first interactive element
|
|
1020
|
-
// and then the browser fires the onClick event because that's how [Enter] works
|
|
1021
|
-
// so we need to prevent that default action otherwise entering the trap triggers the first element
|
|
1022
|
-
event.preventDefault();
|
|
1023
|
-
}
|
|
1024
|
-
break;
|
|
1025
|
-
case _services.keys.F2:
|
|
1026
|
-
// toggle interactives' focus trap
|
|
1027
|
-
_this2.setState(function (_ref2) {
|
|
1028
|
-
var isEntered = _ref2.isEntered;
|
|
1029
|
-
if (isEntered) {
|
|
1030
|
-
_this2.preventTabbing();
|
|
1031
|
-
} else {
|
|
1032
|
-
_this2.enableTabbing();
|
|
1033
|
-
}
|
|
1034
|
-
return {
|
|
1035
|
-
isEntered: !isEntered
|
|
1036
|
-
};
|
|
1037
|
-
});
|
|
1038
|
-
break;
|
|
1039
|
-
case _services.keys.ESCAPE:
|
|
1040
|
-
// `Escape` only de-activates the trap
|
|
1041
|
-
_this2.preventTabbing();
|
|
1042
|
-
if (_this2.state.isEntered === true) {
|
|
1043
|
-
_this2.setState({
|
|
1044
|
-
isEntered: false
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
break;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
925
|
}
|
|
1052
926
|
};
|
|
1053
927
|
var rowHeight = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
|
|
@@ -1065,7 +939,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1065
939
|
isControlColumn: cellClasses.includes('euiDataGridRowCell--controlColumn'),
|
|
1066
940
|
ariaRowIndex: ariaRowIndex
|
|
1067
941
|
});
|
|
1068
|
-
var cellActions =
|
|
942
|
+
var cellActions = isExpandable ? (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_data_grid_cell_actions.EuiDataGridCellActions, {
|
|
1069
943
|
rowIndex: rowIndex,
|
|
1070
944
|
colIndex: colIndex,
|
|
1071
945
|
column: column,
|
|
@@ -1082,23 +956,18 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1082
956
|
}), (0, _react2.jsx)("div", {
|
|
1083
957
|
ref: this.popoverAnchorRef,
|
|
1084
958
|
"data-test-subject": "cellPopoverAnchor"
|
|
1085
|
-
}));
|
|
1086
|
-
var cellContent =
|
|
959
|
+
})) : undefined;
|
|
960
|
+
var cellContent = (0, _react2.jsx)(_focus_utils.HandleInteractiveChildren, {
|
|
961
|
+
cellEl: this.cellRef.current,
|
|
962
|
+
updateCellFocusContext: this.updateCellFocusContext,
|
|
963
|
+
renderFocusTrap: !isExpandable
|
|
964
|
+
}, (0, _react2.jsx)(EuiDataGridCellContent, (0, _extends2.default)({}, cellContentProps, {
|
|
1087
965
|
cellActions: cellActions
|
|
1088
|
-
}))
|
|
1089
|
-
disabled: !this.state.isEntered,
|
|
1090
|
-
autoFocus: true,
|
|
1091
|
-
onDeactivation: function onDeactivation() {
|
|
1092
|
-
_this2.setState({
|
|
1093
|
-
isEntered: false
|
|
1094
|
-
}, _this2.preventTabbing);
|
|
1095
|
-
},
|
|
1096
|
-
clickOutsideDisables: true
|
|
1097
|
-
}, (0, _react2.jsx)(EuiDataGridCellContent, cellContentProps));
|
|
966
|
+
})));
|
|
1098
967
|
var cell = (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
1099
968
|
role: "gridcell",
|
|
1100
969
|
"aria-rowindex": ariaRowIndex,
|
|
1101
|
-
tabIndex: this.state.isFocused
|
|
970
|
+
tabIndex: this.state.isFocused ? 0 : -1,
|
|
1102
971
|
ref: this.cellRef
|
|
1103
972
|
}, cellProps, {
|
|
1104
973
|
"data-test-subj": "dataGridRowCell"
|
|
@@ -1112,19 +981,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1112
981
|
,
|
|
1113
982
|
"data-gridcell-visible-row-index": this.props.visibleRowIndex // Affected by sorting & pagination
|
|
1114
983
|
,
|
|
1115
|
-
onKeyDown: handleCellKeyDown
|
|
1116
|
-
onFocus: this.onFocus,
|
|
1117
|
-
onMouseEnter: function onMouseEnter() {
|
|
1118
|
-
_this2.setState({
|
|
1119
|
-
enableInteractions: true
|
|
1120
|
-
});
|
|
1121
|
-
},
|
|
1122
|
-
onMouseLeave: function onMouseLeave() {
|
|
1123
|
-
_this2.setState({
|
|
1124
|
-
enableInteractions: false
|
|
1125
|
-
});
|
|
1126
|
-
},
|
|
1127
|
-
onBlur: this.onBlur
|
|
984
|
+
onKeyDown: handleCellKeyDown
|
|
1128
985
|
}), cellContent);
|
|
1129
986
|
return rowManager && !_utils.IS_JEST_ENVIRONMENT ? /*#__PURE__*/(0, _reactDom.createPortal)(cell, rowManager.getRow({
|
|
1130
987
|
rowIndex: rowIndex,
|
|
@@ -1138,16 +995,6 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
1138
995
|
return EuiDataGridCell;
|
|
1139
996
|
}(_react.Component);
|
|
1140
997
|
exports.EuiDataGridCell = EuiDataGridCell;
|
|
1141
|
-
// focus tracking is split between the entire grid & individual cells,
|
|
1142
|
-
// the parent grid owns which cell is focused,
|
|
1143
|
-
// but individual cells need to react to changes and also report that
|
|
1144
|
-
// they are focused in response to user actions like clicking on the cell
|
|
1145
|
-
// to avoid focus trap fighting, cells wait a tick after being clicked to allow
|
|
1146
|
-
// any existing traps to disconnect before the cell reports the new focus state to the parent grid
|
|
1147
|
-
// but because of this small delay, multiple cells could queue up focus and
|
|
1148
|
-
// create an infinite loop as the cells activate->deactivate->...
|
|
1149
|
-
// so we track the last timeout id and clear that request if superseded
|
|
1150
|
-
(0, _defineProperty2.default)(EuiDataGridCell, "activeFocusTimeoutId", undefined);
|
|
1151
998
|
(0, _defineProperty2.default)(EuiDataGridCell, "contextType", _focus.DataGridFocusContext);
|
|
1152
999
|
EuiDataGridCell.propTypes = {
|
|
1153
1000
|
rowIndex: _propTypes.default.number.isRequired,
|
|
@@ -10,11 +10,11 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
var _i18n = require("
|
|
14
|
-
var _button_icon = require("
|
|
15
|
-
var _button_empty = require("
|
|
16
|
-
var _flex = require("
|
|
17
|
-
var _popover = require("
|
|
13
|
+
var _i18n = require("../../../i18n");
|
|
14
|
+
var _button_icon = require("../../../button/button_icon");
|
|
15
|
+
var _button_empty = require("../../../button/button_empty");
|
|
16
|
+
var _flex = require("../../../flex");
|
|
17
|
+
var _popover = require("../../../popover");
|
|
18
18
|
var _react2 = require("@emotion/react");
|
|
19
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -11,10 +11,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _services = require("
|
|
15
|
-
var _popover = require("
|
|
16
|
-
var _text = require("
|
|
17
|
-
var _code = require("
|
|
14
|
+
var _services = require("../../../../services");
|
|
15
|
+
var _popover = require("../../../popover");
|
|
16
|
+
var _text = require("../../../text");
|
|
17
|
+
var _code = require("../../../code");
|
|
18
18
|
var _react2 = require("@emotion/react");
|
|
19
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _sorting = require("
|
|
14
|
+
var _sorting = require("../../utils/sorting");
|
|
15
15
|
var _data_grid_cell_popover = require("./data_grid_cell_popover");
|
|
16
16
|
var _data_grid_cell = require("./data_grid_cell");
|
|
17
17
|
var _react2 = require("@emotion/react");
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.HandleInteractiveChildren = exports.FocusTrappedChildren = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _tabbable = require("tabbable");
|
|
13
|
+
var _services = require("../../../../services");
|
|
14
|
+
var _focus_trap = require("../../../focus_trap");
|
|
15
|
+
var _accessibility = require("../../../accessibility");
|
|
16
|
+
var _i18n = require("../../../i18n");
|
|
17
|
+
var _react2 = require("@emotion/react");
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
+
/*
|
|
21
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
23
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
24
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
25
|
+
* Side Public License, v 1.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This internal utility component is used by all cells, both header and body/footer cells.
|
|
30
|
+
* It always handles:
|
|
31
|
+
* 1. Removing any interactive children from keyboard tab order on cell mount
|
|
32
|
+
* 2. Listening for focus on any interactive children and updating the cell focus context
|
|
33
|
+
*
|
|
34
|
+
* It should *only* render focus traps for:
|
|
35
|
+
* 1. Header cells that are `actions: false` but still have interactive children
|
|
36
|
+
* 2. Body cells that are `isExpandable: false` but still have interactive children
|
|
37
|
+
*/
|
|
38
|
+
var HandleInteractiveChildren = function HandleInteractiveChildren(_ref) {
|
|
39
|
+
var cellEl = _ref.cellEl,
|
|
40
|
+
children = _ref.children,
|
|
41
|
+
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
42
|
+
renderFocusTrap = _ref.renderFocusTrap;
|
|
43
|
+
var _useState = (0, _react.useState)(false),
|
|
44
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
45
|
+
hasInteractiveChildren = _useState2[0],
|
|
46
|
+
setHasInteractiveChildren = _useState2[1];
|
|
47
|
+
|
|
48
|
+
// On mount, disable all interactive children
|
|
49
|
+
(0, _react.useEffect)(function () {
|
|
50
|
+
if (cellEl) {
|
|
51
|
+
var interactiveChildren = disableInteractives(cellEl);
|
|
52
|
+
if (renderFocusTrap) {
|
|
53
|
+
setHasInteractiveChildren(interactiveChildren.length > 0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, [cellEl, renderFocusTrap]);
|
|
57
|
+
|
|
58
|
+
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
59
|
+
(0, _react.useEffect)(function () {
|
|
60
|
+
if (cellEl) {
|
|
61
|
+
var onFocus = function onFocus() {
|
|
62
|
+
return updateCellFocusContext();
|
|
63
|
+
};
|
|
64
|
+
cellEl.addEventListener('focus', onFocus, true); // useCapture listens for focus on children
|
|
65
|
+
return function () {
|
|
66
|
+
cellEl.removeEventListener('focus', onFocus, true);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}, [cellEl, updateCellFocusContext]);
|
|
70
|
+
var _children = (0, _react.useMemo)(function () {
|
|
71
|
+
return (0, _react2.jsx)(_react.default.Fragment, null, children);
|
|
72
|
+
}, [children]);
|
|
73
|
+
if (!cellEl) return _children; // Do nothing if cell has yet to mount or is unmounting
|
|
74
|
+
if (!renderFocusTrap) return _children; // Cells with default actions / expansion popovers do not need to trap
|
|
75
|
+
if (!hasInteractiveChildren) return _children; // No need to focus trap if no children are interactive
|
|
76
|
+
|
|
77
|
+
return (0, _react2.jsx)(FocusTrappedChildren, {
|
|
78
|
+
cellEl: cellEl
|
|
79
|
+
}, children);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Cells with interactive children but no cell popover expansion should render a
|
|
84
|
+
* focus trap that can be entered with the Enter key, which cycles keyboard tabs
|
|
85
|
+
* through the cell contents only, and exited with the Escape key
|
|
86
|
+
*/
|
|
87
|
+
exports.HandleInteractiveChildren = HandleInteractiveChildren;
|
|
88
|
+
HandleInteractiveChildren.propTypes = {
|
|
89
|
+
cellEl: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.oneOf([null])]),
|
|
90
|
+
updateCellFocusContext: _propTypes.default.func.isRequired,
|
|
91
|
+
renderFocusTrap: _propTypes.default.bool
|
|
92
|
+
};
|
|
93
|
+
var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
94
|
+
var cellEl = _ref2.cellEl,
|
|
95
|
+
children = _ref2.children;
|
|
96
|
+
var _useState3 = (0, _react.useState)(false),
|
|
97
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
98
|
+
isCellEntered = _useState4[0],
|
|
99
|
+
setIsCellEntered = _useState4[1];
|
|
100
|
+
(0, _react.useEffect)(function () {
|
|
101
|
+
if (isCellEntered) {
|
|
102
|
+
enableAndFocusInteractives(cellEl);
|
|
103
|
+
} else {
|
|
104
|
+
disableInteractives(cellEl);
|
|
105
|
+
}
|
|
106
|
+
}, [isCellEntered, cellEl]);
|
|
107
|
+
(0, _react.useEffect)(function () {
|
|
108
|
+
var onKeyUp = function onKeyUp(event) {
|
|
109
|
+
switch (event.key) {
|
|
110
|
+
case _services.keys.ENTER:
|
|
111
|
+
case _services.keys.F2:
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
setIsCellEntered(true);
|
|
114
|
+
break;
|
|
115
|
+
case _services.keys.ESCAPE:
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
setIsCellEntered(function (isCellEntered) {
|
|
118
|
+
if (isCellEntered === true) {
|
|
119
|
+
requestAnimationFrame(function () {
|
|
120
|
+
return cellEl.focus();
|
|
121
|
+
}); // move focus to cell
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return isCellEntered;
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
cellEl.addEventListener('keyup', onKeyUp);
|
|
130
|
+
return function () {
|
|
131
|
+
cellEl.removeEventListener('keyup', onKeyUp);
|
|
132
|
+
};
|
|
133
|
+
}, [cellEl]);
|
|
134
|
+
return (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
|
|
135
|
+
disabled: !isCellEntered,
|
|
136
|
+
onDeactivation: function onDeactivation() {
|
|
137
|
+
return setIsCellEntered(false);
|
|
138
|
+
},
|
|
139
|
+
clickOutsideDisables: true
|
|
140
|
+
}, children, (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", null, ' - ', (0, _react2.jsx)(_i18n.EuiI18n
|
|
141
|
+
// eslint-disable-next-line local/i18n
|
|
142
|
+
, {
|
|
143
|
+
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
144
|
+
default: "Press the Enter key to interact with this cell's contents."
|
|
145
|
+
}))));
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Utility fns for managing child interactive tabIndex state
|
|
150
|
+
*/
|
|
151
|
+
exports.FocusTrappedChildren = FocusTrappedChildren;
|
|
152
|
+
FocusTrappedChildren.propTypes = {
|
|
153
|
+
cellEl: _propTypes.default.any.isRequired
|
|
154
|
+
};
|
|
155
|
+
var disableInteractives = function disableInteractives(cell) {
|
|
156
|
+
var interactives = (0, _tabbable.tabbable)(cell);
|
|
157
|
+
interactives.forEach(function (element) {
|
|
158
|
+
element.setAttribute('data-euigrid-tab-managed', 'true');
|
|
159
|
+
element.setAttribute('tabIndex', '-1');
|
|
160
|
+
});
|
|
161
|
+
return interactives;
|
|
162
|
+
};
|
|
163
|
+
var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
164
|
+
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
165
|
+
interactives.forEach(function (element, i) {
|
|
166
|
+
element.setAttribute('tabIndex', '0');
|
|
167
|
+
if (i === 0) {
|
|
168
|
+
element.focus();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return interactives;
|
|
172
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Cell", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _data_grid_cell_wrapper.Cell;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "DataGridCellPopoverContext", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _data_grid_cell_popover.DataGridCellPopoverContext;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "EuiDataGridCell", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _data_grid_cell.EuiDataGridCell;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useCellPopover", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _data_grid_cell_popover.useCellPopover;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _data_grid_cell = require("./data_grid_cell");
|
|
31
|
+
var _data_grid_cell_wrapper = require("./data_grid_cell_wrapper");
|
|
32
|
+
var _data_grid_cell_popover = require("./data_grid_cell_popover");
|
|
@@ -573,8 +573,6 @@ EuiDataGridBody.propTypes = {
|
|
|
573
573
|
renderCustomGridBody: _propTypes.default.func,
|
|
574
574
|
interactiveCellId: _propTypes.default.string.isRequired,
|
|
575
575
|
pagination: _propTypes.default.any,
|
|
576
|
-
headerIsInteractive: _propTypes.default.bool.isRequired,
|
|
577
|
-
handleHeaderMutation: _propTypes.default.any.isRequired,
|
|
578
576
|
setVisibleColumns: _propTypes.default.func.isRequired,
|
|
579
577
|
switchColumnPos: _propTypes.default.func.isRequired,
|
|
580
578
|
onColumnResize: _propTypes.default.func,
|