@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,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
|
};
|
package/eui.d.ts
CHANGED
|
@@ -4611,7 +4611,7 @@ declare module '@elastic/eui/src/components/portal/portal' {
|
|
|
4611
4611
|
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
4612
4612
|
* into portals.
|
|
4613
4613
|
*/
|
|
4614
|
-
import { ReactNode } from 'react';
|
|
4614
|
+
import { Component, ReactNode } from 'react';
|
|
4615
4615
|
interface InsertPositionsMap {
|
|
4616
4616
|
after: InsertPosition;
|
|
4617
4617
|
before: InsertPosition;
|
|
@@ -4629,7 +4629,14 @@ declare module '@elastic/eui/src/components/portal/portal' {
|
|
|
4629
4629
|
};
|
|
4630
4630
|
portalRef?: (ref: HTMLDivElement | null) => void;
|
|
4631
4631
|
}
|
|
4632
|
-
export
|
|
4632
|
+
export class EuiPortal extends Component<EuiPortalProps> {
|
|
4633
|
+
portalNode: HTMLDivElement | null;
|
|
4634
|
+
constructor(props: EuiPortalProps);
|
|
4635
|
+
componentDidMount(): void;
|
|
4636
|
+
componentWillUnmount(): void;
|
|
4637
|
+
updatePortalRef(ref: HTMLDivElement | null): void;
|
|
4638
|
+
render(): import("react").ReactPortal | null;
|
|
4639
|
+
}
|
|
4633
4640
|
export {};
|
|
4634
4641
|
|
|
4635
4642
|
}
|
|
@@ -5301,7 +5308,7 @@ declare module '@elastic/eui/src/components/popover/popover_footer' {
|
|
|
5301
5308
|
|
|
5302
5309
|
}
|
|
5303
5310
|
declare module '@elastic/eui/src/components/popover/wrapping_popover' {
|
|
5304
|
-
import {
|
|
5311
|
+
import { Component } from 'react';
|
|
5305
5312
|
import { Props as EuiPopoverProps } from '@elastic/eui/src/components/popover/popover';
|
|
5306
5313
|
export interface EuiWrappingPopoverProps extends EuiPopoverProps {
|
|
5307
5314
|
button: HTMLElement;
|
|
@@ -5311,7 +5318,15 @@ declare module '@elastic/eui/src/components/popover/wrapping_popover' {
|
|
|
5311
5318
|
* then the button element is moved into the popover dom.
|
|
5312
5319
|
* On unmount, the button is moved back to its original location.
|
|
5313
5320
|
*/
|
|
5314
|
-
export
|
|
5321
|
+
export class EuiWrappingPopover extends Component<EuiWrappingPopoverProps> {
|
|
5322
|
+
private portal;
|
|
5323
|
+
private anchor;
|
|
5324
|
+
componentDidMount(): void;
|
|
5325
|
+
componentWillUnmount(): void;
|
|
5326
|
+
setPortalRef: (node: HTMLElement | null) => void;
|
|
5327
|
+
setAnchorRef: (node: HTMLElement | null) => void;
|
|
5328
|
+
render(): JSX.Element;
|
|
5329
|
+
}
|
|
5315
5330
|
|
|
5316
5331
|
}
|
|
5317
5332
|
declare module '@elastic/eui/src/components/popover' {
|
|
@@ -27,67 +27,108 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
27
|
|
|
28
28
|
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); }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
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; }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
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; }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
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); } }
|
|
37
37
|
|
|
38
|
-
function
|
|
38
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
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); }
|
|
41
41
|
|
|
42
|
-
function
|
|
42
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
43
43
|
|
|
44
|
-
function
|
|
44
|
+
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); }; }
|
|
45
|
+
|
|
46
|
+
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); }
|
|
47
|
+
|
|
48
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
49
|
+
|
|
50
|
+
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; } }
|
|
51
|
+
|
|
52
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
53
|
+
|
|
54
|
+
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; }
|
|
45
55
|
|
|
46
56
|
/**
|
|
47
57
|
* Injects the EuiPopover next to the button via EuiPortal
|
|
48
58
|
* then the button element is moved into the popover dom.
|
|
49
59
|
* On unmount, the button is moved back to its original location.
|
|
50
60
|
*/
|
|
51
|
-
var EuiWrappingPopover = function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setPortal = _useState4[1];
|
|
64
|
-
|
|
65
|
-
(0, _react.useEffect)(function () {
|
|
66
|
-
if (anchor) {
|
|
67
|
-
// move the button into the popover DOM
|
|
68
|
-
anchor.insertAdjacentElement('beforebegin', button);
|
|
61
|
+
var EuiWrappingPopover = /*#__PURE__*/function (_Component) {
|
|
62
|
+
_inherits(EuiWrappingPopover, _Component);
|
|
63
|
+
|
|
64
|
+
var _super = _createSuper(EuiWrappingPopover);
|
|
65
|
+
|
|
66
|
+
function EuiWrappingPopover() {
|
|
67
|
+
var _this;
|
|
68
|
+
|
|
69
|
+
_classCallCheck(this, EuiWrappingPopover);
|
|
70
|
+
|
|
71
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
|
+
args[_key] = arguments[_key];
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
76
|
+
|
|
77
|
+
_defineProperty(_assertThisInitialized(_this), "portal", null);
|
|
78
|
+
|
|
79
|
+
_defineProperty(_assertThisInitialized(_this), "anchor", null);
|
|
80
|
+
|
|
81
|
+
_defineProperty(_assertThisInitialized(_this), "setPortalRef", function (node) {
|
|
82
|
+
_this.portal = node;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
_defineProperty(_assertThisInitialized(_this), "setAnchorRef", function (node) {
|
|
86
|
+
_this.anchor = node;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
_createClass(EuiWrappingPopover, [{
|
|
93
|
+
key: "componentDidMount",
|
|
94
|
+
value: function componentDidMount() {
|
|
95
|
+
if (this.anchor) {
|
|
96
|
+
this.anchor.insertAdjacentElement('beforebegin', this.props.button);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "componentWillUnmount",
|
|
101
|
+
value: function componentWillUnmount() {
|
|
102
|
+
if (this.props.button.parentNode) {
|
|
103
|
+
if (this.portal) {
|
|
104
|
+
this.portal.insertAdjacentElement('beforebegin', this.props.button);
|
|
105
|
+
}
|
|
75
106
|
}
|
|
76
|
-
};
|
|
77
|
-
}, [anchor, button, portal]);
|
|
78
|
-
return (0, _react2.jsx)(_portal.EuiPortal, {
|
|
79
|
-
portalRef: setPortal,
|
|
80
|
-
insert: {
|
|
81
|
-
sibling: button,
|
|
82
|
-
position: 'after'
|
|
83
107
|
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
}, {
|
|
109
|
+
key: "render",
|
|
110
|
+
value: function render() {
|
|
111
|
+
var _this$props = this.props,
|
|
112
|
+
button = _this$props.button,
|
|
113
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
114
|
+
|
|
115
|
+
return (0, _react2.jsx)(_portal.EuiPortal, {
|
|
116
|
+
portalRef: this.setPortalRef,
|
|
117
|
+
insert: {
|
|
118
|
+
sibling: this.props.button,
|
|
119
|
+
position: 'after'
|
|
120
|
+
}
|
|
121
|
+
}, (0, _react2.jsx)(_popover.EuiPopover, _extends({}, rest, {
|
|
122
|
+
button: (0, _react2.jsx)("div", {
|
|
123
|
+
ref: this.setAnchorRef,
|
|
124
|
+
className: "euiWrappingPopover__anchor"
|
|
125
|
+
})
|
|
126
|
+
})));
|
|
127
|
+
}
|
|
128
|
+
}]);
|
|
129
|
+
|
|
130
|
+
return EuiWrappingPopover;
|
|
131
|
+
}(_react.Component);
|
|
91
132
|
|
|
92
133
|
exports.EuiWrappingPopover = EuiWrappingPopover;
|
|
93
134
|
EuiWrappingPopover.propTypes = {
|