@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,162 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ var _excluded = ["className", "title", "titleId", "hideTitle", "hideCloseButton", "historyItems", "showBackButton", "backButtonProps", "customActions"];
5
+ /*
6
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
+ * or more contributor license agreements. Licensed under the Elastic License
8
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
9
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
10
+ * Side Public License, v 1.
11
+ */
12
+
13
+ import classNames from 'classnames';
14
+ import React, { useContext, useState } from 'react';
15
+ import { useEuiMemoizedStyles } from '../../services';
16
+ import { EuiButtonEmpty, EuiButtonIcon } from '../button';
17
+ import { EuiFlexGroup, EuiFlexItem } from '../flex';
18
+ import { EuiListGroup, EuiListGroupItem } from '../list_group';
19
+ import { EuiPopover } from '../popover';
20
+ import { EuiTitle } from '../title';
21
+ import { EuiFlyoutCloseButton } from './_flyout_close_button';
22
+ import { euiFlyoutMenuStyles } from './flyout_menu.styles';
23
+ import { EuiFlyoutMenuContext } from './flyout_menu_context';
24
+ import { EuiI18n, useEuiI18n } from '../i18n';
25
+
26
+ /**
27
+ * History item for the flyout menu history popover
28
+ */
29
+
30
+ /**
31
+ * Custom action item for the flyout menu component
32
+ */
33
+
34
+ /**
35
+ * Props for EuiFlyoutMenu
36
+ */
37
+ import { jsx as ___EmotionJSX } from "@emotion/react";
38
+ var BackButton = function BackButton(props) {
39
+ return ___EmotionJSX(EuiButtonEmpty, _extends({
40
+ size: "xs",
41
+ color: "text",
42
+ iconType: "editorUndo"
43
+ }, props), ___EmotionJSX(EuiI18n, {
44
+ token: "euiFlyoutMenu.back",
45
+ default: "Back"
46
+ }));
47
+ };
48
+ var HistoryPopover = function HistoryPopover(_ref) {
49
+ var items = _ref.items;
50
+ var _useState = useState(false),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ isPopoverOpen = _useState2[0],
53
+ setIsPopoverOpen = _useState2[1];
54
+ var handlePopoverButtonClick = function handlePopoverButtonClick() {
55
+ setIsPopoverOpen(!isPopoverOpen);
56
+ };
57
+ return ___EmotionJSX(EuiPopover, {
58
+ button: ___EmotionJSX(EuiButtonIcon, {
59
+ iconType: "arrowDown",
60
+ color: "text",
61
+ "aria-label": useEuiI18n('euiFlyoutMenu.history', 'History')
62
+ }),
63
+ isOpen: isPopoverOpen,
64
+ onClick: handlePopoverButtonClick,
65
+ closePopover: function closePopover() {
66
+ return setIsPopoverOpen(false);
67
+ },
68
+ panelPaddingSize: "xs",
69
+ anchorPosition: "downLeft"
70
+ }, ___EmotionJSX(EuiListGroup, {
71
+ gutterSize: "none"
72
+ }, items.map(function (item, index) {
73
+ return ___EmotionJSX(EuiListGroupItem, {
74
+ key: "history-item-".concat(index),
75
+ label: item.title,
76
+ size: "s",
77
+ onClick: function onClick() {
78
+ item.onClick();
79
+ setIsPopoverOpen(false);
80
+ }
81
+ }, item.title);
82
+ })));
83
+ };
84
+
85
+ /**
86
+ * The component for the top menu bar inside a flyout. Since this is a private
87
+ * component, rendering is controlled using the `flyoutMenuProps` prop on
88
+ * `EuiFlyout`. In managed session flyouts, the Flyout Manager controls a back
89
+ * button and history popover for navigating to different flyout sessions
90
+ * within the managed context.
91
+ *
92
+ * @private
93
+ */
94
+ export var EuiFlyoutMenu = function EuiFlyoutMenu(_ref2) {
95
+ var className = _ref2.className,
96
+ title = _ref2.title,
97
+ titleId = _ref2.titleId,
98
+ hideTitle = _ref2.hideTitle,
99
+ hideCloseButton = _ref2.hideCloseButton,
100
+ _ref2$historyItems = _ref2.historyItems,
101
+ historyItems = _ref2$historyItems === void 0 ? [] : _ref2$historyItems,
102
+ showBackButton = _ref2.showBackButton,
103
+ backButtonProps = _ref2.backButtonProps,
104
+ customActions = _ref2.customActions,
105
+ rest = _objectWithoutProperties(_ref2, _excluded);
106
+ var _useContext = useContext(EuiFlyoutMenuContext),
107
+ onClose = _useContext.onClose;
108
+ var styles = useEuiMemoizedStyles(euiFlyoutMenuStyles);
109
+ var classes = classNames('euiFlyoutMenu', className);
110
+ var titleNode;
111
+ if (title) {
112
+ titleNode = ___EmotionJSX(EuiTitle, {
113
+ size: "xxs",
114
+ id: titleId
115
+ }, ___EmotionJSX("h3", {
116
+ css: hideTitle && styles.euiFlyoutMenu__hiddenTitle
117
+ }, title));
118
+ }
119
+ var handleClose = function handleClose(event) {
120
+ onClose === null || onClose === void 0 || onClose(event);
121
+ };
122
+ var closeButton = ___EmotionJSX(EuiFlyoutCloseButton, {
123
+ onClose: handleClose,
124
+ side: "right",
125
+ closeButtonPosition: "inside"
126
+ });
127
+ return ___EmotionJSX("div", _extends({
128
+ className: classes,
129
+ css: styles.euiFlyoutMenu__container
130
+ }, rest), ___EmotionJSX(EuiFlexGroup, {
131
+ alignItems: "center",
132
+ justifyContent: "spaceBetween",
133
+ gutterSize: "none",
134
+ responsive: false
135
+ }, showBackButton && ___EmotionJSX(EuiFlexItem, {
136
+ grow: false
137
+ }, ___EmotionJSX(BackButton, backButtonProps)), historyItems.length > 0 && ___EmotionJSX(EuiFlexItem, {
138
+ grow: false
139
+ }, ___EmotionJSX(HistoryPopover, {
140
+ items: historyItems
141
+ })), titleNode && ___EmotionJSX(EuiFlexItem, {
142
+ grow: false
143
+ }, titleNode), ___EmotionJSX(EuiFlexItem, {
144
+ grow: true
145
+ }), customActions && customActions.map(function (action, actionIndex) {
146
+ return ___EmotionJSX(EuiFlexItem, {
147
+ grow: false,
148
+ key: "action-index-flex-item-".concat(actionIndex),
149
+ css: styles.euiFlyoutMenu__actions
150
+ }, ___EmotionJSX(EuiButtonIcon, {
151
+ key: "action-index-icon-".concat(actionIndex),
152
+ "aria-label": action['aria-label'],
153
+ iconType: action.iconType,
154
+ onClick: action.onClick,
155
+ color: "text",
156
+ size: "s"
157
+ }));
158
+ }), !hideCloseButton && ___EmotionJSX(EuiFlexItem, {
159
+ grow: false,
160
+ css: styles.euiFlyoutMenu__spacer
161
+ })), !hideCloseButton && closeButton);
162
+ };
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { css } from '@emotion/react';
10
+ import { euiScreenReaderOnly } from '../accessibility';
11
+ export var euiFlyoutMenuStyles = function euiFlyoutMenuStyles(euiThemeContext) {
12
+ var euiTheme = euiThemeContext.euiTheme;
13
+ return {
14
+ euiFlyoutMenu__container: /*#__PURE__*/css("block-size:calc(", euiTheme.size.m, " * 3.5);flex-shrink:0;padding-block:", euiTheme.size.s, ";padding-inline:", euiTheme.size.s, ";border-block-end:", euiTheme.border.width.thin, " solid ", euiTheme.border.color, ";padding-block-start:calc(", euiTheme.size.m, " * 0.8);.euiTitle{padding-inline:", euiTheme.size.s, ";};label:euiFlyoutMenu__container;"),
15
+ euiFlyoutMenu__spacer: /*#__PURE__*/css("padding-inline:", euiTheme.size.m, ";;label:euiFlyoutMenu__spacer;"),
16
+ euiFlyoutMenu__actions: /*#__PURE__*/css("block-size:calc(", euiTheme.size.m, " * 1.8);;label:euiFlyoutMenu__actions;"),
17
+ euiFlyoutMenu__hiddenTitle: /*#__PURE__*/css(euiScreenReaderOnly(), ";;label:euiFlyoutMenu__hiddenTitle;")
18
+ };
19
+ };
@@ -7,10 +7,4 @@
7
7
  */
