@elastic/eui 88.5.3 → 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/popover/input_popover.js +79 -59
- package/eui.d.ts +61 -61
- package/i18ntokens.json +4 -4
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/lib/components/popover/input_popover.js +77 -58
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +12 -2
- package/optimize/es/components/popover/input_popover.js +76 -59
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/optimize/lib/components/popover/input_popover.js +75 -58
- package/package.json +1 -1
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +11 -1
- package/test-env/components/popover/input_popover.js +75 -58
|
@@ -29,7 +29,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
29
29
|
import React, { useRef, useMemo, useState, useEffect, useCallback } from 'react';
|
|
30
30
|
import PropTypes from "prop-types";
|
|
31
31
|
import classNames from 'classnames';
|
|
32
|
-
import { useEuiTheme, useGeneratedHtmlId, throttle } from '../../services';
|
|
32
|
+
import { useEuiTheme, useEuiThemeCSSVariables, useGeneratedHtmlId, throttle } from '../../services';
|
|
33
33
|
import { EuiFlyout } from '../flyout';
|
|
34
34
|
import { useEuiI18n } from '../i18n';
|
|
35
35
|
import { euiHeaderVariables } from '../header/header.styles';
|
|
@@ -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 = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
+
var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
|
|
53
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
52
54
|
var euiTheme = useEuiTheme();
|
|
53
55
|
var headerHeight = euiHeaderVariables(euiTheme).height;
|
|
54
56
|
|
|
@@ -107,9 +109,17 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
107
109
|
var width = 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
|
+
useEffect(function () {
|
|
118
|
+
setGlobalCSSVariables({
|
|
119
|
+
'--euiCollapsibleNavOffset': isOverlay ? '0' : width
|
|
120
|
+
});
|
|
121
|
+
}, [width, isOverlay, setGlobalCSSVariables]);
|
|
122
|
+
|
|
113
123
|
/**
|
|
114
124
|
* Prop setup
|
|
115
125
|
*/
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _excluded = ["children", "className", "closePopover", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
2
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
10
|
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."); }
|
|
5
11
|
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); }
|
|
@@ -16,21 +22,23 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
22
|
* Side Public License, v 1.
|
|
17
23
|
*/
|
|
18
24
|
|
|
19
|
-
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
25
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
20
26
|
import PropTypes from "prop-types";
|
|
27
|
+
import { css } from '@emotion/react';
|
|
21
28
|
import classnames from 'classnames';
|
|
22
29
|
import { tabbable } from 'tabbable';
|
|
30
|
+
import { logicalCSS } from '../../global_styling';
|
|
31
|
+
import { keys, useCombinedRefs, useEuiTheme } from '../../services';
|
|
32
|
+
import { useResizeObserver } from '../observer/resize_observer';
|
|
23
33
|
import { EuiFocusTrap } from '../focus_trap';
|
|
24
|
-
import { EuiPopover } from './popover';
|
|
25
|
-
import { EuiResizeObserver } from '../observer/resize_observer';
|
|
26
|
-
import { cascadingMenuKeys, useCombinedRefs, useEuiTheme } from '../../services';
|
|
27
34
|
import { euiFormVariables } from '../form/form.styles';
|
|
28
|
-
import {
|
|
29
|
-
import { logicalCSS } from '../../global_styling';
|
|
35
|
+
import { EuiPopover } from './popover';
|
|
30
36
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
31
37
|
export var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
38
|
+
var _props$panelProps;
|
|
32
39
|
var children = _ref.children,
|
|
33
40
|
className = _ref.className,
|
|
41
|
+
closePopover = _ref.closePopover,
|
|
34
42
|
_ref$disableFocusTrap = _ref.disableFocusTrap,
|
|
35
43
|
disableFocusTrap = _ref$disableFocusTrap === void 0 ? false : _ref$disableFocusTrap,
|
|
36
44
|
focusTrapProps = _ref.focusTrapProps,
|
|
@@ -43,80 +51,92 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
|
43
51
|
_inputRef = _ref.inputRef,
|
|
44
52
|
_panelRef = _ref.panelRef,
|
|
45
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
46
|
-
var
|
|
54
|
+
var classes = classnames('euiInputPopover', className);
|
|
55
|
+
var euiTheme = useEuiTheme();
|
|
56
|
+
var form = euiFormVariables(euiTheme);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Ref setup
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
var popoverClassRef = useRef(null);
|
|
63
|
+
// The inputEl state ensures that width is correctly tracked on initial load
|
|
47
64
|
var _useState = useState(null),
|
|
48
65
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
66
|
inputEl = _useState2[0],
|
|
50
67
|
setInputEl = _useState2[1];
|
|
51
|
-
|
|
68
|
+
// The panelEl state ensures that width is correctly set every time the popover opens
|
|
69
|
+
var _useState3 = useState(null),
|
|
52
70
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _useState5 = useState(null),
|
|
56
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
57
|
-
panelEl = _useState6[0],
|
|
58
|
-
setPanelEl = _useState6[1];
|
|
59
|
-
var popoverClassRef = useRef(null);
|
|
71
|
+
panelEl = _useState4[0],
|
|
72
|
+
setPanelEl = _useState4[1];
|
|
60
73
|
var inputRef = useCombinedRefs([setInputEl, _inputRef]);
|
|
61
74
|
var panelRef = useCombinedRefs([setPanelEl, _panelRef]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Sizing/width logic
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
var inputWidth = useResizeObserver(inputEl, 'width').width;
|
|
81
|
+
var panelWidth = useMemo(function () {
|
|
82
|
+
return inputWidth < panelMinWidth ? panelMinWidth : inputWidth;
|
|
83
|
+
}, [panelMinWidth, inputWidth]);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
if (panelEl) {
|
|
86
|
+
// We have to modify the popover panel DOM node directly instead of using
|
|
87
|
+
// `panelStyle`, as there's some weird positioning bugs on resize otherwise
|
|
88
|
+
panelEl.style.inlineSize = "".concat(panelWidth, "px");
|
|
68
89
|
}
|
|
69
|
-
}, [panelEl,
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
}, [panelEl, panelWidth]);
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
// This fires on all input width changes regardless of minimum size, because on
|
|
93
|
+
// right/center anchored popovers, the input width affects the position of the popover
|
|
94
|
+
if (panelEl) {
|
|
72
95
|
var _popoverClassRef$curr;
|
|
73
|
-
var _width = inputEl.getBoundingClientRect().width;
|
|
74
|
-
setInputElWidth(_width);
|
|
75
|
-
setPanelWidth(_width);
|
|
76
96
|
(_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
|
|
77
97
|
}
|
|
78
|
-
}, [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var onKeyDown = function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
}, [inputWidth, panelEl]);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Popover tab to close logic
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
|
|
105
|
+
var onKeyDown = useCallback(function (event) {
|
|
106
|
+
panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 ? void 0 : panelPropsOnKeyDown(event);
|
|
107
|
+
if (event.key === keys.TAB) {
|
|
108
|
+
if (disableFocusTrap) {
|
|
109
|
+
closePopover();
|
|
110
|
+
} else {
|
|
111
|
+
var tabbableItems = tabbable(event.currentTarget).filter(function (el) {
|
|
112
|
+
return !el.hasAttribute('data-focus-guard');
|
|
113
|
+
});
|
|
114
|
+
if (!tabbableItems.length) return;
|
|
115
|
+
var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
|
|
116
|
+
if (tabbingFromLastItemInPopover) {
|
|
117
|
+
closePopover();
|
|
118
|
+
}
|
|
94
119
|
}
|
|
95
120
|
}
|
|
96
|
-
};
|
|
97
|
-
var classes = classnames('euiInputPopover', className);
|
|
98
|
-
var form = euiFormVariables(euiThemeContext);
|
|
121
|
+
}, [disableFocusTrap, closePopover, panelPropsOnKeyDown]);
|
|
99
122
|
return ___EmotionJSX(EuiPopover, _extends({
|
|
100
123
|
css: /*#__PURE__*/css(fullWidth ? undefined : logicalCSS('max-width', form.maxWidth), ";label:EuiInputPopover;"),
|
|
101
124
|
repositionToCrossAxis: false,
|
|
102
125
|
ownFocus: false,
|
|
103
|
-
button:
|
|
104
|
-
onResize: onResize
|
|
105
|
-
}, function (resizeRef) {
|
|
106
|
-
return ___EmotionJSX("div", {
|
|
107
|
-
ref: resizeRef
|
|
108
|
-
}, input);
|
|
109
|
-
}),
|
|
126
|
+
button: input,
|
|
110
127
|
buttonRef: inputRef,
|
|
111
128
|
panelRef: panelRef,
|
|
112
129
|
className: classes,
|
|
113
|
-
ref: popoverClassRef
|
|
114
|
-
|
|
130
|
+
ref: popoverClassRef,
|
|
131
|
+
closePopover: closePopover
|
|
132
|
+
}, props, {
|
|
133
|
+
panelProps: _objectSpread(_objectSpread({}, props.panelProps), {}, {
|
|
134
|
+
onKeyDown: onKeyDown
|
|
135
|
+
})
|
|
136
|
+
}), ___EmotionJSX(EuiFocusTrap, _extends({
|
|
115
137
|
clickOutsideDisables: true,
|
|
116
138
|
disabled: disableFocusTrap
|
|
117
|
-
}, focusTrapProps),
|
|
118
|
-
onKeyDown: onKeyDown
|
|
119
|
-
}, children)));
|
|
139
|
+
}, focusTrapProps), children));
|
|
120
140
|
};
|
|
121
141
|
EuiInputPopover.propTypes = {
|
|
122
142
|
className: PropTypes.string,
|
package/eui.d.ts
CHANGED
|
@@ -4785,6 +4785,67 @@ declare module '@elastic/eui/src/services/number/number' {
|
|
|
4785
4785
|
declare module '@elastic/eui/src/services/number' {
|
|
4786
4786
|
export * from '@elastic/eui/src/services/number/number';
|
|
4787
4787
|
|
|
4788
|
+
}
|
|
4789
|
+
declare module '@elastic/eui/src/components/observer/observer' {
|
|
4790
|
+
import { Component, ReactNode } from 'react';
|
|
4791
|
+
interface BaseProps {
|
|
4792
|
+
/**
|
|
4793
|
+
* ReactNode to render as this component's content
|
|
4794
|
+
*/
|
|
4795
|
+
children: (ref: any) => ReactNode;
|
|
4796
|
+
}
|
|
4797
|
+
export interface Observer {
|
|
4798
|
+
disconnect: () => void;
|
|
4799
|
+
observe: (element: Element, options?: {
|
|
4800
|
+
[key: string]: any;
|
|
4801
|
+
}) => void;
|
|
4802
|
+
}
|
|
4803
|
+
export class EuiObserver<Props extends BaseProps> extends Component<Props> {
|
|
4804
|
+
protected name: string;
|
|
4805
|
+
protected childNode: null | Element;
|
|
4806
|
+
protected observer: null | Observer;
|
|
4807
|
+
componentDidMount(): void;
|
|
4808
|
+
componentWillUnmount(): void;
|
|
4809
|
+
updateChildNode: (ref: Element) => void;
|
|
4810
|
+
beginObserve: () => void;
|
|
4811
|
+
render(): ReactNode;
|
|
4812
|
+
}
|
|
4813
|
+
export {};
|
|
4814
|
+
|
|
4815
|
+
}
|
|
4816
|
+
declare module '@elastic/eui/src/components/observer/resize_observer/resize_observer' {
|
|
4817
|
+
import { ReactNode } from 'react';
|
|
4818
|
+
import { EuiObserver } from '@elastic/eui/src/components/observer/observer';
|
|
4819
|
+
export interface EuiResizeObserverProps {
|
|
4820
|
+
/**
|
|
4821
|
+
* ReactNode to render as this component's content
|
|
4822
|
+
*/
|
|
4823
|
+
children: (ref: (e: HTMLElement | null) => void) => ReactNode;
|
|
4824
|
+
onResize: (dimensions: {
|
|
4825
|
+
height: number;
|
|
4826
|
+
width: number;
|
|
4827
|
+
}) => void;
|
|
4828
|
+
}
|
|
4829
|
+
export const hasResizeObserver: boolean;
|
|
4830
|
+
export class EuiResizeObserver extends EuiObserver<EuiResizeObserverProps> {
|
|
4831
|
+
name: string;
|
|
4832
|
+
state: {
|
|
4833
|
+
height: number;
|
|
4834
|
+
width: number;
|
|
4835
|
+
};
|
|
4836
|
+
onResize: ResizeObserverCallback;
|
|
4837
|
+
beginObserve: () => void;
|
|
4838
|
+
}
|
|
4839
|
+
export const useResizeObserver: (container: Element | null, dimension?: "height" | "width" | undefined) => {
|
|
4840
|
+
width: number;
|
|
4841
|
+
height: number;
|
|
4842
|
+
};
|
|
4843
|
+
|
|
4844
|
+
}
|
|
4845
|
+
declare module '@elastic/eui/src/components/observer/resize_observer' {
|
|
4846
|
+
export type { EuiResizeObserverProps } from '@elastic/eui/src/components/observer/resize_observer/resize_observer';
|
|
4847
|
+
export { EuiResizeObserver, useResizeObserver } from '@elastic/eui/src/components/observer/resize_observer/resize_observer';
|
|
4848
|
+
|
|
4788
4849
|
}
|
|
4789
4850
|
declare module '@elastic/eui/src/components/portal/portal' {
|
|
4790
4851
|
/**
|
|
@@ -4951,67 +5012,6 @@ declare module '@elastic/eui/src/components/table/table_header_cell_checkbox' {
|
|
|
4951
5012
|
}
|
|
4952
5013
|
export const EuiTableHeaderCellCheckbox: FunctionComponent<CommonProps & ThHTMLAttributes<HTMLTableHeaderCellElement> & EuiTableHeaderCellCheckboxProps>;
|
|
4953
5014
|
|
|
4954
|
-
}
|
|
4955
|
-
declare module '@elastic/eui/src/components/observer/observer' {
|
|
4956
|
-
import { Component, ReactNode } from 'react';
|
|
4957
|
-
interface BaseProps {
|
|
4958
|
-
/**
|
|
4959
|
-
* ReactNode to render as this component's content
|
|
4960
|
-
*/
|
|
4961
|
-
children: (ref: any) => ReactNode;
|
|
4962
|
-
}
|
|
4963
|
-
export interface Observer {
|
|
4964
|
-
disconnect: () => void;
|
|
4965
|
-
observe: (element: Element, options?: {
|
|
4966
|
-
[key: string]: any;
|
|
4967
|
-
}) => void;
|
|
4968
|
-
}
|
|
4969
|
-
export class EuiObserver<Props extends BaseProps> extends Component<Props> {
|
|
4970
|
-
protected name: string;
|
|
4971
|
-
protected childNode: null | Element;
|
|
4972
|
-
protected observer: null | Observer;
|
|
4973
|
-
componentDidMount(): void;
|
|
4974
|
-
componentWillUnmount(): void;
|
|
4975
|
-
updateChildNode: (ref: Element) => void;
|
|
4976
|
-
beginObserve: () => void;
|
|
4977
|
-
render(): ReactNode;
|
|
4978
|
-
}
|
|
4979
|
-
export {};
|
|
4980
|
-
|
|
4981
|
-
}
|
|
4982
|
-
declare module '@elastic/eui/src/components/observer/resize_observer/resize_observer' {
|
|
4983
|
-
import { ReactNode } from 'react';
|
|
4984
|
-
import { EuiObserver } from '@elastic/eui/src/components/observer/observer';
|
|
4985
|
-
export interface EuiResizeObserverProps {
|
|
4986
|
-
/**
|
|
4987
|
-
* ReactNode to render as this component's content
|
|
4988
|
-
*/
|
|
4989
|
-
children: (ref: (e: HTMLElement | null) => void) => ReactNode;
|
|
4990
|
-
onResize: (dimensions: {
|
|
4991
|
-
height: number;
|
|
4992
|
-
width: number;
|
|
4993
|
-
}) => void;
|
|
4994
|
-
}
|
|
4995
|
-
export const hasResizeObserver: boolean;
|
|
4996
|
-
export class EuiResizeObserver extends EuiObserver<EuiResizeObserverProps> {
|
|
4997
|
-
name: string;
|
|
4998
|
-
state: {
|
|
4999
|
-
height: number;
|
|
5000
|
-
width: number;
|
|
5001
|
-
};
|
|
5002
|
-
onResize: ResizeObserverCallback;
|
|
5003
|
-
beginObserve: () => void;
|
|
5004
|
-
}
|
|
5005
|
-
export const useResizeObserver: (container: Element | null, dimension?: "height" | "width" | undefined) => {
|
|
5006
|
-
width: number;
|
|
5007
|
-
height: number;
|
|
5008
|
-
};
|
|
5009
|
-
|
|
5010
|
-
}
|
|
5011
|
-
declare module '@elastic/eui/src/components/observer/resize_observer' {
|
|
5012
|
-
export type { EuiResizeObserverProps } from '@elastic/eui/src/components/observer/resize_observer/resize_observer';
|
|
5013
|
-
export { EuiResizeObserver, useResizeObserver } from '@elastic/eui/src/components/observer/resize_observer/resize_observer';
|
|
5014
|
-
|
|
5015
5015
|
}
|
|
5016
5016
|
declare module '@elastic/eui/src/themes/amsterdam' {
|
|
5017
5017
|
export * from '@elastic/eui/src/themes/amsterdam/global_styling/mixins/shadow';
|
package/i18ntokens.json
CHANGED
|
@@ -455,14 +455,14 @@
|
|
|
455
455
|
"highlighting": "string",
|
|
456
456
|
"loc": {
|
|
457
457
|
"start": {
|
|
458
|
-
"line":
|
|
458
|
+
"line": 165,
|
|
459
459
|
"column": 27,
|
|
460
|
-
"index":
|
|
460
|
+
"index": 5469
|
|
461
461
|
},
|
|
462
462
|
"end": {
|
|
463
|
-
"line":
|
|
463
|
+
"line": 168,
|
|
464
464
|
"column": 3,
|
|
465
|
-
"index":
|
|
465
|
+
"index": 5539
|
|
466
466
|
}
|
|
467
467
|
},
|
|
468
468
|
"filepath": "src/components/collapsible_nav_beta/collapsible_nav_beta.tsx"
|
|
@@ -61,6 +61,8 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
61
61
|
side = _ref$side === void 0 ? 'left' : _ref$side,
|
|
62
62
|
_focusTrapProps = _ref.focusTrapProps,
|
|
63
63
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
64
|
+
var _useEuiThemeCSSVariab = (0, _services.useEuiThemeCSSVariables)(),
|
|
65
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
64
66
|
var euiTheme = (0, _services.useEuiTheme)();
|
|
65
67
|
var headerHeight = (0, _header.euiHeaderVariables)(euiTheme).height;
|
|
66
68
|
|
|
@@ -119,9 +121,17 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
119
121
|
var width = (0, _react.useMemo)(function () {
|
|
120
122
|
if (isOverlayFullWidth) return '100%';
|
|
121
123
|
if (isPush && isCollapsed) return headerHeight;
|
|
122
|
-
return _width;
|
|
124
|
+
return "".concat(_width, "px");
|
|
123
125
|
}, [_width, isOverlayFullWidth, isPush, isCollapsed, headerHeight]);
|
|
124
126
|
|
|
127
|
+
// Other UI elements may need to account for the nav width -
|
|
128
|
+
// set a global CSS variable that they can use
|
|
129
|
+
(0, _react.useEffect)(function () {
|
|
130
|
+
setGlobalCSSVariables({
|
|
131
|
+
'--euiCollapsibleNavOffset': isOverlay ? '0' : width
|
|
132
|
+
});
|
|
133
|
+
}, [width, isOverlay, setGlobalCSSVariables]);
|
|
134
|
+
|
|
125
135
|
/**
|
|
126
136
|
* Prop setup
|
|
127
137
|
*/
|
|
@@ -7,16 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.EuiInputPopover = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _react2 = require("@emotion/react");
|
|
10
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
12
|
var _tabbable = require("tabbable");
|
|
12
|
-
var
|
|
13
|
-
var _popover = require("./popover");
|
|
14
|
-
var _resize_observer = require("../observer/resize_observer");
|
|
13
|
+
var _global_styling = require("../../global_styling");
|
|
15
14
|
var _services = require("../../services");
|
|
15
|
+
var _resize_observer = require("../observer/resize_observer");
|
|
16
|
+
var _focus_trap = require("../focus_trap");
|
|
16
17
|
var _form = require("../form/form.styles");
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
18
|
+
var _popover = require("./popover");
|
|
19
|
+
var _excluded = ["children", "className", "closePopover", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
20
20
|
/*
|
|
21
21
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
22
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -28,6 +28,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
28
28
|
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); }
|
|
29
29
|
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; }
|
|
30
30
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
|
+
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; }
|
|
32
|
+
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; }
|
|
33
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
34
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
35
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
31
36
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
32
37
|
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."); }
|
|
33
38
|
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); }
|
|
@@ -37,8 +42,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
37
42
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
38
43
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
39
44
|
var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
45
|
+
var _props$panelProps;
|
|
40
46
|
var children = _ref.children,
|
|
41
47
|
className = _ref.className,
|
|
48
|
+
closePopover = _ref.closePopover,
|
|
42
49
|
_ref$disableFocusTrap = _ref.disableFocusTrap,
|
|
43
50
|
disableFocusTrap = _ref$disableFocusTrap === void 0 ? false : _ref$disableFocusTrap,
|
|
44
51
|
focusTrapProps = _ref.focusTrapProps,
|
|
@@ -51,80 +58,92 @@ var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
|
51
58
|
_inputRef = _ref.inputRef,
|
|
52
59
|
_panelRef = _ref.panelRef,
|
|
53
60
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
|
-
var
|
|
61
|
+
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
62
|
+
var euiTheme = (0, _services.useEuiTheme)();
|
|
63
|
+
var form = (0, _form.euiFormVariables)(euiTheme);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Ref setup
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
var popoverClassRef = (0, _react.useRef)(null);
|
|
70
|
+
// The inputEl state ensures that width is correctly tracked on initial load
|
|
55
71
|
var _useState = (0, _react.useState)(null),
|
|
56
72
|
_useState2 = _slicedToArray(_useState, 2),
|
|
57
73
|
inputEl = _useState2[0],
|
|
58
74
|
setInputEl = _useState2[1];
|
|
59
|
-
|
|
75
|
+
// The panelEl state ensures that width is correctly set every time the popover opens
|
|
76
|
+
var _useState3 = (0, _react.useState)(null),
|
|
60
77
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var _useState5 = (0, _react.useState)(null),
|
|
64
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
65
|
-
panelEl = _useState6[0],
|
|
66
|
-
setPanelEl = _useState6[1];
|
|
67
|
-
var popoverClassRef = (0, _react.useRef)(null);
|
|
78
|
+
panelEl = _useState4[0],
|
|
79
|
+
setPanelEl = _useState4[1];
|
|
68
80
|
var inputRef = (0, _services.useCombinedRefs)([setInputEl, _inputRef]);
|
|
69
81
|
var panelRef = (0, _services.useCombinedRefs)([setPanelEl, _panelRef]);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Sizing/width logic
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
var inputWidth = (0, _resize_observer.useResizeObserver)(inputEl, 'width').width;
|
|
88
|
+
var panelWidth = (0, _react.useMemo)(function () {
|
|
89
|
+
return inputWidth < panelMinWidth ? panelMinWidth : inputWidth;
|
|
90
|
+
}, [panelMinWidth, inputWidth]);
|
|
91
|
+
(0, _react.useEffect)(function () {
|
|
92
|
+
if (panelEl) {
|
|
93
|
+
// We have to modify the popover panel DOM node directly instead of using
|
|
94
|
+
// `panelStyle`, as there's some weird positioning bugs on resize otherwise
|
|
95
|
+
panelEl.style.inlineSize = "".concat(panelWidth, "px");
|
|
76
96
|
}
|
|
77
|
-
}, [panelEl,
|
|
78
|
-
|
|
79
|
-
|
|
97
|
+
}, [panelEl, panelWidth]);
|
|
98
|
+
(0, _react.useEffect)(function () {
|
|
99
|
+
// This fires on all input width changes regardless of minimum size, because on
|
|
100
|
+
// right/center anchored popovers, the input width affects the position of the popover
|
|
101
|
+
if (panelEl) {
|
|
80
102
|
var _popoverClassRef$curr;
|
|
81
|
-
var _width = inputEl.getBoundingClientRect().width;
|
|
82
|
-
setInputElWidth(_width);
|
|
83
|
-
setPanelWidth(_width);
|
|
84
103
|
(_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
|
|
85
104
|
}
|
|
86
|
-
}, [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var onKeyDown = function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
}, [inputWidth, panelEl]);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Popover tab to close logic
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
|
|
112
|
+
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
113
|
+
panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 ? void 0 : panelPropsOnKeyDown(event);
|
|
114
|
+
if (event.key === _services.keys.TAB) {
|
|
115
|
+
if (disableFocusTrap) {
|
|
116
|
+
closePopover();
|
|
117
|
+
} else {
|
|
118
|
+
var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
|
|
119
|
+
return !el.hasAttribute('data-focus-guard');
|
|
120
|
+
});
|
|
121
|
+
if (!tabbableItems.length) return;
|
|
122
|
+
var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
|
|
123
|
+
if (tabbingFromLastItemInPopover) {
|
|
124
|
+
closePopover();
|
|
125
|
+
}
|
|
102
126
|
}
|
|
103
127
|
}
|
|
104
|
-
};
|
|
105
|
-
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
106
|
-
var form = (0, _form.euiFormVariables)(euiThemeContext);
|
|
128
|
+
}, [disableFocusTrap, closePopover, panelPropsOnKeyDown]);
|
|
107
129
|
return (0, _react2.jsx)(_popover.EuiPopover, _extends({
|
|
108
130
|
css: /*#__PURE__*/(0, _react2.css)(fullWidth ? undefined : (0, _global_styling.logicalCSS)('max-width', form.maxWidth), ";label:EuiInputPopover;"),
|
|
109
131
|
repositionToCrossAxis: false,
|
|
110
132
|
ownFocus: false,
|
|
111
|
-
button:
|
|
112
|
-
onResize: onResize
|
|
113
|
-
}, function (resizeRef) {
|
|
114
|
-
return (0, _react2.jsx)("div", {
|
|
115
|
-
ref: resizeRef
|
|
116
|
-
}, input);
|
|
117
|
-
}),
|
|
133
|
+
button: input,
|
|
118
134
|
buttonRef: inputRef,
|
|
119
135
|
panelRef: panelRef,
|
|
120
136
|
className: classes,
|
|
121
|
-
ref: popoverClassRef
|
|
122
|
-
|
|
137
|
+
ref: popoverClassRef,
|
|
138
|
+
closePopover: closePopover
|
|
139
|
+
}, props, {
|
|
140
|
+
panelProps: _objectSpread(_objectSpread({}, props.panelProps), {}, {
|
|
141
|
+
onKeyDown: onKeyDown
|
|
142
|
+
})
|
|
143
|
+
}), (0, _react2.jsx)(_focus_trap.EuiFocusTrap, _extends({
|
|
123
144
|
clickOutsideDisables: true,
|
|
124
145
|
disabled: disableFocusTrap
|
|
125
|
-
}, focusTrapProps),
|
|
126
|
-
onKeyDown: onKeyDown
|
|
127
|
-
}, children)));
|
|
146
|
+
}, focusTrapProps), children));
|
|
128
147
|
};
|
|
129
148
|
exports.EuiInputPopover = EuiInputPopover;
|
|
130
149
|
EuiInputPopover.propTypes = {
|
|
@@ -16,7 +16,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
|
|
17
17
|
import React, { useRef, useMemo, useState, useEffect, useCallback } from 'react';
|
|
18
18
|
import classNames from 'classnames';
|
|
19
|
-
import { useEuiTheme, useGeneratedHtmlId, throttle } from '../../services';
|
|
19
|
+
import { useEuiTheme, useEuiThemeCSSVariables, useGeneratedHtmlId, throttle } from '../../services';
|
|
20
20
|
import { EuiFlyout } from '../flyout';
|
|
21
21
|
import { useEuiI18n } from '../i18n';
|
|
22
22
|
import { euiHeaderVariables } from '../header/header.styles';
|
|
@@ -36,6 +36,8 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
36
36
|
side = _ref$side === void 0 ? 'left' : _ref$side,
|
|
37
37
|
_focusTrapProps = _ref.focusTrapProps,
|
|
38
38
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
|
|
40
|
+
setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
|
|
39
41
|
var euiTheme = useEuiTheme();
|
|
40
42
|
var headerHeight = euiHeaderVariables(euiTheme).height;
|
|
41
43
|
|
|
@@ -94,9 +96,17 @@ var _EuiCollapsibleNavBeta = function _EuiCollapsibleNavBeta(_ref) {
|
|
|
94
96
|
var width = useMemo(function () {
|
|
95
97
|
if (isOverlayFullWidth) return '100%';
|
|
96
98
|
if (isPush && isCollapsed) return headerHeight;
|
|
97
|
-
return _width;
|
|
99
|
+
return "".concat(_width, "px");
|
|
98
100
|
}, [_width, isOverlayFullWidth, isPush, isCollapsed, headerHeight]);
|
|
99
101
|
|
|
102
|
+
// Other UI elements may need to account for the nav width -
|
|
103
|
+
// set a global CSS variable that they can use
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
setGlobalCSSVariables({
|
|
106
|
+
'--euiCollapsibleNavOffset': isOverlay ? '0' : width
|
|
107
|
+
});
|
|
108
|
+
}, [width, isOverlay, setGlobalCSSVariables]);
|
|
109
|
+
|
|
100
110
|
/**
|
|
101
111
|
* Prop setup
|
|
102
112
|
*/
|
|
@@ -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',
|
|
@@ -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
|
*/
|
|
@@ -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 = {
|
package/package.json
CHANGED
|
@@ -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
|
*/
|
|
@@ -7,20 +7,21 @@ 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"));
|
|
13
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
var _react2 = require("@emotion/react");
|
|
14
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
17
|
var _tabbable = require("tabbable");
|
|
16
|
-
var
|
|
17
|
-
var _popover = require("./popover");
|
|
18
|
-
var _resize_observer = require("../observer/resize_observer");
|
|
18
|
+
var _global_styling = require("../../global_styling");
|
|
19
19
|
var _services = require("../../services");
|
|
20
|
+
var _resize_observer = require("../observer/resize_observer");
|
|
21
|
+
var _focus_trap = require("../focus_trap");
|
|
20
22
|
var _form = require("../form/form.styles");
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
23
|
+
var _popover = require("./popover");
|
|
24
|
+
var _excluded = ["children", "className", "closePopover", "disableFocusTrap", "focusTrapProps", "input", "fullWidth", "panelMinWidth", "onPanelResize", "inputRef", "panelRef"];
|
|
24
25
|
/*
|
|
25
26
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
26
27
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -30,9 +31,13 @@ var _excluded = ["children", "className", "disableFocusTrap", "focusTrapProps",
|
|
|
30
31
|
*/
|
|
31
32
|
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); }
|
|
32
33
|
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; }
|
|
34
|
+
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; }
|
|
35
|
+
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; }
|
|
33
36
|
var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
37
|
+
var _props$panelProps;
|
|
34
38
|
var children = _ref.children,
|
|
35
39
|
className = _ref.className,
|
|
40
|
+
closePopover = _ref.closePopover,
|
|
36
41
|
_ref$disableFocusTrap = _ref.disableFocusTrap,
|
|
37
42
|
disableFocusTrap = _ref$disableFocusTrap === void 0 ? false : _ref$disableFocusTrap,
|
|
38
43
|
focusTrapProps = _ref.focusTrapProps,
|
|
@@ -45,80 +50,92 @@ var EuiInputPopover = function EuiInputPopover(_ref) {
|
|
|
45
50
|
_inputRef = _ref.inputRef,
|
|
46
51
|
_panelRef = _ref.panelRef,
|
|
47
52
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
48
|
-
var
|
|
53
|
+
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
54
|
+
var euiTheme = (0, _services.useEuiTheme)();
|
|
55
|
+
var form = (0, _form.euiFormVariables)(euiTheme);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Ref setup
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
var popoverClassRef = (0, _react.useRef)(null);
|
|
62
|
+
// The inputEl state ensures that width is correctly tracked on initial load
|
|
49
63
|
var _useState = (0, _react.useState)(null),
|
|
50
64
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
51
65
|
inputEl = _useState2[0],
|
|
52
66
|
setInputEl = _useState2[1];
|
|
53
|
-
|
|
67
|
+
// The panelEl state ensures that width is correctly set every time the popover opens
|
|
68
|
+
var _useState3 = (0, _react.useState)(null),
|
|
54
69
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _useState5 = (0, _react.useState)(null),
|
|
58
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
59
|
-
panelEl = _useState6[0],
|
|
60
|
-
setPanelEl = _useState6[1];
|
|
61
|
-
var popoverClassRef = (0, _react.useRef)(null);
|
|
70
|
+
panelEl = _useState4[0],
|
|
71
|
+
setPanelEl = _useState4[1];
|
|
62
72
|
var inputRef = (0, _services.useCombinedRefs)([setInputEl, _inputRef]);
|
|
63
73
|
var panelRef = (0, _services.useCombinedRefs)([setPanelEl, _panelRef]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Sizing/width logic
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
var inputWidth = (0, _resize_observer.useResizeObserver)(inputEl, 'width').width;
|
|
80
|
+
var panelWidth = (0, _react.useMemo)(function () {
|
|
81
|
+
return inputWidth < panelMinWidth ? panelMinWidth : inputWidth;
|
|
82
|
+
}, [panelMinWidth, inputWidth]);
|
|
83
|
+
(0, _react.useEffect)(function () {
|
|
84
|
+
if (panelEl) {
|
|
85
|
+
// We have to modify the popover panel DOM node directly instead of using
|
|
86
|
+
// `panelStyle`, as there's some weird positioning bugs on resize otherwise
|
|
87
|
+
panelEl.style.inlineSize = "".concat(panelWidth, "px");
|
|
70
88
|
}
|
|
71
|
-
}, [panelEl,
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
}, [panelEl, panelWidth]);
|
|
90
|
+
(0, _react.useEffect)(function () {
|
|
91
|
+
// This fires on all input width changes regardless of minimum size, because on
|
|
92
|
+
// right/center anchored popovers, the input width affects the position of the popover
|
|
93
|
+
if (panelEl) {
|
|
74
94
|
var _popoverClassRef$curr;
|
|
75
|
-
var _width = inputEl.getBoundingClientRect().width;
|
|
76
|
-
setInputElWidth(_width);
|
|
77
|
-
setPanelWidth(_width);
|
|
78
95
|
(_popoverClassRef$curr = popoverClassRef.current) === null || _popoverClassRef$curr === void 0 ? void 0 : _popoverClassRef$curr.positionPopoverFluid();
|
|
79
96
|
}
|
|
80
|
-
}, [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
var onKeyDown = function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
}, [inputWidth, panelEl]);
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Popover tab to close logic
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
|
|
104
|
+
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
105
|
+
panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 ? void 0 : panelPropsOnKeyDown(event);
|
|
106
|
+
if (event.key === _services.keys.TAB) {
|
|
107
|
+
if (disableFocusTrap) {
|
|
108
|
+
closePopover();
|
|
109
|
+
} else {
|
|
110
|
+
var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
|
|
111
|
+
return !el.hasAttribute('data-focus-guard');
|
|
112
|
+
});
|
|
113
|
+
if (!tabbableItems.length) return;
|
|
114
|
+
var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
|
|
115
|
+
if (tabbingFromLastItemInPopover) {
|
|
116
|
+
closePopover();
|
|
117
|
+
}
|
|
96
118
|
}
|
|
97
119
|
}
|
|
98
|
-
};
|
|
99
|
-
var classes = (0, _classnames.default)('euiInputPopover', className);
|
|
100
|
-
var form = (0, _form.euiFormVariables)(euiThemeContext);
|
|
120
|
+
}, [disableFocusTrap, closePopover, panelPropsOnKeyDown]);
|
|
101
121
|
return (0, _react2.jsx)(_popover.EuiPopover, (0, _extends2.default)({
|
|
102
122
|
css: /*#__PURE__*/(0, _react2.css)(fullWidth ? undefined : (0, _global_styling.logicalCSS)('max-width', form.maxWidth), ";label:EuiInputPopover;"),
|
|
103
123
|
repositionToCrossAxis: false,
|
|
104
124
|
ownFocus: false,
|
|
105
|
-
button:
|
|
106
|
-
onResize: onResize
|
|
107
|
-
}, function (resizeRef) {
|
|
108
|
-
return (0, _react2.jsx)("div", {
|
|
109
|
-
ref: resizeRef
|
|
110
|
-
}, input);
|
|
111
|
-
}),
|
|
125
|
+
button: input,
|
|
112
126
|
buttonRef: inputRef,
|
|
113
127
|
panelRef: panelRef,
|
|
114
128
|
className: classes,
|
|
115
|
-
ref: popoverClassRef
|
|
116
|
-
|
|
129
|
+
ref: popoverClassRef,
|
|
130
|
+
closePopover: closePopover
|
|
131
|
+
}, props, {
|
|
132
|
+
panelProps: _objectSpread(_objectSpread({}, props.panelProps), {}, {
|
|
133
|
+
onKeyDown: onKeyDown
|
|
134
|
+
})
|
|
135
|
+
}), (0, _react2.jsx)(_focus_trap.EuiFocusTrap, (0, _extends2.default)({
|
|
117
136
|
clickOutsideDisables: true,
|
|
118
137
|
disabled: disableFocusTrap
|
|
119
|
-
}, focusTrapProps),
|
|
120
|
-
onKeyDown: onKeyDown
|
|
121
|
-
}, children)));
|
|
138
|
+
}, focusTrapProps), children));
|
|
122
139
|
};
|
|
123
140
|
exports.EuiInputPopover = EuiInputPopover;
|
|
124
141
|
EuiInputPopover.propTypes = {
|