@elastic/eui 92.0.0 → 92.1.1
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} +111 -244
- 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 +130 -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} +111 -244
- 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} +111 -244
- 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} +111 -244
- 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} +111 -244
- 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
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
/*
|
|
8
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
9
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
10
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
11
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
12
|
+
* Side Public License, v 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import React, { useEffect, useState, useMemo } from 'react';
|
|
16
|
+
import PropTypes from "prop-types";
|
|
17
|
+
import { tabbable } from 'tabbable';
|
|
18
|
+
import { keys } from '../../../../services';
|
|
19
|
+
import { EuiFocusTrap } from '../../../focus_trap';
|
|
20
|
+
import { EuiScreenReaderOnly } from '../../../accessibility';
|
|
21
|
+
import { EuiI18n } from '../../../i18n';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This internal utility component is used by all cells, both header and body/footer cells.
|
|
25
|
+
* It always handles:
|
|
26
|
+
* 1. Removing any interactive children from keyboard tab order on cell mount
|
|
27
|
+
* 2. Listening for focus on any interactive children and updating the cell focus context
|
|
28
|
+
*
|
|
29
|
+
* It should *only* render focus traps for:
|
|
30
|
+
* 1. Header cells that are `actions: false` but still have interactive children
|
|
31
|
+
* 2. Body cells that are `isExpandable: false` but still have interactive children
|
|
32
|
+
*/
|
|
33
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
34
|
+
export var HandleInteractiveChildren = function HandleInteractiveChildren(_ref) {
|
|
35
|
+
var cellEl = _ref.cellEl,
|
|
36
|
+
children = _ref.children,
|
|
37
|
+
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
38
|
+
renderFocusTrap = _ref.renderFocusTrap;
|
|
39
|
+
var _useState = useState(false),
|
|
40
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
+
hasInteractiveChildren = _useState2[0],
|
|
42
|
+
setHasInteractiveChildren = _useState2[1];
|
|
43
|
+
|
|
44
|
+
// On mount, disable all interactive children
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (cellEl) {
|
|
47
|
+
var interactiveChildren = disableInteractives(cellEl);
|
|
48
|
+
if (renderFocusTrap) {
|
|
49
|
+
setHasInteractiveChildren(interactiveChildren.length > 0);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, [cellEl, renderFocusTrap]);
|
|
53
|
+
|
|
54
|
+
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
55
|
+
useEffect(function () {
|
|
56
|
+
if (cellEl) {
|
|
57
|
+
var onFocus = function onFocus() {
|
|
58
|
+
return updateCellFocusContext();
|
|
59
|
+
};
|
|
60
|
+
cellEl.addEventListener('focus', onFocus, true); // useCapture listens for focus on children
|
|
61
|
+
return function () {
|
|
62
|
+
cellEl.removeEventListener('focus', onFocus, true);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}, [cellEl, updateCellFocusContext]);
|
|
66
|
+
var _children = useMemo(function () {
|
|
67
|
+
return ___EmotionJSX(React.Fragment, null, children);
|
|
68
|
+
}, [children]);
|
|
69
|
+
if (!cellEl) return _children; // Do nothing if cell has yet to mount or is unmounting
|
|
70
|
+
if (!renderFocusTrap) return _children; // Cells with default actions / expansion popovers do not need to trap
|
|
71
|
+
if (!hasInteractiveChildren) return _children; // No need to focus trap if no children are interactive
|
|
72
|
+
|
|
73
|
+
return ___EmotionJSX(FocusTrappedChildren, {
|
|
74
|
+
cellEl: cellEl
|
|
75
|
+
}, children);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Cells with interactive children but no cell popover expansion should render a
|
|
80
|
+
* focus trap that can be entered with the Enter key, which cycles keyboard tabs
|
|
81
|
+
* through the cell contents only, and exited with the Escape key
|
|
82
|
+
*/
|
|
83
|
+
HandleInteractiveChildren.propTypes = {
|
|
84
|
+
cellEl: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.oneOf([null])]),
|
|
85
|
+
updateCellFocusContext: PropTypes.func.isRequired,
|
|
86
|
+
renderFocusTrap: PropTypes.bool
|
|
87
|
+
};
|
|
88
|
+
export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
89
|
+
var cellEl = _ref2.cellEl,
|
|
90
|
+
children = _ref2.children;
|
|
91
|
+
var _useState3 = useState(false),
|
|
92
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
|
+
isCellEntered = _useState4[0],
|
|
94
|
+
setIsCellEntered = _useState4[1];
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
if (isCellEntered) {
|
|
97
|
+
enableAndFocusInteractives(cellEl);
|
|
98
|
+
} else {
|
|
99
|
+
disableInteractives(cellEl);
|
|
100
|
+
}
|
|
101
|
+
}, [isCellEntered, cellEl]);
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
var onKeyUp = function onKeyUp(event) {
|
|
104
|
+
switch (event.key) {
|
|
105
|
+
case keys.ENTER:
|
|
106
|
+
case keys.F2:
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
setIsCellEntered(true);
|
|
109
|
+
break;
|
|
110
|
+
case keys.ESCAPE:
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
setIsCellEntered(function (isCellEntered) {
|
|
113
|
+
if (isCellEntered === true) {
|
|
114
|
+
requestAnimationFrame(function () {
|
|
115
|
+
return cellEl.focus();
|
|
116
|
+
}); // move focus to cell
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return isCellEntered;
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
cellEl.addEventListener('keyup', onKeyUp);
|
|
125
|
+
return function () {
|
|
126
|
+
cellEl.removeEventListener('keyup', onKeyUp);
|
|
127
|
+
};
|
|
128
|
+
}, [cellEl]);
|
|
129
|
+
return ___EmotionJSX(EuiFocusTrap, {
|
|
130
|
+
disabled: !isCellEntered,
|
|
131
|
+
onDeactivation: function onDeactivation() {
|
|
132
|
+
return setIsCellEntered(false);
|
|
133
|
+
},
|
|
134
|
+
clickOutsideDisables: true
|
|
135
|
+
}, children, ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", null, ' - ', ___EmotionJSX(EuiI18n
|
|
136
|
+
// eslint-disable-next-line local/i18n
|
|
137
|
+
, {
|
|
138
|
+
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
139
|
+
default: "Press the Enter key to interact with this cell's contents."
|
|
140
|
+
}))));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Utility fns for managing child interactive tabIndex state
|
|
145
|
+
*/
|
|
146
|
+
FocusTrappedChildren.propTypes = {
|
|
147
|
+
cellEl: PropTypes.any.isRequired
|
|
148
|
+
};
|
|
149
|
+
var disableInteractives = function disableInteractives(cell) {
|
|
150
|
+
var interactives = tabbable(cell);
|
|
151
|
+
interactives.forEach(function (element) {
|
|
152
|
+
element.setAttribute('data-euigrid-tab-managed', 'true');
|
|
153
|
+
element.setAttribute('tabIndex', '-1');
|
|
154
|
+
});
|
|
155
|
+
return interactives;
|
|
156
|
+
};
|
|
157
|
+
var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
158
|
+
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
159
|
+
interactives.forEach(function (element, i) {
|
|
160
|
+
element.setAttribute('tabIndex', '0');
|
|
161
|
+
if (i === 0) {
|
|
162
|
+
element.focus();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return interactives;
|
|
166
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { EuiDataGridCell } from './data_grid_cell';
|
|
10
|
+
export { Cell } from './data_grid_cell_wrapper';
|
|
11
|
+
export { DataGridCellPopoverContext, useCellPopover } from './data_grid_cell_popover';
|
|
@@ -567,8 +567,6 @@ EuiDataGridBody.propTypes = {
|
|
|
567
567
|
renderCustomGridBody: PropTypes.func,
|
|
568
568
|
interactiveCellId: PropTypes.string.isRequired,
|
|
569
569
|
pagination: PropTypes.any,
|
|
570
|
-
headerIsInteractive: PropTypes.bool.isRequired,
|
|
571
|
-
handleHeaderMutation: PropTypes.any.isRequired,
|
|
572
570
|
setVisibleColumns: PropTypes.func.isRequired,
|
|
573
571
|
switchColumnPos: PropTypes.func.isRequired,
|
|
574
572
|
onColumnResize: PropTypes.func,
|
|
@@ -33,7 +33,7 @@ import { useDefaultColumnWidth, useColumnWidths } from '../utils/col_widths';
|
|
|
33
33
|
import { useRowHeightUtils, useDefaultRowHeight } from '../utils/row_heights';
|
|
34
34
|
import { useDataGridHeader } from './header';
|
|
35
35
|
import { useDataGridFooter } from './footer';
|
|
36
|
-
import { Cell } from './
|
|
36
|
+
import { Cell } from './cell';
|
|
37
37
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
38
38
|
export var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_ref) {
|
|
39
39
|
var renderCustomGridBody = _ref.renderCustomGridBody,
|
|
@@ -48,8 +48,6 @@ export var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_r
|
|
|
48
48
|
renderCellPopover = _ref.renderCellPopover,
|
|
49
49
|
renderFooterCellValue = _ref.renderFooterCellValue,
|
|
50
50
|
interactiveCellId = _ref.interactiveCellId,
|
|
51
|
-
headerIsInteractive = _ref.headerIsInteractive,
|
|
52
|
-
handleHeaderMutation = _ref.handleHeaderMutation,
|
|
53
51
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
54
52
|
switchColumnPos = _ref.switchColumnPos,
|
|
55
53
|
onColumnResize = _ref.onColumnResize,
|
|
@@ -95,8 +93,6 @@ export var EuiDataGridBodyCustomRender = function EuiDataGridBodyCustomRender(_r
|
|
|
95
93
|
* Header & footer
|
|
96
94
|
*/
|
|
97
95
|
var _useDataGridHeader = useDataGridHeader({
|
|
98
|
-
headerIsInteractive: headerIsInteractive,
|
|
99
|
-
handleHeaderMutation: handleHeaderMutation,
|
|
100
96
|
switchColumnPos: switchColumnPos,
|
|
101
97
|
setVisibleColumns: setVisibleColumns,
|
|
102
98
|
leadingControlColumns: leadingControlColumns,
|
|
@@ -714,8 +710,6 @@ EuiDataGridBodyCustomRender.propTypes = {
|
|
|
714
710
|
renderCustomGridBody: PropTypes.func,
|
|
715
711
|
interactiveCellId: PropTypes.string.isRequired,
|
|
716
712
|
pagination: PropTypes.any,
|
|
717
|
-
headerIsInteractive: PropTypes.bool.isRequired,
|
|
718
|
-
handleHeaderMutation: PropTypes.any.isRequired,
|
|
719
713
|
setVisibleColumns: PropTypes.func.isRequired,
|
|
720
714
|
switchColumnPos: PropTypes.func.isRequired,
|
|
721
715
|
onColumnResize: PropTypes.func,
|
|
@@ -23,7 +23,7 @@ import { VariableSizeGrid as Grid } from 'react-window';
|
|
|
23
23
|
import { useResizeObserver } from '../../observer/resize_observer';
|
|
24
24
|
import { useDataGridHeader } from './header';
|
|
25
25
|
import { useDataGridFooter } from './footer';
|
|
26
|
-
import { Cell } from './
|
|
26
|
+
import { Cell } from './cell';
|
|
27
27
|
import { useRowManager } from './data_grid_row_manager';
|
|
28
28
|
import { useFinalGridDimensions, useUnconstrainedHeight, useVirtualizeContainerWidth } from '../utils/grid_height_width';
|
|
29
29
|
import { useDefaultColumnWidth, useColumnWidths } from '../utils/col_widths';
|
|
@@ -92,8 +92,6 @@ export var EuiDataGridBodyVirtualized = function EuiDataGridBodyVirtualized(_ref
|
|
|
92
92
|
renderFooterCellValue = _ref3.renderFooterCellValue,
|
|
93
93
|
interactiveCellId = _ref3.interactiveCellId,
|
|
94
94
|
pagination = _ref3.pagination,
|
|
95
|
-
headerIsInteractive = _ref3.headerIsInteractive,
|
|
96
|
-
handleHeaderMutation = _ref3.handleHeaderMutation,
|
|
97
95
|
setVisibleColumns = _ref3.setVisibleColumns,
|
|
98
96
|
switchColumnPos = _ref3.switchColumnPos,
|
|
99
97
|
onColumnResize = _ref3.onColumnResize,
|
|
@@ -143,8 +141,6 @@ export var EuiDataGridBodyVirtualized = function EuiDataGridBodyVirtualized(_ref
|
|
|
143
141
|
* Header & footer
|
|
144
142
|
*/
|
|
145
143
|
var _useDataGridHeader = useDataGridHeader({
|
|
146
|
-
headerIsInteractive: headerIsInteractive,
|
|
147
|
-
handleHeaderMutation: handleHeaderMutation,
|
|
148
144
|
switchColumnPos: switchColumnPos,
|
|
149
145
|
setVisibleColumns: setVisibleColumns,
|
|
150
146
|
leadingControlColumns: leadingControlColumns,
|
|
@@ -843,8 +839,6 @@ EuiDataGridBodyVirtualized.propTypes = {
|
|
|
843
839
|
renderCustomGridBody: PropTypes.func,
|
|
844
840
|
interactiveCellId: PropTypes.string.isRequired,
|
|
845
841
|
pagination: PropTypes.any,
|
|
846
|
-
headerIsInteractive: PropTypes.bool.isRequired,
|
|
847
|
-
handleHeaderMutation: PropTypes.any.isRequired,
|
|
848
842
|
setVisibleColumns: PropTypes.func.isRequired,
|
|
849
843
|
switchColumnPos: PropTypes.func.isRequired,
|
|
850
844
|
onColumnResize: PropTypes.func,
|
|
@@ -12,8 +12,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
12
12
|
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import React, { forwardRef, memo, useContext } from 'react';
|
|
15
|
-
import { EuiDataGridCell } from '../
|
|
16
|
-
import { DataGridCellPopoverContext } from '../data_grid_cell_popover';
|
|
15
|
+
import { EuiDataGridCell, DataGridCellPopoverContext } from '../cell';
|
|
17
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
18
17
|
var renderEmpty = function renderEmpty() {
|
|
19
18
|
return null;
|
|
@@ -14,8 +14,7 @@ import { EuiDataGridHeaderCellWrapper } from './data_grid_header_cell_wrapper';
|
|
|
14
14
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
15
15
|
export var EuiDataGridControlHeaderCell = function EuiDataGridControlHeaderCell(_ref) {
|
|
16
16
|
var controlColumn = _ref.controlColumn,
|
|
17
|
-
index = _ref.index
|
|
18
|
-
headerIsInteractive = _ref.headerIsInteractive;
|
|
17
|
+
index = _ref.index;
|
|
19
18
|
var HeaderCellRender = controlColumn.headerCellRender,
|
|
20
19
|
headerCellProps = controlColumn.headerCellProps,
|
|
21
20
|
width = controlColumn.width,
|
|
@@ -24,8 +23,7 @@ export var EuiDataGridControlHeaderCell = function EuiDataGridControlHeaderCell(
|
|
|
24
23
|
className: classNames('euiDataGridHeaderCell--controlColumn', headerCellProps === null || headerCellProps === void 0 ? void 0 : headerCellProps.className),
|
|
25
24
|
id: id,
|
|
26
25
|
index: index,
|
|
27
|
-
width: width
|
|
28
|
-
headerIsInteractive: headerIsInteractive
|
|
26
|
+
width: width
|
|
29
27
|
}), ___EmotionJSX("div", {
|
|
30
28
|
className: "euiDataGridHeaderCell__content"
|
|
31
29
|
}, ___EmotionJSX(HeaderCellRender, null)));
|
|
@@ -61,6 +59,5 @@ EuiDataGridControlHeaderCell.propTypes = {
|
|
|
61
59
|
* Optional props to pass to the column footer cell
|
|
62
60
|
*/
|
|
63
61
|
footerCellProps: PropTypes.any
|
|
64
|
-
}).isRequired
|
|
65
|
-
headerIsInteractive: PropTypes.bool.isRequired
|
|
62
|
+
}).isRequired
|
|
66
63
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
9
|
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); }
|
|
7
10
|
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; }
|
|
8
11
|
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; } }
|
|
9
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
13
|
/*
|
|
14
14
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
15
15
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -44,6 +44,7 @@ var _ref2 = process.env.NODE_ENV === "production" ? {
|
|
|
44
44
|
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
45
45
|
};
|
|
46
46
|
export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
47
|
+
var _classnames;
|
|
47
48
|
var column = _ref.column,
|
|
48
49
|
index = _ref.index,
|
|
49
50
|
columns = _ref.columns,
|
|
@@ -53,15 +54,13 @@ export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
|
53
54
|
defaultColumnWidth = _ref.defaultColumnWidth,
|
|
54
55
|
setColumnWidth = _ref.setColumnWidth,
|
|
55
56
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
56
|
-
switchColumnPos = _ref.switchColumnPos
|
|
57
|
-
headerIsInteractive = _ref.headerIsInteractive;
|
|
57
|
+
switchColumnPos = _ref.switchColumnPos;
|
|
58
58
|
var id = column.id,
|
|
59
59
|
display = column.display,
|
|
60
60
|
displayAsText = column.displayAsText,
|
|
61
61
|
displayHeaderCellProps = column.displayHeaderCellProps;
|
|
62
62
|
var width = columnWidths[id] || defaultColumnWidth;
|
|
63
63
|
var columnType = schema[id] ? schema[id].columnType : null;
|
|
64
|
-
var classes = classnames(_defineProperty({}, "euiDataGridHeaderCell--".concat(columnType), columnType), displayHeaderCellProps === null || displayHeaderCellProps === void 0 ? void 0 : displayHeaderCellProps.className);
|
|
65
64
|
var _useContext = useContext(DataGridFocusContext),
|
|
66
65
|
setFocusedCell = _useContext.setFocusedCell,
|
|
67
66
|
focusFirstVisibleInteractiveCell = _useContext.focusFirstVisibleInteractiveCell;
|
|
@@ -86,6 +85,14 @@ export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
|
86
85
|
});
|
|
87
86
|
var showColumnActions = columnActions && columnActions.length > 0;
|
|
88
87
|
var actionsButtonRef = useRef(null);
|
|
88
|
+
var focusActionsButton = useCallback(function () {
|
|
89
|
+
var _actionsButtonRef$cur;
|
|
90
|
+
(_actionsButtonRef$cur = actionsButtonRef.current) === null || _actionsButtonRef$cur === void 0 ? void 0 : _actionsButtonRef$cur.focus();
|
|
91
|
+
}, []);
|
|
92
|
+
var _useState3 = useState(false),
|
|
93
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
94
|
+
isActionsButtonFocused = _useState4[0],
|
|
95
|
+
setIsActionsButtonFocused = _useState4[1];
|
|
89
96
|
var _useSortingUtils = useSortingUtils({
|
|
90
97
|
sorting: sorting,
|
|
91
98
|
id: id,
|
|
@@ -106,13 +113,16 @@ export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
|
106
113
|
title: displayAsText || id,
|
|
107
114
|
className: "euiDataGridHeaderCell__content"
|
|
108
115
|
}, display || displayAsText || id), sortingArrow);
|
|
116
|
+
var classes = classnames((_classnames = {}, _defineProperty(_classnames, "euiDataGridHeaderCell--".concat(columnType), columnType), _defineProperty(_classnames, 'euiDataGridHeaderCell--hasColumnActions', showColumnActions), _defineProperty(_classnames, 'euiDataGridHeaderCell--isActionsPopoverOpen', isPopoverOpen), _classnames), displayHeaderCellProps === null || displayHeaderCellProps === void 0 ? void 0 : displayHeaderCellProps.className);
|
|
109
117
|
return ___EmotionJSX(EuiDataGridHeaderCellWrapper, _extends({}, displayHeaderCellProps, {
|
|
110
118
|
className: classes,
|
|
111
119
|
id: id,
|
|
112
120
|
index: index,
|
|
113
121
|
width: width,
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
"aria-sort": ariaSort,
|
|
123
|
+
hasActionsPopover: showColumnActions,
|
|
124
|
+
isActionsButtonFocused: isActionsButtonFocused,
|
|
125
|
+
focusActionsButton: focusActionsButton
|
|
116
126
|
}), column.isResizable !== false && width != null ? ___EmotionJSX(EuiDataGridColumnResizer, {
|
|
117
127
|
columnId: id,
|
|
118
128
|
columnWidth: width,
|
|
@@ -120,11 +130,16 @@ export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
|
120
130
|
}) : null, !showColumnActions ? ___EmotionJSX(React.Fragment, null, cellContent, sortingScreenReaderText && ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", null, sortingScreenReaderText))) : ___EmotionJSX(React.Fragment, null, ___EmotionJSX("button", {
|
|
121
131
|
className: "euiDataGridHeaderCell__button",
|
|
122
132
|
onClick: function onClick() {
|
|
123
|
-
|
|
124
|
-
setIsPopoverOpen(function (isPopoverOpen) {
|
|
133
|
+
return setIsPopoverOpen(function (isPopoverOpen) {
|
|
125
134
|
return !isPopoverOpen;
|
|
126
135
|
});
|
|
127
136
|
},
|
|
137
|
+
onFocus: function onFocus() {
|
|
138
|
+
return setIsActionsButtonFocused(true);
|
|
139
|
+
},
|
|
140
|
+
onBlur: function onBlur() {
|
|
141
|
+
return setIsActionsButtonFocused(false);
|
|
142
|
+
},
|
|
128
143
|
"aria-describedby": "".concat(sortingAriaId, " ").concat(actionsAriaId),
|
|
129
144
|
ref: actionsButtonRef,
|
|
130
145
|
"data-test-subj": "dataGridHeaderCellActionButton-".concat(id)
|
|
@@ -138,8 +153,8 @@ export var EuiDataGridHeaderCell = function EuiDataGridHeaderCell(_ref) {
|
|
|
138
153
|
focusTrapProps: {
|
|
139
154
|
// We need to override the default EuiPopover `onClickOutside` since the anchor is separate from the actual button
|
|
140
155
|
onClickOutside: function onClickOutside(event) {
|
|
141
|
-
var _actionsButtonRef$
|
|
142
|
-
if (((_actionsButtonRef$
|
|
156
|
+
var _actionsButtonRef$cur2;
|
|
157
|
+
if (((_actionsButtonRef$cur2 = actionsButtonRef.current) === null || _actionsButtonRef$cur2 === void 0 ? void 0 : _actionsButtonRef$cur2.contains(event.target)) === false) {
|
|
143
158
|
setIsPopoverOpen(false);
|
|
144
159
|
}
|
|
145
160
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["id", "index", "
|
|
1
|
+
var _excluded = ["id", "index", "width", "className", "children", "hasActionsPopover", "isActionsButtonFocused", "focusActionsButton"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
4
|
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."); }
|
|
@@ -18,123 +18,69 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
18
18
|
|
|
19
19
|
import classnames from 'classnames';
|
|
20
20
|
import PropTypes from "prop-types";
|
|
21
|
-
import React, { useContext, useEffect,
|
|
22
|
-
import { tabbable } from 'tabbable';
|
|
23
|
-
import { keys } from '../../../../services';
|
|
21
|
+
import React, { useContext, useEffect, useState, useCallback } from 'react';
|
|
24
22
|
import { DataGridFocusContext } from '../../utils/focus';
|
|
25
|
-
import {
|
|
23
|
+
import { HandleInteractiveChildren } from '../cell/focus_utils';
|
|
24
|
+
|
|
26
25
|
/**
|
|
27
26
|
* This is a wrapper that handles repeated concerns between control &
|
|
28
27
|
* standard header cells. Most of its shared logic is around focus state/UX,
|
|
29
28
|
* but it also DRY's out certain class/data-test-subj/style attributes
|
|
30
29
|
*/
|
|
30
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
31
31
|
export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(_ref) {
|
|
32
32
|
var id = _ref.id,
|
|
33
33
|
index = _ref.index,
|
|
34
|
-
headerIsInteractive = _ref.headerIsInteractive,
|
|
35
34
|
width = _ref.width,
|
|
36
35
|
className = _ref.className,
|
|
37
36
|
children = _ref.children,
|
|
37
|
+
hasActionsPopover = _ref.hasActionsPopover,
|
|
38
|
+
isActionsButtonFocused = _ref.isActionsButtonFocused,
|
|
39
|
+
focusActionsButton = _ref.focusActionsButton,
|
|
38
40
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
39
41
|
var classes = classnames('euiDataGridHeaderCell', className);
|
|
42
|
+
|
|
43
|
+
// Must be a state and not a ref to trigger a HandleInteractiveChildren rerender
|
|
44
|
+
var _useState = useState(null),
|
|
45
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
46
|
+
headerEl = _useState2[0],
|
|
47
|
+
setHeaderEl = _useState2[1];
|
|
40
48
|
var _useContext = useContext(DataGridFocusContext),
|
|
41
49
|
setFocusedCell = _useContext.setFocusedCell,
|
|
42
50
|
onFocusUpdate = _useContext.onFocusUpdate;
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
var updateCellFocusContext = useCallback(function () {
|
|
52
|
+
setFocusedCell([index, -1]);
|
|
53
|
+
}, [index, setFocusedCell]);
|
|
54
|
+
var _useState3 = useState(false),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
isFocused = _useState4[0],
|
|
57
|
+
setIsFocused = _useState4[1];
|
|
47
58
|
useEffect(function () {
|
|
48
59
|
onFocusUpdate([index, -1], function (isFocused) {
|
|
49
60
|
setIsFocused(isFocused);
|
|
50
61
|
});
|
|
51
62
|
}, [index, onFocusUpdate]);
|
|
52
|
-
var headerRef = useRef(null);
|
|
53
|
-
var _useState3 = useState(false),
|
|
54
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
|
-
isCellEntered = _useState4[0],
|
|
56
|
-
setIsCellEntered = _useState4[1];
|
|
57
|
-
useEffect(function () {
|
|
58
|
-
var headerNode = headerRef.current;
|
|
59
|
-
if (isCellEntered) {
|
|
60
|
-
enableAndFocusInteractives(headerNode);
|
|
61
|
-
} else {
|
|
62
|
-
disableInteractives(headerNode);
|
|
63
|
-
}
|
|
64
|
-
}, [isCellEntered]);
|
|
65
63
|
useEffect(function () {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setIsCellEntered(true);
|
|
71
|
-
} else {
|
|
72
|
-
headerNode.focus();
|
|
64
|
+
if (isFocused && headerEl) {
|
|
65
|
+
// Only focus the cell if not already focused on something in the cell
|
|
66
|
+
if (!headerEl.contains(document.activeElement)) {
|
|
67
|
+
headerEl.focus();
|
|
73
68
|
}
|
|
74
|
-
} else {
|
|
75
|
-
setIsCellEntered(false);
|
|
76
69
|
}
|
|
70
|
+
}, [isFocused, headerEl]);
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
e.preventDefault();
|
|
86
|
-
return false;
|
|
87
|
-
} else {
|
|
88
|
-
// take the focus
|
|
89
|
-
if (isFocused === false) {
|
|
90
|
-
setFocusedCell([index, -1]);
|
|
91
|
-
} else {
|
|
92
|
-
// this cell already had the grid's focus, so re-enable and focus interactives
|
|
93
|
-
setIsCellEntered(true);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// focusout bubbles while blur does not, and this needs to react to the children losing focus
|
|
99
|
-
var onFocusOut = function onFocusOut() {
|
|
100
|
-
// wait for the next element to receive focus, then update interactives' state
|
|
101
|
-
requestAnimationFrame(function () {
|
|
102
|
-
if (!headerNode.contains(document.activeElement)) {
|
|
103
|
-
setIsCellEntered(false);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
var onKeyUp = function onKeyUp(event) {
|
|
108
|
-
switch (event.key) {
|
|
109
|
-
case keys.ENTER:
|
|
110
|
-
{
|
|
111
|
-
event.preventDefault();
|
|
112
|
-
setIsCellEntered(true);
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case keys.ESCAPE:
|
|
116
|
-
{
|
|
117
|
-
event.preventDefault();
|
|
118
|
-
// move focus to cell
|
|
119
|
-
setIsCellEntered(false);
|
|
120
|
-
headerNode.focus();
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
headerNode.addEventListener('focusin', onFocusIn);
|
|
126
|
-
headerNode.addEventListener('focusout', onFocusOut);
|
|
127
|
-
headerNode.addEventListener('keyup', onKeyUp);
|
|
128
|
-
return function () {
|
|
129
|
-
headerNode.removeEventListener('focusin', onFocusIn);
|
|
130
|
-
headerNode.removeEventListener('focusout', onFocusOut);
|
|
131
|
-
headerNode.removeEventListener('keyup', onKeyUp);
|
|
132
|
-
};
|
|
133
|
-
}, [headerIsInteractive, isFocused, index, setFocusedCell]);
|
|
72
|
+
// For cell headers with actions, auto-focus into the button instead of the cell wrapper div
|
|
73
|
+
// The button text is significantly more useful to screen readers (e.g. contains sort order & hints)
|
|
74
|
+
var onFocus = useCallback(function (e) {
|
|
75
|
+
if (hasActionsPopover && e.target === headerEl) {
|
|
76
|
+
focusActionsButton === null || focusActionsButton === void 0 ? void 0 : focusActionsButton();
|
|
77
|
+
}
|
|
78
|
+
}, [hasActionsPopover, focusActionsButton, headerEl]);
|
|
134
79
|
return ___EmotionJSX("div", _extends({
|
|
135
80
|
role: "columnheader",
|
|
136
|
-
ref:
|
|
137
|
-
tabIndex: isFocused && !
|
|
81
|
+
ref: setHeaderEl,
|
|
82
|
+
tabIndex: isFocused && !isActionsButtonFocused ? 0 : -1,
|
|
83
|
+
onFocus: onFocus,
|
|
138
84
|
className: classes,
|
|
139
85
|
"data-test-subj": "dataGridHeaderCell-".concat(id),
|
|
140
86
|
"data-gridcell-column-id": id,
|
|
@@ -144,35 +90,18 @@ export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(
|
|
|
144
90
|
style: width != null ? {
|
|
145
91
|
width: "".concat(width, "px")
|
|
146
92
|
} : {}
|
|
147
|
-
}, rest),
|
|
93
|
+
}, rest), ___EmotionJSX(HandleInteractiveChildren, {
|
|
94
|
+
cellEl: headerEl,
|
|
95
|
+
updateCellFocusContext: updateCellFocusContext,
|
|
96
|
+
renderFocusTrap: !hasActionsPopover
|
|
97
|
+
}, children));
|
|
148
98
|
};
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Utility fns for managing child interactive tabIndex state
|
|
152
|
-
*/
|
|
153
99
|
EuiDataGridHeaderCellWrapper.propTypes = {
|
|
154
100
|
id: PropTypes.string.isRequired,
|
|
155
101
|
index: PropTypes.number.isRequired,
|
|
156
|
-
headerIsInteractive: PropTypes.bool.isRequired,
|
|
157
102
|
width: PropTypes.oneOfType([PropTypes.number.isRequired, PropTypes.oneOf([null])]),
|
|
158
|
-
className: PropTypes.string
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (tabbables.length > 1) {
|
|
163
|
-
console.warn("EuiDataGridHeaderCell expects at most 1 tabbable element, ".concat(tabbables.length, " found instead"));
|
|
164
|
-
}
|
|
165
|
-
tabbables.forEach(function (element) {
|
|
166
|
-
element.setAttribute('data-euigrid-tab-managed', 'true');
|
|
167
|
-
element.setAttribute('tabIndex', '-1');
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
var enableAndFocusInteractives = function enableAndFocusInteractives(headerNode) {
|
|
171
|
-
var interactiveElements = headerNode.querySelectorAll('[data-euigrid-tab-managed]');
|
|
172
|
-
interactiveElements.forEach(function (element, i) {
|
|
173
|
-
element.setAttribute('tabIndex', '0');
|
|
174
|
-
if (i === 0) {
|
|
175
|
-
element.focus();
|
|
176
|
-
}
|
|
177
|
-
});
|
|
103
|
+
className: PropTypes.string,
|
|
104
|
+
hasActionsPopover: PropTypes.bool,
|
|
105
|
+
isActionsButtonFocused: PropTypes.bool,
|
|
106
|
+
focusActionsButton: PropTypes.func
|
|
178
107
|
};
|