@elastic/eui 97.0.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/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/es/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/es/components/drag_and_drop/draggable.js +13 -5
- package/es/components/header/header.styles.js +6 -12
- package/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/es/components/tabs/tab.js +1 -1
- package/eui.d.ts +416 -307
- package/i18ntokens.json +171 -171
- 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/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/lib/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/lib/components/drag_and_drop/draggable.js +13 -5
- package/lib/components/header/header.styles.js +6 -12
- package/lib/components/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/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- package/optimize/es/components/drag_and_drop/draggable.js +8 -3
- package/optimize/es/components/header/header.styles.js +6 -12
- package/optimize/es/components/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/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
- package/optimize/lib/components/header/header.styles.js +6 -12
- package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/lib/components/tabs/tab.js +1 -1
- package/package.json +1 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
- package/test-env/components/datagrid/body/data_grid_body.js +2 -1
- package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/test-env/components/datagrid/body/header/column_actions.js +261 -27
- package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
- package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
- package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/test-env/components/datagrid/data_grid.js +2 -1
- package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
- package/test-env/components/datagrid/utils/col_widths.js +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/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/test-env/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/test-env/components/drag_and_drop/draggable.js +13 -5
- package/test-env/components/header/header.styles.js +6 -12
- package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
- package/test-env/components/tabs/tab.js +1 -1
|
@@ -43,6 +43,7 @@ export var euiDataGridCellOutlineSelectors = function euiDataGridCellOutlineSele
|
|
|
43
43
|
|
|
44
44
|
// Cell header specific selectors
|
|
45
45
|
var headerActionsOpen = '.euiDataGridHeaderCell--isActionsPopoverOpen';
|
|
46
|
+
var isMoving = '[data-column-moving]'; // prevents the header column actions hover animation from replaying on column move
|
|
46
47
|
|
|
47
48
|
// Utils
|
|
48
49
|
var selectors = function selectors() {
|
|
@@ -76,10 +77,11 @@ export var euiDataGridCellOutlineSelectors = function euiDataGridCellOutlineSele
|
|
|
76
77
|
hoverAnimation: hoverNot(selectors(focus, isOpen, isClosing))
|
|
77
78
|
},
|
|
78
79
|
header: {
|
|
79
|
-
focus: is(selectors(focus, focusWithin, headerActionsOpen)),
|
|
80
|
+
focus: is(selectors(focus, focusWithin, headerActionsOpen, isMoving)),
|
|
80
81
|
// :focus-within here is primarily intended for when the column actions button has been clicked twice
|
|
81
82
|
focusTrapped: _(isEntered),
|
|
82
|
-
|
|
83
|
+
showActions: is(selectors(hover, focusWithin, headerActionsOpen, isMoving)),
|
|
84
|
+
hideActions: not(selectors(hover, focusWithin, headerActionsOpen, isMoving))
|
|
83
85
|
}
|
|
84
86
|
};
|
|
85
87
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
|
|
2
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
1
3
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
4
|
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."); }
|
|
3
5
|
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; } }
|
|
@@ -104,16 +106,24 @@ export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
|
104
106
|
|
|
105
107
|
// direct DOM manipulation as workaround to attach required hints
|
|
106
108
|
useEffect(function () {
|
|
109
|
+
var _currentAriaDescribed;
|
|
107
110
|
var currentAriaDescribedbyId = cellEl.getAttribute('aria-describedby');
|
|
108
|
-
|
|
111
|
+
// A11y: splitting ids to be able to append the first hint (sorting)
|
|
112
|
+
// while other hints should follow the keyboard navigation hints
|
|
113
|
+
var _ref3 = (_currentAriaDescribed = currentAriaDescribedbyId === null || currentAriaDescribedbyId === void 0 ? void 0 : currentAriaDescribedbyId.split(' ')) !== null && _currentAriaDescribed !== void 0 ? _currentAriaDescribed : [],
|
|
114
|
+
_ref4 = _toArray(_ref3),
|
|
115
|
+
sortingId = _ref4[0],
|
|
116
|
+
rest = _ref4.slice(1);
|
|
117
|
+
var remainingIds = rest.join(' ');
|
|
118
|
+
cellEl.setAttribute('aria-describedby', classNames(sortingId, ariaDescribedById, !isCellEntered && remainingIds));
|
|
109
119
|
return function () {
|
|
110
120
|
if (currentAriaDescribedbyId) {
|
|
111
|
-
cellEl.setAttribute('aria-
|
|
121
|
+
cellEl.setAttribute('aria-describedby', currentAriaDescribedbyId);
|
|
112
122
|
} else {
|
|
113
123
|
cellEl.removeAttribute('aria-describedby');
|
|
114
124
|
}
|
|
115
125
|
};
|
|
116
|
-
}, [cellEl, ariaDescribedById]);
|
|
126
|
+
}, [cellEl, ariaDescribedById, isCellEntered]);
|
|
117
127
|
useEffect(function () {
|
|
118
128
|
if (isCellEntered) {
|
|
119
129
|
enableAndFocusInteractives(cellEl);
|
|
@@ -141,7 +151,7 @@ export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
|
141
151
|
} else if (
|
|
142
152
|
// when opened content is closed, we don't want Escape to return to the cell
|
|
143
153
|
// immediately but instead return focus to a trigger as expected
|
|
144
|
-
isCellEntered === false && isDOMNode(event.target) && isDOMNode(event.currentTarget) && event.currentTarget.contains(event.target)) {
|
|
154
|
+
isCellEntered === false && isDOMNode(event.target) && isDOMNode(event.currentTarget) && event.currentTarget !== event.target && event.currentTarget.contains(event.target)) {
|
|
145
155
|
return true;
|
|
146
156
|
}
|
|
147
157
|
return isCellEntered;
|
|
@@ -653,5 +653,6 @@ EuiDataGridBody.propTypes = {
|
|
|
653
653
|
gridRef: PropTypes.any.isRequired,
|
|
654
654
|
gridItemsRendered: PropTypes.any.isRequired,
|
|
655
655
|
wrapperRef: PropTypes.any.isRequired,
|
|
656
|
-
className: PropTypes.string
|
|
656
|
+
className: PropTypes.string,
|
|
657
|
+
canDragAndDropColumns: PropTypes.bool
|
|
657
658
|
};
|
|
@@ -49,6 +49,7 @@ export var EuiDataGridBodyCustomRender = /*#__PURE__*/memo(function (_ref) {
|
|
|
49
49
|
columns = _ref.columns,
|
|
50
50
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
51
51
|
switchColumnPos = _ref.switchColumnPos,
|
|
52
|
+
canDragAndDropColumns = _ref.canDragAndDropColumns,
|
|
52
53
|
onColumnResize = _ref.onColumnResize,
|
|
53
54
|
schema = _ref.schema,
|
|
54
55
|
schemaDetectors = _ref.schemaDetectors,
|
|
@@ -102,12 +103,13 @@ export var EuiDataGridBodyCustomRender = /*#__PURE__*/memo(function (_ref) {
|
|
|
102
103
|
setVisibleColumns: setVisibleColumns,
|
|
103
104
|
visibleColCount: visibleColCount,
|
|
104
105
|
switchColumnPos: switchColumnPos,
|
|
106
|
+
canDragAndDropColumns: canDragAndDropColumns,
|
|
105
107
|
sorting: sorting,
|
|
106
108
|
schema: schema,
|
|
107
109
|
schemaDetectors: schemaDetectors,
|
|
108
110
|
gridStyles: gridStyles
|
|
109
111
|
};
|
|
110
|
-
}, [leadingControlColumns, trailingControlColumns, columns, columnWidths, defaultColumnWidth, setColumnWidth, visibleColCount, setVisibleColumns, switchColumnPos, sorting, schema, schemaDetectors, gridStyles]);
|
|
112
|
+
}, [leadingControlColumns, trailingControlColumns, columns, columnWidths, defaultColumnWidth, setColumnWidth, visibleColCount, setVisibleColumns, switchColumnPos, canDragAndDropColumns, sorting, schema, schemaDetectors, gridStyles]);
|
|
111
113
|
|
|
112
114
|
/**
|
|
113
115
|
* Header & footer
|
|
@@ -816,6 +818,7 @@ EuiDataGridBodyCustomRender.propTypes = {
|
|
|
816
818
|
gridRef: PropTypes.any.isRequired,
|
|
817
819
|
gridItemsRendered: PropTypes.any.isRequired,
|
|
818
820
|
wrapperRef: PropTypes.any.isRequired,
|
|
819
|
-
className: PropTypes.string
|
|
821
|
+
className: PropTypes.string,
|
|
822
|
+
canDragAndDropColumns: PropTypes.bool
|
|
820
823
|
};
|
|
821
824
|
EuiDataGridBodyCustomRender.displayName = 'EuiDataGridBodyCustomRender';
|
|
@@ -109,7 +109,8 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
|
|
|
109
109
|
gridRef = _ref3.gridRef,
|
|
110
110
|
gridItemsRendered = _ref3.gridItemsRendered,
|
|
111
111
|
wrapperRef = _ref3.wrapperRef,
|
|
112
|
-
className = _ref3.className
|
|
112
|
+
className = _ref3.className,
|
|
113
|
+
canDragAndDropColumns = _ref3.canDragAndDropColumns;
|
|
113
114
|
/**
|
|
114
115
|
* Grid refs & observers
|
|
115
116
|
*/
|
|
@@ -160,7 +161,8 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
|
|
|
160
161
|
sorting: sorting,
|
|
161
162
|
schema: schema,
|
|
162
163
|
schemaDetectors: schemaDetectors,
|
|
163
|
-
gridStyles: gridStyles
|
|
164
|
+
gridStyles: gridStyles,
|
|
165
|
+
canDragAndDropColumns: canDragAndDropColumns
|
|
164
166
|
}),
|
|
165
167
|
headerRow = _useDataGridHeader.headerRow,
|
|
166
168
|
headerRowHeight = _useDataGridHeader.headerRowHeight;
|
|
@@ -192,7 +194,8 @@ export var EuiDataGridBodyVirtualized = /*#__PURE__*/memo(function (_ref3) {
|
|
|
192
194
|
headerRowHeight: headerRowHeight,
|
|
193
195
|
footerRowHeight: footerRowHeight,
|
|
194
196
|
visibleRowCount: visibleRowCount,
|
|
195
|
-
hasStickyFooter: !!(renderFooterCellValue && gridStyles.stickyFooter)
|
|
197
|
+
hasStickyFooter: !!(renderFooterCellValue && gridStyles.stickyFooter),
|
|
198
|
+
canDragAndDropColumns: canDragAndDropColumns
|
|
196
199
|
});
|
|
197
200
|
|
|
198
201
|
/**
|
|
@@ -940,6 +943,7 @@ EuiDataGridBodyVirtualized.propTypes = {
|
|
|
940
943
|
gridRef: PropTypes.any.isRequired,
|
|
941
944
|
gridItemsRendered: PropTypes.any.isRequired,
|
|
942
945
|
wrapperRef: PropTypes.any.isRequired,
|
|
943
|
-
className: PropTypes.string
|
|
946
|
+
className: PropTypes.string,
|
|
947
|
+
canDragAndDropColumns: PropTypes.bool
|
|
944
948
|
};
|
|
945
949
|
EuiDataGridBodyVirtualized.displayName = 'EuiDataGridBodyVirtualized';
|
|
@@ -6,10 +6,15 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
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); }
|
|
7
7
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
8
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
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; } }
|
|
10
9
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
11
10
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
+
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); }
|
|
12
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
13
|
+
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."); }
|
|
14
|
+
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; } }
|
|
12
15
|
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; }
|
|
16
|
+
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; } }
|
|
17
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
18
|
/*
|
|
14
19
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
15
20
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -18,24 +23,242 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
|
|
|
18
23
|
* Side Public License, v 1.
|
|
19
24
|
*/
|
|
20
25
|
|
|
21
|
-
import React from 'react';
|
|
22
|
-
import
|
|
26
|
+
import React, { useContext, useState, useMemo, useCallback, useRef, memo, useEffect } from 'react';
|
|
27
|
+
import PropTypes from "prop-types";
|
|
28
|
+
import { tabbable } from 'tabbable';
|
|
29
|
+
import { keys, useEuiMemoizedStyles } from '../../../../services';
|
|
30
|
+
// Keep the i18n scope the same as EuiDataGridHeaderCell
|
|
31
|
+
/* eslint-disable local/i18n */
|
|
32
|
+
import { EuiI18n, useEuiI18n } from '../../../i18n';
|
|
33
|
+
import { EuiPopover } from '../../../popover';
|
|
34
|
+
import { EuiListGroup } from '../../../list_group';
|
|
35
|
+
import { EuiButtonIcon } from '../../../button';
|
|
36
|
+
import { DataGridFocusContext } from '../../utils/focus';
|
|
23
37
|
import { getDetailsForSchema } from '../../utils/data_grid_schema';
|
|
24
38
|
import { defaultSortAscLabel, defaultSortDescLabel } from '../../controls/column_sorting_draggable';
|
|
39
|
+
import { euiDataGridHeaderCellStyles } from './data_grid_header_cell.styles';
|
|
25
40
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
26
|
-
export var
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
export var useHasColumnActions = function useHasColumnActions(columnActions) {
|
|
42
|
+
return useMemo(function () {
|
|
43
|
+
// By default, all column actions are enabled
|
|
44
|
+
if (columnActions === undefined) return true;
|
|
45
|
+
if (columnActions === false) return false;
|
|
46
|
+
if (columnActions.additional && columnActions.additional.length) return true;
|
|
47
|
+
// Check if all (currently 5) default column actions have been manually disabled
|
|
48
|
+
var disabledActions = Object.values(columnActions).filter(function (action) {
|
|
49
|
+
return action === false;
|
|
50
|
+
});
|
|
51
|
+
return disabledActions.length < 5;
|
|
52
|
+
}, [columnActions]);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Props to pass back to EuiDataGridHeaderCell and set on EuiDataGridHeaderCellWrapper
|
|
56
|
+
|
|
57
|
+
export var ColumnActions = /*#__PURE__*/memo(function (_ref) {
|
|
58
|
+
var index = _ref.index,
|
|
59
|
+
id = _ref.id,
|
|
60
|
+
title = _ref.title,
|
|
61
|
+
column = _ref.column,
|
|
29
62
|
columns = _ref.columns,
|
|
30
63
|
schema = _ref.schema,
|
|
31
64
|
schemaDetectors = _ref.schemaDetectors,
|
|
32
65
|
setVisibleColumns = _ref.setVisibleColumns,
|
|
33
|
-
focusFirstVisibleInteractiveCell = _ref.focusFirstVisibleInteractiveCell,
|
|
34
|
-
setIsPopoverOpen = _ref.setIsPopoverOpen,
|
|
35
|
-
sorting = _ref.sorting,
|
|
36
66
|
switchColumnPos = _ref.switchColumnPos,
|
|
37
|
-
|
|
38
|
-
|
|
67
|
+
sorting = _ref.sorting,
|
|
68
|
+
hasFocusTrap = _ref.hasFocusTrap,
|
|
69
|
+
setPropsFromColumnActions = _ref.setPropsFromColumnActions,
|
|
70
|
+
actionsButtonRef = _ref.actionsButtonRef;
|
|
71
|
+
/**
|
|
72
|
+
* Popover logic and accessibility
|
|
73
|
+
*/
|
|
74
|
+
var _useState = useState(false),
|
|
75
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
76
|
+
isPopoverOpen = _useState2[0],
|
|
77
|
+
setIsPopoverOpen = _useState2[1];
|
|
78
|
+
var togglePopover = useCallback(function () {
|
|
79
|
+
setIsPopoverOpen(function (isOpen) {
|
|
80
|
+
return !isOpen;
|
|
81
|
+
});
|
|
82
|
+
}, []);
|
|
83
|
+
var closePopover = useCallback(function () {
|
|
84
|
+
setIsPopoverOpen(false);
|
|
85
|
+
}, []);
|
|
86
|
+
var _useState3 = useState(false),
|
|
87
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
88
|
+
isActionsButtonFocused = _useState4[0],
|
|
89
|
+
setIsActionsButtonFocused = _useState4[1];
|
|
90
|
+
var onFocus = useCallback(function () {
|
|
91
|
+
return setIsActionsButtonFocused(true);
|
|
92
|
+
}, []);
|
|
93
|
+
var onBlur = useCallback(function () {
|
|
94
|
+
return setIsActionsButtonFocused(false);
|
|
95
|
+
}, []);
|
|
96
|
+
var actionsButtonAriaLabel = useEuiI18n('euiDataGridHeaderCell.actionsButtonAriaLabel', '{title}. Click to view column header actions.', {
|
|
97
|
+
title: title
|
|
98
|
+
});
|
|
99
|
+
var actionsEnterKeyInstructions = useEuiI18n('euiDataGridHeaderCell.actionsEnterKeyInstructions', "Press the Enter key to view this column's actions");
|
|
100
|
+
var openActionsPopoverOnEnter = useCallback(function (e) {
|
|
101
|
+
if (e.key === keys.ENTER) {
|
|
102
|
+
setIsPopoverOpen(true);
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
var popoverArrowNavigationProps = usePopoverArrowNavigation();
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Props to set on parent EuiDataGridHeaderCell
|
|
109
|
+
*/
|
|
110
|
+
var _useState5 = useState(false),
|
|
111
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
112
|
+
isColumnMoving = _useState6[0],
|
|
113
|
+
setIsColumnMoving = _useState6[1];
|
|
114
|
+
useEffect(function () {
|
|
115
|
+
setPropsFromColumnActions({
|
|
116
|
+
className: isPopoverOpen ? 'euiDataGridHeaderCell--isActionsPopoverOpen' : '',
|
|
117
|
+
onKeyDown: openActionsPopoverOnEnter,
|
|
118
|
+
'data-column-moving': isColumnMoving || undefined
|
|
119
|
+
});
|
|
120
|
+
}, [setPropsFromColumnActions, isPopoverOpen, openActionsPopoverOnEnter, isColumnMoving]);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get column actions as an array of EuiListGroup items
|
|
124
|
+
*/
|
|
125
|
+
var _useContext = useContext(DataGridFocusContext),
|
|
126
|
+
setFocusedCell = _useContext.setFocusedCell,
|
|
127
|
+
focusFirstVisibleInteractiveCell = _useContext.focusFirstVisibleInteractiveCell;
|
|
128
|
+
var columnActions = useMemo(function () {
|
|
129
|
+
return getColumnActions({
|
|
130
|
+
column: column,
|
|
131
|
+
columns: columns,
|
|
132
|
+
schema: schema,
|
|
133
|
+
schemaDetectors: schemaDetectors,
|
|
134
|
+
setVisibleColumns: setVisibleColumns,
|
|
135
|
+
focusFirstVisibleInteractiveCell: focusFirstVisibleInteractiveCell,
|
|
136
|
+
sorting: sorting,
|
|
137
|
+
switchColumnPos: switchColumnPos,
|
|
138
|
+
setIsPopoverOpen: setIsPopoverOpen,
|
|
139
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
140
|
+
setFocusedCell: setFocusedCell,
|
|
141
|
+
columnFocusIndex: index
|
|
142
|
+
});
|
|
143
|
+
}, [column, columns, schema, schemaDetectors, setVisibleColumns, focusFirstVisibleInteractiveCell, sorting, switchColumnPos, setFocusedCell, index]);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Rendering
|
|
147
|
+
*/
|
|
148
|
+
var styles = useEuiMemoizedStyles(euiDataGridHeaderCellStyles);
|
|
149
|
+
return ___EmotionJSX(EuiPopover, _extends({
|
|
150
|
+
display: "block",
|
|
151
|
+
panelPaddingSize: "none",
|
|
152
|
+
offset: 7,
|
|
153
|
+
anchorPosition: "downRight",
|
|
154
|
+
css: styles.euiDataGridHeaderCell__popover,
|
|
155
|
+
button: ___EmotionJSX(EuiButtonIcon, {
|
|
156
|
+
iconType: "boxesVertical",
|
|
157
|
+
iconSize: "s",
|
|
158
|
+
color: "text",
|
|
159
|
+
css: styles.euiDataGridHeaderCell__actions,
|
|
160
|
+
className: "euiDataGridHeaderCell__button",
|
|
161
|
+
onClick: togglePopover,
|
|
162
|
+
buttonRef: actionsButtonRef,
|
|
163
|
+
onFocus: onFocus,
|
|
164
|
+
onBlur: onBlur,
|
|
165
|
+
tabIndex: 0 // Override EuiButtonIcon's conditional tabindex based on aria-hidden
|
|
166
|
+
,
|
|
167
|
+
"aria-hidden": hasFocusTrap && !isActionsButtonFocused ? 'true' // prevent the actions button from being read on cell focus
|
|
168
|
+
: undefined,
|
|
169
|
+
"aria-label": hasFocusTrap ? actionsButtonAriaLabel : actionsEnterKeyInstructions,
|
|
170
|
+
"data-test-subj": "dataGridHeaderCellActionButton-".concat(id)
|
|
171
|
+
}),
|
|
172
|
+
isOpen: isPopoverOpen,
|
|
173
|
+
closePopover: closePopover
|
|
174
|
+
}, popoverArrowNavigationProps), ___EmotionJSX(EuiListGroup, {
|
|
175
|
+
listItems: columnActions,
|
|
176
|
+
gutterSize: "none",
|
|
177
|
+
"data-test-subj": "dataGridHeaderCellActionGroup-".concat(id)
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
ColumnActions.propTypes = {
|
|
181
|
+
id: PropTypes.string.isRequired,
|
|
182
|
+
title: PropTypes.string.isRequired,
|
|
183
|
+
hasFocusTrap: PropTypes.bool.isRequired,
|
|
184
|
+
setPropsFromColumnActions: PropTypes.func.isRequired,
|
|
185
|
+
actionsButtonRef: PropTypes.any.isRequired
|
|
186
|
+
};
|
|
187
|
+
ColumnActions.displayName = 'EuiDataGridHeaderCellColumnActions';
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Add keyboard arrow navigation to the cell actions popover
|
|
191
|
+
* to match the UX of the rest of EuiDataGrid
|
|
192
|
+
*/
|
|
193
|
+
export var usePopoverArrowNavigation = function usePopoverArrowNavigation() {
|
|
194
|
+
var popoverPanelRef = useRef(null);
|
|
195
|
+
var actionsRef = useRef(undefined);
|
|
196
|
+
var panelRef = useCallback(function (ref) {
|
|
197
|
+
popoverPanelRef.current = ref;
|
|
198
|
+
actionsRef.current = ref ? tabbable(ref) : undefined;
|
|
199
|
+
}, []);
|
|
200
|
+
var onKeyDown = useCallback(function (e) {
|
|
201
|
+
var _actionsRef$current;
|
|
202
|
+
if (e.key !== keys.ARROW_DOWN && e.key !== keys.ARROW_UP) return;
|
|
203
|
+
if (!((_actionsRef$current = actionsRef.current) !== null && _actionsRef$current !== void 0 && _actionsRef$current.length)) return;
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
var initialState = document.activeElement === popoverPanelRef.current;
|
|
206
|
+
var currentIndex = !initialState ? actionsRef.current.findIndex(function (el) {
|
|
207
|
+
return document.activeElement === el;
|
|
208
|
+
}) : -1;
|
|
209
|
+
var lastIndex = actionsRef.current.length - 1;
|
|
210
|
+
var indexToFocus;
|
|
211
|
+
if (initialState) {
|
|
212
|
+
if (e.key === keys.ARROW_DOWN) {
|
|
213
|
+
indexToFocus = 0;
|
|
214
|
+
} else if (e.key === keys.ARROW_UP) {
|
|
215
|
+
indexToFocus = lastIndex;
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
if (e.key === keys.ARROW_DOWN) {
|
|
219
|
+
indexToFocus = currentIndex + 1;
|
|
220
|
+
if (indexToFocus > lastIndex) {
|
|
221
|
+
indexToFocus = 0;
|
|
222
|
+
}
|
|
223
|
+
} else if (e.key === keys.ARROW_UP) {
|
|
224
|
+
indexToFocus = currentIndex - 1;
|
|
225
|
+
if (indexToFocus < 0) {
|
|
226
|
+
indexToFocus = lastIndex;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
actionsRef.current[indexToFocus].focus();
|
|
231
|
+
}, []);
|
|
232
|
+
return {
|
|
233
|
+
panelRef: panelRef,
|
|
234
|
+
panelProps: {
|
|
235
|
+
onKeyDown: onKeyDown
|
|
236
|
+
},
|
|
237
|
+
popoverScreenReaderText: ___EmotionJSX(EuiI18n, {
|
|
238
|
+
token: "euiDataGridHeaderCell.actionsPopoverScreenReaderText",
|
|
239
|
+
default: "To navigate through the list of column actions, press the Tab or Up and Down arrow keys."
|
|
240
|
+
})
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Logic for returning an array of actions/items to pass to EuiListGroup
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
export var getColumnActions = function getColumnActions(_ref2) {
|
|
249
|
+
var _column$actions;
|
|
250
|
+
var column = _ref2.column,
|
|
251
|
+
columns = _ref2.columns,
|
|
252
|
+
schema = _ref2.schema,
|
|
253
|
+
schemaDetectors = _ref2.schemaDetectors,
|
|
254
|
+
setVisibleColumns = _ref2.setVisibleColumns,
|
|
255
|
+
focusFirstVisibleInteractiveCell = _ref2.focusFirstVisibleInteractiveCell,
|
|
256
|
+
setIsPopoverOpen = _ref2.setIsPopoverOpen,
|
|
257
|
+
sorting = _ref2.sorting,
|
|
258
|
+
switchColumnPos = _ref2.switchColumnPos,
|
|
259
|
+
setIsColumnMoving = _ref2.setIsColumnMoving,
|
|
260
|
+
setFocusedCell = _ref2.setFocusedCell,
|
|
261
|
+
columnFocusIndex = _ref2.columnFocusIndex;
|
|
39
262
|
if (column.actions === false) {
|
|
40
263
|
return [];
|
|
41
264
|
}
|
|
@@ -53,6 +276,7 @@ export var getColumnActions = function getColumnActions(_ref) {
|
|
|
53
276
|
column: column,
|
|
54
277
|
columns: columns,
|
|
55
278
|
switchColumnPos: switchColumnPos,
|
|
279
|
+
setIsColumnMoving: setIsColumnMoving,
|
|
56
280
|
setFocusedCell: setFocusedCell,
|
|
57
281
|
columnFocusIndex: columnFocusIndex
|
|
58
282
|
})), _toConsumableArray(((_column$actions = column.actions) === null || _column$actions === void 0 ? void 0 : _column$actions.additional) || []));
|
|
@@ -74,11 +298,11 @@ export var getColumnActions = function getColumnActions(_ref) {
|
|
|
74
298
|
* Hide column action
|
|
75
299
|
*/
|
|
76
300
|
|
|
77
|
-
export var getHideColumnAction = function getHideColumnAction(
|
|
78
|
-
var column =
|
|
79
|
-
columns =
|
|
80
|
-
setVisibleColumns =
|
|
81
|
-
focusFirstVisibleInteractiveCell =
|
|
301
|
+
export var getHideColumnAction = function getHideColumnAction(_ref3) {
|
|
302
|
+
var column = _ref3.column,
|
|
303
|
+
columns = _ref3.columns,
|
|
304
|
+
setVisibleColumns = _ref3.setVisibleColumns,
|
|
305
|
+
focusFirstVisibleInteractiveCell = _ref3.focusFirstVisibleInteractiveCell;
|
|
82
306
|
var items = [];
|
|
83
307
|
var onClickHideColumn = function onClickHideColumn() {
|
|
84
308
|
setVisibleColumns(columns.filter(function (col) {
|
|
@@ -109,16 +333,25 @@ export var getHideColumnAction = function getHideColumnAction(_ref2) {
|
|
|
109
333
|
* Move column actions
|
|
110
334
|
*/
|
|
111
335
|
|
|
112
|
-
var getMoveColumnActions = function getMoveColumnActions(
|
|
113
|
-
var column =
|
|
114
|
-
columns =
|
|
115
|
-
switchColumnPos =
|
|
116
|
-
|
|
117
|
-
|
|
336
|
+
var getMoveColumnActions = function getMoveColumnActions(_ref4) {
|
|
337
|
+
var column = _ref4.column,
|
|
338
|
+
columns = _ref4.columns,
|
|
339
|
+
switchColumnPos = _ref4.switchColumnPos,
|
|
340
|
+
setIsColumnMoving = _ref4.setIsColumnMoving,
|
|
341
|
+
setFocusedCell = _ref4.setFocusedCell,
|
|
342
|
+
columnFocusIndex = _ref4.columnFocusIndex;
|
|
118
343
|
var items = [];
|
|
119
344
|
var colIdx = columns.findIndex(function (col) {
|
|
120
345
|
return col.id === column.id;
|
|
121
346
|
});
|
|
347
|
+
|
|
348
|
+
// UX polish: prevent the column actions hover animation from flashing after column move
|
|
349
|
+
var handleAnimationFlash = function handleAnimationFlash() {
|
|
350
|
+
setIsColumnMoving(true);
|
|
351
|
+
requestAnimationFrame(function () {
|
|
352
|
+
return setIsColumnMoving(false);
|
|
353
|
+
});
|
|
354
|
+
};
|
|
122
355
|
var moveFocus = function moveFocus(direction) {
|
|
123
356
|
var newIndex = direction === 'left' ? -1 : 1;
|
|
124
357
|
// Wait a beat to move focus, otherwise the EuiPopover's EuiFocusTrap's
|
|
@@ -132,6 +365,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
132
365
|
var targetCol = columns[colIdx - 1];
|
|
133
366
|
if (targetCol) {
|
|
134
367
|
switchColumnPos(column.id, targetCol.id);
|
|
368
|
+
handleAnimationFlash();
|
|
135
369
|
moveFocus('left');
|
|
136
370
|
}
|
|
137
371
|
};
|
|
@@ -153,6 +387,7 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
153
387
|
var targetCol = columns[colIdx + 1];
|
|
154
388
|
if (targetCol) {
|
|
155
389
|
switchColumnPos(column.id, targetCol.id);
|
|
390
|
+
handleAnimationFlash();
|
|
156
391
|
moveFocus('right');
|
|
157
392
|
}
|
|
158
393
|
};
|
|
@@ -176,11 +411,11 @@ var getMoveColumnActions = function getMoveColumnActions(_ref3) {
|
|
|
176
411
|
* Sort column actions
|
|
177
412
|
*/
|
|
178
413
|
|
|
179
|
-
export var getSortColumnActions = function getSortColumnActions(
|
|
180
|
-
var column =
|
|
181
|
-
sorting =
|
|
182
|
-
schema =
|
|
183
|
-
schemaDetectors =
|
|
414
|
+
export var getSortColumnActions = function getSortColumnActions(_ref5) {
|
|
415
|
+
var column = _ref5.column,
|
|
416
|
+
sorting = _ref5.sorting,
|
|
417
|
+
schema = _ref5.schema,
|
|
418
|
+
schemaDetectors = _ref5.schemaDetectors;
|
|
184
419
|
if (!sorting) return [];
|
|
185
420
|
var items = [];
|
|
186
421
|
var sortingIdx = sorting.columns.findIndex(function (col) {
|
package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js}
RENAMED
|
@@ -24,7 +24,8 @@ import React, { Component } from 'react';
|
|
|
24
24
|
import PropTypes from "prop-types";
|
|
25
25
|
import { RenderWithEuiStylesMemoizer } from '../../../../services';
|
|
26
26
|
import { logicalStyle } from '../../../../global_styling';
|
|
27
|
-
import {
|
|
27
|
+
import { DragOverlay } from './draggable_columns';
|
|
28
|
+
import { euiDataGridColumnResizerStyles } from './column_resizer.styles';
|
|
28
29
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
29
30
|
var MINIMUM_COLUMN_WIDTH = 40;
|
|
30
31
|
export var EuiDataGridColumnResizer = /*#__PURE__*/function (_Component) {
|
|
@@ -81,16 +82,20 @@ export var EuiDataGridColumnResizer = /*#__PURE__*/function (_Component) {
|
|
|
81
82
|
value: function render() {
|
|
82
83
|
var _this2 = this;
|
|
83
84
|
var offset = this.state.offset;
|
|
85
|
+
var isLastColumn = this.props.isLastColumn;
|
|
84
86
|
return ___EmotionJSX(RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
|
|
85
87
|
var styles = stylesMemoizer(euiDataGridColumnResizerStyles);
|
|
86
|
-
var cssStyles = [styles.euiDataGridColumnResizer, offset && styles.isDragging];
|
|
88
|
+
var cssStyles = [styles.euiDataGridColumnResizer, isLastColumn && styles.isLastColumn, offset && styles.isDragging];
|
|
87
89
|
return ___EmotionJSX("div", {
|
|
88
90
|
css: cssStyles,
|
|
89
91
|
className: "euiDataGridColumnResizer",
|
|
90
92
|
"data-test-subj": "dataGridColumnResizer",
|
|
91
93
|
style: offset ? logicalStyle('margin-right', "".concat(-offset, "px")) : undefined,
|
|
92
94
|
onMouseDown: _this2.onMouseDown
|
|
93
|
-
}
|
|
95
|
+
}, ___EmotionJSX(DragOverlay, {
|
|
96
|
+
isDragging: !!offset,
|
|
97
|
+
cursor: "ew-resize"
|
|
98
|
+
}));
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
101
|
}]);
|
|
@@ -98,5 +103,6 @@ export var EuiDataGridColumnResizer = /*#__PURE__*/function (_Component) {
|
|
|
98
103
|
EuiDataGridColumnResizer.propTypes = {
|
|
99
104
|
columnId: PropTypes.string.isRequired,
|
|
100
105
|
columnWidth: PropTypes.number.isRequired,
|
|
101
|
-
setColumnWidth: PropTypes.func.isRequired
|
|
106
|
+
setColumnWidth: PropTypes.func.isRequired,
|
|
107
|
+
isLastColumn: PropTypes.bool.isRequired
|
|
102
108
|
};
|
|
@@ -30,7 +30,12 @@ export var euiDataGridColumnResizerStyles = function euiDataGridColumnResizerSty
|
|
|
30
30
|
}); // Odd number because it straddles a border
|
|
31
31
|
var indicatorOffset = "-".concat(euiTheme.border.width.thin);
|
|
32
32
|
return {
|
|
33
|
-
euiDataGridColumnResizer: /*#__PURE__*/css("z-index:2;position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('left', positionOffset), " ", logicalCSS('margin-left', indicatorOffset), " ", logicalCSS('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";}
|
|
33
|
+
euiDataGridColumnResizer: /*#__PURE__*/css("z-index:2;position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('right', positionOffset), " cursor:ew-resize;opacity:0;&:hover,&:active{opacity:1;}&::after{content:'';position:absolute;", logicalCSS('vertical', 0), " ", logicalCSS('left', positionOffset), " ", logicalCSS('margin-left', indicatorOffset), " ", logicalCSS('width', indicatorWidth), " background-color:", euiTheme.colors.primary, ";};label:euiDataGridColumnResizer;"),
|
|
34
|
+
/* Because the resizer sits in the negative space to the right of the column,
|
|
35
|
+
* it can cause the full grid to be a few pixels longer than it actually is.
|
|
36
|
+
* So for the last cell, we don't use negative positioning and the borders from
|
|
37
|
+
* the cell will match the container. */
|
|
38
|
+
isLastColumn: /*#__PURE__*/css(logicalCSS('right', 0), " ", logicalCSS('width', euiTheme.size.s), " &::after{", logicalCSS('left', 'auto'), " ", logicalCSS('right', 0), ";};label:isLastColumn;"),
|
|
34
39
|
isDragging: _ref
|
|
35
40
|
};
|
|
36
41
|
};
|