@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.
Files changed (62) hide show
  1. package/dist/eui_charts_theme.js +330 -330
  2. package/dist/eui_charts_theme.js.map +1 -1
  3. package/es/components/datagrid/body/data_grid_body.js +11 -1
  4. package/es/components/datagrid/body/data_grid_cell.js +31 -3
  5. package/es/components/datagrid/data_grid.js +9 -1
  6. package/es/components/datagrid/utils/row_heights.js +33 -4
  7. package/es/components/description_list/description_list_description.js +2 -1
  8. package/es/components/description_list/description_list_title.js +2 -1
  9. package/es/components/popover/wrapping_popover.js +88 -45
  10. package/es/components/portal/portal.js +84 -38
  11. package/es/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +2 -12
  12. package/es/services/breakpoint/current_breakpoint_hook.js +20 -0
  13. package/es/services/breakpoint/index.js +2 -1
  14. package/es/services/breakpoint/useIsWithinBreakpoints.js +1 -1
  15. package/es/test/rtl/component_helpers.js +60 -1
  16. package/eui.d.ts +50 -150
  17. package/lib/components/datagrid/body/data_grid_body.js +11 -1
  18. package/lib/components/datagrid/body/data_grid_cell.js +31 -3
  19. package/lib/components/datagrid/data_grid.js +9 -1
  20. package/lib/components/datagrid/utils/row_heights.js +33 -4
  21. package/lib/components/popover/wrapping_popover.js +85 -44
  22. package/lib/components/portal/portal.js +87 -39
  23. package/lib/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +5 -16
  24. package/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
  25. package/lib/services/breakpoint/index.js +17 -4
  26. package/lib/services/breakpoint/useIsWithinBreakpoints.js +2 -2
  27. package/lib/test/rtl/component_helpers.js +69 -3
  28. package/optimize/es/components/datagrid/body/data_grid_body.js +2 -0
  29. package/optimize/es/components/datagrid/body/data_grid_cell.js +13 -1
  30. package/optimize/es/components/datagrid/utils/row_heights.js +33 -4
  31. package/optimize/es/components/description_list/description_list_description.js +2 -1
  32. package/optimize/es/components/description_list/description_list_title.js +2 -1
  33. package/optimize/es/components/popover/wrapping_popover.js +79 -38
  34. package/optimize/es/components/portal/portal.js +66 -34
  35. package/optimize/es/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +2 -11
  36. package/optimize/es/services/breakpoint/current_breakpoint_hook.js +20 -0
  37. package/optimize/es/services/breakpoint/index.js +2 -1
  38. package/optimize/es/services/breakpoint/useIsWithinBreakpoints.js +1 -1
  39. package/optimize/es/test/rtl/component_helpers.js +60 -1
  40. package/optimize/lib/components/datagrid/body/data_grid_body.js +2 -0
  41. package/optimize/lib/components/datagrid/body/data_grid_cell.js +13 -1
  42. package/optimize/lib/components/datagrid/utils/row_heights.js +33 -4
  43. package/optimize/lib/components/popover/wrapping_popover.js +78 -38
  44. package/optimize/lib/components/portal/portal.js +65 -44
  45. package/optimize/lib/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint.js} +5 -18
  46. package/optimize/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
  47. package/optimize/lib/services/breakpoint/index.js +17 -4
  48. package/optimize/lib/services/breakpoint/useIsWithinBreakpoints.js +2 -2
  49. package/optimize/lib/test/rtl/component_helpers.js +69 -3
  50. package/package.json +2 -2
  51. package/test-env/components/datagrid/body/data_grid_body.js +11 -1
  52. package/test-env/components/datagrid/body/data_grid_cell.js +31 -3
  53. package/test-env/components/datagrid/data_grid.js +9 -1
  54. package/test-env/components/datagrid/utils/row_heights.js +33 -4
  55. package/test-env/components/observer/resize_observer/resize_observer.js +43 -126
  56. package/test-env/components/popover/wrapping_popover.js +78 -38
  57. package/test-env/components/portal/portal.js +79 -45
  58. package/test-env/services/breakpoint/current_breakpoint.js +68 -0
  59. package/test-env/services/breakpoint/{currentEuiBreakpoint.js → current_breakpoint_hook.js} +3 -7
  60. package/test-env/services/breakpoint/index.js +17 -4
  61. package/test-env/services/breakpoint/useIsWithinBreakpoints.js +2 -2
  62. package/test-env/test/rtl/component_helpers.js +69 -3