8
8
 
9
9
  import { createContext } from 'react';
10
-
11
- /**
12
- * Context shared between the main and child flyouts
13
- * @internal
14
- */
15
-
16
- export var EuiFlyoutContext = /*#__PURE__*/createContext(null);
10
+ export var EuiFlyoutMenuContext = /*#__PURE__*/createContext({});
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import React, { createContext, useContext } from 'react';
10
+
11
+ /**
12
+ * Context to track if we're inside a parent flyout's children.
13
+ * This allows nested flyouts to automatically inherit the session
14
+ * without requiring explicit `session="inherit"` prop.
15
+ */
16
+ import { jsx as ___EmotionJSX } from "@emotion/react";
17
+ var EuiFlyoutParentContext = /*#__PURE__*/createContext(false);
18
+
19
+ /**
20
+ * Provider that wraps a flyout's children to indicate they're inside a parent flyout.
21
+ * Nested flyouts can use this to automatically default to session inheritance.
22
+ */
23
+ export var EuiFlyoutParentProvider = function EuiFlyoutParentProvider(_ref) {
24
+ var children = _ref.children;
25
+ return ___EmotionJSX(EuiFlyoutParentContext.Provider, {
26
+ value: true
27
+ }, children);
28
+ };
29
+
30
+ /**
31
+ * Hook that returns `true` when called within a parent flyout's children.
32
+ * Used to automatically determine if a nested flyout should inherit the session.
33
+ */
34
+ export var useIsInsideParentFlyout = function useIsInsideParentFlyout() {
35
+ return useContext(EuiFlyoutParentContext);
36
+ };
@@ -1,7 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["size", "maxWidth", "minWidth", "onResize", "side", "type", "ownFocus", "children"];
5
2
  /*
6
3
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
4
  * or more contributor license agreements. Licensed under the Elastic License
@@ -10,144 +7,16 @@ var _excluded = ["size", "maxWidth", "minWidth", "onResize", "side", "type", "ow
10
7
  * Side Public License, v 1.
11
8
  */
