@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.
Files changed (46) hide show
  1. package/dist/eui-icons.json +94 -94
  2. package/es/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  3. package/es/components/datagrid/utils/row_heights.js +4 -1
  4. package/es/components/flyout/flyout.component.js +129 -55
  5. package/es/components/flyout/flyout_menu/action_button.js +15 -21
  6. package/es/components/flyout/flyout_menu/flyout_menu.js +40 -46
  7. package/es/components/flyout/manager/flyout_managed.js +24 -6
  8. package/es/components/form/described_form_group/described_form_group.js +17 -4
  9. package/es/components/tabs/tabbed_content/tabbed_content.js +93 -138
  10. package/es/components/text_truncate/text_truncate.js +9 -4
  11. package/eui.d.ts +32 -58
  12. package/lib/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  13. package/lib/components/datagrid/utils/row_heights.js +4 -1
  14. package/lib/components/flyout/flyout.component.js +134 -62
  15. package/lib/components/flyout/flyout_menu/action_button.js +18 -23
  16. package/lib/components/flyout/flyout_menu/flyout_menu.js +40 -46
  17. package/lib/components/flyout/manager/flyout_managed.js +23 -5
  18. package/lib/components/form/described_form_group/described_form_group.js +19 -3
  19. package/lib/components/tabs/tabbed_content/tabbed_content.js +98 -142
  20. package/lib/components/text_truncate/text_truncate.js +9 -4
  21. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  22. package/optimize/es/components/datagrid/utils/row_heights.js +4 -1
  23. package/optimize/es/components/flyout/flyout.component.js +124 -50
  24. package/optimize/es/components/flyout/flyout_menu/action_button.js +14 -21
  25. package/optimize/es/components/flyout/manager/flyout_managed.js +24 -6
  26. package/optimize/es/components/form/described_form_group/described_form_group.js +17 -4
  27. package/optimize/es/components/tabs/tabbed_content/tabbed_content.js +87 -131
  28. package/optimize/es/components/text_truncate/text_truncate.js +4 -3
  29. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +116 -36
  30. package/optimize/lib/components/datagrid/utils/row_heights.js +4 -1
  31. package/optimize/lib/components/flyout/flyout.component.js +123 -49
  32. package/optimize/lib/components/flyout/flyout_menu/action_button.js +14 -22
  33. package/optimize/lib/components/flyout/manager/flyout_managed.js +23 -5
  34. package/optimize/lib/components/form/described_form_group/described_form_group.js +19 -3
  35. package/optimize/lib/components/tabs/tabbed_content/tabbed_content.js +87 -131
  36. package/optimize/lib/components/text_truncate/text_truncate.js +4 -3
  37. package/package.json +2 -2
  38. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +119 -36
  39. package/test-env/components/datagrid/utils/row_heights.js +4 -1
  40. package/test-env/components/flyout/flyout.component.js +123 -49
  41. package/test-env/components/flyout/flyout_menu/action_button.js +14 -22
  42. package/test-env/components/flyout/flyout_menu/flyout_menu.js +40 -46
  43. package/test-env/components/flyout/manager/flyout_managed.js +23 -5
  44. package/test-env/components/form/described_form_group/described_form_group.js +19 -3
  45. package/test-env/components/tabs/tabbed_content/tabbed_content.js +88 -132
  46. 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
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
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, { Component, createRef } from '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 { jsx as ___EmotionJSX } from "@emotion/react";
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 = /*#__PURE__*/function (_Component) {
33
- function EuiTabbedContent(props) {
34
- var _this;
35
- _classCallCheck(this, EuiTabbedContent);
36
- _this = _callSuper(this, EuiTabbedContent, [props]);
37
- _defineProperty(_this, "rootId", htmlIdGenerator()());
38
- _defineProperty(_this, "tabsRef", /*#__PURE__*/createRef());
39
- _defineProperty(_this, "focusTab", function () {
40
- var targetTab = _this.tabsRef.current.querySelector("#".concat(_this.state.selectedTabId));
41
- targetTab.focus();
42
- });
43
- _defineProperty(_this, "initializeFocus", function () {
44
- if (!_this.state.inFocus && _this.props.autoFocus === 'selected') {
45
- // Must wait for setState to finish before calling `.focus()`
46
- // as the focus call triggers a blur on the first tab
47
- _this.setState({
48
- inFocus: true
49
- }, function () {
50
- _this.focusTab();
51
- });
52
- }
53
- });
54
- _defineProperty(_this, "removeFocus", function (blurEvent) {
55
- // only set inFocus to false if the wrapping div doesn't contain the now-focusing element
56
- var currentTarget = blurEvent.currentTarget;
57
- var relatedTarget = blurEvent.relatedTarget;
58
- if (currentTarget.contains(relatedTarget) === false) {
59
- _this.setState({
60
- inFocus: false
61
- });
62
- }
63
- });
64
- _defineProperty(_this, "onTabClick", function (selectedTab) {
65
- var _this$props = _this.props,
66
- onTabClick = _this$props.onTabClick,
67
- externalSelectedTab = _this$props.selectedTab;
68
- if (onTabClick) {
69
- onTabClick(selectedTab);
70
- }
71
-
72
- // Only track selection state if it's not controlled externally.
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
- var selectedTabId;
87
- if (!_selectedTab) {
88
- selectedTabId = (initialSelectedTab === null || initialSelectedTab === void 0 ? void 0 : initialSelectedTab.id) || tabs[0].id;
67
+ if (!externalSelectedTab) {
68
+ setSelectedTabId(tab.id);
69
+ focusTab(tab.id);
89
70
  }
90
- _this.state = {
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
- // Allow the consumer to control tab selection.
113
- var selectedTab = externalSelectedTab || tabs.find(function (tab) {
114
- return tab.id === _this2.state.selectedTabId;
115
- }) || tabs[0]; // Fall back to the first tab if a selected tab can't be found
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
- var selectedTabContent = selectedTab.content,
118
- selectedTabId = selectedTab.id;
119
- return ___EmotionJSX("div", _extends({
120
- className: className
121
- }, rest), ___EmotionJSX(EuiTabs, {
122
- ref: this.tabsRef,
123
- expand: expand,
124
- size: size,
125
- onFocus: this.initializeFocus,
126
- onBlur: this.removeFocus
127
- }, tabs.map(function (tab) {
128
- var id = tab.id,
129
- name = tab.name,
130
- content = tab.content,
131
- tabProps = _objectWithoutProperties(tab, _excluded2);
132
- var props = _objectSpread(_objectSpread({
133
- key: id,
134
- id: id
135
- }, tabProps), {}, {
136
- onClick: function onClick() {
137
- return _this2.onTabClick(tab);
138
- },
139
- isSelected: tab === selectedTab,
140
- 'aria-controls': "".concat(_this2.rootId)
141
- });
142
- return ___EmotionJSX(EuiTab, props, name);
143
- })), ___EmotionJSX("div", {
144
- role: "tabpanel",
145
- id: "".concat(this.rootId),
146
- "aria-labelledby": selectedTabId
147
- }, selectedTabContent));
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 EuiDataGridBodyVirtualized = exports.EuiDataGridBodyVirtualized = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
88
- var leadingControlColumns = _ref3.leadingControlColumns,
89
- trailingControlColumns = _ref3.trailingControlColumns,
90
- columns = _ref3.columns,
91
- visibleColCount = _ref3.visibleColCount,
92
- schema = _ref3.schema,
93
- schemaDetectors = _ref3.schemaDetectors,
94
- rowCount = _ref3.rowCount,
95
- _ref3$visibleRows = _ref3.visibleRows,
96
- startRow = _ref3$visibleRows.startRow,
97
- endRow = _ref3$visibleRows.endRow,
98
- visibleRowCount = _ref3$visibleRows.visibleRowCount,
99
- renderCellValue = _ref3.renderCellValue,
100
- cellContext = _ref3.cellContext,
101
- renderCellPopover = _ref3.renderCellPopover,
102
- renderFooterCellValue = _ref3.renderFooterCellValue,
103
- interactiveCellId = _ref3.interactiveCellId,
104
- pagination = _ref3.pagination,
105
- sorting = _ref3.sorting,
106
- setVisibleColumns = _ref3.setVisibleColumns,
107
- switchColumnPos = _ref3.switchColumnPos,
108
- onColumnResize = _ref3.onColumnResize,
109
- rowHeightsOptions = _ref3.rowHeightsOptions,
110
- virtualizationOptions = _ref3.virtualizationOptions,
111
- isFullScreen = _ref3.isFullScreen,
112
- gridStyles = _ref3.gridStyles,
113
- gridWidth = _ref3.gridWidth,
114
- gridRef = _ref3.gridRef,
115
- gridItemsRendered = _ref3.gridItemsRendered,
116
- wrapperRef = _ref3.wrapperRef,
117
- className = _ref3.className,
118
- canDragAndDropColumns = _ref3.canDragAndDropColumns,
119
- _ref3$showHeader = _ref3.showHeader,
120
- showHeader = _ref3$showHeader === void 0 ? true : _ref3$showHeader;
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