@@ -11,10 +11,22 @@ exports.EuiWrappingPopover = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
15
 
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
+
20
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
+
22
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
+
24
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
+
26
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
+
28
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
+
18
30
  var _react = _interopRequireWildcard(require("react"));
19
31
 
20
32
  var _popover = require("./popover");
@@ -29,50 +41,78 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
41
 
30
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
43
 
44
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
45
+
46
+ 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; } }
47
+
32
48
  /**
33
49
  * Injects the EuiPopover next to the button via EuiPortal
34
50
  * then the button element is moved into the popover dom.
35
51
  * On unmount, the button is moved back to its original location.
36
52
  */
37
- var EuiWrappingPopover = function EuiWrappingPopover(_ref) {
38
- var button = _ref.button,
39
- rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
40
-
41
- var _useState = (0, _react.useState)(null),
42
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
43
- anchor = _useState2[0],
44
- setAnchor = _useState2[1];
45
-
46
- var _useState3 = (0, _react.useState)(null),
47
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
48
- portal = _useState4[0],
49
- setPortal = _useState4[1];
50
-
51
- (0, _react.useEffect)(function () {
52
- if (anchor) {
53
- // move the button into the popover DOM
54
- anchor.insertAdjacentElement('beforebegin', button);
53
+ var EuiWrappingPopover = /*#__PURE__*/function (_Component) {
54
+ (0, _inherits2.default)(EuiWrappingPopover, _Component);
55
+
56
+ var _super = _createSuper(EuiWrappingPopover);
57
+
58
+ function EuiWrappingPopover() {
59
+ var _this;
60
+
61
+ (0, _classCallCheck2.default)(this, EuiWrappingPopover);
62
+
63
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
64
+ args[_key] = arguments[_key];
55
65
  }
56
66
 
57
- return function () {
58
- if (portal) {
59
- // move the button back out of the popover DOM
60
- portal.insertAdjacentElement('beforebegin', button);
67
+ _this = _super.call.apply(_super, [this].concat(args));
68
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "portal", null);
69
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "anchor", null);
70
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setPortalRef", function (node) {
71
+ _this.portal = node;
72
+ });
73
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setAnchorRef", function (node) {
74
+ _this.anchor = node;
75
+ });
76
+ return _this;
77
+ }
78
+
79
+ (0, _createClass2.default)(EuiWrappingPopover, [{
80
+ key: "componentDidMount",
81
+ value: function componentDidMount() {
82
+ if (this.anchor) {
83
+ this.anchor.insertAdjacentElement('beforebegin', this.props.button);
84
+ }
85
+ }
86
+ }, {
87
+ key: "componentWillUnmount",
88
+ value: function componentWillUnmount() {
89
+ if (this.props.button.parentNode) {
90
+ if (this.portal) {
91
+ this.portal.insertAdjacentElement('beforebegin', this.props.button);
92
+ }
61
93
  }
62
- };
63
- }, [anchor, button, portal]);
64
- return (0, _react2.jsx)(_portal.EuiPortal, {
65
- portalRef: setPortal,
66
- insert: {
67
- sibling: button,
68
- position: 'after'
69
94
  }
70
- }, (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({}, rest, {
71
- button: (0, _react2.jsx)("div", {
72
- ref: setAnchor,
73
- className: "euiWrappingPopover__anchor"
74
- })
75
- })));
76
- };
95
+ }, {
96
+ key: "render",
97
+ value: function render() {
98
+ var _this$props = this.props,
99
+ button = _this$props.button,
100
+ rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
101
+ return (0, _react2.jsx)(_portal.EuiPortal, {
102
+ portalRef: this.setPortalRef,
103
+ insert: {
104
+ sibling: this.props.button,
105
+ position: 'after'
106
+ }
107
+ }, (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({}, rest, {
108
+ button: (0, _react2.jsx)("div", {
109
+ ref: this.setAnchorRef,
110
+ className: "euiWrappingPopover__anchor"
111
+ })
112
+ })));
113
+ }
114
+ }]);
115
+ return EuiWrappingPopover;
116
+ }(_react.Component);
77
117
 
