@elastic/eui 62.1.0 → 62.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/dist/eui_charts_theme.js +330 -330
- package/dist/eui_charts_theme.js.map +1 -1
- package/es/components/datagrid/body/data_grid_body.js +11 -1
- package/es/components/datagrid/body/data_grid_cell.js +31 -3
- package/es/components/datagrid/data_grid.js +9 -1
- package/es/components/datagrid/utils/row_heights.js +33 -4
- package/es/components/popover/wrapping_popover.js +88 -45
- package/es/components/portal/portal.js +84 -38
- package/es/test/rtl/component_helpers.js +60 -1
- package/eui.d.ts +43 -8
- package/lib/components/datagrid/body/data_grid_body.js +11 -1
- package/lib/components/datagrid/body/data_grid_cell.js +31 -3
- package/lib/components/datagrid/data_grid.js +9 -1
- package/lib/components/datagrid/utils/row_heights.js +33 -4
- package/lib/components/popover/wrapping_popover.js +85 -44
- package/lib/components/portal/portal.js +87 -39
- package/lib/test/rtl/component_helpers.js +69 -3
- package/optimize/es/components/datagrid/body/data_grid_body.js +2 -0
- package/optimize/es/components/datagrid/body/data_grid_cell.js +13 -1
- package/optimize/es/components/datagrid/utils/row_heights.js +33 -4
- package/optimize/es/components/popover/wrapping_popover.js +79 -38
- package/optimize/es/components/portal/portal.js +66 -34
- package/optimize/es/test/rtl/component_helpers.js +60 -1
- package/optimize/lib/components/datagrid/body/data_grid_body.js +2 -0
- package/optimize/lib/components/datagrid/body/data_grid_cell.js +13 -1
- package/optimize/lib/components/datagrid/utils/row_heights.js +33 -4
- package/optimize/lib/components/popover/wrapping_popover.js +78 -38
- package/optimize/lib/components/portal/portal.js +65 -44
- package/optimize/lib/test/rtl/component_helpers.js +69 -3
- package/package.json +2 -2
- package/test-env/components/datagrid/body/data_grid_body.js +11 -1
- package/test-env/components/datagrid/body/data_grid_cell.js +31 -3
- package/test-env/components/datagrid/data_grid.js +9 -1
- package/test-env/components/datagrid/utils/row_heights.js +33 -4
- package/test-env/components/observer/resize_observer/resize_observer.js +43 -126
- package/test-env/components/popover/wrapping_popover.js +78 -38
- package/test-env/components/portal/portal.js +79 -45
- package/test-env/test/rtl/component_helpers.js +69 -3
|
@@ -343,6 +343,8 @@ export var EuiDataGridBody = function EuiDataGridBody(props) {
|
|
|
343
343
|
|
|
344
344
|
var rowHeightUtils = useRowHeightUtils({
|
|
345
345
|
gridRef: gridRef,
|
|
346
|
+
outerGridElementRef: outerGridRef,
|
|
347
|
+
gridItemsRenderedRef: gridItemsRendered,
|
|
346
348
|
gridStyles: gridStyles,
|
|
347
349
|
columns: columns,
|
|
348
350
|
rowHeightsOptions: rowHeightsOptions
|
|
@@ -1025,7 +1027,15 @@ EuiDataGridBody.propTypes = {
|
|
|
1025
1027
|
* Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
|
|
1026
1028
|
* Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
|
|
1027
1029
|
*/
|
|
1028
|
-
onChange: PropTypes.func
|
|
1030
|
+
onChange: PropTypes.func,
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
|
|
1034
|
+
* When set to 'start' or 'center', the topmost or middle visible row will try
|
|
1035
|
+
* to compensate for changes in their top offsets by adjusting the grid's scroll
|
|
1036
|
+
* position.
|
|
1037
|
+
*/
|
|
1038
|
+
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
1029
1039
|
}),
|
|
1030
1040
|
isFullScreen: PropTypes.bool.isRequired,
|
|
1031
1041
|
gridStyles: PropTypes.shape({
|
|
@@ -544,7 +544,15 @@ EuiDataGridCellContent.propTypes = {
|
|
|
544
544
|
* Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
|
|
545
545
|
* Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
|
|
546
546
|
*/
|
|
547
|
-
onChange: PropTypes.func
|
|
547
|
+
onChange: PropTypes.func,
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
|
|
551
|
+
* When set to 'start' or 'center', the topmost or middle visible row will try
|
|
552
|
+
* to compensate for changes in their top offsets by adjusting the grid's scroll
|
|
553
|
+
* position.
|
|
554
|
+
*/
|
|
555
|
+
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
548
556
|
}),
|
|
549
557
|
rowHeightUtils: PropTypes.any,
|
|
550
558
|
pagination: PropTypes.shape({
|
|
@@ -915,7 +923,7 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
915
923
|
}, {
|
|
916
924
|
key: "componentDidUpdate",
|
|
917
925
|
value: function componentDidUpdate(prevProps) {
|
|
918
|
-
var _this$props$rowHeight, _prevProps$rowHeights;
|
|
926
|
+
var _this$props$rowHeight, _prevProps$rowHeights, _this$props$rowHeight2, _this$props$style, _prevProps$style;
|
|
919
927
|
|
|
920
928
|
this.recalculateAutoHeight();
|
|
921
929
|
|
|
@@ -923,6 +931,18 @@ export var EuiDataGridCell = /*#__PURE__*/function (_Component) {
|
|
|
923
931
|
this.recalculateLineHeight();
|
|
924
932
|
}
|
|
925
933
|
|
|
934
|
+
if ((_this$props$rowHeight2 = this.props.rowHeightsOptions) !== null && _this$props$rowHeight2 !== void 0 && _this$props$rowHeight2.scrollAnchorRow && this.props.colIndex === 0 && // once per row
|
|
935
|
+
this.props.columnId === prevProps.columnId && // if this is still the same column
|
|
936
|
+
this.props.rowIndex === prevProps.rowIndex && // if this is still the same row
|
|
937
|
+
((_this$props$style = this.props.style) === null || _this$props$style === void 0 ? void 0 : _this$props$style.top) !== ((_prevProps$style = prevProps.style) === null || _prevProps$style === void 0 ? void 0 : _prevProps$style.top) // if the top position has changed
|
|
938
|
+
) {
|
|
939
|
+
var _prevProps$style2, _this$props$style2, _this$props$rowHeight3, _this$props$rowHeight4;
|
|
940
|
+
|
|
941
|
+
var previousTop = parseFloat((_prevProps$style2 = prevProps.style) === null || _prevProps$style2 === void 0 ? void 0 : _prevProps$style2.top);
|
|
942
|
+
var currentTop = parseFloat((_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.top);
|
|
943
|
+
(_this$props$rowHeight3 = this.props.rowHeightUtils) === null || _this$props$rowHeight3 === void 0 ? void 0 : _this$props$rowHeight3.compensateForLayoutShift(this.props.rowIndex, currentTop - previousTop, (_this$props$rowHeight4 = this.props.rowHeightsOptions) === null || _this$props$rowHeight4 === void 0 ? void 0 : _this$props$rowHeight4.scrollAnchorRow);
|
|
944
|
+
}
|
|
945
|
+
|
|
926
946
|
if (this.props.popoverContext.popoverIsOpen !== prevProps.popoverContext.popoverIsOpen || this.props.popoverContext.cellLocation !== prevProps.popoverContext.cellLocation || this.props.renderCellPopover !== prevProps.renderCellPopover) {
|
|
927
947
|
this.handleCellPopover();
|
|
928
948
|
}
|
|
@@ -1572,7 +1592,15 @@ EuiDataGridCell.propTypes = {
|
|
|
1572
1592
|
* Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
|
|
1573
1593
|
* Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
|
|
1574
1594
|
*/
|
|
1575
|
-
onChange: PropTypes.func
|
|
1595
|
+
onChange: PropTypes.func,
|
|
1596
|
+
|
|
1597
|
+
/**
|
|
1598
|
+
* Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
|
|
1599
|
+
* When set to 'start' or 'center', the topmost or middle visible row will try
|
|
1600
|
+
* to compensate for changes in their top offsets by adjusting the grid's scroll
|
|
1601
|
+
* position.
|
|
1602
|
+
*/
|
|
1603
|
+
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
1576
1604
|
}),
|
|
1577
1605
|
rowHeightUtils: PropTypes.any,
|
|
1578
1606
|
rowManager: PropTypes.shape({
|
|
@@ -1253,7 +1253,15 @@ EuiDataGrid.propTypes = {
|
|
|
1253
1253
|
* Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
|
|
1254
1254
|
* Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
|
|
1255
1255
|
*/
|
|
1256
|
-
onChange: PropTypes.func
|
|
1256
|
+
onChange: PropTypes.func,
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
|
|
1260
|
+
* When set to 'start' or 'center', the topmost or middle visible row will try
|
|
1261
|
+
* to compensate for changes in their top offsets by adjusting the grid's scroll
|
|
1262
|
+
* position.
|
|
1263
|
+
*/
|
|
1264
|
+
scrollAnchorRow: PropTypes.oneOf(["start", "center", undefined])
|
|
1257
1265
|
})
|
|
1258
1266
|
};
|
|
1259
1267
|
EuiDataGrid.displayName = 'EuiDataGrid';
|
|
@@ -33,9 +33,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
33
33
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
34
34
|
* Side Public License, v 1.
|
|
35
35
|
*/
|
|
36
|
-
import {
|
|
37
|
-
import { isObject, isNumber } from '../../../services/predicate';
|
|
36
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
38
37
|
import { useForceRender, useLatest } from '../../../services';
|
|
38
|
+
import { isNumber, isObject } from '../../../services/predicate';
|
|
39
39
|
import { DataGridSortingContext } from './sorting'; // TODO: Once JS variables are available, use them here instead of hard-coded maps
|
|
40
40
|
|
|
41
41
|
export var cellPaddingsMap = {
|
|
@@ -46,12 +46,14 @@ export var cellPaddingsMap = {
|
|
|
46
46
|
export var AUTO_HEIGHT = 'auto';
|
|
47
47
|
export var DEFAULT_ROW_HEIGHT = 34;
|
|
48
48
|
export var RowHeightUtils = /*#__PURE__*/function () {
|
|
49
|
-
function RowHeightUtils(gridRef, rerenderGridBodyRef) {
|
|
49
|
+
function RowHeightUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, rerenderGridBodyRef) {
|
|
50
50
|
var _this = this;
|
|
51
51
|
|
|
52
52
|
_classCallCheck(this, RowHeightUtils);
|
|
53
53
|
|
|
54
54
|
this.gridRef = gridRef;
|
|
55
|
+
this.outerGridElementRef = outerGridElementRef;
|
|
56
|
+
this.gridItemsRenderedRef = gridItemsRenderedRef;
|
|
55
57
|
this.rerenderGridBodyRef = rerenderGridBodyRef;
|
|
56
58
|
|
|
57
59
|
_defineProperty(this, "styles", {
|
|
@@ -247,6 +249,31 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
247
249
|
(_this$gridRef$current = this.gridRef.current) === null || _this$gridRef$current === void 0 ? void 0 : _this$gridRef$current.resetAfterRowIndex(this.lastUpdatedRow);
|
|
248
250
|
this.lastUpdatedRow = Infinity;
|
|
249
251
|
}
|
|
252
|
+
}, {
|
|
253
|
+
key: "compensateForLayoutShift",
|
|
254
|
+
value: function compensateForLayoutShift(rowIndex, verticalLayoutShift, anchorRow) {
|
|
255
|
+
var grid = this.gridRef.current;
|
|
256
|
+
var outerGridElement = this.outerGridElementRef.current;
|
|
257
|
+
var renderedItems = this.gridItemsRenderedRef.current;
|
|
258
|
+
|
|
259
|
+
if (grid == null || outerGridElement == null || renderedItems == null || anchorRow == null || !Number.isFinite(verticalLayoutShift)) {
|
|
260
|
+
return;
|
|
261
|
+
} // skip if the start row is the anchor row but it hasn't shifted
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
if (anchorRow === 'start' && renderedItems.visibleRowStartIndex !== rowIndex) {
|
|
265
|
+
return;
|
|
266
|
+
} // skip if the center row is the anchor row but it hasn't shifted
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if (anchorRow === 'center' && Math.floor((renderedItems.visibleRowStopIndex - renderedItems.visibleRowStartIndex) / 2) !== rowIndex) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
grid.scrollTo({
|
|
274
|
+
scrollTop: outerGridElement.scrollTop + verticalLayoutShift
|
|
275
|
+
});
|
|
276
|
+
}
|
|
250
277
|
}]);
|
|
251
278
|
|
|
252
279
|
return RowHeightUtils;
|
|
@@ -258,13 +285,15 @@ export var RowHeightUtils = /*#__PURE__*/function () {
|
|
|
258
285
|
|
|
259
286
|
export var useRowHeightUtils = function useRowHeightUtils(_ref2) {
|
|
260
287
|
var gridRef = _ref2.gridRef,
|
|
288
|
+
outerGridElementRef = _ref2.outerGridElementRef,
|
|
289
|
+
gridItemsRenderedRef = _ref2.gridItemsRenderedRef,
|
|
261
290
|
gridStyles = _ref2.gridStyles,
|
|
262
291
|
columns = _ref2.columns,
|
|
263
292
|
rowHeightsOptions = _ref2.rowHeightsOptions;
|
|
264
293
|
var forceRenderRef = useLatest(useForceRender());
|
|
265
294
|
|
|
266
295
|
var _useState = useState(function () {
|
|
267
|
-
return new RowHeightUtils(gridRef, forceRenderRef);
|
|
296
|
+
return new RowHeightUtils(gridRef, outerGridElementRef, gridItemsRenderedRef, forceRenderRef);
|
|
268
297
|
}),
|
|
269
298
|
_useState2 = _slicedToArray(_useState, 1),
|
|
270
299
|
rowHeightUtils = _useState2[0]; // Forces a rerender whenever the row heights change, as this can cause the
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
1
3
|
var _excluded = ["button"];
|
|
2
4
|
|
|
3
5
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
6
|
|
|
5
|
-
function
|
|
7
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
8
|
|
|
7
|
-
function
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
8
10
|
|
|
9
|
-
function
|
|
11
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
12
|
|
|
11
|
-
function
|
|
13
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
12
14
|
|
|
13
|
-
function
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
14
16
|
|
|
15
|
-
function
|
|
17
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
18
|
|
|
17
|
-
function
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
20
|
|
|
19
|
-
function
|
|
21
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
22
|
+
|
|
23
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
24
|
+
|
|
25
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
+
|
|
27
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
+
|
|
29
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
30
|
+
|
|
31
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
32
|
|
|
21
33
|
/*
|
|
22
34
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -25,7 +37,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
25
37
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
26
38
|
* Side Public License, v 1.
|
|
27
39
|
*/
|
|
28
|
-
import React, {
|
|
40
|
+
import React, { Component } from 'react';
|
|
29
41
|
import PropTypes from "prop-types";
|
|
30
42
|
import { EuiPopover } from './popover';
|
|
31
43
|
import { EuiPortal } from '../portal';
|
|
@@ -36,46 +48,77 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
36
48
|
* then the button element is moved into the popover dom.
|
|
37
49
|
* On unmount, the button is moved back to its original location.
|
|
38
50
|
*/
|
|
39
|
-
export var EuiWrappingPopover = function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setPortal = _useState4[1];
|
|
52
|
-
|
|
53
|
-
useEffect(function () {
|
|
54
|
-
if (anchor) {
|
|
55
|
-
// move the button into the popover DOM
|
|
56
|
-
anchor.insertAdjacentElement('beforebegin', button);
|
|
51
|
+
export var EuiWrappingPopover = /*#__PURE__*/function (_Component) {
|
|
52
|
+
_inherits(EuiWrappingPopover, _Component);
|
|
53
|
+
|
|
54
|
+
var _super = _createSuper(EuiWrappingPopover);
|
|
55
|
+
|
|
56
|
+
function EuiWrappingPopover() {
|
|
57
|
+
var _this;
|
|
58
|
+
|
|
59
|
+
_classCallCheck(this, EuiWrappingPopover);
|
|
60
|
+
|
|
61
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
62
|
+
args[_key] = arguments[_key];
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
66
|
+
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "portal", null);
|
|
68
|
+
|
|
69
|
+
_defineProperty(_assertThisInitialized(_this), "anchor", null);
|
|
70
|
+
|
|
71
|
+
_defineProperty(_assertThisInitialized(_this), "setPortalRef", function (node) {
|
|
72
|
+
_this.portal = node;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "setAnchorRef", function (node) {
|
|
76
|
+
_this.anchor = node;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_createClass(EuiWrappingPopover, [{
|
|
83
|
+
key: "componentDidMount",
|
|
84
|
+
value: function componentDidMount() {
|
|
85
|
+
if (this.anchor) {
|
|
86
|
+
this.anchor.insertAdjacentElement('beforebegin', this.props.button);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "componentWillUnmount",
|
|
91
|
+
value: function componentWillUnmount() {
|
|
92
|
+
if (this.props.button.parentNode) {
|
|
93
|
+
if (this.portal) {
|
|
94
|
+
this.portal.insertAdjacentElement('beforebegin', this.props.button);
|
|
95
|
+
}
|
|
63
96
|
}
|
|
64
|
-
};
|
|
65
|
-
}, [anchor, button, portal]);
|
|
66
|
-
return ___EmotionJSX(EuiPortal, {
|
|
67
|
-
portalRef: setPortal,
|
|
68
|
-
insert: {
|
|
69
|
-
sibling: button,
|
|
70
|
-
position: 'after'
|
|
71
97
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
98
|
+
}, {
|
|
99
|
+
key: "render",
|
|
100
|
+
value: function render() {
|
|
101
|
+
var _this$props = this.props,
|
|
102
|
+
button = _this$props.button,
|
|
103
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
104
|
+
|
|
105
|
+
return ___EmotionJSX(EuiPortal, {
|
|
106
|
+
portalRef: this.setPortalRef,
|
|
107
|
+
insert: {
|
|
108
|
+
sibling: this.props.button,
|
|
109
|
+
position: 'after'
|
|
110
|
+
}
|
|
111
|
+
}, ___EmotionJSX(EuiPopover, _extends({}, rest, {
|
|
112
|
+
button: ___EmotionJSX("div", {
|
|
113
|
+
ref: this.setAnchorRef,
|
|
114
|
+
className: "euiWrappingPopover__anchor"
|
|
115
|
+
})
|
|
116
|
+
})));
|
|
117
|
+
}
|
|
118
|
+
}]);
|
|
119
|
+
|
|
120
|
+
return EuiWrappingPopover;
|
|
121
|
+
}(Component);
|
|
79
122
|
EuiWrappingPopover.propTypes = {
|
|
80
123
|
button: PropTypes.any.isRequired
|
|
81
124
|
};
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
|
|
15
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
+
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
|
|
19
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
+
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
|
|
23
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
24
|
|
|
13
25
|
/*
|
|
14
26
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -22,54 +34,88 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
22
34
|
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
23
35
|
* into portals.
|
|
24
36
|
*/
|
|
25
|
-
import {
|
|
37
|
+
import { Component } from 'react';
|
|
38
|
+
import PropTypes from "prop-types";
|
|
26
39
|
import { createPortal } from 'react-dom';
|
|
27
40
|
import { keysOf } from '../common';
|
|
28
|
-
import { useUpdateEffect } from '../../services';
|
|
29
41
|
export var insertPositions = {
|
|
30
42
|
after: 'afterend',
|
|
31
43
|
before: 'beforebegin'
|
|
32
44
|
};
|
|
33
45
|
export var INSERT_POSITIONS = keysOf(insertPositions);
|
|
34
|
-
export var EuiPortal = function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
export var EuiPortal = /*#__PURE__*/function (_Component) {
|
|
47
|
+
_inherits(EuiPortal, _Component);
|
|
48
|
+
|
|
49
|
+
var _super = _createSuper(EuiPortal);
|
|
50
|
+
|
|
51
|
+
function EuiPortal(props) {
|
|
52
|
+
var _this;
|
|
53
|
+
|
|
54
|
+
_classCallCheck(this, EuiPortal);
|
|
38
55
|
|
|
39
|
-
|
|
40
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
41
|
-
portalNode = _useState2[0],
|
|
42
|
-
setPortalNode = _useState2[1]; // pull `sibling` and `position` out of insert in case their wrapping object is recreated every render
|
|
56
|
+
_this = _super.call(this, props);
|
|
43
57
|
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "portalNode", null);
|
|
44
59
|
|
|
45
|
-
|
|
46
|
-
sibling = _ref2.sibling,
|
|
47
|
-
position = _ref2.position;
|
|
60
|
+
if (typeof window === 'undefined') return _possibleConstructorReturn(_this); // Prevent SSR errors
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
portalNode.dataset.euiportal = 'true';
|
|
52
|
-
setPortalNode(portalNode);
|
|
62
|
+
var insert = _this.props.insert;
|
|
63
|
+
_this.portalNode = document.createElement('div');
|
|
64
|
+
_this.portalNode.dataset.euiportal = 'true';
|
|
53
65
|
|
|
54
|
-
if (
|
|
66
|
+
if (insert == null) {
|
|
55
67
|
// no insertion defined, append to body
|
|
56
|
-
document.body.appendChild(portalNode);
|
|
68
|
+
document.body.appendChild(_this.portalNode);
|
|
57
69
|
} else {
|
|
58
70
|
// inserting before or after an element
|
|
59
|
-
sibling.
|
|
71
|
+
var sibling = insert.sibling,
|
|
72
|
+
position = insert.position;
|
|
73
|
+
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
60
74
|
}
|
|
61
75
|
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
return _this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_createClass(EuiPortal, [{
|
|
80
|
+
key: "componentDidMount",
|
|
81
|
+
value: function componentDidMount() {
|
|
82
|
+
this.updatePortalRef(this.portalNode);
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "componentWillUnmount",
|
|
86
|
+
value: function componentWillUnmount() {
|
|
87
|
+
var _this$portalNode;
|
|
88
|
+
|
|
89
|
+
if ((_this$portalNode = this.portalNode) !== null && _this$portalNode !== void 0 && _this$portalNode.parentNode) {
|
|
90
|
+
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
65
91
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
|
|
93
|
+
this.updatePortalRef(null);
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "updatePortalRef",
|
|
97
|
+
value: function updatePortalRef(ref) {
|
|
98
|
+
if (this.props.portalRef) {
|
|
99
|
+
this.props.portalRef(ref);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "render",
|
|
104
|
+
value: function render() {
|
|
105
|
+
return this.portalNode ? /*#__PURE__*/createPortal(this.props.children, this.portalNode) : null;
|
|
106
|
+
}
|
|
107
|
+
}]);
|
|
108
|
+
|
|
109
|
+
return EuiPortal;
|
|
110
|
+
}(Component);
|
|
111
|
+
EuiPortal.propTypes = {
|
|
112
|
+
/**
|
|
113
|
+
* ReactNode to render as this component's content
|
|
114
|
+
*/
|
|
115
|
+
children: PropTypes.node.isRequired,
|
|
116
|
+
insert: PropTypes.shape({
|
|
117
|
+
sibling: PropTypes.any.isRequired,
|
|
118
|
+
position: PropTypes.oneOf(["before", "after"]).isRequired
|
|
119
|
+
}),
|
|
120
|
+
portalRef: PropTypes.func
|
|
75
121
|
};
|
|
@@ -9,9 +9,10 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
9
9
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
10
10
|
* Side Public License, v 1.
|
|
11
11
|
*/
|
|
12
|
+
import '@testing-library/jest-dom';
|
|
12
13
|
import { waitFor } from '@testing-library/react';
|
|
13
14
|
/**
|
|
14
|
-
* Ensure the EuiPopover being tested is open/closed before
|
|
15
|
+
* Ensure the EuiPopover being tested is open/closed before continuing
|
|
15
16
|
* Note: Because EuiPopover is portalled, we want to query `document`
|
|
16
17
|
* instead of the `container` returned by RTL's render()
|
|
17
18
|
*/
|
|
@@ -69,4 +70,62 @@ export var waitForEuiPopoverClose = /*#__PURE__*/function () {
|
|
|
69
70
|
return function waitForEuiPopoverClose() {
|
|
70
71
|
return _ref2.apply(this, arguments);
|
|
71
72
|
};
|
|
73
|
+
}();
|
|
74
|
+
/**
|
|
75
|
+
* Ensure the EuiToolTip being tested is open and visible before continuing
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
export var waitForEuiToolTipVisible = /*#__PURE__*/function () {
|
|
79
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
|
80
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
81
|
+
while (1) {
|
|
82
|
+
switch (_context3.prev = _context3.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
_context3.next = 2;
|
|
85
|
+
return waitFor(function () {
|
|
86
|
+
var tooltip = document.querySelector('.euiToolTipPopover');
|
|
87
|
+
expect(tooltip).toBeVisible();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
case 2:
|
|
91
|
+
return _context3.abrupt("return", _context3.sent);
|
|
92
|
+
|
|
93
|
+
case 3:
|
|
94
|
+
case "end":
|
|
95
|
+
return _context3.stop();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, _callee3);
|
|
99
|
+
}));
|
|
100
|
+
|
|
101
|
+
return function waitForEuiToolTipVisible() {
|
|
102
|
+
return _ref3.apply(this, arguments);
|
|
103
|
+
};
|
|
104
|
+
}();
|
|
105
|
+
export var waitForEuiToolTipHidden = /*#__PURE__*/function () {
|
|
106
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
|
|
107
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
108
|
+
while (1) {
|
|
109
|
+
switch (_context4.prev = _context4.next) {
|
|
110
|
+
case 0:
|
|
111
|
+
_context4.next = 2;
|
|
112
|
+
return waitFor(function () {
|
|
113
|
+
var tooltip = document.querySelector('.euiToolTipPopover');
|
|
114
|
+
expect(tooltip).toBeNull();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
case 2:
|
|
118
|
+
return _context4.abrupt("return", _context4.sent);
|
|
119
|
+
|
|
120
|
+
case 3:
|
|
121
|
+
case "end":
|
|
122
|
+
return _context4.stop();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, _callee4);
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
return function waitForEuiToolTipHidden() {
|
|
129
|
+
return _ref4.apply(this, arguments);
|
|
130
|
+
};
|
|
72
131
|
}();
|