@elastic/eui 110.0.0 → 111.0.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.
Files changed (237) hide show
  1. package/es/components/collapsible_nav/collapsible_nav.js +20 -101
  2. package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +1 -0
  3. package/es/components/flyout/_flyout_overlay.js +52 -0
  4. package/es/components/flyout/_flyout_resize_button.js +32 -0
  5. package/es/components/flyout/{flyout_resizable.styles.js → _flyout_resize_button.styles.js} +11 -11
  6. package/es/components/flyout/const.js +42 -0
  7. package/es/components/flyout/flyout.component.js +481 -0
  8. package/es/components/flyout/flyout.js +77 -379
  9. package/es/components/flyout/flyout.styles.js +105 -7
  10. package/es/components/flyout/flyout_menu.js +241 -0
  11. package/es/components/flyout/flyout_menu.styles.js +19 -0
  12. package/{optimize/es/components/flyout/flyout_context.js → es/components/flyout/flyout_menu_context.js} +1 -7
  13. package/es/components/flyout/flyout_parent_context.js +36 -0
  14. package/es/components/flyout/flyout_resizable.js +33 -144
  15. package/es/components/flyout/hooks.js +25 -0
  16. package/es/components/flyout/index.js +5 -2
  17. package/es/components/flyout/manager/actions.js +153 -0
  18. package/es/components/flyout/manager/activity_stage.js +95 -0
  19. package/es/components/flyout/manager/const.js +56 -0
  20. package/es/components/flyout/manager/context.js +33 -0
  21. package/es/components/flyout/manager/flyout_child.js +75 -0
  22. package/es/components/flyout/manager/flyout_main.js +65 -0
  23. package/es/components/flyout/manager/flyout_main.styles.js +25 -0
  24. package/es/components/flyout/manager/flyout_managed.js +227 -0
  25. package/es/components/flyout/manager/flyout_managed.styles.js +69 -0
  26. package/es/components/flyout/manager/hooks.js +55 -0
  27. package/es/components/flyout/manager/index.js +31 -0
  28. package/es/components/flyout/manager/layout_mode.js +167 -0
  29. package/es/components/flyout/manager/provider.js +57 -0
  30. package/es/components/flyout/manager/reducer.js +320 -0
  31. package/es/components/flyout/manager/selectors.js +116 -0
  32. package/es/components/flyout/manager/store.js +113 -0
  33. package/es/components/flyout/manager/validation.js +85 -0
  34. package/es/components/flyout/use_flyout_resizable.js +149 -0
  35. package/es/components/flyout/use_flyout_z_index.js +46 -0
  36. package/es/components/overlay_mask/overlay_mask.js +13 -3
  37. package/es/components/overlay_mask/overlay_mask.styles.js +11 -2
  38. package/es/components/provider/provider.js +2 -1
  39. package/eui.d.ts +1484 -921
  40. package/i18ntokens.json +1207 -1153
  41. package/lib/components/collapsible_nav/collapsible_nav.js +20 -101
  42. package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +1 -0
  43. package/lib/components/flyout/_flyout_overlay.js +59 -0
  44. package/lib/components/flyout/_flyout_resize_button.js +38 -0
  45. package/{test-env/components/flyout/flyout_resizable.styles.js → lib/components/flyout/_flyout_resize_button.styles.js} +12 -12
  46. package/lib/components/flyout/const.js +49 -0
  47. package/lib/components/flyout/flyout.component.js +488 -0
  48. package/lib/components/flyout/flyout.js +102 -379
  49. package/lib/components/flyout/flyout.styles.js +105 -7
  50. package/lib/components/flyout/flyout_menu.js +243 -0
  51. package/lib/components/flyout/flyout_menu.styles.js +25 -0
  52. package/{optimize/lib/components/flyout/flyout_context.js → lib/components/flyout/flyout_menu_context.js} +2 -7
  53. package/lib/components/flyout/flyout_parent_context.js +43 -0
  54. package/lib/components/flyout/flyout_resizable.js +36 -147
  55. package/lib/components/flyout/hooks.js +30 -0
  56. package/lib/components/flyout/index.js +21 -14
  57. package/lib/components/flyout/manager/actions.js +159 -0
  58. package/lib/components/flyout/manager/activity_stage.js +101 -0
  59. package/lib/components/flyout/manager/const.js +62 -0
  60. package/lib/components/flyout/manager/context.js +41 -0
  61. package/lib/components/flyout/manager/flyout_child.js +80 -0
  62. package/lib/components/flyout/manager/flyout_main.js +70 -0
  63. package/lib/components/flyout/manager/flyout_main.styles.js +31 -0
  64. package/lib/components/flyout/manager/flyout_managed.js +233 -0
  65. package/lib/components/flyout/manager/flyout_managed.styles.js +73 -0
  66. package/lib/components/flyout/manager/hooks.js +131 -0
  67. package/lib/components/flyout/manager/index.js +168 -0
  68. package/lib/components/flyout/manager/layout_mode.js +171 -0
  69. package/lib/components/flyout/manager/provider.js +63 -0
  70. package/lib/components/flyout/manager/reducer.js +325 -0
  71. package/lib/components/flyout/manager/selectors.js +122 -0
  72. package/lib/components/flyout/manager/store.js +120 -0
  73. package/lib/components/flyout/manager/validation.js +94 -0
  74. package/lib/components/flyout/use_flyout_resizable.js +153 -0
  75. package/lib/components/flyout/use_flyout_z_index.js +51 -0
  76. package/lib/components/overlay_mask/overlay_mask.js +12 -2
  77. package/lib/components/overlay_mask/overlay_mask.styles.js +11 -4
  78. package/lib/components/provider/provider.js +2 -1
  79. package/optimize/es/components/collapsible_nav/collapsible_nav.js +1 -0
  80. package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +1 -0
  81. package/optimize/es/components/flyout/_flyout_overlay.js +52 -0
  82. package/optimize/es/components/flyout/_flyout_resize_button.js +31 -0
  83. package/optimize/es/components/flyout/{flyout_resizable.styles.js → _flyout_resize_button.styles.js} +11 -11
  84. package/optimize/es/components/flyout/const.js +42 -0
  85. package/optimize/es/components/flyout/flyout.component.js +469 -0
  86. package/optimize/es/components/flyout/flyout.js +53 -349
  87. package/optimize/es/components/flyout/flyout.styles.js +102 -7
  88. package/optimize/es/components/flyout/flyout_menu.js +162 -0
  89. package/optimize/es/components/flyout/flyout_menu.styles.js +19 -0
  90. package/{es/components/flyout/flyout_context.js → optimize/es/components/flyout/flyout_menu_context.js} +1 -7
  91. package/optimize/es/components/flyout/flyout_parent_context.js +36 -0
  92. package/optimize/es/components/flyout/flyout_resizable.js +7 -138
  93. package/optimize/es/components/flyout/hooks.js +25 -0
  94. package/optimize/es/components/flyout/index.js +5 -2
  95. package/optimize/es/components/flyout/manager/actions.js +153 -0
  96. package/optimize/es/components/flyout/manager/activity_stage.js +95 -0
  97. package/optimize/es/components/flyout/manager/const.js +56 -0
  98. package/optimize/es/components/flyout/manager/context.js +33 -0
  99. package/optimize/es/components/flyout/manager/flyout_child.js +71 -0
  100. package/optimize/es/components/flyout/manager/flyout_main.js +61 -0
  101. package/optimize/es/components/flyout/manager/flyout_main.styles.js +25 -0
  102. package/optimize/es/components/flyout/manager/flyout_managed.js +223 -0
  103. package/optimize/es/components/flyout/manager/flyout_managed.styles.js +69 -0
  104. package/optimize/es/components/flyout/manager/hooks.js +55 -0
  105. package/optimize/es/components/flyout/manager/index.js +31 -0
  106. package/optimize/es/components/flyout/manager/layout_mode.js +162 -0
  107. package/optimize/es/components/flyout/manager/provider.js +53 -0
  108. package/optimize/es/components/flyout/manager/reducer.js +312 -0
  109. package/optimize/es/components/flyout/manager/selectors.js +116 -0
  110. package/optimize/es/components/flyout/manager/store.js +113 -0
  111. package/optimize/es/components/flyout/manager/types.js +1 -0
  112. package/optimize/es/components/flyout/manager/validation.js +85 -0
  113. package/optimize/es/components/flyout/types.js +1 -0
  114. package/optimize/es/components/flyout/use_flyout_resizable.js +144 -0
  115. package/optimize/es/components/flyout/use_flyout_z_index.js +46 -0
  116. package/optimize/es/components/overlay_mask/overlay_mask.js +13 -3
  117. package/optimize/es/components/overlay_mask/overlay_mask.styles.js +11 -2
  118. package/optimize/es/components/provider/provider.js +2 -1
  119. package/optimize/lib/components/collapsible_nav/collapsible_nav.js +1 -0
  120. package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +1 -0
  121. package/optimize/lib/components/flyout/_flyout_overlay.js +62 -0
  122. package/optimize/lib/components/flyout/_flyout_resize_button.js +37 -0
  123. package/{lib/components/flyout/flyout_resizable.styles.js → optimize/lib/components/flyout/_flyout_resize_button.styles.js} +12 -12
  124. package/optimize/lib/components/flyout/const.js +49 -0
  125. package/optimize/lib/components/flyout/flyout.component.js +477 -0
  126. package/optimize/lib/components/flyout/flyout.js +77 -349
  127. package/optimize/lib/components/flyout/flyout.styles.js +102 -7
  128. package/optimize/lib/components/flyout/flyout_menu.js +168 -0
  129. package/optimize/lib/components/flyout/flyout_menu.styles.js +25 -0
  130. package/{lib/components/flyout/flyout_context.js → optimize/lib/components/flyout/flyout_menu_context.js} +2 -7
  131. package/optimize/lib/components/flyout/flyout_parent_context.js +43 -0
  132. package/optimize/lib/components/flyout/flyout_resizable.js +9 -139
  133. package/optimize/lib/components/flyout/hooks.js +30 -0
  134. package/optimize/lib/components/flyout/index.js +21 -14
  135. package/optimize/lib/components/flyout/manager/actions.js +159 -0
  136. package/optimize/lib/components/flyout/manager/activity_stage.js +101 -0
  137. package/optimize/lib/components/flyout/manager/const.js +62 -0
  138. package/optimize/lib/components/flyout/manager/context.js +41 -0
  139. package/optimize/lib/components/flyout/manager/flyout_child.js +76 -0
  140. package/optimize/lib/components/flyout/manager/flyout_main.js +66 -0
  141. package/optimize/lib/components/flyout/manager/flyout_main.styles.js +31 -0
  142. package/optimize/lib/components/flyout/manager/flyout_managed.js +231 -0
  143. package/optimize/lib/components/flyout/manager/flyout_managed.styles.js +74 -0
  144. package/optimize/lib/components/flyout/manager/hooks.js +131 -0
  145. package/optimize/lib/components/flyout/manager/index.js +168 -0
  146. package/optimize/lib/components/flyout/manager/layout_mode.js +169 -0
  147. package/optimize/lib/components/flyout/manager/provider.js +61 -0
  148. package/optimize/lib/components/flyout/manager/reducer.js +318 -0
  149. package/optimize/lib/components/flyout/manager/selectors.js +122 -0
  150. package/optimize/lib/components/flyout/manager/store.js +120 -0
  151. package/optimize/lib/components/flyout/manager/validation.js +94 -0
  152. package/optimize/lib/components/flyout/types.js +5 -0
  153. package/optimize/lib/components/flyout/use_flyout_resizable.js +151 -0
  154. package/optimize/lib/components/flyout/use_flyout_z_index.js +51 -0
  155. package/optimize/lib/components/overlay_mask/overlay_mask.js +12 -2
  156. package/optimize/lib/components/overlay_mask/overlay_mask.styles.js +11 -4
  157. package/optimize/lib/components/provider/provider.js +2 -1
  158. package/package.json +5 -4
  159. package/test-env/components/collapsible_nav/collapsible_nav.js +20 -101
  160. package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +1 -0
  161. package/test-env/components/flyout/_flyout_overlay.js +62 -0
  162. package/test-env/components/flyout/_flyout_resize_button.js +37 -0
  163. package/{optimize/lib/components/flyout/flyout_resizable.styles.js → test-env/components/flyout/_flyout_resize_button.styles.js} +12 -12
  164. package/test-env/components/flyout/const.js +49 -0
  165. package/test-env/components/flyout/flyout.component.js +477 -0
  166. package/test-env/components/flyout/flyout.styles.js +102 -7
  167. package/test-env/components/flyout/flyout_menu.js +241 -0
  168. package/test-env/components/flyout/flyout_menu.styles.js +25 -0
  169. package/test-env/components/flyout/{flyout_context.js → flyout_menu_context.js} +2 -7
  170. package/test-env/components/flyout/flyout_parent_context.js +43 -0
  171. package/test-env/components/flyout/flyout_resizable.js +35 -139
  172. package/test-env/components/flyout/hooks.js +30 -0
  173. package/test-env/components/flyout/index.js +21 -14
  174. package/test-env/components/flyout/manager/actions.js +159 -0
  175. package/test-env/components/flyout/manager/activity_stage.js +101 -0
  176. package/test-env/components/flyout/manager/const.js +62 -0
  177. package/test-env/components/flyout/manager/context.js +41 -0
  178. package/test-env/components/flyout/manager/flyout_child.js +76 -0
  179. package/test-env/components/flyout/manager/flyout_main.js +66 -0
  180. package/test-env/components/flyout/manager/flyout_main.styles.js +31 -0
  181. package/test-env/components/flyout/manager/flyout_managed.js +231 -0
  182. package/test-env/components/flyout/manager/flyout_managed.styles.js +74 -0
  183. package/test-env/components/flyout/manager/hooks.js +131 -0
  184. package/test-env/components/flyout/manager/index.js +168 -0
  185. package/test-env/components/flyout/manager/layout_mode.js +169 -0
  186. package/test-env/components/flyout/manager/provider.js +61 -0
  187. package/test-env/components/flyout/manager/reducer.js +318 -0
  188. package/test-env/components/flyout/manager/selectors.js +122 -0
  189. package/test-env/components/flyout/manager/store.js +120 -0
  190. package/test-env/components/flyout/manager/types.js +5 -0
  191. package/test-env/components/flyout/manager/validation.js +94 -0
  192. package/test-env/components/flyout/types.js +5 -0
  193. package/test-env/components/flyout/use_flyout_resizable.js +151 -0
  194. package/test-env/components/flyout/use_flyout_z_index.js +51 -0
  195. package/test-env/components/overlay_mask/overlay_mask.js +12 -2
  196. package/test-env/components/overlay_mask/overlay_mask.styles.js +11 -4
  197. package/test-env/components/provider/provider.js +2 -1
  198. package/es/components/flyout/flyout_child.js +0 -223
  199. package/es/components/flyout/flyout_child.styles.js +0 -32
  200. package/es/components/flyout/flyout_child_manager.js +0 -114
  201. package/es/components/flyout/sessions/flyout_provider.js +0 -95
  202. package/es/components/flyout/sessions/flyout_reducer.js +0 -195
  203. package/es/components/flyout/sessions/index.js +0 -10
  204. package/es/components/flyout/sessions/use_eui_flyout.js +0 -82
  205. package/lib/components/flyout/flyout_child.js +0 -231
  206. package/lib/components/flyout/flyout_child.styles.js +0 -38
  207. package/lib/components/flyout/flyout_child_manager.js +0 -122
  208. package/lib/components/flyout/sessions/flyout_provider.js +0 -102
  209. package/lib/components/flyout/sessions/flyout_reducer.js +0 -202
  210. package/lib/components/flyout/sessions/index.js +0 -25
  211. package/lib/components/flyout/sessions/use_eui_flyout.js +0 -88
  212. package/optimize/es/components/flyout/flyout_child.js +0 -178
  213. package/optimize/es/components/flyout/flyout_child.styles.js +0 -32
  214. package/optimize/es/components/flyout/flyout_child_manager.js +0 -100
  215. package/optimize/es/components/flyout/sessions/flyout_provider.js +0 -90
  216. package/optimize/es/components/flyout/sessions/flyout_reducer.js +0 -187
  217. package/optimize/es/components/flyout/sessions/index.js +0 -10
  218. package/optimize/es/components/flyout/sessions/use_eui_flyout.js +0 -82
  219. package/optimize/lib/components/flyout/flyout_child.js +0 -186
  220. package/optimize/lib/components/flyout/flyout_child.styles.js +0 -38
  221. package/optimize/lib/components/flyout/flyout_child_manager.js +0 -110
  222. package/optimize/lib/components/flyout/sessions/flyout_provider.js +0 -100
  223. package/optimize/lib/components/flyout/sessions/flyout_reducer.js +0 -195
  224. package/optimize/lib/components/flyout/sessions/index.js +0 -25
  225. package/optimize/lib/components/flyout/sessions/use_eui_flyout.js +0 -88
  226. package/test-env/components/flyout/flyout_child.js +0 -230
  227. package/test-env/components/flyout/flyout_child.styles.js +0 -38
  228. package/test-env/components/flyout/flyout_child_manager.js +0 -119
  229. package/test-env/components/flyout/sessions/flyout_provider.js +0 -100
  230. package/test-env/components/flyout/sessions/flyout_reducer.js +0 -195
  231. package/test-env/components/flyout/sessions/index.js +0 -25
  232. package/test-env/components/flyout/sessions/use_eui_flyout.js +0 -88
  233. /package/es/components/flyout/{sessions → manager}/types.js +0 -0
  234. /package/{optimize/es/components/flyout/sessions → es/components/flyout}/types.js +0 -0
  235. /package/lib/components/flyout/{sessions → manager}/types.js +0 -0
  236. /package/{optimize/lib/components/flyout/sessions → lib/components/flyout}/types.js +0 -0
  237. /package/{test-env/components/flyout/sessions → optimize/lib/components/flyout/manager}/types.js +0 -0