78
118
  exports.EuiWrappingPopover = EuiWrappingPopover;
@@ -7,7 +7,19 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.insertPositions = exports.INSERT_POSITIONS = exports.EuiPortal = void 0;
9
9
 
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
23
 
12
24
  var _react = require("react");
13
25
 
@@ -15,20 +27,10 @@ var _reactDom = require("react-dom");
15
27
 
16
28
  var _common = require("../common");
17
29
 
18
- var _services = require("../../services");
30
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
19
31
 
20
- /*
21
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
22
- * or more contributor license agreements. Licensed under the Elastic License
23
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
24
- * in compliance with, at your election, the Elastic License 2.0 or the Server
25
- * Side Public License, v 1.
26
- */
32
+ 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; } }
27
33
 
28
- /**
29
- * NOTE: We can't test this component because Enzyme doesn't support rendering
30
- * into portals.
31
- */
32
34
  var insertPositions = {
33
35
  after: 'afterend',
34
36
  before: 'beforebegin'
@@ -37,47 +39,66 @@ exports.insertPositions = insertPositions;
37
39
  var INSERT_POSITIONS = (0, _common.keysOf)(insertPositions);
38
40
  exports.INSERT_POSITIONS = INSERT_POSITIONS;
39
41
 
40
- var EuiPortal = function EuiPortal(_ref) {
41
- var insert = _ref.insert,
42
- portalRef = _ref.portalRef,
43
- children = _ref.children;
42
+ var EuiPortal = /*#__PURE__*/function (_Component) {
43
+ (0, _inherits2.default)(EuiPortal, _Component);
44
44
 
45
- var _useState = (0, _react.useState)(null),
46
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
47
- portalNode = _useState2[0],
48
- setPortalNode = _useState2[1]; // pull `sibling` and `position` out of insert in case their wrapping object is recreated every render
45
+ var _super = _createSuper(EuiPortal);
49
46
 
47
+ function EuiPortal(props) {
48
+ var _this;
50
49
 
51
- var _ref2 = insert || {},
52
- sibling = _ref2.sibling,
53
- position = _ref2.position;
50
+ (0, _classCallCheck2.default)(this, EuiPortal);
51
+ _this = _super.call(this, props);
52
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "portalNode", null);
53
+ if (typeof window === 'undefined') return (0, _possibleConstructorReturn2.default)(_this); // Prevent SSR errors
54
54
 
55
- (0, _react.useEffect)(function () {
56
- var portalNode = document.createElement('div');
57
- portalNode.dataset.euiportal = 'true';
58
- setPortalNode(portalNode);
55
+ var insert = _this.props.insert;
56
+ _this.portalNode = document.createElement('div');
57
+ _this.portalNode.dataset.euiportal = 'true';
59
58
 
60
- if (sibling == null || position == null) {
59
+ if (insert == null) {
61
60
  // no insertion defined, append to body
62
- document.body.appendChild(portalNode);
61
+ document.body.appendChild(_this.portalNode);
63
62
  } else {
64
63
  // inserting before or after an element
65
- sibling.insertAdjacentElement(insertPositions[position], portalNode);
64
+ var sibling = insert.sibling,
65
+ position = insert.position;
66
+ sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
66
67
  }
67
68
 
68
- return function () {
69
- if (portalNode && portalNode.parentNode) {
70
- portalNode.parentNode.removeChild(portalNode);
69
+ return _this;
70
+ }
71
+
72
+ (0, _createClass2.default)(EuiPortal, [{
73
+ key: "componentDidMount",
74
+ value: function componentDidMount() {
75
+ this.updatePortalRef(this.portalNode);
76
+ }
77
+ }, {
78
+ key: "componentWillUnmount",
79
+ value: function componentWillUnmount() {
80
+ var _this$portalNode;
81
+
82
+ if ((_this$portalNode = this.portalNode) !== null && _this$portalNode !== void 0 && _this$portalNode.parentNode) {
83
+ this.portalNode.parentNode.removeChild(this.portalNode);
71
84
  }
72
- };
73
- }, [sibling, position]);
74
- (0, _services.useUpdateEffect)(function () {
75
- portalRef === null || portalRef === void 0 ? void 0 : portalRef(portalNode);
76
- return function () {
77
- portalRef === null || portalRef === void 0 ? void 0 : portalRef(null);
78
- };
79
- }, [portalNode, portalRef]);
80
- return portalNode == null ? null : /*#__PURE__*/(0, _reactDom.createPortal)(children, portalNode);
81
- };
85
+
86
+ this.updatePortalRef(null);
87
+ }
88
+ }, {
89
+ key: "updatePortalRef",
90
+ value: function updatePortalRef(ref) {
91
+ if (this.props.portalRef) {
92
+ this.props.portalRef(ref);
93
+ }
94
+ }
95
+ }, {
96
+ key: "render",
97
+ value: function render() {
98
+ return this.portalNode ? /*#__PURE__*/(0, _reactDom.createPortal)(this.props.children, this.portalNode) : null;
99
+ }
100
+ }]);
101
+ return EuiPortal;
102
+ }(_react.Component);
82
103
 
83
104
  exports.EuiPortal = EuiPortal;
@@ -2,14 +2,12 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.useCurrentEuiBreakpoint = exports.CurrentEuiBreakpointProvider = exports.CurrentEuiBreakpointContext = void 0;
11
-
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ exports.CurrentEuiBreakpointProvider = exports.CurrentEuiBreakpointContext = void 0;
13
11
 
14
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
13
 
@@ -25,7 +23,7 @@ var _react2 = require("@emotion/react");
25
23
 
26
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
25
 
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
27
 
30
28
  /*
31
29
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -48,7 +46,7 @@ var CurrentEuiBreakpointProvider = function CurrentEuiBreakpointProvider(_ref) {
48
46
  var _useEuiTheme = (0, _theme.useEuiTheme)(),
49
47
  breakpoints = _useEuiTheme.euiTheme.breakpoint;
50
48
 
51
- var _useState = (0, _react.useState)((typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) !== undefined ? (0, _breakpoint.getBreakpoint)(window.innerWidth, breakpoints) : undefined),
49
+ var _useState = (0, _react.useState)(typeof window !== 'undefined' ? (0, _breakpoint.getBreakpoint)(window.innerWidth, breakpoints) : undefined),
52
50
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
53
51
  currentBreakpoint = _useState2[0],
54
52
  setCurrentBreakpoint = _useState2[1];
@@ -66,16 +64,5 @@ var CurrentEuiBreakpointProvider = function CurrentEuiBreakpointProvider(_ref) {
66
64
  value: currentBreakpoint
67
65
  }, children);
68
66
  };
69
- /**
70
- * Hook util / syntactical sugar
71
- */
72
-
73
-
74
- exports.CurrentEuiBreakpointProvider = CurrentEuiBreakpointProvider;
75
-
76
- var useCurrentEuiBreakpoint = function useCurrentEuiBreakpoint() {
77
- var currentBreakpoint = (0, _react.useContext)(CurrentEuiBreakpointContext);
78
- return currentBreakpoint;
79
- };
80
67
 
81
- exports.useCurrentEuiBreakpoint = useCurrentEuiBreakpoint;
68
+ exports.CurrentEuiBreakpointProvider = CurrentEuiBreakpointProvider;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCurrentEuiBreakpoint = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _current_breakpoint = require("./current_breakpoint");
11
+
12
+ /*
13
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
14
+ * or more contributor license agreements. Licensed under the Elastic License
15
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
16
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
17
+ * Side Public License, v 1.
18
+ */
19
+
20
+ /**
21
+ * Hook util / syntactical sugar for useContext()
22
+ *
23
+ * This hook is in its own separate file to make mocking it
24
+ * as a testenv easy for Jest unit tests
25
+ */
26
+ var useCurrentEuiBreakpoint = function useCurrentEuiBreakpoint() {
27
+ var currentBreakpoint = (0, _react.useContext)(_current_breakpoint.CurrentEuiBreakpointContext);
28
+ return currentBreakpoint;
29
+ };
30
+
31
+ exports.useCurrentEuiBreakpoint = useCurrentEuiBreakpoint;
@@ -17,15 +17,28 @@ Object.keys(_breakpoint).forEach(function (key) {
17
17
  });
18
18
  });
