@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
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
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); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -7,23 +9,35 @@ exports.insertPositions = exports.INSERT_POSITIONS = exports.EuiPortal = void 0;
|
|
|
7
9
|
|
|
8
10
|
var _react = require("react");
|
|
9
11
|
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
10
14
|
var _reactDom = require("react-dom");
|
|
11
15
|
|
|
12
16
|
var _common = require("../common");
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
+
|
|
22
|
+
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); } }
|
|
23
|
+
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
15
25
|
|
|
16
|
-
function
|
|
26
|
+
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); }
|
|
17
27
|
|
|
18
|
-
function
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
29
|
|
|
20
|
-
function
|
|
30
|
+
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); }; }
|
|
21
31
|
|
|
22
|
-
function
|
|
32
|
+
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); }
|
|
23
33
|
|
|
24
|
-
function
|
|
34
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
35
|
|
|
26
|
-
function
|
|
36
|
+
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; } }
|
|
37
|
+
|
|
38
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
27
41
|
|
|
28
42
|
var insertPositions = {
|
|
29
43
|
after: 'afterend',
|
|
@@ -33,47 +47,81 @@ exports.insertPositions = insertPositions;
|
|
|
33
47
|
var INSERT_POSITIONS = (0, _common.keysOf)(insertPositions);
|
|
34
48
|
exports.INSERT_POSITIONS = INSERT_POSITIONS;
|
|
35
49
|
|
|
36
|
-
var EuiPortal = function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
var EuiPortal = /*#__PURE__*/function (_Component) {
|
|
51
|
+
_inherits(EuiPortal, _Component);
|
|
52
|
+
|
|
53
|
+
var _super = _createSuper(EuiPortal);
|
|
54
|
+
|
|
55
|
+
function EuiPortal(props) {
|
|
56
|
+
var _this;
|
|
40
57
|
|
|
41
|
-
|
|
42
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
-
portalNode = _useState2[0],
|
|
44
|
-
setPortalNode = _useState2[1]; // pull `sibling` and `position` out of insert in case their wrapping object is recreated every render
|
|
58
|
+
_classCallCheck(this, EuiPortal);
|
|
45
59
|
|
|
60
|
+
_this = _super.call(this, props);
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
sibling = _ref2.sibling,
|
|
49
|
-
position = _ref2.position;
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "portalNode", null);
|
|
50
63
|
|
|
51
|
-
|
|
52
|
-
var portalNode = document.createElement('div');
|
|
53
|
-
portalNode.dataset.euiportal = 'true';
|
|
54
|
-
setPortalNode(portalNode);
|
|
64
|
+
if (typeof window === 'undefined') return _possibleConstructorReturn(_this); // Prevent SSR errors
|
|
55
65
|
|
|
56
|
-
|
|
66
|
+
var insert = _this.props.insert;
|
|
67
|
+
_this.portalNode = document.createElement('div');
|
|
68
|
+
_this.portalNode.dataset.euiportal = 'true';
|
|
69
|
+
|
|
70
|
+
if (insert == null) {
|
|
57
71
|
// no insertion defined, append to body
|
|
58
|
-
document.body.appendChild(portalNode);
|
|
72
|
+
document.body.appendChild(_this.portalNode);
|
|
59
73
|
} else {
|
|
60
74
|
// inserting before or after an element
|
|
61
|
-
sibling.
|
|
75
|
+
var sibling = insert.sibling,
|
|
76
|
+
position = insert.position;
|
|
77
|
+
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
62
78
|
}
|
|
63
79
|
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_createClass(EuiPortal, [{
|
|
84
|
+
key: "componentDidMount",
|
|
85
|
+
value: function componentDidMount() {
|
|
86
|
+
this.updatePortalRef(this.portalNode);
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "componentWillUnmount",
|
|
90
|
+
value: function componentWillUnmount() {
|
|
91
|
+
var _this$portalNode;
|
|
92
|
+
|
|
93
|
+
if ((_this$portalNode = this.portalNode) !== null && _this$portalNode !== void 0 && _this$portalNode.parentNode) {
|
|
94
|
+
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
67
95
|
}
|
|
68
|
-
};
|
|
69
|
-
}, [sibling, position]);
|
|
70
|
-
(0, _services.useUpdateEffect)(function () {
|
|
71
|
-
portalRef === null || portalRef === void 0 ? void 0 : portalRef(portalNode);
|
|
72
|
-
return function () {
|
|
73
|
-
portalRef === null || portalRef === void 0 ? void 0 : portalRef(null);
|
|
74
|
-
};
|
|
75
|
-
}, [portalNode, portalRef]);
|
|
76
|
-
return portalNode == null ? null : /*#__PURE__*/(0, _reactDom.createPortal)(children, portalNode);
|
|
77
|
-
};
|
|
78
96
|
|
|
79
|
-
|
|
97
|
+
this.updatePortalRef(null);
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "updatePortalRef",
|
|
101
|
+
value: function updatePortalRef(ref) {
|
|
102
|
+
if (this.props.portalRef) {
|
|
103
|
+
this.props.portalRef(ref);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "render",
|
|
108
|
+
value: function render() {
|
|
109
|
+
return this.portalNode ? /*#__PURE__*/(0, _reactDom.createPortal)(this.props.children, this.portalNode) : null;
|
|
110
|
+
}
|
|
111
|
+
}]);
|
|
112
|
+
|
|
113
|
+
return EuiPortal;
|
|
114
|
+
}(_react.Component);
|
|
115
|
+
|
|
116
|
+
exports.EuiPortal = EuiPortal;
|
|
117
|
+
EuiPortal.propTypes = {
|
|
118
|
+
/**
|
|
119
|
+
* ReactNode to render as this component's content
|
|
120
|
+
*/
|
|
121
|
+
children: _propTypes.default.node.isRequired,
|
|
122
|
+
insert: _propTypes.default.shape({
|
|
123
|
+
sibling: _propTypes.default.any.isRequired,
|
|
124
|
+
position: _propTypes.default.oneOf(["before", "after"]).isRequired
|
|
125
|
+
}),
|
|
126
|
+
portalRef: _propTypes.default.func
|
|
127
|
+
};
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
10
|
var _excluded = ["button"];
|
|
5
11
|
|
|
12
|
+
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); }; }
|
|
13
|
+
|
|
14
|
+
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; } }
|
|
15
|
+
|
|
6
16
|
/*
|
|
7
17
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
8
18
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -10,7 +20,7 @@ var _excluded = ["button"];
|
|
|
10
20
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
11
21
|
* Side Public License, v 1.
|
|
12
22
|
*/
|
|
13
|
-
import React, {
|
|
23
|
+
import React, { Component } from 'react';
|
|
14
24
|
import { EuiPopover } from './popover';
|
|
15
25
|
import { EuiPortal } from '../portal';
|
|
16
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
@@ -20,43 +30,74 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
20
30
|
* then the button element is moved into the popover dom.
|
|
21
31
|
* On unmount, the button is moved back to its original location.
|
|
22
32
|
*/
|
|
23
|
-
export var EuiWrappingPopover = function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
setPortal = _useState4[1];
|
|
36
|
-
|
|
37
|
-
useEffect(function () {
|
|
38
|
-
if (anchor) {
|
|
39
|
-
// move the button into the popover DOM
|
|
40
|
-
anchor.insertAdjacentElement('beforebegin', button);
|
|
33
|
+
export var EuiWrappingPopover = /*#__PURE__*/function (_Component) {
|
|
34
|
+
_inherits(EuiWrappingPopover, _Component);
|
|
35
|
+
|
|
36
|
+
var _super = _createSuper(EuiWrappingPopover);
|
|
37
|
+
|
|
38
|
+
function EuiWrappingPopover() {
|
|
39
|
+
var _this;
|
|
40
|
+
|
|
41
|
+
_classCallCheck(this, EuiWrappingPopover);
|
|
42
|
+
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
|
+
args[_key] = arguments[_key];
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
|
+
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "portal", null);
|
|
50
|
+
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "anchor", null);
|
|
52
|
+
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "setPortalRef", function (node) {
|
|
54
|
+
_this.portal = node;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "setAnchorRef", function (node) {
|
|
58
|
+
_this.anchor = node;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_createClass(EuiWrappingPopover, [{
|
|
65
|
+
key: "componentDidMount",
|
|
66
|
+
value: function componentDidMount() {
|
|
67
|
+
if (this.anchor) {
|
|
68
|
+
this.anchor.insertAdjacentElement('beforebegin', this.props.button);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "componentWillUnmount",
|
|
73
|
+
value: function componentWillUnmount() {
|
|
74
|
+
if (this.props.button.parentNode) {
|
|
75
|
+
if (this.portal) {
|
|
76
|
+
this.portal.insertAdjacentElement('beforebegin', this.props.button);
|
|
77
|
+
}
|
|
47
78
|
}
|
|
48
|
-
};
|
|
49
|
-
}, [anchor, button, portal]);
|
|
50
|
-
return ___EmotionJSX(EuiPortal, {
|
|
51
|
-
portalRef: setPortal,
|
|
52
|
-
insert: {
|
|
53
|
-
sibling: button,
|
|
54
|
-
position: 'after'
|
|
55
79
|
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
80
|
+
}, {
|
|
81
|
+
key: "render",
|
|
82
|
+
value: function render() {
|
|
83
|
+
var _this$props = this.props,
|
|
84
|
+
button = _this$props.button,
|
|
85
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
86
|
+
|
|
87
|
+
return ___EmotionJSX(EuiPortal, {
|
|
88
|
+
portalRef: this.setPortalRef,
|
|
89
|
+
insert: {
|
|
90
|
+
sibling: this.props.button,
|
|
91
|
+
position: 'after'
|
|
92
|
+
}
|
|
93
|
+
}, ___EmotionJSX(EuiPopover, _extends({}, rest, {
|
|
94
|
+
button: ___EmotionJSX("div", {
|
|
95
|
+
ref: this.setAnchorRef,
|
|
96
|
+
className: "euiWrappingPopover__anchor"
|
|
97
|
+
})
|
|
98
|
+
})));
|
|
99
|
+
}
|
|
100
|
+
}]);
|
|
101
|
+
|
|
102
|
+
return EuiWrappingPopover;
|
|
103
|
+
}(Component);
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
9
|
+
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); }; }
|
|
10
|
+
|
|
11
|
+
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; } }
|
|
2
12
|
|
|
3
13
|
/*
|
|
4
14
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -12,54 +22,76 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
12
22
|
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
13
23
|
* into portals.
|
|
14
24
|
*/
|
|
15
|
-
import {
|
|
25
|
+
import { Component } from 'react';
|
|
16
26
|
import { createPortal } from 'react-dom';
|
|
17
27
|
import { keysOf } from '../common';
|
|
18
|
-
import { useUpdateEffect } from '../../services';
|
|
19
28
|
export var insertPositions = {
|
|
20
29
|
after: 'afterend',
|
|
21
30
|
before: 'beforebegin'
|
|
22
31
|
};
|
|
23
32
|
export var INSERT_POSITIONS = keysOf(insertPositions);
|
|
24
|
-
export var EuiPortal = function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
export var EuiPortal = /*#__PURE__*/function (_Component) {
|
|
34
|
+
_inherits(EuiPortal, _Component);
|
|
35
|
+
|
|
36
|
+
var _super = _createSuper(EuiPortal);
|
|
37
|
+
|
|
38
|
+
function EuiPortal(props) {
|
|
39
|
+
var _this;
|
|
28
40
|
|
|
29
|
-
|
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
-
portalNode = _useState2[0],
|
|
32
|
-
setPortalNode = _useState2[1]; // pull `sibling` and `position` out of insert in case their wrapping object is recreated every render
|
|
41
|
+
_classCallCheck(this, EuiPortal);
|
|
33
42
|
|
|
43
|
+
_this = _super.call(this, props);
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
sibling = _ref2.sibling,
|
|
37
|
-
position = _ref2.position;
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "portalNode", null);
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
var portalNode = document.createElement('div');
|
|
41
|
-
portalNode.dataset.euiportal = 'true';
|
|
42
|
-
setPortalNode(portalNode);
|
|
47
|
+
if (typeof window === 'undefined') return _possibleConstructorReturn(_this); // Prevent SSR errors
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
var insert = _this.props.insert;
|
|
50
|
+
_this.portalNode = document.createElement('div');
|
|
51
|
+
_this.portalNode.dataset.euiportal = 'true';
|
|
52
|
+
|
|
53
|
+
if (insert == null) {
|
|
45
54
|
// no insertion defined, append to body
|
|
46
|
-
document.body.appendChild(portalNode);
|
|
55
|
+
document.body.appendChild(_this.portalNode);
|
|
47
56
|
} else {
|
|
48
57
|
// inserting before or after an element
|
|
49
|
-
sibling.
|
|
58
|
+
var sibling = insert.sibling,
|
|
59
|
+
position = insert.position;
|
|
60
|
+
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return _this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_createClass(EuiPortal, [{
|
|
67
|
+
key: "componentDidMount",
|
|
68
|
+
value: function componentDidMount() {
|
|
69
|
+
this.updatePortalRef(this.portalNode);
|
|
50
70
|
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "componentWillUnmount",
|
|
73
|
+
value: function componentWillUnmount() {
|
|
74
|
+
var _this$portalNode;
|
|
75
|
+
|
|
76
|
+
if ((_this$portalNode = this.portalNode) !== null && _this$portalNode !== void 0 && _this$portalNode.parentNode) {
|
|
77
|
+
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
78
|
+
}
|
|
51
79
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
80
|
+
this.updatePortalRef(null);
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "updatePortalRef",
|
|
84
|
+
value: function updatePortalRef(ref) {
|
|
85
|
+
if (this.props.portalRef) {
|
|
86
|
+
this.props.portalRef(ref);
|
|
55
87
|
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
};
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "render",
|
|
91
|
+
value: function render() {
|
|
92
|
+
return this.portalNode ? /*#__PURE__*/createPortal(this.props.children, this.portalNode) : null;
|
|
93
|
+
}
|
|
94
|
+
}]);
|
|
95
|
+
|
|
96
|
+
return EuiPortal;
|
|
97
|
+
}(Component);
|
|
@@ -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
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|