@@ -0,0 +1,469 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
6
+ var _excluded = ["className", "children", "as", "hideCloseButton", "flyoutMenuProps", "closeButtonProps", "closeButtonPosition", "onClose", "ownFocus", "side", "size", "paddingSize", "maxWidth", "style", "hasChildBackground", "maskProps", "type", "outsideClickCloses", "pushMinBreakpoint", "pushAnimation", "focusTrapProps", "includeFixedHeadersInFocusTrap", "includeSelectorInFocusTrap", "aria-describedby", "aria-labelledby", "id", "resizable", "minWidth", "onResize", "onAnimationEnd"],
7
+ _excluded2 = ["titleId"];
8
+ 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; }
9
+ 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; }
10
+ /*
11
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
+ * or more contributor license agreements. Licensed under the Elastic License
13
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
14
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
15
+ * Side Public License, v 1.
16
+ */
17
+
18
+ /* eslint-disable local/i18n */
19
+
20
+ import React, { useEffect, useLayoutEffect, useRef, useMemo, useCallback, useState, forwardRef } from 'react';
21
+ import classnames from 'classnames';
22
+ import { keys, EuiWindowEvent, useCombinedRefs, useEuiMemoizedStyles, useGeneratedHtmlId, useEuiThemeCSSVariables, focusTrapPubSub } from '../../services';
23
+ import { useCurrentSession, useIsInManagedFlyout, useFlyoutLayoutMode, useFlyoutId, useFlyoutWidth, useIsFlyoutActive, useFlyoutManager, useHasPushPadding } from './manager';
24
+ import { EuiFocusTrap } from '../focus_trap';
25
+ import { EuiI18n } from '../i18n';
26
+ import { useResizeObserver } from '../observer/resize_observer';
27
+ import { EuiScreenReaderOnly } from '../accessibility';
28
+ import { EuiFlyoutCloseButton } from './_flyout_close_button';
29
+ import { euiFlyoutStyles, composeFlyoutInlineStyles } from './flyout.styles';
30
+ import { usePropsWithComponentDefaults } from '../provider/component_defaults';
31
+ import { DEFAULT_PADDING_SIZE, DEFAULT_PUSH_MIN_BREAKPOINT, DEFAULT_SIDE, DEFAULT_SIZE, DEFAULT_TYPE, isEuiFlyoutSizeNamed } from './const';
32
+ import { useIsPushed } from './hooks';
33
+ import { EuiFlyoutMenu } from './flyout_menu';
34
+ import { EuiFlyoutOverlay } from './_flyout_overlay';
35
+ import { EuiFlyoutResizeButton } from './_flyout_resize_button';
36
+ import { useEuiFlyoutResizable } from './use_flyout_resizable';
37
+ import { useEuiFlyoutZIndex } from './use_flyout_z_index';
38
+ import { EuiFlyoutParentProvider } from './flyout_parent_context';
39
+ import { useCurrentFlyoutZIndexRef } from './manager/selectors';
40
+ import { jsx as ___EmotionJSX } from "@emotion/react";
41
+ var defaultElement = 'div';
42
+ export var EuiFlyoutComponent = /*#__PURE__*/forwardRef(function (props, ref) {
43
+ var _usePropsWithComponen = usePropsWithComponentDefaults('EuiFlyout', props),
44
+ className = _usePropsWithComponen.className,
45
+ children = _usePropsWithComponen.children,
46
+ as = _usePropsWithComponen.as,
47
+ _usePropsWithComponen2 = _usePropsWithComponen.hideCloseButton,
48
+ hideCloseButton = _usePropsWithComponen2 === void 0 ? false : _usePropsWithComponen2,
49
+ _flyoutMenuProps = _usePropsWithComponen.flyoutMenuProps,
50
+ closeButtonProps = _usePropsWithComponen.closeButtonProps,
51
+ _usePropsWithComponen3 = _usePropsWithComponen.closeButtonPosition,
52
+ closeButtonPosition = _usePropsWithComponen3 === void 0 ? 'inside' : _usePropsWithComponen3,
53
+ onClose = _usePropsWithComponen.onClose,
54
+ _usePropsWithComponen4 = _usePropsWithComponen.ownFocus,
55
+ ownFocus = _usePropsWithComponen4 === void 0 ? true : _usePropsWithComponen4,
56
+ _usePropsWithComponen5 = _usePropsWithComponen.side,
57
+ side = _usePropsWithComponen5 === void 0 ? DEFAULT_SIDE : _usePropsWithComponen5,
58
+ _usePropsWithComponen6 = _usePropsWithComponen.size,
59
+ _size = _usePropsWithComponen6 === void 0 ? DEFAULT_SIZE : _usePropsWithComponen6,
60
+ _usePropsWithComponen7 = _usePropsWithComponen.paddingSize,
61
+ paddingSize = _usePropsWithComponen7 === void 0 ? DEFAULT_PADDING_SIZE : _usePropsWithComponen7,
62
+ _usePropsWithComponen8 = _usePropsWithComponen.maxWidth,
63
+ maxWidth = _usePropsWithComponen8 === void 0 ? false : _usePropsWithComponen8,
64
+ style = _usePropsWithComponen.style,
65
+ _usePropsWithComponen9 = _usePropsWithComponen.hasChildBackground,
66
+ hasChildBackground = _usePropsWithComponen9 === void 0 ? false : _usePropsWithComponen9,
67
+ maskProps = _usePropsWithComponen.maskProps,
68
+ _usePropsWithComponen10 = _usePropsWithComponen.type,
69
+ type = _usePropsWithComponen10 === void 0 ? DEFAULT_TYPE : _usePropsWithComponen10,
70
+ outsideClickCloses = _usePropsWithComponen.outsideClickCloses,
71
+ _usePropsWithComponen11 = _usePropsWithComponen.pushMinBreakpoint,
72
+ pushMinBreakpoint = _usePropsWithComponen11 === void 0 ? DEFAULT_PUSH_MIN_BREAKPOINT : _usePropsWithComponen11,
73
+ _usePropsWithComponen12 = _usePropsWithComponen.pushAnimation,
74
+ pushAnimation = _usePropsWithComponen12 === void 0 ? false : _usePropsWithComponen12,
75
+ _focusTrapProps = _usePropsWithComponen.focusTrapProps,
76
+ _usePropsWithComponen13 = _usePropsWithComponen.includeFixedHeadersInFocusTrap,
77
+ includeFixedHeadersInFocusTrap = _usePropsWithComponen13 === void 0 ? true : _usePropsWithComponen13,
78
+ includeSelectorInFocusTrap = _usePropsWithComponen.includeSelectorInFocusTrap,
79
+ _ariaDescribedBy = _usePropsWithComponen['aria-describedby'],
80
+ _ariaLabelledBy = _usePropsWithComponen['aria-labelledby'],
81
+ id = _usePropsWithComponen.id,
82
+ _usePropsWithComponen14 = _usePropsWithComponen.resizable,
83
+ resizable = _usePropsWithComponen14 === void 0 ? false : _usePropsWithComponen14,
84
+ minWidth = _usePropsWithComponen.minWidth,
85
+ onResize = _usePropsWithComponen.onResize,
86
+ onAnimationEnd = _usePropsWithComponen.onAnimationEnd,
87
+ rest = _objectWithoutProperties(_usePropsWithComponen, _excluded);
88
+ var _useEuiThemeCSSVariab = useEuiThemeCSSVariables(),
89
+ setGlobalCSSVariables = _useEuiThemeCSSVariab.setGlobalCSSVariables;
90
+ var Element = as || defaultElement;
91
+ var maskRef = useRef(null);
92
+
93
+ // Ref for the main flyout element to pass to context
94
+ var internalParentFlyoutRef = useRef(null);
95
+ var isPushed = useIsPushed({
96
+ type: type,
97
+ pushMinBreakpoint: pushMinBreakpoint
98
+ });
99
+ var currentSession = useCurrentSession();
100
+ var isInManagedContext = useIsInManagedFlyout();
101
+ var flyoutId = useFlyoutId(id);
102
+ var layoutMode = useFlyoutLayoutMode();
103
+ var isActiveManagedFlyout = useIsFlyoutActive(flyoutId);
104
+ var flyoutManager = useFlyoutManager();
105
+ var currentZIndexRef = useCurrentFlyoutZIndexRef();
106
+
107
+ // Use a ref to access the latest flyoutManager without triggering effect re-runs
108
+ var flyoutManagerRef = useRef(flyoutManager);
109
+ useEffect(function () {
110
+ flyoutManagerRef.current = flyoutManager;
111
+ }, [flyoutManager]);
112
+ useEffect(function () {
113
+ // Keep track of unmanaged flyouts to properly calculate z-index
114
+ // values for all flyouts
115
+ if (!isInManagedContext) {
116
+ var _flyoutManagerRef$cur;
117
+ (_flyoutManagerRef$cur = flyoutManagerRef.current) === null || _flyoutManagerRef$cur === void 0 || _flyoutManagerRef$cur.addUnmanagedFlyout(flyoutId);
118
+ return function () {
119
+ var _flyoutManagerRef$cur2;
120
+ return (_flyoutManagerRef$cur2 = flyoutManagerRef.current) === null || _flyoutManagerRef$cur2 === void 0 ? void 0 : _flyoutManagerRef$cur2.closeUnmanagedFlyout(flyoutId);
121
+ };
122
+ }
123
+ }, [isInManagedContext, flyoutId]);
124
+ var _useEuiFlyoutResizabl = useEuiFlyoutResizable({
125
+ enabled: resizable,
126
+ minWidth: minWidth,
127
+ maxWidth: typeof maxWidth === 'number' ? maxWidth : 0,
128
+ onResize: onResize,
129
+ side: side,
130
+ size: _size
131
+ }),
132
+ onMouseDownResizableButton = _useEuiFlyoutResizabl.onMouseDown,
133
+ onKeyDownResizableButton = _useEuiFlyoutResizabl.onKeyDown,
134
+ size = _useEuiFlyoutResizabl.size,
135
+ setFlyoutRef = _useEuiFlyoutResizabl.setFlyoutRef;
136
+
137
+ /**
138
+ * Setting up the refs on the actual flyout element in order to
139
+ * accommodate for the `isPushed` state by adding padding to the body equal to the width of the element
140
+ */
141
+ var _useState = useState(null),
142
+ _useState2 = _slicedToArray(_useState, 2),
143
+ resizeRef = _useState2[0],
144
+ setResizeRef = _useState2[1];
145
+ var setRef = useCombinedRefs([setResizeRef, ref, internalParentFlyoutRef, setFlyoutRef]);
146
+ var _useResizeObserver = useResizeObserver(isPushed ? resizeRef : null, 'width'),
147
+ width = _useResizeObserver.width;
148
+
149
+ /**
150
+ * Effect for adding push padding to body. Using useLayoutEffect to ensure
151
+ * padding changes happen synchronously before child components render -
152
+ * this is needed to prevent RemoveScrollBar from measuring the body in an
153
+ * inconsistent state during flyout transitions.
154
+ */
155
+ useLayoutEffect(function () {
156
+ if (!isPushed) {
157
+ return; // Only push-type flyouts manage body padding
158
+ }
159
+ var shouldApplyPadding = !isInManagedContext || isActiveManagedFlyout;
160
+ var paddingSide = side === 'left' ? 'paddingInlineStart' : 'paddingInlineEnd';
161
+ var cssVarName = "--euiPushFlyoutOffset".concat(side === 'left' ? 'InlineStart' : 'InlineEnd');
162
+ var managerSide = side === 'left' ? 'left' : 'right';
163
+ if (shouldApplyPadding) {
164
+ document.body.style[paddingSide] = "".concat(width, "px");
165
+ setGlobalCSSVariables(_defineProperty({}, cssVarName, "".concat(width, "px")));
166
+ // Update manager state if in managed context
167
+ if (isInManagedContext && flyoutManagerRef.current) {
168
+ flyoutManagerRef.current.setPushPadding(managerSide, width);
169
+ }
170
+ } else {
171
+ // Explicitly remove padding when this push flyout becomes inactive
172
+ document.body.style[paddingSide] = '';
173
+ setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
174
+ // Clear manager state if in managed context
175
+ if (isInManagedContext && flyoutManagerRef.current) {
176
+ flyoutManagerRef.current.setPushPadding(managerSide, 0);
177
+ }
178
+ }
179
+
180
+ // Cleanup on unmount
181
+ return function () {
182
+ document.body.style[paddingSide] = '';
183
+ setGlobalCSSVariables(_defineProperty({}, cssVarName, null));
184
+ // Clear manager state on unmount if in managed context
185
+ if (isInManagedContext && flyoutManagerRef.current) {
186
+ flyoutManagerRef.current.setPushPadding(managerSide, 0);
187
+ }
188
+ };
189
+ }, [isPushed, isInManagedContext, isActiveManagedFlyout, setGlobalCSSVariables, side, width]);
190
+
191
+ /**
192
+ * This class doesn't actually do anything by EUI, but is nice to add for consumers (JIC)
193
+ */
194
+ useEffect(function () {
195
+ document.body.classList.add('euiBody--hasFlyout');
196
+ return function () {
197
+ // Remove the hasFlyout class when the flyout is unmounted
198
+ document.body.classList.remove('euiBody--hasFlyout');
199
+ };
200
+ }, []);
201
+
202
+ // Memoize flyout identification and relationships to prevent race conditions
203
+ var flyoutIdentity = useMemo(function () {
204
+ if (!flyoutId || !currentSession) {
205
+ return {
206
+ isMainFlyout: false,
207
+ siblingFlyoutId: null,
208
+ hasValidSession: false,
209
+ sessionForWidth: null
210
+ };
211
+ }
212
+ var siblingFlyoutId = currentSession.mainFlyoutId === flyoutId ? currentSession.childFlyoutId : currentSession.mainFlyoutId;
213
+ return {
214
+ siblingFlyoutId: siblingFlyoutId,
215
+ hasValidSession: true,
216
+ sessionForWidth: currentSession
217
+ };
218
+ }, [flyoutId, currentSession]);
219
+
220
+ // Destructure for easier use
221
+ var siblingFlyoutId = flyoutIdentity.siblingFlyoutId;
222
+ var hasChildFlyout = (currentSession === null || currentSession === void 0 ? void 0 : currentSession.childFlyoutId) != null;
223
+ var isChildFlyout = isInManagedContext && hasChildFlyout && (currentSession === null || currentSession === void 0 ? void 0 : currentSession.childFlyoutId) === id;
224
+ var shouldCloseOnEscape = useMemo(function () {
225
+ // Regular flyout - always close on ESC
226
+ if (!isInManagedContext) {
227
+ return true;
228
+ }
229
+
230
+ // Managed flyout with no child - close on ESC
231
+ if (!hasChildFlyout) {
232
+ return true;
233
+ }
234
+
235
+ // Child flyout - close on ESC
236
+ if (isChildFlyout) {
237
+ return true;
238
+ }
239
+
240
+ // Main flyout with child flyout - don't close on ESC
241
+ return false;
242
+ }, [isInManagedContext, hasChildFlyout, isChildFlyout]);
243
+
244
+ /**
245
+ * ESC key closes flyout based on flyout hierarchy rules
246
+ */
247
+ var onKeyDown = useCallback(function (event) {
248
+ if (!isPushed && event.key === keys.ESCAPE && shouldCloseOnEscape) {
249
+ event.preventDefault();
250
+ onClose(event);
251
+ }
252
+ }, [onClose, isPushed, shouldCloseOnEscape]);
253
+ var siblingFlyoutWidth = useFlyoutWidth(siblingFlyoutId);
254
+ var managedFlyoutIndex = currentZIndexRef.current;
255
+ if (isInManagedContext && currentSession) {
256
+ managedFlyoutIndex = currentSession.zIndex;
257
+ }
258
+ var _useEuiFlyoutZIndex = useEuiFlyoutZIndex({
259
+ maskProps: maskProps,
260
+ isPushed: isPushed,
261
+ managedFlyoutIndex: managedFlyoutIndex,
262
+ isChildFlyout: isChildFlyout
263
+ }),
264
+ flyoutZIndex = _useEuiFlyoutZIndex.flyoutZIndex,
265
+ maskZIndex = _useEuiFlyoutZIndex.maskZIndex;
266
+
267
+ /**
268
+ * Set inline styles
269
+ */
270
+ var inlineStyles = useMemo(function () {
271
+ var composedStyles = composeFlyoutInlineStyles(size, layoutMode, siblingFlyoutId, siblingFlyoutWidth || null, maxWidth, flyoutZIndex);
272
+ return _objectSpread(_objectSpread({}, style), composedStyles);
273
+ }, [style, size, layoutMode, siblingFlyoutId, siblingFlyoutWidth, maxWidth, flyoutZIndex]);
274
+ var styles = useEuiMemoizedStyles(euiFlyoutStyles);
275
+ var cssStyles = [styles.euiFlyout, styles.paddingSizes[paddingSize], isEuiFlyoutSizeNamed(size) && styles[size], maxWidth === false && styles.noMaxWidth, isPushed ? styles.push.push : styles.overlay.overlay, isPushed ? styles.push[side] : styles.overlay[side], isPushed && !pushAnimation && styles.push.noAnimation, styles[side]];
276
+ var classes = classnames('euiFlyout', isChildFlyout && hasChildBackground && 'euiFlyout--hasChildBackground', className);
277
+ var flyoutToggle = useRef(document.activeElement);
278
+ var _useState3 = useState([]),
279
+ _useState4 = _slicedToArray(_useState3, 2),
280
+ focusTrapShards = _useState4[0],
281
+ setFocusTrapShards = _useState4[1];
282
+ var focusTrapSelectors = useMemo(function () {
283
+ var selectors = [];
284
+ if (includeSelectorInFocusTrap) {
285
+ selectors = Array.isArray(includeSelectorInFocusTrap) ? includeSelectorInFocusTrap : [includeSelectorInFocusTrap];
286
+ }
287
+ if (includeFixedHeadersInFocusTrap) {
288
+ selectors.push('.euiHeader[data-fixed-header]');
289
+ }
290
+ return selectors;
291
+ }, [includeSelectorInFocusTrap, includeFixedHeadersInFocusTrap]);
292
+
293
+ /**
294
+ * Finds the shards to include in the focus trap by querying by `focusTrapSelectors`.
295
+ *
296
+ * @param shouldAutoFocus Whether to auto-focus the flyout wrapper when the focus trap is activated.
297
+ * This is necessary because when a flyout is toggled from within a shard, the focus trap's `autoFocus`
298
+ * feature doesn't work. This logic manually focuses the flyout as a workaround.
299
+ */
300
+ var findShards = useCallback(function () {
301
+ var shouldAutoFocus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
302
+ if (focusTrapSelectors.length > 0) {
303
+ var shardsEls = focusTrapSelectors.flatMap(function (selector) {
304
+ return Array.from(document.querySelectorAll(selector));
305
+ });
306
+ setFocusTrapShards(Array.from(shardsEls));
307
+ if (shouldAutoFocus) {
308
+ shardsEls.forEach(function (shard) {
309
+ if (shard.contains(flyoutToggle.current)) {
310
+ resizeRef === null || resizeRef === void 0 || resizeRef.focus();
311
+ }
312
+ });
313
+ }
314
+ } else {
315
+ // Clear existing shards if necessary, e.g. switching to `false`
316
+ setFocusTrapShards(function (shards) {
317
+ return shards.length ? [] : shards;
318
+ });
319
+ }
320
+ }, [focusTrapSelectors, resizeRef]);
321
+ useEffect(function () {
322
+ // Auto-focus should only happen on initial flyout mount (or when the dependencies change)
323
+ // because it snaps focus to the flyout wrapper, which steals it from subsequently focused elements.
324
+ findShards(true);
325
+ var unsubscribe = focusTrapPubSub.subscribe(function () {
326
+ return findShards();
327
+ });
328
+ return unsubscribe;
329
+ }, [findShards]);
330
+ var focusTrapProps = useMemo(function () {
331
+ return _objectSpread(_objectSpread({}, _focusTrapProps), {}, {
332
+ shards: [].concat(_toConsumableArray(focusTrapShards), _toConsumableArray((_focusTrapProps === null || _focusTrapProps === void 0 ? void 0 : _focusTrapProps.shards) || []))
333
+ });
334
+ }, [_focusTrapProps, focusTrapShards]);
335
+
336
+ /*
337
+ * Provide meaningful screen reader instructions/details
338
+ */
339
+ var hasOverlayMask = ownFocus && !isPushed;
340
+ var descriptionId = useGeneratedHtmlId();
341
+ var ariaDescribedBy = classnames(descriptionId, _ariaDescribedBy);
342
+ var screenReaderDescription = useMemo(function () {
343
+ return ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
344
+ id: descriptionId
345
+ }, hasOverlayMask ? ___EmotionJSX(EuiI18n, {
346
+ token: "euiFlyout.screenReaderModalDialog",
347
+ default: "You are in a modal dialog. Press Escape or tap/click outside the dialog on the shadowed overlay to close."
348
+ }) : ___EmotionJSX(EuiI18n, {
349
+ token: "euiFlyout.screenReaderNonModalDialog",
350
+ default: "You are in a non-modal dialog. To close the dialog, press Escape."
351
+ }), ' ', focusTrapShards.length > 0 && ___EmotionJSX(EuiI18n, {
352
+ token: "euiFlyout.screenReaderFocusTrapShards",
353
+ default: "You can still continue tabbing through other global page landmarks."
354
+ })));
355
+ }, [hasOverlayMask, descriptionId, focusTrapShards.length]);
356
+
357
+ /*
358
+ * If the flyout menu is to be rendered, ensure the flyout has aria-labelledby referencing the menu's titleId
359
+ */
360
+ var generatedMenuId = useGeneratedHtmlId();
361
+ var _ref = _flyoutMenuProps || {},
362
+ _titleId = _ref.titleId,
363
+ flyoutMenuProps = _objectWithoutProperties(_ref, _excluded2);
364
+ var hasMenu = !!_flyoutMenuProps;
365
+ var flyoutMenuId = useMemo(function () {
366
+ if (!hasMenu) return undefined;
367
+ return _titleId || generatedMenuId;
368
+ }, [hasMenu, _titleId, generatedMenuId]);
369
+
370
+ // If the flyout level is LEVEL_MAIN, the title should be hidden by default
371
+ var flyoutMenuHideTitle = useMemo(function () {
372
+ if (!hasMenu) return undefined;
373
+ if ((_flyoutMenuProps === null || _flyoutMenuProps === void 0 ? void 0 : _flyoutMenuProps.hideTitle) !== undefined) {
374
+ return _flyoutMenuProps.hideTitle;
375
+ }
376
+ return (currentSession === null || currentSession === void 0 ? void 0 : currentSession.mainFlyoutId) === flyoutId;
377
+ }, [hasMenu, _flyoutMenuProps, currentSession, flyoutId]);
378
+ var ariaLabelledBy = useMemo(function () {
379
+ if (flyoutMenuId) {
380
+ return classnames(flyoutMenuId, _ariaLabelledBy);
381
+ }
382
+ return _ariaLabelledBy;
383
+ }, [flyoutMenuId, _ariaLabelledBy]);
384
+
385
+ /*
386
+ * Trap focus even when `ownFocus={false}`, otherwise closing
387
+ * the flyout won't return focus to the originating button.
388
+ *
389
+ * Set `clickOutsideDisables={true}` when `ownFocus={false}`
390
+ * to allow non-keyboard users the ability to interact with
391
+ * elements outside the flyout.
392
+ *
393
+ * Set `onClickOutside={onClose}` when `ownFocus` and `type` are the defaults,
394
+ * or if `outsideClickCloses={true}` to close on clicks that target
395
+ * (both mousedown and mouseup) the overlay mask.
396
+ */
397
+ var onClickOutside = useCallback(function (event) {
398
+ // Do not close the flyout for any external click
399
+ if (outsideClickCloses === false) return undefined;
400
+ if (hasOverlayMask) {
401
+ // The overlay mask is present, so only clicks on the mask should close the flyout, regardless of outsideClickCloses
402
+ if (event.target === maskRef.current) return onClose(event);
403
+ } else {
404
+ // No overlay mask is present, so any outside clicks should close the flyout
405
+ if (outsideClickCloses === true) return onClose(event);
406
+ }
407
+ // Otherwise if ownFocus is false and outsideClickCloses is undefined, outside clicks should not close the flyout
408
+ return undefined;
409
+ }, [onClose, hasOverlayMask, outsideClickCloses]);
410
+ var maskCombinedRefs = useCombinedRefs([maskProps === null || maskProps === void 0 ? void 0 : maskProps.maskRef, maskRef]);
411
+
412
+ /**
413
+ * For overlay flyouts in managed contexts, coordinate scroll locking with push flyout state.
414
+ */
415
+ var hasPushPaddingInManager = useHasPushPadding();
416
+ var shouldDeferScrollLock = !isPushed && isInManagedContext && hasPushPaddingInManager;
417
+ var shouldUseScrollLock = hasOverlayMask && !shouldDeferScrollLock;
418
+ return ___EmotionJSX(EuiFlyoutOverlay, {
419
+ hasOverlayMask: hasOverlayMask,
420
+ isPushed: isPushed,
421
+ maskZIndex: maskZIndex,
422
+ maskProps: _objectSpread(_objectSpread({}, maskProps), {}, {
423
+ maskRef: maskCombinedRefs
424
+ })
425
+ }, ___EmotionJSX(EuiWindowEvent, {
426
+ event: "keydown",
427
+ handler: onKeyDown
428
+ }), ___EmotionJSX(EuiFocusTrap, _extends({
429
+ disabled: isPushed,
430
+ scrollLock: shouldUseScrollLock,
431
+ clickOutsideDisables: !ownFocus,
432
+ onClickOutside: onClickOutside
433
+ }, focusTrapProps), ___EmotionJSX(Element, _extends({
434
+ className: classes,
435
+ css: cssStyles,
436
+ style: inlineStyles,
437
+ ref: setRef,
438
+ id: id
439
+ }, rest, {
440
+ role: !isPushed ? 'dialog' : rest.role,
441
+ "aria-modal": !isPushed || undefined,
442
+ tabIndex: !isPushed ? 0 : rest.tabIndex,
443
+ "aria-describedby": !isPushed ? ariaDescribedBy : _ariaDescribedBy,
444
+ "aria-labelledby": ariaLabelledBy,
445
+ "data-autofocus": !isPushed || undefined,
446
+ onAnimationEnd: onAnimationEnd
447
+ }), !isPushed && screenReaderDescription, !_flyoutMenuProps && !hideCloseButton && ___EmotionJSX(EuiFlyoutCloseButton, _extends({}, closeButtonProps, {
448
+ onClose: onClose,
449
+ closeButtonPosition: closeButtonPosition,
450
+ side: side
451
+ })), _flyoutMenuProps && ___EmotionJSX(EuiFlyoutMenu, _extends({}, flyoutMenuProps, {
452
+ hideTitle: flyoutMenuHideTitle,
453
+ titleId: flyoutMenuId
454
+ })), resizable && ___EmotionJSX(EuiFlyoutResizeButton, {
455
+ type: type,
456
+ side: side,
457
+ ownFocus: ownFocus,
458
+ isPushed: isPushed,
459
+ onMouseDown: onMouseDownResizableButton,
460
+ onTouchStart: onMouseDownResizableButton,
461
+ onKeyDown: onKeyDownResizableButton
462
+ }), ___EmotionJSX(EuiFlyoutParentProvider, null, children))));
463
+ }
464
+ // React.forwardRef interferes with the inferred element type
465
+ // Casting to ensure correct element prop type checking for `as`
466
+ // e.g., `href` is not on a `div`
467
+ );
468
+ // Recast to allow `displayName`
469
+ EuiFlyoutComponent.displayName = 'EuiFlyoutComponent';