@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
package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js
CHANGED
|
@@ -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,231 @@
|
|
|
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 _services = require("../../../../services");
|
|
13
|
+
var _drag_and_drop = require("../../../drag_and_drop");
|
|
14
|
+
var _portal = require("../../../portal");
|
|
15
|
+
var _focus = require("../../utils/focus");
|
|
16
|
+
var _data_grid = require("../../data_grid.styles");
|
|
17
|
+
var _draggable_columns = require("./draggable_columns.styles");
|
|
18
|
+
var _react2 = require("@emotion/react");
|
|
19
|
+
var _excluded = ["role", "tabIndex"],
|
|
20
|
+
_excluded2 = ["canDragAndDropColumns", "children"],
|
|
21
|
+
_excluded3 = ["canDragAndDropColumns", "children"];
|
|
22
|
+
/*
|
|
23
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
24
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
25
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
26
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
27
|
+
* Side Public License, v 1.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Parent context + EuiDroppable wrapper
|
|
31
|
+
*/
|
|
32
|
+
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); }
|
|
33
|
+
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; }
|
|
34
|
+
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)."; }
|
|
35
|
+
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; }
|
|
36
|
+
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; }
|
|
37
|
+
var DroppableColumns = exports.DroppableColumns = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
38
|
+
var columns = _ref.columns,
|
|
39
|
+
switchColumnPos = _ref.switchColumnPos,
|
|
40
|
+
indexOffset = _ref.indexOffset,
|
|
41
|
+
children = _ref.children;
|
|
42
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_draggable_columns.euiDataGridDraggableHeaderStyles);
|
|
43
|
+
var droppableId = (0, _services.useGeneratedHtmlId)({
|
|
44
|
+
prefix: 'euiDataGridHeaderDroppable'
|
|
45
|
+
});
|
|
46
|
+
var _useContext = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
47
|
+
setFocusedCell = _useContext.setFocusedCell;
|
|
48
|
+
var handleOnDragEnd = (0, _react.useCallback)(function (_ref2) {
|
|
49
|
+
var source = _ref2.source,
|
|
50
|
+
destination = _ref2.destination;
|
|
51
|
+
if (!source) return;
|
|
52
|
+
if (destination && destination.index !== source.index) {
|
|
53
|
+
var sourceColumn = columns[source.index - indexOffset];
|
|
54
|
+
var destinationColumn = columns[destination.index - indexOffset];
|
|
55
|
+
if (sourceColumn && destinationColumn) {
|
|
56
|
+
switchColumnPos(sourceColumn.id, destinationColumn.id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Force focus the cell to prevent the datagrid body from become unfocusable, including on drag cancel
|
|
60
|
+
setTimeout(function () {
|
|
61
|
+
var cellToFocus = destination ? destination.index : source.index;
|
|
62
|
+
setFocusedCell([cellToFocus, -1], true);
|
|
63
|
+
});
|
|
64
|
+
}, [columns, indexOffset, switchColumnPos, setFocusedCell]);
|
|
65
|
+
return (0, _react2.jsx)(_drag_and_drop.EuiDragDropContext, {
|
|
66
|
+
onDragEnd: handleOnDragEnd
|
|
67
|
+
}, (0, _react2.jsx)(_drag_and_drop.EuiDroppable, {
|
|
68
|
+
droppableId: droppableId,
|
|
69
|
+
direction: "horizontal",
|
|
70
|
+
ignoreContainerClipping: true,
|
|
71
|
+
css: styles.euiDataGridHeaderDroppable,
|
|
72
|
+
"data-test-subj": "euiDataGridHeaderDroppable"
|
|
73
|
+
}, children));
|
|
74
|
+
});
|
|
75
|
+
DroppableColumns.displayName = 'DroppableColumns';
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Individual EuiDraggable columns
|
|
79
|
+
*/
|
|
80
|
+
var DraggableColumn = exports.DraggableColumn = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
81
|
+
var id = _ref3.id,
|
|
82
|
+
index = _ref3.index,
|
|
83
|
+
gridStyles = _ref3.gridStyles,
|
|
84
|
+
columnResizer = _ref3.columnResizer,
|
|
85
|
+
actionsPopoverToggle = _ref3.actionsPopoverToggle,
|
|
86
|
+
children = _ref3.children;
|
|
87
|
+
var dataGridStyles = (0, _services.useEuiMemoizedStyles)(_data_grid.euiDataGridStyles);
|
|
88
|
+
var styles = (0, _services.useEuiMemoizedStyles)(_draggable_columns.euiDataGridDraggableHeaderStyles);
|
|
89
|
+
// Manually re-apply background and border overrides, since
|
|
90
|
+
// the droppable zone sets its own and confuses :first-of-type CSS
|
|
91
|
+
var reapplyCellStyles = [styles[gridStyles.header], index !== 0 && styles.noLeadingBorder];
|
|
92
|
+
|
|
93
|
+
// Draggable prevents the cell from receiving focus on click.
|
|
94
|
+
// We manually ensure focus is set on cell mouseDown which
|
|
95
|
+
// also includes setting focus before dragging
|
|
96
|
+
var _useContext2 = (0, _react.useContext)(_focus.DataGridFocusContext),
|
|
97
|
+
setFocusedCell = _useContext2.setFocusedCell;
|
|
98
|
+
var handleOnMouseDown = (0, _react.useCallback)(function (e) {
|
|
99
|
+
var openFocusTrap = document.querySelector('[data-focus-lock-disabled="false"]');
|
|
100
|
+
if (!!openFocusTrap &&
|
|
101
|
+
// If a focus trap is open somewhere on the page
|
|
102
|
+
!openFocusTrap.contains(e.target) &&
|
|
103
|
+
// & the focus trap doesn't belong to this header
|
|
104
|
+
e.target !== actionsPopoverToggle // & we're not closing the actions popover toggle
|
|
105
|
+
) {
|
|
106
|
+
// Trick the focus trap lib into registering an outside click -
|
|
107
|
+
// the drag/drop lib otherwise otherwise prevents the event 💀
|
|
108
|
+
document.dispatchEvent(new MouseEvent('mousedown'));
|
|
109
|
+
}
|
|
110
|
+
setTimeout(function () {
|
|
111
|
+
setFocusedCell([index, -1], true);
|
|
112
|
+
});
|
|
113
|
+
}, [setFocusedCell, index, actionsPopoverToggle]);
|
|
114
|
+
|
|
115
|
+
// Prevent any other keypresses when dragging
|
|
116
|
+
var isDraggingRef = (0, _react.useRef)(false);
|
|
117
|
+
var handleOnKeydown = (0, _react.useCallback)(function (e) {
|
|
118
|
+
if (isDraggingRef.current) {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
e.stopPropagation();
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
// UX polish: add a slight animation frame delay to the dragging ref end
|
|
126
|
+
// which prevents re-running the hover animation of column header actions
|
|
127
|
+
var updateDraggingRef = (0, _react.useCallback)(function (isDragging) {
|
|
128
|
+
// Only update if the state has changed from before
|
|
129
|
+
if (isDragging !== isDraggingRef.current) {
|
|
130
|
+
if (!isDragging) {
|
|
131
|
+
requestAnimationFrame(function () {
|
|
132
|
+
isDraggingRef.current = false;
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
isDraggingRef.current = true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, []);
|
|
139
|
+
return (0, _react2.jsx)("div", {
|
|
140
|
+
css: styles.euiDataGridHeaderCellDraggableWrapper,
|
|
141
|
+
onMouseDown: handleOnMouseDown,
|
|
142
|
+
onKeyDownCapture: handleOnKeydown
|
|
143
|
+
}, columnResizer, (0, _react2.jsx)(_drag_and_drop.EuiDraggable, {
|
|
144
|
+
draggableId: id,
|
|
145
|
+
className: "euiDataGridHeaderCellDraggable",
|
|
146
|
+
css: styles.euiDataGridHeaderCellDraggable,
|
|
147
|
+
index: index,
|
|
148
|
+
customDragHandle: "custom",
|
|
149
|
+
hasInteractiveChildren: true,
|
|
150
|
+
usePortal: true
|
|
151
|
+
}, function (_ref4, _ref5) {
|
|
152
|
+
var dragHandleProps = _ref4.dragHandleProps;
|
|
153
|
+
var isDragging = _ref5.isDragging,
|
|
154
|
+
mode = _ref5.mode;
|
|
155
|
+
updateDraggingRef(isDragging);
|
|
156
|
+
var _ref6 = dragHandleProps !== null && dragHandleProps !== void 0 ? dragHandleProps : {},
|
|
157
|
+
role = _ref6.role,
|
|
158
|
+
tabIndex = _ref6.tabIndex,
|
|
159
|
+
restDragHandleProps = (0, _objectWithoutProperties2.default)(_ref6, _excluded);
|
|
160
|
+
var passedProps = _objectSpread(_objectSpread({}, restDragHandleProps), {}, {
|
|
161
|
+
css: reapplyCellStyles,
|
|
162
|
+
'data-column-moving': isDraggingRef.current || undefined,
|
|
163
|
+
isDragging: isDragging
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// since the cloned content is in a portal outside the datagrid
|
|
167
|
+
// we need to re-add styles to the cell as the scoped styles
|
|
168
|
+
// from the wrapper don't apply
|
|
169
|
+
var draggingStyles = [styles.euiDataGridHeaderCellDraggable,
|
|
170
|
+
// ensure height is maintained while dragging
|
|
171
|
+
dataGridStyles.cellPadding[gridStyles.cellPadding], dataGridStyles.fontSize[gridStyles.fontSize], dataGridStyles.borders[gridStyles.border], mode === 'SNAP' && styles.isKeyboardDragging];
|
|
172
|
+
return isDragging ? (0, _react2.jsx)("div", {
|
|
173
|
+
css: draggingStyles
|
|
174
|
+
}, (0, _react2.jsx)(DragOverlay, {
|
|
175
|
+
isDragging: true,
|
|
176
|
+
cursor: "grabbing"
|
|
177
|
+
}), children(passedProps)) : children(passedProps);
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
DraggableColumn.displayName = 'DraggableColumn';
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Components for conditionally rendering drag/drop wrappers
|
|
184
|
+
* Allows us to conditionally call hooks while not instantiating a bunch
|
|
185
|
+
* of extra state/etc., since draggable columns isn't yet(?) a default
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
var ConditionalDroppableColumns = exports.ConditionalDroppableColumns = /*#__PURE__*/(0, _react.memo)(function (_ref7) {
|
|
189
|
+
var canDragAndDropColumns = _ref7.canDragAndDropColumns,
|
|
190
|
+
children = _ref7.children,
|
|
191
|
+
rest = (0, _objectWithoutProperties2.default)(_ref7, _excluded2);
|
|
192
|
+
return canDragAndDropColumns ? (0, _react2.jsx)(DroppableColumns, rest, children) : (0, _react2.jsx)(_react.default.Fragment, null, children);
|
|
193
|
+
});
|
|
194
|
+
ConditionalDroppableColumns.displayName = 'ConditionalDroppableColumns';
|
|
195
|
+
var ConditionalDraggableColumn = exports.ConditionalDraggableColumn = /*#__PURE__*/(0, _react.memo)(function (_ref8) {
|
|
196
|
+
var canDragAndDropColumns = _ref8.canDragAndDropColumns,
|
|
197
|
+
children = _ref8.children,
|
|
198
|
+
rest = (0, _objectWithoutProperties2.default)(_ref8, _excluded3);
|
|
199
|
+
return canDragAndDropColumns ? (0, _react2.jsx)(DraggableColumn, rest, children) : (0, _react2.jsx)(_react.default.Fragment, null, children());
|
|
200
|
+
});
|
|
201
|
+
ConditionalDraggableColumn.displayName = 'ConditionalDraggableColumn';
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Creates an invisible overlay that prevents hover interactions/transitions
|
|
205
|
+
* on other elements that the dragged element is dragged over, and also maintains
|
|
206
|
+
* the intended drag cursor over any location.
|
|
207
|
+
*
|
|
208
|
+
* TODO: If this is useful elsewhere, consider moving it to `src/services`
|
|
209
|
+
*/
|
|
210
|
+
var _ref10 = process.env.NODE_ENV === "production" ? {
|
|
211
|
+
name: "q8wbl-DragOverlay",
|
|
212
|
+
styles: "position:fixed;inset:0;label:DragOverlay;"
|
|
213
|
+
} : {
|
|
214
|
+
name: "q8wbl-DragOverlay",
|
|
215
|
+
styles: "position:fixed;inset:0;label:DragOverlay;",
|
|
216
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
217
|
+
};
|
|
218
|
+
var DragOverlay = exports.DragOverlay = /*#__PURE__*/(0, _react.memo)(function (_ref9) {
|
|
219
|
+
var isDragging = _ref9.isDragging,
|
|
220
|
+
cursor = _ref9.cursor,
|
|
221
|
+
_ref9$zIndex = _ref9.zIndex,
|
|
222
|
+
zIndex = _ref9$zIndex === void 0 ? 9999 : _ref9$zIndex;
|
|
223
|
+
return isDragging ? (0, _react2.jsx)(_portal.EuiPortal, null, (0, _react2.jsx)("div", {
|
|
224
|
+
css: _ref10,
|
|
225
|
+
style: {
|
|
226
|
+
cursor: cursor,
|
|
227
|
+
zIndex: zIndex
|
|
228
|
+
}
|
|
229
|
+
})) : null;
|
|
230
|
+
});
|
|
231
|
+
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
|
|
@@ -114,9 +114,6 @@ var columns = [{
|
|
|
114
114
|
"aria-label": "Send email to ".concat(value)
|
|
115
115
|
}, "Send email");
|
|
116
116
|
}]
|
|
117
|
-
}, {
|
|
118
|
-
id: 'location',
|
|
119
|
-
displayAsText: 'Location'
|
|
120
117
|
}, {
|
|
121
118
|
id: 'account',
|
|
122
119
|
displayAsText: 'Account',
|
|
@@ -151,6 +148,9 @@ var columns = [{
|
|
|
151
148
|
"aria-label": "Send money to ".concat(value)
|
|
152
149
|
}, "Send money");
|
|
153
150
|
}]
|
|
151
|
+
}, {
|
|
152
|
+
id: 'location',
|
|
153
|
+
displayAsText: 'Location'
|
|
154
154
|
}, {
|
|
155
155
|
id: 'date',
|
|
156
156
|
displayAsText: 'Date',
|
|
@@ -231,7 +231,8 @@ var defaultStorybookArgs = exports.defaultStorybookArgs = {
|
|
|
231
231
|
// setup for easier testing/QA
|
|
232
232
|
columnVisibility: {
|
|
233
233
|
visibleColumns: ['name', 'email', 'account', 'location', 'date', 'amount', 'phone', 'version'],
|
|
234
|
-
setVisibleColumns: function setVisibleColumns() {}
|
|
234
|
+
setVisibleColumns: function setVisibleColumns() {},
|
|
235
|
+
canDragAndDropColumns: false
|
|
235
236
|
},
|
|
236
237
|
inMemory: {
|
|
237
238
|
level: 'sorting'
|
|
@@ -342,7 +343,8 @@ var StatefulDataGrid = exports.StatefulDataGrid = function StatefulDataGrid(prop
|
|
|
342
343
|
return (0, _react2.jsx)(_data_grid.EuiDataGrid, (0, _extends2.default)({}, rest, {
|
|
343
344
|
columnVisibility: {
|
|
344
345
|
visibleColumns: visibleColumns,
|
|
345
|
-
setVisibleColumns: setVisibleColumns
|
|
346
|
+
setVisibleColumns: setVisibleColumns,
|
|
347
|
+
canDragAndDropColumns: columnVisibility.canDragAndDropColumns
|
|
346
348
|
},
|
|
347
349
|
sorting: {
|
|
348
350
|
columns: sortingColumns,
|
|
@@ -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,
|
|
@@ -80,7 +81,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
80
81
|
function () {
|
|
81
82
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref2) {
|
|
82
83
|
var _adjustedScrollLeft;
|
|
83
|
-
var rowIndex, colIndex, getCell, cell, cellIsInView, _outerGridRef$current, scrollTop, scrollLeft, adjustedScrollTop, adjustedScrollLeft, cellRightPos, rightScrollBound, rightWidthOutOfView,
|
|
84
|
+
var rowIndex, colIndex, 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;
|
|
84
85
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
85
86
|
while (1) switch (_context.prev = _context.next) {
|
|
86
87
|
case 0:
|
|
@@ -127,7 +128,10 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
127
128
|
return _context.abrupt("return");
|
|
128
129
|
case 15:
|
|
129
130
|
// If for some reason we can't find a valid cell, short-circuit
|
|
130
|
-
|
|
131
|
+
isStickyHeader = rowIndex === -1;
|
|
132
|
+
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
133
|
+
isDraggableHeader = canDragAndDropColumns && isStickyHeader;
|
|
134
|
+
isDraggableHeaderCell = isDraggableHeader && cell.offsetLeft === 0 && colIndex !== 0; // We now manually adjust scroll positioning around the cell to ensure it's
|
|
131
135
|
// fully in view on all sides. A couple of notes on this:
|
|
132
136
|
// 1. We're avoiding relying on react-window's scrollToItem for this because it also
|
|
133
137
|
// does not account for sticky items (see https://github.com/bvaughn/react-window/issues/586)
|
|
@@ -136,8 +140,10 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
136
140
|
// halfway there, but doesn't guarantee the *full* cell in view, or account for
|
|
137
141
|
// sticky positioned rows or OS scrollbars, hence these workarounds
|
|
138
142
|
_outerGridRef$current = outerGridRef.current, scrollTop = _outerGridRef$current.scrollTop, scrollLeft = _outerGridRef$current.scrollLeft;
|
|
139
|
-
//
|
|
140
|
-
|
|
143
|
+
// Draggable header columns are nested within EuiDraggables,
|
|
144
|
+
// and their offsetLeft needs to go up a wrapper as a result
|
|
145
|
+
cellLeftPos = isDraggableHeaderCell ? cell.offsetParent.offsetLeft : cell.offsetLeft; // Check if the cell's right side is outside the current scrolling bounds
|
|
146
|
+
cellRightPos = cellLeftPos + cell.offsetWidth;
|
|
141
147
|
rightScrollBound = scrollLeft + outerGridRef.current.clientWidth; // Note: We specifically want clientWidth and not offsetWidth here to account for scrollbars
|
|
142
148
|
rightWidthOutOfView = cellRightPos - rightScrollBound;
|
|
143
149
|
if (rightWidthOutOfView > 0) {
|
|
@@ -145,7 +151,6 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
// Check if the cell's left side is outside the current scrolling bounds
|
|
148
|
-
cellLeftPos = cell.offsetLeft;
|
|
149
154
|
leftScrollBound = (_adjustedScrollLeft = adjustedScrollLeft) !== null && _adjustedScrollLeft !== void 0 ? _adjustedScrollLeft : scrollLeft;
|
|
150
155
|
leftWidthOutOfView = leftScrollBound - cellLeftPos;
|
|
151
156
|
if (leftWidthOutOfView > 0) {
|
|
@@ -156,8 +161,6 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
156
161
|
|
|
157
162
|
// Skip top/bottom scroll adjustments for sticky headers & footers
|
|
158
163
|
// since they should always be in view vertically
|
|
159
|
-
isStickyHeader = rowIndex === -1;
|
|
160
|
-
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
161
164
|
if (!isStickyHeader && !isStickyFooter) {
|
|
162
165
|
parentRow = cell.parentNode; // Check if the cell's bottom side is outside the current scrolling bounds
|
|
163
166
|
cellBottomPos = parentRow.offsetTop + cell.offsetHeight;
|
|
@@ -187,7 +190,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
187
190
|
scrollTop: (_adjustedScrollTop2 = adjustedScrollTop) !== null && _adjustedScrollTop2 !== void 0 ? _adjustedScrollTop2 : scrollTop
|
|
188
191
|
});
|
|
189
192
|
}
|
|
190
|
-
case
|
|
193
|
+
case 30:
|
|
191
194
|
case "end":
|
|
192
195
|
return _context.stop();
|
|
193
196
|
}
|
|
@@ -196,7 +199,7 @@ var useScrollCellIntoView = exports.useScrollCellIntoView = function useScrollCe
|
|
|
196
199
|
return function (_x) {
|
|
197
200
|
return _ref3.apply(this, arguments);
|
|
198
201
|
};
|
|
199
|
-
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter]);
|
|
202
|
+
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter, canDragAndDropColumns]);
|
|
200
203
|
return {
|
|
201
204
|
scrollCellIntoView: scrollCellIntoView
|
|
202
205
|
};
|
|
@@ -41,6 +41,8 @@ var EuiAbsoluteTab = exports.EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
41
41
|
locale = _ref.locale,
|
|
42
42
|
roundUp = _ref.roundUp,
|
|
43
43
|
utcOffset = _ref.utcOffset,
|
|
44
|
+
minDate = _ref.minDate,
|
|
45
|
+
maxDate = _ref.maxDate,
|
|
44
46
|
labelPrefix = _ref.labelPrefix;
|
|
45
47
|
var styles = (0, _services.useEuiMemoizedStyles)(_absolute_tab.euiAbsoluteTabDateFormStyles);
|
|
46
48
|
var _useState = (0, _react.useState)(function () {
|
|
@@ -134,7 +136,9 @@ var EuiAbsoluteTab = exports.EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
134
136
|
dateFormat: dateFormat,
|
|
135
137
|
timeFormat: timeFormat,
|
|
136
138
|
locale: locale,
|
|
137
|
-
utcOffset: utcOffset
|
|
139
|
+
utcOffset: utcOffset,
|
|
140
|
+
minDate: minDate,
|
|
141
|
+
maxDate: maxDate
|
|
138
142
|
}), (0, _react2.jsx)(_flex.EuiFlexGroup, {
|
|
139
143
|
component: "form",
|
|
140
144
|
onSubmit: function onSubmit(e) {
|
package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js
CHANGED
|
@@ -16,7 +16,7 @@ var _pretty_duration = require("../pretty_duration");
|
|
|
16
16
|
var _date_popover_content = require("./date_popover_content");
|
|
17
17
|
var _date_popover_button = require("./date_popover_button.styles");
|
|
18
18
|
var _react2 = require("@emotion/react");
|
|
19
|
-
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
19
|
+
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "minDate", "maxDate", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
20
20
|
/*
|
|
21
21
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
22
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -38,6 +38,8 @@ var EuiDatePopoverButton = exports.EuiDatePopoverButton = function EuiDatePopove
|
|
|
38
38
|
locale = props.locale,
|
|
39
39
|
dateFormat = props.dateFormat,
|
|
40
40
|
utcOffset = props.utcOffset,
|
|
41
|
+
minDate = props.minDate,
|
|
42
|
+
maxDate = props.maxDate,
|
|
41
43
|
timeFormat = props.timeFormat,
|
|
42
44
|
isOpen = props.isOpen,
|
|
43
45
|
onPopoverToggle = props.onPopoverToggle,
|
|
@@ -98,7 +100,9 @@ var EuiDatePopoverButton = exports.EuiDatePopoverButton = function EuiDatePopove
|
|
|
98
100
|
locale: locale,
|
|
99
101
|
position: position,
|
|
100
102
|
utcOffset: utcOffset,
|
|
101
|
-
timeOptions: timeOptions
|
|
103
|
+
timeOptions: timeOptions,
|
|
104
|
+
minDate: minDate,
|
|
105
|
+
maxDate: maxDate
|
|
102
106
|
}));
|
|
103
107
|
};
|
|
104
108
|
EuiDatePopoverButton.displayName = 'EuiDatePopoverButton';
|
package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js
CHANGED
|
@@ -37,7 +37,9 @@ var EuiDatePopoverContent = exports.EuiDatePopoverContent = function EuiDatePopo
|
|
|
37
37
|
locale = _ref.locale,
|
|
38
38
|
position = _ref.position,
|
|
39
39
|
utcOffset = _ref.utcOffset,
|
|
40
|
-
timeOptions = _ref.timeOptions
|
|
40
|
+
timeOptions = _ref.timeOptions,
|
|
41
|
+
minDate = _ref.minDate,
|
|
42
|
+
maxDate = _ref.maxDate;
|
|
41
43
|
var styles = (0, _services.useEuiMemoizedStyles)(_date_popover_content.euiDatePopoverContentStyles);
|
|
42
44
|
var onTabClick = function onTabClick(selectedTab) {
|
|
43
45
|
switch (selectedTab.id) {
|
|
@@ -66,7 +68,9 @@ var EuiDatePopoverContent = exports.EuiDatePopoverContent = function EuiDatePopo
|
|
|
66
68
|
onChange: onChange,
|
|
67
69
|
roundUp: roundUp,
|
|
68
70
|
labelPrefix: labelPrefix,
|
|
69
|
-
utcOffset: utcOffset
|
|
71
|
+
utcOffset: utcOffset,
|
|
72
|
+
minDate: minDate,
|
|
73
|
+
maxDate: maxDate
|
|
70
74
|
}),
|
|
71
75
|
'data-test-subj': 'superDatePickerAbsoluteTab',
|
|
72
76
|
'aria-label': "".concat(labelPrefix, ": ").concat(absoluteLabel)
|