@elastic/eui 62.0.2 → 62.0.3
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/es/components/popover/wrapping_popover.js +88 -45
- package/es/components/portal/portal.js +84 -38
- package/eui.d.ts +19 -4
- package/lib/components/popover/wrapping_popover.js +85 -44
- package/lib/components/portal/portal.js +87 -39
- package/optimize/es/components/popover/wrapping_popover.js +79 -38
- package/optimize/es/components/portal/portal.js +66 -34
- package/optimize/lib/components/popover/wrapping_popover.js +78 -38
- package/optimize/lib/components/portal/portal.js +65 -44
- package/package.json +1 -1
- package/test-env/components/popover/wrapping_popover.js +78 -38
- package/test-env/components/portal/portal.js +79 -45
|
@@ -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
|
|
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
|
|
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
|
|
41
|
-
|
|
42
|
-
portalRef = _ref.portalRef,
|
|
43
|
-
children = _ref.children;
|
|
42
|
+
var EuiPortal = /*#__PURE__*/function (_Component) {
|
|
43
|
+
(0, _inherits2.default)(EuiPortal, _Component);
|
|
44
44
|
|
|
45
|
-
var
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
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 (
|
|
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.
|
|
64
|
+
var sibling = insert.sibling,
|
|
65
|
+
position = insert.position;
|
|
66
|
+
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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;
|
package/package.json
CHANGED
|
@@ -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 _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -31,51 +43,79 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
31
43
|
|
|
32
44
|
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; }
|
|
33
45
|
|
|
46
|
+
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); }; }
|
|
47
|
+
|
|
48
|
+
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; } }
|
|
49
|
+
|
|
34
50
|
/**
|
|
35
51
|
* Injects the EuiPopover next to the button via EuiPortal
|
|
36
52
|
* then the button element is moved into the popover dom.
|
|
37
53
|
* On unmount, the button is moved back to its original location.
|
|
38
54
|
*/
|
|
39
|
-
var EuiWrappingPopover = function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setPortal = _useState4[1];
|
|
52
|
-
|
|
53
|
-
(0, _react.useEffect)(function () {
|
|
54
|
-
if (anchor) {
|
|
55
|
-
// move the button into the popover DOM
|
|
56
|
-
anchor.insertAdjacentElement('beforebegin', button);
|
|
55
|
+
var EuiWrappingPopover = /*#__PURE__*/function (_Component) {
|
|
56
|
+
(0, _inherits2.default)(EuiWrappingPopover, _Component);
|
|
57
|
+
|
|
58
|
+
var _super = _createSuper(EuiWrappingPopover);
|
|
59
|
+
|
|
60
|
+
function EuiWrappingPopover() {
|
|
61
|
+
var _this;
|
|
62
|
+
|
|
63
|
+
(0, _classCallCheck2.default)(this, EuiWrappingPopover);
|
|
64
|
+
|
|
65
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
66
|
+
args[_key] = arguments[_key];
|
|
57
67
|
}
|
|
58
68
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
70
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "portal", null);
|
|
71
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "anchor", null);
|
|
72
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setPortalRef", function (node) {
|
|
73
|
+
_this.portal = node;
|
|
74
|
+
});
|
|
75
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setAnchorRef", function (node) {
|
|
76
|
+
_this.anchor = node;
|
|
77
|
+
});
|
|
78
|
+
return _this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
(0, _createClass2.default)(EuiWrappingPopover, [{
|
|
82
|
+
key: "componentDidMount",
|
|
83
|
+
value: function componentDidMount() {
|
|
84
|
+
if (this.anchor) {
|
|
85
|
+
this.anchor.insertAdjacentElement('beforebegin', this.props.button);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "componentWillUnmount",
|
|
90
|
+
value: function componentWillUnmount() {
|
|
91
|
+
if (this.props.button.parentNode) {
|
|
92
|
+
if (this.portal) {
|
|
93
|
+
this.portal.insertAdjacentElement('beforebegin', this.props.button);
|
|
94
|
+
}
|
|
63
95
|
}
|
|
64
|
-
};
|
|
65
|
-
}, [anchor, button, portal]);
|
|
66
|
-
return (0, _react2.jsx)(_portal.EuiPortal, {
|
|
67
|
-
portalRef: setPortal,
|
|
68
|
-
insert: {
|
|
69
|
-
sibling: button,
|
|
70
|
-
position: 'after'
|
|
71
96
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
}, {
|
|
98
|
+
key: "render",
|
|
99
|
+
value: function render() {
|
|
100
|
+
var _this$props = this.props,
|
|
101
|
+
button = _this$props.button,
|
|
102
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
103
|
+
return (0, _react2.jsx)(_portal.EuiPortal, {
|
|
104
|
+
portalRef: this.setPortalRef,
|
|
105
|
+
insert: {
|
|
106
|
+
sibling: this.props.button,
|
|
107
|
+
position: 'after'
|
|
108
|
+
}
|
|
109
|
+
}, (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({}, rest, {
|
|
110
|
+
button: (0, _react2.jsx)("div", {
|
|
111
|
+
ref: this.setAnchorRef,
|
|
112
|
+
className: "euiWrappingPopover__anchor"
|
|
113
|
+
})
|
|
114
|
+
})));
|
|
115
|
+
}
|
|
116
|
+
}]);
|
|
117
|
+
return EuiWrappingPopover;
|
|
118
|
+
}(_react.Component);
|
|
79
119
|
|
|
80
120
|
exports.EuiWrappingPopover = EuiWrappingPopover;
|
|
81
121
|
EuiWrappingPopover.propTypes = {
|
|
@@ -7,28 +7,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.insertPositions = exports.INSERT_POSITIONS = exports.EuiPortal = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
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
|
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
14
28
|
var _reactDom = require("react-dom");
|
|
15
29
|
|
|
16
30
|
var _common = require("../common");
|
|
17
31
|
|
|
18
|
-
var
|
|
32
|
+
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
33
|
|
|
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
|
-
*/
|
|
34
|
+
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
35
|
|
|
28
|
-
/**
|
|
29
|
-
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
30
|
-
* into portals.
|
|
31
|
-
*/
|
|
32
36
|
var insertPositions = {
|
|
33
37
|
after: 'afterend',
|
|
34
38
|
before: 'beforebegin'
|
|
@@ -37,47 +41,77 @@ exports.insertPositions = insertPositions;
|
|
|
37
41
|
var INSERT_POSITIONS = (0, _common.keysOf)(insertPositions);
|
|
38
42
|
exports.INSERT_POSITIONS = INSERT_POSITIONS;
|
|
39
43
|
|
|
40
|
-
var EuiPortal = function
|
|
41
|
-
|
|
42
|
-
portalRef = _ref.portalRef,
|
|
43
|
-
children = _ref.children;
|
|
44
|
+
var EuiPortal = /*#__PURE__*/function (_Component) {
|
|
45
|
+
(0, _inherits2.default)(EuiPortal, _Component);
|
|
44
46
|
|
|
45
|
-
var
|
|
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
|
|
47
|
+
var _super = _createSuper(EuiPortal);
|
|
49
48
|
|
|
49
|
+
function EuiPortal(props) {
|
|
50
|
+
var _this;
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
(0, _classCallCheck2.default)(this, EuiPortal);
|
|
53
|
+
_this = _super.call(this, props);
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "portalNode", null);
|
|
55
|
+
if (typeof window === 'undefined') return (0, _possibleConstructorReturn2.default)(_this); // Prevent SSR errors
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
portalNode.dataset.euiportal = 'true';
|
|
58
|
-
setPortalNode(portalNode);
|
|
57
|
+
var insert = _this.props.insert;
|
|
58
|
+
_this.portalNode = document.createElement('div');
|
|
59
|
+
_this.portalNode.dataset.euiportal = 'true';
|
|
59
60
|
|
|
60
|
-
if (
|
|
61
|
+
if (insert == null) {
|
|
61
62
|
// no insertion defined, append to body
|
|
62
|
-
document.body.appendChild(portalNode);
|
|
63
|
+
document.body.appendChild(_this.portalNode);
|
|
63
64
|
} else {
|
|
64
65
|
// inserting before or after an element
|
|
65
|
-
sibling.
|
|
66
|
+
var sibling = insert.sibling,
|
|
67
|
+
position = insert.position;
|
|
68
|
+
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
return _this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
(0, _createClass2.default)(EuiPortal, [{
|
|
75
|
+
key: "componentDidMount",
|
|
76
|
+
value: function componentDidMount() {
|
|
77
|
+
this.updatePortalRef(this.portalNode);
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "componentWillUnmount",
|
|
81
|
+
value: function componentWillUnmount() {
|
|
82
|
+
var _this$portalNode;
|
|
83
|
+
|
|
84
|
+
if ((_this$portalNode = this.portalNode) !== null && _this$portalNode !== void 0 && _this$portalNode.parentNode) {
|
|
85
|
+
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
71
86
|
}
|
|
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
|
-
};
|
|
82
87
|
|
|
83
|
-
|
|
88
|
+
this.updatePortalRef(null);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "updatePortalRef",
|
|
92
|
+
value: function updatePortalRef(ref) {
|
|
93
|
+
if (this.props.portalRef) {
|
|
94
|
+
this.props.portalRef(ref);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "render",
|
|
99
|
+
value: function render() {
|
|
100
|
+
return this.portalNode ? /*#__PURE__*/(0, _reactDom.createPortal)(this.props.children, this.portalNode) : null;
|
|
101
|
+
}
|
|
102
|
+
}]);
|
|
103
|
+
return EuiPortal;
|
|
104
|
+
}(_react.Component);
|
|
105
|
+
|
|
106
|
+
exports.EuiPortal = EuiPortal;
|
|
107
|
+
EuiPortal.propTypes = {
|
|
108
|
+
/**
|
|
109
|
+
* ReactNode to render as this component's content
|
|
110
|
+
*/
|
|
111
|
+
children: _propTypes.default.node.isRequired,
|
|
112
|
+
insert: _propTypes.default.shape({
|
|
113
|
+
sibling: _propTypes.default.any.isRequired,
|
|
114
|
+
position: _propTypes.default.oneOf(["before", "after"]).isRequired
|
|
115
|
+
}),
|
|
116
|
+
portalRef: _propTypes.default.func
|
|
117
|
+
};
|