@elastic/eui 62.0.0 → 62.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eui_charts_theme.js +330 -330
- package/dist/eui_charts_theme.js.map +1 -1
- package/es/components/filter_group/filter_button.js +3 -1
- package/es/components/image/image_caption.js +2 -2
- package/es/components/image/image_wrapper.styles.js +1 -1
- package/es/components/popover/wrapping_popover.js +45 -88
- package/es/components/portal/portal.js +38 -79
- package/eui.d.ts +4 -19
- package/lib/components/filter_group/filter_button.js +3 -1
- package/lib/components/image/image_caption.js +2 -2
- package/lib/components/image/image_wrapper.styles.js +1 -1
- package/lib/components/popover/wrapping_popover.js +44 -85
- package/lib/components/portal/portal.js +39 -82
- package/optimize/es/components/filter_group/filter_button.js +3 -1
- package/optimize/es/components/image/image_caption.js +2 -2
- package/optimize/es/components/image/image_wrapper.styles.js +1 -1
- package/optimize/es/components/popover/wrapping_popover.js +38 -79
- package/optimize/es/components/portal/portal.js +34 -61
- package/optimize/lib/components/filter_group/filter_button.js +3 -1
- package/optimize/lib/components/image/image_caption.js +2 -2
- package/optimize/lib/components/image/image_wrapper.styles.js +1 -1
- package/optimize/lib/components/popover/wrapping_popover.js +38 -78
- package/optimize/lib/components/portal/portal.js +45 -61
- package/package.json +1 -1
- package/test-env/components/filter_group/filter_button.js +3 -1
- package/test-env/components/image/image_caption.js +2 -2
- package/test-env/components/image/image_wrapper.styles.js +1 -1
- package/test-env/components/popover/wrapping_popover.js +38 -78
- package/test-env/components/portal/portal.js +46 -75
|
@@ -1,7 +1,5 @@
|
|
|
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
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,35 +7,23 @@ exports.insertPositions = exports.INSERT_POSITIONS = exports.EuiPortal = void 0;
|
|
|
9
7
|
|
|
10
8
|
var _react = require("react");
|
|
11
9
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _reactDom = require("react-dom");
|
|
15
11
|
|
|
16
12
|
var _common = require("../common");
|
|
17
13
|
|
|
18
|
-
|
|
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); } }
|
|
14
|
+
var _services = require("../../services");
|
|
23
15
|
|
|
24
|
-
function
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
17
|
|
|
26
|
-
function
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
19
|
|
|
28
|
-
function
|
|
20
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
21
|
|
|
30
|
-
function
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
31
23
|
|
|
32
|
-
function
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
33
25
|
|
|
34
|
-
function
|
|
35
|
-
|
|
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; }
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
27
|
|
|
42
28
|
var insertPositions = {
|
|
43
29
|
after: 'afterend',
|
|
@@ -47,76 +33,47 @@ exports.insertPositions = insertPositions;
|
|
|
47
33
|
var INSERT_POSITIONS = (0, _common.keysOf)(insertPositions);
|
|
48
34
|
exports.INSERT_POSITIONS = INSERT_POSITIONS;
|
|
49
35
|
|
|
50
|
-
var EuiPortal =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
var EuiPortal = function EuiPortal(_ref) {
|
|
37
|
+
var insert = _ref.insert,
|
|
38
|
+
portalRef = _ref.portalRef,
|
|
39
|
+
children = _ref.children;
|
|
54
40
|
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
var _useState = (0, _react.useState)(null),
|
|
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
|
|
57
45
|
|
|
58
|
-
_classCallCheck(this, EuiPortal);
|
|
59
46
|
|
|
60
|
-
|
|
47
|
+
var _ref2 = insert || {},
|
|
48
|
+
sibling = _ref2.sibling,
|
|
49
|
+
position = _ref2.position;
|
|
61
50
|
|
|
62
|
-
|
|
51
|
+
(0, _react.useEffect)(function () {
|
|
52
|
+
var portalNode = document.createElement('div');
|
|
53
|
+
portalNode.dataset.euiportal = 'true';
|
|
54
|
+
setPortalNode(portalNode);
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
_this.portalNode = document.createElement('div');
|
|
66
|
-
|
|
67
|
-
if (insert == null) {
|
|
56
|
+
if (sibling == null || position == null) {
|
|
68
57
|
// no insertion defined, append to body
|
|
69
|
-
document.body.appendChild(
|
|
58
|
+
document.body.appendChild(portalNode);
|
|
70
59
|
} else {
|
|
71
60
|
// inserting before or after an element
|
|
72
|
-
|
|
73
|
-
position = insert.position;
|
|
74
|
-
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
61
|
+
sibling.insertAdjacentElement(insertPositions[position], portalNode);
|
|
75
62
|
}
|
|
76
63
|
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_createClass(EuiPortal, [{
|
|
81
|
-
key: "componentDidMount",
|
|
82
|
-
value: function componentDidMount() {
|
|
83
|
-
this.updatePortalRef(this.portalNode);
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "componentWillUnmount",
|
|
87
|
-
value: function componentWillUnmount() {
|
|
88
|
-
if (this.portalNode.parentNode) {
|
|
89
|
-
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
64
|
+
return function () {
|
|
65
|
+
if (portalNode && portalNode.parentNode) {
|
|
66
|
+
portalNode.parentNode.removeChild(portalNode);
|
|
90
67
|
}
|
|
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
|
+
};
|
|
91
78
|
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
key: "updatePortalRef",
|
|
96
|
-
value: function updatePortalRef(ref) {
|
|
97
|
-
if (this.props.portalRef) {
|
|
98
|
-
this.props.portalRef(ref);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "render",
|
|
103
|
-
value: function render() {
|
|
104
|
-
return /*#__PURE__*/(0, _reactDom.createPortal)(this.props.children, this.portalNode);
|
|
105
|
-
}
|
|
106
|
-
}]);
|
|
107
|
-
|
|
108
|
-
return EuiPortal;
|
|
109
|
-
}(_react.Component);
|
|
110
|
-
|
|
111
|
-
exports.EuiPortal = EuiPortal;
|
|
112
|
-
EuiPortal.propTypes = {
|
|
113
|
-
/**
|
|
114
|
-
* ReactNode to render as this component's content
|
|
115
|
-
*/
|
|
116
|
-
children: _propTypes.default.node.isRequired,
|
|
117
|
-
insert: _propTypes.default.shape({
|
|
118
|
-
sibling: _propTypes.default.any.isRequired,
|
|
119
|
-
position: _propTypes.default.oneOf(["before", "after"]).isRequired
|
|
120
|
-
}),
|
|
121
|
-
portalRef: _propTypes.default.func
|
|
122
|
-
};
|
|
79
|
+
exports.EuiPortal = EuiPortal;
|
|
@@ -69,7 +69,9 @@ export var EuiFilterButton = function EuiFilterButton(_ref) {
|
|
|
69
69
|
var badgeContent = showBadge && ___EmotionJSX(EuiNotificationBadge, {
|
|
70
70
|
className: "euiFilterButton__notification",
|
|
71
71
|
"aria-label": hasActiveFilters ? activeBadgeLabel : availableBadgeLabel,
|
|
72
|
-
color: isDisabled || !hasActiveFilters ? 'subdued' : 'accent'
|
|
72
|
+
color: isDisabled || !hasActiveFilters ? 'subdued' : 'accent',
|
|
73
|
+
role: "marquee" // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/marquee_role
|
|
74
|
+
|
|
73
75
|
}, badgeCount);
|
|
74
76
|
|
|
75
77
|
var dataText;
|
|
@@ -16,9 +16,9 @@ export var EuiImageCaption = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
16
16
|
var euiTheme = useEuiTheme();
|
|
17
17
|
var styles = euiImageCaptionStyles(euiTheme);
|
|
18
18
|
var cssStyles = [styles.euiImageCaption, isOnOverlayMask && styles.isOnOverlayMask];
|
|
19
|
-
return ___EmotionJSX("figcaption", {
|
|
19
|
+
return caption ? ___EmotionJSX("figcaption", {
|
|
20
20
|
ref: ref,
|
|
21
21
|
css: cssStyles
|
|
22
|
-
}, caption);
|
|
22
|
+
}, caption) : null;
|
|
23
23
|
});
|
|
24
24
|
EuiImageCaption.displayName = 'EuiImageCaption';
|
|
@@ -23,7 +23,7 @@ export var euiImageWrapperStyles = function euiImageWrapperStyles(euiThemeContex
|
|
|
23
23
|
var euiTheme = euiThemeContext.euiTheme;
|
|
24
24
|
return {
|
|
25
25
|
// Base
|
|
26
|
-
euiImageWrapper: /*#__PURE__*/css("display:
|
|
26
|
+
euiImageWrapper: /*#__PURE__*/css("display:inline-block;", logicalCSS('max-width', '100%'), " ", logicalTextAlignCSS('center'), ";line-height:0;flex-shrink:0;;label:euiImageWrapper;"),
|
|
27
27
|
allowFullScreen: _ref,
|
|
28
28
|
// Margins
|
|
29
29
|
s: /*#__PURE__*/css("margin:", euiTheme.size.s, ";;label:s;"),
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
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";
|
|
10
4
|
var _excluded = ["button"];
|
|
11
5
|
|
|
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
|
-
|
|
16
6
|
/*
|
|
17
7
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
18
8
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -20,7 +10,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
20
10
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
21
11
|
* Side Public License, v 1.
|
|
22
12
|
*/
|
|
23
|
-
import React, {
|
|
13
|
+
import React, { useState, useEffect } from 'react';
|
|
24
14
|
import { EuiPopover } from './popover';
|
|
25
15
|
import { EuiPortal } from '../portal';
|
|
26
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
@@ -30,74 +20,43 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
30
20
|
* then the button element is moved into the popover dom.
|
|
31
21
|
* On unmount, the button is moved back to its original location.
|
|
32
22
|
*/
|
|
33
|
-
export var EuiWrappingPopover =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
export var EuiWrappingPopover = function EuiWrappingPopover(_ref) {
|
|
24
|
+
var button = _ref.button,
|
|
25
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
|
|
27
|
+
var _useState = useState(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
anchor = _useState2[0],
|
|
30
|
+
setAnchor = _useState2[1];
|
|
31
|
+
|
|
32
|
+
var _useState3 = useState(null),
|
|
33
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
+
portal = _useState4[0],
|
|
35
|
+
setPortal = _useState4[1];
|
|
36
|
+
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
if (anchor) {
|
|
39
|
+
// move the button into the popover DOM
|
|
40
|
+
anchor.insertAdjacentElement('beforebegin', button);
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
}
|
|
43
|
+
return function () {
|
|
44
|
+
if (portal) {
|
|
45
|
+
// move the button back out of the popover DOM
|
|
46
|
+
portal.insertAdjacentElement('beforebegin', button);
|
|
78
47
|
}
|
|
48
|
+
};
|
|
49
|
+
}, [anchor, button, portal]);
|
|
50
|
+
return ___EmotionJSX(EuiPortal, {
|
|
51
|
+
portalRef: setPortal,
|
|
52
|
+
insert: {
|
|
53
|
+
sibling: button,
|
|
54
|
+
position: 'after'
|
|
79
55
|
}
|
|
80
|
-
}, {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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);
|
|
56
|
+
}, ___EmotionJSX(EuiPopover, _extends({}, rest, {
|
|
57
|
+
button: ___EmotionJSX("div", {
|
|
58
|
+
ref: setAnchor,
|
|
59
|
+
className: "euiWrappingPopover__anchor"
|
|
60
|
+
})
|
|
61
|
+
})));
|
|
62
|
+
};
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import
|
|
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; } }
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
12
2
|
|
|
13
3
|
/*
|
|
14
4
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -22,71 +12,54 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
12
|
* NOTE: We can't test this component because Enzyme doesn't support rendering
|
|
23
13
|
* into portals.
|
|
24
14
|
*/
|
|
25
|
-
import {
|
|
15
|
+
import { useState, useEffect } from 'react';
|
|
26
16
|
import { createPortal } from 'react-dom';
|
|
27
17
|
import { keysOf } from '../common';
|
|
18
|
+
import { useUpdateEffect } from '../../services';
|
|
28
19
|
export var insertPositions = {
|
|
29
20
|
after: 'afterend',
|
|
30
21
|
before: 'beforebegin'
|
|
31
22
|
};
|
|
32
23
|
export var INSERT_POSITIONS = keysOf(insertPositions);
|
|
33
|
-
export var EuiPortal =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
export var EuiPortal = function EuiPortal(_ref) {
|
|
25
|
+
var insert = _ref.insert,
|
|
26
|
+
portalRef = _ref.portalRef,
|
|
27
|
+
children = _ref.children;
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
var _useState = useState(null),
|
|
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
|
|
40
33
|
|
|
41
|
-
_classCallCheck(this, EuiPortal);
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
var _ref2 = insert || {},
|
|
36
|
+
sibling = _ref2.sibling,
|
|
37
|
+
position = _ref2.position;
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
var portalNode = document.createElement('div');
|
|
41
|
+
portalNode.dataset.euiportal = 'true';
|
|
42
|
+
setPortalNode(portalNode);
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
_this.portalNode = document.createElement('div');
|
|
49
|
-
|
|
50
|
-
if (insert == null) {
|
|
44
|
+
if (sibling == null || position == null) {
|
|
51
45
|
// no insertion defined, append to body
|
|
52
|
-
document.body.appendChild(
|
|
46
|
+
document.body.appendChild(portalNode);
|
|
53
47
|
} else {
|
|
54
48
|
// inserting before or after an element
|
|
55
|
-
|
|
56
|
-
position = insert.position;
|
|
57
|
-
sibling.insertAdjacentElement(insertPositions[position], _this.portalNode);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return _this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
_createClass(EuiPortal, [{
|
|
64
|
-
key: "componentDidMount",
|
|
65
|
-
value: function componentDidMount() {
|
|
66
|
-
this.updatePortalRef(this.portalNode);
|
|
49
|
+
sibling.insertAdjacentElement(insertPositions[position], portalNode);
|
|
67
50
|
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "componentWillUnmount",
|
|
70
|
-
value: function componentWillUnmount() {
|
|
71
|
-
if (this.portalNode.parentNode) {
|
|
72
|
-
this.portalNode.parentNode.removeChild(this.portalNode);
|
|
73
|
-
}
|
|
74
51
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
key: "updatePortalRef",
|
|
79
|
-
value: function updatePortalRef(ref) {
|
|
80
|
-
if (this.props.portalRef) {
|
|
81
|
-
this.props.portalRef(ref);
|
|
52
|
+
return function () {
|
|
53
|
+
if (portalNode && portalNode.parentNode) {
|
|
54
|
+
portalNode.parentNode.removeChild(portalNode);
|
|
82
55
|
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
}
|
|
56
|
+
};
|
|
57
|
+
}, [sibling, position]);
|
|
58
|
+
useUpdateEffect(function () {
|
|
59
|
+
portalRef === null || portalRef === void 0 ? void 0 : portalRef(portalNode);
|
|
60
|
+
return function () {
|
|
61
|
+
portalRef === null || portalRef === void 0 ? void 0 : portalRef(null);
|
|
62
|
+
};
|
|
63
|
+
}, [portalNode, portalRef]);
|
|
64
|
+
return portalNode == null ? null : /*#__PURE__*/createPortal(children, portalNode);
|
|
65
|
+
};
|
|
@@ -86,7 +86,9 @@ var EuiFilterButton = function EuiFilterButton(_ref) {
|
|
|
86
86
|
var badgeContent = showBadge && (0, _react2.jsx)(_notification_badge.EuiNotificationBadge, {
|
|
87
87
|
className: "euiFilterButton__notification",
|
|
88
88
|
"aria-label": hasActiveFilters ? activeBadgeLabel : availableBadgeLabel,
|
|
89
|
-
color: isDisabled || !hasActiveFilters ? 'subdued' : 'accent'
|
|
89
|
+
color: isDisabled || !hasActiveFilters ? 'subdued' : 'accent',
|
|
90
|
+
role: "marquee" // https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/marquee_role
|
|
91
|
+
|
|
90
92
|
}, badgeCount);
|
|
91
93
|
var dataText;
|
|
92
94
|
|
|
@@ -33,10 +33,10 @@ var EuiImageCaption = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
33
33
|
var euiTheme = (0, _services.useEuiTheme)();
|
|
34
34
|
var styles = (0, _image_caption.euiImageCaptionStyles)(euiTheme);
|
|
35
35
|
var cssStyles = [styles.euiImageCaption, isOnOverlayMask && styles.isOnOverlayMask];
|
|
36
|
-
return (0, _react2.jsx)("figcaption", {
|
|
36
|
+
return caption ? (0, _react2.jsx)("figcaption", {
|
|
37
37
|
ref: ref,
|
|
38
38
|
css: cssStyles
|
|
39
|
-
}, caption);
|
|
39
|
+
}, caption) : null;
|
|
40
40
|
});
|
|
41
41
|
exports.EuiImageCaption = EuiImageCaption;
|
|
42
42
|
EuiImageCaption.displayName = 'EuiImageCaption';
|
|
@@ -24,7 +24,7 @@ var euiImageWrapperStyles = function euiImageWrapperStyles(euiThemeContext) {
|
|
|
24
24
|
var euiTheme = euiThemeContext.euiTheme;
|
|
25
25
|
return {
|
|
26
26
|
// Base
|
|
27
|
-
euiImageWrapper: /*#__PURE__*/(0, _react.css)("display:
|
|
27
|
+
euiImageWrapper: /*#__PURE__*/(0, _react.css)("display:inline-block;", (0, _global_styling.logicalCSS)('max-width', '100%'), " ", (0, _global_styling.logicalTextAlignCSS)('center'), ";line-height:0;flex-shrink:0;;label:euiImageWrapper;"),
|
|
28
28
|
allowFullScreen: _ref,
|
|
29
29
|
// Margins
|
|
30
30
|
s: /*#__PURE__*/(0, _react.css)("margin:", euiTheme.size.s, ";;label:s;"),
|
|
@@ -11,21 +11,9 @@ exports.EuiWrappingPopover = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var
|
|
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"));
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
23
15
|
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
-
|
|
28
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
29
17
|
|
|
30
18
|
var _react = _interopRequireWildcard(require("react"));
|
|
31
19
|
|
|
@@ -41,78 +29,50 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
41
29
|
|
|
42
30
|
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; }
|
|
43
31
|
|
|
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
|
-
|
|
48
32
|
/**
|
|
49
33
|
* Injects the EuiPopover next to the button via EuiPortal
|
|
50
34
|
* then the button element is moved into the popover dom.
|
|
51
35
|
* On unmount, the button is moved back to its original location.
|
|
52
36
|
*/
|
|
53
|
-
var EuiWrappingPopover =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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);
|
|
65
55
|
}
|
|
66
56
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
}
|
|
57
|
+
return function () {
|
|
58
|
+
if (portal) {
|
|
59
|
+
// move the button back out of the popover DOM
|
|
60
|
+
portal.insertAdjacentElement('beforebegin', button);
|
|
93
61
|
}
|
|
62
|
+
};
|
|
63
|
+
}, [anchor, button, portal]);
|
|
64
|
+
return (0, _react2.jsx)(_portal.EuiPortal, {
|
|
65
|
+
portalRef: setPortal,
|
|
66
|
+
insert: {
|
|
67
|
+
sibling: button,
|
|
68
|
+
position: 'after'
|
|
94
69
|
}
|
|
95
|
-
}, {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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);
|
|
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
|
+
};
|
|
117
77
|
|
|
118
78
|
exports.EuiWrappingPopover = EuiWrappingPopover;
|