@elastic/eui 106.3.0 → 106.4.0

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.
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style"];
2
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
3
3
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -37,6 +37,7 @@ export var EuiModal = function EuiModal(_ref) {
37
37
  _ref$role = _ref.role,
38
38
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
39
39
  style = _ref.style,
40
+ focusTrapProps = _ref.focusTrapProps,
40
41
  rest = _objectWithoutProperties(_ref, _excluded);
41
42
  var onKeyDown = function onKeyDown(event) {
42
43
  if (event.key === keys.ESCAPE) {
@@ -58,11 +59,11 @@ export var EuiModal = function EuiModal(_ref) {
58
59
  var styles = euiModalStyles(euiTheme);
59
60
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
60
61
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
61
- return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, {
62
+ return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, _extends({}, focusTrapProps, {
62
63
  initialFocus: initialFocus,
63
64
  scrollLock: true,
64
65
  preventScrollOnFocus: true
65
- }, ___EmotionJSX("div", _extends({
66
+ }), ___EmotionJSX("div", _extends({
66
67
  css: cssStyles,
67
68
  className: classes,
68
69
  onKeyDown: onKeyDown,
@@ -108,5 +109,10 @@ EuiModal.propTypes = {
108
109
  * Identifies a modal dialog to screen readers. Modal dialogs that confirm destructive actions
109
110
  * or need a user's attention should use "alertdialog".
110
111
  */
111
- role: PropTypes.oneOf(["dialog", "alertdialog"])
112
+ role: PropTypes.oneOf(["dialog", "alertdialog"]),
113
+ /**
114
+ * Object of props passed to EuiFocusTrap.
115
+ * `returnFocus` defines the return focus behavior and provides the possibility to check the available target element or opt out of the behavior in favor of manually returning focus
116
+ */
117
+ focusTrapProps: PropTypes.any
112
118
  };
@@ -98,7 +98,8 @@ export var EuiPageHeaderContent = function EuiPageHeaderContent(_ref) {
98
98
  // Don't go any further if there's no other content than children
99
99
  if (onlyChildren) {
100
100
  return ___EmotionJSX("div", _extends({
101
- css: cssStyles
101
+ css: cssStyles,
102
+ style: styles
102
103
  }, rest), ___EmotionJSX("div", {
103
104
  css: childrenOnlyStyles
104
105
  }, children));
@@ -123,25 +123,31 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
123
123
  */
124
124
 
125
125
  var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
126
+ var handleTabNavigation = useCallback(function (e) {
127
+ var tabbableItems = tabbable(e.currentTarget).filter(function (el) {
128
+ return !el.hasAttribute('data-focus-guard');
129
+ });
130
+ if (!tabbableItems.length) return;
131
+ var tabbingFromFirstItemInPopover = document.activeElement === tabbableItems[0];
132
+ var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
133
+ if (tabbingFromFirstItemInPopover && e.shiftKey || tabbingFromLastItemInPopover && !e.shiftKey) {
134
+ closePopover();
135
+ }
136
+ }, [closePopover]);
126
137
  var onKeyDown = useCallback(function (event) {
127
138
  panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 || panelPropsOnKeyDown(event);
128
139
  if (event.key === keys.TAB) {
129
140
  if (disableFocusTrap) {
130
141
  if (!ownFocus) {
131
- closePopover();
142
+ handleTabNavigation(event);
132
143
  }
133
144
  } else {
134
- var tabbableItems = tabbable(event.currentTarget).filter(function (el) {
135
- return !el.hasAttribute('data-focus-guard');
136
- });
137
- if (!tabbableItems.length) return;
138
- var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
139
- if (tabbingFromLastItemInPopover) {
140
- closePopover();
145
+ if (!ownFocus) {
146
+ handleTabNavigation(event);
141
147
  }
142
148
  }
143
149
  }
144
- }, [disableFocusTrap, ownFocus, closePopover, panelPropsOnKeyDown]);
150
+ }, [disableFocusTrap, ownFocus, panelPropsOnKeyDown, handleTabNavigation]);
145
151
 
146
152
  /**
147
153
  * Optional close on scroll behavior
package/eui.d.ts CHANGED
@@ -11556,7 +11556,7 @@ declare module '@elastic/eui/src/components/form/range/types' {
11556
11556
  * Allows customizing the underlying [EuiInputPopover](/#/layout/popover#popover-attached-to-input-element),
11557
11557
  * except for props controlled by the range component
11558
11558
  */
11559
- inputPopoverProps?: Omit<EuiInputPopoverProps, 'input' | 'isOpen' | 'closePopover' | 'disableFocusTrap' | 'popoverScreenReaderText' | 'fullWidth'>;
11559
+ inputPopoverProps?: Omit<EuiInputPopoverProps, 'input' | 'isOpen' | 'closePopover' | 'disableFocusTrap' | 'ownFocus' | 'popoverScreenReaderText' | 'fullWidth'>;
11560
11560
  }
11561
11561
  export type _SharedRangeInputSide = {
11562
11562
  /**
@@ -20822,6 +20822,7 @@ declare module '@elastic/eui/src/components/modal/modal.styles' {
20822
20822
  }
20823
20823
  declare module '@elastic/eui/src/components/modal/modal' {
20824
20824
  import React, { FunctionComponent, ReactNode, HTMLAttributes } from 'react';
20825
+ import { EuiFocusTrapProps } from '@elastic/eui/src/components/focus_trap';
20825
20826
  export interface EuiModalProps extends HTMLAttributes<HTMLDivElement> {
20826
20827
  className?: string;
20827
20828
  /**
@@ -20847,6 +20848,11 @@ declare module '@elastic/eui/src/components/modal/modal' {
20847
20848
  * or need a user's attention should use "alertdialog".
20848
20849
  */
20849
20850
  role?: 'dialog' | 'alertdialog';
20851
+ /**
20852
+ * Object of props passed to EuiFocusTrap.
20853
+ * `returnFocus` defines the return focus behavior and provides the possibility to check the available target element or opt out of the behavior in favor of manually returning focus
20854
+ */
20855
+ focusTrapProps?: Pick<EuiFocusTrapProps, 'returnFocus'>;
20850
20856
  }
20851
20857
  export const EuiModal: FunctionComponent<EuiModalProps>;
20852
20858
 
@@ -16,7 +16,7 @@ var _overlay_mask = require("../overlay_mask");
16
16
  var _i18n = require("../i18n");
17
17
  var _modal = require("./modal.styles");
18
18
  var _react2 = require("@emotion/react");
19
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style"];
19
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
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
@@ -43,6 +43,7 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
43
43
  _ref$role = _ref.role,
44
44
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
45
45
  style = _ref.style,
46
+ focusTrapProps = _ref.focusTrapProps,
46
47
  rest = _objectWithoutProperties(_ref, _excluded);
47
48
  var onKeyDown = function onKeyDown(event) {
48
49
  if (event.key === _services.keys.ESCAPE) {
@@ -64,11 +65,11 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
64
65
  var styles = (0, _modal.euiModalStyles)(euiTheme);
65
66
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
66
67
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
67
- return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
68
+ return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, _extends({}, focusTrapProps, {
68
69
  initialFocus: initialFocus,
69
70
  scrollLock: true,
70
71
  preventScrollOnFocus: true
71
- }, (0, _react2.jsx)("div", _extends({
72
+ }), (0, _react2.jsx)("div", _extends({
72
73
  css: cssStyles,
73
74
  className: classes,
74
75
  onKeyDown: onKeyDown,
@@ -114,5 +115,10 @@ EuiModal.propTypes = {
114
115
  * Identifies a modal dialog to screen readers. Modal dialogs that confirm destructive actions
115
116
  * or need a user's attention should use "alertdialog".
116
117
  */
117
- role: _propTypes.default.oneOf(["dialog", "alertdialog"])
118
+ role: _propTypes.default.oneOf(["dialog", "alertdialog"]),
119
+ /**
120
+ * Object of props passed to EuiFocusTrap.
121
+ * `returnFocus` defines the return focus behavior and provides the possibility to check the available target element or opt out of the behavior in favor of manually returning focus
122
+ */
123
+ focusTrapProps: _propTypes.default.any
118
124
  };
@@ -104,7 +104,8 @@ var EuiPageHeaderContent = exports.EuiPageHeaderContent = function EuiPageHeader
104
104
  // Don't go any further if there's no other content than children
105
105
  if (onlyChildren) {
106
106
  return (0, _react2.jsx)("div", _extends({
107
- css: cssStyles
107
+ css: cssStyles,
108
+ style: styles
108
109
  }, rest), (0, _react2.jsx)("div", {
109
110
  css: childrenOnlyStyles
110
111
  }, children));
@@ -130,25 +130,31 @@ var EuiInputPopover = exports.EuiInputPopover = function EuiInputPopover(_ref) {
130
130
  */
131
131
 
132
132
  var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
133
+ var handleTabNavigation = (0, _react.useCallback)(function (e) {
134
+ var tabbableItems = (0, _tabbable.tabbable)(e.currentTarget).filter(function (el) {
135
+ return !el.hasAttribute('data-focus-guard');
136
+ });
137
+ if (!tabbableItems.length) return;
138
+ var tabbingFromFirstItemInPopover = document.activeElement === tabbableItems[0];
139
+ var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
140
+ if (tabbingFromFirstItemInPopover && e.shiftKey || tabbingFromLastItemInPopover && !e.shiftKey) {
141
+ closePopover();
142
+ }
143
+ }, [closePopover]);
133
144
  var onKeyDown = (0, _react.useCallback)(function (event) {
134
145
  panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 || panelPropsOnKeyDown(event);
135
146
  if (event.key === _services.keys.TAB) {
136
147
  if (disableFocusTrap) {
137
148
  if (!ownFocus) {
138
- closePopover();
149
+ handleTabNavigation(event);
139
150
  }
140
151
  } else {
141
- var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
142
- return !el.hasAttribute('data-focus-guard');
143
- });
144
- if (!tabbableItems.length) return;
145
- var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
146
- if (tabbingFromLastItemInPopover) {
147
- closePopover();
152
+ if (!ownFocus) {
153
+ handleTabNavigation(event);
148
154
  }
149
155
  }
150
156
  }
151
- }, [disableFocusTrap, ownFocus, closePopover, panelPropsOnKeyDown]);
157
+ }, [disableFocusTrap, ownFocus, panelPropsOnKeyDown, handleTabNavigation]);
152
158
 
153
159
  /**
154
160
  * Optional close on scroll behavior
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style"];
4
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  /*
@@ -32,6 +32,7 @@ export var EuiModal = function EuiModal(_ref) {
32
32
  _ref$role = _ref.role,
33
33
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
34
34
  style = _ref.style,
35
+ focusTrapProps = _ref.focusTrapProps,
35
36
  rest = _objectWithoutProperties(_ref, _excluded);
36
37
  var onKeyDown = function onKeyDown(event) {
37
38
  if (event.key === keys.ESCAPE) {
@@ -53,11 +54,11 @@ export var EuiModal = function EuiModal(_ref) {
53
54
  var styles = euiModalStyles(euiTheme);
54
55
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
55
56
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
56
- return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, {
57
+ return ___EmotionJSX(EuiOverlayMask, null, ___EmotionJSX(EuiFocusTrap, _extends({}, focusTrapProps, {
57
58
  initialFocus: initialFocus,
58
59
  scrollLock: true,
59
60
  preventScrollOnFocus: true
60
- }, ___EmotionJSX("div", _extends({
61
+ }), ___EmotionJSX("div", _extends({
61
62
  css: cssStyles,
62
63
  className: classes,
63
64
  onKeyDown: onKeyDown,
@@ -91,7 +91,8 @@ export var EuiPageHeaderContent = function EuiPageHeaderContent(_ref) {
91
91
  // Don't go any further if there's no other content than children
92
92
  if (onlyChildren) {
93
93
  return ___EmotionJSX("div", _extends({
94
- css: cssStyles
94
+ css: cssStyles,
95
+ style: styles
95
96
  }, rest), ___EmotionJSX("div", {
96
97
  css: childrenOnlyStyles
97
98
  }, children));
@@ -113,25 +113,31 @@ export var EuiInputPopover = function EuiInputPopover(_ref) {
113
113
  */
114
114
 
115
115
  var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
116
+ var handleTabNavigation = useCallback(function (e) {
117
+ var tabbableItems = tabbable(e.currentTarget).filter(function (el) {
118
+ return !el.hasAttribute('data-focus-guard');
119
+ });
120
+ if (!tabbableItems.length) return;
121
+ var tabbingFromFirstItemInPopover = document.activeElement === tabbableItems[0];
122
+ var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
123
+ if (tabbingFromFirstItemInPopover && e.shiftKey || tabbingFromLastItemInPopover && !e.shiftKey) {
124
+ closePopover();
125
+ }
126
+ }, [closePopover]);
116
127
  var onKeyDown = useCallback(function (event) {
117
128
  panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 || panelPropsOnKeyDown(event);
118
129
  if (event.key === keys.TAB) {
119
130
  if (disableFocusTrap) {
120
131
  if (!ownFocus) {
121
- closePopover();
132
+ handleTabNavigation(event);
122
133
  }
123
134
  } else {
124
- var tabbableItems = tabbable(event.currentTarget).filter(function (el) {
125
- return !el.hasAttribute('data-focus-guard');
126
- });
127
- if (!tabbableItems.length) return;
128
- var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
129
- if (tabbingFromLastItemInPopover) {
130
- closePopover();
135
+ if (!ownFocus) {
136
+ handleTabNavigation(event);
131
137
  }
132
138
  }
133
139
  }
134
- }, [disableFocusTrap, ownFocus, closePopover, panelPropsOnKeyDown]);
140
+ }, [disableFocusTrap, ownFocus, panelPropsOnKeyDown, handleTabNavigation]);
135
141
 
136
142
  /**
137
143
  * Optional close on scroll behavior
@@ -18,7 +18,7 @@ var _overlay_mask = require("../overlay_mask");
18
18
  var _i18n = require("../i18n");
19
19
  var _modal = require("./modal.styles");
20
20
  var _react2 = require("@emotion/react");
21
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style"];
21
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
22
22
  /*
23
23
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
24
24
  * or more contributor license agreements. Licensed under the Elastic License
@@ -38,6 +38,7 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
38
38
  _ref$role = _ref.role,
39
39
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
40
40
  style = _ref.style,
41
+ focusTrapProps = _ref.focusTrapProps,
41
42
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
42
43
  var onKeyDown = function onKeyDown(event) {
43
44
  if (event.key === _services.keys.ESCAPE) {
@@ -59,11 +60,11 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
59
60
  var styles = (0, _modal.euiModalStyles)(euiTheme);
60
61
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
61
62
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
62
- return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
63
+ return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, (0, _extends2.default)({}, focusTrapProps, {
63
64
  initialFocus: initialFocus,
64
65
  scrollLock: true,
65
66
  preventScrollOnFocus: true
66
- }, (0, _react2.jsx)("div", (0, _extends2.default)({
67
+ }), (0, _react2.jsx)("div", (0, _extends2.default)({
67
68
  css: cssStyles,
68
69
  className: classes,
69
70
  onKeyDown: onKeyDown,
@@ -97,7 +97,8 @@ var EuiPageHeaderContent = exports.EuiPageHeaderContent = function EuiPageHeader
97
97
  // Don't go any further if there's no other content than children
98
98
  if (onlyChildren) {
99
99
  return (0, _react2.jsx)("div", (0, _extends2.default)({
100
- css: cssStyles
100
+ css: cssStyles,
101
+ style: styles
101
102
  }, rest), (0, _react2.jsx)("div", {
102
103
  css: childrenOnlyStyles
103
104
  }, children));
@@ -121,25 +121,31 @@ var EuiInputPopover = exports.EuiInputPopover = function EuiInputPopover(_ref) {
121
121
  */
122
122
 
123
123
  var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
124
+ var handleTabNavigation = (0, _react.useCallback)(function (e) {
125
+ var tabbableItems = (0, _tabbable.tabbable)(e.currentTarget).filter(function (el) {
126
+ return !el.hasAttribute('data-focus-guard');
127
+ });
128
+ if (!tabbableItems.length) return;
129
+ var tabbingFromFirstItemInPopover = document.activeElement === tabbableItems[0];
130
+ var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
131
+ if (tabbingFromFirstItemInPopover && e.shiftKey || tabbingFromLastItemInPopover && !e.shiftKey) {
132
+ closePopover();
133
+ }
134
+ }, [closePopover]);
124
135
  var onKeyDown = (0, _react.useCallback)(function (event) {
125
136
  panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 || panelPropsOnKeyDown(event);
126
137
  if (event.key === _services.keys.TAB) {
127
138
  if (disableFocusTrap) {
128
139
  if (!ownFocus) {
129
- closePopover();
140
+ handleTabNavigation(event);
130
141
  }
131
142
  } else {
132
- var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
133
- return !el.hasAttribute('data-focus-guard');
134
- });
135
- if (!tabbableItems.length) return;
136
- var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
137
- if (tabbingFromLastItemInPopover) {
138
- closePopover();
143
+ if (!ownFocus) {
144
+ handleTabNavigation(event);
139
145
  }
140
146
  }
141
147
  }
142
- }, [disableFocusTrap, ownFocus, closePopover, panelPropsOnKeyDown]);
148
+ }, [disableFocusTrap, ownFocus, panelPropsOnKeyDown, handleTabNavigation]);
143
149
 
144
150
  /**
145
151
  * Optional close on scroll behavior
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elastic/eui",
3
3
  "description": "Elastic UI Component Library",
4
- "version": "106.3.0",
4
+ "version": "106.4.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "lib",
7
7
  "module": "es",
@@ -107,7 +107,7 @@
107
107
  "@cypress/webpack-dev-server": "^1.7.0",
108
108
  "@elastic/charts": "^64.1.0",
109
109
  "@elastic/datemath": "^5.0.3",
110
- "@elastic/eui-theme-borealis": "3.3.1",
110
+ "@elastic/eui-theme-borealis": "3.3.2",
111
111
  "@emotion/babel-preset-css-prop": "^11.11.0",
112
112
  "@emotion/cache": "^11.11.0",
113
113
  "@emotion/css": "^11.11.0",
@@ -257,7 +257,7 @@
257
257
  },
258
258
  "peerDependencies": {
259
259
  "@elastic/datemath": "^5.0.2",
260
- "@elastic/eui-theme-borealis": "3.3.1",
260
+ "@elastic/eui-theme-borealis": "3.3.2",
261
261
  "@emotion/css": "11.x",
262
262
  "@emotion/react": "11.x",
263
263
  "@types/react": "^17.0 || ^18.0",
@@ -121,8 +121,8 @@ $euiColorBorderBaseFloating: $euiColorLightShade !default;
121
121
  $euiColorBorderBaseFormsColorSwatch: transparentize($euiColorFullShade, 0.1) !default;
122
122
  $euiColorBorderBaseFormsControl: tint($euiColorLightestShade, 0.31) !default;
123
123
 
124
- $euiColorBorderInteractiveFormsHoverPlain: 'transparent' !default;
125
- $euiColorBorderInteractiveFormsHoverDanger: 'transparent' !default;
124
+ $euiColorBorderInteractiveFormsHoverPlain: transparent !default;
125
+ $euiColorBorderInteractiveFormsHoverDanger: transparent !default;
126
126
 
127
127
  $euiColorBorderStrongPrimary: $euiColorPrimary !default;
128
128
  $euiColorBorderStrongAccent: $euiColorAccent !default;
@@ -117,12 +117,12 @@ $euiColorBorderBaseDanger: tint($euiColorDanger, 0.6) !default;
117
117
  $euiColorBorderBasePlain: $euiColorLightShade !default;
118
118
  $euiColorBorderBaseSubdued: $euiColorLightShade !default;
119
119
  $euiColorBorderBaseDisabled: transparentize(darken($euiColorLightShade, 40%), 0.1) !default;
120
- $euiColorBorderBaseFloating: 'transparent' !default;
120
+ $euiColorBorderBaseFloating: transparent !default;
121
121
  $euiColorBorderBaseFormsColorSwatch: transparentize($euiColorFullShade, 0.1) !default;
122
122
  $euiColorBorderBaseFormsControl: shade($euiColorLightestShade, 0.4) !default;
123
123
 
124
- $euiColorBorderInteractiveFormsHoverPlain: 'transparent' !default;
125
- $euiColorBorderInteractiveFormsHoverDanger: 'transparent' !default;
124
+ $euiColorBorderInteractiveFormsHoverPlain: transparent !default;
125
+ $euiColorBorderInteractiveFormsHoverDanger: transparent !default;
126
126
 
127
127
  $euiColorBorderStrongPrimary: $euiColorPrimary !default;
128
128
  $euiColorBorderStrongAccent: $euiColorAccent !default;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.EuiFlyout = void 0;
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
9
  var _react2 = require("@emotion/react");
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
12
  /*
11
13
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
14
  * or more contributor license agreements. Licensed under the Elastic License
@@ -15,7 +17,7 @@ var _react2 = require("@emotion/react");
15
17
  * Side Public License, v 1.
16
18
  */
17
19
 
18
- var EuiFlyout = exports.EuiFlyout = function EuiFlyout(_ref) {
20
+ var EuiFlyout = exports.EuiFlyout = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
19
21
  var _ref$as = _ref.as,
20
22
  as = _ref$as === void 0 ? 'div' : _ref$as,
21
23
  _ref$role = _ref.role,
@@ -28,6 +30,7 @@ var EuiFlyout = exports.EuiFlyout = function EuiFlyout(_ref) {
28
30
  dataTestSubj = _ref['data-test-subj'];
29
31
  var Element = as;
30
32
  return (0, _react2.jsx)(Element, {
33
+ ref: ref,
31
34
  "data-eui": "EuiFlyout",
32
35
  "data-test-subj": dataTestSubj,
33
36
  role: role,
@@ -41,4 +44,5 @@ var EuiFlyout = exports.EuiFlyout = function EuiFlyout(_ref) {
41
44
  (closeButtonProps === null || closeButtonProps === void 0 ? void 0 : closeButtonProps.onClick) && closeButtonProps.onClick(e);
42
45
  }
43
46
  }), children);
44
- };
47
+ });
48
+ EuiFlyout.displayName = 'EuiFlyout';
@@ -19,7 +19,7 @@ var _overlay_mask = require("../overlay_mask");
19
19
  var _i18n = require("../i18n");
20
20
  var _modal = require("./modal.styles");
21
21
  var _react2 = require("@emotion/react");
22
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style"];
22
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
23
23
  /*
24
24
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
25
25
  * or more contributor license agreements. Licensed under the Elastic License
@@ -39,6 +39,7 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
39
39
  _ref$role = _ref.role,
40
40
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
41
41
  style = _ref.style,
42
+ focusTrapProps = _ref.focusTrapProps,
42
43
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
43
44
  var onKeyDown = function onKeyDown(event) {
44
45
  if (event.key === _services.keys.ESCAPE) {
@@ -60,11 +61,11 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
60
61
  var styles = (0, _modal.euiModalStyles)(euiTheme);
61
62
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
62
63
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
63
- return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
64
+ return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, (0, _extends2.default)({}, focusTrapProps, {
64
65
  initialFocus: initialFocus,
65
66
  scrollLock: true,
66
67
  preventScrollOnFocus: true
67
- }, (0, _react2.jsx)("div", (0, _extends2.default)({
68
+ }), (0, _react2.jsx)("div", (0, _extends2.default)({
68
69
  css: cssStyles,
69
70
  className: classes,
70
71
  onKeyDown: onKeyDown,
@@ -110,5 +111,10 @@ EuiModal.propTypes = {
110
111
  * Identifies a modal dialog to screen readers. Modal dialogs that confirm destructive actions
111
112
  * or need a user's attention should use "alertdialog".
112
113
  */
113
- role: _propTypes.default.oneOf(["dialog", "alertdialog"])
114
+ role: _propTypes.default.oneOf(["dialog", "alertdialog"]),
115
+ /**
116
+ * Object of props passed to EuiFocusTrap.
117
+ * `returnFocus` defines the return focus behavior and provides the possibility to check the available target element or opt out of the behavior in favor of manually returning focus
118
+ */
119
+ focusTrapProps: _propTypes.default.any
114
120
  };
@@ -98,7 +98,8 @@ var EuiPageHeaderContent = exports.EuiPageHeaderContent = function EuiPageHeader
98
98
  // Don't go any further if there's no other content than children
99
99
  if (onlyChildren) {
100
100
  return (0, _react2.jsx)("div", (0, _extends2.default)({
101
- css: cssStyles
101
+ css: cssStyles,
102
+ style: styles
102
103
  }, rest), (0, _react2.jsx)("div", {
103
104
  css: childrenOnlyStyles
104
105
  }, children));
@@ -122,25 +122,31 @@ var EuiInputPopover = exports.EuiInputPopover = function EuiInputPopover(_ref) {
122
122
  */
123
123
 
124
124
  var panelPropsOnKeyDown = (_props$panelProps = props.panelProps) === null || _props$panelProps === void 0 ? void 0 : _props$panelProps.onKeyDown;
125
+ var handleTabNavigation = (0, _react.useCallback)(function (e) {
126
+ var tabbableItems = (0, _tabbable.tabbable)(e.currentTarget).filter(function (el) {
127
+ return !el.hasAttribute('data-focus-guard');
128
+ });
129
+ if (!tabbableItems.length) return;
130
+ var tabbingFromFirstItemInPopover = document.activeElement === tabbableItems[0];
131
+ var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
132
+ if (tabbingFromFirstItemInPopover && e.shiftKey || tabbingFromLastItemInPopover && !e.shiftKey) {
133
+ closePopover();
134
+ }
135
+ }, [closePopover]);
125
136
  var onKeyDown = (0, _react.useCallback)(function (event) {
126
137
  panelPropsOnKeyDown === null || panelPropsOnKeyDown === void 0 || panelPropsOnKeyDown(event);
127
138
  if (event.key === _services.keys.TAB) {
128
139
  if (disableFocusTrap) {
129
140
  if (!ownFocus) {
130
- closePopover();
141
+ handleTabNavigation(event);
131
142
  }
132
143
  } else {
133
- var tabbableItems = (0, _tabbable.tabbable)(event.currentTarget).filter(function (el) {
134
- return !el.hasAttribute('data-focus-guard');
135
- });
136
- if (!tabbableItems.length) return;
137
- var tabbingFromLastItemInPopover = document.activeElement === tabbableItems[tabbableItems.length - 1];
138
- if (tabbingFromLastItemInPopover) {
139
- closePopover();
144
+ if (!ownFocus) {
145
+ handleTabNavigation(event);
140
146
  }
141
147
  }
142
148
  }
143
- }, [disableFocusTrap, ownFocus, closePopover, panelPropsOnKeyDown]);
149
+ }, [disableFocusTrap, ownFocus, panelPropsOnKeyDown, handleTabNavigation]);
144
150
 
145
151
  /**
146
152
  * Optional close on scroll behavior