@elastic/eui 116.0.0 → 116.1.0-snapshot.1779110362015
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/accordion/accordion.js +95 -134
- package/es/components/basic_table/basic_table.js +6 -0
- package/es/components/basic_table/in_memory_table.js +6 -0
- package/es/components/color_picker/color_picker_swatch.js +4 -0
- package/es/components/context_menu/context_menu_panel.js +2 -2
- package/es/components/copy/copy.js +36 -13
- package/es/components/datagrid/body/cell/data_grid_cell_popover.js +10 -7
- package/es/components/datagrid/data_grid.styles.js +6 -5
- package/es/components/focus_trap/focus_trap.js +110 -177
- package/es/components/observer/mutation_observer/mutation_observer.js +32 -35
- package/es/components/observer/resize_observer/resize_observer.js +46 -60
- package/es/components/observer/use_observer.js +62 -0
- package/es/components/table/table_header_cell.js +4 -0
- package/es/components/tool_tip/icon_tip.js +4 -0
- package/es/components/tool_tip/tool_tip.js +8 -2
- package/eui.d.ts +26 -69
- package/lib/components/accordion/accordion.js +102 -139
- package/lib/components/basic_table/basic_table.js +6 -0
- package/lib/components/basic_table/in_memory_table.js +6 -0
- package/lib/components/color_picker/color_picker_swatch.js +4 -0
- package/lib/components/context_menu/context_menu_panel.js +2 -2
- package/lib/components/copy/copy.js +35 -12
- package/lib/components/datagrid/body/cell/data_grid_cell_popover.js +10 -7
- package/lib/components/datagrid/data_grid.styles.js +6 -5
- package/lib/components/focus_trap/focus_trap.js +117 -183
- package/lib/components/observer/mutation_observer/mutation_observer.js +32 -34
- package/lib/components/observer/resize_observer/resize_observer.js +48 -61
- package/lib/components/observer/use_observer.js +68 -0
- package/lib/components/table/table_header_cell.js +4 -0
- package/lib/components/tool_tip/icon_tip.js +4 -0
- package/lib/components/tool_tip/tool_tip.js +8 -2
- package/optimize/es/components/accordion/accordion.js +88 -126
- package/optimize/es/components/context_menu/context_menu_panel.js +2 -2
- package/optimize/es/components/copy/copy.js +36 -13
- package/optimize/es/components/datagrid/body/cell/data_grid_cell_popover.js +10 -7
- package/optimize/es/components/datagrid/data_grid.styles.js +6 -5
- package/optimize/es/components/focus_trap/focus_trap.js +103 -122
- package/optimize/es/components/observer/mutation_observer/mutation_observer.js +23 -32
- package/optimize/es/components/observer/resize_observer/resize_observer.js +38 -54
- package/optimize/es/components/observer/use_observer.js +62 -0
- package/optimize/es/components/tool_tip/tool_tip.js +4 -2
- package/optimize/lib/components/accordion/accordion.js +90 -127
- package/optimize/lib/components/context_menu/context_menu_panel.js +2 -2
- package/optimize/lib/components/copy/copy.js +35 -12
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell_popover.js +10 -7
- package/optimize/lib/components/datagrid/data_grid.styles.js +6 -5
- package/optimize/lib/components/focus_trap/focus_trap.js +106 -124
- package/optimize/lib/components/observer/mutation_observer/mutation_observer.js +23 -32
- package/optimize/lib/components/observer/resize_observer/resize_observer.js +40 -54
- package/optimize/lib/components/observer/use_observer.js +68 -0
- package/optimize/lib/components/tool_tip/tool_tip.js +4 -2
- package/package.json +4 -3
- package/test-env/components/accordion/accordion.js +92 -129
- package/test-env/components/basic_table/basic_table.js +6 -0
- package/test-env/components/basic_table/in_memory_table.js +6 -0
- package/test-env/components/color_picker/color_picker_swatch.js +4 -0
- package/test-env/components/context_menu/context_menu_panel.js +2 -2
- package/test-env/components/copy/copy.js +35 -12
- package/test-env/components/datagrid/body/cell/data_grid_cell_popover.js +10 -7
- package/test-env/components/datagrid/data_grid.styles.js +6 -5
- package/test-env/components/observer/mutation_observer/mutation_observer.js +32 -32
- package/test-env/components/observer/use_observer.js +68 -0
- package/test-env/components/table/table_header_cell.js +4 -0
- package/test-env/components/tool_tip/icon_tip.js +4 -0
- package/test-env/components/tool_tip/tool_tip.js +8 -2
- package/es/components/observer/observer.js +0 -75
- package/lib/components/observer/observer.js +0 -79
- package/optimize/es/components/observer/observer.js +0 -69
- package/optimize/lib/components/observer/observer.js +0 -74
- package/test-env/components/observer/observer.js +0 -74
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
var _excluded = ["children", "clickOutsideDisables", "disabled", "returnFocus", "noIsolation", "scrollLock", "gapMode"];
|
|
2
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["children", "disabled", "clickOutsideDisables", "returnFocus", "noIsolation", "crossFrame", "scrollLock", "initialFocus", "gapMode", "closeOnMouseup", "onClickOutside"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
6
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
7
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
8
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
10
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
11
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
12
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
13
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
15
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
16
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
17
5
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
+
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."); }
|
|
10
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
20
16
|
/*
|
|
21
17
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
18
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -25,183 +21,120 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
25
21
|
* Side Public License, v 1.
|
|
26
22
|
*/
|
|
27
23
|
|
|
28
|
-
import React, {
|
|
24
|
+
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
29
25
|
import PropTypes from "prop-types";
|
|
30
26
|
import { FocusOn } from 'react-focus-on';
|
|
31
27
|
import { RemoveScrollBar } from 'react-remove-scroll-bar';
|
|
32
|
-
import { findElementBySelectorOrRef } from '../../services';
|
|
28
|
+
import { findElementBySelectorOrRef, useUpdateEffect } from '../../services';
|
|
33
29
|
import { usePropsWithComponentDefaults } from '../provider/component_defaults';
|
|
34
30
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
35
|
-
export var EuiFocusTrap = function EuiFocusTrap(
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
*/
|
|
83
|
-
noIsolation: PropTypes.any,
|
|
84
|
-
/**
|
|
85
|
-
* @default true
|
|
86
|
-
*/
|
|
87
|
-
returnFocus: PropTypes.any
|
|
88
|
-
};
|
|
89
|
-
var EuiFocusTrapClass = /*#__PURE__*/function (_Component) {
|
|
90
|
-
function EuiFocusTrapClass() {
|
|
91
|
-
var _this;
|
|
92
|
-
_classCallCheck(this, EuiFocusTrapClass);
|
|
93
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
94
|
-
args[_key] = arguments[_key];
|
|
31
|
+
export var EuiFocusTrap = function EuiFocusTrap(_props) {
|
|
32
|
+
var props = usePropsWithComponentDefaults('EuiFocusTrap', _props);
|
|
33
|
+
var children = props.children,
|
|
34
|
+
disabled = props.disabled,
|
|
35
|
+
_props$clickOutsideDi = props.clickOutsideDisables,
|
|
36
|
+
clickOutsideDisables = _props$clickOutsideDi === void 0 ? false : _props$clickOutsideDi,
|
|
37
|
+
_props$returnFocus = props.returnFocus,
|
|
38
|
+
returnFocus = _props$returnFocus === void 0 ? true : _props$returnFocus,
|
|
39
|
+
_props$noIsolation = props.noIsolation,
|
|
40
|
+
noIsolation = _props$noIsolation === void 0 ? true : _props$noIsolation,
|
|
41
|
+
_props$crossFrame = props.crossFrame,
|
|
42
|
+
crossFrame = _props$crossFrame === void 0 ? false : _props$crossFrame,
|
|
43
|
+
_props$scrollLock = props.scrollLock,
|
|
44
|
+
scrollLock = _props$scrollLock === void 0 ? false : _props$scrollLock,
|
|
45
|
+
initialFocus = props.initialFocus,
|
|
46
|
+
_props$gapMode = props.gapMode,
|
|
47
|
+
gapMode = _props$gapMode === void 0 ? 'padding' : _props$gapMode,
|
|
48
|
+
closeOnMouseup = props.closeOnMouseup,
|
|
49
|
+
onClickOutside = props.onClickOutside,
|
|
50
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
51
|
+
var _useState = useState(false),
|
|
52
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
+
hasBeenDisabledByClick = _useState2[0],
|
|
54
|
+
setHasBeenDisabledByClick = _useState2[1];
|
|
55
|
+
var isDisabled = disabled || hasBeenDisabledByClick;
|
|
56
|
+
|
|
57
|
+
// Programmatically sets focus on a nested DOM node; optional
|
|
58
|
+
var setInitialFocus = function setInitialFocus(initialFocus) {
|
|
59
|
+
if (!initialFocus) return;
|
|
60
|
+
var node = findElementBySelectorOrRef(initialFocus);
|
|
61
|
+
if (!node) return;
|
|
62
|
+
// `data-autofocus` is part of the 'react-focus-on' API
|
|
63
|
+
node.setAttribute('data-autofocus', 'true');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Stabilize the onClickOutside callback
|
|
67
|
+
var onClickOutsideRef = useRef(onClickOutside);
|
|
68
|
+
onClickOutsideRef.current = onClickOutside;
|
|
69
|
+
|
|
70
|
+
// We use a ref to store the listener to prevent circular dependencies
|
|
71
|
+
// while still ensuring the listeners can properly be cleaned up
|
|
72
|
+
var mouseupListenerRef = useRef(null);
|
|
73
|
+
var removeMouseupListener = useCallback(function () {
|
|
74
|
+
if (mouseupListenerRef.current) {
|
|
75
|
+
document.removeEventListener('mouseup', mouseupListenerRef.current);
|
|
76
|
+
document.removeEventListener('touchend', mouseupListenerRef.current);
|
|
77
|
+
mouseupListenerRef.current = null;
|
|
95
78
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
_defineProperty(_this, "preventFocusExit", false);
|
|
102
|
-
// Programmatically sets focus on a nested DOM node; optional
|
|
103
|
-
_defineProperty(_this, "setInitialFocus", function (initialFocus) {
|
|
104
|
-
if (!initialFocus) return;
|
|
105
|
-
var node = findElementBySelectorOrRef(initialFocus);
|
|
106
|
-
if (!node) return;
|
|
107
|
-
// `data-autofocus` is part of the 'react-focus-on' API
|
|
108
|
-
node.setAttribute('data-autofocus', 'true');
|
|
109
|
-
});
|
|
110
|
-
_defineProperty(_this, "onMouseupOutside", function (e) {
|
|
111
|
-
_this.removeMouseupListener();
|
|
79
|
+
}, []);
|
|
80
|
+
var addMouseupListener = useCallback(function () {
|
|
81
|
+
removeMouseupListener();
|
|
82
|
+
mouseupListenerRef.current = function (e) {
|
|
83
|
+
removeMouseupListener();
|
|
112
84
|
// Timeout gives precedence to the consumer to initiate close if it has toggle behavior.
|
|
113
85
|
// Otherwise this event may occur first and the consumer toggle will reopen the flyout.
|
|
114
86
|
setTimeout(function () {
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
87
|
+
var _onClickOutsideRef$cu;
|
|
88
|
+
return (_onClickOutsideRef$cu = onClickOutsideRef.current) === null || _onClickOutsideRef$cu === void 0 ? void 0 : _onClickOutsideRef$cu.call(onClickOutsideRef, e);
|
|
117
89
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
document.removeEventListener('touchend', _this.onMouseupOutside);
|
|
126
|
-
});
|
|
127
|
-
_defineProperty(_this, "handleOutsideClick", function (event) {
|
|
128
|
-
var _this$props2 = _this.props,
|
|
129
|
-
onClickOutside = _this$props2.onClickOutside,
|
|
130
|
-
clickOutsideDisables = _this$props2.clickOutsideDisables,
|
|
131
|
-
closeOnMouseup = _this$props2.closeOnMouseup;
|
|
132
|
-
if (clickOutsideDisables) {
|
|
133
|
-
_this.setState({
|
|
134
|
-
hasBeenDisabledByClick: true
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
if (onClickOutside) {
|
|
138
|
-
closeOnMouseup ? _this.addMouseupListener() : onClickOutside(event);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
return _this;
|
|
142
|
-
}
|
|
143
|
-
_inherits(EuiFocusTrapClass, _Component);
|
|
144
|
-
return _createClass(EuiFocusTrapClass, [{
|
|
145
|
-
key: "componentDidMount",
|
|
146
|
-
value: function componentDidMount() {
|
|
147
|
-
this.setInitialFocus(this.props.initialFocus);
|
|
90
|
+
};
|
|
91
|
+
document.addEventListener('mouseup', mouseupListenerRef.current);
|
|
92
|
+
document.addEventListener('touchend', mouseupListenerRef.current);
|
|
93
|
+
}, [removeMouseupListener]);
|
|
94
|
+
var handleOutsideClick = useCallback(function (event) {
|
|
95
|
+
if (clickOutsideDisables) {
|
|
96
|
+
setHasBeenDisabledByClick(true);
|
|
148
97
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
value: function componentDidUpdate(prevProps) {
|
|
152
|
-
if (prevProps.disabled === true && this.props.disabled === false) {
|
|
153
|
-
this.setState({
|
|
154
|
-
hasBeenDisabledByClick: false
|
|
155
|
-
});
|
|
156
|
-
}
|
|
98
|
+
if (onClickOutside) {
|
|
99
|
+
closeOnMouseup ? addMouseupListener() : onClickOutside(event);
|
|
157
100
|
}
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var _this$props3 = this.props,
|
|
167
|
-
children = _this$props3.children,
|
|
168
|
-
clickOutsideDisables = _this$props3.clickOutsideDisables,
|
|
169
|
-
disabled = _this$props3.disabled,
|
|
170
|
-
returnFocus = _this$props3.returnFocus,
|
|
171
|
-
noIsolation = _this$props3.noIsolation,
|
|
172
|
-
scrollLock = _this$props3.scrollLock,
|
|
173
|
-
gapMode = _this$props3.gapMode,
|
|
174
|
-
rest = _objectWithoutProperties(_this$props3, _excluded);
|
|
175
|
-
var isDisabled = disabled || this.state.hasBeenDisabledByClick;
|
|
176
|
-
var focusOnProps = _objectSpread(_objectSpread({
|
|
177
|
-
returnFocus: returnFocus,
|
|
178
|
-
noIsolation: noIsolation,
|
|
179
|
-
enabled: !isDisabled
|
|
180
|
-
}, rest), {}, {
|
|
181
|
-
onClickOutside: this.handleOutsideClick,
|
|
182
|
-
/**
|
|
183
|
-
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
184
|
-
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
185
|
-
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
186
|
-
*/
|
|
187
|
-
scrollLock: false
|
|
188
|
-
});
|
|
189
|
-
return ___EmotionJSX(FocusOn, focusOnProps, children, !isDisabled && scrollLock && ___EmotionJSX(RemoveScrollBar, {
|
|
190
|
-
gapMode: gapMode
|
|
191
|
-
}));
|
|
101
|
+
}, [clickOutsideDisables, closeOnMouseup, onClickOutside, addMouseupListener]);
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
setInitialFocus(initialFocus);
|
|
104
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
+
}, []);
|
|
106
|
+
useUpdateEffect(function () {
|
|
107
|
+
if (!disabled) {
|
|
108
|
+
setHasBeenDisabledByClick(false);
|
|
192
109
|
}
|
|
193
|
-
}]);
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
110
|
+
}, [disabled]);
|
|
111
|
+
|
|
112
|
+
// listener cleanup on unmount
|
|
113
|
+
useEffect(function () {
|
|
114
|
+
return function () {
|
|
115
|
+
return removeMouseupListener();
|
|
116
|
+
};
|
|
117
|
+
}, [removeMouseupListener]);
|
|
118
|
+
var focusOnProps = _objectSpread(_objectSpread({
|
|
119
|
+
returnFocus: returnFocus,
|
|
120
|
+
noIsolation: noIsolation,
|
|
121
|
+
initialFocus: initialFocus,
|
|
122
|
+
crossFrame: crossFrame,
|
|
123
|
+
enabled: !isDisabled
|
|
124
|
+
}, rest), {}, {
|
|
125
|
+
onClickOutside: handleOutsideClick,
|
|
126
|
+
/**
|
|
127
|
+
* `scrollLock` should always be unset on FocusOn, as it can prevent scrolling on
|
|
128
|
+
* portals (i.e. popovers, comboboxes, dropdown menus, etc.) within modals & flyouts
|
|
129
|
+
* @see https://github.com/theKashey/react-focus-on/issues/49
|
|
130
|
+
*/
|
|
131
|
+
scrollLock: false
|
|
132
|
+
});
|
|
133
|
+
return ___EmotionJSX(FocusOn, focusOnProps, children, !isDisabled && scrollLock && ___EmotionJSX(RemoveScrollBar, {
|
|
134
|
+
gapMode: gapMode
|
|
135
|
+
}));
|
|
136
|
+
};
|
|
137
|
+
EuiFocusTrap.propTypes = {
|
|
205
138
|
// For some reason, Storybook doesn't register these props if they're Pick<>'d
|
|
206
139
|
className: PropTypes.string,
|
|
207
140
|
css: PropTypes.any,
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
5
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
6
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
7
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
9
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
10
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
12
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
13
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
14
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -22,31 +12,38 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
22
12
|
* Side Public License, v 1.
|
|
23
13
|
*/
|
|
24
14
|
|
|
25
|
-
import { useEffect } from 'react';
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
15
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
16
|
+
import PropTypes from "prop-types";
|
|
17
|
+
import { useObserver } from '../use_observer';
|
|
18
|
+
export var EuiMutationObserver = function EuiMutationObserver(_ref) {
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
onMutation = _ref.onMutation,
|
|
21
|
+
observerOptions = _ref.observerOptions;
|
|
22
|
+
// Store onMutation and observerOptions in refs so the observer callback
|
|
23
|
+
// and setup always use the latest prop values without needing to
|
|
24
|
+
// re-subscribe (which would cause the ref callback to cycle)
|
|
25
|
+
var onMutationRef = useRef(onMutation);
|
|
26
|
+
onMutationRef.current = onMutation;
|
|
27
|
+
var observerOptionsRef = useRef(observerOptions);
|
|
28
|
+
observerOptionsRef.current = observerOptions;
|
|
29
|
+
var mutationCallback = useCallback(function (records, observer) {
|
|
30
|
+
onMutationRef.current(records, observer);
|
|
31
|
+
}, []);
|
|
32
|
+
var beginObserve = useCallback(function (node) {
|
|
33
|
+
return makeMutationObserver(node, observerOptionsRef.current, mutationCallback);
|
|
34
|
+
}, [mutationCallback]);
|
|
35
|
+
var updateChildNode = useObserver(beginObserve, 'EuiMutationObserver');
|
|
36
|
+
return children(updateChildNode);
|
|
37
|
+
};
|
|
38
|
+
EuiMutationObserver.propTypes = {
|
|
39
|
+
/**
|
|
40
|
+
* ReactNode to render as this component's content
|
|
41
|
+
*/
|
|
42
|
+
children: PropTypes.func.isRequired,
|
|
43
|
+
onMutation: PropTypes.any.isRequired,
|
|
44
|
+
observerOptions: PropTypes.any
|
|
45
|
+
};
|
|
46
|
+
EuiMutationObserver.displayName = 'EuiMutationObserver';
|
|
50
47
|
var makeMutationObserver = function makeMutationObserver(node, _observerOptions, callback) {
|
|
51
48
|
// The MutationObserver polyfill used in Kibana (for Jest) implements
|
|
52
49
|
// an older spec in which specifying `attributeOldValue` or `attributeFilter`
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
1
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
2
|
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."); }
|
|
4
3
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
13
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
14
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
16
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
17
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
18
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
21
7
|
/*
|
|
22
8
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
23
9
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -27,52 +13,52 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
13
|
*/
|
|
28
14
|
|
|
29
15
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
30
|
-
import
|
|
16
|
+
import PropTypes from "prop-types";
|
|
17
|
+
import { useObserver } from '../use_observer';
|
|
31
18
|
export var hasResizeObserver = typeof window !== 'undefined' && typeof window.ResizeObserver !== 'undefined';
|
|
32
|
-
export var EuiResizeObserver =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
entry = _ref2[0];
|
|
48
|
-
var _entry$borderBoxSize$ = entry.borderBoxSize[0],
|
|
49
|
-
width = _entry$borderBoxSize$.inlineSize,
|
|
50
|
-
height = _entry$borderBoxSize$.blockSize;
|
|
19
|
+
export var EuiResizeObserver = function EuiResizeObserver(_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
onResize = _ref.onResize;
|
|
22
|
+
var onResizeRef = useRef(onResize);
|
|
23
|
+
onResizeRef.current = onResize;
|
|
24
|
+
var sizeRef = useRef({
|
|
25
|
+
height: 0,
|
|
26
|
+
width: 0
|
|
27
|
+
});
|
|
28
|
+
var resizeCallback = useCallback(function (_ref2) {
|
|
29
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
30
|
+
entry = _ref3[0];
|
|
31
|
+
var _entry$borderBoxSize$ = entry.borderBoxSize[0],
|
|
32
|
+
width = _entry$borderBoxSize$.inlineSize,
|
|
33
|
+
height = _entry$borderBoxSize$.blockSize;
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
_defineProperty(_this, "beginObserve", function () {
|
|
66
|
-
// The superclass checks that childNode is not null before invoking
|
|
67
|
-
// beginObserve()
|
|
68
|
-
var childNode = _this.childNode;
|
|
69
|
-
_this.observer = makeResizeObserver(childNode, _this.onResize);
|
|
35
|
+
// Check for actual resize event
|
|
36
|
+
if (sizeRef.current.height === height && sizeRef.current.width === width) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
sizeRef.current = {
|
|
40
|
+
height: height,
|
|
41
|
+
width: width
|
|
42
|
+
};
|
|
43
|
+
onResizeRef.current({
|
|
44
|
+
height: height,
|
|
45
|
+
width: width
|
|
70
46
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
47
|
+
}, []);
|
|
48
|
+
var beginObserve = useCallback(function (node) {
|
|
49
|
+
return makeResizeObserver(node, resizeCallback);
|
|
50
|
+
}, [resizeCallback]);
|
|
51
|
+
var updateChildNode = useObserver(beginObserve, 'EuiResizeObserver');
|
|
52
|
+
return children(updateChildNode);
|
|
53
|
+
};
|
|
54
|
+
EuiResizeObserver.propTypes = {
|
|
55
|
+
/**
|
|
56
|
+
* ReactNode to render as this component's content
|
|
57
|
+
*/
|
|
58
|
+
children: PropTypes.func.isRequired,
|
|
59
|
+
onResize: PropTypes.func.isRequired
|
|
60
|
+
};
|
|
61
|
+
EuiResizeObserver.displayName = 'EuiResizeObserver';
|
|
76
62
|
var makeResizeObserver = function makeResizeObserver(node, callback) {
|
|
77
63
|
var observer;
|
|
78
64
|
if (hasResizeObserver) {
|
|
@@ -103,9 +89,9 @@ export var useResizeObserver = function useResizeObserver(container, dimension)
|
|
|
103
89
|
}, [dimension]);
|
|
104
90
|
useEffect(function () {
|
|
105
91
|
if (container != null) {
|
|
106
|
-
var observer = makeResizeObserver(container, function (
|
|
107
|
-
var
|
|
108
|
-
entry =
|
|
92
|
+
var observer = makeResizeObserver(container, function (_ref4) {
|
|
93
|
+
var _ref5 = _slicedToArray(_ref4, 1),
|
|
94
|
+
entry = _ref5[0];
|
|
109
95
|
var _entry$borderBoxSize$2 = entry.borderBoxSize[0],
|
|
110
96
|
inlineSize = _entry$borderBoxSize$2.inlineSize,
|
|
111
97
|
blockSize = _entry$borderBoxSize$2.blockSize;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
4
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
5
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
6
|
+
* Side Public License, v 1.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
10
|
+
/**
|
|
11
|
+
* A shared custom hook that provides a pattern for observing DOM nodes
|
|
12
|
+
* via browser observer APIs. Used by `EuiResizeObserver` and `EuiMutationObserver`.
|
|
13
|
+
*
|
|
14
|
+
* @param beginObserve - A callback that receives the target DOM element and should
|
|
15
|
+
* create and return the observer instance (e.g., `ResizeObserver`).
|
|
16
|
+
* @param componentName - Optional name used in error messages when no ref is
|
|
17
|
+
* attached on mount, mirroring the guard previously in `EuiObserver`.
|
|
18
|
+
*/
|
|
19
|
+
export var useObserver = function useObserver(beginObserve) {
|
|
20
|
+
var componentName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'useObserver';
|
|
21
|
+
var childNodeRef = useRef(null);
|
|
22
|
+
var observerRef = useRef(null);
|
|
23
|
+
|
|
24
|
+
// Store beginObserve in a ref so the ref callback doesn't cycle
|
|
25
|
+
var beginObserveRef = useRef(beginObserve);
|
|
26
|
+
beginObserveRef.current = beginObserve;
|
|
27
|
+
|
|
28
|
+
// Store componentName in a ref so the mount-only effect can access the
|
|
29
|
+
// latest value without needing it as a dependency.
|
|
30
|
+
var componentNameRef = useRef(componentName);
|
|
31
|
+
componentNameRef.current = componentName;
|
|
32
|
+
|
|
33
|
+
// Guard: throw if the ref callback was never called (no element attached),
|
|
34
|
+
// mirroring the check previously in EuiObserver.componentDidMount.
|
|
35
|
+
// Also cleans up the observer on unmount.
|
|
36
|
+
// Empty deps: run only on mount/unmount — componentName is only used for the
|
|
37
|
+
// error message and changing it must not disconnect/re-connect the observer.
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (childNodeRef.current == null) {
|
|
40
|
+
throw new Error("".concat(componentNameRef.current, " did not receive a ref"));
|
|
41
|
+
}
|
|
42
|
+
return function () {
|
|
43
|
+
var _observerRef$current;
|
|
44
|
+
(_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 || _observerRef$current.disconnect();
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
var updateChildNode = useCallback(function (ref) {
|
|
48
|
+
if (childNodeRef.current === ref) return; // node hasn't changed
|
|
49
|
+
|
|
50
|
+
// if there's an existing observer disconnect it
|
|
51
|
+
if (observerRef.current != null) {
|
|
52
|
+
observerRef.current.disconnect();
|
|
53
|
+
observerRef.current = null;
|
|
54
|
+
}
|
|
55
|
+
childNodeRef.current = ref;
|
|
56
|
+
if (childNodeRef.current != null) {
|
|
57
|
+
var _beginObserveRef$curr;
|
|
58
|
+
observerRef.current = (_beginObserveRef$curr = beginObserveRef.current(childNodeRef.current)) !== null && _beginObserveRef$curr !== void 0 ? _beginObserveRef$curr : null;
|
|
59
|
+
}
|
|
60
|
+
}, []);
|
|
61
|
+
return updateChildNode;
|
|
62
|
+
};
|
|
@@ -237,6 +237,10 @@ EuiTableHeaderCell.propTypes = {
|
|
|
237
237
|
* hidden.
|
|
238
238
|
*/
|
|
239
239
|
onMouseOut: PropTypes.func,
|
|
240
|
+
/**
|
|
241
|
+
* If supplied, called when the trigger loses focus.
|
|
242
|
+
*/
|
|
243
|
+
onBlur: PropTypes.func,
|
|
240
244
|
/**
|
|
241
245
|
* Offset in pixels from the anchor. Defaults to 16.
|
|
242
246
|
*/
|