12
9
 
13
- import React, { forwardRef, useState, useEffect, useRef, useMemo, useCallback } from 'react';
14
- import { keys, useCombinedRefs, useEuiMemoizedStyles } from '../../services';
15
- import { EuiResizableButton } from '../resizable_container';
16
- import { getPosition } from '../resizable_container/helpers';
10
+ import React, { forwardRef } from 'react';
17
11
  import { EuiFlyout } from './flyout';
18
- import { euiFlyoutResizableButtonStyles } from './flyout_resizable.styles';
19
12
  import { jsx as ___EmotionJSX } from "@emotion/react";
20
13
  // If not omitted, the correct props don't show up in the docs prop table
21
14
 
22
- export var EuiFlyoutResizable = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
- var size = _ref.size,
24
- maxWidth = _ref.maxWidth,
25
- _ref$minWidth = _ref.minWidth,
26
- minWidth = _ref$minWidth === void 0 ? 200 : _ref$minWidth,
27
- onResize = _ref.onResize,
28
- _ref$side = _ref.side,
29
- side = _ref$side === void 0 ? 'right' : _ref$side,
30
- _ref$type = _ref.type,
31
- type = _ref$type === void 0 ? 'overlay' : _ref$type,
32
- _ref$ownFocus = _ref.ownFocus,
33
- ownFocus = _ref$ownFocus === void 0 ? true : _ref$ownFocus,
34
- children = _ref.children,
35
- rest = _objectWithoutProperties(_ref, _excluded);
36
- var hasOverlay = type === 'overlay' && ownFocus;
37
- var styles = useEuiMemoizedStyles(euiFlyoutResizableButtonStyles);
38
- var cssStyles = [styles.euiFlyoutResizableButton, styles[type][side], !hasOverlay && styles.noOverlay.noOverlay, !hasOverlay && styles.noOverlay[side]];
39
- var getFlyoutMinMaxWidth = useCallback(function (width) {
40
- return Math.min(Math.max(width, minWidth), maxWidth || Infinity, window.innerWidth - 20 // Leave some offset
41
- );
42
- }, [minWidth, maxWidth]);
43
- var _useState = useState(0),
44
- _useState2 = _slicedToArray(_useState, 2),
45
- flyoutWidth = _useState2[0],
46
- setFlyoutWidth = _useState2[1];
47
- var _useState3 = useState(false),
48
- _useState4 = _slicedToArray(_useState3, 2),
49
- callOnResize = _useState4[0],
50
- setCallOnResize = _useState4[1];
51
-
52
- // Must use state for the flyout ref in order for the useEffect to be correctly called after render
53
- var _useState5 = useState(null),
54
- _useState6 = _slicedToArray(_useState5, 2),
55
- flyoutRef = _useState6[0],
56
- setFlyoutRef = _useState6[1];
57
- var setRefs = useCombinedRefs([setFlyoutRef, ref]);
58
- useEffect(function () {
59
- if (!flyoutWidth && flyoutRef) {
60
- setCallOnResize(false); // Don't call `onResize` for non-user width changes
61
- setFlyoutWidth(getFlyoutMinMaxWidth(flyoutRef.offsetWidth));
62
- }
63
- }, [flyoutWidth, flyoutRef, getFlyoutMinMaxWidth]);
64
-
65
- // Update flyout width when consumers pass in a new `size`
66
- useEffect(function () {
67
- setCallOnResize(false);
68
- // For string `size`s, resetting flyoutWidth to 0 will trigger the above useEffect's recalculation
69
- setFlyoutWidth(typeof size === 'number' ? getFlyoutMinMaxWidth(size) : 0);
70
- }, [size, getFlyoutMinMaxWidth]);
71
-
72
- // Initial numbers to calculate from, on resize drag start
73
- var initialWidth = useRef(0);
74
- var initialMouseX = useRef(0);
75
-
76
- // Account for flyout side and logical property direction
77
- var direction = useMemo(function () {
78
- var modifier = side === 'right' ? -1 : 1;
79
- if (flyoutRef) {
80
- var languageDirection = window.getComputedStyle(flyoutRef).direction;
81
- if (languageDirection === 'rtl') modifier *= -1;
82
- }
83
- return modifier;
84
- }, [side, flyoutRef]);
85
- var onMouseMove = useCallback(function (e) {
86
- var mouseOffset = getPosition(e, true) - initialMouseX.current;
87
- var changedFlyoutWidth = initialWidth.current + mouseOffset * direction;
88
- setFlyoutWidth(getFlyoutMinMaxWidth(changedFlyoutWidth));
89
- }, [getFlyoutMinMaxWidth, direction]);
90
- var onMouseUp = useCallback(function () {
91
- setCallOnResize(true);
92
- initialMouseX.current = 0;
93
- window.removeEventListener('mousemove', onMouseMove);
94
- window.removeEventListener('mouseup', onMouseUp);
95
- window.removeEventListener('touchmove', onMouseMove);
96
- window.removeEventListener('touchend', onMouseUp);
97
- }, [onMouseMove]);
98
- var onMouseDown = useCallback(function (e) {
99
- var _flyoutRef$offsetWidt;
100
- setCallOnResize(false);
101
- initialMouseX.current = getPosition(e, true);
102
- initialWidth.current = (_flyoutRef$offsetWidt = flyoutRef === null || flyoutRef === void 0 ? void 0 : flyoutRef.offsetWidth) !== null && _flyoutRef$offsetWidt !== void 0 ? _flyoutRef$offsetWidt : 0;
103
-
104
- // Window event listeners instead of React events are used
105
- // in case the user's mouse leaves the component
106
- window.addEventListener('mousemove', onMouseMove);
107
- window.addEventListener('mouseup', onMouseUp);
108
- window.addEventListener('touchmove', onMouseMove);
109
- window.addEventListener('touchend', onMouseUp);
110
- }, [flyoutRef, onMouseMove, onMouseUp]);
111
- var onKeyDown = useCallback(function (e) {
112
- setCallOnResize(true);
113
- var KEYBOARD_OFFSET = 10;
114
- switch (e.key) {
115
- case keys.ARROW_RIGHT:
116
- e.preventDefault(); // Safari+VO will screen reader navigate off the button otherwise
117
- setFlyoutWidth(function (flyoutWidth) {
118
- return getFlyoutMinMaxWidth(flyoutWidth + KEYBOARD_OFFSET * direction);
119
- });
120
- break;
121
- case keys.ARROW_LEFT:
122
- e.preventDefault(); // Safari+VO will screen reader navigate off the button otherwise
123
- setFlyoutWidth(function (flyoutWidth) {
124
- return getFlyoutMinMaxWidth(flyoutWidth - KEYBOARD_OFFSET * direction);
125
- });
126
- }
127
- }, [getFlyoutMinMaxWidth, direction]);
128
-
129
- // To reduce unnecessary calls, only fire onResize callback:
130
- // 1. After initial mount / on user width change events only
131
- // 2. If not currently mouse dragging
132
- useEffect(function () {
133
- if (callOnResize) {
134
- onResize === null || onResize === void 0 || onResize(flyoutWidth);
135
- }
136
- }, [onResize, callOnResize, flyoutWidth]);
137
- return ___EmotionJSX(EuiFlyout, _extends({}, rest, {
138
- size: flyoutWidth || size,
139
- maxWidth: maxWidth,
140
- side: side,
141
- type: type,
142
- ownFocus: ownFocus,
143
- ref: setRefs
144
- }), ___EmotionJSX(EuiResizableButton, {
145
- isHorizontal: true,
146
- indicator: "border",
147
- css: cssStyles,
148
- onMouseDown: onMouseDown,
149
- onTouchStart: onMouseDown,
150
- onKeyDown: onKeyDown
151
- }), children);
15
+ export var EuiFlyoutResizable = /*#__PURE__*/forwardRef(function (props, ref) {
16
+ return ___EmotionJSX(EuiFlyout, _extends({
17
+ ref: ref
18
+ }, props, {
19
+ resizable: true
20
+ }));
152
21
  });
