@elastic/eui 62.1.0 → 62.2.2
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/description_list/description_list_description.js +2 -1
- package/es/components/description_list/description_list_title.js +2 -1
- package/es/components/popover/wrapping_popover.js +88 -45
- package/es/components/portal/portal.js +84 -38
- package/es/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +2 -12
- package/es/services/breakpoint/current_breakpoint_hook.js +20 -0
- package/es/services/breakpoint/index.js +2 -1
- package/es/services/breakpoint/useIsWithinBreakpoints.js +1 -1
- package/es/test/rtl/component_helpers.js +60 -1
- package/eui.d.ts +50 -150
- 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/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +5 -16
- package/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
- package/lib/services/breakpoint/index.js +17 -4
- package/lib/services/breakpoint/useIsWithinBreakpoints.js +2 -2
- 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/description_list/description_list_description.js +2 -1
- package/optimize/es/components/description_list/description_list_title.js +2 -1
- package/optimize/es/components/popover/wrapping_popover.js +79 -38
- package/optimize/es/components/portal/portal.js +66 -34
- package/optimize/es/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +2 -11
- package/optimize/es/services/breakpoint/current_breakpoint_hook.js +20 -0
- package/optimize/es/services/breakpoint/index.js +2 -1
- package/optimize/es/services/breakpoint/useIsWithinBreakpoints.js +1 -1
- 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/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +5 -18
- package/optimize/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
- package/optimize/lib/services/breakpoint/index.js +17 -4
- package/optimize/lib/services/breakpoint/useIsWithinBreakpoints.js +2 -2
- 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/services/breakpoint/current_breakpoint.js +68 -0
- package/test-env/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint_hook.js} +3 -7
- package/test-env/services/breakpoint/index.js +17 -4
- package/test-env/services/breakpoint/useIsWithinBreakpoints.js +2 -2
- 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
|
|
@@ -30,7 +30,8 @@ import PropTypes from "prop-types";
|
|
|
30
30
|
import classNames from 'classnames';
|
|
31
31
|
import { useEuiTheme } from '../../services';
|
|
32
32
|
import { euiDescriptionListDescriptionStyles } from './description_list_description.styles';
|
|
33
|
-
import { EuiDescriptionListContext } from './description_list_context';
|
|
33
|
+
import { EuiDescriptionListContext } from './description_list_context'; // Export required for correct inference by HOCs
|
|
34
|
+
|
|
34
35
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
35
36
|
export var EuiDescriptionListDescription = function EuiDescriptionListDescription(_ref) {
|
|
36
37
|
var children = _ref.children,
|
|
@@ -30,7 +30,8 @@ import PropTypes from "prop-types";
|
|
|
30
30
|
import classNames from 'classnames';
|
|
31
31
|
import { useEuiTheme } from '../../services';
|
|
32
32
|
import { euiDescriptionListTitleStyles } from './description_list_title.styles';
|
|
33
|
-
import { EuiDescriptionListContext } from './description_list_context';
|
|
33
|
+
import { EuiDescriptionListContext } from './description_list_context'; // Export required for correct inference by HOCs
|
|
34
|
+
|
|
34
35
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
35
36
|
export var EuiDescriptionListTitle = function EuiDescriptionListTitle(_ref) {
|
|
36
37
|
var children = _ref.children,
|
|
@@ -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
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
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
|
-
|
|
3
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
2
|
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -19,7 +17,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
19
17
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
20
18
|
* Side Public License, v 1.
|
|
21
19
|
*/
|
|
22
|
-
import React, { createContext,
|
|
20
|
+
import React, { createContext, useState, useEffect } from 'react';
|
|
23
21
|
import { useEuiTheme } from '../theme';
|
|
24
22
|
import { throttle } from '../throttle';
|
|
25
23
|
import { getBreakpoint } from './breakpoint';
|
|
@@ -36,7 +34,7 @@ export var CurrentEuiBreakpointProvider = function CurrentEuiBreakpointProvider(
|
|
|
36
34
|
var _useEuiTheme = useEuiTheme(),
|
|
37
35
|
breakpoints = _useEuiTheme.euiTheme.breakpoint;
|
|
38
36
|
|
|
39
|
-
var _useState = useState(
|
|
37
|
+
var _useState = useState(typeof window !== 'undefined' ? getBreakpoint(window.innerWidth, breakpoints) : undefined),
|
|
40
38
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
39
|
currentBreakpoint = _useState2[0],
|
|
42
40
|
setCurrentBreakpoint = _useState2[1];
|
|
@@ -53,12 +51,4 @@ export var CurrentEuiBreakpointProvider = function CurrentEuiBreakpointProvider(
|
|
|
53
51
|
return ___EmotionJSX(CurrentEuiBreakpointContext.Provider, {
|
|
54
52
|
value: currentBreakpoint
|
|
55
53
|
}, children);
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Hook util / syntactical sugar
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
export var useCurrentEuiBreakpoint = function useCurrentEuiBreakpoint() {
|
|
62
|
-
var currentBreakpoint = useContext(CurrentEuiBreakpointContext);
|
|
63
|
-
return currentBreakpoint;
|
|
64
54
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
import { useContext } from 'react';
|
|
9
|
+
import { CurrentEuiBreakpointContext } from './current_breakpoint';
|
|
10
|
+
/**
|
|
11
|
+
* Hook util / syntactical sugar for useContext()
|
|
12
|
+
*
|
|
13
|
+
* This hook is in its own separate file to make mocking it
|
|
14
|
+
* as a testenv easy for Jest unit tests
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var useCurrentEuiBreakpoint = function useCurrentEuiBreakpoint() {
|
|
18
|
+
var currentBreakpoint = useContext(CurrentEuiBreakpointContext);
|
|
19
|
+
return currentBreakpoint;
|
|
20
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
6
|
* Side Public License, v 1.
|
|
7
7
|
*/
|
|
8
|
-
import { useCurrentEuiBreakpoint } from './
|
|
8
|
+
import { useCurrentEuiBreakpoint } from './current_breakpoint_hook';
|
|
9
9
|
/**
|
|
10
10
|
* Given the current window.innerWidth and an array of breakpoint keys,
|
|
11
11
|
* this hook stores state and returns true or false if the window.innerWidth
|