@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
|
@@ -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.
|
|
@@ -70,12 +70,10 @@ var useColumnWidths = exports.useColumnWidths = function useColumnWidths(_ref) {
|
|
|
70
70
|
setColumnWidths(function (prevColumnWidths) {
|
|
71
71
|
return _objectSpread(_objectSpread({}, prevColumnWidths), {}, (0, _defineProperty2.default)({}, columnId, width));
|
|
72
72
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
});
|
|
78
|
-
}
|
|
73
|
+
onColumnResize === null || onColumnResize === void 0 || onColumnResize({
|
|
74
|
+
columnId: columnId,
|
|
75
|
+
width: width
|
|
76
|
+
});
|
|
79
77
|
}, [onColumnResize]);
|
|
80
78
|
|
|
81
79
|
// Used by react-window to determine actual column widths
|
|
@@ -49,11 +49,11 @@ var useFocus = exports.useFocus = function useFocus() {
|
|
|
49
49
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
50
50
|
focusedCell = _useState4[0],
|
|
51
51
|
_setFocusedCell = _useState4[1];
|
|
52
|
-
var setFocusedCell = (0, _react.useCallback)(function (nextFocusedCell) {
|
|
52
|
+
var setFocusedCell = (0, _react.useCallback)(function (nextFocusedCell, forceUpdate) {
|
|
53
53
|
_setFocusedCell(function (prevFocusedCell) {
|
|
54
54
|
// If the x/y coordinates remained the same, don't update. This keeps the focusedCell
|
|
55
55
|
// reference stable, and allows it to be used in places that need reference equality.
|
|
56
|
-
if (nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
56
|
+
if (!forceUpdate && nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
57
57
|
return prevFocusedCell;
|
|
58
58
|
} else {
|
|
59
59
|
setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view
|
|
@@ -71,7 +71,8 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
71
71
|
headerRowHeight = _ref.headerRowHeight,
|
|
72
72
|
footerRowHeight = _ref.footerRowHeight,
|
|
73
73
|
visibleRowCount = _ref.visibleRowCount,
|
|
74
|
-
hasStickyFooter = _ref.hasStickyFooter
|
|
74
|
+
hasStickyFooter = _ref.hasStickyFooter,
|
|
75
|
+
canDragAndDropColumns = _ref.canDragAndDropColumns;
|
|
75
76
|
var scrollCellIntoView = (0, _react.useCallback)(
|
|
76
77
|
/*#__PURE__*/
|
|
77
78
|
// Note: in order for this UX to work correctly with react-window's APIs,
|
|
@@ -82,7 +83,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
82
83
|
var rowIndex = _ref3.rowIndex,
|
|
83
84
|
colIndex = _ref3.colIndex;
|
|
84
85
|
return /*#__PURE__*/_regenerator.default.mark(function _callee(_adjustedScrollLeft) {
|
|
85
|
-
var getCell, cell, cellIsInView, _outerGridRef$current, scrollTop, scrollLeft, adjustedScrollTop, adjustedScrollLeft, cellRightPos, rightScrollBound, rightWidthOutOfView,
|
|
86
|
+
var getCell, cell, cellIsInView, isStickyHeader, isStickyFooter, isDraggableHeader, isDraggableHeaderCell, _outerGridRef$current, scrollTop, scrollLeft, adjustedScrollTop, adjustedScrollLeft, cellLeftPos, cellRightPos, rightScrollBound, rightWidthOutOfView, leftScrollBound, leftWidthOutOfView, _adjustedScrollTop, parentRow, cellBottomPos, bottomScrollBound, bottomHeightOutOfView, cellTopPos, topScrollBound, topHeightOutOfView, _adjustedScrollLeft2, _adjustedScrollTop2;
|
|
86
87
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
87
88
|
while (1) switch (_context.prev = _context.next) {
|
|
88
89
|
case 0:
|
|
@@ -128,7 +129,10 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
128
129
|
return _context.abrupt("return");
|
|
129
130
|
case 14:
|
|
130
131
|
// If for some reason we can't find a valid cell, short-circuit
|
|
131
|
-
|
|
132
|
+
isStickyHeader = rowIndex === -1;
|
|
133
|
+
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
134
|
+
isDraggableHeader = canDragAndDropColumns && isStickyHeader;
|
|
135
|
+
isDraggableHeaderCell = isDraggableHeader && cell.offsetLeft === 0 && colIndex !== 0; // We now manually adjust scroll positioning around the cell to ensure it's
|
|
132
136
|
// fully in view on all sides. A couple of notes on this:
|
|
133
137
|
// 1. We're avoiding relying on react-window's scrollToItem for this because it also
|
|
134
138
|
// does not account for sticky items (see https://github.com/bvaughn/react-window/issues/586)
|
|
@@ -137,8 +141,10 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
137
141
|
// halfway there, but doesn't guarantee the *full* cell in view, or account for
|
|
138
142
|
// sticky positioned rows or OS scrollbars, hence these workarounds
|
|
139
143
|
_outerGridRef$current = outerGridRef.current, scrollTop = _outerGridRef$current.scrollTop, scrollLeft = _outerGridRef$current.scrollLeft;
|
|
140
|
-
//
|
|
141
|
-
|
|
144
|
+
// Draggable header columns are nested within EuiDraggables,
|
|
145
|
+
// and their offsetLeft needs to go up a wrapper as a result
|
|
146
|
+
cellLeftPos = isDraggableHeaderCell ? cell.offsetParent.offsetLeft : cell.offsetLeft; // Check if the cell's right side is outside the current scrolling bounds
|
|
147
|
+
cellRightPos = cellLeftPos + cell.offsetWidth;
|
|
142
148
|
rightScrollBound = scrollLeft + outerGridRef.current.clientWidth; // Note: We specifically want clientWidth and not offsetWidth here to account for scrollbars
|
|
143
149
|
rightWidthOutOfView = cellRightPos - rightScrollBound;
|
|
144
150
|
if (rightWidthOutOfView > 0) {
|
|
@@ -146,7 +152,6 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
146
152
|
}
|
|
147
153
|
|
|
148
154
|
// Check if the cell's left side is outside the current scrolling bounds
|
|
149
|
-
cellLeftPos = cell.offsetLeft;
|
|
150
155
|
leftScrollBound = (_adjustedScrollLeft = adjustedScrollLeft) !== null && _adjustedScrollLeft !== void 0 ? _adjustedScrollLeft : scrollLeft;
|
|
151
156
|
leftWidthOutOfView = leftScrollBound - cellLeftPos;
|
|
152
157
|
if (leftWidthOutOfView > 0) {
|
|
@@ -157,8 +162,6 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
157
162
|
|
|
158
163
|
// Skip top/bottom scroll adjustments for sticky headers & footers
|
|
159
164
|
// since they should always be in view vertically
|
|
160
|
-
isStickyHeader = rowIndex === -1;
|
|
161
|
-
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
162
165
|
if (!isStickyHeader && !isStickyFooter) {
|
|
163
166
|
parentRow = cell.parentNode; // Check if the cell's bottom side is outside the current scrolling bounds
|
|
164
167
|
cellBottomPos = parentRow.offsetTop + cell.offsetHeight;
|
|
@@ -188,7 +191,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
188
191
|
scrollTop: (_adjustedScrollTop2 = adjustedScrollTop) !== null && _adjustedScrollTop2 !== void 0 ? _adjustedScrollTop2 : scrollTop
|
|
189
192
|
});
|
|
190
193
|
}
|
|
191
|
-
case
|
|
194
|
+
case 29:
|
|
192
195
|
case "end":
|
|
193
196
|
return _context.stop();
|
|
194
197
|
}
|
|
@@ -198,7 +201,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
198
201
|
return function (_x) {
|
|
199
202
|
return _ref2.apply(this, arguments);
|
|
200
203
|
};
|
|
201
|
-
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter]);
|
|
204
|
+
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter, canDragAndDropColumns]);
|
|
202
205
|
return {
|
|
203
206
|
scrollCellIntoView: scrollCellIntoView
|
|
204
207
|
};
|
|
@@ -42,6 +42,8 @@ var EuiAbsoluteTab = exports.EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
42
42
|
locale = _ref.locale,
|
|
43
43
|
roundUp = _ref.roundUp,
|
|
44
44
|
utcOffset = _ref.utcOffset,
|
|
45
|
+
minDate = _ref.minDate,
|
|
46
|
+
maxDate = _ref.maxDate,
|
|
45
47
|
labelPrefix = _ref.labelPrefix;
|
|
46
48
|
var styles = (0, _services.useEuiMemoizedStyles)(_absolute_tab.euiAbsoluteTabDateFormStyles);
|
|
47
49
|
var _useState = (0, _react.useState)(function () {
|
|
@@ -135,7 +137,9 @@ var EuiAbsoluteTab = exports.EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
135
137
|
dateFormat: dateFormat,
|
|
136
138
|
timeFormat: timeFormat,
|
|
137
139
|
locale: locale,
|
|
138
|
-
utcOffset: utcOffset
|
|
140
|
+
utcOffset: utcOffset,
|
|
141
|
+
minDate: minDate,
|
|
142
|
+
maxDate: maxDate
|
|
139
143
|
}), (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
140
144
|
component: "form",
|
|
141
145
|
onSubmit: function onSubmit(e) {
|
|
@@ -180,5 +184,7 @@ EuiAbsoluteTab.propTypes = {
|
|
|
180
184
|
onChange: _propTypes.default.func.isRequired,
|
|
181
185
|
roundUp: _propTypes.default.bool.isRequired,
|
|
182
186
|
labelPrefix: _propTypes.default.string.isRequired,
|
|
183
|
-
utcOffset: _propTypes.default.number
|
|
187
|
+
utcOffset: _propTypes.default.number,
|
|
188
|
+
minDate: _propTypes.default.any,
|
|
189
|
+
maxDate: _propTypes.default.any
|
|
184
190
|
};
|
package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js
CHANGED
|
@@ -17,7 +17,7 @@ var _pretty_duration = require("../pretty_duration");
|
|
|
17
17
|
var _date_popover_content = require("./date_popover_content");
|
|
18
18
|
var _date_popover_button = require("./date_popover_button.styles");
|
|
19
19
|
var _react2 = require("@emotion/react");
|
|
20
|
-
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
20
|
+
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "minDate", "maxDate", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
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
|
|
@@ -39,6 +39,8 @@ var EuiDatePopoverButton = exports.EuiDatePopoverButton = function EuiDatePopove
|
|
|
39
39
|
locale = props.locale,
|
|
40
40
|
dateFormat = props.dateFormat,
|
|
41
41
|
utcOffset = props.utcOffset,
|
|
42
|
+
minDate = props.minDate,
|
|
43
|
+
maxDate = props.maxDate,
|
|
42
44
|
timeFormat = props.timeFormat,
|
|
43
45
|
isOpen = props.isOpen,
|
|
44
46
|
onPopoverToggle = props.onPopoverToggle,
|
|
@@ -99,7 +101,9 @@ var EuiDatePopoverButton = exports.EuiDatePopoverButton = function EuiDatePopove
|
|
|
99
101
|
locale: locale,
|
|
100
102
|
position: position,
|
|
101
103
|
utcOffset: utcOffset,
|
|
102
|
-
timeOptions: timeOptions
|
|
104
|
+
timeOptions: timeOptions,
|
|
105
|
+
minDate: minDate,
|
|
106
|
+
maxDate: maxDate
|
|
103
107
|
}));
|
|
104
108
|
};
|
|
105
109
|
EuiDatePopoverButton.propTypes = {
|
|
@@ -125,6 +129,8 @@ EuiDatePopoverButton.propTypes = {
|
|
|
125
129
|
timeFormat: _propTypes.default.string.isRequired,
|
|
126
130
|
value: _propTypes.default.string.isRequired,
|
|
127
131
|
utcOffset: _propTypes.default.number,
|
|
132
|
+
minDate: _propTypes.default.any,
|
|
133
|
+
maxDate: _propTypes.default.any,
|
|
128
134
|
compressed: _propTypes.default.bool,
|
|
129
135
|
timeOptions: _propTypes.default.shape({
|
|
130
136
|
timeTenseOptions: _propTypes.default.arrayOf(_propTypes.default.any.isRequired).isRequired,
|
package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js
CHANGED
|
@@ -38,7 +38,9 @@ var EuiDatePopoverContent = exports.EuiDatePopoverContent = function EuiDatePopo
|
|
|
38
38
|
locale = _ref.locale,
|
|
39
39
|
position = _ref.position,
|
|
40
40
|
utcOffset = _ref.utcOffset,
|
|
41
|
-
timeOptions = _ref.timeOptions
|
|
41
|
+
timeOptions = _ref.timeOptions,
|
|
42
|
+
minDate = _ref.minDate,
|
|
43
|
+
maxDate = _ref.maxDate;
|
|
42
44
|
var styles = (0, _services.useEuiMemoizedStyles)(_date_popover_content.euiDatePopoverContentStyles);
|
|
43
45
|
var onTabClick = function onTabClick(selectedTab) {
|
|
44
46
|
switch (selectedTab.id) {
|
|
@@ -67,7 +69,9 @@ var EuiDatePopoverContent = exports.EuiDatePopoverContent = function EuiDatePopo
|
|
|
67
69
|
onChange: onChange,
|
|
68
70
|
roundUp: roundUp,
|
|
69
71
|
labelPrefix: labelPrefix,
|
|
70
|
-
utcOffset: utcOffset
|
|
72
|
+
utcOffset: utcOffset,
|
|
73
|
+
minDate: minDate,
|
|
74
|
+
maxDate: maxDate
|
|
71
75
|
}),
|
|
72
76
|
'data-test-subj': 'superDatePickerAbsoluteTab',
|
|
73
77
|
'aria-label': "".concat(labelPrefix, ": ").concat(absoluteLabel)
|
|
@@ -137,6 +141,8 @@ EuiDatePopoverContent.propTypes = {
|
|
|
137
141
|
locale: _propTypes.default.any,
|
|
138
142
|
position: _propTypes.default.oneOf(["start", "end"]).isRequired,
|
|
139
143
|
utcOffset: _propTypes.default.number,
|
|
144
|
+
minDate: _propTypes.default.any,
|
|
145
|
+
maxDate: _propTypes.default.any,
|
|
140
146
|
timeOptions: _propTypes.default.shape({
|
|
141
147
|
timeTenseOptions: _propTypes.default.arrayOf(_propTypes.default.any.isRequired).isRequired,
|
|
142
148
|
timeUnitsOptions: _propTypes.default.arrayOf(_propTypes.default.any.isRequired).isRequired,
|