@elastic/eui 97.0.0-backport.0 → 97.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/es/components/datagrid/body/cell/focus_utils.js +14 -4
- package/es/components/datagrid/body/data_grid_body.js +2 -1
- package/es/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/es/components/datagrid/body/header/column_actions.js +262 -27
- package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +10 -4
- package/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/es/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/es/components/datagrid/body/header/draggable_columns.js +301 -0
- package/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/es/components/datagrid/data_grid.js +2 -1
- package/es/components/datagrid/data_grid.stories.utils.js +9 -6
- package/es/components/datagrid/utils/col_widths.js +17 -13
- package/es/components/datagrid/utils/focus.js +2 -2
- package/es/components/datagrid/utils/scrolling.js +13 -10
- package/es/components/drag_and_drop/draggable.js +13 -5
- package/es/components/header/header.styles.js +6 -12
- package/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/es/components/tabs/tab.js +1 -1
- package/eui.d.ts +406 -311
- package/i18ntokens.json +123 -123
- package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/lib/components/datagrid/body/cell/focus_utils.js +14 -4
- package/lib/components/datagrid/body/data_grid_body.js +2 -1
- package/lib/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/lib/components/datagrid/body/header/column_actions.js +265 -29
- package/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{optimize/lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/lib/components/datagrid/body/header/draggable_columns.js +308 -0
- package/lib/components/datagrid/body/header/draggable_columns.styles.js +42 -0
- package/lib/components/datagrid/data_grid.js +2 -1
- package/lib/components/datagrid/data_grid.stories.utils.js +9 -6
- package/lib/components/datagrid/utils/col_widths.js +17 -13
- package/lib/components/datagrid/utils/focus.js +2 -2
- package/lib/components/datagrid/utils/scrolling.js +13 -10
- package/lib/components/drag_and_drop/draggable.js +13 -5
- package/lib/components/header/header.styles.js +6 -12
- package/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/lib/components/tabs/tab.js +1 -1
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/es/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/es/components/datagrid/body/header/column_actions.js +250 -26
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +8 -3
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/optimize/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +82 -302
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/optimize/es/components/datagrid/body/header/draggable_columns.js +223 -0
- package/optimize/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/optimize/es/components/datagrid/data_grid.js +2 -1
- package/optimize/es/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/es/components/datagrid/utils/col_widths.js +17 -13
- package/optimize/es/components/datagrid/utils/focus.js +2 -2
- package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/es/components/drag_and_drop/draggable.js +8 -3
- package/optimize/es/components/header/header.styles.js +6 -12
- package/optimize/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/es/components/tabs/tab.js +1 -1
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/lib/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/lib/components/datagrid/body/header/column_actions.js +253 -27
- package/optimize/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +9 -4
- package/{test-env/components/datagrid/body/header/data_grid_column_resizer.styles.js → optimize/lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/optimize/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +80 -300
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/optimize/lib/components/datagrid/body/header/draggable_columns.js +231 -0
- package/optimize/lib/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/optimize/lib/components/datagrid/data_grid.js +2 -1
- package/optimize/lib/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/lib/components/datagrid/utils/col_widths.js +17 -13
- package/optimize/lib/components/datagrid/utils/focus.js +2 -2
- package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
- package/optimize/lib/components/header/header.styles.js +6 -12
- package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/lib/components/tabs/tab.js +1 -1
- package/package.json +2 -3
- package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
- package/test-env/components/datagrid/body/data_grid_body.js +2 -1
- package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/test-env/components/datagrid/body/header/column_actions.js +261 -27
- package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
- package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
- package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/test-env/components/datagrid/data_grid.js +2 -1
- package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
- package/test-env/components/datagrid/utils/col_widths.js +17 -13
- package/test-env/components/datagrid/utils/focus.js +2 -2
- package/test-env/components/datagrid/utils/scrolling.js +13 -10
- package/test-env/components/drag_and_drop/draggable.js +13 -5
- package/test-env/components/header/header.styles.js +6 -12
- package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
- package/test-env/components/tabs/tab.js +1 -1
|
@@ -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.
|
|
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
|
|
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
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
|
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
|
-
|
|
77
|
+
hasColumnActions: hasColumnActions
|
|
121
78
|
}),
|
|
122
|
-
sortingArrow =
|
|
123
|
-
ariaSort =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
,
|
|
182
|
-
"
|
|
183
|
-
:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
};
|
|
@@ -13,7 +13,7 @@ var _focus = require("../../utils/focus");
|
|
|
13
13
|
var _focus_utils = require("../cell/focus_utils");
|
|
14
14
|
var _data_grid_header_cell_wrapper = require("./data_grid_header_cell_wrapper.styles");
|
|
15
15
|
var _react2 = require("@emotion/react");
|
|
16
|
-
var _excluded = ["id", "index", "
|
|
16
|
+
var _excluded = ["id", "index", "isLastColumn", "width", "className", "children", "hasColumnActions", "isDragging", "onKeyDown", "aria-label"];
|
|
17
17
|
/*
|
|
18
18
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
19
19
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -41,12 +41,13 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
41
41
|
var EuiDataGridHeaderCellWrapper = exports.EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(_ref) {
|
|
42
42
|
var id = _ref.id,
|
|
43
43
|
index = _ref.index,
|
|
44
|
-
|
|
44
|
+
isLastColumn = _ref.isLastColumn,
|
|
45
45
|
width = _ref.width,
|
|
46
46
|
className = _ref.className,
|
|
47
47
|
children = _ref.children,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
hasColumnActions = _ref.hasColumnActions,
|
|
49
|
+
isDragging = _ref.isDragging,
|
|
50
|
+
_onKeyDown = _ref.onKeyDown,
|
|
50
51
|
ariaLabel = _ref['aria-label'],
|
|
51
52
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
53
|
var classes = (0, _classnames.default)('euiDataGridHeaderCell', className);
|
|
@@ -67,8 +68,8 @@ var EuiDataGridHeaderCellWrapper = exports.EuiDataGridHeaderCellWrapper = functi
|
|
|
67
68
|
setInteractiveChildren = _useState6[1];
|
|
68
69
|
(0, _react.useEffect)(function () {
|
|
69
70
|
// We're checking for interactive children outside of the default actions button
|
|
70
|
-
setRenderFocusTrap(interactiveChildren.length > (
|
|
71
|
-
}, [
|
|
71
|
+
setRenderFocusTrap(interactiveChildren.length > (hasColumnActions ? 1 : 0));
|
|
72
|
+
}, [hasColumnActions, interactiveChildren]);
|
|
72
73
|
var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
73
74
|
setFocusedCell = _useContext.setFocusedCell,
|
|
74
75
|
onFocusUpdate = _useContext.onFocusUpdate;
|
|
@@ -90,14 +91,14 @@ var EuiDataGridHeaderCellWrapper = exports.EuiDataGridHeaderCellWrapper = functi
|
|
|
90
91
|
}
|
|
91
92
|
});
|
|
92
93
|
}, [index, onFocusUpdate, headerEl]);
|
|
93
|
-
|
|
94
|
-
// For cell headers with only actions, auto-open the actions popover on enter keypress
|
|
95
94
|
var onKeyDown = (0, _react.useCallback)(function (e) {
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
// Ignore keys that conflict with the focus trap being entered/exited
|
|
96
|
+
if (renderFocusTrap && (e.key === _services.keys.ENTER || e.key === _services.keys.ESCAPE)) {
|
|
97
|
+
return;
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
// Otherwise, continue with whatever onKeyDown is being passed
|
|
100
|
+
_onKeyDown === null || _onKeyDown === void 0 || _onKeyDown(e);
|
|
101
|
+
}, [_onKeyDown, renderFocusTrap]);
|
|
101
102
|
return (0, _react2.jsx)("div", _extends({
|
|
102
103
|
role: "columnheader",
|
|
103
104
|
ref: setHeaderEl,
|
|
@@ -115,9 +116,9 @@ var EuiDataGridHeaderCellWrapper = exports.EuiDataGridHeaderCellWrapper = functi
|
|
|
115
116
|
} : {},
|
|
116
117
|
"aria-label": renderFocusTrap ? ariaLabel : undefined
|
|
117
118
|
}, rest), (0, _react2.jsx)(_focus_utils.HandleInteractiveChildren, {
|
|
118
|
-
cellEl: headerEl,
|
|
119
|
+
cellEl: isDragging ? null : headerEl,
|
|
120
|
+
renderFocusTrap: isDragging ? false : renderFocusTrap,
|
|
119
121
|
updateCellFocusContext: updateCellFocusContext,
|
|
120
|
-
renderFocusTrap: renderFocusTrap,
|
|
121
122
|
onInteractiveChildrenFound: setInteractiveChildren
|
|
122
123
|
}, typeof children === 'function' ? children(renderFocusTrap) : children), isLastColumn ? _services.tabularCopyMarkers.hiddenNewline : _services.tabularCopyMarkers.hiddenTab);
|
|
123
124
|
};
|
|
@@ -125,10 +126,11 @@ EuiDataGridHeaderCellWrapper.propTypes = {
|
|
|
125
126
|
children: _propTypes.default.oneOfType([_propTypes.default.node.isRequired, _propTypes.default.func.isRequired]).isRequired,
|
|
126
127
|
id: _propTypes.default.string.isRequired,
|
|
127
128
|
index: _propTypes.default.number.isRequired,
|
|
128
|
-
|
|
129
|
+
isLastColumn: _propTypes.default.bool.isRequired,
|
|
129
130
|
width: _propTypes.default.oneOfType([_propTypes.default.number.isRequired, _propTypes.default.oneOf([null])]),
|
|
130
131
|
className: _propTypes.default.string,
|
|
131
132
|
"aria-label": _propTypes.default.any,
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
hasColumnActions: _propTypes.default.bool,
|
|
134
|
+
isDragging: _propTypes.default.bool,
|
|
135
|
+
onKeyDown: _propTypes.default.any
|
|
134
136
|
};
|
|
@@ -25,8 +25,7 @@ var euiDataGridHeaderCellWrapperStyles = exports.euiDataGridHeaderCellWrapperSty
|
|
|
25
25
|
hoverStyles = _euiDataGridCellOutli.hoverStyles;
|
|
26
26
|
var _euiDataGridCellOutli2 = (0, _data_grid_cell.euiDataGridCellOutlineSelectors)(),
|
|
27
27
|
outlineSelectors = _euiDataGridCellOutli2.header;
|
|
28
|
-
var _sharedFlexCss = /*#__PURE__*/(0, _react.css)("display:flex;align-items:center;gap:", euiTheme.size.xxs, ";");
|
|
29
28
|
return {
|
|
30
|
-
euiDataGridHeaderCell: /*#__PURE__*/(0, _react.css)("position:relative;
|
|
29
|
+
euiDataGridHeaderCell: /*#__PURE__*/(0, _react.css)("position:relative;display:flex;align-items:center;flex:0 0 auto;font-weight:", euiTheme.font.weight.bold, ";", outlineSelectors.focus, "{", focusStyles, ";}", outlineSelectors.focusTrapped, "{", hoverStyles, ";}", outlineSelectors.showActions, "{&,&>[data-focus-lock-disabled]{gap:", euiTheme.size.xxs, ";}}&>[data-focus-lock-disabled]{display:flex;align-items:center;", (0, _global_styling.logicalCSS)('width', '100%'), ";};label:euiDataGridHeaderCell;")
|
|
31
30
|
};
|
|
32
31
|
};
|
|
@@ -9,11 +9,12 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _services = require("../../../../services");
|
|
11
11
|
var _data_grid_types = require("../../data_grid_types");
|
|
12
|
+
var _draggable_columns = require("./draggable_columns");
|
|
12
13
|
var _data_grid_control_header_cell = require("./data_grid_control_header_cell");
|
|
13
14
|
var _data_grid_header_cell = require("./data_grid_header_cell");
|
|
14
15
|
var _data_grid_header_row = require("./data_grid_header_row.styles");
|
|
15
16
|
var _react2 = require("@emotion/react");
|
|
16
|
-
var _excluded = ["className", "data-test-subj", "leadingControlColumns", "trailingControlColumns", "columns", "columnWidths", "defaultColumnWidth", "setColumnWidth", "visibleColCount", "setVisibleColumns", "switchColumnPos", "sorting", "schema", "schemaDetectors", "gridStyles"];
|
|
17
|
+
var _excluded = ["className", "data-test-subj", "leadingControlColumns", "trailingControlColumns", "columns", "columnWidths", "defaultColumnWidth", "setColumnWidth", "visibleColCount", "setVisibleColumns", "switchColumnPos", "sorting", "schema", "schemaDetectors", "gridStyles", "canDragAndDropColumns"];
|
|
17
18
|
/*
|
|
18
19
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
19
20
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -28,6 +29,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
28
29
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
29
30
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
30
31
|
var EuiDataGridHeaderRow = exports.EuiDataGridHeaderRow = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
32
|
+
var _leadingControlColumn;
|
|
31
33
|
var className = props.className,
|
|
32
34
|
_dataTestSubj = props['data-test-subj'],
|
|
33
35
|
_props$leadingControl = props.leadingControlColumns,
|
|
@@ -45,11 +47,15 @@ var EuiDataGridHeaderRow = exports.EuiDataGridHeaderRow = /*#__PURE__*/(0, _reac
|
|
|
45
47
|
schema = props.schema,
|
|
46
48
|
schemaDetectors = props.schemaDetectors,
|
|
47
49
|
gridStyles = props.gridStyles,
|
|
50
|
+
canDragAndDropColumns = props.canDragAndDropColumns,
|
|
48
51
|
rest = _objectWithoutProperties(props, _excluded);
|
|
49
52
|
var styles = (0, _services.useEuiMemoizedStyles)(_data_grid_header_row.euiDataGridHeaderStyles);
|
|
50
53
|
var cssStyles = [styles.euiDataGridHeader, styles[gridStyles.header]];
|
|
51
54
|
var classes = (0, _classnames.default)('euiDataGridHeader', className);
|
|
52
55
|
var dataTestSubj = (0, _classnames.default)('dataGridHeader', _dataTestSubj);
|
|
56
|
+
var isLastColumn = (0, _react.useCallback)(function (index) {
|
|
57
|
+
return index === visibleColCount - 1;
|
|
58
|
+
}, [visibleColCount]);
|
|
53
59
|
return (0, _react2.jsx)("div", _extends({
|
|
54
60
|
role: "row",
|
|
55
61
|
ref: ref,
|
|
@@ -60,30 +66,39 @@ var EuiDataGridHeaderRow = exports.EuiDataGridHeaderRow = /*#__PURE__*/(0, _reac
|
|
|
60
66
|
return (0, _react2.jsx)(_data_grid_control_header_cell.EuiDataGridControlHeaderCell, {
|
|
61
67
|
key: controlColumn.id,
|
|
62
68
|
index: index,
|
|
63
|
-
|
|
69
|
+
isLastColumn: isLastColumn(index),
|
|
64
70
|
controlColumn: controlColumn
|
|
65
71
|
});
|
|
66
|
-
}),
|
|
72
|
+
}), (0, _react2.jsx)(_draggable_columns.ConditionalDroppableColumns, {
|
|
73
|
+
canDragAndDropColumns: !!canDragAndDropColumns,
|
|
74
|
+
columns: columns,
|
|
75
|
+
switchColumnPos: switchColumnPos,
|
|
76
|
+
indexOffset: (_leadingControlColumn = leadingControlColumns === null || leadingControlColumns === void 0 ? void 0 : leadingControlColumns.length) !== null && _leadingControlColumn !== void 0 ? _leadingControlColumn : 0
|
|
77
|
+
}, columns.map(function (column, index) {
|
|
78
|
+
var visibleIndex = index + leadingControlColumns.length;
|
|
67
79
|
return (0, _react2.jsx)(_data_grid_header_cell.EuiDataGridHeaderCell, {
|
|
68
80
|
key: column.id,
|
|
69
|
-
index:
|
|
81
|
+
index: visibleIndex,
|
|
82
|
+
isLastColumn: isLastColumn(visibleIndex),
|
|
70
83
|
column: column,
|
|
71
84
|
columns: columns,
|
|
72
85
|
columnWidths: columnWidths,
|
|
73
86
|
defaultColumnWidth: defaultColumnWidth,
|
|
74
87
|
setColumnWidth: setColumnWidth,
|
|
75
|
-
visibleColCount: visibleColCount,
|
|
76
88
|
setVisibleColumns: setVisibleColumns,
|
|
77
89
|
switchColumnPos: switchColumnPos,
|
|
78
90
|
sorting: sorting,
|
|
79
91
|
schema: schema,
|
|
80
|
-
schemaDetectors: schemaDetectors
|
|
92
|
+
schemaDetectors: schemaDetectors,
|
|
93
|
+
canDragAndDropColumns: canDragAndDropColumns,
|
|
94
|
+
gridStyles: gridStyles
|
|
81
95
|
});
|
|
82
|
-
}), trailingControlColumns.map(function (controlColumn, index) {
|
|
96
|
+
})), trailingControlColumns.map(function (controlColumn, index) {
|
|
97
|
+
var visibleIndex = index + leadingControlColumns.length + columns.length;
|
|
83
98
|
return (0, _react2.jsx)(_data_grid_control_header_cell.EuiDataGridControlHeaderCell, {
|
|
84
99
|
key: controlColumn.id,
|
|
85
|
-
index:
|
|
86
|
-
|
|
100
|
+
index: visibleIndex,
|
|
101
|
+
isLastColumn: isLastColumn(visibleIndex),
|
|
87
102
|
controlColumn: controlColumn
|
|
88
103
|
});
|
|
89
104
|
}));
|