153
22
  EuiFlyoutResizable.displayName = 'EuiFlyoutResizable';
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { useIsWithinMinBreakpoint } from '../../services';
10
+ import { usePropsWithComponentDefaults } from '../provider/component_defaults';
11
+ import { DEFAULT_PUSH_MIN_BREAKPOINT, DEFAULT_TYPE } from './const';
12
+
13
+ /**
14
+ * Determines if a flyout should be rendered in a "pushed" state based on its
15
+ * configuration and the current window size.
16
+ */
17
+ export var useIsPushed = function useIsPushed(props) {
18
+ var _usePropsWithComponen = usePropsWithComponentDefaults('EuiFlyout', props),
19
+ _usePropsWithComponen2 = _usePropsWithComponen.type,
20
+ type = _usePropsWithComponen2 === void 0 ? DEFAULT_TYPE : _usePropsWithComponen2,
21
+ _usePropsWithComponen3 = _usePropsWithComponen.pushMinBreakpoint,
22
+ pushMinBreakpoint = _usePropsWithComponen3 === void 0 ? DEFAULT_PUSH_MIN_BREAKPOINT : _usePropsWithComponen3;
23
+ var windowIsLargeEnoughToPush = useIsWithinMinBreakpoint(pushMinBreakpoint);
24
+ return type === 'push' && windowIsLargeEnoughToPush;
25
+ };
@@ -12,5 +12,8 @@ export { EuiFlyoutFooter } from './flyout_footer';
12
12
  export { EuiFlyoutHeader } from './flyout_header';