19
19
 
20
- var _currentEuiBreakpoint = require("./currentEuiBreakpoint");
20
+ var _current_breakpoint = require("./current_breakpoint");
21
21
 
22
- Object.keys(_currentEuiBreakpoint).forEach(function (key) {
22
+ Object.keys(_current_breakpoint).forEach(function (key) {
23
23
  if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _currentEuiBreakpoint[key]) return;
24
+ if (key in exports && exports[key] === _current_breakpoint[key]) return;
25
25
  Object.defineProperty(exports, key, {
26
26
  enumerable: true,
27
27
  get: function get() {
28
- return _currentEuiBreakpoint[key];
28
+ return _current_breakpoint[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _current_breakpoint_hook = require("./current_breakpoint_hook");
34
+
35
+ Object.keys(_current_breakpoint_hook).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _current_breakpoint_hook[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function get() {
41
+ return _current_breakpoint_hook[key];
29
42
  }
30
43
  });
31
44
  });
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.useIsWithinBreakpoints = void 0;
7
7
 
8
- var _currentEuiBreakpoint = require("./currentEuiBreakpoint");
8
+ var _current_breakpoint_hook = require("./current_breakpoint_hook");
9
9
 
10
10
  /*
11
11
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -27,7 +27,7 @@ var _currentEuiBreakpoint = require("./currentEuiBreakpoint");
27
27
  */
28
28
  var useIsWithinBreakpoints = function useIsWithinBreakpoints(sizes) {
29
29
  var isResponsive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
30
- var currentBreakpoint = (0, _currentEuiBreakpoint.useCurrentEuiBreakpoint)();
30
+ var currentBreakpoint = (0, _current_breakpoint_hook.useCurrentEuiBreakpoint)();
31
31
  return currentBreakpoint && isResponsive ? sizes.includes(currentBreakpoint) : false;
32
32
  };
33
33
 
@@ -5,12 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.waitForEuiPopoverOpen = exports.waitForEuiPopoverClose = void 0;
8
+ exports.waitForEuiToolTipVisible = exports.waitForEuiToolTipHidden = exports.waitForEuiPopoverOpen = exports.waitForEuiPopoverClose = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
 
14
+ require("@testing-library/jest-dom");
15
+
14
16
  var _react = require("@testing-library/react");
15
17
 
16
18
  /*
@@ -22,7 +24,7 @@ var _react = require("@testing-library/react");
22
24
  */
23
25
 
24
26
  /**
25
- * Ensure the EuiPopover being tested is open/closed before contiuning
27
+ * Ensure the EuiPopover being tested is open/closed before continuing
26
28
  * Note: Because EuiPopover is portalled, we want to query `document`
27
29
  * instead of the `container` returned by RTL's render()
28
30
  */
@@ -83,5 +85,69 @@ var waitForEuiPopoverClose = /*#__PURE__*/function () {
83
85
  return _ref2.apply(this, arguments);
84
86
  };
85
87
  }();
88
+ /**
89
+ * Ensure the EuiToolTip being tested is open and visible before continuing
90
+ */
91
+
92
+
93
+ exports.waitForEuiPopoverClose = waitForEuiPopoverClose;
94
+
95
+ var waitForEuiToolTipVisible = /*#__PURE__*/function () {
96
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
97
+ return _regenerator.default.wrap(function _callee3$(_context3) {
98
+ while (1) {
99
+ switch (_context3.prev = _context3.next) {
100
+ case 0:
101
+ _context3.next = 2;
102
+ return (0, _react.waitFor)(function () {
103
+ var tooltip = document.querySelector('.euiToolTipPopover');
104
+ expect(tooltip).toBeVisible();
105
+ });
106
+
107
+ case 2:
108
+ return _context3.abrupt("return", _context3.sent);
109
+
110
+ case 3:
111
+ case "end":
112
+ return _context3.stop();
113
+ }
114
+ }
115
+ }, _callee3);
116
+ }));
117
+
118
+ return function waitForEuiToolTipVisible() {
119
+ return _ref3.apply(this, arguments);
120
+ };
121
+ }();
122
+
123
+ exports.waitForEuiToolTipVisible = waitForEuiToolTipVisible;
124
+
125
+ var waitForEuiToolTipHidden = /*#__PURE__*/function () {
126
+ var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
127
+ return _regenerator.default.wrap(function _callee4$(_context4) {
128
+ while (1) {
129
+ switch (_context4.prev = _context4.next) {
130
+ case 0:
131
+ _context4.next = 2;
132
+ return (0, _react.waitFor)(function () {
133
+ var tooltip = document.querySelector('.euiToolTipPopover');
134
+ expect(tooltip).toBeNull();
135
+ });
136
+
137
+ case 2:
138
+ return _context4.abrupt("return", _context4.sent);
139
+
140
+ case 3:
141
+ case "end":
142
+ return _context4.stop();
143
+ }
144
+ }
145
+ }, _callee4);
146
+ }));
147
+
148
+ return function waitForEuiToolTipHidden() {
149
+ return _ref4.apply(this, arguments);
150
+ };
151
+ }();
86
152
 
