@elastic/eui 97.0.0 → 97.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/es/components/datagrid/body/cell/focus_utils.js +14 -4
- package/es/components/datagrid/body/data_grid_body.js +2 -1
- package/es/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/es/components/datagrid/body/header/column_actions.js +262 -27
- package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +10 -4
- package/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/es/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/es/components/datagrid/body/header/draggable_columns.js +301 -0
- package/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/es/components/datagrid/data_grid.js +2 -1
- package/es/components/datagrid/data_grid.stories.utils.js +9 -6
- package/es/components/datagrid/utils/col_widths.js +4 -6
- package/es/components/datagrid/utils/focus.js +2 -2
- package/es/components/datagrid/utils/scrolling.js +13 -10
- package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/es/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/es/components/drag_and_drop/draggable.js +13 -5
- package/es/components/header/header.styles.js +6 -12
- package/es/components/header/header_links/header_links.js +1 -1
- package/es/components/header/header_links/header_links.styles.js +1 -0
- package/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/es/components/tabs/tab.js +1 -1
- package/eui.d.ts +417 -307
- package/i18ntokens.json +175 -175
- package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/lib/components/datagrid/body/cell/focus_utils.js +14 -4
- package/lib/components/datagrid/body/data_grid_body.js +2 -1
- package/lib/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/lib/components/datagrid/body/header/column_actions.js +265 -29
- package/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{optimize/lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +86 -305
- package/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/lib/components/datagrid/body/header/draggable_columns.js +308 -0
- package/lib/components/datagrid/body/header/draggable_columns.styles.js +42 -0
- package/lib/components/datagrid/data_grid.js +2 -1
- package/lib/components/datagrid/data_grid.stories.utils.js +9 -6
- package/lib/components/datagrid/utils/col_widths.js +4 -6
- package/lib/components/datagrid/utils/focus.js +2 -2
- package/lib/components/datagrid/utils/scrolling.js +13 -10
- package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/lib/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/lib/components/drag_and_drop/draggable.js +13 -5
- package/lib/components/header/header.styles.js +6 -12
- package/lib/components/header/header_links/header_links.js +1 -1
- package/lib/components/header/header_links/header_links.styles.js +1 -0
- package/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/lib/components/tabs/tab.js +1 -1
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/es/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/es/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/es/components/datagrid/body/header/column_actions.js +250 -26
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +8 -3
- package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
- package/optimize/es/components/datagrid/body/header/column_sorting.js +134 -0
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +82 -302
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
- package/optimize/es/components/datagrid/body/header/draggable_columns.js +223 -0
- package/optimize/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
- package/optimize/es/components/datagrid/data_grid.js +2 -1
- package/optimize/es/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/es/components/datagrid/utils/col_widths.js +4 -6
- package/optimize/es/components/datagrid/utils/focus.js +2 -2
- package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- package/optimize/es/components/drag_and_drop/draggable.js +8 -3
- package/optimize/es/components/header/header.styles.js +6 -12
- package/optimize/es/components/header/header_links/header_links.js +1 -1
- package/optimize/es/components/header/header_links/header_links.styles.js +1 -0
- package/optimize/es/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/es/components/tabs/tab.js +1 -1
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/optimize/lib/components/datagrid/body/cell/focus_utils.js +13 -4
- package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +3 -1
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +6 -3
- package/optimize/lib/components/datagrid/body/header/column_actions.js +253 -27
- package/optimize/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +9 -4
- package/{test-env/components/datagrid/body/header/data_grid_column_resizer.styles.js → optimize/lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/optimize/lib/components/datagrid/body/header/column_sorting.js +144 -0
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +80 -300
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/optimize/lib/components/datagrid/body/header/draggable_columns.js +231 -0
- package/optimize/lib/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/optimize/lib/components/datagrid/data_grid.js +2 -1
- package/optimize/lib/components/datagrid/data_grid.stories.utils.js +7 -5
- package/optimize/lib/components/datagrid/utils/col_widths.js +4 -6
- package/optimize/lib/components/datagrid/utils/focus.js +2 -2
- package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
- package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +11 -5
- package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
- package/optimize/lib/components/header/header.styles.js +6 -12
- package/optimize/lib/components/header/header_links/header_links.js +1 -1
- package/optimize/lib/components/header/header_links/header_links.styles.js +1 -0
- package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
- package/optimize/lib/components/tabs/tab.js +1 -1
- package/package.json +1 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
- package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
- package/test-env/components/datagrid/body/data_grid_body.js +2 -1
- package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
- package/test-env/components/datagrid/body/header/column_actions.js +261 -27
- package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
- package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
- package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
- package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
- package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
- package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
- package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
- package/test-env/components/datagrid/data_grid.js +2 -1
- package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
- package/test-env/components/datagrid/utils/col_widths.js +4 -6
- package/test-env/components/datagrid/utils/focus.js +2 -2
- package/test-env/components/datagrid/utils/scrolling.js +13 -10
- package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
- package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
- package/test-env/components/date_picker/super_date_picker/super_date_picker.js +27 -5
- package/test-env/components/drag_and_drop/draggable.js +13 -5
- package/test-env/components/header/header.styles.js +6 -12
- package/test-env/components/header/header_links/header_links.js +1 -1
- package/test-env/components/header/header_links/header_links.styles.js +1 -0
- package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
- package/test-env/components/tabs/tab.js +1 -1
|
@@ -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
|
}));
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DroppableColumns = exports.DraggableColumn = exports.DragOverlay = exports.ConditionalDroppableColumns = exports.ConditionalDraggableColumn = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _services = require("../../../../services");
|
|
11
|
+
var _drag_and_drop = require("../../../drag_and_drop");
|
|
12
|
+
var _portal = require("../../../portal");
|
|
13
|
+
var _focus = require("../../utils/focus");
|
|
14
|
+
var _data_grid = require("../../data_grid.styles");
|
|
15
|
+
var _draggable_columns = require("./draggable_columns.styles");
|
|
16
|
+
var _react2 = require("@emotion/react");
|
|
17
|
+
var _excluded = ["role", "tabIndex"],
|
|
18
|
+
_excluded2 = ["canDragAndDropColumns", "children"],
|
|
19
|
+
_excluded3 = ["canDragAndDropColumns", "children"];
|
|
20
|
+
/*
|
|
21
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
23
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
24
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
25
|
+
* Side Public License, v 1.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Parent context + EuiDroppable wrapper
|
|
29
|
+
*/
|
|
30
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
31
|
+
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); }
|
|
32
|
+
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; }
|
|
33
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
|
|
34
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
36
|
+
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; }
|
|
37
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
38
|
+
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); }
|
|
39
|
+
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; }
|
|
40
|
+
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; }
|
|
41
|
+
var DroppableColumns = exports.DroppableColumns = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
42
|
+
var columns = _ref.columns,
|
|
43
|
+
switchColumnPos = _ref.switchColumnPos,
|
|
44
|
+
indexOffset = _ref.indexOffset,
|
|
45
|
+
children = _ref.children;
|
|
46
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_draggable_columns.euiDataGridDraggableHeaderStyles);
|
|
47
|
+
var droppableId = (0, _services.useGeneratedHtmlId)({
|
|
48
|
+
prefix: 'euiDataGridHeaderDroppable'
|
|
49
|
+
});
|
|
50
|
+
var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
51
|
+
setFocusedCell = _useContext.setFocusedCell;
|
|
52
|
+
var handleOnDragEnd = (0, _react.useCallback)(function (_ref2) {
|
|
53
|
+
var source = _ref2.source,
|
|
54
|
+
destination = _ref2.destination;
|
|
55
|
+
if (!source) return;
|
|
56
|
+
if (destination && destination.index !== source.index) {
|
|
57
|
+
var sourceColumn = columns[source.index - indexOffset];
|
|
58
|
+
var destinationColumn = columns[destination.index - indexOffset];
|
|
59
|
+
if (sourceColumn && destinationColumn) {
|
|
60
|
+
switchColumnPos(sourceColumn.id, destinationColumn.id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Force focus the cell to prevent the datagrid body from become unfocusable, including on drag cancel
|
|
64
|
+
setTimeout(function () {
|
|
65
|
+
var cellToFocus = destination ? destination.index : source.index;
|
|
66
|
+
setFocusedCell([cellToFocus, -1], true);
|
|
67
|
+
});
|
|
68
|
+
}, [columns, indexOffset, switchColumnPos, setFocusedCell]);
|
|
69
|
+
return (0, _react2.jsx)(_drag_and_drop.EuiDragDropContext, {
|
|
70
|
+
onDragEnd: handleOnDragEnd
|
|
71
|
+
}, (0, _react2.jsx)(_drag_and_drop.EuiDroppable, {
|
|
72
|
+
droppableId: droppableId,
|
|
73
|
+
direction: "horizontal",
|
|
74
|
+
ignoreContainerClipping: true,
|
|
75
|
+
css: styles.euiDataGridHeaderDroppable,
|
|
76
|
+
"data-test-subj": "euiDataGridHeaderDroppable"
|
|
77
|
+
}, children));
|
|
78
|
+
});
|
|
79
|
+
DroppableColumns.propTypes = {
|
|
80
|
+
indexOffset: _propTypes.default.number.isRequired,
|
|
81
|
+
children: _propTypes.default.oneOfType([_propTypes.default.element.isRequired, _propTypes.default.arrayOf(_propTypes.default.element.isRequired).isRequired, _propTypes.default.any.isRequired]).isRequired
|
|
82
|
+
};
|
|
83
|
+
DroppableColumns.displayName = 'DroppableColumns';
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Individual EuiDraggable columns
|
|
87
|
+
*/
|
|
88
|
+
var DraggableColumn = exports.DraggableColumn = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
89
|
+
var id = _ref3.id,
|
|
90
|
+
index = _ref3.index,
|
|
91
|
+
gridStyles = _ref3.gridStyles,
|
|
92
|
+
columnResizer = _ref3.columnResizer,
|
|
93
|
+
actionsPopoverToggle = _ref3.actionsPopoverToggle,
|
|
94
|
+
children = _ref3.children;
|
|
95
|
+
var dataGridStyles = (0, _services.useEuiMemoizedStyles)(_data_grid.euiDataGridStyles);
|
|
96
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_draggable_columns.euiDataGridDraggableHeaderStyles);
|
|
97
|
+
// Manually re-apply background and border overrides, since
|
|
98
|
+
// the droppable zone sets its own and confuses :first-of-type CSS
|
|
99
|
+
var reapplyCellStyles = [styles[gridStyles.header], index !== 0 && styles.noLeadingBorder];
|
|
100
|
+
|
|
101
|
+
// Draggable prevents the cell from receiving focus on click.
|
|
102
|
+
// We manually ensure focus is set on cell mouseDown which
|
|
103
|
+
// also includes setting focus before dragging
|
|
104
|
+
var _useContext2 = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
105
|
+
setFocusedCell = _useContext2.setFocusedCell;
|
|
106
|
+
var handleOnMouseDown = (0, _react.useCallback)(function (e) {
|
|
107
|
+
var openFocusTrap = document.querySelector('[data-focus-lock-disabled="false"]');
|
|
108
|
+
if (!!openFocusTrap &&
|
|
109
|
+
// If a focus trap is open somewhere on the page
|
|
110
|
+
!openFocusTrap.contains(e.target) &&
|
|
111
|
+
// & the focus trap doesn't belong to this header
|
|
112
|
+
e.target !== actionsPopoverToggle // & we're not closing the actions popover toggle
|
|
113
|
+
) {
|
|
114
|
+
// Trick the focus trap lib into registering an outside click -
|
|
115
|
+
// the drag/drop lib otherwise otherwise prevents the event 💀
|
|
116
|
+
document.dispatchEvent(new MouseEvent('mousedown'));
|
|
117
|
+
}
|
|
118
|
+
setTimeout(function () {
|
|
119
|
+
setFocusedCell([index, -1], true);
|
|
120
|
+
});
|
|
121
|
+
}, [setFocusedCell, index, actionsPopoverToggle]);
|
|
122
|
+
|
|
123
|
+
// Prevent any other keypresses when dragging
|
|
124
|
+
var isDraggingRef = (0, _react.useRef)(false);
|
|
125
|
+
var handleOnKeydown = (0, _react.useCallback)(function (e) {
|
|
126
|
+
if (isDraggingRef.current) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}, []);
|
|
132
|
+
|
|
133
|
+
// UX polish: add a slight animation frame delay to the dragging ref end
|
|
134
|
+
// which prevents re-running the hover animation of column header actions
|
|
135
|
+
var updateDraggingRef = (0, _react.useCallback)(function (isDragging) {
|
|
136
|
+
// Only update if the state has changed from before
|
|
137
|
+
if (isDragging !== isDraggingRef.current) {
|
|
138
|
+
if (!isDragging) {
|
|
139
|
+
requestAnimationFrame(function () {
|
|
140
|
+
isDraggingRef.current = false;
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
isDraggingRef.current = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, []);
|
|
147
|
+
return (0, _react2.jsx)("div", {
|
|
148
|
+
css: styles.euiDataGridHeaderCellDraggableWrapper,
|
|
149
|
+
onMouseDown: handleOnMouseDown,
|
|
150
|
+
onKeyDownCapture: handleOnKeydown
|
|
151
|
+
}, columnResizer, (0, _react2.jsx)(_drag_and_drop.EuiDraggable, {
|
|
152
|
+
draggableId: id,
|
|
153
|
+
className: "euiDataGridHeaderCellDraggable",
|
|
154
|
+
css: styles.euiDataGridHeaderCellDraggable,
|
|
155
|
+
index: index,
|
|
156
|
+
customDragHandle: "custom",
|
|
157
|
+
hasInteractiveChildren: true,
|
|
158
|
+
usePortal: true
|
|
159
|
+
}, function (_ref4, _ref5) {
|
|
160
|
+
var dragHandleProps = _ref4.dragHandleProps;
|
|
161
|
+
var isDragging = _ref5.isDragging,
|
|
162
|
+
mode = _ref5.mode;
|
|
163
|
+
updateDraggingRef(isDragging);
|
|
164
|
+
var _ref6 = dragHandleProps !== null && dragHandleProps !== void 0 ? dragHandleProps : {},
|
|
165
|
+
role = _ref6.role,
|
|
166
|
+
tabIndex = _ref6.tabIndex,
|
|
167
|
+
restDragHandleProps = _objectWithoutProperties(_ref6, _excluded);
|
|
168
|
+
var passedProps = _objectSpread(_objectSpread({}, restDragHandleProps), {}, {
|
|
169
|
+
css: reapplyCellStyles,
|
|
170
|
+
'data-column-moving': isDraggingRef.current || undefined,
|
|
171
|
+
isDragging: isDragging
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// since the cloned content is in a portal outside the datagrid
|
|
175
|
+
// we need to re-add styles to the cell as the scoped styles
|
|
176
|
+
// from the wrapper don't apply
|
|
177
|
+
var draggingStyles = [styles.euiDataGridHeaderCellDraggable,
|
|
178
|
+
// ensure height is maintained while dragging
|
|
179
|
+
dataGridStyles.cellPadding[gridStyles.cellPadding], dataGridStyles.fontSize[gridStyles.fontSize], dataGridStyles.borders[gridStyles.border], mode === 'SNAP' && styles.isKeyboardDragging];
|
|
180
|
+
return isDragging ? (0, _react2.jsx)("div", {
|
|
181
|
+
css: draggingStyles
|
|
182
|
+
}, (0, _react2.jsx)(DragOverlay, {
|
|
183
|
+
isDragging: true,
|
|
184
|
+
cursor: "grabbing"
|
|
185
|
+
}), children(passedProps)) : children(passedProps);
|
|
186
|
+
}));
|
|
187
|
+
});
|
|
188
|
+
DraggableColumn.propTypes = {
|
|
189
|
+
id: _propTypes.default.string.isRequired,
|
|
190
|
+
index: _propTypes.default.number.isRequired,
|
|
191
|
+
gridStyles: _propTypes.default.shape({
|
|
192
|
+
/**
|
|
193
|
+
* Size of fonts used within the row and column cells
|
|
194
|
+
* @default m
|
|
195
|
+
*/
|
|
196
|
+
fontSize: _propTypes.default.oneOf(["s", "m", "l"]),
|
|
197
|
+
/**
|
|
198
|
+
* Defines the padding with the row and column cells
|
|
199
|
+
* @default m
|
|
200
|
+
*/
|
|
201
|
+
cellPadding: _propTypes.default.oneOf(["s", "m", "l"]),
|
|
202
|
+
/**
|
|
203
|
+
* Border used for the row and column cells
|
|
204
|
+
* @default all
|
|
205
|
+
*/
|
|
206
|
+
border: _propTypes.default.oneOf(["all", "horizontal", "none"]),
|
|
207
|
+
/**
|
|
208
|
+
* If set to true, rows will alternate zebra striping for clarity
|
|
209
|
+
* @default false
|
|
210
|
+
*/
|
|
211
|
+
stripes: _propTypes.default.bool,
|
|
212
|
+
/**
|
|
213
|
+
* Visual style for the column headers. Recommendation is to use the `underline` style in times when #EuiDataGrid `toolbarVisibility` is set to `false`.
|
|
214
|
+
* @default shade
|
|
215
|
+
*/
|
|
216
|
+
header: _propTypes.default.oneOf(["shade", "underline"]),
|
|
217
|
+
/**
|
|
218
|
+
* Visual style for the column footers.
|
|
219
|
+
* @default overline
|
|
220
|
+
*/
|
|
221
|
+
footer: _propTypes.default.oneOf(["shade", "overline", "striped"]),
|
|
222
|
+
/**
|
|
223
|
+
* If set to true, the footer row will be sticky
|
|
224
|
+
* @default true
|
|
225
|
+
*/
|
|
226
|
+
stickyFooter: _propTypes.default.bool,
|
|
227
|
+
/**
|
|
228
|
+
* Will define what visual style to show on row hover
|
|
229
|
+
* @default hover
|
|
230
|
+
*/
|
|
231
|
+
rowHover: _propTypes.default.oneOf(["highlight", "none"]),
|
|
232
|
+
/**
|
|
233
|
+
* Optionally pass custom classes to highlight or customize certain rows
|
|
234
|
+
*/
|
|
235
|
+
rowClasses: _propTypes.default.shape({}),
|
|
236
|
+
/**
|
|
237
|
+
* Optional callback returning the current `gridStyle` config when changes occur from user input (e.g. toolbar display controls).
|
|
238
|
+
* Can be used for, e.g. storing user `gridStyle` in a local storage object.
|
|
239
|
+
*/
|
|
240
|
+
onChange: _propTypes.default.func
|
|
241
|
+
}).isRequired,
|
|
242
|
+
columnResizer: _propTypes.default.node,
|
|
243
|
+
actionsPopoverToggle: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.oneOf([null])]),
|
|
244
|
+
children: _propTypes.default.func.isRequired
|
|
245
|
+
};
|
|
246
|
+
DraggableColumn.displayName = 'DraggableColumn';
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Components for conditionally rendering drag/drop wrappers
|
|
250
|
+
* Allows us to conditionally call hooks while not instantiating a bunch
|
|
251
|
+
* of extra state/etc., since draggable columns isn't yet(?) a default
|
|
252
|
+
*/
|
|
253
|
+
|
|
254
|
+
var ConditionalDroppableColumns = exports.ConditionalDroppableColumns = /*#__PURE__*/(0, _react.memo)(function (_ref7) {
|
|
255
|
+
var canDragAndDropColumns = _ref7.canDragAndDropColumns,
|
|
256
|
+
children = _ref7.children,
|
|
257
|
+
rest = _objectWithoutProperties(_ref7, _excluded2);
|
|
258
|
+
return canDragAndDropColumns ? (0, _react2.jsx)(DroppableColumns, rest, children) : (0, _react2.jsx)(_react.default.Fragment, null, children);
|
|
259
|
+
});
|
|
260
|
+
ConditionalDroppableColumns.propTypes = {
|
|
261
|
+
canDragAndDropColumns: _propTypes.default.bool.isRequired
|
|
262
|
+
};
|
|
263
|
+
ConditionalDroppableColumns.displayName = 'ConditionalDroppableColumns';
|
|
264
|
+
var ConditionalDraggableColumn = exports.ConditionalDraggableColumn = /*#__PURE__*/(0, _react.memo)(function (_ref8) {
|
|
265
|
+
var canDragAndDropColumns = _ref8.canDragAndDropColumns,
|
|
266
|
+
children = _ref8.children,
|
|
267
|
+
rest = _objectWithoutProperties(_ref8, _excluded3);
|
|
268
|
+
return canDragAndDropColumns ? (0, _react2.jsx)(DraggableColumn, rest, children) : (0, _react2.jsx)(_react.default.Fragment, null, children());
|
|
269
|
+
});
|
|
270
|
+
ConditionalDraggableColumn.propTypes = {
|
|
271
|
+
canDragAndDropColumns: _propTypes.default.bool.isRequired
|
|
272
|
+
};
|
|
273
|
+
ConditionalDraggableColumn.displayName = 'ConditionalDraggableColumn';
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Creates an invisible overlay that prevents hover interactions/transitions
|
|
277
|
+
* on other elements that the dragged element is dragged over, and also maintains
|
|
278
|
+
* the intended drag cursor over any location.
|
|
279
|
+
*
|
|
280
|
+
* TODO: If this is useful elsewhere, consider moving it to `src/services`
|
|
281
|
+
*/
|
|
282
|
+
var _ref10 = process.env.NODE_ENV === "production" ? {
|
|
283
|
+
name: "q8wbl-DragOverlay",
|
|
284
|
+
styles: "position:fixed;inset:0;label:DragOverlay;"
|
|
285
|
+
} : {
|
|
286
|
+
name: "q8wbl-DragOverlay",
|
|
287
|
+
styles: "position:fixed;inset:0;label:DragOverlay;",
|
|
288
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
289
|
+
};
|
|
290
|
+
var DragOverlay = exports.DragOverlay = /*#__PURE__*/(0, _react.memo)(function (_ref9) {
|
|
291
|
+
var isDragging = _ref9.isDragging,
|
|
292
|
+
cursor = _ref9.cursor,
|
|
293
|
+
_ref9$zIndex = _ref9.zIndex,
|
|
294
|
+
zIndex = _ref9$zIndex === void 0 ? 9999 : _ref9$zIndex;
|
|
295
|
+
return isDragging ? (0, _react2.jsx)(_portal.EuiPortal, null, (0, _react2.jsx)("div", {
|
|
296
|
+
css: _ref10,
|
|
297
|
+
style: {
|
|
298
|
+
cursor: cursor,
|
|
299
|
+
zIndex: zIndex
|
|
300
|
+
}
|
|
301
|
+
})) : null;
|
|
302
|
+
});
|
|
303
|
+
DragOverlay.propTypes = {
|
|
304
|
+
isDragging: _propTypes.default.bool,
|
|
305
|
+
cursor: _propTypes.default.any,
|
|
306
|
+
zIndex: _propTypes.default.any
|
|
307
|
+
};
|
|
308
|
+
DragOverlay.displayName = 'DragOverlay';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.euiDataGridDraggableHeaderStyles = void 0;
|
|
7
|
+
var _react = require("@emotion/react");
|
|
8
|
+
var _global_styling = require("../../../../global_styling");
|
|
9
|
+
var _templateObject;
|
|
10
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
11
|
+
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } /*
|
|
12
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
13
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
14
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
15
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
16
|
+
* Side Public License, v 1.
|
|
17
|
+
*/
|
|
18
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
19
|
+
name: "pfqu74-euiDataGridHeaderDroppable",
|
|
20
|
+
styles: "display:flex;label:euiDataGridHeaderDroppable;"
|
|
21
|
+
} : {
|
|
22
|
+
name: "pfqu74-euiDataGridHeaderDroppable",
|
|
23
|
+
styles: "display:flex;label:euiDataGridHeaderDroppable;",
|
|
24
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
25
|
+
};
|
|
26
|
+
var euiDataGridDraggableHeaderStyles = exports.euiDataGridDraggableHeaderStyles = function euiDataGridDraggableHeaderStyles(_ref2) {
|
|
27
|
+
var euiTheme = _ref2.euiTheme;
|
|
28
|
+
return {
|
|
29
|
+
euiDataGridHeaderDroppable: _ref,
|
|
30
|
+
// The resizer must be positioned outside the draggable component to ensure both work independently
|
|
31
|
+
euiDataGridHeaderCellDraggableWrapper: /*#__PURE__*/(0, _react.css)("position:relative;.euiDataGridColumnResizer::after{", (0, _global_styling.logicalCSS)('margin-left', "-".concat(euiTheme.border.width.thick)), ";};label:euiDataGridHeaderCellDraggableWrapper;"),
|
|
32
|
+
// override internal styling from @hello-pangea/dnd to ensure positioning
|
|
33
|
+
euiDataGridHeaderCellDraggable: /*#__PURE__*/(0, _react.css)("display:flex;", (0, _global_styling.logicalCSS)('height', '100%'), ";;label:euiDataGridHeaderCellDraggable;"),
|
|
34
|
+
// Add more visual affordance to keyboard drags (raises cell slightly to show green droppable bg)
|
|
35
|
+
// Using animation as transition doesn't seem to work (a tale as old as EuiDataGrid...)
|
|
36
|
+
isKeyboardDragging: /*#__PURE__*/(0, _react.css)("animation-name:", (0, _react.keyframes)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from { transform: translateY(0); }\n to { transform: translateY(-", "); }\n "])), euiTheme.size.s), ";animation-iteration-count:1;animation-fill-mode:forwards;", _global_styling.euiCanAnimate, "{animation-duration:", euiTheme.animation.fast, ";};label:isKeyboardDragging;"),
|
|
37
|
+
// Ensure correct cell background colors on drag
|
|
38
|
+
underline: /*#__PURE__*/(0, _react.css)("background-color:", euiTheme.colors.emptyShade, ";;label:underline;"),
|
|
39
|
+
shade: /*#__PURE__*/(0, _react.css)("background-color:", euiTheme.colors.lightestShade, ";;label:shade;"),
|
|
40
|
+
noLeadingBorder: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('border-left', 'none !important'), ";;label:noLeadingBorder;")
|
|
41
|
+
};
|
|
42
|
+
};
|
|
@@ -410,7 +410,8 @@ var EuiDataGrid = exports.EuiDataGrid = /*#__PURE__*/(0, _react.memo)( /*#__PURE
|
|
|
410
410
|
gridRef: gridRef,
|
|
411
411
|
gridItemsRendered: gridItemsRendered,
|
|
412
412
|
wrapperRef: contentRef,
|
|
413
|
-
renderCustomGridBody: renderCustomGridBody
|
|
413
|
+
renderCustomGridBody: renderCustomGridBody,
|
|
414
|
+
canDragAndDropColumns: columnVisibility.canDragAndDropColumns
|
|
414
415
|
}))), showPagination && props['aria-labelledby'] && (0, _react2.jsx)("p", {
|
|
415
416
|
id: ariaLabelledById,
|
|
416
417
|
hidden: true
|
|
@@ -122,9 +122,6 @@ var columns = [{
|
|
|
122
122
|
"aria-label": "Send email to ".concat(value)
|
|
123
123
|
}, "Send email");
|
|
124
124
|
}]
|
|
125
|
-
}, {
|
|
126
|
-
id: 'location',
|
|
127
|
-
displayAsText: 'Location'
|
|
128
125
|
}, {
|
|
129
126
|
id: 'account',
|
|
130
127
|
displayAsText: 'Account',
|
|
@@ -159,6 +156,9 @@ var columns = [{
|
|
|
159
156
|
"aria-label": "Send money to ".concat(value)
|
|
160
157
|
}, "Send money");
|
|
161
158
|
}]
|
|
159
|
+
}, {
|
|
160
|
+
id: 'location',
|
|
161
|
+
displayAsText: 'Location'
|
|
162
162
|
}, {
|
|
163
163
|
id: 'date',
|
|
164
164
|
displayAsText: 'Date',
|
|
@@ -239,7 +239,8 @@ var defaultStorybookArgs = exports.defaultStorybookArgs = {
|
|
|
239
239
|
// setup for easier testing/QA
|
|
240
240
|
columnVisibility: {
|
|
241
241
|
visibleColumns: ['name', 'email', 'account', 'location', 'date', 'amount', 'phone', 'version'],
|
|
242
|
-
setVisibleColumns: function setVisibleColumns() {}
|
|
242
|
+
setVisibleColumns: function setVisibleColumns() {},
|
|
243
|
+
canDragAndDropColumns: false
|
|
243
244
|
},
|
|
244
245
|
inMemory: {
|
|
245
246
|
level: 'sorting'
|
|
@@ -350,7 +351,8 @@ var StatefulDataGrid = exports.StatefulDataGrid = function StatefulDataGrid(prop
|
|
|
350
351
|
return (0, _react2.jsx)(_data_grid.EuiDataGrid, _extends({}, rest, {
|
|
351
352
|
columnVisibility: {
|
|
352
353
|
visibleColumns: visibleColumns,
|
|
353
|
-
setVisibleColumns: setVisibleColumns
|
|
354
|
+
setVisibleColumns: setVisibleColumns,
|
|
355
|
+
canDragAndDropColumns: columnVisibility.canDragAndDropColumns
|
|
354
356
|
},
|
|
355
357
|
sorting: {
|
|
356
358
|
columns: sortingColumns,
|
|
@@ -859,7 +861,8 @@ EuiDataGridToolbarPropsComponent.propTypes = {
|
|
|
859
861
|
/**
|
|
860
862
|
* A callback for when a column's visibility or order is modified by the user.
|
|
861
863
|
*/
|
|
862
|
-
setVisibleColumns: _propTypes.default.func.isRequired
|
|
864
|
+
setVisibleColumns: _propTypes.default.func.isRequired,
|
|
865
|
+
/** Enables reordering grid columns on drag and drop via the headers cells */canDragAndDropColumns: _propTypes.default.bool
|
|
863
866
|
}).isRequired,
|
|
864
867
|
/**
|
|
865
868
|
* An array of custom #EuiDataGridSchemaDetector objects. You can inject custom schemas to the grid to define the classnames applied.
|
|
@@ -80,12 +80,10 @@ var useColumnWidths = exports.useColumnWidths = function useColumnWidths(_ref) {
|
|
|
80
80
|
setColumnWidths(function (prevColumnWidths) {
|
|
81
81
|
return _objectSpread(_objectSpread({}, prevColumnWidths), {}, _defineProperty({}, columnId, width));
|
|
82
82
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
}
|
|
83
|
+
onColumnResize === null || onColumnResize === void 0 || onColumnResize({
|
|
84
|
+
columnId: columnId,
|
|
85
|
+
width: width
|
|
86
|
+
});
|
|
89
87
|
}, [onColumnResize]);
|
|
90
88
|
|
|
91
89
|
// Used by react-window to determine actual column widths
|
|
@@ -51,11 +51,11 @@ var useFocus = exports.useFocus = function useFocus() {
|
|
|
51
51
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
52
52
|
focusedCell = _useState4[0],
|
|
53
53
|
_setFocusedCell = _useState4[1];
|
|
54
|
-
var setFocusedCell = (0, _react.useCallback)(function (nextFocusedCell) {
|
|
54
|
+
var setFocusedCell = (0, _react.useCallback)(function (nextFocusedCell, forceUpdate) {
|
|
55
55
|
_setFocusedCell(function (prevFocusedCell) {
|
|
56
56
|
// If the x/y coordinates remained the same, don't update. This keeps the focusedCell
|
|
57
57
|
// reference stable, and allows it to be used in places that need reference equality.
|
|
58
|
-
if (nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
58
|
+
if (!forceUpdate && nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
59
59
|
return prevFocusedCell;
|
|
60
60
|
} else {
|
|
61
61
|
setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view
|