13
13
  export { euiFlyoutSlideInRight, euiFlyoutSlideInLeft } from './flyout.styles';
14
14
  export { EuiFlyoutResizable } from './flyout_resizable';
15
- export { EuiFlyoutChild } from './flyout_child';
16
- export { EuiFlyoutSessionProvider, useEuiFlyoutSession } from './sessions';
15
+ export { EuiFlyoutMenu } from './flyout_menu';
16
+
17
+ // Hooks for using Manager-based flyouts
18
+ export { useIsInManagedFlyout, useHasActiveSession } from './manager';
19
+ export { useIsInsideParentFlyout } from './flyout_parent_context';
@@ -0,0 +1,153 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { LEVEL_MAIN } from './const';
10
+ var PREFIX = 'eui/flyoutManager';
11
+ /** Dispatched when a flyout registers itself with the manager. */
12
+ export var ACTION_ADD = "".concat(PREFIX, "/add");
13
+ /** Dispatched to remove a flyout from the manager (usually on close/unmount). */
14
+ export var ACTION_CLOSE = "".concat(PREFIX, "/close");
15
+ /** Dispatched to set which flyout is currently active within the session. */
16
+ export var ACTION_SET_ACTIVE = "".concat(PREFIX, "/setActive");
17
+ /** Dispatched when an active flyout's pixel width changes (for responsive layout). */
18
+ export var ACTION_SET_WIDTH = "".concat(PREFIX, "/setWidth");
19
+ /** Dispatched to switch layout mode between `side-by-side` and `stacked`. */
20
+ export var ACTION_SET_LAYOUT_MODE = "".concat(PREFIX, "/setLayoutMode");
21
+ /** Dispatched to update a flyout's activity stage (e.g., opening -> active). */
22
+ export var ACTION_SET_ACTIVITY_STAGE = "".concat(PREFIX, "/setActivityStage");
23
+ /** Dispatched to go back one session (remove current session). */
24
+ export var ACTION_GO_BACK = "".concat(PREFIX, "/goBack");
25
+ /** Dispatched to navigate to a specific flyout (remove all sessions after it). */
26
+ export var ACTION_GO_TO_FLYOUT = "".concat(PREFIX, "/goToFlyout");
27
+ /** Dispatched to set push padding offset for a side. */
28
+ export var ACTION_SET_PUSH_PADDING = "".concat(PREFIX, "/setPushPadding");
29
+ export var ACTION_ADD_UNMANAGED_FLYOUT = "".concat(PREFIX, "/addUnmanagedFlyout");
30
+ export var ACTION_CLOSE_UNMANAGED_FLYOUT = "".concat(PREFIX, "/closeUnmanagedFlyout");
31
+
32
+ /**
33
+ * Add a flyout to manager state. The manager will create or update
34
+ * the current session depending on the `level` provided.
35
+ */
36
+
37
+ /** Remove a flyout from manager state. Also updates the active session. */
38
+
39
+ /** Set the active flyout within the current session (or clear with `null`). */
40
+
41
+ /** Update a flyout's measured width in pixels. */
42
+
43
+ /** Change how flyouts are arranged: `side-by-side` or `stacked`. */
44
+
45
+ /** Set a specific flyout's activity stage. */
46
+
47
+ /** Go back one session (remove current session from stack). */
48
+
49
+ /** Navigate to a specific flyout (remove all sessions after it). */
50
+
51
+ /** Set push padding offset for a specific side. */
52
+
53
+ /** Union of all flyout manager actions. */
54
+
55
+ /**
56
+ * Register a flyout with the manager.
57
+ * - `title` is used for the flyout menu.
58
+ * - `level` determines whether the flyout is `main` or `child`.
59
+ * - Optional `size` is the named EUI size (e.g. `s`, `m`, `l`).
60
+ */
61
+ export var addFlyout = function addFlyout(flyoutId, title) {
62
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : LEVEL_MAIN;
63
+ var size = arguments.length > 3 ? arguments[3] : undefined;
64
+ return {
65
+ type: ACTION_ADD,
66
+ flyoutId: flyoutId,
67
+ title: title,
68
+ level: level,
69
+ size: size
70
+ };
71
+ };
72
+
73
+ /** Unregister a flyout and update the session accordingly. */
74
+ export var closeFlyout = function closeFlyout(flyoutId) {
75
+ return {
76
+ type: ACTION_CLOSE,
77
+ flyoutId: flyoutId
78
+ };
79
+ };
80
+
81
+ /** Set or clear the active flyout for the current session. */
82
+ export var setActiveFlyout = function setActiveFlyout(flyoutId) {
83
+ return {
84
+ type: ACTION_SET_ACTIVE,
85
+ flyoutId: flyoutId
86
+ };
87
+ };
88
+
89
+ /** Record a flyout's current width in pixels. */
90
+ export var setFlyoutWidth = function setFlyoutWidth(flyoutId, width) {
91
+ return {
92
+ type: ACTION_SET_WIDTH,
93
+ flyoutId: flyoutId,
94
+ width: width
95
+ };
96
+ };
97
+
98
+ /** Switch layout mode between `side-by-side` and `stacked`. */
99
+ export var setLayoutMode = function setLayoutMode(layoutMode) {
100
+ return {
101
+ type: ACTION_SET_LAYOUT_MODE,
102
+ layoutMode: layoutMode
103
+ };
104
+ };
105
+
106
+ /** Update a flyout's activity stage. */
107
+ export var setActivityStage = function setActivityStage(flyoutId, activityStage) {
108
+ return {
109
+ type: ACTION_SET_ACTIVITY_STAGE,
110
+ flyoutId: flyoutId,
111
+ activityStage: activityStage
112
+ };
113
+ };
114
+
115
+ /** Go back one session (remove current session from stack). */
116
+ export var goBack = function goBack() {
117
+ return {
118
+ type: ACTION_GO_BACK
119
+ };
120
+ };
121
+
122
+ /** Navigate to a specific flyout (remove all sessions after it). */
123
+ export var goToFlyout = function goToFlyout(flyoutId) {
124
+ return {
125
+ type: ACTION_GO_TO_FLYOUT,
126
+ flyoutId: flyoutId
127
+ };
128
+ };
129
+
130
+ /** Set push padding offset for a specific side. */
131
+ export var setPushPadding = function setPushPadding(side, width) {
132
+ return {
133
+ type: ACTION_SET_PUSH_PADDING,
134
+ side: side,
135
+ width: width
136
+ };
137
+ };
138
+
139
+ /** Register an unmanaged flyout for z-index positioning purposes */
140
+ export var addUnmanagedFlyout = function addUnmanagedFlyout(flyoutId) {
141
+ return {
142
+ type: ACTION_ADD_UNMANAGED_FLYOUT,
143
+ flyoutId: flyoutId
144
+ };
145
+ };
146
+
147
+ /** Unregister an unmanaged flyout */
148
+ export var closeUnmanagedFlyout = function closeUnmanagedFlyout(flyoutId) {
149
+ return {
150
+ type: ACTION_CLOSE_UNMANAGED_FLYOUT,
151
+ flyoutId: flyoutId
152
+ };
153
+ };
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ import { useCallback, useEffect, useRef } from 'react';
10
+ import { LAYOUT_MODE_SIDE_BY_SIDE, LAYOUT_MODE_STACKED, LEVEL_MAIN, STAGE_ACTIVE, STAGE_BACKGROUNDED, STAGE_BACKGROUNDING, STAGE_CLOSING, STAGE_INACTIVE, STAGE_OPENING, STAGE_RETURNING } from './const';
11
+ import { useFlyoutLayoutMode, useHasChildFlyout, useIsFlyoutActive } from './hooks';
12
+ import { setActivityStage } from './actions';
13
+ import { useFlyoutManager } from './provider';
14
+ /**
15
+ * Encapsulates all activity-stage transitions and animation-driven updates
16
+ * for managed flyouts.
17
+ */
18
+ export var useFlyoutActivityStage = function useFlyoutActivityStage(_ref) {
19
+ var _ctx$state$flyouts$fi;
20
+ var flyoutId = _ref.flyoutId,
21
+ level = _ref.level;
22
+ var isActive = useIsFlyoutActive(flyoutId);
23
+ var hasChild = useHasChildFlyout(flyoutId);
24
+ var layoutMode = useFlyoutLayoutMode();
25
+ var ctx = useFlyoutManager();
26
+ var stage = (ctx === null || ctx === void 0 || (_ctx$state$flyouts$fi = ctx.state.flyouts.find(function (f) {
27
+ return f.flyoutId === flyoutId;
28
+ })) === null || _ctx$state$flyouts$fi === void 0 ? void 0 : _ctx$state$flyouts$fi.activityStage) || (isActive ? STAGE_ACTIVE : STAGE_INACTIVE);
29
+ var stageRef = useRef(stage);
30
+ if (stageRef.current !== stage) {
31
+ stageRef.current = stage;
32
+ }
33
+
34
+ /**
35
+ * 1. ACTIVE -> CLOSING when no longer the active flyout.
36
+ * 2. INACTIVE -> RETURNING when it becomes active again (e.g., reopened or brought forward).
37
+ * 3. (Main flyout only) ACTIVE + stacked + has child -> BACKGROUNDING (begin background animation).
38
+ * 4. (Main only) BACKGROUNDED/BACKGROUNDING + (child gone OR side-by-side) -> RETURNING (bring main to foreground).
39
+ *
40
+ * Any stages that depend on animation end (OPENING, RETURNING, CLOSING, BACKGROUNDING) are finalized in `onAnimationEnd`.
41
+ */
42
+ useEffect(function () {
43
+ var s = stageRef.current;
44
+ var next = null;
45
+ if (s === STAGE_ACTIVE && !isActive) next = STAGE_CLOSING;else if (s === STAGE_INACTIVE && isActive) {
46
+ next = STAGE_RETURNING;
47
+ } else if (level === LEVEL_MAIN && isActive && s === STAGE_ACTIVE && hasChild && layoutMode === LAYOUT_MODE_STACKED) next = STAGE_BACKGROUNDING;else if (level === LEVEL_MAIN && (s === STAGE_BACKGROUNDED || s === STAGE_BACKGROUNDING) && (!hasChild || layoutMode === LAYOUT_MODE_SIDE_BY_SIDE)) next = STAGE_RETURNING;
48
+ if (next && next !== s) {
49
+ var _ctx$dispatch;
50
+ ctx === null || ctx === void 0 || (_ctx$dispatch = ctx.dispatch) === null || _ctx$dispatch === void 0 || _ctx$dispatch.call(ctx, setActivityStage(flyoutId, next));
51
+ stageRef.current = next;
52
+ }
53
+ }, [isActive, hasChild, layoutMode, level, ctx, flyoutId, stage]);
54
+
55
+ /**
56
+ * Get the stage to transition to for given current stage.
57
+ * Returns `null` if stage should remain unchanged.
58
+ *
59
+ * Stage transitions:
60
+ * - OPENING / RETURNING -> ACTIVE
61
+ * - CLOSING -> INACTIVE
62
+ * - BACKGROUNDING -> BACKGROUNDED
63
+ */
64
+ var getNextStage = function getNextStage(stage) {
65
+ switch (stage) {
66
+ case STAGE_OPENING:
67
+ case STAGE_RETURNING:
68
+ return STAGE_ACTIVE;
69
+ case STAGE_CLOSING:
70
+ return STAGE_INACTIVE;
71
+ case STAGE_BACKGROUNDING:
72
+ return STAGE_BACKGROUNDED;
73
+ }
74
+ return null;
75
+ };
76
+
77
+ /**
78
+ * onAnimationEnd event handler that must be passed to EuiFlyout.
79
+ * It handles transitions between stages and updates activity stage
80
+ * in EuiFlyoutManagerContext.
81
+ */
82
+ var onAnimationEnd = useCallback(function () {
83
+ var currentStage = stageRef.current;
84
+ var nextStage = getNextStage(currentStage);
85
+ if (nextStage && nextStage !== currentStage) {
86
+ var _ctx$dispatch2;
87
+ ctx === null || ctx === void 0 || (_ctx$dispatch2 = ctx.dispatch) === null || _ctx$dispatch2 === void 0 || _ctx$dispatch2.call(ctx, setActivityStage(flyoutId, nextStage));
88
+ stageRef.current = nextStage;
89
+ }
90
+ }, [ctx, flyoutId]);
91
+ return {
92
+ activityStage: stage,
93
+ onAnimationEnd: onAnimationEnd
94
+ };
95
+ };