@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,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) {
|
package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js}
RENAMED
|
@@ -16,7 +16,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
var _services = require("../../../../services");
|
|
18
18
|
var _global_styling = require("../../../../global_styling");
|
|
19
|
-
var
|
|
19
|
+
var _draggable_columns = require("./draggable_columns");
|
|
20
|
+
var _column_resizer = require("./column_resizer.styles");
|
|
20
21
|
var _react2 = require("@emotion/react");
|
|
21
22
|
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); }
|
|
22
23
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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; }
|
|
@@ -83,16 +84,20 @@ var EuiDataGridColumnResizer = exports.EuiDataGridColumnResizer = /*#__PURE__*/f
|
|
|
83
84
|
value: function render() {
|
|
84
85
|
var _this2 = this;
|
|
85
86
|
var offset = this.state.offset;
|
|
87
|
+
var isLastColumn = this.props.isLastColumn;
|
|
86
88
|
return (0, _react2.jsx)(_services.RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
|
|
87
|
-
var styles = stylesMemoizer(
|
|
88
|
-
var cssStyles = [styles.euiDataGridColumnResizer, offset && styles.isDragging];
|
|
89
|
+
var styles = stylesMemoizer(_column_resizer.euiDataGridColumnResizerStyles);
|
|
90
|
+
var cssStyles = [styles.euiDataGridColumnResizer, isLastColumn && styles.isLastColumn, offset && styles.isDragging];
|
|
89
91
|
return (0, _react2.jsx)("div", {
|
|
90
92
|
css: cssStyles,
|
|
91
93
|
className: "euiDataGridColumnResizer",
|
|
92
94
|
"data-test-subj": "dataGridColumnResizer",
|
|
93
95
|
style: offset ? (0, _global_styling.logicalStyle)('margin-right', "".concat(-offset, "px")) : undefined,
|
|
94
96
|
onMouseDown: _this2.onMouseDown
|
|
95
|
-
})
|
|
97
|
+
}, (0, _react2.jsx)(_draggable_columns.DragOverlay, {
|
|
98
|
+
isDragging: !!offset,
|
|
99
|
+
cursor: "ew-resize"
|
|
100
|
+
}));
|
|
96
101
|
});
|
|
97
102
|
}
|
|
98
103
|
}]);
|
|
@@ -100,5 +105,6 @@ var EuiDataGridColumnResizer = exports.EuiDataGridColumnResizer = /*#__PURE__*/f
|
|
|
100
105
|
EuiDataGridColumnResizer.propTypes = {
|
|
101
106
|
columnId: _propTypes.default.string.isRequired,
|
|
102
107
|
columnWidth: _propTypes.default.number.isRequired,
|
|
103
|
-
setColumnWidth: _propTypes.default.func.isRequired
|
|
108
|
+
setColumnWidth: _propTypes.default.func.isRequired,
|
|
109
|
+
isLastColumn: _propTypes.default.bool.isRequired
|
|
104
110
|
};
|
|
@@ -33,7 +33,12 @@ var euiDataGridColumnResizerStyles = exports.euiDataGridColumnResizerStyles = fu
|
|
|
33
33
|
}); // Odd number because it straddles a border
|
|
34
34
|
var indicatorOffset = "-".concat(euiTheme.border.width.thin);
|
|
35
35
|
return {
|
|
36
|
-
euiDataGridColumnResizer: /*#__PURE__*/(0, _react.css)("z-index:2;position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('left', positionOffset), " ", (0, _global_styling.logicalCSS)('margin-left', indicatorOffset), " ", (0, _global_styling.logicalCSS)('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";}
|
|
36
|
+
euiDataGridColumnResizer: /*#__PURE__*/(0, _react.css)("z-index:2;position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", (0, _global_styling.logicalCSS)('vertical', 0), " ", (0, _global_styling.logicalCSS)('left', positionOffset), " ", (0, _global_styling.logicalCSS)('margin-left', indicatorOffset), " ", (0, _global_styling.logicalCSS)('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";};label:euiDataGridColumnResizer;"),
|
|
37
|
+
/* Because the resizer sits in the negative space to the right of the column,
|
|
38
|
+
* it can cause the full grid to be a few pixels longer than it actually is.
|
|
39
|
+
* So for the last cell, we don't use negative positioning and the borders from
|
|
40
|
+
* the cell will match the container. */
|
|
41
|
+
isLastColumn: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('right', 0), " ", (0, _global_styling.logicalCSS)('width', euiTheme.size.s), " &::after{", (0, _global_styling.logicalCSS)('left', 'auto'), " ", (0, _global_styling.logicalCSS)('right', 0), ";};label:isLastColumn;"),
|
|
37
42
|
isDragging: _ref
|
|
38
43
|
};
|
|
39
44
|
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useColumnSorting = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _services = require("../../../../services");
|
|
10
|
+
var _i18n = require("../../../i18n");
|
|
11
|
+
var _icon = require("../../../icon");
|
|
12
|
+
var _react2 = require("@emotion/react");
|
|
13
|
+
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); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(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; }
|
|
15
|
+
/*
|
|
16
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
17
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
18
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
19
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
20
|
+
* Side Public License, v 1.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Keep the i18n scope the same as EuiDataGridHeaderCell
|
|
24
|
+
/* eslint-disable local/i18n */
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Column sorting utility helpers
|
|
28
|
+
*/
|
|
29
|
+
var useColumnSorting = exports.useColumnSorting = function useColumnSorting(_ref) {
|
|
30
|
+
var _sorting$columns;
|
|
31
|
+
var sorting = _ref.sorting,
|
|
32
|
+
id = _ref.id,
|
|
33
|
+
hasColumnActions = _ref.hasColumnActions;
|
|
34
|
+
var sortedColumn = (0, _react.useMemo)(function () {
|
|
35
|
+
return sorting === null || sorting === void 0 ? void 0 : sorting.columns.find(function (col) {
|
|
36
|
+
return col.id === id;
|
|
37
|
+
});
|
|
38
|
+
}, [sorting, id]);
|
|
39
|
+
var isColumnSorted = !!sortedColumn;
|
|
40
|
+
var hasOnlyOneSort = (sorting === null || sorting === void 0 || (_sorting$columns = sorting.columns) === null || _sorting$columns === void 0 ? void 0 : _sorting$columns.length) === 1;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Arrow icon
|
|
44
|
+
*/
|
|
45
|
+
var sortingArrow = (0, _react.useMemo)(function () {
|
|
46
|
+
return isColumnSorted ? (0, _react2.jsx)(_icon.EuiIcon, {
|
|
47
|
+
type: sortedColumn.direction === 'asc' ? 'sortUp' : 'sortDown',
|
|
48
|
+
color: "text",
|
|
49
|
+
className: "euiDataGridHeaderCell__sortingArrow",
|
|
50
|
+
"data-test-subj": "dataGridHeaderCellSortingIcon-".concat(id)
|
|
51
|
+
}) : null;
|
|
52
|
+
}, [id, isColumnSorted, sortedColumn]);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* aria-sort attribute - should only be used when a single column is being sorted
|
|
56
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort
|
|
57
|
+
* @see https://www.w3.org/WAI/ARIA/apg/example-index/table/sortable-table.html
|
|
58
|
+
* @see https://github.com/w3c/aria/issues/283 for potential future multi-column usage
|
|
59
|
+
*/
|
|
60
|
+
var ariaSort = isColumnSorted && hasOnlyOneSort ? sorting.columns[0].direction === 'asc' ? 'ascending' : 'descending' : undefined;
|
|
61
|
+
|
|
62
|
+
// aria-describedby ID for when aria-sort isn't sufficient
|
|
63
|
+
var sortingAriaId = (0, _services.useGeneratedHtmlId)({
|
|
64
|
+
prefix: 'euiDataGridCellHeader',
|
|
65
|
+
suffix: 'sorting'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Sorting status - screen reader text
|
|
70
|
+
*/
|
|
71
|
+
var sortingScreenReaderText = (0, _react.useMemo)(function () {
|
|
72
|
+
var _sorting$columns2;
|
|
73
|
+
if (!isColumnSorted) return null;
|
|
74
|
+
if (!hasColumnActions && hasOnlyOneSort) return null; // in this scenario, the `aria-sort` attribute will be used by screen readers
|
|
75
|
+
return (0, _react2.jsx)("p", {
|
|
76
|
+
id: sortingAriaId,
|
|
77
|
+
hidden: true
|
|
78
|
+
}, sorting === null || sorting === void 0 || (_sorting$columns2 = sorting.columns) === null || _sorting$columns2 === void 0 ? void 0 : _sorting$columns2.map(function (_ref2, index) {
|
|
79
|
+
var columnId = _ref2.id,
|
|
80
|
+
direction = _ref2.direction;
|
|
81
|
+
if (hasOnlyOneSort) {
|
|
82
|
+
if (direction === 'asc') {
|
|
83
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
84
|
+
token: "euiDataGridHeaderCell.sortedByAscendingSingle",
|
|
85
|
+
default: "Sorted ascending",
|
|
86
|
+
key: index
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
90
|
+
token: "euiDataGridHeaderCell.sortedByDescendingSingle",
|
|
91
|
+
default: "Sorted descending",
|
|
92
|
+
key: index
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
} else if (index === 0) {
|
|
96
|
+
if (direction === 'asc') {
|
|
97
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
98
|
+
token: "euiDataGridHeaderCell.sortedByAscendingFirst",
|
|
99
|
+
default: "Sorted by {columnId}, ascending",
|
|
100
|
+
values: {
|
|
101
|
+
columnId: columnId
|
|
102
|
+
},
|
|
103
|
+
key: index
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
107
|
+
token: "euiDataGridHeaderCell.sortedByDescendingFirst",
|
|
108
|
+
default: "Sorted by {columnId}, descending",
|
|
109
|
+
values: {
|
|
110
|
+
columnId: columnId
|
|
111
|
+
},
|
|
112
|
+
key: index
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (direction === 'asc') {
|
|
117
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
118
|
+
token: "euiDataGridHeaderCell.sortedByAscendingMultiple",
|
|
119
|
+
default: ", then sorted by {columnId}, ascending",
|
|
120
|
+
values: {
|
|
121
|
+
columnId: columnId
|
|
122
|
+
},
|
|
123
|
+
key: index
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
return (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
127
|
+
token: "euiDataGridHeaderCell.sortedByDescendingMultiple",
|
|
128
|
+
default: ", then sorted by {columnId}, descending",
|
|
129
|
+
values: {
|
|
130
|
+
columnId: columnId
|
|
131
|
+
},
|
|
132
|
+
key: index
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}), ".");
|
|
137
|
+
}, [isColumnSorted, hasColumnActions, hasOnlyOneSort, sorting, sortingAriaId]);
|
|
138
|
+
return {
|
|
139
|
+
sortingArrow: sortingArrow,
|
|
140
|
+
ariaSort: ariaSort,
|
|
141
|
+
sortingAriaId: sortingAriaId,
|
|
142
|
+
sortingScreenReaderText: sortingScreenReaderText
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -25,7 +25,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
25
25
|
var EuiDataGridControlHeaderCell = exports.EuiDataGridControlHeaderCell = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
26
26
|
var controlColumn = _ref.controlColumn,
|
|
27
27
|
index = _ref.index,
|
|
28
|
-
|
|
28
|
+
isLastColumn = _ref.isLastColumn;
|
|
29
29
|
var HeaderCellRender = controlColumn.headerCellRender,
|
|
30
30
|
headerCellProps = controlColumn.headerCellProps,
|
|
31
31
|
width = controlColumn.width,
|
|
@@ -35,12 +35,12 @@ var EuiDataGridControlHeaderCell = exports.EuiDataGridControlHeaderCell = /*#__P
|
|
|
35
35
|
id: id,
|
|
36
36
|
index: index,
|
|
37
37
|
width: width,
|
|
38
|
-
|
|
38
|
+
isLastColumn: isLastColumn
|
|
39
39
|
}), (0, _react2.jsx)(HeaderCellRender, null));
|
|
40
40
|
});
|
|
41
41
|
EuiDataGridControlHeaderCell.propTypes = {
|
|
42
42
|
index: _propTypes.default.number.isRequired,
|
|
43
|
-
|
|
43
|
+
isLastColumn: _propTypes.default.bool.isRequired,
|
|
44
44
|
controlColumn: _propTypes.default.shape({
|
|
45
45
|
/**
|
|
46
46
|
* Used as the React `key` when rendering content
|