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