@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,223 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["role", "tabIndex"],
|
|
4
|
+
_excluded2 = ["canDragAndDropColumns", "children"],
|
|
5
|
+
_excluded3 = ["canDragAndDropColumns", "children"];
|
|
6
|
+
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)."; }
|
|
7
|
+
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; }
|
|
8
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
|
+
/*
|
|
10
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
11
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
12
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
13
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
14
|
+
* Side Public License, v 1.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { memo, useCallback, useContext, useRef } from 'react';
|
|
18
|
+
import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../../services';
|
|
19
|
+
import { EuiDragDropContext, EuiDroppable, EuiDraggable } from '../../../drag_and_drop';
|
|
20
|
+
import { EuiPortal } from '../../../portal';
|
|
21
|
+
import { DataGridFocusContext } from '../../utils/focus';
|
|
22
|
+
import { euiDataGridStyles } from '../../data_grid.styles';
|
|
23
|
+
import { euiDataGridDraggableHeaderStyles } from './draggable_columns.styles';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Parent context + EuiDroppable wrapper
|
|
27
|
+
*/
|
|
28
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
29
|
+
export var DroppableColumns = /*#__PURE__*/memo(function (_ref) {
|
|
30
|
+
var columns = _ref.columns,
|
|
31
|
+
switchColumnPos = _ref.switchColumnPos,
|
|
32
|
+
indexOffset = _ref.indexOffset,
|
|
33
|
+
children = _ref.children;
|
|
34
|
+
var styles = useEuiMemoizedStyles(euiDataGridDraggableHeaderStyles);
|
|
35
|
+
var droppableId = useGeneratedHtmlId({
|
|
36
|
+
prefix: 'euiDataGridHeaderDroppable'
|
|
37
|
+
});
|
|
38
|
+
var _useContext = useContext(DataGridFocusContext),
|
|
39
|
+
setFocusedCell = _useContext.setFocusedCell;
|
|
40
|
+
var handleOnDragEnd = useCallback(function (_ref2) {
|
|
41
|
+
var source = _ref2.source,
|
|
42
|
+
destination = _ref2.destination;
|
|
43
|
+
if (!source) return;
|
|
44
|
+
if (destination && destination.index !== source.index) {
|
|
45
|
+
var sourceColumn = columns[source.index - indexOffset];
|
|
46
|
+
var destinationColumn = columns[destination.index - indexOffset];
|
|
47
|
+
if (sourceColumn && destinationColumn) {
|
|
48
|
+
switchColumnPos(sourceColumn.id, destinationColumn.id);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Force focus the cell to prevent the datagrid body from become unfocusable, including on drag cancel
|
|
52
|
+
setTimeout(function () {
|
|
53
|
+
var cellToFocus = destination ? destination.index : source.index;
|
|
54
|
+
setFocusedCell([cellToFocus, -1], true);
|
|
55
|
+
});
|
|
56
|
+
}, [columns, indexOffset, switchColumnPos, setFocusedCell]);
|
|
57
|
+
return ___EmotionJSX(EuiDragDropContext, {
|
|
58
|
+
onDragEnd: handleOnDragEnd
|
|
59
|
+
}, ___EmotionJSX(EuiDroppable, {
|
|
60
|
+
droppableId: droppableId,
|
|
61
|
+
direction: "horizontal",
|
|
62
|
+
ignoreContainerClipping: true,
|
|
63
|
+
css: styles.euiDataGridHeaderDroppable,
|
|
64
|
+
"data-test-subj": "euiDataGridHeaderDroppable"
|
|
65
|
+
}, children));
|
|
66
|
+
});
|
|
67
|
+
DroppableColumns.displayName = 'DroppableColumns';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Individual EuiDraggable columns
|
|
71
|
+
*/
|
|
72
|
+
export var DraggableColumn = /*#__PURE__*/memo(function (_ref3) {
|
|
73
|
+
var id = _ref3.id,
|
|
74
|
+
index = _ref3.index,
|
|
75
|
+
gridStyles = _ref3.gridStyles,
|
|
76
|
+
columnResizer = _ref3.columnResizer,
|
|
77
|
+
actionsPopoverToggle = _ref3.actionsPopoverToggle,
|
|
78
|
+
children = _ref3.children;
|
|
79
|
+
var dataGridStyles = useEuiMemoizedStyles(euiDataGridStyles);
|
|
80
|
+
var styles = useEuiMemoizedStyles(euiDataGridDraggableHeaderStyles);
|
|
81
|
+
// Manually re-apply background and border overrides, since
|
|
82
|
+
// the droppable zone sets its own and confuses :first-of-type CSS
|
|
83
|
+
var reapplyCellStyles = [styles[gridStyles.header], index !== 0 && styles.noLeadingBorder];
|
|
84
|
+
|
|
85
|
+
// Draggable prevents the cell from receiving focus on click.
|
|
86
|
+
// We manually ensure focus is set on cell mouseDown which
|
|
87
|
+
// also includes setting focus before dragging
|
|
88
|
+
var _useContext2 = useContext(DataGridFocusContext),
|
|
89
|
+
setFocusedCell = _useContext2.setFocusedCell;
|
|
90
|
+
var handleOnMouseDown = useCallback(function (e) {
|
|
91
|
+
var openFocusTrap = document.querySelector('[data-focus-lock-disabled="false"]');
|
|
92
|
+
if (!!openFocusTrap &&
|
|
93
|
+
// If a focus trap is open somewhere on the page
|
|
94
|
+
!openFocusTrap.contains(e.target) &&
|
|
95
|
+
// & the focus trap doesn't belong to this header
|
|
96
|
+
e.target !== actionsPopoverToggle // & we're not closing the actions popover toggle
|
|
97
|
+
) {
|
|
98
|
+
// Trick the focus trap lib into registering an outside click -
|
|
99
|
+
// the drag/drop lib otherwise otherwise prevents the event 💀
|
|
100
|
+
document.dispatchEvent(new MouseEvent('mousedown'));
|
|
101
|
+
}
|
|
102
|
+
setTimeout(function () {
|
|
103
|
+
setFocusedCell([index, -1], true);
|
|
104
|
+
});
|
|
105
|
+
}, [setFocusedCell, index, actionsPopoverToggle]);
|
|
106
|
+
|
|
107
|
+
// Prevent any other keypresses when dragging
|
|
108
|
+
var isDraggingRef = useRef(false);
|
|
109
|
+
var handleOnKeydown = useCallback(function (e) {
|
|
110
|
+
if (isDraggingRef.current) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
// UX polish: add a slight animation frame delay to the dragging ref end
|
|
118
|
+
// which prevents re-running the hover animation of column header actions
|
|
119
|
+
var updateDraggingRef = useCallback(function (isDragging) {
|
|
120
|
+
// Only update if the state has changed from before
|
|
121
|
+
if (isDragging !== isDraggingRef.current) {
|
|
122
|
+
if (!isDragging) {
|
|
123
|
+
requestAnimationFrame(function () {
|
|
124
|
+
isDraggingRef.current = false;
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
isDraggingRef.current = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, []);
|
|
131
|
+
return ___EmotionJSX("div", {
|
|
132
|
+
css: styles.euiDataGridHeaderCellDraggableWrapper,
|
|
133
|
+
onMouseDown: handleOnMouseDown,
|
|
134
|
+
onKeyDownCapture: handleOnKeydown
|
|
135
|
+
}, columnResizer, ___EmotionJSX(EuiDraggable, {
|
|
136
|
+
draggableId: id,
|
|
137
|
+
className: "euiDataGridHeaderCellDraggable",
|
|
138
|
+
css: styles.euiDataGridHeaderCellDraggable,
|
|
139
|
+
index: index,
|
|
140
|
+
customDragHandle: "custom",
|
|
141
|
+
hasInteractiveChildren: true,
|
|
142
|
+
usePortal: true
|
|
143
|
+
}, function (_ref4, _ref5) {
|
|
144
|
+
var dragHandleProps = _ref4.dragHandleProps;
|
|
145
|
+
var isDragging = _ref5.isDragging,
|
|
146
|
+
mode = _ref5.mode;
|
|
147
|
+
updateDraggingRef(isDragging);
|
|
148
|
+
var _ref6 = dragHandleProps !== null && dragHandleProps !== void 0 ? dragHandleProps : {},
|
|
149
|
+
role = _ref6.role,
|
|
150
|
+
tabIndex = _ref6.tabIndex,
|
|
151
|
+
restDragHandleProps = _objectWithoutProperties(_ref6, _excluded);
|
|
152
|
+
var passedProps = _objectSpread(_objectSpread({}, restDragHandleProps), {}, {
|
|
153
|
+
css: reapplyCellStyles,
|
|
154
|
+
'data-column-moving': isDraggingRef.current || undefined,
|
|
155
|
+
isDragging: isDragging
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// since the cloned content is in a portal outside the datagrid
|
|
159
|
+
// we need to re-add styles to the cell as the scoped styles
|
|
160
|
+
// from the wrapper don't apply
|
|
161
|
+
var draggingStyles = [styles.euiDataGridHeaderCellDraggable,
|
|
162
|
+
// ensure height is maintained while dragging
|
|
163
|
+
dataGridStyles.cellPadding[gridStyles.cellPadding], dataGridStyles.fontSize[gridStyles.fontSize], dataGridStyles.borders[gridStyles.border], mode === 'SNAP' && styles.isKeyboardDragging];
|
|
164
|
+
return isDragging ? ___EmotionJSX("div", {
|
|
165
|
+
css: draggingStyles
|
|
166
|
+
}, ___EmotionJSX(DragOverlay, {
|
|
167
|
+
isDragging: true,
|
|
168
|
+
cursor: "grabbing"
|
|
169
|
+
}), children(passedProps)) : children(passedProps);
|
|
170
|
+
}));
|
|
171
|
+
});
|
|
172
|
+
DraggableColumn.displayName = 'DraggableColumn';
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Components for conditionally rendering drag/drop wrappers
|
|
176
|
+
* Allows us to conditionally call hooks while not instantiating a bunch
|
|
177
|
+
* of extra state/etc., since draggable columns isn't yet(?) a default
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
export var ConditionalDroppableColumns = /*#__PURE__*/memo(function (_ref7) {
|
|
181
|
+
var canDragAndDropColumns = _ref7.canDragAndDropColumns,
|
|
182
|
+
children = _ref7.children,
|
|
183
|
+
rest = _objectWithoutProperties(_ref7, _excluded2);
|
|
184
|
+
return canDragAndDropColumns ? ___EmotionJSX(DroppableColumns, rest, children) : ___EmotionJSX(React.Fragment, null, children);
|
|
185
|
+
});
|
|
186
|
+
ConditionalDroppableColumns.displayName = 'ConditionalDroppableColumns';
|
|
187
|
+
export var ConditionalDraggableColumn = /*#__PURE__*/memo(function (_ref8) {
|
|
188
|
+
var canDragAndDropColumns = _ref8.canDragAndDropColumns,
|
|
189
|
+
children = _ref8.children,
|
|
190
|
+
rest = _objectWithoutProperties(_ref8, _excluded3);
|
|
191
|
+
return canDragAndDropColumns ? ___EmotionJSX(DraggableColumn, rest, children) : ___EmotionJSX(React.Fragment, null, children());
|
|
192
|
+
});
|
|
193
|
+
ConditionalDraggableColumn.displayName = 'ConditionalDraggableColumn';
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Creates an invisible overlay that prevents hover interactions/transitions
|
|
197
|
+
* on other elements that the dragged element is dragged over, and also maintains
|
|
198
|
+
* the intended drag cursor over any location.
|
|
199
|
+
*
|
|
200
|
+
* TODO: If this is useful elsewhere, consider moving it to `src/services`
|
|
201
|
+
*/
|
|
202
|
+
var _ref10 = process.env.NODE_ENV === "production" ? {
|
|
203
|
+
name: "q8wbl-DragOverlay",
|
|
204
|
+
styles: "position:fixed;inset:0;label:DragOverlay;"
|
|
205
|
+
} : {
|
|
206
|
+
name: "q8wbl-DragOverlay",
|
|
207
|
+
styles: "position:fixed;inset:0;label:DragOverlay;",
|
|
208
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
209
|
+
};
|
|
210
|
+
export var DragOverlay = /*#__PURE__*/memo(function (_ref9) {
|
|
211
|
+
var isDragging = _ref9.isDragging,
|
|
212
|
+
cursor = _ref9.cursor,
|
|
213
|
+
_ref9$zIndex = _ref9.zIndex,
|
|
214
|
+
zIndex = _ref9$zIndex === void 0 ? 9999 : _ref9$zIndex;
|
|
215
|
+
return isDragging ? ___EmotionJSX(EuiPortal, null, ___EmotionJSX("div", {
|
|
216
|
+
css: _ref10,
|
|
217
|
+
style: {
|
|
218
|
+
cursor: cursor,
|
|
219
|
+
zIndex: zIndex
|
|
220
|
+
}
|
|
221
|
+
})) : null;
|
|
222
|
+
});
|
|
223
|
+
DragOverlay.displayName = 'DragOverlay';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject;
|
|
3
|
+
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)."; }
|
|
4
|
+
/*
|
|
5
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
6
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
7
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
8
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
9
|
+
* Side Public License, v 1.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { css, keyframes } from '@emotion/react';
|
|
13
|
+
import { euiCanAnimate, logicalCSS } from '../../../../global_styling';
|
|
14
|
+
var _ref = process.env.NODE_ENV === "production" ? {
|
|
15
|
+
name: "pfqu74-euiDataGridHeaderDroppable",
|
|
16
|
+
styles: "display:flex;label:euiDataGridHeaderDroppable;"
|
|
17
|
+
} : {
|
|
18
|
+
name: "pfqu74-euiDataGridHeaderDroppable",
|
|
19
|
+
styles: "display:flex;label:euiDataGridHeaderDroppable;",
|
|
20
|
+
toString: _EMOTION_STRINGIFIED_CSS_ERROR__
|
|
21
|
+
};
|
|
22
|
+
export var euiDataGridDraggableHeaderStyles = function euiDataGridDraggableHeaderStyles(_ref2) {
|
|
23
|
+
var euiTheme = _ref2.euiTheme;
|
|
24
|
+
return {
|
|
25
|
+
euiDataGridHeaderDroppable: _ref,
|
|
26
|
+
// The resizer must be positioned outside the draggable component to ensure both work independently
|
|
27
|
+
euiDataGridHeaderCellDraggableWrapper: /*#__PURE__*/css("position:relative;.euiDataGridColumnResizer::after{", logicalCSS('margin-left', "-".concat(euiTheme.border.width.thick)), ";};label:euiDataGridHeaderCellDraggableWrapper;"),
|
|
28
|
+
// override internal styling from @hello-pangea/dnd to ensure positioning
|
|
29
|
+
euiDataGridHeaderCellDraggable: /*#__PURE__*/css("display:flex;", logicalCSS('height', '100%'), ";;label:euiDataGridHeaderCellDraggable;"),
|
|
30
|
+
// Add more visual affordance to keyboard drags (raises cell slightly to show green droppable bg)
|
|
31
|
+
// Using animation as transition doesn't seem to work (a tale as old as EuiDataGrid...)
|
|
32
|
+
isKeyboardDragging: /*#__PURE__*/css("animation-name:", keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from { transform: translateY(0); }\n to { transform: translateY(-", "); }\n "])), euiTheme.size.s), ";animation-iteration-count:1;animation-fill-mode:forwards;", euiCanAnimate, "{animation-duration:", euiTheme.animation.fast, ";};label:isKeyboardDragging;"),
|
|
33
|
+
// Ensure correct cell background colors on drag
|
|
34
|
+
underline: /*#__PURE__*/css("background-color:", euiTheme.colors.emptyShade, ";;label:underline;"),
|
|
35
|
+
shade: /*#__PURE__*/css("background-color:", euiTheme.colors.lightestShade, ";;label:shade;"),
|
|
36
|
+
noLeadingBorder: /*#__PURE__*/css(logicalCSS('border-left', 'none !important'), ";;label:noLeadingBorder;")
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -391,7 +391,8 @@ export var EuiDataGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (pr
|
|
|
391
391
|
gridRef: gridRef,
|
|
392
392
|
gridItemsRendered: gridItemsRendered,
|
|
393
393
|
wrapperRef: contentRef,
|
|
394
|
-
renderCustomGridBody: renderCustomGridBody
|
|
394
|
+
renderCustomGridBody: renderCustomGridBody,
|
|
395
|
+
canDragAndDropColumns: columnVisibility.canDragAndDropColumns
|
|
395
396
|
}))), showPagination && props['aria-labelledby'] && ___EmotionJSX("p", {
|
|
396
397
|
id: ariaLabelledById,
|
|
397
398
|
hidden: true
|
|
@@ -109,9 +109,6 @@ var columns = [{
|
|
|
109
109
|
"aria-label": "Send email to ".concat(value)
|
|
110
110
|
}, "Send email");
|
|
111
111
|
}]
|
|
112
|
-
}, {
|
|
113
|
-
id: 'location',
|
|
114
|
-
displayAsText: 'Location'
|
|
115
112
|
}, {
|
|
116
113
|
id: 'account',
|
|
117
114
|
displayAsText: 'Account',
|
|
@@ -146,6 +143,9 @@ var columns = [{
|
|
|
146
143
|
"aria-label": "Send money to ".concat(value)
|
|
147
144
|
}, "Send money");
|
|
148
145
|
}]
|
|
146
|
+
}, {
|
|
147
|
+
id: 'location',
|
|
148
|
+
displayAsText: 'Location'
|
|
149
149
|
}, {
|
|
150
150
|
id: 'date',
|
|
151
151
|
displayAsText: 'Date',
|
|
@@ -226,7 +226,8 @@ export var defaultStorybookArgs = {
|
|
|
226
226
|
// setup for easier testing/QA
|
|
227
227
|
columnVisibility: {
|
|
228
228
|
visibleColumns: ['name', 'email', 'account', 'location', 'date', 'amount', 'phone', 'version'],
|
|
229
|
-
setVisibleColumns: function setVisibleColumns() {}
|
|
229
|
+
setVisibleColumns: function setVisibleColumns() {},
|
|
230
|
+
canDragAndDropColumns: false
|
|
230
231
|
},
|
|
231
232
|
inMemory: {
|
|
232
233
|
level: 'sorting'
|
|
@@ -337,7 +338,8 @@ export var StatefulDataGrid = function StatefulDataGrid(props) {
|
|
|
337
338
|
return ___EmotionJSX(EuiDataGrid, _extends({}, rest, {
|
|
338
339
|
columnVisibility: {
|
|
339
340
|
visibleColumns: visibleColumns,
|
|
340
|
-
setVisibleColumns: setVisibleColumns
|
|
341
|
+
setVisibleColumns: setVisibleColumns,
|
|
342
|
+
canDragAndDropColumns: columnVisibility.canDragAndDropColumns
|
|
341
343
|
},
|
|
342
344
|
sorting: {
|
|
343
345
|
columns: sortingColumns,
|
|
@@ -65,12 +65,10 @@ export var useColumnWidths = function useColumnWidths(_ref) {
|
|
|
65
65
|
setColumnWidths(function (prevColumnWidths) {
|
|
66
66
|
return _objectSpread(_objectSpread({}, prevColumnWidths), {}, _defineProperty({}, columnId, width));
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
73
|
-
}
|
|
68
|
+
onColumnResize === null || onColumnResize === void 0 || onColumnResize({
|
|
69
|
+
columnId: columnId,
|
|
70
|
+
width: width
|
|
71
|
+
});
|
|
74
72
|
}, [onColumnResize]);
|
|
75
73
|
|
|
76
74
|
// Used by react-window to determine actual column widths
|
|
@@ -42,11 +42,11 @@ export var useFocus = function useFocus() {
|
|
|
42
42
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
43
|
focusedCell = _useState4[0],
|
|
44
44
|
_setFocusedCell = _useState4[1];
|
|
45
|
-
var setFocusedCell = useCallback(function (nextFocusedCell) {
|
|
45
|
+
var setFocusedCell = useCallback(function (nextFocusedCell, forceUpdate) {
|
|
46
46
|
_setFocusedCell(function (prevFocusedCell) {
|
|
47
47
|
// If the x/y coordinates remained the same, don't update. This keeps the focusedCell
|
|
48
48
|
// reference stable, and allows it to be used in places that need reference equality.
|
|
49
|
-
if (nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
49
|
+
if (!forceUpdate && nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
|
|
50
50
|
return prevFocusedCell;
|
|
51
51
|
} else {
|
|
52
52
|
setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view
|
|
@@ -61,7 +61,8 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
61
61
|
headerRowHeight = _ref.headerRowHeight,
|
|
62
62
|
footerRowHeight = _ref.footerRowHeight,
|
|
63
63
|
visibleRowCount = _ref.visibleRowCount,
|
|
64
|
-
hasStickyFooter = _ref.hasStickyFooter
|
|
64
|
+
hasStickyFooter = _ref.hasStickyFooter,
|
|
65
|
+
canDragAndDropColumns = _ref.canDragAndDropColumns;
|
|
65
66
|
var scrollCellIntoView = useCallback(
|
|
66
67
|
/*#__PURE__*/
|
|
67
68
|
// Note: in order for this UX to work correctly with react-window's APIs,
|
|
@@ -70,7 +71,7 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
70
71
|
function () {
|
|
71
72
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref2) {
|
|
72
73
|
var _adjustedScrollLeft;
|
|
73
|
-
var rowIndex, colIndex, getCell, cell, cellIsInView, _outerGridRef$current, scrollTop, scrollLeft, adjustedScrollTop, adjustedScrollLeft, cellRightPos, rightScrollBound, rightWidthOutOfView,
|
|
74
|
+
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;
|
|
74
75
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
75
76
|
while (1) switch (_context.prev = _context.next) {
|
|
76
77
|
case 0:
|
|
@@ -117,7 +118,10 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
117
118
|
return _context.abrupt("return");
|
|
118
119
|
case 15:
|
|
119
120
|
// If for some reason we can't find a valid cell, short-circuit
|
|
120
|
-
|
|
121
|
+
isStickyHeader = rowIndex === -1;
|
|
122
|
+
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
123
|
+
isDraggableHeader = canDragAndDropColumns && isStickyHeader;
|
|
124
|
+
isDraggableHeaderCell = isDraggableHeader && cell.offsetLeft === 0 && colIndex !== 0; // We now manually adjust scroll positioning around the cell to ensure it's
|
|
121
125
|
// fully in view on all sides. A couple of notes on this:
|
|
122
126
|
// 1. We're avoiding relying on react-window's scrollToItem for this because it also
|
|
123
127
|
// does not account for sticky items (see https://github.com/bvaughn/react-window/issues/586)
|
|
@@ -126,8 +130,10 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
126
130
|
// halfway there, but doesn't guarantee the *full* cell in view, or account for
|
|
127
131
|
// sticky positioned rows or OS scrollbars, hence these workarounds
|
|
128
132
|
_outerGridRef$current = outerGridRef.current, scrollTop = _outerGridRef$current.scrollTop, scrollLeft = _outerGridRef$current.scrollLeft;
|
|
129
|
-
//
|
|
130
|
-
|
|
133
|
+
// Draggable header columns are nested within EuiDraggables,
|
|
134
|
+
// and their offsetLeft needs to go up a wrapper as a result
|
|
135
|
+
cellLeftPos = isDraggableHeaderCell ? cell.offsetParent.offsetLeft : cell.offsetLeft; // Check if the cell's right side is outside the current scrolling bounds
|
|
136
|
+
cellRightPos = cellLeftPos + cell.offsetWidth;
|
|
131
137
|
rightScrollBound = scrollLeft + outerGridRef.current.clientWidth; // Note: We specifically want clientWidth and not offsetWidth here to account for scrollbars
|
|
132
138
|
rightWidthOutOfView = cellRightPos - rightScrollBound;
|
|
133
139
|
if (rightWidthOutOfView > 0) {
|
|
@@ -135,7 +141,6 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
// Check if the cell's left side is outside the current scrolling bounds
|
|
138
|
-
cellLeftPos = cell.offsetLeft;
|
|
139
144
|
leftScrollBound = (_adjustedScrollLeft = adjustedScrollLeft) !== null && _adjustedScrollLeft !== void 0 ? _adjustedScrollLeft : scrollLeft;
|
|
140
145
|
leftWidthOutOfView = leftScrollBound - cellLeftPos;
|
|
141
146
|
if (leftWidthOutOfView > 0) {
|
|
@@ -146,8 +151,6 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
146
151
|
|
|
147
152
|
// Skip top/bottom scroll adjustments for sticky headers & footers
|
|
148
153
|
// since they should always be in view vertically
|
|
149
|
-
isStickyHeader = rowIndex === -1;
|
|
150
|
-
isStickyFooter = hasStickyFooter && rowIndex === visibleRowCount;
|
|
151
154
|
if (!isStickyHeader && !isStickyFooter) {
|
|
152
155
|
parentRow = cell.parentNode; // Check if the cell's bottom side is outside the current scrolling bounds
|
|
153
156
|
cellBottomPos = parentRow.offsetTop + cell.offsetHeight;
|
|
@@ -177,7 +180,7 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
177
180
|
scrollTop: (_adjustedScrollTop2 = adjustedScrollTop) !== null && _adjustedScrollTop2 !== void 0 ? _adjustedScrollTop2 : scrollTop
|
|
178
181
|
});
|
|
179
182
|
}
|
|
180
|
-
case
|
|
183
|
+
case 30:
|
|
181
184
|
case "end":
|
|
182
185
|
return _context.stop();
|
|
183
186
|
}
|
|
@@ -186,7 +189,7 @@ export var useScrollCellIntoView = function useScrollCellIntoView(_ref) {
|
|
|
186
189
|
return function (_x) {
|
|
187
190
|
return _ref3.apply(this, arguments);
|
|
188
191
|
};
|
|
189
|
-
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter]);
|
|
192
|
+
}(), [gridRef, outerGridRef, hasGridScrolling, headerRowHeight, footerRowHeight, visibleRowCount, hasStickyFooter, canDragAndDropColumns]);
|
|
190
193
|
return {
|
|
191
194
|
scrollCellIntoView: scrollCellIntoView
|
|
192
195
|
};
|
|
@@ -32,6 +32,8 @@ export var EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
32
32
|
locale = _ref.locale,
|
|
33
33
|
roundUp = _ref.roundUp,
|
|
34
34
|
utcOffset = _ref.utcOffset,
|
|
35
|
+
minDate = _ref.minDate,
|
|
36
|
+
maxDate = _ref.maxDate,
|
|
35
37
|
labelPrefix = _ref.labelPrefix;
|
|
36
38
|
var styles = useEuiMemoizedStyles(euiAbsoluteTabDateFormStyles);
|
|
37
39
|
var _useState = useState(function () {
|
|
@@ -125,7 +127,9 @@ export var EuiAbsoluteTab = function EuiAbsoluteTab(_ref) {
|
|
|
125
127
|
dateFormat: dateFormat,
|
|
126
128
|
timeFormat: timeFormat,
|
|
127
129
|
locale: locale,
|
|
128
|
-
utcOffset: utcOffset
|
|
130
|
+
utcOffset: utcOffset,
|
|
131
|
+
minDate: minDate,
|
|
132
|
+
maxDate: maxDate
|
|
129
133
|
}), ___EmotionJSX(EuiFlexGroup, {
|
|
130
134
|
component: "form",
|
|
131
135
|
onSubmit: function onSubmit(e) {
|
package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
3
|
+
var _excluded = ["position", "isDisabled", "isInvalid", "needsUpdating", "value", "buttonProps", "canRoundRelativeUnits", "roundUp", "onChange", "locale", "dateFormat", "utcOffset", "minDate", "maxDate", "timeFormat", "isOpen", "onPopoverToggle", "onPopoverClose", "compressed", "timeOptions"];
|
|
4
4
|
/*
|
|
5
5
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
6
6
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -33,6 +33,8 @@ export var EuiDatePopoverButton = function EuiDatePopoverButton(props) {
|
|
|
33
33
|
locale = props.locale,
|
|
34
34
|
dateFormat = props.dateFormat,
|
|
35
35
|
utcOffset = props.utcOffset,
|
|
36
|
+
minDate = props.minDate,
|
|
37
|
+
maxDate = props.maxDate,
|
|
36
38
|
timeFormat = props.timeFormat,
|
|
37
39
|
isOpen = props.isOpen,
|
|
38
40
|
onPopoverToggle = props.onPopoverToggle,
|
|
@@ -93,7 +95,9 @@ export var EuiDatePopoverButton = function EuiDatePopoverButton(props) {
|
|
|
93
95
|
locale: locale,
|
|
94
96
|
position: position,
|
|
95
97
|
utcOffset: utcOffset,
|
|
96
|
-
timeOptions: timeOptions
|
|
98
|
+
timeOptions: timeOptions,
|
|
99
|
+
minDate: minDate,
|
|
100
|
+
maxDate: maxDate
|
|
97
101
|
}));
|
|
98
102
|
};
|
|
99
103
|
EuiDatePopoverButton.displayName = 'EuiDatePopoverButton';
|
package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js
CHANGED
|
@@ -30,7 +30,9 @@ export var EuiDatePopoverContent = function EuiDatePopoverContent(_ref) {
|
|
|
30
30
|
locale = _ref.locale,
|
|
31
31
|
position = _ref.position,
|
|
32
32
|
utcOffset = _ref.utcOffset,
|
|
33
|
-
timeOptions = _ref.timeOptions
|
|
33
|
+
timeOptions = _ref.timeOptions,
|
|
34
|
+
minDate = _ref.minDate,
|
|
35
|
+
maxDate = _ref.maxDate;
|
|
34
36
|
var styles = useEuiMemoizedStyles(euiDatePopoverContentStyles);
|
|
35
37
|
var onTabClick = function onTabClick(selectedTab) {
|
|
36
38
|
switch (selectedTab.id) {
|
|
@@ -59,7 +61,9 @@ export var EuiDatePopoverContent = function EuiDatePopoverContent(_ref) {
|
|
|
59
61
|
onChange: onChange,
|
|
60
62
|
roundUp: roundUp,
|
|
61
63
|
labelPrefix: labelPrefix,
|
|
62
|
-
utcOffset: utcOffset
|
|
64
|
+
utcOffset: utcOffset,
|
|
65
|
+
minDate: minDate,
|
|
66
|
+
maxDate: maxDate
|
|
63
67
|
}),
|
|
64
68
|
'data-test-subj': 'superDatePickerAbsoluteTab',
|
|
65
69
|
'aria-label': "".concat(labelPrefix, ": ").concat(absoluteLabel)
|
|
@@ -37,7 +37,7 @@ import { EuiDatePopoverButton } from './date_popover/date_popover_button';
|
|
|
37
37
|
import { EuiAutoRefresh, EuiAutoRefreshButton } from '../auto_refresh/auto_refresh';
|
|
38
38
|
import { euiSuperDatePickerStyles } from './super_date_picker.styles';
|
|
39
39
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
40
|
-
function isRangeInvalid(start, end) {
|
|
40
|
+
function isRangeInvalid(start, end, minDate, maxDate) {
|
|
41
41
|
if (start === 'now' && end === 'now') {
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ function isRangeInvalid(start, end) {
|
|
|
45
45
|
var endMoment = dateMath.parse(end, {
|
|
46
46
|
roundUp: true
|
|
47
47
|
});
|
|
48
|
-
var isInvalid = !startMoment || !endMoment || !startMoment.isValid() || !endMoment.isValid() || !moment(startMoment).isValid() || !moment(endMoment).isValid() || startMoment.isAfter(endMoment);
|
|
48
|
+
var isInvalid = !startMoment || !endMoment || !startMoment.isValid() || !endMoment.isValid() || !moment(startMoment).isValid() || !moment(endMoment).isValid() || startMoment.isAfter(endMoment) || endMoment.isBefore(startMoment) || minDate != null && startMoment.isBefore(minDate) || maxDate != null && endMoment.isAfter(maxDate);
|
|
49
49
|
return isInvalid;
|
|
50
50
|
}
|
|
51
51
|
export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
@@ -64,7 +64,7 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
64
64
|
},
|
|
65
65
|
start: _this.props.start,
|
|
66
66
|
end: _this.props.end,
|
|
67
|
-
isInvalid: isRangeInvalid(_this.props.start, _this.props.end),
|
|
67
|
+
isInvalid: isRangeInvalid(_this.props.start, _this.props.end, _this.props.minDate, _this.props.maxDate),
|
|
68
68
|
hasChanged: false,
|
|
69
69
|
showPrettyDuration: showPrettyDuration(_this.props.start, _this.props.end, _this.props.commonlyUsedRanges),
|
|
70
70
|
isStartDatePopoverOpen: false,
|
|
@@ -73,7 +73,7 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
73
73
|
_defineProperty(_this, "setTime", function (_ref) {
|
|
74
74
|
var end = _ref.end,
|
|
75
75
|
start = _ref.start;
|
|
76
|
-
var isInvalid = isRangeInvalid(start, end);
|
|
76
|
+
var isInvalid = isRangeInvalid(start, end, _this.props.minDate, _this.props.maxDate);
|
|
77
77
|
_this.setState({
|
|
78
78
|
start: start,
|
|
79
79
|
end: end,
|
|
@@ -262,6 +262,8 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
262
262
|
locale = _this$props3.locale,
|
|
263
263
|
timeFormat = _this$props3.timeFormat,
|
|
264
264
|
utcOffset = _this$props3.utcOffset,
|
|
265
|
+
minDate = _this$props3.minDate,
|
|
266
|
+
maxDate = _this$props3.maxDate,
|
|
265
267
|
compressed = _this$props3.compressed,
|
|
266
268
|
onFocus = _this$props3.onFocus,
|
|
267
269
|
styles = _this$props3.memoizedStyles;
|
|
@@ -336,6 +338,8 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
336
338
|
utcOffset: utcOffset,
|
|
337
339
|
timeFormat: timeFormat,
|
|
338
340
|
locale: locale || contextLocale,
|
|
341
|
+
minDate: minDate,
|
|
342
|
+
maxDate: maxDate,
|
|
339
343
|
canRoundRelativeUnits: canRoundRelativeUnits,
|
|
340
344
|
isOpen: _this.state.isStartDatePopoverOpen,
|
|
341
345
|
onPopoverToggle: _this.onStartDatePopoverToggle,
|
|
@@ -358,6 +362,8 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
358
362
|
utcOffset: utcOffset,
|
|
359
363
|
timeFormat: timeFormat,
|
|
360
364
|
locale: locale || contextLocale,
|
|
365
|
+
minDate: minDate,
|
|
366
|
+
maxDate: maxDate,
|
|
361
367
|
canRoundRelativeUnits: canRoundRelativeUnits,
|
|
362
368
|
roundUp: true,
|
|
363
369
|
isOpen: _this.state.isEndDatePopoverOpen,
|
|
@@ -463,7 +469,7 @@ export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
|
|
|
463
469
|
},
|
|
464
470
|
start: nextProps.start,
|
|
465
471
|
end: nextProps.end,
|
|
466
|
-
isInvalid: isRangeInvalid(nextProps.start, nextProps.end),
|
|
472
|
+
isInvalid: isRangeInvalid(nextProps.start, nextProps.end, nextProps.minDate, nextProps.maxDate),
|
|
467
473
|
hasChanged: false,
|
|
468
474
|
showPrettyDuration: showPrettyDuration(nextProps.start, nextProps.end, nextProps.commonlyUsedRanges)
|
|
469
475
|
};
|
|
@@ -45,6 +45,7 @@ export var EuiDraggable = function EuiDraggable(_ref) {
|
|
|
45
45
|
cloneItems = _useContext.cloneItems;
|
|
46
46
|
var euiTheme = useEuiTheme();
|
|
47
47
|
var styles = euiDraggableStyles(euiTheme);
|
|
48
|
+
var hasCustomDragHandle = customDragHandle !== false;
|
|
48
49
|
return ___EmotionJSX(Draggable, _extends({
|
|
49
50
|
draggableId: draggableId,
|
|
50
51
|
index: index,
|
|
@@ -52,13 +53,14 @@ export var EuiDraggable = function EuiDraggable(_ref) {
|
|
|
52
53
|
}, rest), function (provided, snapshot, rubric) {
|
|
53
54
|
var _provided$dragHandleP, _provided$dragHandleP2;
|
|
54
55
|
var isDragging = snapshot.isDragging;
|
|
56
|
+
var isFullyCustomDragHandle = customDragHandle === 'custom';
|
|
55
57
|
var cssStyles = [styles.euiDraggable, cloneItems && !isDragging && styles.hasClone, isDragging && styles.isDragging, isRemovable && styles.isRemovable, styles.spacing[spacing]];
|
|
56
58
|
var classes = classNames('euiDraggable', className);
|
|
57
59
|
var childClasses = classNames('euiDraggable__item', {
|
|
58
60
|
'euiDraggable__item-isDisabled': isDragDisabled
|
|
59
61
|
});
|
|
60
62
|
var DraggableElement = typeof children === 'function' ? children(provided, snapshot, rubric) : children;
|
|
61
|
-
var content = ___EmotionJSX(React.Fragment, null, ___EmotionJSX("div", _extends({}, provided.draggableProps, !
|
|
63
|
+
var content = ___EmotionJSX(React.Fragment, null, ___EmotionJSX("div", _extends({}, provided.draggableProps, !hasCustomDragHandle ? provided.dragHandleProps : {}, {
|
|
62
64
|
ref: provided.innerRef,
|
|
63
65
|
"data-test-subj": dataTestSubj,
|
|
64
66
|
className: classes,
|
|
@@ -68,11 +70,14 @@ export var EuiDraggable = function EuiDraggable(_ref) {
|
|
|
68
70
|
// interactive element. Screen readers will cue users that this is a container
|
|
69
71
|
// and has one or more elements inside that are part of a related group.
|
|
70
72
|
,
|
|
71
|
-
role:
|
|
73
|
+
role: isFullyCustomDragHandle ? undefined // prevent wrapper role from removing semantics of the children
|
|
74
|
+
: hasInteractiveChildren ? 'group' : (_provided$dragHandleP = provided.dragHandleProps) === null || _provided$dragHandleP === void 0 ? void 0 : _provided$dragHandleP.role
|
|
72
75
|
// If the container includes an interactive element, we remove the tabindex=0
|
|
73
76
|
// because [role="group"] does not permit or warrant a tab stop
|
|
77
|
+
// additionally we remove the tabindex when the child is a fully custom handle
|
|
78
|
+
// that has its own tabindex and handle props
|
|
74
79
|
,
|
|
75
|
-
tabIndex: hasInteractiveChildren ? undefined : (_provided$dragHandleP2 = provided.dragHandleProps) === null || _provided$dragHandleP2 === void 0 ? void 0 : _provided$dragHandleP2.tabIndex
|
|
80
|
+
tabIndex: hasInteractiveChildren || isFullyCustomDragHandle ? undefined : (_provided$dragHandleP2 = provided.dragHandleProps) === null || _provided$dragHandleP2 === void 0 ? void 0 : _provided$dragHandleP2.tabIndex
|
|
76
81
|
}), cloneElementWithCss(DraggableElement, {
|
|
77
82
|
className: classNames(DraggableElement.props.className, childClasses),
|
|
78
83
|
css: [euiDraggableItemStyles.euiDraggable__item, isDragDisabled && euiDraggableItemStyles.disabled]
|