@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.
Files changed (161) hide show
  1. package/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  2. package/es/components/datagrid/body/cell/focus_utils.js +14 -4
  3. package/es/components/datagrid/body/data_grid_body.js +2 -1
  4. package/es/components/datagrid/body/data_grid_body_custom.js +5 -2
  5. package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  6. package/es/components/datagrid/body/header/column_actions.js +262 -27
  7. package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +10 -4
  8. package/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
  9. package/es/components/datagrid/body/header/column_sorting.js +134 -0
  10. package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  11. package/es/components/datagrid/body/header/data_grid_header_cell.js +86 -305
  12. package/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  13. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  14. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  15. package/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
  16. package/es/components/datagrid/body/header/draggable_columns.js +301 -0
  17. package/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
  18. package/es/components/datagrid/data_grid.js +2 -1
  19. package/es/components/datagrid/data_grid.stories.utils.js +9 -6
  20. package/es/components/datagrid/utils/col_widths.js +4 -6
  21. package/es/components/datagrid/utils/focus.js +2 -2
  22. package/es/components/datagrid/utils/scrolling.js +13 -10
  23. package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  24. package/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  25. package/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  26. package/es/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  27. package/es/components/drag_and_drop/draggable.js +13 -5
  28. package/es/components/header/header.styles.js +6 -12
  29. package/es/components/header/header_links/header_links.js +1 -1
  30. package/es/components/header/header_links/header_links.styles.js +1 -0
  31. package/es/components/page_template/inner/page_inner.styles.js +3 -4
  32. package/es/components/tabs/tab.js +1 -1
  33. package/eui.d.ts +417 -307
  34. package/i18ntokens.json +175 -175
  35. package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  36. package/lib/components/datagrid/body/cell/focus_utils.js +14 -4
  37. package/lib/components/datagrid/body/data_grid_body.js +2 -1
  38. package/lib/components/datagrid/body/data_grid_body_custom.js +5 -2
  39. package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  40. package/lib/components/datagrid/body/header/column_actions.js +265 -29
  41. package/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
  42. package/{optimize/lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
  43. package/lib/components/datagrid/body/header/column_sorting.js +144 -0
  44. package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  45. package/lib/components/datagrid/body/header/data_grid_header_cell.js +86 -305
  46. package/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  47. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  48. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  49. package/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
  50. package/lib/components/datagrid/body/header/draggable_columns.js +308 -0
  51. package/lib/components/datagrid/body/header/draggable_columns.styles.js +42 -0
  52. package/lib/components/datagrid/data_grid.js +2 -1
  53. package/lib/components/datagrid/data_grid.stories.utils.js +9 -6
  54. package/lib/components/datagrid/utils/col_widths.js +4 -6
  55. package/lib/components/datagrid/utils/focus.js +2 -2
  56. package/lib/components/datagrid/utils/scrolling.js +13 -10
  57. package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  58. package/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  59. package/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  60. package/lib/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  61. package/lib/components/drag_and_drop/draggable.js +13 -5
  62. package/lib/components/header/header.styles.js +6 -12
  63. package/lib/components/header/header_links/header_links.js +1 -1
  64. package/lib/components/header/header_links/header_links.styles.js +1 -0
  65. package/lib/components/page_template/inner/page_inner.styles.js +3 -4
  66. package/lib/components/tabs/tab.js +1 -1
  67. package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  68. package/optimize/es/components/datagrid/body/cell/focus_utils.js +13 -4
  69. package/optimize/es/components/datagrid/body/data_grid_body_custom.js +3 -1
  70. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +6 -3
  71. package/optimize/es/components/datagrid/body/header/column_actions.js +250 -26
  72. package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +8 -3
  73. package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
  74. package/optimize/es/components/datagrid/body/header/column_sorting.js +134 -0
  75. package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
  76. package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +82 -302
  77. package/optimize/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  78. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
  79. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  80. package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
  81. package/optimize/es/components/datagrid/body/header/draggable_columns.js +223 -0
  82. package/optimize/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
  83. package/optimize/es/components/datagrid/data_grid.js +2 -1
  84. package/optimize/es/components/datagrid/data_grid.stories.utils.js +7 -5
  85. package/optimize/es/components/datagrid/utils/col_widths.js +4 -6
  86. package/optimize/es/components/datagrid/utils/focus.js +2 -2
  87. package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
  88. package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
  89. package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
  90. package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
  91. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +11 -5
  92. package/optimize/es/components/drag_and_drop/draggable.js +8 -3
  93. package/optimize/es/components/header/header.styles.js +6 -12
  94. package/optimize/es/components/header/header_links/header_links.js +1 -1
  95. package/optimize/es/components/header/header_links/header_links.styles.js +1 -0
  96. package/optimize/es/components/page_template/inner/page_inner.styles.js +3 -4
  97. package/optimize/es/components/tabs/tab.js +1 -1
  98. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  99. package/optimize/lib/components/datagrid/body/cell/focus_utils.js +13 -4
  100. package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +3 -1
  101. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +6 -3
  102. package/optimize/lib/components/datagrid/body/header/column_actions.js +253 -27
  103. package/optimize/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +9 -4
  104. 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
  105. package/optimize/lib/components/datagrid/body/header/column_sorting.js +144 -0
  106. package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
  107. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +80 -300
  108. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  109. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
  110. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  111. package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
  112. package/optimize/lib/components/datagrid/body/header/draggable_columns.js +231 -0
  113. package/optimize/lib/components/datagrid/body/header/draggable_columns.styles.js +43 -0
  114. package/optimize/lib/components/datagrid/data_grid.js +2 -1
  115. package/optimize/lib/components/datagrid/data_grid.stories.utils.js +7 -5
  116. package/optimize/lib/components/datagrid/utils/col_widths.js +4 -6
  117. package/optimize/lib/components/datagrid/utils/focus.js +2 -2
  118. package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
  119. package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
  120. package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
  121. package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
  122. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +11 -5
  123. package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
  124. package/optimize/lib/components/header/header.styles.js +6 -12
  125. package/optimize/lib/components/header/header_links/header_links.js +1 -1
  126. package/optimize/lib/components/header/header_links/header_links.styles.js +1 -0
  127. package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
  128. package/optimize/lib/components/tabs/tab.js +1 -1
  129. package/package.json +1 -1
  130. package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  131. package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
  132. package/test-env/components/datagrid/body/data_grid_body.js +2 -1
  133. package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
  134. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  135. package/test-env/components/datagrid/body/header/column_actions.js +261 -27
  136. package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
  137. package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
  138. package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
  139. package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  140. package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
  141. package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  142. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  143. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  144. package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
  145. package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
  146. package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
  147. package/test-env/components/datagrid/data_grid.js +2 -1
  148. package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
  149. package/test-env/components/datagrid/utils/col_widths.js +4 -6
  150. package/test-env/components/datagrid/utils/focus.js +2 -2
  151. package/test-env/components/datagrid/utils/scrolling.js +13 -10
  152. package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  153. package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  154. package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  155. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  156. package/test-env/components/drag_and_drop/draggable.js +13 -5
  157. package/test-env/components/header/header.styles.js +6 -12
  158. package/test-env/components/header/header_links/header_links.js +1 -1
  159. package/test-env/components/header/header_links/header_links.styles.js +1 -0
  160. package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
  161. package/test-env/components/tabs/tab.js +1 -1
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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
+ };
@@ -23,7 +23,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
23
23
  var EuiDataGridControlHeaderCell = exports.EuiDataGridControlHeaderCell = /*#__PURE__*/(0, _react.memo)(function (_ref) {
24
24
  var controlColumn = _ref.controlColumn,
25
25
  index = _ref.index,
26
- visibleColCount = _ref.visibleColCount;
26
+ isLastColumn = _ref.isLastColumn;
27
27
  var HeaderCellRender = controlColumn.headerCellRender,
28
28
  headerCellProps = controlColumn.headerCellProps,
29
29
  width = controlColumn.width,
@@ -33,12 +33,12 @@ var EuiDataGridControlHeaderCell = exports.EuiDataGridControlHeaderCell = /*#__P
33
33
  id: id,
34
34
  index: index,
35
35
  width: width,
36
- visibleColCount: visibleColCount
36
+ isLastColumn: isLastColumn
37
37
  }), (0, _react2.jsx)(HeaderCellRender, null));
38
38
  });
39
39
  EuiDataGridControlHeaderCell.propTypes = {
40
40
  index: _propTypes.default.number.isRequired,
41
- visibleColCount: _propTypes.default.number.isRequired,
41
+ isLastColumn: _propTypes.default.bool.isRequired,
42
42
  controlColumn: _propTypes.default.shape({
43
43
  /**
44
44
  * Used as the React `key` when rendering content
@@ -1,39 +1,35 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.useSortingUtils = exports.usePopoverArrowNavigation = exports.EuiDataGridHeaderCell = void 0;
6
+ exports.EuiDataGridHeaderCell = void 0;
8
7
  var _classnames2 = _interopRequireDefault(require("classnames"));
9
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
9
  var _react = _interopRequireWildcard(require("react"));
11
- var _tabbable = require("tabbable");
12
10
  var _services = require("../../../../services");
13
- var _i18n = require("../../../i18n");
14
11
  var _icon = require("../../../icon");
15
- var _list_group = require("../../../list_group");
16
- var _popover = require("../../../popover");
17
- var _button = require("../../../button");
18
- var _focus = require("../../utils/focus");
19
12
  var _column_actions = require("./column_actions");
20
- var _data_grid_column_resizer = require("./data_grid_column_resizer");
13
+ var _column_sorting = require("./column_sorting");
14
+ var _draggable_columns = require("./draggable_columns");
15
+ var _column_resizer = require("./column_resizer");
21
16
  var _data_grid_header_cell_wrapper = require("./data_grid_header_cell_wrapper");
22
17
  var _data_grid_header_cell = require("./data_grid_header_cell.styles");
23
18
  var _react2 = require("@emotion/react");
24
19
  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); }
25
20
  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; }
26
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
27
23
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
28
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
29
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
30
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
24
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
32
25
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
26
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
34
27
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
35
28
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
36
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /*
29
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
30
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
32
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
37
33
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
38
34
  * or more contributor license agreements. Licensed under the Elastic License
39
35
  * 2.0 and the Server Side Public License, v 1; you may not use this file except
@@ -47,153 +43,103 @@ var EuiDataGridHeaderCell = exports.EuiDataGridHeaderCell = /*#__PURE__*/(0, _re
47
43
  columnWidths = _ref.columnWidths,
48
44
  defaultColumnWidth = _ref.defaultColumnWidth,
49
45
  setColumnWidth = _ref.setColumnWidth,
50
- visibleColCount = _ref.visibleColCount,
51
46
  setVisibleColumns = _ref.setVisibleColumns,
52
47
  switchColumnPos = _ref.switchColumnPos,
48
+ isLastColumn = _ref.isLastColumn,
53
49
  sorting = _ref.sorting,
54
50
  schema = _ref.schema,
55
- schemaDetectors = _ref.schemaDetectors;
51
+ schemaDetectors = _ref.schemaDetectors,
52
+ canDragAndDropColumns = _ref.canDragAndDropColumns,
53
+ gridStyles = _ref.gridStyles;
56
54
  var id = column.id,
57
55
  display = column.display,
58
56
  displayAsText = column.displayAsText,
59
- displayHeaderCellProps = column.displayHeaderCellProps;
57
+ displayHeaderCellProps = column.displayHeaderCellProps,
58
+ actions = column.actions;
60
59
  var title = displayAsText || id;
61
60
  var children = display || displayAsText || id;
62
61
  var width = columnWidths[id] || defaultColumnWidth;
63
62
  var columnType = schema[id] ? schema[id].columnType : null;
64
- var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
65
- setFocusedCell = _useContext.setFocusedCell,
66
- focusFirstVisibleInteractiveCell = _useContext.focusFirstVisibleInteractiveCell;
63
+ var hasColumnActions = (0, _column_actions.useHasColumnActions)(actions);
64
+ var classes = (0, _classnames2.default)(_defineProperty(_defineProperty({}, "euiDataGridHeaderCell--".concat(columnType), columnType), 'euiDataGridHeaderCell--hasColumnActions', hasColumnActions), displayHeaderCellProps === null || displayHeaderCellProps === void 0 ? void 0 : displayHeaderCellProps.className);
65
+ var styles = (0, _services.useEuiMemoizedStyles)(_data_grid_header_cell.euiDataGridHeaderCellStyles);
66
+ var contentStyles = [styles.euiDataGridHeaderCell__content, (columnType === 'numeric' || columnType === 'currency') && styles.right];
67
67
 
68
- /*
69
- * Column actions
70
- */
71
- var _useState = (0, _react.useState)(false),
68
+ // Props passed from <ColumnActions /> to be set on <EuiDataGridHeaderCellWrapper />
69
+ var _useState = (0, _react.useState)({}),
72
70
  _useState2 = _slicedToArray(_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
- return setIsPopoverOpen(false);
82
- }, []);
83
- var popoverArrowNavigationProps = usePopoverArrowNavigation();
84
- var columnActions = (0, _react.useMemo)(function () {
85
- return (0, _column_actions.getColumnActions)({
86
- column: column,
87
- columns: columns,
88
- schema: schema,
89
- schemaDetectors: schemaDetectors,
90
- setVisibleColumns: setVisibleColumns,
91
- focusFirstVisibleInteractiveCell: focusFirstVisibleInteractiveCell,
92
- setIsPopoverOpen: setIsPopoverOpen,
93
- sorting: sorting,
94
- switchColumnPos: switchColumnPos,
95
- setFocusedCell: setFocusedCell,
96
- columnFocusIndex: index
97
- });
98
- }, [column, columns, schema, schemaDetectors, setVisibleColumns, focusFirstVisibleInteractiveCell, setIsPopoverOpen, sorting, switchColumnPos, setFocusedCell, index]);
99
- var showColumnActions = columnActions && columnActions.length > 0;
71
+ propsFromColumnActions = _useState2[0],
72
+ setPropsFromColumnActions = _useState2[1];
100
73
  var actionsButtonRef = (0, _react.useRef)(null);
101
- var clickActionsButton = (0, _react.useCallback)(function () {
102
- var _actionsButtonRef$cur;
103
- (_actionsButtonRef$cur = actionsButtonRef.current) === null || _actionsButtonRef$cur === void 0 || _actionsButtonRef$cur.click();
104
- }, []);
105
- var _useState3 = (0, _react.useState)(false),
106
- _useState4 = _slicedToArray(_useState3, 2),
107
- isActionsButtonFocused = _useState4[0],
108
- setIsActionsButtonFocused = _useState4[1];
109
- var actionsButtonAriaLabel = (0, _i18n.useEuiI18n)('euiDataGridHeaderCell.actionsButtonAriaLabel', '{title}. Click to view column header actions.', {
110
- title: title
111
- });
112
- var actionsEnterKeyInstructions = (0, _i18n.useEuiI18n)('euiDataGridHeaderCell.actionsEnterKeyInstructions', "Press the Enter key to view this column's actions");
113
-
114
- /*
115
- * Column sorting
116
- */
117
- var _useSortingUtils = useSortingUtils({
74
+ var _useColumnSorting = (0, _column_sorting.useColumnSorting)({
118
75
  sorting: sorting,
119
76
  id: id,
120
- showColumnActions: showColumnActions
77
+ hasColumnActions: hasColumnActions
121
78
  }),
122
- sortingArrow = _useSortingUtils.sortingArrow,
123
- ariaSort = _useSortingUtils.ariaSort,
124
- sortingScreenReaderText = _useSortingUtils.sortingScreenReaderText;
125
- var sortingAriaId = (0, _services.useGeneratedHtmlId)({
126
- prefix: 'euiDataGridCellHeader',
127
- suffix: 'sorting'
128
- });
129
-
130
- /*
131
- * Rendering
132
- */
133
- var classes = (0, _classnames2.default)(_defineProperty(_defineProperty(_defineProperty({}, "euiDataGridHeaderCell--".concat(columnType), columnType), 'euiDataGridHeaderCell--hasColumnActions', showColumnActions), 'euiDataGridHeaderCell--isActionsPopoverOpen', isPopoverOpen), displayHeaderCellProps === null || displayHeaderCellProps === void 0 ? void 0 : displayHeaderCellProps.className);
134
- var styles = (0, _services.useEuiMemoizedStyles)(_data_grid_header_cell.euiDataGridHeaderCellStyles);
135
- var contentStyles = [styles.euiDataGridHeaderCell__content, (columnType === 'numeric' || columnType === 'currency') && styles.right];
136
- return (0, _react2.jsx)(_data_grid_header_cell_wrapper.EuiDataGridHeaderCellWrapper, _extends({}, displayHeaderCellProps, {
137
- className: classes,
138
- id: id,
139
- index: index,
140
- visibleColCount: visibleColCount,
141
- width: width,
142
- "aria-sort": ariaSort,
143
- hasActionsPopover: showColumnActions,
144
- openActionsPopover: clickActionsButton,
145
- "aria-label": displayAsText && "".concat(displayAsText, ", ") // ensure cell text content is read first, if available
146
- ,
147
- "aria-describedby": sortingAriaId
148
- }), function (hasFocusTrap) {
149
- return (0, _react2.jsx)(_react.default.Fragment, null, column.isResizable !== false && width != null ? (0, _react2.jsx)(_data_grid_column_resizer.EuiDataGridColumnResizer, {
79
+ sortingArrow = _useColumnSorting.sortingArrow,
80
+ ariaSort = _useColumnSorting.ariaSort,
81
+ sortingAriaId = _useColumnSorting.sortingAriaId,
82
+ sortingScreenReaderText = _useColumnSorting.sortingScreenReaderText;
83
+ var columnResizer = (0, _react.useMemo)(function () {
84
+ return column.isResizable !== false && width != null ? (0, _react2.jsx)(_column_resizer.EuiDataGridColumnResizer, {
150
85
  columnId: id,
151
86
  columnWidth: width,
152
- setColumnWidth: setColumnWidth
153
- }) : null, (0, _react2.jsx)("div", {
154
- css: contentStyles,
155
- className: "euiDataGridHeaderCell__content",
156
- title: title
157
- }, children), sortingArrow, sortingScreenReaderText && (0, _react2.jsx)("p", {
158
- id: sortingAriaId,
159
- hidden: true
160
- }, sortingScreenReaderText), showColumnActions && (0, _react2.jsx)(_popover.EuiPopover, _extends({
161
- display: "block",
162
- panelPaddingSize: "none",
163
- offset: 7,
164
- anchorPosition: "downRight",
165
- css: styles.euiDataGridHeaderCell__popover,
166
- button: (0, _react2.jsx)(_button.EuiButtonIcon, {
167
- iconType: "boxesVertical",
168
- iconSize: "s",
169
- color: "text",
170
- css: styles.euiDataGridHeaderCell__button,
171
- className: "euiDataGridHeaderCell__button",
172
- buttonRef: actionsButtonRef,
173
- onClick: togglePopover,
174
- onFocus: function onFocus() {
175
- return setIsActionsButtonFocused(true);
176
- },
177
- onBlur: function onBlur() {
178
- return setIsActionsButtonFocused(false);
179
- },
180
- tabIndex: 0 // Override EuiButtonIcon's conditional tabindex based on aria-hidden
181
- ,
182
- "aria-hidden": hasFocusTrap && !isActionsButtonFocused ? 'true' // prevent the actions button from being read on cell focus
183
- : undefined,
184
- "aria-label": hasFocusTrap ? actionsButtonAriaLabel : actionsEnterKeyInstructions,
185
- "data-test-subj": "dataGridHeaderCellActionButton-".concat(id)
186
- }),
187
- isOpen: isPopoverOpen,
188
- closePopover: closePopover
189
- }, popoverArrowNavigationProps), (0, _react2.jsx)(_list_group.EuiListGroup, {
190
- listItems: columnActions,
191
- gutterSize: "none",
192
- "data-test-subj": "dataGridHeaderCellActionGroup-".concat(id)
193
- })));
87
+ setColumnWidth: setColumnWidth,
88
+ isLastColumn: isLastColumn
89
+ }) : null;
90
+ }, [column.isResizable, id, width, setColumnWidth, isLastColumn]);
91
+ return (0, _react2.jsx)(_draggable_columns.ConditionalDraggableColumn, {
92
+ id: id,
93
+ index: index,
94
+ canDragAndDropColumns: !!canDragAndDropColumns,
95
+ gridStyles: gridStyles,
96
+ columnResizer: columnResizer,
97
+ actionsPopoverToggle: actionsButtonRef.current
98
+ }, function (dragProps) {
99
+ return (0, _react2.jsx)(_data_grid_header_cell_wrapper.EuiDataGridHeaderCellWrapper, _extends({}, displayHeaderCellProps, dragProps, {
100
+ hasColumnActions: hasColumnActions
101
+ }, propsFromColumnActions, {
102
+ className: (0, _classnames2.default)(classes, propsFromColumnActions.className),
103
+ id: id,
104
+ index: index,
105
+ isLastColumn: isLastColumn,
106
+ width: width,
107
+ "aria-sort": ariaSort,
108
+ "aria-label": displayAsText && "".concat(displayAsText, ", ") // ensure cell text content is read first, if available
109
+ ,
110
+ "aria-describedby": (0, _classnames2.default)(sortingAriaId, dragProps === null || dragProps === void 0 ? void 0 : dragProps['aria-describedby']),
111
+ "data-column-moving": propsFromColumnActions['data-column-moving'] || (dragProps === null || dragProps === void 0 ? void 0 : dragProps['data-column-moving']) || undefined
112
+ }), function (hasFocusTrap) {
113
+ return (0, _react2.jsx)(_react.default.Fragment, null, !canDragAndDropColumns && columnResizer, canDragAndDropColumns && (0, _react2.jsx)("span", {
114
+ className: "euiDataGridHeaderCell__draggableIcon"
115
+ }, (0, _react2.jsx)(_icon.EuiIcon, {
116
+ type: "grabOmnidirectional",
117
+ size: "s",
118
+ css: styles.euiDataGridHeaderCell__actions
119
+ })), (0, _react2.jsx)("div", {
120
+ css: contentStyles,
121
+ className: "euiDataGridHeaderCell__content",
122
+ title: title
123
+ }, children), sortingArrow, sortingScreenReaderText, hasColumnActions && (0, _react2.jsx)(_column_actions.ColumnActions, {
124
+ index: index,
125
+ id: id,
126
+ title: title,
127
+ column: column,
128
+ columns: columns,
129
+ schema: schema,
130
+ schemaDetectors: schemaDetectors,
131
+ setVisibleColumns: setVisibleColumns,
132
+ switchColumnPos: switchColumnPos,
133
+ sorting: sorting,
134
+ hasFocusTrap: hasFocusTrap,
135
+ setPropsFromColumnActions: setPropsFromColumnActions,
136
+ actionsButtonRef: actionsButtonRef
137
+ }));
138
+ });
194
139
  });
195
140
  });
196
141
  EuiDataGridHeaderCell.propTypes = {
142
+ index: _propTypes.default.number.isRequired,
197
143
  column: _propTypes.default.shape({
198
144
  /**
199
145
  * The unique identifier for this column
@@ -590,171 +536,6 @@ EuiDataGridHeaderCell.propTypes = {
590
536
  */
591
537
  visibleCellActions: _propTypes.default.number
592
538
  }).isRequired,
593
- index: _propTypes.default.number.isRequired
539
+ isLastColumn: _propTypes.default.bool.isRequired
594
540
  };
595
- EuiDataGridHeaderCell.displayName = 'EuiDataGridHeaderCell';
596
-
597
- /**
598
- * Column sorting utility helpers
599
- */
600
- var useSortingUtils = exports.useSortingUtils = function useSortingUtils(_ref2) {
601
- var _sorting$columns;
602
- var sorting = _ref2.sorting,
603
- id = _ref2.id,
604
- showColumnActions = _ref2.showColumnActions;
605
- var sortedColumn = (0, _react.useMemo)(function () {
606
- return sorting === null || sorting === void 0 ? void 0 : sorting.columns.find(function (col) {
607
- return col.id === id;
608
- });
609
- }, [sorting, id]);
610
- var isColumnSorted = !!sortedColumn;
611
- var hasOnlyOneSort = (sorting === null || sorting === void 0 || (_sorting$columns = sorting.columns) === null || _sorting$columns === void 0 ? void 0 : _sorting$columns.length) === 1;
612
-
613
- /**
614
- * Arrow icon
615
- */
616
- var sortingArrow = (0, _react.useMemo)(function () {
617
- return isColumnSorted ? (0, _react2.jsx)(_icon.EuiIcon, {
618
- type: sortedColumn.direction === 'asc' ? 'sortUp' : 'sortDown',
619
- color: "text",
620
- className: "euiDataGridHeaderCell__sortingArrow",
621
- "data-test-subj": "dataGridHeaderCellSortingIcon-".concat(id)
622
- }) : null;
623
- }, [id, isColumnSorted, sortedColumn]);
624
-
625
- /**
626
- * aria-sort attribute - should only be used when a single column is being sorted
627
- * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort
628
- * @see https://www.w3.org/WAI/ARIA/apg/example-index/table/sortable-table.html
629
- * @see https://github.com/w3c/aria/issues/283 for potential future multi-column usage
630
- */
631
- var ariaSort = isColumnSorted && hasOnlyOneSort ? sorting.columns[0].direction === 'asc' ? 'ascending' : 'descending' : undefined;
632
-
633
- /**
634
- * Sorting status - screen reader text
635
- */
636
- var sortingScreenReaderText = (0, _react.useMemo)(function () {
637
- var _sorting$columns2;
638
- if (!isColumnSorted) return null;
639
- if (!showColumnActions && hasOnlyOneSort) return null; // in this scenario, the `aria-sort` attribute will be used by screen readers
640
- return (0, _react2.jsx)(_react.default.Fragment, null, sorting === null || sorting === void 0 || (_sorting$columns2 = sorting.columns) === null || _sorting$columns2 === void 0 ? void 0 : _sorting$columns2.map(function (_ref3, index) {
641
- var columnId = _ref3.id,
642
- direction = _ref3.direction;
643
- if (hasOnlyOneSort) {
644
- if (direction === 'asc') {
645
- return (0, _react2.jsx)(_i18n.EuiI18n, {
646
- token: "euiDataGridHeaderCell.sortedByAscendingSingle",
647
- default: "Sorted ascending",
648
- key: index
649
- });
650
- } else {
651
- return (0, _react2.jsx)(_i18n.EuiI18n, {
652
- token: "euiDataGridHeaderCell.sortedByDescendingSingle",
653
- default: "Sorted descending",
654
- key: index
655
- });
656
- }
657
- } else if (index === 0) {
658
- if (direction === 'asc') {
659
- return (0, _react2.jsx)(_i18n.EuiI18n, {
660
- token: "euiDataGridHeaderCell.sortedByAscendingFirst",
661
- default: "Sorted by {columnId}, ascending",
662
- values: {
663
- columnId: columnId
664
- },
665
- key: index
666
- });
667
- } else {
668
- return (0, _react2.jsx)(_i18n.EuiI18n, {
669
- token: "euiDataGridHeaderCell.sortedByDescendingFirst",
670
- default: "Sorted by {columnId}, descending",
671
- values: {
672
- columnId: columnId
673
- },
674
- key: index
675
- });
676
- }
677
- } else {
678
- if (direction === 'asc') {
679
- return (0, _react2.jsx)(_i18n.EuiI18n, {
680
- token: "euiDataGridHeaderCell.sortedByAscendingMultiple",
681
- default: ", then sorted by {columnId}, ascending",
682
- values: {
683
- columnId: columnId
684
- },
685
- key: index
686
- });
687
- } else {
688
- return (0, _react2.jsx)(_i18n.EuiI18n, {
689
- token: "euiDataGridHeaderCell.sortedByDescendingMultiple",
690
- default: ", then sorted by {columnId}, descending",
691
- values: {
692
- columnId: columnId
693
- },
694
- key: index
695
- });
696
- }
697
- }
698
- }), ".");
699
- }, [isColumnSorted, showColumnActions, hasOnlyOneSort, sorting]);
700
- return {
701
- sortingArrow: sortingArrow,
702
- ariaSort: ariaSort,
703
- sortingScreenReaderText: sortingScreenReaderText
704
- };
705
- };
706
-
707
- /**
708
- * Add keyboard arrow navigation to the cell actions popover
709
- * to match the UX of the rest of EuiDataGrid
710
- */
711
- var usePopoverArrowNavigation = exports.usePopoverArrowNavigation = function usePopoverArrowNavigation() {
712
- var popoverPanelRef = (0, _react.useRef)(null);
713
- var actionsRef = (0, _react.useRef)(undefined);
714
- var panelRef = (0, _react.useCallback)(function (ref) {
715
- popoverPanelRef.current = ref;
716
- actionsRef.current = ref ? (0, _tabbable.tabbable)(ref) : undefined;
717
- }, []);
718
- var onKeyDown = (0, _react.useCallback)(function (e) {
719
- var _actionsRef$current;
720
- if (e.key !== _services.keys.ARROW_DOWN && e.key !== _services.keys.ARROW_UP) return;
721
- if (!((_actionsRef$current = actionsRef.current) !== null && _actionsRef$current !== void 0 && _actionsRef$current.length)) return;
722
- e.preventDefault();
723
- var initialState = document.activeElement === popoverPanelRef.current;
724
- var currentIndex = !initialState ? actionsRef.current.findIndex(function (el) {
725
- return document.activeElement === el;
726
- }) : -1;
727
- var lastIndex = actionsRef.current.length - 1;
728
- var indexToFocus;
729
- if (initialState) {
730
- if (e.key === _services.keys.ARROW_DOWN) {
731
- indexToFocus = 0;
732
- } else if (e.key === _services.keys.ARROW_UP) {
733
- indexToFocus = lastIndex;
734
- }
735
- } else {
736
- if (e.key === _services.keys.ARROW_DOWN) {
737
- indexToFocus = currentIndex + 1;
738
- if (indexToFocus > lastIndex) {
739
- indexToFocus = 0;
740
- }
741
- } else if (e.key === _services.keys.ARROW_UP) {
742
- indexToFocus = currentIndex - 1;
743
- if (indexToFocus < 0) {
744
- indexToFocus = lastIndex;
745
- }
746
- }
747
- }
748
- actionsRef.current[indexToFocus].focus();
749
- }, []);
750
- return {
751
- panelRef: panelRef,
752
- panelProps: {
753
- onKeyDown: onKeyDown
754
- },
755
- popoverScreenReaderText: (0, _react2.jsx)(_i18n.EuiI18n, {
756
- token: "euiDataGridHeaderCell.actionsPopoverScreenReaderText",
757
- default: "To navigate through the list of column actions, press the Tab or Up and Down arrow keys."
758
- })
759
- };
760
- };
541
+ EuiDataGridHeaderCell.displayName = 'EuiDataGridHeaderCell';
@@ -27,6 +27,6 @@ var euiDataGridHeaderCellStyles = exports.euiDataGridHeaderCellStyles = function
27
27
  // Numeric and currency schemas are aligned to the right
28
28
  right: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalTextAlignCSS)('right'), ";;label:right;"),
29
29
  euiDataGridHeaderCell__popover: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('margin-left', 'auto'), "line-height:0;;label:euiDataGridHeaderCell__popover;"),
30
- euiDataGridHeaderCell__button: /*#__PURE__*/(0, _react.css)("overflow:hidden;", header.hideActions, " &{", (0, _global_styling.logicalCSS)('width', 0), " opacity:0;}", _global_styling.euiCanAnimate, "{transition:inline-size ", euiTheme.animation.fast, " ease-in,opacity ", euiTheme.animation.slow, " ease-in;transform:none!important;animation:none!important;};label:euiDataGridHeaderCell__button;")
30
+ euiDataGridHeaderCell__actions: /*#__PURE__*/(0, _react.css)("overflow:hidden;display:flex;", header.hideActions, " &{", (0, _global_styling.logicalCSS)('width', 0), " opacity:0;}", _global_styling.euiCanAnimate, "{transition:inline-size ", euiTheme.animation.fast, " ease-in,opacity ", euiTheme.animation.slow, " ease-in;transform:none!important;animation:none!important;};label:euiDataGridHeaderCell__actions;")
31
31
  };
32
32
  };