@elastic/eui 88.5.2 → 88.5.4
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/collapsible_nav_beta/collapsible_nav_beta.js +12 -2
- package/es/components/combo_box/combo_box_input/combo_box_input.js +38 -41
- package/es/components/popover/input_popover.js +79 -59
- package/es/components/text_truncate/text_truncate.js +5 -2
- package/eui.d.ts +64 -65
- package/i18ntokens.json +4 -4
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/lib/components/combo_box/combo_box_input/combo_box_input.js +38 -41
- package/lib/components/popover/input_popover.js +77 -58
- package/lib/components/text_truncate/text_truncate.js +5 -2
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +12 -2
- package/optimize/es/components/combo_box/combo_box_input/combo_box_input.js +36 -39
- package/optimize/es/components/popover/input_popover.js +76 -59
- package/optimize/es/components/text_truncate/text_truncate.js +5 -2
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/optimize/lib/components/combo_box/combo_box_input/combo_box_input.js +36 -39
- package/optimize/lib/components/popover/input_popover.js +75 -58
- package/optimize/lib/components/text_truncate/text_truncate.js +5 -2
- package/package.json +6 -5
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/test-env/components/combo_box/combo_box_input/combo_box_input.js +38 -41
- package/test-env/components/popover/input_popover.js +75 -58
- package/test-env/components/text_truncate/text_truncate.js +5 -2
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
5
|
+
var _excluded = ["children", "className", "closePopover", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
8
|
/*
|
|
6
9
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
7
10
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -10,20 +13,22 @@ var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps",
|
|
|
10
13
|
* Side Public License, v 1.
|
|
11
14
|
*/
|
|
12
15
|
|
|
13
|
-
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
16
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
17
|
+
import { css } from '@emotion/react';
|
|
14
18
|
import classnames from 'classnames';
|
|
15
19
|
import { tabbable } from 'tabbable';
|
|
20
|
+
import { logicalCSS } from '../../global_styling';
|
|
21
|
+
import { keys, useCombinedRefs, useEuiTheme } from '../../services';
|
|
22
|
+
import { useResizeObserver } from '../observer/resize_observer';
|
|
16
23
|
import { EuiFocusTrap } from '../focus_trap';
|
|
17
|
-
import { EuiPopover } from './popover';
|
|
18
|
-
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
19
|
-
import { cascadingMenuKeys, useCombinedRefs, useEuiTheme } from '../../services';
|
|
20
24
|
import { euiFormVariables } from '../form/form.styles';
|
|
21
|
-
import {
|
|
22
|
-
import { logicalCSS } from '../../global_styling';
|
|
25
|
+
import { EuiPopover } from './popover';
|
|
23
26
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
24
27
|
export var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
28
|
+
var _props$panelProps;
|
|
25
29
|
var children = _ref.children,
|
|
26
30
|
className = _ref.className,
|
|
31
|
+
closePopover = _ref.closePopover,
|
|
27
32
|
_ref$disableFocusTrap = _ref.disableFocusTrap,
|
|
28
33
|
disableFocusTrap = _ref$disableFocusTrap === void 0 ? false : _ref$disableFocusTrap,
|
|
29
34
|
focusTrapProps = _ref.focusTrapProps,
|
|
@@ -36,80 +41,92 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
|
36
41
|
_inputRef = _ref.inputRef,
|
|
37
42
|
_panelRef = _ref.panelRef,
|
|
38
43
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
-
var
|
|
44
|
+
var classes = classnames('euiInputPopover', className);
|
|
45
|
+
var euiTheme = useEuiTheme();
|
|
46
|
+
var form = euiFormVariables(euiTheme);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Ref setup
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
var popoverClassRef = useRef(null);
|
|
53
|
+
// The inputEl state ensures that width is correctly tracked on initial load
|
|
40
54
|
var _useState = useState(null),
|
|
41
55
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
56
|
inputEl = _useState2[0],
|
|
43
57
|
setInputEl = _useState2[1];
|
|
44
|
-
|
|
58
|
+
// The panelEl state ensures that width is correctly set every time the popover opens
|
|
59
|
+
var _useState3 = useState(null),
|
|
45
60
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var _useState5 = useState(null),
|
|
49
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
50
|
-
panelEl = _useState6[0],
|
|
51
|
-
setPanelEl = _useState6[1];
|
|
52
|
-
var popoverClassRef = useRef(null);
|
|
61
|
+
panelEl = _useState4[0],
|
|
62
|
+
setPanelEl = _useState4[1];
|
|
53
63
|
var inputRef = useCombinedRefs([setInputEl, _inputRef]);
|
|
54
64
|
var panelRef = useCombinedRefs([setPanelEl, _panelRef]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Sizing/width logic
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
var inputWidth = useResizeObserver(inputEl, 'width').width;
|
|
71
|
+
var panelWidth = useMemo(function () {
|
|
72
|
+
return inputWidth < panelMinWidth ? panelMinWidth : inputWidth;
|
|
73
|
+
}, [panelMinWidth, inputWidth]);
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (panelEl) {
|
|
76
|
+
// We have to modify the popover panel DOM node directly instead of using
|
|
77
|
+
// `panelStyle`, as there's some weird positioning bugs on resize otherwise
|
|
78
|
+
panelEl.style.inlineSize = "".concat(panelWidth, "px");
|
|
61
79
|
}
|
|
62
|
-
}, [panelEl,
|
|
63
|
-
|
|
64
|
-
|
|
80
|
+
}, [panelEl, panelWidth]);
|
|
81
|
+
useEffect(function () {
|
|
82
|
+
// This fires on all input width changes regardless of minimum size, because on
|
|
83
|
+
// right/center anchored popovers, the input width affects the position of the popover
|
|
84
|
+
if (panelEl) {
|
|
65
85
|
var _popoverClassRef$curr;
|
|
66
|
-
var _width = inputEl.getBoundingClientRect().width;
|
|
67
|
-
setInputElWidth(_width);
|
|
68
|
-
setPanelWidth(_width);
|
|
69
86
|
(_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
|
|
70
87
|
}
|
|
71
|
-
}, [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var onKeyDown = function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
}, [inputWidth, panelEl]);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Popover tab to close logic
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
|
|
95
|
+
var onKeyDown = useCallback(function (event) {
|
|
96
|
+
panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 ? void 0 : panelPropsOnKeyDown(event);
|
|
97
|
+
if (event.key === keys.TAB) {
|
|
98
|
+
if (disableFocusTrap) {
|
|
99
|
+
closePopover();
|
|
100
|
+
} else {
|
|
101
|
+
var tabbableItems = tabbable(event.currentTarget).filter(function (el) {
|
|
102
|
+
return !el.hasAttribute('data-focus-guard');
|
|
103
|
+
});
|
|
104
|
+
if (!tabbableItems.length) return;
|
|
105
|
+
var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
|
|
106
|
+
if (tabbingFromLastItemInPopover) {
|
|
107
|
+
closePopover();
|
|
108
|
+
}
|
|
87
109
|
}
|
|
88
110
|
}
|
|
89
|
-
};
|
|
90
|
-
var classes = classnames('euiInputPopover', className);
|
|
91
|
-
var form = euiFormVariables(euiThemeContext);
|
|
111
|
+
}, [disableFocusTrap, closePopover, panelPropsOnKeyDown]);
|
|
92
112
|
return ___EmotionJSX(EuiPopover, _extends({
|
|
93
113
|
css: /*#__PURE__*/css(fullWidth ? undefined : logicalCSS('max-width', form.maxWidth), ";label:EuiInputPopover;"),
|
|
94
114
|
repositionToCrossAxis: false,
|
|
95
115
|
ownFocus: false,
|
|
96
|
-
button:
|
|
97
|
-
onResize: onResize
|
|
98
|
-
}, function (resizeRef) {
|
|
99
|
-
return ___EmotionJSX("div", {
|
|
100
|
-
ref: resizeRef
|
|
101
|
-
}, input);
|
|
102
|
-
}),
|
|
116
|
+
button: input,
|
|
103
117
|
buttonRef: inputRef,
|
|
104
118
|
panelRef: panelRef,
|
|
105
119
|
className: classes,
|
|
106
|
-
ref: popoverClassRef
|
|
107
|
-
|
|
120
|
+
ref: popoverClassRef,
|
|
121
|
+
closePopover: closePopover
|
|
122
|
+
}, props, {
|
|
123
|
+
panelProps: _objectSpread(_objectSpread({}, props.panelProps), {}, {
|
|
124
|
+
onKeyDown: onKeyDown
|
|
125
|
+
})
|
|
126
|
+
}), ___EmotionJSX(EuiFocusTrap, _extends({
|
|
108
127
|
clickOutsideDisables: true,
|
|
109
128
|
disabled: disableFocusTrap
|
|
110
|
-
}, focusTrapProps),
|
|
111
|
-
onKeyDown: onKeyDown
|
|
112
|
-
}, children)));
|
|
129
|
+
}, focusTrapProps), children));
|
|
113
130
|
};
|
|
114
131
|
EuiInputPopover.defaultProps = {
|
|
115
132
|
anchorPosition: 'downLeft',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["width"],
|
|
4
|
+
var _excluded = ["width", "onResize"],
|
|
5
5
|
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "className"],
|
|
6
6
|
_excluded3 = ["onResize"];
|
|
7
7
|
/*
|
|
@@ -22,10 +22,13 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
|
22
22
|
var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
|
|
23
23
|
export var EuiTextTruncate = function EuiTextTruncate(_ref) {
|
|
24
24
|
var width = _ref.width,
|
|
25
|
+
onResize = _ref.onResize,
|
|
25
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
27
|
return width != null ? ___EmotionJSX(EuiTextTruncateWithWidth, _extends({
|
|
27
28
|
width: width
|
|
28
|
-
}, props)) : ___EmotionJSX(EuiTextTruncateWithResizeObserver,
|
|
29
|
+
}, props)) : ___EmotionJSX(EuiTextTruncateWithResizeObserver, _extends({
|
|
30
|
+
onResize: onResize
|
|
31
|
+
}, props));
|
|
29
32
|
};
|
|
30
33
|
var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
|
|
31
34
|
var width = _ref2.width,
|
|
@@ -49,6 +49,8 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
49
49
|
side = _ref$side === void 0 ? 'left' : _ref$side,
|
|
50
50
|
_focusTrapProps = _ref.focusTrapProps,
|
|
51
51
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
52
|
+
var _useEuiThemeCSSVariab = (0, _services.useEuiThemeCSSVariables)(),
|
|
53
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
52
54
|
var euiTheme = (0, _services.useEuiTheme)();
|
|
53
55
|
var headerHeight = (0, _header.euiHeaderVariables)(euiTheme).height;
|
|
54
56
|
|
|
@@ -107,9 +109,17 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
107
109
|
var width = (0, _react.useMemo)(function () {
|
|
108
110
|
if (isOverlayFullWidth) return '100%';
|
|
109
111
|
if (isPush && isCollapsed) return headerHeight;
|
|
110
|
-
return _width;
|
|
112
|
+
return "".concat(_width, "px");
|
|
111
113
|
}, [_width, isOverlayFullWidth, isPush, isCollapsed, headerHeight]);
|
|
112
114
|
|
|
115
|
+
// Other UI elements may need to account for the nav width -
|
|
116
|
+
// set a global CSS variable that they can use
|
|
117
|
+
(0, _react.useEffect)(function () {
|
|
118
|
+
setGlobalCSSVariables({
|
|
119
|
+
'--euiCollapsibleNavOffset': isOverlay ? '0' : width
|
|
120
|
+
});
|
|
121
|
+
}, [width, isOverlay, setGlobalCSSVariables]);
|
|
122
|
+
|
|
113
123
|
/**
|
|
114
124
|
* Prop setup
|
|
115
125
|
*/
|
|
@@ -106,56 +106,51 @@ var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "inputOnChange", function (event) {
|
|
110
|
-
var _this$props$onChange, _this$props3;
|
|
111
|
-
var value = event.target.value;
|
|
112
|
-
_this.updateInputSize(value);
|
|
113
|
-
(_this$props$onChange = (_this$props3 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props3, value);
|
|
114
|
-
});
|
|
115
109
|
return _this;
|
|
116
110
|
}
|
|
117
111
|
(0, _createClass2.default)(EuiComboBoxInput, [{
|
|
118
112
|
key: "componentDidUpdate",
|
|
119
113
|
value: function componentDidUpdate(prevProps) {
|
|
120
|
-
|
|
114
|
+
if (prevProps.searchValue !== this.props.searchValue) {
|
|
115
|
+
this.updateInputSize(this.props.searchValue);
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (searchValue !== this.props.searchValue) {
|
|
117
|
+
// We need to update the position of everything if the user enters enough input to change
|
|
118
|
+
// the size of the input.
|
|
125
119
|
this.updatePosition();
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
}, {
|
|
129
123
|
key: "render",
|
|
130
124
|
value: function render() {
|
|
131
|
-
var _this$
|
|
132
|
-
compressed = _this$
|
|
133
|
-
focusedOptionId = _this$
|
|
134
|
-
fullWidth = _this$
|
|
135
|
-
hasSelectedOptions = _this$
|
|
136
|
-
id = _this$
|
|
137
|
-
isDisabled = _this$
|
|
138
|
-
isListOpen = _this$
|
|
139
|
-
noIcon = _this$
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
125
|
+
var _this$props3 = this.props,
|
|
126
|
+
compressed = _this$props3.compressed,
|
|
127
|
+
focusedOptionId = _this$props3.focusedOptionId,
|
|
128
|
+
fullWidth = _this$props3.fullWidth,
|
|
129
|
+
hasSelectedOptions = _this$props3.hasSelectedOptions,
|
|
130
|
+
id = _this$props3.id,
|
|
131
|
+
isDisabled = _this$props3.isDisabled,
|
|
132
|
+
isListOpen = _this$props3.isListOpen,
|
|
133
|
+
noIcon = _this$props3.noIcon,
|
|
134
|
+
_onChange = _this$props3.onChange,
|
|
135
|
+
onClear = _this$props3.onClear,
|
|
136
|
+
onClick = _this$props3.onClick,
|
|
137
|
+
onCloseListClick = _this$props3.onCloseListClick,
|
|
138
|
+
onOpenListClick = _this$props3.onOpenListClick,
|
|
139
|
+
onRemoveOption = _this$props3.onRemoveOption,
|
|
140
|
+
placeholder = _this$props3.placeholder,
|
|
141
|
+
rootId = _this$props3.rootId,
|
|
142
|
+
searchValue = _this$props3.searchValue,
|
|
143
|
+
selectedOptions = _this$props3.selectedOptions,
|
|
144
|
+
singleSelectionProp = _this$props3.singleSelection,
|
|
145
|
+
toggleButtonRef = _this$props3.toggleButtonRef,
|
|
146
|
+
value = _this$props3.value,
|
|
147
|
+
prepend = _this$props3.prepend,
|
|
148
|
+
append = _this$props3.append,
|
|
149
|
+
isLoading = _this$props3.isLoading,
|
|
150
|
+
isInvalid = _this$props3.isInvalid,
|
|
151
|
+
autoFocus = _this$props3.autoFocus,
|
|
152
|
+
ariaLabel = _this$props3['aria-label'],
|
|
153
|
+
ariaLabelledby = _this$props3['aria-labelledby'];
|
|
159
154
|
var singleSelection = Boolean(singleSelectionProp);
|
|
160
155
|
var asPlainText = singleSelectionProp && (0, _typeof2.default)(singleSelectionProp) === 'object' && singleSelectionProp.asPlainText || false;
|
|
161
156
|
var pills = selectedOptions ? selectedOptions.map(function (option) {
|
|
@@ -260,7 +255,9 @@ var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
260
255
|
disabled: isDisabled,
|
|
261
256
|
id: id,
|
|
262
257
|
onBlur: this.onBlur,
|
|
263
|
-
onChange:
|
|
258
|
+
onChange: function onChange(event) {
|
|
259
|
+
return _onChange(event.target.value);
|
|
260
|
+
},
|
|
264
261
|
onFocus: this.onFocus,
|
|
265
262
|
onKeyDown: this.onKeyDown,
|
|
266
263
|
ref: this.inputRefCallback,
|
|
@@ -7,19 +7,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.EuiInputPopover = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
12
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _react2 = require("@emotion/react");
|
|
13
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
16
|
var _tabbable = require("tabbable");
|
|
15
|
-
var
|
|
16
|
-
var _popover = require("./popover");
|
|
17
|
-
var _resize_observer = require("../observer/resize_observer");
|
|
17
|
+
var _global_styling = require("../../global_styling");
|
|
18
18
|
var _services = require("../../services");
|
|
19
|
+
var _resize_observer = require("../observer/resize_observer");
|
|
20
|
+
var _focus_trap = require("../focus_trap");
|
|
19
21
|
var _form = require("../form/form.styles");
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
22
|
+
var _popover = require("./popover");
|
|
23
|
+
var _excluded = ["children", "className", "closePopover", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
23
24
|
/*
|
|
24
25
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
25
26
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -29,9 +30,13 @@ var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps",
|
|
|
29
30
|
*/
|
|
30
31
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
32
35
|
var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
36
|
+
var _props$panelProps;
|
|
33
37
|
var children = _ref.children,
|
|
34
38
|
className = _ref.className,
|
|
39
|
+
closePopover = _ref.closePopover,
|
|
35
40
|
_ref$disableFocusTrap = _ref.disableFocusTrap,
|
|
36
41
|
disableFocusTrap = _ref$disableFocusTrap === void 0 ? false : _ref$disableFocusTrap,
|
|
37
42
|
focusTrapProps = _ref.focusTrapProps,
|
|
@@ -44,80 +49,92 @@ var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
|
44
49
|
_inputRef = _ref.inputRef,
|
|
45
50
|
_panelRef = _ref.panelRef,
|
|
46
51
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
47
|
-
var
|
|
52
|
+
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
53
|
+
var euiTheme = (0, _services.useEuiTheme)();
|
|
54
|
+
var form = (0, _form.euiFormVariables)(euiTheme);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Ref setup
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
var popoverClassRef = (0, _react.useRef)(null);
|
|
61
|
+
// The inputEl state ensures that width is correctly tracked on initial load
|
|
48
62
|
var _useState = (0, _react.useState)(null),
|
|
49
63
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
50
64
|
inputEl = _useState2[0],
|
|
51
65
|
setInputEl = _useState2[1];
|
|
52
|
-
|
|
66
|
+
// The panelEl state ensures that width is correctly set every time the popover opens
|
|
67
|
+
var _useState3 = (0, _react.useState)(null),
|
|
53
68
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _useState5 = (0, _react.useState)(null),
|
|
57
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
58
|
-
panelEl = _useState6[0],
|
|
59
|
-
setPanelEl = _useState6[1];
|
|
60
|
-
var popoverClassRef = (0, _react.useRef)(null);
|
|
69
|
+
panelEl = _useState4[0],
|
|
70
|
+
setPanelEl = _useState4[1];
|
|
61
71
|
var inputRef = (0, _services.useCombinedRefs)([setInputEl, _inputRef]);
|
|
62
72
|
var panelRef = (0, _services.useCombinedRefs)([setPanelEl, _panelRef]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Sizing/width logic
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
var inputWidth = (0, _resize_observer.useResizeObserver)(inputEl, 'width').width;
|
|
79
|
+
var panelWidth = (0, _react.useMemo)(function () {
|
|
80
|
+
return inputWidth < panelMinWidth ? panelMinWidth : inputWidth;
|
|
81
|
+
}, [panelMinWidth, inputWidth]);
|
|
82
|
+
(0, _react.useEffect)(function () {
|
|
83
|
+
if (panelEl) {
|
|
84
|
+
// We have to modify the popover panel DOM node directly instead of using
|
|
85
|
+
// `panelStyle`, as there's some weird positioning bugs on resize otherwise
|
|
86
|
+
panelEl.style.inlineSize = "".concat(panelWidth, "px");
|
|
69
87
|
}
|
|
70
|
-
}, [panelEl,
|
|
71
|
-
|
|
72
|
-
|
|
88
|
+
}, [panelEl, panelWidth]);
|
|
89
|
+
(0, _react.useEffect)(function () {
|
|
90
|
+
// This fires on all input width changes regardless of minimum size, because on
|
|
91
|
+
// right/center anchored popovers, the input width affects the position of the popover
|
|
92
|
+
if (panelEl) {
|
|
73
93
|
var _popoverClassRef$curr;
|
|
74
|
-
var _width = inputEl.getBoundingClientRect().width;
|
|
75
|
-
setInputElWidth(_width);
|
|
76
|
-
setPanelWidth(_width);
|
|
77
94
|
(_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
|
|
78
95
|
}
|
|
79
|
-
}, [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var onKeyDown = function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
}, [inputWidth, panelEl]);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Popover tab to close logic
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
|
|
103
|
+
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
104
|
+
panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 ? void 0 : panelPropsOnKeyDown(event);
|
|
105
|
+
if (event.key === _services.keys.TAB) {
|
|
106
|
+
if (disableFocusTrap) {
|
|
107
|
+
closePopover();
|
|
108
|
+
} else {
|
|
109
|
+
var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
|
|
110
|
+
return !el.hasAttribute('data-focus-guard');
|
|
111
|
+
});
|
|
112
|
+
if (!tabbableItems.length) return;
|
|
113
|
+
var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
|
|
114
|
+
if (tabbingFromLastItemInPopover) {
|
|
115
|
+
closePopover();
|
|
116
|
+
}
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
|
-
};
|
|
98
|
-
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
99
|
-
var form = (0, _form.euiFormVariables)(euiThemeContext);
|
|
119
|
+
}, [disableFocusTrap, closePopover, panelPropsOnKeyDown]);
|
|
100
120
|
return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
|
|
101
121
|
css: /*#__PURE__*/(0, _react2.css)(fullWidth ? undefined : (0, _global_styling.logicalCSS)('max-width', form.maxWidth), ";label:EuiInputPopover;"),
|
|
102
122
|
repositionToCrossAxis: false,
|
|
103
123
|
ownFocus: false,
|
|
104
|
-
button:
|
|
105
|
-
onResize: onResize
|
|
106
|
-
}, function (resizeRef) {
|
|
107
|
-
return (0, _react2.jsx)("div", {
|
|
108
|
-
ref: resizeRef
|
|
109
|
-
}, input);
|
|
110
|
-
}),
|
|
124
|
+
button: input,
|
|
111
125
|
buttonRef: inputRef,
|
|
112
126
|
panelRef: panelRef,
|
|
113
127
|
className: classes,
|
|
114
|
-
ref: popoverClassRef
|
|
115
|
-
|
|
128
|
+
ref: popoverClassRef,
|
|
129
|
+
closePopover: closePopover
|
|
130
|
+
}, props, {
|
|
131
|
+
panelProps: _objectSpread(_objectSpread({}, props.panelProps), {}, {
|
|
132
|
+
onKeyDown: onKeyDown
|
|
133
|
+
})
|
|
134
|
+
}), (0, _react2.jsx)(_focus_trap.EuiFocusTrap, (0, _extends2.default)({
|
|
116
135
|
clickOutsideDisables: true,
|
|
117
136
|
disabled: disableFocusTrap
|
|
118
|
-
}, focusTrapProps),
|
|
119
|
-
onKeyDown: onKeyDown
|
|
120
|
-
}, children)));
|
|
137
|
+
}, focusTrapProps), children));
|
|
121
138
|
};
|
|
122
139
|
exports.EuiInputPopover = EuiInputPopover;
|
|
123
140
|
EuiInputPopover.defaultProps = {
|
|
@@ -16,7 +16,7 @@ var _resize_observer = require("../observer/resize_observer");
|
|
|
16
16
|
var _utils = require("./utils");
|
|
17
17
|
var _text_truncate = require("./text_truncate.styles");
|
|
18
18
|
var _react2 = require("@emotion/react");
|
|
19
|
-
var _excluded = ["width"],
|
|
19
|
+
var _excluded = ["width", "onResize"],
|
|
20
20
|
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "className"],
|
|
21
21
|
_excluded3 = ["onResize"];
|
|
22
22
|
/*
|
|
@@ -31,10 +31,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
31
31
|
var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
|
|
32
32
|
var EuiTextTruncate = function EuiTextTruncate(_ref) {
|
|
33
33
|
var width = _ref.width,
|
|
34
|
+
onResize = _ref.onResize,
|
|
34
35
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
35
36
|
return width != null ? (0, _react2.jsx)(EuiTextTruncateWithWidth, (0, _extends2.default)({
|
|
36
37
|
width: width
|
|
37
|
-
}, props)) : (0, _react2.jsx)(EuiTextTruncateWithResizeObserver,
|
|
38
|
+
}, props)) : (0, _react2.jsx)(EuiTextTruncateWithResizeObserver, (0, _extends2.default)({
|
|
39
|
+
onResize: onResize
|
|
40
|
+
}, props));
|
|
38
41
|
};
|
|
39
42
|
exports.EuiTextTruncate = EuiTextTruncate;
|
|
40
43
|
var EuiTextTruncateWithWidth = function EuiTextTruncateWithWidth(_ref2) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elastic/eui",
|
|
3
3
|
"description": "Elastic UI Component Library",
|
|
4
|
-
"version": "88.5.
|
|
4
|
+
"version": "88.5.4",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "lib",
|
|
7
7
|
"module": "es",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"lint-sass": "yarn stylelint \"**/*.scss\" --quiet-deprecation-warnings",
|
|
32
32
|
"test": "yarn lint && yarn test-unit",
|
|
33
33
|
"test-ci": "yarn test && yarn test-cypress",
|
|
34
|
-
"test-unit": "
|
|
34
|
+
"test-unit": "node ./scripts/test-unit",
|
|
35
35
|
"test-a11y": "node ./scripts/a11y-testing",
|
|
36
36
|
"test-staged": "yarn lint && node scripts/test-staged.js",
|
|
37
|
-
"test-cypress": "node ./scripts/cypress",
|
|
38
|
-
"test-cypress-dev": "
|
|
39
|
-
"test-cypress-a11y": "
|
|
37
|
+
"test-cypress": "node ./scripts/test-cypress",
|
|
38
|
+
"test-cypress-dev": "yarn test-cypress --dev",
|
|
39
|
+
"test-cypress-a11y": "yarn test-cypress --a11y",
|
|
40
40
|
"combine-test-coverage": "sh ./scripts/combine-coverage.sh",
|
|
41
41
|
"start-test-server": "BABEL_MODULES=false NODE_ENV=puppeteer NODE_OPTIONS=--max-old-space-size=4096 webpack-dev-server --config src-docs/webpack.config.js --port 9999",
|
|
42
42
|
"yo-component": "yo ./generator-eui/app/component.js",
|
|
@@ -183,6 +183,7 @@
|
|
|
183
183
|
"dedent": "^0.7.0",
|
|
184
184
|
"dts-generator": "^3.0.0",
|
|
185
185
|
"enzyme": "^3.11.0",
|
|
186
|
+
"enzyme-adapter-react-16": "^1.15.7",
|
|
186
187
|
"enzyme-to-json": "^3.5.0",
|
|
187
188
|
"eslint": "^8.41.0",
|
|
188
189
|
"eslint-config-prettier": "^8.8.0",
|
|
@@ -50,6 +50,8 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
50
50
|
side = _ref$side === void 0 ? 'left' : _ref$side,
|
|
51
51
|
_focusTrapProps = _ref.focusTrapProps,
|
|
52
52
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
53
|
+
var _useEuiThemeCSSVariab = (0, _services.useEuiThemeCSSVariables)(),
|
|
54
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
53
55
|
var euiTheme = (0, _services.useEuiTheme)();
|
|
54
56
|
var headerHeight = (0, _header.euiHeaderVariables)(euiTheme).height;
|
|
55
57
|
|
|
@@ -108,9 +110,17 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
108
110
|
var width = (0, _react.useMemo)(function () {
|
|
109
111
|
if (isOverlayFullWidth) return '100%';
|
|
110
112
|
if (isPush && isCollapsed) return headerHeight;
|
|
111
|
-
return _width;
|
|
113
|
+
return "".concat(_width, "px");
|
|
112
114
|
}, [_width, isOverlayFullWidth, isPush, isCollapsed, headerHeight]);
|
|
113
115
|
|
|
116
|
+
// Other UI elements may need to account for the nav width -
|
|
117
|
+
// set a global CSS variable that they can use
|
|
118
|
+
(0, _react.useEffect)(function () {
|
|
119
|
+
setGlobalCSSVariables({
|
|
120
|
+
'--euiCollapsibleNavOffset': isOverlay ? '0' : width
|
|
121
|
+
});
|
|
122
|
+
}, [width, isOverlay, setGlobalCSSVariables]);
|
|
123
|
+
|
|
114
124
|
/**
|
|
115
125
|
* Prop setup
|
|
116
126
|
*/
|