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