@elastic/eui 97.0.0 → 97.2.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 +4 -6
- package/es/components/datagrid/utils/focus.js +2 -2
- package/es/components/datagrid/utils/scrolling.js +13 -10
- package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/es/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/es/components/drag_and_drop/draggable.js +13 -5
- package/es/components/header/header.styles.js +6 -12
- package/es/components/header/header_links/header_links.js +1 -1
- package/es/components/header/header_links/header_links.styles.js +1 -0
- package/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/es/components/tabs/tab.js +1 -1
- package/eui.d.ts +417 -307
- package/i18ntokens.json +175 -175
- 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 +4 -6
- package/lib/components/datagrid/utils/focus.js +2 -2
- package/lib/components/datagrid/utils/scrolling.js +13 -10
- package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/lib/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/lib/components/drag_and_drop/draggable.js +13 -5
- package/lib/components/header/header.styles.js +6 -12
- package/lib/components/header/header_links/header_links.js +1 -1
- package/lib/components/header/header_links/header_links.styles.js +1 -0
- 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 +4 -6
- package/optimize/es/components/datagrid/utils/focus.js +2 -2
- package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- 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/header/header_links/header_links.js +1 -1
- package/optimize/es/components/header/header_links/header_links.styles.js +1 -0
- 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 +4 -6
- package/optimize/lib/components/datagrid/utils/focus.js +2 -2
- package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- 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/header/header_links/header_links.js +1 -1
- package/optimize/lib/components/header/header_links/header_links.styles.js +1 -0
- 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 +1 -1
- 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 +4 -6
- package/test-env/components/datagrid/utils/focus.js +2 -2
- package/test-env/components/datagrid/utils/scrolling.js +13 -10
- package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/test-env/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- 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/header/header_links/header_links.js +1 -1
- package/test-env/components/header/header_links/header_links.styles.js +1 -0
- package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
- package/test-env/components/tabs/tab.js +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
6
|
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; }
|
|
5
7
|
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) { _defineProperty(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; }
|
|
6
8
|
/*
|
|
@@ -11,24 +13,234 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
13
|
* Side Public License, v 1.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import {
|
|
16
|
+
import React, { useContext, useState, useMemo, useCallback, useRef, memo, useEffect } from 'react';
|
|
17
|
+
import { tabbable } from 'tabbable';
|
|
18
|
+
import { keys, useEuiMemoizedStyles } from '../../../../services';
|
|
19
|
+
// Keep the i18n scope the same as EuiDataGridHeaderCell
|
|
20
|
+
/* eslint-disable local/i18n */
|
|
21
|
+
import { EuiI18n, useEuiI18n } from '../../../i18n';
|
|
22
|
+
import { EuiPopover } from '../../../popover';
|
|
23
|
+
import { EuiListGroup } from '../../../list_group';
|
|
24
|
+
import { EuiButtonIcon } from '../../../button';
|
|
25
|
+
import { DataGridFocusContext } from '../../utils/focus';
|
|
16
26
|
import { getDetailsForSchema } from '../../utils/data_grid_schema';
|
|
17
27
|
import { defaultSortAscLabel, defaultSortDescLabel } from '../../controls/column_sorting_draggable';
|
|
28
|
+
import { euiDataGridHeaderCellStyles } from './data_grid_header_cell.styles';
|
|
18
29
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
19
|
-
export var
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
export var useHasColumnActions = function useHasColumnActions(columnActions) {
|
|
31
|
+
return useMemo(function () {
|
|
32
|
+
// By default, all column actions are enabled
|
|
33
|
+
if (columnActions === undefined) return true;
|
|
34
|
+
if (columnActions === false) return false;
|
|
35
|
+
if (columnActions.additional && columnActions.additional.length) return true;
|
|
36
|
+
// Check if all (currently 5) default column actions have been manually disabled
|
|
37
|
+
var disabledActions = Object.values(columnActions).filter(function (action) {
|
|
38
|
+
return action === false;
|
|
39
|
+
});
|
|
40
|
+
return disabledActions.length < 5;
|
|
41
|
+
}, [columnActions]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Props to pass back to EuiDataGridHeaderCell and set on EuiDataGridHeaderCellWrapper
|
|
45
|
+
|
|
46
|
+
export var ColumnActions = /*#__PURE__*/memo(function (_ref) {
|
|
47
|
+
var index = _ref.index,
|
|
48
|
+
id = _ref.id,
|
|
49
|
+
title = _ref.title,
|
|
50
|
+
column = _ref.column,
|
|
22
51
|
columns = _ref.columns,
|
|
23
52
|
schema = _ref.schema,
|
|
24
53
|
schemaDetectors = _ref.schemaDetectors,
|
|
25
54
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
26
|
-
focusFirstVisibleInteractiveCell = _ref.focusFirstVisibleInteractiveCell,
|
|
27
|
-
setIsPopoverOpen = _ref.setIsPopoverOpen,
|
|
28
|
-
sorting = _ref.sorting,
|
|
29
55
|
switchColumnPos = _ref.switchColumnPos,
|
|
30
|
-
|
|
31
|
-
|
|
56
|
+
sorting = _ref.sorting,
|
|
57
|
+
hasFocusTrap = _ref.hasFocusTrap,
|
|
58
|
+
setPropsFromColumnActions = _ref.setPropsFromColumnActions,
|
|
59
|
+
actionsButtonRef = _ref.actionsButtonRef;
|
|
60
|
+
/**
|
|
61
|
+
* Popover logic and accessibility
|
|
62
|
+
*/
|
|
63
|
+
var _useState = useState(false),
|
|
64
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
65
|
+
isPopoverOpen = _useState2[0],
|
|
66
|
+
setIsPopoverOpen = _useState2[1];
|
|
67
|
+
var togglePopover = useCallback(function () {
|
|
68
|
+
setIsPopoverOpen(function (isOpen) {
|
|
69
|
+
return !isOpen;
|
|
70
|
+
});
|
|
71
|
+
}, []);
|
|
72
|
+
var closePopover = useCallback(function () {
|
|
73
|
+
setIsPopoverOpen(false);
|
|
74
|
+
}, []);
|
|
75
|
+
var _useState3 = useState(false),
|
|
76
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
77
|
+
isActionsButtonFocused = _useState4[0],
|
|
78
|
+
setIsActionsButtonFocused = _useState4[1];
|
|
79
|
+
var onFocus = useCallback(function () {
|
|
80
|
+
return setIsActionsButtonFocused(true);
|
|
81
|
+
}, []);
|
|
82
|
+
var onBlur = useCallback(function () {
|
|
83
|
+
return setIsActionsButtonFocused(false);
|
|
84
|
+
}, []);
|
|
85
|
+
var actionsButtonAriaLabel = useEuiI18n('euiDataGridHeaderCell.actionsButtonAriaLabel', '{title}. Click to view column header actions.', {
|
|
86
|
+
title: title
|
|
87
|
+
});
|
|
88
|
+
var actionsEnterKeyInstructions = useEuiI18n('euiDataGridHeaderCell.actionsEnterKeyInstructions', "Press the Enter key to view this column's actions");
|
|
89
|
+
var openActionsPopoverOnEnter = useCallback(function (e) {
|
|
90
|
+
if (e.key === keys.ENTER) {
|
|
91
|
+
setIsPopoverOpen(true);
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
var popoverArrowNavigationProps = usePopoverArrowNavigation();
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Props to set on parent EuiDataGridHeaderCell
|
|
98
|
+
*/
|
|
99
|
+
var _useState5 = useState(false),
|
|
100
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
101
|
+
isColumnMoving = _useState6[0],
|
|
102
|
+
setIsColumnMoving = _useState6[1];
|
|
103
|
+
useEffect(function () {
|
|
104
|
+
setPropsFromColumnActions({
|
|
105
|
+
className: isPopoverOpen ? 'euiDataGridHeaderCell--isActionsPopoverOpen' : '',
|
|
106
|
+
onKeyDown: openActionsPopoverOnEnter,
|
|
107
|
+
'data-column-moving': isColumnMoving || undefined
|
|
108
|
+
});
|
|
109
|
+
}, [setPropsFromColumnActions, isPopoverOpen, openActionsPopoverOnEnter, isColumnMoving]);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get column actions as an array of EuiListGroup items
|
|
113
|
+
*/
|
|
114
|
+
var _useContext = useContext(DataGridFocusContext),
|
|
115
|
+
setFocusedCell = _useContext.setFocusedCell,
|
|
116
|
+
focusFirstVisibleInteractiveCell = _useContext.focusFirstVisibleInteractiveCell;
|
|
117
|
+
var columnActions = useMemo(function () {
|
|
118
|
+
return getColumnActions({
|
|
119
|
+
column: column,
|
|
120
|
+
columns: columns,
|
|
121
|
+
schema: schema,
|
|
122
|
+
schemaDetectors: schemaDetectors,
|
|
123
|
+
setVisibleColumns: setVisibleColumns,
|
|
124
|
+
focusFirstVisibleInteractiveCell: focusFirstVisibleInteractiveCell,
|
|
125
|
+
sorting: sorting,
|
|
126
|
+
switchColumnPos: switchColumnPos,
|
|
127
|
+
setIsPopoverOpen: setIsPopoverOpen,
|
|
128
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
129
|
+
setFocusedCell: setFocusedCell,
|
|
130
|
+
columnFocusIndex: index
|
|
131
|
+
});
|
|
132
|
+
}, [column, columns, schema, schemaDetectors, setVisibleColumns, focusFirstVisibleInteractiveCell, sorting, switchColumnPos, setFocusedCell, index]);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Rendering
|
|
136
|
+
*/
|
|
137
|
+
var styles = useEuiMemoizedStyles(euiDataGridHeaderCellStyles);
|
|
138
|
+
return ___EmotionJSX(EuiPopover, _extends({
|
|
139
|
+
display: "block",
|
|
140
|
+
panelPaddingSize: "none",
|
|
141
|
+
offset: 7,
|
|
142
|
+
anchorPosition: "downRight",
|
|
143
|
+
css: styles.euiDataGridHeaderCell__popover,
|
|
144
|
+
button: ___EmotionJSX(EuiButtonIcon, {
|
|
145
|
+
iconType: "boxesVertical",
|
|
146
|
+
iconSize: "s",
|
|
147
|
+
color: "text",
|
|
148
|
+
css: styles.euiDataGridHeaderCell__actions,
|
|
149
|
+
className: "euiDataGridHeaderCell__button",
|
|
150
|
+
onClick: togglePopover,
|
|
151
|
+
buttonRef: actionsButtonRef,
|
|
152
|
+
onFocus: onFocus,
|
|
153
|
+
onBlur: onBlur,
|
|
154
|
+
tabIndex: 0 // Override EuiButtonIcon's conditional tabindex based on aria-hidden
|
|
155
|
+
,
|
|
156
|
+
"aria-hidden": hasFocusTrap && !isActionsButtonFocused ? 'true' // prevent the actions button from being read on cell focus
|
|
157
|
+
: undefined,
|
|
158
|
+
"aria-label": hasFocusTrap ? actionsButtonAriaLabel : actionsEnterKeyInstructions,
|
|
159
|
+
"data-test-subj": "dataGridHeaderCellActionButton-".concat(id)
|
|
160
|
+
}),
|
|
161
|
+
isOpen: isPopoverOpen,
|
|
162
|
+
closePopover: closePopover
|
|
163
|
+
}, popoverArrowNavigationProps), ___EmotionJSX(EuiListGroup, {
|
|
164
|
+
listItems: columnActions,
|
|
165
|
+
gutterSize: "none",
|
|
166
|
+
"data-test-subj": "dataGridHeaderCellActionGroup-".concat(id)
|
|
167
|
+
}));
|
|
168
|
+
});
|
|
169
|
+
ColumnActions.displayName = 'EuiDataGridHeaderCellColumnActions';
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Add keyboard arrow navigation to the cell actions popover
|
|
173
|
+
* to match the UX of the rest of EuiDataGrid
|
|
174
|
+
*/
|
|
175
|
+
export var usePopoverArrowNavigation = function usePopoverArrowNavigation() {
|
|
176
|
+
var popoverPanelRef = useRef(null);
|
|
177
|
+
var actionsRef = useRef(undefined);
|
|
178
|
+
var panelRef = useCallback(function (ref) {
|
|
179
|
+
popoverPanelRef.current = ref;
|
|
180
|
+
actionsRef.current = ref ? tabbable(ref) : undefined;
|
|
181
|
+
}, []);
|
|
182
|
+
var onKeyDown = useCallback(function (e) {
|
|
183
|
+
var _actionsRef$current;
|
|
184
|
+
if (e.key !== keys.ARROW_DOWN && e.key !== keys.ARROW_UP) return;
|
|
185
|
+
if (!((_actionsRef$current = actionsRef.current) !== null && _actionsRef$current !== void 0 && _actionsRef$current.length)) return;
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
var initialState = document.activeElement === popoverPanelRef.current;
|
|
188
|
+
var currentIndex = !initialState ? actionsRef.current.findIndex(function (el) {
|
|
189
|
+
return document.activeElement === el;
|
|
190
|
+
}) : -1;
|
|
191
|
+
var lastIndex = actionsRef.current.length - 1;
|
|
192
|
+
var indexToFocus;
|
|
193
|
+
if (initialState) {
|
|
194
|
+
if (e.key === keys.ARROW_DOWN) {
|
|
195
|
+
indexToFocus = 0;
|
|
196
|
+
} else if (e.key === keys.ARROW_UP) {
|
|
197
|
+
indexToFocus = lastIndex;
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
if (e.key === keys.ARROW_DOWN) {
|
|
201
|
+
indexToFocus = currentIndex + 1;
|
|
202
|
+
if (indexToFocus > lastIndex) {
|
|
203
|
+
indexToFocus = 0;
|
|
204
|
+
}
|
|
205
|
+
} else if (e.key === keys.ARROW_UP) {
|
|
206
|
+
indexToFocus = currentIndex - 1;
|
|
207
|
+
if (indexToFocus < 0) {
|
|
208
|
+
indexToFocus = lastIndex;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
actionsRef.current[indexToFocus].focus();
|
|
213
|
+
}, []);
|
|
214
|
+
return {
|
|
215
|
+
panelRef: panelRef,
|
|
216
|
+
panelProps: {
|
|
217
|
+
onKeyDown: onKeyDown
|
|
218
|
+
},
|
|
219
|
+
popoverScreenReaderText: ___EmotionJSX(EuiI18n, {
|
|
220
|
+
token: "euiDataGridHeaderCell.actionsPopoverScreenReaderText",
|
|
221
|
+
default: "To navigate through the list of column actions, press the Tab or Up and Down arrow keys."
|
|
222
|
+
})
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Logic for returning an array of actions/items to pass to EuiListGroup
|
|
228
|
+
*/
|
|
229
|
+
|
|
230
|
+
export var getColumnActions = function getColumnActions(_ref2) {
|
|
231
|
+
var _column$actions;
|
|
232
|
+
var column = _ref2.column,
|
|
233
|
+
columns = _ref2.columns,
|
|
234
|
+
schema = _ref2.schema,
|
|
235
|
+
schemaDetectors = _ref2.schemaDetectors,
|
|
236
|
+
setVisibleColumns = _ref2.setVisibleColumns,
|
|
237
|
+
focusFirstVisibleInteractiveCell = _ref2.focusFirstVisibleInteractiveCell,
|
|
238
|
+
setIsPopoverOpen = _ref2.setIsPopoverOpen,
|
|
239
|
+
sorting = _ref2.sorting,
|
|
240
|
+
switchColumnPos = _ref2.switchColumnPos,
|
|
241
|
+
setIsColumnMoving = _ref2.setIsColumnMoving,
|
|
242
|
+
setFocusedCell = _ref2.setFocusedCell,
|
|
243
|
+
columnFocusIndex = _ref2.columnFocusIndex;
|
|
32
244
|
if (column.actions === false) {
|
|
33
245
|
return [];
|
|
34
246
|
}
|
|
@@ -46,6 +258,7 @@ export var getColumnActions = function getColumnActions(_ref) {
|
|
|
46
258
|
column: column,
|
|
47
259
|
columns: columns,
|
|
48
260
|
switchColumnPos: switchColumnPos,
|
|
261
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
49
262
|
setFocusedCell: setFocusedCell,
|
|
50
263
|
columnFocusIndex: columnFocusIndex
|
|
51
264
|
})), _toConsumableArray(((_column$actions = column.actions) === null || _column$actions === void 0 ? void 0 : _column$actions.additional) || []));
|
|
@@ -67,11 +280,11 @@ export var getColumnActions = function getColumnActions(_ref) {
|
|
|
67
280
|
* Hide column action
|
|
68
281
|
*/
|
|
69
282
|
|
|
70
|
-
export var getHideColumnAction = function getHideColumnAction(
|
|
71
|
-
var column =
|
|
72
|
-
columns =
|
|
73
|
-
setVisibleColumns =
|
|
74
|
-
focusFirstVisibleInteractiveCell =
|
|
283
|
+
export var getHideColumnAction = function getHideColumnAction(_ref3) {
|
|
284
|
+
var column = _ref3.column,
|
|
285
|
+
columns = _ref3.columns,
|
|
286
|
+
setVisibleColumns = _ref3.setVisibleColumns,
|
|
287
|
+
focusFirstVisibleInteractiveCell = _ref3.focusFirstVisibleInteractiveCell;
|
|
75
288
|
var items = [];
|
|
76
289
|
var onClickHideColumn = function onClickHideColumn() {
|
|
77
290
|
setVisibleColumns(columns.filter(function (col) {
|
|
@@ -102,16 +315,25 @@ export var getHideColumnAction = function getHideColumnAction(_ref2) {
|
|
|
102
315
|
* Move column actions
|
|
103
316
|
*/
|
|
104
317
|
|
|
105
|
-
var getMoveColumnActions = function getMoveColumnActions(
|
|
106
|
-
var column =
|
|
107
|
-
columns =
|
|
108
|
-
switchColumnPos =
|
|
109
|
-
|
|
110
|
-
|
|
318
|
+
var getMoveColumnActions = function getMoveColumnActions(_ref4) {
|
|
319
|
+
var column = _ref4.column,
|
|
320
|
+
columns = _ref4.columns,
|
|
321
|
+
switchColumnPos = _ref4.switchColumnPos,
|
|
322
|
+
setIsColumnMoving = _ref4.setIsColumnMoving,
|
|
323
|
+
setFocusedCell = _ref4.setFocusedCell,
|
|
324
|
+
columnFocusIndex = _ref4.columnFocusIndex;
|
|
111
325
|
var items = [];
|
|
112
326
|
var colIdx = columns.findIndex(function (col) {
|
|
113
327
|
return col.id === column.id;
|
|
114
328
|
});
|
|
329
|
+
|
|
330
|
+
// UX polish: prevent the column actions hover animation from flashing after column move
|
|
331
|
+
var handleAnimationFlash = function handleAnimationFlash() {
|
|
332
|
+
setIsColumnMoving(true);
|
|
333
|
+
requestAnimationFrame(function () {
|
|
334
|
+
return setIsColumnMoving(false);
|
|
335
|
+
});
|
|
336
|
+
};
|
|
115
337
|
var moveFocus = function moveFocus(direction) {
|
|
116
338
|
var newIndex = direction === 'left' ? -1 : 1;
|
|
117
339
|
// Wait a beat to move focus, otherwise the EuiPopover's EuiFocusTrap's
|
|
@@ -125,6 +347,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
125
347
|
var targetCol = columns[colIdx - 1];
|
|
126
348
|
if (targetCol) {
|
|
127
349
|
switchColumnPos(column.id, targetCol.id);
|
|
350
|
+
handleAnimationFlash();
|
|
128
351
|
moveFocus('left');
|
|
129
352
|
}
|
|
130
353
|
};
|
|
@@ -146,6 +369,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
146
369
|
var targetCol = columns[colIdx + 1];
|
|
147
370
|
if (targetCol) {
|
|
148
371
|
switchColumnPos(column.id, targetCol.id);
|
|
372
|
+
handleAnimationFlash();
|
|
149
373
|
moveFocus('right');
|
|
150
374
|
}
|
|
151
375
|
};
|
|
@@ -169,11 +393,11 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
169
393
|
* Sort column actions
|
|
170
394
|
*/
|
|
171
395
|
|
|
172
|
-
export var getSortColumnActions = function getSortColumnActions(
|
|
173
|
-
var column =
|
|
174
|
-
sorting =
|
|
175
|
-
schema =
|
|
176
|
-
schemaDetectors =
|
|
396
|
+
export var getSortColumnActions = function getSortColumnActions(_ref5) {
|
|
397
|
+
var column = _ref5.column,
|
|
398
|
+
sorting = _ref5.sorting,
|
|
399
|
+
schema = _ref5.schema,
|
|
400
|
+
schemaDetectors = _ref5.schemaDetectors;
|
|
177
401
|
if (!sorting) return [];
|
|
178
402
|
var items = [];
|
|
179
403
|
var sortingIdx = sorting.columns.findIndex(function (col) {
|
|
@@ -17,7 +17,8 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
17
17
|
import React, { Component } from 'react';
|
|
18
18
|
import { RenderWithEuiStylesMemoizer } from '../../../../services';
|
|
19
19
|
import { logicalStyle } from '../../../../global_styling';
|
|
20
|
-
import {
|
|
20
|
+
import { DragOverlay } from './draggable_columns';
|
|
21
|
+
import { euiDataGridColumnResizerStyles } from './column_resizer.styles';
|
|
21
22
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
22
23
|
var MINIMUM_COLUMN_WIDTH = 40;
|
|
23
24
|
export var EuiDataGridColumnResizer = /*#__PURE__*/function (_Component) {
|
|
@@ -74,16 +75,20 @@ export var EuiDataGridColumnResizer = /*#__PURE__*/function (_Component) {
|
|
|
74
75
|
value: function render() {
|
|
75
76
|
var _this2 = this;
|
|
76
77
|
var offset = this.state.offset;
|
|
78
|
+
var isLastColumn = this.props.isLastColumn;
|
|
77
79
|
return ___EmotionJSX(RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
|
|
78
80
|
var styles = stylesMemoizer(euiDataGridColumnResizerStyles);
|
|
79
|
-
var cssStyles = [styles.euiDataGridColumnResizer, offset && styles.isDragging];
|
|
81
|
+
var cssStyles = [styles.euiDataGridColumnResizer, isLastColumn && styles.isLastColumn, offset && styles.isDragging];
|
|
80
82
|
return ___EmotionJSX("div", {
|
|
81
83
|
css: cssStyles,
|
|
82
84
|
className: "euiDataGridColumnResizer",
|
|
83
85
|
"data-test-subj": "dataGridColumnResizer",
|
|
84
86
|
style: offset ? logicalStyle('margin-right', "".concat(-offset, "px")) : undefined,
|
|
85
87
|
onMouseDown: _this2.onMouseDown
|
|
86
|
-
}
|
|
88
|
+
}, ___EmotionJSX(DragOverlay, {
|
|
89
|
+
isDragging: !!offset,
|
|
90
|
+
cursor: "ew-resize"
|
|
91
|
+
}));
|
|
87
92
|
});
|
|
88
93
|
}
|
|
89
94
|
}]);
|
|
@@ -30,7 +30,12 @@ export var euiDataGridColumnResizerStyles = function euiDataGridColumnResizerSty
|
|
|
30
30
|
}); // Odd number because it straddles a border
|
|
31
31
|
var indicatorOffset = "-".concat(euiTheme.border.width.thin);
|
|
32
32
|
return {
|
|
33
|
-
euiDataGridColumnResizer: /*#__PURE__*/css("z-index:2;position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('left', positionOffset), " ", logicalCSS('margin-left', indicatorOffset), " ", logicalCSS('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";}
|
|
33
|
+
euiDataGridColumnResizer: /*#__PURE__*/css("z-index:2;position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('left', positionOffset), " ", logicalCSS('margin-left', indicatorOffset), " ", logicalCSS('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";};label:euiDataGridColumnResizer;"),
|
|
34
|
+
/* Because the resizer sits in the negative space to the right of the column,
|
|
35
|
+
* it can cause the full grid to be a few pixels longer than it actually is.
|
|
36
|
+
* So for the last cell, we don't use negative positioning and the borders from
|
|
37
|
+
* the cell will match the container. */
|
|
38
|
+
isLastColumn: /*#__PURE__*/css(logicalCSS('right', 0), " ", logicalCSS('width', euiTheme.size.s), " &::after{", logicalCSS('left', 'auto'), " ", logicalCSS('right', 0), ";};label:isLastColumn;"),
|
|
34
39
|
isDragging: _ref
|
|
35
40
|
};
|
|
36
41
|
};
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
import React, { useMemo } from 'react';
|
|
10
|
+
import { useGeneratedHtmlId } from '../../../../services';
|
|
11
|
+
// Keep the i18n scope the same as EuiDataGridHeaderCell
|
|
12
|
+
/* eslint-disable local/i18n */
|
|
13
|
+
import { EuiI18n } from '../../../i18n';
|
|
14
|
+
import { EuiIcon } from '../../../icon';
|
|
15
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
16
|
+
/**
|
|
17
|
+
* Column sorting utility helpers
|
|
18
|
+
*/
|
|
19
|
+
export var useColumnSorting = function useColumnSorting(_ref) {
|
|
20
|
+
var _sorting$columns;
|
|
21
|
+
var sorting = _ref.sorting,
|
|
22
|
+
id = _ref.id,
|
|
23
|
+
hasColumnActions = _ref.hasColumnActions;
|
|
24
|
+
var sortedColumn = useMemo(function () {
|
|
25
|
+
return sorting === null || sorting === void 0 ? void 0 : sorting.columns.find(function (col) {
|
|
26
|
+
return col.id === id;
|
|
27
|
+
});
|
|
28
|
+
}, [sorting, id]);
|
|
29
|
+
var isColumnSorted = !!sortedColumn;
|
|
30
|
+
var hasOnlyOneSort = (sorting === null || sorting === void 0 || (_sorting$columns = sorting.columns) === null || _sorting$columns === void 0 ? void 0 : _sorting$columns.length) === 1;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Arrow icon
|
|
34
|
+
*/
|
|
35
|
+
var sortingArrow = useMemo(function () {
|
|
36
|
+
return isColumnSorted ? ___EmotionJSX(EuiIcon, {
|
|
37
|
+
type: sortedColumn.direction === 'asc' ? 'sortUp' : 'sortDown',
|
|
38
|
+
color: "text",
|
|
39
|
+
className: "euiDataGridHeaderCell__sortingArrow",
|
|
40
|
+
"data-test-subj": "dataGridHeaderCellSortingIcon-".concat(id)
|
|
41
|
+
}) : null;
|
|
42
|
+
}, [id, isColumnSorted, sortedColumn]);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* aria-sort attribute - should only be used when a single column is being sorted
|
|
46
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort
|
|
47
|
+
* @see https://www.w3.org/WAI/ARIA/apg/example-index/table/sortable-table.html
|
|
48
|
+
* @see https://github.com/w3c/aria/issues/283 for potential future multi-column usage
|
|
49
|
+
*/
|
|
50
|
+
var ariaSort = isColumnSorted && hasOnlyOneSort ? sorting.columns[0].direction === 'asc' ? 'ascending' : 'descending' : undefined;
|
|
51
|
+
|
|
52
|
+
// aria-describedby ID for when aria-sort isn't sufficient
|
|
53
|
+
var sortingAriaId = useGeneratedHtmlId({
|
|
54
|
+
prefix: 'euiDataGridCellHeader',
|
|
55
|
+
suffix: 'sorting'
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Sorting status - screen reader text
|
|
60
|
+
*/
|
|
61
|
+
var sortingScreenReaderText = useMemo(function () {
|
|
62
|
+
var _sorting$columns2;
|
|
63
|
+
if (!isColumnSorted) return null;
|
|
64
|
+
if (!hasColumnActions && hasOnlyOneSort) return null; // in this scenario, the `aria-sort` attribute will be used by screen readers
|
|
65
|
+
return ___EmotionJSX("p", {
|
|
66
|
+
id: sortingAriaId,
|
|
67
|
+
hidden: true
|
|
68
|
+
}, sorting === null || sorting === void 0 || (_sorting$columns2 = sorting.columns) === null || _sorting$columns2 === void 0 ? void 0 : _sorting$columns2.map(function (_ref2, index) {
|
|
69
|
+
var columnId = _ref2.id,
|
|
70
|
+
direction = _ref2.direction;
|
|
71
|
+
if (hasOnlyOneSort) {
|
|
72
|
+
if (direction === 'asc') {
|
|
73
|
+
return ___EmotionJSX(EuiI18n, {
|
|
74
|
+
token: "euiDataGridHeaderCell.sortedByAscendingSingle",
|
|
75
|
+
default: "Sorted ascending",
|
|
76
|
+
key: index
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return ___EmotionJSX(EuiI18n, {
|
|
80
|
+
token: "euiDataGridHeaderCell.sortedByDescendingSingle",
|
|
81
|
+
default: "Sorted descending",
|
|
82
|
+
key: index
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} else if (index === 0) {
|
|
86
|
+
if (direction === 'asc') {
|
|
87
|
+
return ___EmotionJSX(EuiI18n, {
|
|
88
|
+
token: "euiDataGridHeaderCell.sortedByAscendingFirst",
|
|
89
|
+
default: "Sorted by {columnId}, ascending",
|
|
90
|
+
values: {
|
|
91
|
+
columnId: columnId
|
|
92
|
+
},
|
|
93
|
+
key: index
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
return ___EmotionJSX(EuiI18n, {
|
|
97
|
+
token: "euiDataGridHeaderCell.sortedByDescendingFirst",
|
|
98
|
+
default: "Sorted by {columnId}, descending",
|
|
99
|
+
values: {
|
|
100
|
+
columnId: columnId
|
|
101
|
+
},
|
|
102
|
+
key: index
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
if (direction === 'asc') {
|
|
107
|
+
return ___EmotionJSX(EuiI18n, {
|
|
108
|
+
token: "euiDataGridHeaderCell.sortedByAscendingMultiple",
|
|
109
|
+
default: ", then sorted by {columnId}, ascending",
|
|
110
|
+
values: {
|
|
111
|
+
columnId: columnId
|
|
112
|
+
},
|
|
113
|
+
key: index
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
return ___EmotionJSX(EuiI18n, {
|
|
117
|
+
token: "euiDataGridHeaderCell.sortedByDescendingMultiple",
|
|
118
|
+
default: ", then sorted by {columnId}, descending",
|
|
119
|
+
values: {
|
|
120
|
+
columnId: columnId
|
|
121
|
+
},
|
|
122
|
+
key: index
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}), ".");
|
|
127
|
+
}, [isColumnSorted, hasColumnActions, hasOnlyOneSort, sorting, sortingAriaId]);
|
|
128
|
+
return {
|
|
129
|
+
sortingArrow: sortingArrow,
|
|
130
|
+
ariaSort: ariaSort,
|
|
131
|
+
sortingAriaId: sortingAriaId,
|
|
132
|
+
sortingScreenReaderText: sortingScreenReaderText
|
|
133
|
+
};
|
|
134
|
+
};
|
|
@@ -14,7 +14,7 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
14
14
|
export var EuiDataGridControlHeaderCell = /*#__PURE__*/memo(function (_ref) {
|
|
15
15
|
var controlColumn = _ref.controlColumn,
|
|
16
16
|
index = _ref.index,
|
|
17
|
-
|
|
17
|
+
isLastColumn = _ref.isLastColumn;
|
|
18
18
|
var HeaderCellRender = controlColumn.headerCellRender,
|
|
19
19
|
headerCellProps = controlColumn.headerCellProps,
|
|
20
20
|
width = controlColumn.width,
|
|
@@ -24,7 +24,7 @@ export var EuiDataGridControlHeaderCell = /*#__PURE__*/memo(function (_ref) {
|
|
|
24
24
|
id: id,
|
|
25
25
|
index: index,
|
|
26
26
|
width: width,
|
|
27
|
-
|
|
27
|
+
isLastColumn: isLastColumn
|
|
28
28
|
}), ___EmotionJSX(HeaderCellRender, null));
|
|
29
29
|
});
|
|
30
30
|
EuiDataGridControlHeaderCell.displayName = 'EuiDataGridControlHeaderCell';
|