@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
|
@@ -18,17 +18,16 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
|
|
|
18
18
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
19
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
20
|
var _reactDom = require("react-dom");
|
|
21
|
-
var
|
|
22
|
-
var _services = require("
|
|
23
|
-
var _accessibility = require("
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var _focus = require("../utils/focus");
|
|
21
|
+
var _utils = require("../../../../utils");
|
|
22
|
+
var _services = require("../../../../services");
|
|
23
|
+
var _accessibility = require("../../../accessibility");
|
|
24
|
+
var _i18n = require("../../../i18n");
|
|
25
|
+
var _text_truncate = require("../../../text_truncate");
|
|
26
|
+
var _resize_observer = require("../../../observer/resize_observer/resize_observer");
|
|
27
|
+
var _focus = require("../../utils/focus");
|
|
29
28
|
var _data_grid_cell_actions = require("./data_grid_cell_actions");
|
|
30
29
|
var _data_grid_cell_popover = require("./data_grid_cell_popover");
|
|
31
|
-
var
|
|
30
|
+
var _focus_utils = require("./focus_utils");
|
|
32
31
|
var _react2 = require("@emotion/react");
|
|
33
32
|
var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowIndex", "colIndex", "ariaRowIndex", "rowHeight", "rowHeightUtils", "isControlColumn", "isFocused", "cellActions"],
|
|
34
33
|
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
|
|
@@ -94,7 +93,10 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
94
93
|
col: colIndex + 1,
|
|
95
94
|
row: ariaRowIndex
|
|
96
95
|
}
|
|
97
|
-
})))
|
|
96
|
+
}), cellActions && (0, _react2.jsx)(_react.default.Fragment, null, '. ', (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
97
|
+
token: "euiDataGridCell.expansionEnterPrompt",
|
|
98
|
+
default: "Press the Enter key to expand this cell."
|
|
99
|
+
}))));
|
|
98
100
|
return (0, _react2.jsx)(_react.default.Fragment, null, cellContent, screenReaderText, cellActions);
|
|
99
101
|
});
|
|
100
102
|
var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
@@ -115,43 +117,20 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
115
117
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
116
118
|
cellProps: {},
|
|
117
119
|
isFocused: false,
|
|
118
|
-
isEntered: false,
|
|
119
|
-
enableInteractions: false,
|
|
120
|
-
disableCellTabIndex: false,
|
|
121
120
|
cellTextAlign: 'Left'
|
|
122
121
|
});
|
|
123
122
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unsubscribeCell", void 0);
|
|
124
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusTimeout", void 0);
|
|
125
123
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "style", null);
|
|
126
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "
|
|
127
|
-
|
|
128
|
-
if (tabbingRef) {
|
|
129
|
-
return tabbingRef.querySelectorAll('[data-datagrid-interactable=true]');
|
|
130
|
-
}
|
|
131
|
-
return [];
|
|
124
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateCellFocusContext", function () {
|
|
125
|
+
_this.context.setFocusedCell([_this.props.colIndex, _this.props.visibleRowIndex]);
|
|
132
126
|
});
|
|
133
127
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "takeFocus", function (preventScroll) {
|
|
134
128
|
var cell = _this.cellRef.current;
|
|
135
|
-
if
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
var doFocusUpdate = element !== cell;
|
|
142
|
-
if (doFocusUpdate) {
|
|
143
|
-
var interactables = _this.getInteractables();
|
|
144
|
-
if (_this.isExpandable() === false && interactables.length === 1) {
|
|
145
|
-
// Only one element can be interacted with
|
|
146
|
-
interactables[0].focus({
|
|
147
|
-
preventScroll: preventScroll
|
|
148
|
-
});
|
|
149
|
-
} else {
|
|
150
|
-
cell.focus({
|
|
151
|
-
preventScroll: preventScroll
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
129
|
+
// Only focus the cell if not already focused on something in the cell
|
|
130
|
+
if (cell && !cell.contains(document.activeElement)) {
|
|
131
|
+
cell.focus({
|
|
132
|
+
preventScroll: preventScroll
|
|
133
|
+
});
|
|
155
134
|
}
|
|
156
135
|
});
|
|
157
136
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "recalculateAutoHeight", function () {
|
|
@@ -220,61 +199,8 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
220
199
|
} else if (_this.contentObserver) {
|
|
221
200
|
_this.contentObserver.disconnect();
|
|
222
201
|
}
|
|
223
|
-
_this.preventTabbing();
|
|
224
202
|
_this.setCellTextAlign();
|
|
225
203
|
});
|
|
226
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFocus", function (e) {
|
|
227
|
-
// only perform this logic when the event's originating element (e.target) is
|
|
228
|
-
// the wrapping element with the onFocus logic
|
|
229
|
-
// reasons:
|
|
230
|
-
// * the outcome is only meaningful when the focus shifts to the wrapping element
|
|
231
|
-
// * if the cell children include portalled content React will bubble the focus
|
|
232
|
-
// event up, which can trigger the focus() call below, causing focus lock fighting
|
|
233
|
-
if (_this.cellRef.current === e.target) {
|
|
234
|
-
var _this$props5 = _this.props,
|
|
235
|
-
colIndex = _this$props5.colIndex,
|
|
236
|
-
visibleRowIndex = _this$props5.visibleRowIndex;
|
|
237
|
-
// focus in next tick to give potential focus capturing mechanisms time to release their traps
|
|
238
|
-
// also clear any previous focus timeout that may still be queued
|
|
239
|
-
if (EuiDataGridCell.activeFocusTimeoutId) {
|
|
240
|
-
window.clearTimeout(EuiDataGridCell.activeFocusTimeoutId);
|
|
241
|
-
}
|
|
242
|
-
EuiDataGridCell.activeFocusTimeoutId = _this.focusTimeout = window.setTimeout(function () {
|
|
243
|
-
_this.context.setFocusedCell([colIndex, visibleRowIndex]);
|
|
244
|
-
var interactables = _this.getInteractables();
|
|
245
|
-
if (interactables.length === 1 && _this.isExpandable() === false) {
|
|
246
|
-
interactables[0].focus();
|
|
247
|
-
_this.setState({
|
|
248
|
-
disableCellTabIndex: true
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}, 0);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function () {
|
|
255
|
-
_this.setState({
|
|
256
|
-
disableCellTabIndex: false
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "preventTabbing", function () {
|
|
260
|
-
if (_this.cellContentsRef) {
|
|
261
|
-
var tabbables = (0, _tabbable.tabbable)(_this.cellContentsRef);
|
|
262
|
-
for (var i = 0; i < tabbables.length; i++) {
|
|
263
|
-
var element = tabbables[i];
|
|
264
|
-
element.setAttribute('tabIndex', '-1');
|
|
265
|
-
element.setAttribute('data-datagrid-interactable', 'true');
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "enableTabbing", function () {
|
|
270
|
-
if (_this.cellContentsRef) {
|
|
271
|
-
var interactables = _this.getInteractables();
|
|
272
|
-
for (var i = 0; i < interactables.length; i++) {
|
|
273
|
-
var element = interactables[i];
|
|
274
|
-
element.removeAttribute('tabIndex');
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
204
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setCellTextAlign", function () {
|
|
279
205
|
if (_this.cellContentsRef) {
|
|
280
206
|
var columnType = _this.props.columnType;
|
|
@@ -327,14 +253,14 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
327
253
|
setPopoverAnchorPosition("down".concat(_this.state.cellTextAlign));
|
|
328
254
|
|
|
329
255
|
// Set popover contents with cell content
|
|
330
|
-
var _this$
|
|
331
|
-
renderCellPopover = _this$
|
|
332
|
-
renderCellValue = _this$
|
|
333
|
-
rowIndex = _this$
|
|
334
|
-
colIndex = _this$
|
|
335
|
-
column = _this$
|
|
336
|
-
columnId = _this$
|
|
337
|
-
columnType = _this$
|
|
256
|
+
var _this$props5 = _this.props,
|
|
257
|
+
renderCellPopover = _this$props5.renderCellPopover,
|
|
258
|
+
renderCellValue = _this$props5.renderCellValue,
|
|
259
|
+
rowIndex = _this$props5.rowIndex,
|
|
260
|
+
colIndex = _this$props5.colIndex,
|
|
261
|
+
column = _this$props5.column,
|
|
262
|
+
columnId = _this$props5.columnId,
|
|
263
|
+
columnType = _this$props5.columnType;
|
|
338
264
|
var PopoverElement = renderCellPopover || _data_grid_cell_popover.DefaultCellPopover;
|
|
339
265
|
var CellElement = renderCellValue;
|
|
340
266
|
var sharedProps = {
|
|
@@ -364,9 +290,9 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
364
290
|
(0, _createClass2.default)(EuiDataGridCell, [{
|
|
365
291
|
key: "componentDidMount",
|
|
366
292
|
value: function componentDidMount() {
|
|
367
|
-
var _this$
|
|
368
|
-
colIndex = _this$
|
|
369
|
-
visibleRowIndex = _this$
|
|
293
|
+
var _this$props6 = this.props,
|
|
294
|
+
colIndex = _this$props6.colIndex,
|
|
295
|
+
visibleRowIndex = _this$props6.visibleRowIndex;
|
|
370
296
|
this.unsubscribeCell = this.context.onFocusUpdate([colIndex, visibleRowIndex], this.onFocusUpdate);
|
|
371
297
|
|
|
372
298
|
// Account for virtualization - when a cell unmounts when scrolled out of view
|
|
@@ -385,7 +311,6 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
385
311
|
}, {
|
|
386
312
|
key: "componentWillUnmount",
|
|
387
313
|
value: function componentWillUnmount() {
|
|
388
|
-
window.clearTimeout(this.focusTimeout);
|
|
389
314
|
if (this.unsubscribeCell) {
|
|
390
315
|
this.unsubscribeCell();
|
|
391
316
|
}
|
|
@@ -452,39 +377,33 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
452
377
|
if (nextProps.style.width !== this.props.style.width) return true;
|
|
453
378
|
}
|
|
454
379
|
if (nextState.cellProps !== this.state.cellProps) return true;
|
|
455
|
-
if (nextState.isEntered !== this.state.isEntered) return true;
|
|
456
380
|
if (nextState.isFocused !== this.state.isFocused) return true;
|
|
457
|
-
if (nextState.enableInteractions !== this.state.enableInteractions) return true;
|
|
458
|
-
if (nextState.disableCellTabIndex !== this.state.disableCellTabIndex) return true;
|
|
459
381
|
return false;
|
|
460
382
|
}
|
|
461
383
|
}, {
|
|
462
384
|
key: "render",
|
|
463
385
|
value: function render() {
|
|
464
|
-
var _classNames,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
pagination = _this$props8.pagination,
|
|
481
|
-
rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded2);
|
|
386
|
+
var _classNames, _rowHeightsOptions$li;
|
|
387
|
+
var _this$props7 = this.props,
|
|
388
|
+
width = _this$props7.width,
|
|
389
|
+
_this$props7$popoverC = _this$props7.popoverContext,
|
|
390
|
+
closeCellPopover = _this$props7$popoverC.closeCellPopover,
|
|
391
|
+
openCellPopover = _this$props7$popoverC.openCellPopover,
|
|
392
|
+
interactiveCellId = _this$props7.interactiveCellId,
|
|
393
|
+
columnType = _this$props7.columnType,
|
|
394
|
+
className = _this$props7.className,
|
|
395
|
+
column = _this$props7.column,
|
|
396
|
+
style = _this$props7.style,
|
|
397
|
+
rowHeightUtils = _this$props7.rowHeightUtils,
|
|
398
|
+
rowHeightsOptions = _this$props7.rowHeightsOptions,
|
|
399
|
+
rowManager = _this$props7.rowManager,
|
|
400
|
+
pagination = _this$props7.pagination,
|
|
401
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props7, _excluded2);
|
|
482
402
|
var rowIndex = rest.rowIndex,
|
|
483
403
|
visibleRowIndex = rest.visibleRowIndex,
|
|
484
404
|
colIndex = rest.colIndex;
|
|
485
405
|
var isExpandable = this.isExpandable();
|
|
486
406
|
var popoverIsOpen = this.isPopoverOpen();
|
|
487
|
-
var showCellActions = this.state.isFocused || this.state.isEntered || this.state.enableInteractions || popoverIsOpen;
|
|
488
407
|
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);
|
|
489
408
|
var ariaRowIndex = pagination ? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex : visibleRowIndex + 1;
|
|
490
409
|
var _this$state$cellProps2 = this.state.cellProps,
|
|
@@ -520,51 +439,6 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
520
439
|
});
|
|
521
440
|
break;
|
|
522
441
|
}
|
|
523
|
-
} else {
|
|
524
|
-
if (event.key === _services.keys.ENTER || event.key === _services.keys.F2 || event.key === _services.keys.ESCAPE) {
|
|
525
|
-
var interactables = _this2.getInteractables();
|
|
526
|
-
if (interactables.length >= 2) {
|
|
527
|
-
switch (event.key) {
|
|
528
|
-
case _services.keys.ENTER:
|
|
529
|
-
// `Enter` only activates the trap
|
|
530
|
-
if (_this2.state.isEntered === false) {
|
|
531
|
-
_this2.enableTabbing();
|
|
532
|
-
_this2.setState({
|
|
533
|
-
isEntered: true
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
// result of this keypress is focus shifts to the first interactive element
|
|
537
|
-
// and then the browser fires the onClick event because that's how [Enter] works
|
|
538
|
-
// so we need to prevent that default action otherwise entering the trap triggers the first element
|
|
539
|
-
event.preventDefault();
|
|
540
|
-
}
|
|
541
|
-
break;
|
|
542
|
-
case _services.keys.F2:
|
|
543
|
-
// toggle interactives' focus trap
|
|
544
|
-
_this2.setState(function (_ref2) {
|
|
545
|
-
var isEntered = _ref2.isEntered;
|
|
546
|
-
if (isEntered) {
|
|
547
|
-
_this2.preventTabbing();
|
|
548
|
-
} else {
|
|
549
|
-
_this2.enableTabbing();
|
|
550
|
-
}
|
|
551
|
-
return {
|
|
552
|
-
isEntered: !isEntered
|
|
553
|
-
};
|
|
554
|
-
});
|
|
555
|
-
break;
|
|
556
|
-
case _services.keys.ESCAPE:
|
|
557
|
-
// `Escape` only de-activates the trap
|
|
558
|
-
_this2.preventTabbing();
|
|
559
|
-
if (_this2.state.isEntered === true) {
|
|
560
|
-
_this2.setState({
|
|
561
|
-
isEntered: false
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
break;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
442
|
}
|
|
569
443
|
};
|
|
570
444
|
var rowHeight = rowHeightUtils === null || rowHeightUtils === void 0 ? void 0 : rowHeightUtils.getRowHeightOption(rowIndex, rowHeightsOptions);
|
|
@@ -582,7 +456,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
582
456
|
isControlColumn: cellClasses.includes('euiDataGridRowCell--controlColumn'),
|
|
583
457
|
ariaRowIndex: ariaRowIndex
|
|
584
458
|
});
|
|
585
|
-
var cellActions =
|
|
459
|
+
var cellActions = isExpandable ? (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_data_grid_cell_actions.EuiDataGridCellActions, {
|
|
586
460
|
rowIndex: rowIndex,
|
|
587
461
|
colIndex: colIndex,
|
|
588
462
|
column: column,
|
|
@@ -599,23 +473,18 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
599
473
|
}), (0, _react2.jsx)("div", {
|
|
600
474
|
ref: this.popoverAnchorRef,
|
|
601
475
|
"data-test-subject": "cellPopoverAnchor"
|
|
602
|
-
}));
|
|
603
|
-
var cellContent =
|
|
476
|
+
})) : undefined;
|
|
477
|
+
var cellContent = (0, _react2.jsx)(_focus_utils.HandleInteractiveChildren, {
|
|
478
|
+
cellEl: this.cellRef.current,
|
|
479
|
+
updateCellFocusContext: this.updateCellFocusContext,
|
|
480
|
+
renderFocusTrap: !isExpandable
|
|
481
|
+
}, (0, _react2.jsx)(EuiDataGridCellContent, (0, _extends2.default)({}, cellContentProps, {
|
|
604
482
|
cellActions: cellActions
|
|
605
|
-
}))
|
|
606
|
-
disabled: !this.state.isEntered,
|
|
607
|
-
autoFocus: true,
|
|
608
|
-
onDeactivation: function onDeactivation() {
|
|
609
|
-
_this2.setState({
|
|
610
|
-
isEntered: false
|
|
611
|
-
}, _this2.preventTabbing);
|
|
612
|
-
},
|
|
613
|
-
clickOutsideDisables: true
|
|
614
|
-
}, (0, _react2.jsx)(EuiDataGridCellContent, cellContentProps));
|
|
483
|
+
})));
|
|
615
484
|
var cell = (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
616
485
|
role: "gridcell",
|
|
617
486
|
"aria-rowindex": ariaRowIndex,
|
|
618
|
-
tabIndex: this.state.isFocused
|
|
487
|
+
tabIndex: this.state.isFocused ? 0 : -1,
|
|
619
488
|
ref: this.cellRef
|
|
620
489
|
}, cellProps, {
|
|
621
490
|
"data-test-subj": "dataGridRowCell"
|
|
@@ -629,19 +498,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
629
498
|
,
|
|
630
499
|
"data-gridcell-visible-row-index": this.props.visibleRowIndex // Affected by sorting & pagination
|
|
631
500
|
,
|
|
632
|
-
onKeyDown: handleCellKeyDown
|
|
633
|
-
onFocus: this.onFocus,
|
|
634
|
-
onMouseEnter: function onMouseEnter() {
|
|
635
|
-
_this2.setState({
|
|
636
|
-
enableInteractions: true
|
|
637
|
-
});
|
|
638
|
-
},
|
|
639
|
-
onMouseLeave: function onMouseLeave() {
|
|
640
|
-
_this2.setState({
|
|
641
|
-
enableInteractions: false
|
|
642
|
-
});
|
|
643
|
-
},
|
|
644
|
-
onBlur: this.onBlur
|
|
501
|
+
onKeyDown: handleCellKeyDown
|
|
645
502
|
}), cellContent);
|
|
646
503
|
return rowManager && !_utils.IS_JEST_ENVIRONMENT ? /*#__PURE__*/(0, _reactDom.createPortal)(cell, rowManager.getRow({
|
|
647
504
|
rowIndex: rowIndex,
|
|
@@ -655,14 +512,4 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
655
512
|
return EuiDataGridCell;
|
|
656
513
|
}(_react.Component);
|
|
657
514
|
exports.EuiDataGridCell = EuiDataGridCell;
|
|
658
|
-
// focus tracking is split between the entire grid & individual cells,
|
|
659
|
-
// the parent grid owns which cell is focused,
|
|
660
|
-
// but individual cells need to react to changes and also report that
|
|
661
|
-
// they are focused in response to user actions like clicking on the cell
|
|
662
|
-
// to avoid focus trap fighting, cells wait a tick after being clicked to allow
|
|
663
|
-
// any existing traps to disconnect before the cell reports the new focus state to the parent grid
|
|
664
|
-
// but because of this small delay, multiple cells could queue up focus and
|
|
665
|
-
// create an infinite loop as the cells activate->deactivate->...
|
|
666
|
-
// so we track the last timeout id and clear that request if superseded
|
|
667
|
-
(0, _defineProperty2.default)(EuiDataGridCell, "activeFocusTimeoutId", undefined);
|
|
668
515
|
(0, _defineProperty2.default)(EuiDataGridCell, "contextType", _focus.DataGridFocusContext);
|
|
@@ -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,163 @@
|
|
|
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 _tabbable = require("tabbable");
|
|
12
|
+
var _services = require("../../../../services");
|
|
13
|
+
var _focus_trap = require("../../../focus_trap");
|
|
14
|
+
var _accessibility = require("../../../accessibility");
|
|
15
|
+
var _i18n = require("../../../i18n");
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
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
|
+
/*
|
|
20
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
21
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
22
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
23
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
24
|
+
* Side Public License, v 1.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This internal utility component is used by all cells, both header and body/footer cells.
|
|
29
|
+
* It always handles:
|
|
30
|
+
* 1. Removing any interactive children from keyboard tab order on cell mount
|
|
31
|
+
* 2. Listening for focus on any interactive children and updating the cell focus context
|
|
32
|
+
*
|
|
33
|
+
* It should *only* render focus traps for:
|
|
34
|
+
* 1. Header cells that are `actions: false` but still have interactive children
|
|
35
|
+
* 2. Body cells that are `isExpandable: false` but still have interactive children
|
|
36
|
+
*/
|
|
37
|
+
var HandleInteractiveChildren = function HandleInteractiveChildren(_ref) {
|
|
38
|
+
var cellEl = _ref.cellEl,
|
|
39
|
+
children = _ref.children,
|
|
40
|
+
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
41
|
+
renderFocusTrap = _ref.renderFocusTrap;
|
|
42
|
+
var _useState = (0, _react.useState)(false),
|
|
43
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
|
+
hasInteractiveChildren = _useState2[0],
|
|
45
|
+
setHasInteractiveChildren = _useState2[1];
|
|
46
|
+
|
|
47
|
+
// On mount, disable all interactive children
|
|
48
|
+
(0, _react.useEffect)(function () {
|
|
49
|
+
if (cellEl) {
|
|
50
|
+
var interactiveChildren = disableInteractives(cellEl);
|
|
51
|
+
if (renderFocusTrap) {
|
|
52
|
+
setHasInteractiveChildren(interactiveChildren.length > 0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [cellEl, renderFocusTrap]);
|
|
56
|
+
|
|
57
|
+
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
58
|
+
(0, _react.useEffect)(function () {
|
|
59
|
+
if (cellEl) {
|
|
60
|
+
var onFocus = function onFocus() {
|
|
61
|
+
return updateCellFocusContext();
|
|
62
|
+
};
|
|
63
|
+
cellEl.addEventListener('focus', onFocus, true); // useCapture listens for focus on children
|
|
64
|
+
return function () {
|
|
65
|
+
cellEl.removeEventListener('focus', onFocus, true);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, [cellEl, updateCellFocusContext]);
|
|
69
|
+
var _children = (0, _react.useMemo)(function () {
|
|
70
|
+
return (0, _react2.jsx)(_react.default.Fragment, null, children);
|
|
71
|
+
}, [children]);
|
|
72
|
+
if (!cellEl) return _children; // Do nothing if cell has yet to mount or is unmounting
|
|
73
|
+
if (!renderFocusTrap) return _children; // Cells with default actions / expansion popovers do not need to trap
|
|
74
|
+
if (!hasInteractiveChildren) return _children; // No need to focus trap if no children are interactive
|
|
75
|
+
|
|
76
|
+
return (0, _react2.jsx)(FocusTrappedChildren, {
|
|
77
|
+
cellEl: cellEl
|
|
78
|
+
}, children);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Cells with interactive children but no cell popover expansion should render a
|
|
83
|
+
* focus trap that can be entered with the Enter key, which cycles keyboard tabs
|
|
84
|
+
* through the cell contents only, and exited with the Escape key
|
|
85
|
+
*/
|
|
86
|
+
exports.HandleInteractiveChildren = HandleInteractiveChildren;
|
|
87
|
+
var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
88
|
+
var cellEl = _ref2.cellEl,
|
|
89
|
+
children = _ref2.children;
|
|
90
|
+
var _useState3 = (0, _react.useState)(false),
|
|
91
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
92
|
+
isCellEntered = _useState4[0],
|
|
93
|
+
setIsCellEntered = _useState4[1];
|
|
94
|
+
(0, _react.useEffect)(function () {
|
|
95
|
+
if (isCellEntered) {
|
|
96
|
+
enableAndFocusInteractives(cellEl);
|
|
97
|
+
} else {
|
|
98
|
+
disableInteractives(cellEl);
|
|
99
|
+
}
|
|
100
|
+
}, [isCellEntered, cellEl]);
|
|
101
|
+
(0, _react.useEffect)(function () {
|
|
102
|
+
var onKeyUp = function onKeyUp(event) {
|
|
103
|
+
switch (event.key) {
|
|
104
|
+
case _services.keys.ENTER:
|
|
105
|
+
case _services.keys.F2:
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
setIsCellEntered(true);
|
|
108
|
+
break;
|
|
109
|
+
case _services.keys.ESCAPE:
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
setIsCellEntered(function (isCellEntered) {
|
|
112
|
+
if (isCellEntered === true) {
|
|
113
|
+
requestAnimationFrame(function () {
|
|
114
|
+
return cellEl.focus();
|
|
115
|
+
}); // move focus to cell
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return isCellEntered;
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
cellEl.addEventListener('keyup', onKeyUp);
|
|
124
|
+
return function () {
|
|
125
|
+
cellEl.removeEventListener('keyup', onKeyUp);
|
|
126
|
+
};
|
|
127
|
+
}, [cellEl]);
|
|
128
|
+
return (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
|
|
129
|
+
disabled: !isCellEntered,
|
|
130
|
+
onDeactivation: function onDeactivation() {
|
|
131
|
+
return setIsCellEntered(false);
|
|
132
|
+
},
|
|
133
|
+
clickOutsideDisables: true
|
|
134
|
+
}, children, (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", null, ' - ', (0, _react2.jsx)(_i18n.EuiI18n
|
|
135
|
+
// eslint-disable-next-line local/i18n
|
|
136
|
+
, {
|
|
137
|
+
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
138
|
+
default: "Press the Enter key to interact with this cell's contents."
|
|
139
|
+
}))));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Utility fns for managing child interactive tabIndex state
|
|
144
|
+
*/
|
|
145
|
+
exports.FocusTrappedChildren = FocusTrappedChildren;
|
|
146
|
+
var disableInteractives = function disableInteractives(cell) {
|
|
147
|
+
var interactives = (0, _tabbable.tabbable)(cell);
|
|
148
|
+
interactives.forEach(function (element) {
|
|
149
|
+
element.setAttribute('data-euigrid-tab-managed', 'true');
|
|
150
|
+
element.setAttribute('tabIndex', '-1');
|
|
151
|
+
});
|
|
152
|
+
return interactives;
|
|
153
|
+
};
|
|
154
|
+
var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
155
|
+
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
156
|
+
interactives.forEach(function (element, i) {
|
|
157
|
+
element.setAttribute('tabIndex', '0');
|
|
158
|
+
if (i === 0) {
|
|
159
|
+
element.focus();
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return interactives;
|
|
163
|
+
};
|
|
@@ -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");
|
|
@@ -17,7 +17,7 @@ var _col_widths = require("../utils/col_widths");
|
|
|
17
17
|
var _row_heights = require("../utils/row_heights");
|
|
18
18
|
var _header = require("./header");
|
|
19
19
|
var _footer = require("./footer");
|
|
20
|
-
var
|
|
20
|
+
var _cell = require("./cell");
|
|
21
21
|
var _react2 = require("@emotion/react");
|
|
22
22
|
var _excluded = ["colIndex", "visibleRowIndex"];
|
|
23
23
|
/*
|
|
@@ -44,8 +44,6 @@ var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_ref) {
|
|
|
44
44
|
renderCellPopover = _ref.renderCellPopover,
|
|
45
45
|
renderFooterCellValue = _ref.renderFooterCellValue,
|
|
46
46
|
interactiveCellId = _ref.interactiveCellId,
|
|
47
|
-
headerIsInteractive = _ref.headerIsInteractive,
|
|
48
|
-
handleHeaderMutation = _ref.handleHeaderMutation,
|
|
49
47
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
50
48
|
switchColumnPos = _ref.switchColumnPos,
|
|
51
49
|
onColumnResize = _ref.onColumnResize,
|
|
@@ -91,8 +89,6 @@ var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_ref) {
|
|
|
91
89
|
* Header & footer
|
|
92
90
|
*/
|
|
93
91
|
var _useDataGridHeader = (0, _header.useDataGridHeader)({
|
|
94
|
-
headerIsInteractive: headerIsInteractive,
|
|
95
|
-
handleHeaderMutation: handleHeaderMutation,
|
|
96
92
|
switchColumnPos: switchColumnPos,
|
|
97
93
|
setVisibleColumns: setVisibleColumns,
|
|
98
94
|
leadingControlColumns: leadingControlColumns,
|
|
@@ -152,7 +148,7 @@ var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_ref) {
|
|
|
152
148
|
visibleRowIndex: visibleRowIndex,
|
|
153
149
|
style: style
|
|
154
150
|
}, cellProps);
|
|
155
|
-
return (0, _react2.jsx)(
|
|
151
|
+
return (0, _react2.jsx)(_cell.Cell, (0, _extends2.default)({}, props, rest));
|
|
156
152
|
}, [].concat((0, _toConsumableArray2.default)(Object.values(cellProps)), [getRowHeight]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
157
153
|
);
|
|
158
154
|
|