@elastic/eui 122.1.0 → 123.0.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/dist/eui-icons.json +94 -94
- package/es/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/es/components/datagrid/utils/row_heights.js +4 -1
- package/es/components/flyout/flyout.component.js +129 -55
- package/es/components/flyout/flyout_menu/action_button.js +15 -21
- package/es/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/es/components/flyout/manager/flyout_managed.js +24 -6
- package/es/components/form/described_form_group/described_form_group.js +17 -4
- package/es/components/tabs/tabbed_content/tabbed_content.js +93 -138
- package/es/components/text_truncate/text_truncate.js +9 -4
- package/eui.d.ts +32 -58
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/lib/components/datagrid/utils/row_heights.js +4 -1
- package/lib/components/flyout/flyout.component.js +134 -62
- package/lib/components/flyout/flyout_menu/action_button.js +18 -23
- package/lib/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/lib/components/flyout/manager/flyout_managed.js +23 -5
- package/lib/components/form/described_form_group/described_form_group.js +19 -3
- package/lib/components/tabs/tabbed_content/tabbed_content.js +98 -142
- package/lib/components/text_truncate/text_truncate.js +9 -4
- package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +116 -36
- package/optimize/es/components/datagrid/utils/row_heights.js +4 -1
- package/optimize/es/components/flyout/flyout.component.js +124 -50
- package/optimize/es/components/flyout/flyout_menu/action_button.js +14 -21
- package/optimize/es/components/flyout/manager/flyout_managed.js +24 -6
- package/optimize/es/components/form/described_form_group/described_form_group.js +17 -4
- package/optimize/es/components/tabs/tabbed_content/tabbed_content.js +87 -131
- package/optimize/es/components/text_truncate/text_truncate.js +4 -3
- package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +116 -36
- package/optimize/lib/components/datagrid/utils/row_heights.js +4 -1
- package/optimize/lib/components/flyout/flyout.component.js +123 -49
- package/optimize/lib/components/flyout/flyout_menu/action_button.js +14 -22
- package/optimize/lib/components/flyout/manager/flyout_managed.js +23 -5
- package/optimize/lib/components/form/described_form_group/described_form_group.js +19 -3
- package/optimize/lib/components/tabs/tabbed_content/tabbed_content.js +87 -131
- package/optimize/lib/components/text_truncate/text_truncate.js +4 -3
- package/package.json +2 -2
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +119 -36
- package/test-env/components/datagrid/utils/row_heights.js +4 -1
- package/test-env/components/flyout/flyout.component.js +123 -49
- package/test-env/components/flyout/flyout_menu/action_button.js +14 -22
- package/test-env/components/flyout/flyout_menu/flyout_menu.js +40 -46
- package/test-env/components/flyout/manager/flyout_managed.js +23 -5
- package/test-env/components/form/described_form_group/described_form_group.js +19 -3
- package/test-env/components/tabs/tabbed_content/tabbed_content.js +88 -132
- package/test-env/components/text_truncate/text_truncate.js +9 -4
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
var _excluded = ["className", "expand", "initialSelectedTab", "onTabClick", "selectedTab", "size", "tabs", "autoFocus"],
|
|
4
|
+
var _excluded = ["autoFocus", "className", "expand", "initialSelectedTab", "onTabClick", "selectedTab", "size", "tabs"],
|
|
10
5
|
_excluded2 = ["id", "name", "content"];
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
6
|
/*
|
|
16
7
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
17
8
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -20,134 +11,99 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
20
11
|
* Side Public License, v 1.
|
|
21
12
|
*/
|
|
22
13
|
|
|
23
|
-
import React, {
|
|
24
|
-
import { htmlIdGenerator } from '../../../services';
|
|
14
|
+
import React, { useRef, useState } from 'react';
|
|
25
15
|
import { EuiTabs } from '../tabs';
|
|
26
16
|
import { EuiTab } from '../tab';
|
|
27
|
-
import {
|
|
17
|
+
import { useGeneratedHtmlId } from '../../../services';
|
|
18
|
+
|
|
28
19
|
/**
|
|
29
20
|
* Marked as const so type is `['initial', 'selected']` instead of `string[]`
|
|
30
21
|
*/
|
|
22
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
31
23
|
export var AUTOFOCUS = ['initial', 'selected'];
|
|
32
|
-
export var EuiTabbedContent =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!externalSelectedTab) {
|
|
74
|
-
_this.setState({
|
|
75
|
-
selectedTabId: selectedTab.id
|
|
76
|
-
}, function () {
|
|
77
|
-
_this.focusTab();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
var initialSelectedTab = props.initialSelectedTab,
|
|
82
|
-
_selectedTab = props.selectedTab,
|
|
83
|
-
tabs = props.tabs;
|
|
24
|
+
export var EuiTabbedContent = function EuiTabbedContent(_ref) {
|
|
25
|
+
var _ref$autoFocus = _ref.autoFocus,
|
|
26
|
+
autoFocus = _ref$autoFocus === void 0 ? 'initial' : _ref$autoFocus,
|
|
27
|
+
className = _ref.className,
|
|
28
|
+
expand = _ref.expand,
|
|
29
|
+
initialSelectedTab = _ref.initialSelectedTab,
|
|
30
|
+
onTabClick = _ref.onTabClick,
|
|
31
|
+
externalSelectedTab = _ref.selectedTab,
|
|
32
|
+
size = _ref.size,
|
|
33
|
+
tabs = _ref.tabs,
|
|
34
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
var rootId = useGeneratedHtmlId();
|
|
36
|
+
var tabsRef = useRef(null);
|
|
37
|
+
var inFocusRef = useRef(false);
|
|
38
|
+
var _useState = useState(function () {
|
|
39
|
+
return externalSelectedTab ? undefined : (initialSelectedTab === null || initialSelectedTab === void 0 ? void 0 : initialSelectedTab.id) || tabs[0].id;
|
|
40
|
+
}),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
+
selectedTabId = _useState2[0],
|
|
43
|
+
setSelectedTabId = _useState2[1];
|
|
44
|
+
var focusTab = function focusTab(id) {
|
|
45
|
+
var _tabsRef$current;
|
|
46
|
+
var targetTab = (_tabsRef$current = tabsRef.current) === null || _tabsRef$current === void 0 ? void 0 : _tabsRef$current.querySelector("#".concat(id));
|
|
47
|
+
targetTab === null || targetTab === void 0 || targetTab.focus();
|
|
48
|
+
};
|
|
49
|
+
var initializeFocus = function initializeFocus() {
|
|
50
|
+
if (!inFocusRef.current && autoFocus === 'selected') {
|
|
51
|
+
inFocusRef.current = true;
|
|
52
|
+
focusTab(selectedTabId);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var removeFocus = function removeFocus(blurEvent) {
|
|
56
|
+
// only set inFocus to false if the wrapping div doesn't contain the now-focusing element
|
|
57
|
+
var currentTarget = blurEvent.currentTarget;
|
|
58
|
+
var relatedTarget = blurEvent.relatedTarget;
|
|
59
|
+
if (currentTarget.contains(relatedTarget) === false) {
|
|
60
|
+
inFocusRef.current = false;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var handleTabClick = function handleTabClick(tab) {
|
|
64
|
+
onTabClick === null || onTabClick === void 0 || onTabClick(tab);
|
|
84
65
|
|
|
85
66
|
// Only track selection state if it's not controlled externally.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
67
|
+
if (!externalSelectedTab) {
|
|
68
|
+
setSelectedTabId(tab.id);
|
|
69
|
+
focusTab(tab.id);
|
|
89
70
|
}
|
|
90
|
-
|
|
91
|
-
selectedTabId: selectedTabId,
|
|
92
|
-
inFocus: false
|
|
93
|
-
};
|
|
94
|
-
return _this;
|
|
95
|
-
}
|
|
96
|
-
_inherits(EuiTabbedContent, _Component);
|
|
97
|
-
return _createClass(EuiTabbedContent, [{
|
|
98
|
-
key: "render",
|
|
99
|
-
value: function render() {
|
|
100
|
-
var _this2 = this;
|
|
101
|
-
var _this$props2 = this.props,
|
|
102
|
-
className = _this$props2.className,
|
|
103
|
-
expand = _this$props2.expand,
|
|
104
|
-
initialSelectedTab = _this$props2.initialSelectedTab,
|
|
105
|
-
onTabClick = _this$props2.onTabClick,
|
|
106
|
-
externalSelectedTab = _this$props2.selectedTab,
|
|
107
|
-
size = _this$props2.size,
|
|
108
|
-
tabs = _this$props2.tabs,
|
|
109
|
-
autoFocus = _this$props2.autoFocus,
|
|
110
|
-
rest = _objectWithoutProperties(_this$props2, _excluded);
|
|
71
|
+
};
|
|
111
72
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
73
|
+
// Allow the consumer to control tab selection.
|
|
74
|
+
var selectedTab = externalSelectedTab || tabs.find(function (tab) {
|
|
75
|
+
return tab.id === selectedTabId;
|
|
76
|
+
}) || tabs[0]; // Fall back to the first tab if a selected tab can't be found
|
|
116
77
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}]);
|
|
150
|
-
}(Component);
|
|
151
|
-
_defineProperty(EuiTabbedContent, "defaultProps", {
|
|
152
|
-
autoFocus: 'initial'
|
|
153
|
-
});
|
|
78
|
+
var selectedTabContent = selectedTab.content,
|
|
79
|
+
selectedTabContentId = selectedTab.id;
|
|
80
|
+
return ___EmotionJSX("div", _extends({
|
|
81
|
+
className: className
|
|
82
|
+
}, rest), ___EmotionJSX(EuiTabs, {
|
|
83
|
+
ref: tabsRef,
|
|
84
|
+
expand: expand,
|
|
85
|
+
size: size,
|
|
86
|
+
onFocus: initializeFocus,
|
|
87
|
+
onBlur: removeFocus
|
|
88
|
+
}, tabs.map(function (tab) {
|
|
89
|
+
var id = tab.id,
|
|
90
|
+
name = tab.name,
|
|
91
|
+
content = tab.content,
|
|
92
|
+
tabProps = _objectWithoutProperties(tab, _excluded2);
|
|
93
|
+
return ___EmotionJSX(EuiTab, _extends({
|
|
94
|
+
key: id,
|
|
95
|
+
id: id
|
|
96
|
+
}, tabProps, {
|
|
97
|
+
onClick: function onClick() {
|
|
98
|
+
return handleTabClick(tab);
|
|
99
|
+
},
|
|
100
|
+
isSelected: tab === selectedTab,
|
|
101
|
+
"aria-controls": rootId
|
|
102
|
+
}), name);
|
|
103
|
+
})), ___EmotionJSX("div", {
|
|
104
|
+
role: "tabpanel",
|
|
105
|
+
id: rootId,
|
|
106
|
+
"aria-labelledby": selectedTabContentId
|
|
107
|
+
}, selectedTabContent));
|
|
108
|
+
};
|
|
109
|
+
EuiTabbedContent.displayName = 'EuiTabbedContent';
|
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["width", "onResize"],
|
|
5
|
-
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "calculationDelayMs", "containerRef", "className"],
|
|
5
|
+
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "calculationDelayMs", "containerRef", "className", "toolTipProps"],
|
|
6
6
|
_excluded3 = ["onResize"];
|
|
7
7
|
/*
|
|
8
8
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -45,6 +45,7 @@ var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
|
|
|
45
45
|
calculationDelayMs = _ref2.calculationDelayMs,
|
|
46
46
|
containerRef = _ref2.containerRef,
|
|
47
47
|
className = _ref2.className,
|
|
48
|
+
toolTipProps = _ref2.toolTipProps,
|
|
48
49
|
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
49
50
|
// Note: This needs to be a state and not a ref to trigger a rerender on mount
|
|
50
51
|
var _useState = useState(null),
|
|
@@ -146,11 +147,11 @@ var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
|
|
|
146
147
|
className: "euiTextTruncate__fullText",
|
|
147
148
|
"data-test-subj": "fullText"
|
|
148
149
|
}, children ? children(text) : text));
|
|
149
|
-
return isTruncating ? ___EmotionJSX(EuiToolTip, {
|
|
150
|
+
return isTruncating ? ___EmotionJSX(EuiToolTip, _extends({
|
|
150
151
|
content: text,
|
|
151
152
|
disableScreenReaderOutput: true,
|
|
152
153
|
display: "block"
|
|
153
|
-
}, content) : content;
|
|
154
|
+
}, toolTipProps), content) : content;
|
|
154
155
|
};
|
|
155
156
|
var EuiTextTruncateWithResizeObserver = function EuiTextTruncateWithResizeObserver(_ref3) {
|
|
156
157
|
var _onResize = _ref3.onResize,
|
|
@@ -24,7 +24,8 @@ var _row_heights = require("../utils/row_heights");
|
|
|
24
24
|
var _scrolling = require("../utils/scrolling");
|
|
25
25
|
var _utils = require("../../../utils");
|
|
26
26
|
var _react2 = require("@emotion/react");
|
|
27
|
-
var _excluded = ["children", "style"]
|
|
27
|
+
var _excluded = ["children", "style"],
|
|
28
|
+
_excluded2 = ["onScroll"];
|
|
28
29
|
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); }
|
|
29
30
|
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; }
|
|
30
31
|
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; }
|
|
@@ -84,40 +85,93 @@ var InnerElement = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwar
|
|
|
84
85
|
}, rest), headerRow, children), footerRow);
|
|
85
86
|
}));
|
|
86
87
|
InnerElement.displayName = 'EuiDataGridInnerElement';
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
88
|
+
var DataGridOuterElementContext = /*#__PURE__*/(0, _react.createContext)({
|
|
89
|
+
scrollPositionRef: {
|
|
90
|
+
current: null
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
var clampScrollOffset = function clampScrollOffset(offset, max) {
|
|
94
|
+
return Math.max(0, Math.min(offset, max));
|
|
95
|
+
};
|
|
96
|
+
var OuterElement = /*#__PURE__*/(0, _react.forwardRef)(function (_ref3, ref) {
|
|
97
|
+
var onScroll = _ref3.onScroll,
|
|
98
|
+
rest = (0, _objectWithoutProperties2.default)(_ref3, _excluded2);
|
|
99
|
+
var _useContext2 = (0, _react.useContext)(DataGridOuterElementContext),
|
|
100
|
+
_useContext2$outerEle = _useContext2.outerElementType,
|
|
101
|
+
Element = _useContext2$outerEle === void 0 ? 'div' : _useContext2$outerEle,
|
|
102
|
+
direction = _useContext2.direction,
|
|
103
|
+
scrollPositionRef = _useContext2.scrollPositionRef;
|
|
104
|
+
|
|
105
|
+
// react-window compares the raw scroll offsets against its own clamped
|
|
106
|
+
// offsets, and flags the grid as scrolling (setting `pointer-events: none`
|
|
107
|
+
// on the inner element) whenever they differ. Firefox can report a
|
|
108
|
+
// `scrollTop` above the maximum at fractional device pixel ratios, which
|
|
109
|
+
// makes every scroll event at the bottom of the grid look like a scroll,
|
|
110
|
+
// so hovered cells lose the pointer and tooltips repeatedly open and close.
|
|
111
|
+
var onScrollIfMoved = (0, _react.useCallback)(function (event) {
|
|
112
|
+
if (direction !== 'rtl') {
|
|
113
|
+
var _event$currentTarget = event.currentTarget,
|
|
114
|
+
scrollTop = _event$currentTarget.scrollTop,
|
|
115
|
+
scrollLeft = _event$currentTarget.scrollLeft,
|
|
116
|
+
scrollHeight = _event$currentTarget.scrollHeight,
|
|
117
|
+
scrollWidth = _event$currentTarget.scrollWidth,
|
|
118
|
+
clientHeight = _event$currentTarget.clientHeight,
|
|
119
|
+
clientWidth = _event$currentTarget.clientWidth;
|
|
120
|
+
var scrollPosition = {
|
|
121
|
+
scrollTop: clampScrollOffset(scrollTop, scrollHeight - clientHeight),
|
|
122
|
+
scrollLeft: clampScrollOffset(scrollLeft, scrollWidth - clientWidth)
|
|
123
|
+
};
|
|
124
|
+
var previousScrollPosition = scrollPositionRef.current;
|
|
125
|
+
if (previousScrollPosition && scrollPosition.scrollTop === previousScrollPosition.scrollTop && scrollPosition.scrollLeft === previousScrollPosition.scrollLeft) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
// react-window may not have rendered the previous event's position
|
|
129
|
+
// yet, so the ref must reflect every forwarded event, not only the
|
|
130
|
+
// positions react-window reports back through its `onScroll` prop.
|
|
131
|
+
scrollPositionRef.current = scrollPosition;
|
|
132
|
+
}
|
|
133
|
+
onScroll(event);
|
|
134
|
+
}, [onScroll, direction, scrollPositionRef]);
|
|
135
|
+
return (0, _react2.jsx)(Element, (0, _extends2.default)({
|
|
136
|
+
ref: ref,
|
|
137
|
+
onScroll: onScrollIfMoved
|
|
138
|
+
}, rest));
|
|
139
|
+
});
|
|
140
|
+
OuterElement.displayName = 'EuiDataGridOuterElement';
|
|
141
|
+
var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE__*/(0, _react.memo)(function (_ref4) {
|
|
142
|
+
var leadingControlColumns = _ref4.leadingControlColumns,
|
|
143
|
+
trailingControlColumns = _ref4.trailingControlColumns,
|
|
144
|
+
columns = _ref4.columns,
|
|
145
|
+
visibleColCount = _ref4.visibleColCount,
|
|
146
|
+
schema = _ref4.schema,
|
|
147
|
+
schemaDetectors = _ref4.schemaDetectors,
|
|
148
|
+
rowCount = _ref4.rowCount,
|
|
149
|
+
_ref4$visibleRows = _ref4.visibleRows,
|
|
150
|
+
startRow = _ref4$visibleRows.startRow,
|
|
151
|
+
endRow = _ref4$visibleRows.endRow,
|
|
152
|
+
visibleRowCount = _ref4$visibleRows.visibleRowCount,
|
|
153
|
+
renderCellValue = _ref4.renderCellValue,
|
|
154
|
+
cellContext = _ref4.cellContext,
|
|
155
|
+
renderCellPopover = _ref4.renderCellPopover,
|
|
156
|
+
renderFooterCellValue = _ref4.renderFooterCellValue,
|
|
157
|
+
interactiveCellId = _ref4.interactiveCellId,
|
|
158
|
+
pagination = _ref4.pagination,
|
|
159
|
+
sorting = _ref4.sorting,
|
|
160
|
+
setVisibleColumns = _ref4.setVisibleColumns,
|
|
161
|
+
switchColumnPos = _ref4.switchColumnPos,
|
|
162
|
+
onColumnResize = _ref4.onColumnResize,
|
|
163
|
+
rowHeightsOptions = _ref4.rowHeightsOptions,
|
|
164
|
+
virtualizationOptions = _ref4.virtualizationOptions,
|
|
165
|
+
isFullScreen = _ref4.isFullScreen,
|
|
166
|
+
gridStyles = _ref4.gridStyles,
|
|
167
|
+
gridWidth = _ref4.gridWidth,
|
|
168
|
+
gridRef = _ref4.gridRef,
|
|
169
|
+
gridItemsRendered = _ref4.gridItemsRendered,
|
|
170
|
+
wrapperRef = _ref4.wrapperRef,
|
|
171
|
+
className = _ref4.className,
|
|
172
|
+
canDragAndDropColumns = _ref4.canDragAndDropColumns,
|
|
173
|
+
_ref4$showHeader = _ref4.showHeader,
|
|
174
|
+
showHeader = _ref4$showHeader === void 0 ? true : _ref4$showHeader;
|
|
121
175
|
/**
|
|
122
176
|
* Grid refs & observers
|
|
123
177
|
*/
|
|
@@ -313,7 +367,30 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
313
367
|
footerRow: footerRow
|
|
314
368
|
};
|
|
315
369
|
}, [headerRowHeight, headerRow, footerRow, showHeader]);
|
|
370
|
+
var scrollPositionRef = (0, _react.useRef)(null);
|
|
371
|
+
var outerElementContextValue = (0, _react.useMemo)(function () {
|
|
372
|
+
return {
|
|
373
|
+
outerElementType: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType,
|
|
374
|
+
direction: virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction,
|
|
375
|
+
scrollPositionRef: scrollPositionRef
|
|
376
|
+
};
|
|
377
|
+
}, [virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.outerElementType, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.direction]);
|
|
316
378
|
var onScroll = (0, _react.useCallback)(function (args) {
|
|
379
|
+
var element = outerGridRef.current;
|
|
380
|
+
// `scrollTo` reports the requested offset, which can sit past the
|
|
381
|
+
// end. Storing that would replace the clamped position already
|
|
382
|
+
// taken from the DOM. Leave the ref unchanged instead of writing
|
|
383
|
+
// the clamped value: a scroll event that has not arrived yet still
|
|
384
|
+
// differs from the previous position and is forwarded.
|
|
385
|
+
var topInRange = element == null || args.scrollTop === clampScrollOffset(args.scrollTop, element.scrollHeight - element.clientHeight);
|
|
386
|
+
var leftInRange = element == null || args.scrollLeft === clampScrollOffset(args.scrollLeft, element.scrollWidth - element.clientWidth);
|
|
387
|
+
if (topInRange && leftInRange) {
|
|
388
|
+
scrollPositionRef.current = {
|
|
389
|
+
scrollTop: args.scrollTop,
|
|
390
|
+
scrollLeft: args.scrollLeft
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
317
394
|
// check only if a callback is passed
|
|
318
395
|
if (typeof (virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.onScroll) !== 'function') return;
|
|
319
396
|
var enhancedArgs = _objectSpread(_objectSpread({}, args), {}, {
|
|
@@ -357,10 +434,13 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
357
434
|
}, [outerGridRef, virtualizationOptions]);
|
|
358
435
|
return _utils.IS_JEST_ENVIRONMENT || finalWidth > 0 ? (0, _react2.jsx)(DataGridWrapperRowsContext.Provider, {
|
|
359
436
|
value: rowWrapperContextValue
|
|
437
|
+
}, (0, _react2.jsx)(DataGridOuterElementContext.Provider, {
|
|
438
|
+
value: outerElementContextValue
|
|
360
439
|
}, (0, _react2.jsx)(_reactWindow.VariableSizeGrid, (0, _extends2.default)({}, virtualizationOptions, {
|
|
361
440
|
ref: gridRef,
|
|
362
441
|
className: (0, _classnames.default)('euiDataGrid__virtualized', className, virtualizationOptions === null || virtualizationOptions === void 0 ? void 0 : virtualizationOptions.className),
|
|
363
442
|
onItemsRendered: onItemsRendered,
|
|
443
|
+
outerElementType: OuterElement,
|
|
364
444
|
innerElementType: InnerElement,
|
|
365
445
|
outerRef: outerGridRef,
|
|
366
446
|
innerRef: innerGridRef,
|
|
@@ -372,6 +452,6 @@ var EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE_
|
|
|
372
452
|
itemData: itemData,
|
|
373
453
|
rowCount: _utils.IS_JEST_ENVIRONMENT || headerRowHeight > 0 || showHeader === false && innerGridRef.current ? visibleRowCount : 0,
|
|
374
454
|
onScroll: onScroll
|
|
375
|
-
}), Cell), scrollBorderOverlay) : null;
|
|
455
|
+
}), Cell)), scrollBorderOverlay) : null;
|
|
376
456
|
});
|
|
377
457
|
EuiDataGridBodyVirtualized.displayName = 'EuiDataGridBodyVirtualized';
|
|
@@ -298,7 +298,10 @@ var useRowHeightUtils = exports.useRowHeightUtils = function useRowHeightUtils(_
|
|
|
298
298
|
if (forceRenderRef.current == null) {
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
-
requestAnimationFrame(forceRenderRef.current);
|
|
301
|
+
var frameId = requestAnimationFrame(forceRenderRef.current);
|
|
302
|
+
return function () {
|
|
303
|
+
return cancelAnimationFrame(frameId);
|
|
304
|
+
};
|
|
302
305
|
}, [// Effects that should cause rerendering
|
|
303
306
|
rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.defaultHeight, rowHeightsOptions === null || rowHeightsOptions === void 0 ? void 0 : rowHeightsOptions.rowHeights,
|
|
304
307
|
// Dependencies
|