@elastic/eui 97.0.0-backport.0 → 97.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/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/es/components/datagrid/body/cell/focus_utils.js +14 -4
- package/es/components/datagrid/body/data_grid_body.js +2 -1
- package/es/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/es/components/datagrid/body/header/column_actions.js +262 -27
- package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +10 -4
- package/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/es/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/es/components/datagrid/body/header/draggable_columns.js +301 -0
- package/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/es/components/datagrid/data_grid.js +2 -1
- package/es/components/datagrid/data_grid.stories.utils.js +9 -6
- package/es/components/datagrid/utils/col_widths.js +17 -13
- package/es/components/datagrid/utils/focus.js +2 -2
- package/es/components/datagrid/utils/scrolling.js +13 -10
- package/es/components/drag_and_drop/draggable.js +13 -5
- package/es/components/header/header.styles.js +6 -12
- package/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/es/components/tabs/tab.js +1 -1
- package/eui.d.ts +406 -311
- package/i18ntokens.json +123 -123
- package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/lib/components/datagrid/body/cell/focus_utils.js +14 -4
- package/lib/components/datagrid/body/data_grid_body.js +2 -1
- package/lib/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/lib/components/datagrid/body/header/column_actions.js +265 -29
- package/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{optimize/lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/lib/components/datagrid/body/header/draggable_columns.js +308 -0
- package/lib/components/datagrid/body/header/draggable_columns.styles.js +42 -0
- package/lib/components/datagrid/data_grid.js +2 -1
- package/lib/components/datagrid/data_grid.stories.utils.js +9 -6
- package/lib/components/datagrid/utils/col_widths.js +17 -13
- package/lib/components/datagrid/utils/focus.js +2 -2
- package/lib/components/datagrid/utils/scrolling.js +13 -10
- package/lib/components/drag_and_drop/draggable.js +13 -5
- package/lib/components/header/header.styles.js +6 -12
- package/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/lib/components/tabs/tab.js +1 -1
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/es/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/es/components/datagrid/body/header/column_actions.js +250 -26
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +8 -3
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/optimize/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +82 -302
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/optimize/es/components/datagrid/body/header/draggable_columns.js +223 -0
- package/optimize/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/optimize/es/components/datagrid/data_grid.js +2 -1
- package/optimize/es/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/es/components/datagrid/utils/col_widths.js +17 -13
- package/optimize/es/components/datagrid/utils/focus.js +2 -2
- package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/es/components/drag_and_drop/draggable.js +8 -3
- package/optimize/es/components/header/header.styles.js +6 -12
- package/optimize/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/es/components/tabs/tab.js +1 -1
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/lib/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/lib/components/datagrid/body/header/column_actions.js +253 -27
- package/optimize/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +9 -4
- package/{test-env/components/datagrid/body/header/data_grid_column_resizer.styles.js → optimize/lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/optimize/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +80 -300
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/optimize/lib/components/datagrid/body/header/draggable_columns.js +231 -0
- package/optimize/lib/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/optimize/lib/components/datagrid/data_grid.js +2 -1
- package/optimize/lib/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/lib/components/datagrid/utils/col_widths.js +17 -13
- package/optimize/lib/components/datagrid/utils/focus.js +2 -2
- package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
- package/optimize/lib/components/header/header.styles.js +6 -12
- package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/lib/components/tabs/tab.js +1 -1
- package/package.json +2 -3
- package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
- package/test-env/components/datagrid/body/data_grid_body.js +2 -1
- package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/test-env/components/datagrid/body/header/column_actions.js +261 -27
- package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
- package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
- package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/test-env/components/datagrid/data_grid.js +2 -1
- package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
- package/test-env/components/datagrid/utils/col_widths.js +17 -13
- package/test-env/components/datagrid/utils/focus.js +2 -2
- package/test-env/components/datagrid/utils/scrolling.js +13 -10
- package/test-env/components/drag_and_drop/draggable.js +13 -5
- package/test-env/components/header/header.styles.js +6 -12
- package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
- package/test-env/components/tabs/tab.js +1 -1
|
@@ -26,23 +26,18 @@ var euiHeaderVariables = exports.euiHeaderVariables = function euiHeaderVariable
|
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
var euiHeaderStyles = exports.euiHeaderStyles = function euiHeaderStyles(euiThemeContext) {
|
|
29
|
-
var euiTheme = euiThemeContext.euiTheme
|
|
30
|
-
colorMode = euiThemeContext.colorMode;
|
|
29
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
31
30
|
var _euiHeaderVariables = euiHeaderVariables(euiThemeContext),
|
|
32
31
|
height = _euiHeaderVariables.height,
|
|
33
32
|
padding = _euiHeaderVariables.padding;
|
|
34
|
-
|
|
35
|
-
// Curated border color to fade into the shadow without looking too much like a border
|
|
36
|
-
// It adds separation between the header and flyout
|
|
37
|
-
var borderColor = colorMode === 'DARK' ? (0, _services.shade)(euiTheme.colors.emptyShade, 0.35) : (0, _services.shade)(euiTheme.border.color, 0.03);
|
|
38
33
|
return {
|
|
39
|
-
euiHeader: /*#__PURE__*/(0, _react.css)("display:flex;justify-content:space-between;", (0, _global_styling.logicalCSS)('height', height), " ", (0, _global_styling.logicalCSS)('padding-horizontal', padding), " ", (0, _mixins.euiShadowSmall)(euiThemeContext), ";;label:euiHeader;"),
|
|
34
|
+
euiHeader: /*#__PURE__*/(0, _react.css)("display:flex;justify-content:space-between;", (0, _global_styling.logicalCSS)('height', height), " ", (0, _global_styling.logicalCSS)('padding-horizontal', padding), " ", (0, _global_styling.logicalCSS)('border-bottom', euiTheme.border.thin), " ", (0, _mixins.euiShadowSmall)(euiThemeContext), ";;label:euiHeader;"),
|
|
40
35
|
// Position
|
|
41
36
|
static: /*#__PURE__*/(0, _react.css)("z-index:", Number(euiTheme.levels.header) - 1, ";position:relative;;label:static;"),
|
|
42
37
|
fixed: /*#__PURE__*/(0, _react.css)("z-index:", euiTheme.levels.header, ";position:fixed;", (0, _global_styling.logicalCSS)('top', 0), " ", (0, _global_styling.logicalCSS)('horizontal', 0), ";;label:fixed;"),
|
|
43
38
|
// Theme
|
|
44
|
-
default: /*#__PURE__*/(0, _react.css)("background-color:", euiTheme.colors.emptyShade, "
|
|
45
|
-
dark: /*#__PURE__*/(0, _react.css)(euiHeaderDarkStyles(euiThemeContext
|
|
39
|
+
default: /*#__PURE__*/(0, _react.css)("background-color:", euiTheme.colors.emptyShade, ";;label:default;"),
|
|
40
|
+
dark: /*#__PURE__*/(0, _react.css)(euiHeaderDarkStyles(euiThemeContext), ";label:dark;")
|
|
46
41
|
};
|
|
47
42
|
};
|
|
48
43
|
|
|
@@ -56,12 +51,11 @@ var euiHeaderStyles = exports.euiHeaderStyles = function euiHeaderStyles(euiThem
|
|
|
56
51
|
* by Kibana in the near future, at which point we can remove this
|
|
57
52
|
*/
|
|
58
53
|
|
|
59
|
-
var euiHeaderDarkStyles = function euiHeaderDarkStyles(euiThemeContext
|
|
54
|
+
var euiHeaderDarkStyles = function euiHeaderDarkStyles(euiThemeContext) {
|
|
60
55
|
var euiTheme = euiThemeContext.euiTheme,
|
|
61
56
|
colorMode = euiThemeContext.colorMode;
|
|
62
57
|
var _euiFormVariables = (0, _form.euiFormVariables)(euiThemeContext),
|
|
63
58
|
controlPlaceholderText = _euiFormVariables.controlPlaceholderText;
|
|
64
59
|
var backgroundColor = colorMode === 'DARK' ? (0, _services.shade)(euiTheme.colors.lightestShade, 0.5) : (0, _services.shade)(euiTheme.colors.darkestShade, 0.28);
|
|
65
|
-
|
|
66
|
-
return "\n background-color: ".concat(backgroundColor, ";\n ").concat((0, _global_styling.logicalCSS)('border-bottom-color', borderColor), "\n\n .euiHeaderLogo__text,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n color: ").concat(euiTheme.colors.ghost, ";\n }\n\n .euiHeaderLink-isActive {\n color: ").concat((0, _services.makeHighContrastColor)(euiTheme.colors.primary)(backgroundColor), ";\n }\n\n .euiHeaderLogo,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n &:focus {\n background-color: ").concat((0, _services.shade)(euiTheme.colors.primary, 0.5), ";\n }\n }\n\n .euiHeaderSectionItemButton__notification--badge {\n box-shadow: 0 0 0 ").concat(euiTheme.border.width.thin, " ").concat(backgroundColor, ";\n }\n\n .euiHeaderSectionItemButton__notification--dot {\n stroke: ").concat(backgroundColor, ";\n }\n\n .euiSelectableTemplateSitewide .euiFormControlLayout {\n background-color: transparent;\n\n &--group {\n border-color: ").concat((0, _services.transparentize)(euiTheme.colors.ghost, 0.3), ";\n }\n\n &:not(:focus-within) {\n /* Increase contrast of filled text to be more than placeholder text */\n color: ").concat(euiTheme.colors.ghost, ";\n\n input {\n /* Increase contrast of placeholder text */\n &::placeholder {\n color: ").concat((0, _services.makeHighContrastColor)(controlPlaceholderText, 8)(backgroundColor), ";\n }\n\n /* Inherit color from form control layout */\n color: inherit;\n background-color: transparent;\n }\n\n .euiFormControlLayout__append,\n .euiFormControlLayout__prepend {\n background-color: transparent;\n }\n\n .euiFormLabel {\n color: inherit;\n }\n }\n }\n ");
|
|
60
|
+
return "\n background-color: ".concat(backgroundColor, ";\n\n .euiHeaderLogo__text,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n color: ").concat(euiTheme.colors.ghost, ";\n }\n\n .euiHeaderLink-isActive {\n color: ").concat((0, _services.makeHighContrastColor)(euiTheme.colors.primary)(backgroundColor), ";\n }\n\n .euiHeaderLogo,\n .euiHeaderLink,\n .euiHeaderSectionItemButton {\n &:focus {\n background-color: ").concat((0, _services.shade)(euiTheme.colors.primary, 0.5), ";\n }\n }\n\n .euiHeaderSectionItemButton__notification--badge {\n box-shadow: 0 0 0 ").concat(euiTheme.border.width.thin, " ").concat(backgroundColor, ";\n }\n\n .euiHeaderSectionItemButton__notification--dot {\n stroke: ").concat(backgroundColor, ";\n }\n\n .euiSelectableTemplateSitewide .euiFormControlLayout {\n background-color: transparent;\n\n &--group {\n border-color: ").concat((0, _services.transparentize)(euiTheme.colors.ghost, 0.3), ";\n }\n\n &:not(:focus-within) {\n /* Increase contrast of filled text to be more than placeholder text */\n color: ").concat(euiTheme.colors.ghost, ";\n\n input {\n /* Increase contrast of placeholder text */\n &::placeholder {\n color: ").concat((0, _services.makeHighContrastColor)(controlPlaceholderText, 8)(backgroundColor), ";\n }\n\n /* Inherit color from form control layout */\n color: inherit;\n background-color: transparent;\n }\n\n .euiFormControlLayout__append,\n .euiFormControlLayout__prepend {\n background-color: transparent;\n }\n\n .euiFormLabel {\n color: inherit;\n }\n }\n }\n ");
|
|
67
61
|
};
|
|
@@ -7,7 +7,6 @@ exports.euiPageInnerStyles = void 0;
|
|
|
7
7
|
var _react = require("@emotion/react");
|
|
8
8
|
var _mixins = require("../../../themes/amsterdam/global_styling/mixins");
|
|
9
9
|
var _global_styling = require("../../../global_styling");
|
|
10
|
-
var _services = require("../../../services");
|
|
11
10
|
/*
|
|
12
11
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
13
12
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -17,13 +16,13 @@ var _services = require("../../../services");
|
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
var euiPageInnerStyles = exports.euiPageInnerStyles = function euiPageInnerStyles(euiThemeContext) {
|
|
20
|
-
var
|
|
19
|
+
var euiTheme = euiThemeContext.euiTheme;
|
|
21
20
|
return {
|
|
22
21
|
euiPageInner: /*#__PURE__*/(0, _react.css)("display:flex;flex-direction:column;align-items:stretch;flex:1 1 100%;", (0, _global_styling.logicalCSS)('max-width', '100%'), " ", (0, _global_styling.logicalCSS)('min-width', '0'), ";;label:euiPageInner;"),
|
|
23
22
|
panelled: /*#__PURE__*/(0, _react.css)("background:", (0, _global_styling.euiBackgroundColor)(euiThemeContext, 'plain'), ";", (0, _mixins.euiShadow)(euiThemeContext, 'm'), ";;label:panelled;"),
|
|
24
23
|
border: {
|
|
25
|
-
top: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('border-top',
|
|
26
|
-
left: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('border-left',
|
|
24
|
+
top: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('border-top', euiTheme.border.thin), ";;label:top;"),
|
|
25
|
+
left: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('border-left', euiTheme.border.thin), ";;label:left;")
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
28
|
};
|
|
@@ -74,7 +74,7 @@ var EuiTab = exports.EuiTab = function EuiTab(_ref) {
|
|
|
74
74
|
target: target,
|
|
75
75
|
rel: secureRel
|
|
76
76
|
}, rest), prependNode, (0, _react2.jsx)("span", {
|
|
77
|
-
className: "euiTab__content",
|
|
77
|
+
className: "euiTab__content eui-textTruncate",
|
|
78
78
|
css: cssTabContentStyles
|
|
79
79
|
}, children), appendNode);
|
|
80
80
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/eui",
|
|
3
3
|
"description": "Elastic UI Component Library",
|
|
4
|
-
"version": "97.
|
|
4
|
+
"version": "97.1.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "lib",
|
|
7
7
|
"module": "es",
|
|
@@ -276,6 +276,5 @@
|
|
|
276
276
|
],
|
|
277
277
|
"installConfig": {
|
|
278
278
|
"hoistingLimits": "workspaces"
|
|
279
|
-
}
|
|
280
|
-
"stableVersion": "97.0.0"
|
|
279
|
+
}
|
|
281
280
|
}
|
|
@@ -47,6 +47,7 @@ var euiDataGridCellOutlineSelectors = exports.euiDataGridCellOutlineSelectors =
|
|
|
47
47
|
|
|
48
48
|
// Cell header specific selectors
|
|
49
49
|
var headerActionsOpen = '.euiDataGridHeaderCell--isActionsPopoverOpen';
|
|
50
|
+
var isMoving = '[data-column-moving]'; // prevents the header column actions hover animation from replaying on column move
|
|
50
51
|
|
|
51
52
|
// Utils
|
|
52
53
|
var selectors = function selectors() {
|
|
@@ -80,10 +81,11 @@ var euiDataGridCellOutlineSelectors = exports.euiDataGridCellOutlineSelectors =
|
|
|
80
81
|
hoverAnimation: hoverNot(selectors(focus, isOpen, isClosing))
|
|
81
82
|
},
|
|
82
83
|
header: {
|
|
83
|
-
focus: is(selectors(focus, focusWithin, headerActionsOpen)),
|
|
84
|
+
focus: is(selectors(focus, focusWithin, headerActionsOpen, isMoving)),
|
|
84
85
|
// :focus-within here is primarily intended for when the column actions button has been clicked twice
|
|
85
86
|
focusTrapped: _(isEntered),
|
|
86
|
-
|
|
87
|
+
showActions: is(selectors(hover, focusWithin, headerActionsOpen, isMoving)),
|
|
88
|
+
hideActions: not(selectors(hover, focusWithin, headerActionsOpen, isMoving))
|
|
87
89
|
}
|
|
88
90
|
};
|
|
89
91
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.HandleInteractiveChildren = exports.FocusTrappedChildren = void 0;
|
|
9
|
+
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
|
|
9
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -108,16 +109,24 @@ var FocusTrappedChildren = exports.FocusTrappedChildren = function FocusTrappedC
|
|
|
108
109
|
|
|
109
110
|
// direct DOM manipulation as workaround to attach required hints
|
|
110
111
|
(0, _react.useEffect)(function () {
|
|
112
|
+
var _currentAriaDescribed;
|
|
111
113
|
var currentAriaDescribedbyId = cellEl.getAttribute('aria-describedby');
|
|
112
|
-
|
|
114
|
+
// A11y: splitting ids to be able to append the first hint (sorting)
|
|
115
|
+
// while other hints should follow the keyboard navigation hints
|
|
116
|
+
var _ref3 = (_currentAriaDescribed = currentAriaDescribedbyId === null || currentAriaDescribedbyId === void 0 ? void 0 : currentAriaDescribedbyId.split(' ')) !== null && _currentAriaDescribed !== void 0 ? _currentAriaDescribed : [],
|
|
117
|
+
_ref4 = (0, _toArray2.default)(_ref3),
|
|
118
|
+
sortingId = _ref4[0],
|
|
119
|
+
rest = _ref4.slice(1);
|
|
120
|
+
var remainingIds = rest.join(' ');
|
|
121
|
+
cellEl.setAttribute('aria-describedby', (0, _classnames.default)(sortingId, ariaDescribedById, !isCellEntered && remainingIds));
|
|
113
122
|
return function () {
|
|
114
123
|
if (currentAriaDescribedbyId) {
|
|
115
|
-
cellEl.setAttribute('aria-
|
|
124
|
+
cellEl.setAttribute('aria-describedby', currentAriaDescribedbyId);
|
|
116
125
|
} else {
|
|
117
126
|
cellEl.removeAttribute('aria-describedby');
|
|
118
127
|
}
|
|
119
128
|
};
|
|
120
|
-
}, [cellEl, ariaDescribedById]);
|
|
129
|
+
}, [cellEl, ariaDescribedById, isCellEntered]);
|
|
121
130
|
(0, _react.useEffect)(function () {
|
|
122
131
|
if (isCellEntered) {
|
|
123
132
|
enableAndFocusInteractives(cellEl);
|
|
@@ -145,7 +154,7 @@ var FocusTrappedChildren = exports.FocusTrappedChildren = function FocusTrappedC
|
|
|
145
154
|
} else if (
|
|
146
155
|
// when opened content is closed, we don't want Escape to return to the cell
|
|
147
156
|
// immediately but instead return focus to a trigger as expected
|
|
148
|
-
isCellEntered === false && (0, _utils.isDOMNode)(event.target) && (0, _utils.isDOMNode)(event.currentTarget) && event.currentTarget.contains(event.target)) {
|
|
157
|
+
isCellEntered === false && (0, _utils.isDOMNode)(event.target) && (0, _utils.isDOMNode)(event.currentTarget) && event.currentTarget !== event.target && event.currentTarget.contains(event.target)) {
|
|
149
158
|
return true;
|
|
150
159
|
}
|
|
151
160
|
return isCellEntered;
|
|
@@ -658,5 +658,6 @@ EuiDataGridBody.propTypes = {
|
|
|
658
658
|
gridRef: _propTypes.default.any.isRequired,
|
|
659
659
|
gridItemsRendered: _propTypes.default.any.isRequired,
|
|
660
660
|
wrapperRef: _propTypes.default.any.isRequired,
|
|
661
|
-
className: _propTypes.default.string
|
|
661
|
+
className: _propTypes.default.string,
|
|
662
|
+
canDragAndDropColumns: _propTypes.default.bool
|
|
662
663
|
};
|
|
@@ -46,6 +46,7 @@ var EuiDataGridBodyCustomRender = exports.EuiDataGridBodyCustomRender = /*#__PUR
|
|
|
46
46
|
columns = _ref.columns,
|
|
47
47
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
48
48
|
switchColumnPos = _ref.switchColumnPos,
|
|
49
|
+
canDragAndDropColumns = _ref.canDragAndDropColumns,
|
|
49
50
|
onColumnResize = _ref.onColumnResize,
|
|
50
51
|
schema = _ref.schema,
|
|
51
52
|
schemaDetectors = _ref.schemaDetectors,
|
|
@@ -99,12 +100,13 @@ var EuiDataGridBodyCustomRender = exports.EuiDataGridBodyCustomRender = /*#__PUR
|
|
|
99
100
|
setVisibleColumns: setVisibleColumns,
|
|
100
101
|
visibleColCount: visibleColCount,
|
|
101
102
|
switchColumnPos: switchColumnPos,
|
|
103
|
+
canDragAndDropColumns: canDragAndDropColumns,
|
|
102
104
|
sorting: sorting,
|
|
103
105
|
schema: schema,
|
|
104
106
|
schemaDetectors: schemaDetectors,
|
|
105
107
|
gridStyles: gridStyles
|
|
106
108
|
};
|
|
107
|
-
}, [leadingControlColumns, trailingControlColumns, columns, columnWidths, defaultColumnWidth, setColumnWidth, visibleColCount, setVisibleColumns, switchColumnPos, sorting, schema, schemaDetectors, gridStyles]);
|
|
109
|
+
}, [leadingControlColumns, trailingControlColumns, columns, columnWidths, defaultColumnWidth, setColumnWidth, visibleColCount, setVisibleColumns, switchColumnPos, canDragAndDropColumns, sorting, schema, schemaDetectors, gridStyles]);
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
112
|
* Header & footer
|
|
@@ -813,6 +815,7 @@ EuiDataGridBodyCustomRender.propTypes = {
|
|
|
813
815
|
gridRef: _propTypes.default.any.isRequired,
|
|
814
816
|
gridItemsRendered: _propTypes.default.any.isRequired,
|
|
815
817
|
wrapperRef: _propTypes.default.any.isRequired,
|
|
816
|
-
className: _propTypes.default.string
|
|
818
|
+
className: _propTypes.default.string,
|
|
819
|
+
canDragAndDropColumns: _propTypes.default.bool
|
|
817
820
|
};
|
|
818
821
|
EuiDataGridBodyCustomRender.displayName = 'EuiDataGridBodyCustomRender';
|
|
@@ -113,7 +113,8 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
113
113
|
gridRef = _ref3.gridRef,
|
|
114
114
|
gridItemsRendered = _ref3.gridItemsRendered,
|
|
115
115
|
wrapperRef = _ref3.wrapperRef,
|
|
116
|
-
className = _ref3.className
|
|
116
|
+
className = _ref3.className,
|
|
117
|
+
canDragAndDropColumns = _ref3.canDragAndDropColumns;
|
|
117
118
|
/**
|
|
118
119
|
* Grid refs & observers
|
|
119
120
|
*/
|
|
@@ -164,7 +165,8 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
164
165
|
sorting: sorting,
|
|
165
166
|
schema: schema,
|
|
166
167
|
schemaDetectors: schemaDetectors,
|
|
167
|
-
gridStyles: gridStyles
|
|
168
|
+
gridStyles: gridStyles,
|
|
169
|
+
canDragAndDropColumns: canDragAndDropColumns
|
|
168
170
|
}),
|
|
169
171
|
headerRow = _useDataGridHeader.headerRow,
|
|
170
172
|
headerRowHeight = _useDataGridHeader.headerRowHeight;
|
|
@@ -196,7 +198,8 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
196
198
|
headerRowHeight: headerRowHeight,
|
|
197
199
|
footerRowHeight: footerRowHeight,
|
|
198
200
|
visibleRowCount: visibleRowCount,
|
|
199
|
-
hasStickyFooter: !!(renderFooterCellValue && gridStyles.stickyFooter)
|
|
201
|
+
hasStickyFooter: !!(renderFooterCellValue && gridStyles.stickyFooter),
|
|
202
|
+
canDragAndDropColumns: canDragAndDropColumns
|
|
200
203
|
});
|
|
201
204
|
|
|
202
205
|
/**
|
|
@@ -944,6 +947,7 @@ EuiDataGridBodyVirtualized.propTypes = {
|
|
|
944
947
|
gridRef: _propTypes.default.any.isRequired,
|
|
945
948
|
gridItemsRendered: _propTypes.default.any.isRequired,
|
|
946
949
|
wrapperRef: _propTypes.default.any.isRequired,
|
|
947
|
-
className: _propTypes.default.string
|
|
950
|
+
className: _propTypes.default.string,
|
|
951
|
+
canDragAndDropColumns: _propTypes.default.bool
|
|
948
952
|
};
|
|
949
953
|
EuiDataGridBodyVirtualized.displayName = 'EuiDataGridBodyVirtualized';
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
|
-
exports.isColumnActionEnabled = exports.getSortColumnActions = exports.getHideColumnAction = exports.getColumnActions = exports.getColumnActionConfig = void 0;
|
|
8
|
+
exports.usePopoverArrowNavigation = exports.useHasColumnActions = exports.isColumnActionEnabled = exports.getSortColumnActions = exports.getHideColumnAction = exports.getColumnActions = exports.getColumnActionConfig = exports.ColumnActions = void 0;
|
|
8
9
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
var
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
+
var _tabbable = require("tabbable");
|
|
17
|
+
var _services = require("../../../../services");
|
|
12
18
|
var _i18n = require("../../../i18n");
|
|
19
|
+
var _popover = require("../../../popover");
|
|
20
|
+
var _list_group = require("../../../list_group");
|
|
21
|
+
var _button = require("../../../button");
|
|
22
|
+
var _focus = require("../../utils/focus");
|
|
13
23
|
var _data_grid_schema = require("../../utils/data_grid_schema");
|
|
14
24
|
var _column_sorting_draggable = require("../../controls/column_sorting_draggable");
|
|
25
|
+
var _data_grid_header_cell = require("./data_grid_header_cell.styles");
|
|
15
26
|
var _react2 = require("@emotion/react");
|
|
27
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
29
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /*
|
|
18
31
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -20,20 +33,229 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
20
33
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
21
34
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
22
35
|
* Side Public License, v 1.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
*/ // Keep the i18n scope the same as EuiDataGridHeaderCell
|
|
37
|
+
/* eslint-disable local/i18n */
|
|
38
|
+
var useHasColumnActions = exports.useHasColumnActions = function useHasColumnActions(columnActions) {
|
|
39
|
+
return (0, _react.useMemo)(function () {
|
|
40
|
+
// By default, all column actions are enabled
|
|
41
|
+
if (columnActions === undefined) return true;
|
|
42
|
+
if (columnActions === false) return false;
|
|
43
|
+
if (columnActions.additional && columnActions.additional.length) return true;
|
|
44
|
+
// Check if all (currently 5) default column actions have been manually disabled
|
|
45
|
+
var disabledActions = Object.values(columnActions).filter(function (action) {
|
|
46
|
+
return action === false;
|
|
47
|
+
});
|
|
48
|
+
return disabledActions.length < 5;
|
|
49
|
+
}, [columnActions]);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Props to pass back to EuiDataGridHeaderCell and set on EuiDataGridHeaderCellWrapper
|
|
53
|
+
|
|
54
|
+
var ColumnActions = exports.ColumnActions = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
55
|
+
var index = _ref.index,
|
|
56
|
+
id = _ref.id,
|
|
57
|
+
title = _ref.title,
|
|
58
|
+
column = _ref.column,
|
|
27
59
|
columns = _ref.columns,
|
|
28
60
|
schema = _ref.schema,
|
|
29
61
|
schemaDetectors = _ref.schemaDetectors,
|
|
30
62
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
31
|
-
focusFirstVisibleInteractiveCell = _ref.focusFirstVisibleInteractiveCell,
|
|
32
|
-
setIsPopoverOpen = _ref.setIsPopoverOpen,
|
|
33
|
-
sorting = _ref.sorting,
|
|
34
63
|
switchColumnPos = _ref.switchColumnPos,
|
|
35
|
-
|
|
36
|
-
|
|
64
|
+
sorting = _ref.sorting,
|
|
65
|
+
hasFocusTrap = _ref.hasFocusTrap,
|
|
66
|
+
setPropsFromColumnActions = _ref.setPropsFromColumnActions,
|
|
67
|
+
actionsButtonRef = _ref.actionsButtonRef;
|
|
68
|
+
/**
|
|
69
|
+
* Popover logic and accessibility
|
|
70
|
+
*/
|
|
71
|
+
var _useState = (0, _react.useState)(false),
|
|
72
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
73
|
+
isPopoverOpen = _useState2[0],
|
|
74
|
+
setIsPopoverOpen = _useState2[1];
|
|
75
|
+
var togglePopover = (0, _react.useCallback)(function () {
|
|
76
|
+
setIsPopoverOpen(function (isOpen) {
|
|
77
|
+
return !isOpen;
|
|
78
|
+
});
|
|
79
|
+
}, []);
|
|
80
|
+
var closePopover = (0, _react.useCallback)(function () {
|
|
81
|
+
setIsPopoverOpen(false);
|
|
82
|
+
}, []);
|
|
83
|
+
var _useState3 = (0, _react.useState)(false),
|
|
84
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
85
|
+
isActionsButtonFocused = _useState4[0],
|
|
86
|
+
setIsActionsButtonFocused = _useState4[1];
|
|
87
|
+
var onFocus = (0, _react.useCallback)(function () {
|
|
88
|
+
return setIsActionsButtonFocused(true);
|
|
89
|
+
}, []);
|
|
90
|
+
var onBlur = (0, _react.useCallback)(function () {
|
|
91
|
+
return setIsActionsButtonFocused(false);
|
|
92
|
+
}, []);
|
|
93
|
+
var actionsButtonAriaLabel = (0, _i18n.useEuiI18n)('euiDataGridHeaderCell.actionsButtonAriaLabel', '{title}. Click to view column header actions.', {
|
|
94
|
+
title: title
|
|
95
|
+
});
|
|
96
|
+
var actionsEnterKeyInstructions = (0, _i18n.useEuiI18n)('euiDataGridHeaderCell.actionsEnterKeyInstructions', "Press the Enter key to view this column's actions");
|
|
97
|
+
var openActionsPopoverOnEnter = (0, _react.useCallback)(function (e) {
|
|
98
|
+
if (e.key === _services.keys.ENTER) {
|
|
99
|
+
setIsPopoverOpen(true);
|
|
100
|
+
}
|
|
101
|
+
}, []);
|
|
102
|
+
var popoverArrowNavigationProps = usePopoverArrowNavigation();
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Props to set on parent EuiDataGridHeaderCell
|
|
106
|
+
*/
|
|
107
|
+
var _useState5 = (0, _react.useState)(false),
|
|
108
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
109
|
+
isColumnMoving = _useState6[0],
|
|
110
|
+
setIsColumnMoving = _useState6[1];
|
|
111
|
+
(0, _react.useEffect)(function () {
|
|
112
|
+
setPropsFromColumnActions({
|
|
113
|
+
className: isPopoverOpen ? 'euiDataGridHeaderCell--isActionsPopoverOpen' : '',
|
|
114
|
+
onKeyDown: openActionsPopoverOnEnter,
|
|
115
|
+
'data-column-moving': isColumnMoving || undefined
|
|
116
|
+
});
|
|
117
|
+
}, [setPropsFromColumnActions, isPopoverOpen, openActionsPopoverOnEnter, isColumnMoving]);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get column actions as an array of EuiListGroup items
|
|
121
|
+
*/
|
|
122
|
+
var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
123
|
+
setFocusedCell = _useContext.setFocusedCell,
|
|
124
|
+
focusFirstVisibleInteractiveCell = _useContext.focusFirstVisibleInteractiveCell;
|
|
125
|
+
var columnActions = (0, _react.useMemo)(function () {
|
|
126
|
+
return getColumnActions({
|
|
127
|
+
column: column,
|
|
128
|
+
columns: columns,
|
|
129
|
+
schema: schema,
|
|
130
|
+
schemaDetectors: schemaDetectors,
|
|
131
|
+
setVisibleColumns: setVisibleColumns,
|
|
132
|
+
focusFirstVisibleInteractiveCell: focusFirstVisibleInteractiveCell,
|
|
133
|
+
sorting: sorting,
|
|
134
|
+
switchColumnPos: switchColumnPos,
|
|
135
|
+
setIsPopoverOpen: setIsPopoverOpen,
|
|
136
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
137
|
+
setFocusedCell: setFocusedCell,
|
|
138
|
+
columnFocusIndex: index
|
|
139
|
+
});
|
|
140
|
+
}, [column, columns, schema, schemaDetectors, setVisibleColumns, focusFirstVisibleInteractiveCell, sorting, switchColumnPos, setFocusedCell, index]);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Rendering
|
|
144
|
+
*/
|
|
145
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_data_grid_header_cell.euiDataGridHeaderCellStyles);
|
|
146
|
+
return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
|
|
147
|
+
display: "block",
|
|
148
|
+
panelPaddingSize: "none",
|
|
149
|
+
offset: 7,
|
|
150
|
+
anchorPosition: "downRight",
|
|
151
|
+
css: styles.euiDataGridHeaderCell__popover,
|
|
152
|
+
button: (0, _react2.jsx)(_button.EuiButtonIcon, {
|
|
153
|
+
iconType: "boxesVertical",
|
|
154
|
+
iconSize: "s",
|
|
155
|
+
color: "text",
|
|
156
|
+
css: styles.euiDataGridHeaderCell__actions,
|
|
157
|
+
className: "euiDataGridHeaderCell__button",
|
|
158
|
+
onClick: togglePopover,
|
|
159
|
+
buttonRef: actionsButtonRef,
|
|
160
|
+
onFocus: onFocus,
|
|
161
|
+
onBlur: onBlur,
|
|
162
|
+
tabIndex: 0 // Override EuiButtonIcon's conditional tabindex based on aria-hidden
|
|
163
|
+
,
|
|
164
|
+
"aria-hidden": hasFocusTrap && !isActionsButtonFocused ? 'true' // prevent the actions button from being read on cell focus
|
|
165
|
+
: undefined,
|
|
166
|
+
"aria-label": hasFocusTrap ? actionsButtonAriaLabel : actionsEnterKeyInstructions,
|
|
167
|
+
"data-test-subj": "dataGridHeaderCellActionButton-".concat(id)
|
|
168
|
+
}),
|
|
169
|
+
isOpen: isPopoverOpen,
|
|
170
|
+
closePopover: closePopover
|
|
171
|
+
}, popoverArrowNavigationProps), (0, _react2.jsx)(_list_group.EuiListGroup, {
|
|
172
|
+
listItems: columnActions,
|
|
173
|
+
gutterSize: "none",
|
|
174
|
+
"data-test-subj": "dataGridHeaderCellActionGroup-".concat(id)
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
ColumnActions.propTypes = {
|
|
178
|
+
id: _propTypes.default.string.isRequired,
|
|
179
|
+
title: _propTypes.default.string.isRequired,
|
|
180
|
+
hasFocusTrap: _propTypes.default.bool.isRequired,
|
|
181
|
+
setPropsFromColumnActions: _propTypes.default.func.isRequired,
|
|
182
|
+
actionsButtonRef: _propTypes.default.any.isRequired
|
|
183
|
+
};
|
|
184
|
+
ColumnActions.displayName = 'EuiDataGridHeaderCellColumnActions';
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Add keyboard arrow navigation to the cell actions popover
|
|
188
|
+
* to match the UX of the rest of EuiDataGrid
|
|
189
|
+
*/
|
|
190
|
+
var usePopoverArrowNavigation = exports.usePopoverArrowNavigation = function usePopoverArrowNavigation() {
|
|
191
|
+
var popoverPanelRef = (0, _react.useRef)(null);
|
|
192
|
+
var actionsRef = (0, _react.useRef)(undefined);
|
|
193
|
+
var panelRef = (0, _react.useCallback)(function (ref) {
|
|
194
|
+
popoverPanelRef.current = ref;
|
|
195
|
+
actionsRef.current = ref ? (0, _tabbable.tabbable)(ref) : undefined;
|
|
196
|
+
}, []);
|
|
197
|
+
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
198
|
+
var _actionsRef$current;
|
|
199
|
+
if (e.key !== _services.keys.ARROW_DOWN && e.key !== _services.keys.ARROW_UP) return;
|
|
200
|
+
if (!((_actionsRef$current = actionsRef.current) !== null && _actionsRef$current !== void 0 && _actionsRef$current.length)) return;
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
var initialState = document.activeElement === popoverPanelRef.current;
|
|
203
|
+
var currentIndex = !initialState ? actionsRef.current.findIndex(function (el) {
|
|
204
|
+
return document.activeElement === el;
|
|
205
|
+
}) : -1;
|
|
206
|
+
var lastIndex = actionsRef.current.length - 1;
|
|
207
|
+
var indexToFocus;
|
|
208
|
+
if (initialState) {
|
|
209
|
+
if (e.key === _services.keys.ARROW_DOWN) {
|
|
210
|
+
indexToFocus = 0;
|
|
211
|
+
} else if (e.key === _services.keys.ARROW_UP) {
|
|
212
|
+
indexToFocus = lastIndex;
|
|
213
|
+
}
|
|
214
|
+
} else {
|
|
215
|
+
if (e.key === _services.keys.ARROW_DOWN) {
|
|
216
|
+
indexToFocus = currentIndex + 1;
|
|
217
|
+
if (indexToFocus > lastIndex) {
|
|
218
|
+
indexToFocus = 0;
|
|
219
|
+
}
|
|
220
|
+
} else if (e.key === _services.keys.ARROW_UP) {
|
|
221
|
+
indexToFocus = currentIndex - 1;
|
|
222
|
+
if (indexToFocus < 0) {
|
|
223
|
+
indexToFocus = lastIndex;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
actionsRef.current[indexToFocus].focus();
|
|
228
|
+
}, []);
|
|
229
|
+
return {
|
|
230
|
+
panelRef: panelRef,
|
|
231
|
+
panelProps: {
|
|
232
|
+
onKeyDown: onKeyDown
|
|
233
|
+
},
|
|
234
|
+
popoverScreenReaderText: (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
235
|
+
token: "euiDataGridHeaderCell.actionsPopoverScreenReaderText",
|
|
236
|
+
default: "To navigate through the list of column actions, press the Tab or Up and Down arrow keys."
|
|
237
|
+
})
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Logic for returning an array of actions/items to pass to EuiListGroup
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
var getColumnActions = exports.getColumnActions = function getColumnActions(_ref2) {
|
|
246
|
+
var _column$actions;
|
|
247
|
+
var column = _ref2.column,
|
|
248
|
+
columns = _ref2.columns,
|
|
249
|
+
schema = _ref2.schema,
|
|
250
|
+
schemaDetectors = _ref2.schemaDetectors,
|
|
251
|
+
setVisibleColumns = _ref2.setVisibleColumns,
|
|
252
|
+
focusFirstVisibleInteractiveCell = _ref2.focusFirstVisibleInteractiveCell,
|
|
253
|
+
setIsPopoverOpen = _ref2.setIsPopoverOpen,
|
|
254
|
+
sorting = _ref2.sorting,
|
|
255
|
+
switchColumnPos = _ref2.switchColumnPos,
|
|
256
|
+
setIsColumnMoving = _ref2.setIsColumnMoving,
|
|
257
|
+
setFocusedCell = _ref2.setFocusedCell,
|
|
258
|
+
columnFocusIndex = _ref2.columnFocusIndex;
|
|
37
259
|
if (column.actions === false) {
|
|
38
260
|
return [];
|
|
39
261
|
}
|
|
@@ -51,6 +273,7 @@ var getColumnActions = exports.getColumnActions = function getColumnActions(_ref
|
|
|
51
273
|
column: column,
|
|
52
274
|
columns: columns,
|
|
53
275
|
switchColumnPos: switchColumnPos,
|
|
276
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
54
277
|
setFocusedCell: setFocusedCell,
|
|
55
278
|
columnFocusIndex: columnFocusIndex
|
|
56
279
|
})), (0, _toConsumableArray2.default)(((_column$actions = column.actions) === null || _column$actions === void 0 ? void 0 : _column$actions.additional) || []));
|
|
@@ -72,11 +295,11 @@ var getColumnActions = exports.getColumnActions = function getColumnActions(_ref
|
|
|
72
295
|
* Hide column action
|
|
73
296
|
*/
|
|
74
297
|
|
|
75
|
-
var getHideColumnAction = exports.getHideColumnAction = function getHideColumnAction(
|
|
76
|
-
var column =
|
|
77
|
-
columns =
|
|
78
|
-
setVisibleColumns =
|
|
79
|
-
focusFirstVisibleInteractiveCell =
|
|
298
|
+
var getHideColumnAction = exports.getHideColumnAction = function getHideColumnAction(_ref3) {
|
|
299
|
+
var column = _ref3.column,
|
|
300
|
+
columns = _ref3.columns,
|
|
301
|
+
setVisibleColumns = _ref3.setVisibleColumns,
|
|
302
|
+
focusFirstVisibleInteractiveCell = _ref3.focusFirstVisibleInteractiveCell;
|
|
80
303
|
var items = [];
|
|
81
304
|
var onClickHideColumn = function onClickHideColumn() {
|
|
82
305
|
setVisibleColumns(columns.filter(function (col) {
|
|
@@ -107,16 +330,25 @@ var getHideColumnAction = exports.getHideColumnAction = function getHideColumnAc
|
|
|
107
330
|
* Move column actions
|
|
108
331
|
*/
|
|
109
332
|
|
|
110
|
-
var getMoveColumnActions = function getMoveColumnActions(
|
|
111
|
-
var column =
|
|
112
|
-
columns =
|
|
113
|
-
switchColumnPos =
|
|
114
|
-
|
|
115
|
-
|
|
333
|
+
var getMoveColumnActions = function getMoveColumnActions(_ref4) {
|
|
334
|
+
var column = _ref4.column,
|
|
335
|
+
columns = _ref4.columns,
|
|
336
|
+
switchColumnPos = _ref4.switchColumnPos,
|
|
337
|
+
setIsColumnMoving = _ref4.setIsColumnMoving,
|
|
338
|
+
setFocusedCell = _ref4.setFocusedCell,
|
|
339
|
+
columnFocusIndex = _ref4.columnFocusIndex;
|
|
116
340
|
var items = [];
|
|
117
341
|
var colIdx = columns.findIndex(function (col) {
|
|
118
342
|
return col.id === column.id;
|
|
119
343
|
});
|
|
344
|
+
|
|
345
|
+
// UX polish: prevent the column actions hover animation from flashing after column move
|
|
346
|
+
var handleAnimationFlash = function handleAnimationFlash() {
|
|
347
|
+
setIsColumnMoving(true);
|
|
348
|
+
requestAnimationFrame(function () {
|
|
349
|
+
return setIsColumnMoving(false);
|
|
350
|
+
});
|
|
351
|
+
};
|
|
120
352
|
var moveFocus = function moveFocus(direction) {
|
|
121
353
|
var newIndex = direction === 'left' ? -1 : 1;
|
|
122
354
|
// Wait a beat to move focus, otherwise the EuiPopover's EuiFocusTrap's
|
|
@@ -130,6 +362,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
130
362
|
var targetCol = columns[colIdx - 1];
|
|
131
363
|
if (targetCol) {
|
|
132
364
|
switchColumnPos(column.id, targetCol.id);
|
|
365
|
+
handleAnimationFlash();
|
|
133
366
|
moveFocus('left');
|
|
134
367
|
}
|
|
135
368
|
};
|
|
@@ -151,6 +384,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
151
384
|
var targetCol = columns[colIdx + 1];
|
|
152
385
|
if (targetCol) {
|
|
153
386
|
switchColumnPos(column.id, targetCol.id);
|
|
387
|
+
handleAnimationFlash();
|
|
154
388
|
moveFocus('right');
|
|
155
389
|
}
|
|
156
390
|
};
|
|
@@ -174,11 +408,11 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
174
408
|
* Sort column actions
|
|
175
409
|
*/
|
|
176
410
|
|
|
177
|
-
var getSortColumnActions = exports.getSortColumnActions = function getSortColumnActions(
|
|
178
|
-
var column =
|
|
179
|
-
sorting =
|
|
180
|
-
schema =
|
|
181
|
-
schemaDetectors =
|
|
411
|
+
var getSortColumnActions = exports.getSortColumnActions = function getSortColumnActions(_ref5) {
|
|
412
|
+
var column = _ref5.column,
|
|
413
|
+
sorting = _ref5.sorting,
|
|
414
|
+
schema = _ref5.schema,
|
|
415
|
+
schemaDetectors = _ref5.schemaDetectors;
|
|
182
416
|
if (!sorting) return [];
|
|
183
417
|
var items = [];
|
|
184
418
|
var sortingIdx = sorting.columns.findIndex(function (col) {
|