87
- exports.waitForEuiPopoverClose = waitForEuiPopoverClose;
153
+ exports.waitForEuiToolTipHidden = waitForEuiToolTipHidden;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elastic/eui",
3
3
  "description": "Elastic UI Component Library",
4
- "version": "62.1.0",
4
+ "version": "62.2.2",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "lib",
7
7
  "module": "es",
@@ -115,7 +115,7 @@
115
115
  "@cypress/code-coverage": "^3.9.12",
116
116
  "@cypress/react": "^5.10.3",
117
117
  "@cypress/webpack-dev-server": "^1.7.0",
118
- "@elastic/charts": "^47.1.1",
118
+ "@elastic/charts": "^47.2.0",
119
119
  "@elastic/datemath": "^5.0.3",
120
120
  "@elastic/eslint-config-kibana": "^0.15.0",
121
121
  "@emotion/babel-preset-css-prop": "^11.2.0",
@@ -361,6 +361,8 @@ var EuiDataGridBody = function EuiDataGridBody(props) {
361
361
 
362
362
  var rowHeightUtils = (0, _row_heights.useRowHeightUtils)({
363
363
  gridRef: gridRef,
364
+ outerGridElementRef: outerGridRef,
365
+ gridItemsRenderedRef: gridItemsRendered,
364
366
  gridStyles: gridStyles,
365
367
  columns: columns,
366
368
  rowHeightsOptions: rowHeightsOptions
@@ -1045,7 +1047,15 @@ EuiDataGridBody.propTypes = {
1045
1047
  * Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
1046
1048
  * Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
1047
1049
  */
1048
- onChange: _propTypes.default.func
1050
+ onChange: _propTypes.default.func,
1051
+
1052
+ /**
1053
+ * Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
1054
+ * When set to 'start' or 'center', the topmost or middle visible row will try
1055
+ * to compensate for changes in their top offsets by adjusting the grid's scroll
1056
+ * position.
1057
+ */
1058
+ scrollAnchorRow: _propTypes.default.oneOf(["start", "center", undefined])
1049
1059
  }),
1050
1060
  isFullScreen: _propTypes.default.bool.isRequired,
1051
1061
  gridStyles: _propTypes.default.shape({
@@ -558,7 +558,15 @@ EuiDataGridCellContent.propTypes = {
558
558
  * Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
559
559
  * Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
560
560
  */
561
- onChange: _propTypes.default.func
561
+ onChange: _propTypes.default.func,
562
+
563
+ /**
564
+ * Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
565
+ * When set to 'start' or 'center', the topmost or middle visible row will try
566
+ * to compensate for changes in their top offsets by adjusting the grid's scroll
567
+ * position.
568
+ */
569
+ scrollAnchorRow: _propTypes.default.oneOf(["start", "center", undefined])
562
570
  }),
563
571
  rowHeightUtils: _propTypes.default.any,
564
572
  pagination: _propTypes.default.shape({
@@ -904,7 +912,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
904
912
  }, {
905
913
  key: "componentDidUpdate",
906
914
  value: function componentDidUpdate(prevProps) {
907
- var _this$props$rowHeight, _prevProps$rowHeights;
915
+ var _this$props$rowHeight, _prevProps$rowHeights, _this$props$rowHeight2, _this$props$style, _prevProps$style;
908
916
 
909
917
  this.recalculateAutoHeight();
910
918
 
@@ -912,6 +920,18 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
912
920
  this.recalculateLineHeight();
913
921
  }
914
922
 
923
+ if ((_this$props$rowHeight2 = this.props.rowHeightsOptions) !== null && _this$props$rowHeight2 !== void 0 && _this$props$rowHeight2.scrollAnchorRow && this.props.colIndex === 0 && // once per row
924
+ this.props.columnId === prevProps.columnId && // if this is still the same column
925
+ this.props.rowIndex === prevProps.rowIndex && // if this is still the same row
926
+ ((_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
927
+ ) {
928
+ var _prevProps$style2, _this$props$style2, _this$props$rowHeight3, _this$props$rowHeight4;
929
+
930
+ var previousTop = parseFloat((_prevProps$style2 = prevProps.style) === null || _prevProps$style2 === void 0 ? void 0 : _prevProps$style2.top);
931
+ var currentTop = parseFloat((_this$props$style2 = this.props.style) === null || _this$props$style2 === void 0 ? void 0 : _this$props$style2.top);
932
+ (_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);
933
+ }
934
+
915
935
  if (this.props.popoverContext.popoverIsOpen !== prevProps.popoverContext.popoverIsOpen || this.props.popoverContext.cellLocation !== prevProps.popoverContext.cellLocation || this.props.renderCellPopover !== prevProps.renderCellPopover) {
916
936
  this.handleCellPopover();
917
937
  }
@@ -1555,7 +1575,15 @@ EuiDataGridCell.propTypes = {
1555
1575
  * Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
1556
1576
  * Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
1557
1577
  */
1558
- onChange: _propTypes.default.func
1578
+ onChange: _propTypes.default.func,
1579
+
1580
+ /**
1581
+ * Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
1582
+ * When set to 'start' or 'center', the topmost or middle visible row will try
1583
+ * to compensate for changes in their top offsets by adjusting the grid's scroll
1584
+ * position.
1585
+ */
1586
+ scrollAnchorRow: _propTypes.default.oneOf(["start", "center", undefined])
1559
1587
  }),
1560
1588
  rowHeightUtils: _propTypes.default.any,
1561
1589
  rowManager: _propTypes.default.shape({
@@ -1263,7 +1263,15 @@ EuiDataGrid.propTypes = {
1263
1263
  * Optional callback returning the current `rowHeightsOptions` when changes occur from user input (e.g. toolbar display controls).
1264
1264
  * Can be used for, e.g. storing user `rowHeightsOptions` in a local storage object.
1265
1265
  */
1266
- onChange: _propTypes.default.func
1266
+ onChange: _propTypes.default.func,
1267
+
1268
+ /**
1269
+ * Optional indicator of the row that should be used as an anchor for vertical layout shift compensation.
1270
+ * When set to 'start' or 'center', the topmost or middle visible row will try
1271
+ * to compensate for changes in their top offsets by adjusting the grid's scroll
1272
+ * position.
1273
+ */
1274
+ scrollAnchorRow: _propTypes.default.oneOf(["start", "center", undefined])
1267
1275
  })
1268
1276
  };
1269
1277
  EuiDataGrid.displayName = 'EuiDataGrid';