@elastic/eui 113.2.1 → 114.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 (142) hide show
  1. package/es/components/basic_table/collapsed_item_actions.js +2 -0
  2. package/es/components/button/split_button/split_button.js +13 -0
  3. package/es/components/button/split_button/split_button_actions.js +15 -0
  4. package/es/components/collapsible_nav/collapsible_nav.js +5 -0
  5. package/es/components/color_picker/color_picker.js +31 -8
  6. package/es/components/context_menu/context_menu_item.js +9 -3
  7. package/es/components/context_menu/context_menu_item.styles.js +6 -2
  8. package/es/components/datagrid/utils/scrolling.js +39 -10
  9. package/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  10. package/es/components/flyout/_flyout_overlay.js +34 -4
  11. package/es/components/flyout/const.js +10 -0
  12. package/es/components/flyout/flyout.component.js +49 -57
  13. package/es/components/flyout/flyout.js +10 -2
  14. package/es/components/flyout/flyout.styles.js +2 -2
  15. package/es/components/flyout/flyout_menu.js +19 -5
  16. package/es/components/flyout/flyout_resizable.js +5 -0
  17. package/es/components/flyout/manager/actions.js +12 -5
  18. package/es/components/flyout/manager/flyout_child.js +9 -2
  19. package/es/components/flyout/manager/flyout_managed.js +27 -14
  20. package/es/components/flyout/manager/reducer.js +251 -54
  21. package/es/components/flyout/manager/store.js +74 -12
  22. package/es/components/flyout/use_flyout_menu.js +70 -0
  23. package/es/components/form/file_picker/file_picker.js +46 -18
  24. package/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  25. package/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
  26. package/es/components/overlay_mask/overlay_mask.js +10 -3
  27. package/es/components/tree_view/tree_view_item.styles.js +1 -1
  28. package/es/services/hooks/index.js +8 -8
  29. package/es/services/hooks/useIsPointerDown.js +6 -15
  30. package/es/services/index.js +1 -1
  31. package/eui.d.ts +477 -63
  32. package/i18ntokens.json +661 -643
  33. package/lib/components/basic_table/collapsed_item_actions.js +2 -0
  34. package/lib/components/button/split_button/split_button.js +13 -0
  35. package/lib/components/button/split_button/split_button_actions.js +15 -0
  36. package/lib/components/collapsible_nav/collapsible_nav.js +5 -0
  37. package/lib/components/color_picker/color_picker.js +30 -7
  38. package/lib/components/context_menu/context_menu_item.js +9 -3
  39. package/lib/components/context_menu/context_menu_item.styles.js +5 -1
  40. package/lib/components/datagrid/utils/scrolling.js +37 -8
  41. package/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  42. package/lib/components/flyout/_flyout_overlay.js +33 -3
  43. package/lib/components/flyout/const.js +11 -1
  44. package/lib/components/flyout/flyout.component.js +48 -56
  45. package/lib/components/flyout/flyout.js +15 -1
  46. package/lib/components/flyout/flyout.styles.js +2 -2
  47. package/lib/components/flyout/flyout_menu.js +19 -5
  48. package/lib/components/flyout/flyout_resizable.js +5 -0
  49. package/lib/components/flyout/manager/actions.js +12 -5
  50. package/lib/components/flyout/manager/flyout_child.js +9 -2
  51. package/lib/components/flyout/manager/flyout_managed.js +19 -12
  52. package/lib/components/flyout/manager/reducer.js +250 -53
  53. package/lib/components/flyout/manager/store.js +74 -14
  54. package/lib/components/flyout/use_flyout_menu.js +75 -0
  55. package/lib/components/form/file_picker/file_picker.js +46 -18
  56. package/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  57. package/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  58. package/lib/components/overlay_mask/overlay_mask.js +10 -3
  59. package/lib/components/tree_view/tree_view_item.styles.js +1 -1
  60. package/lib/services/hooks/index.js +60 -91
  61. package/lib/services/hooks/useIsPointerDown.js +7 -14
  62. package/lib/services/index.js +70 -11
  63. package/optimize/es/components/basic_table/collapsed_item_actions.js +2 -0
  64. package/optimize/es/components/color_picker/color_picker.js +31 -8
  65. package/optimize/es/components/context_menu/context_menu_item.js +3 -2
  66. package/optimize/es/components/context_menu/context_menu_item.styles.js +6 -2
  67. package/optimize/es/components/datagrid/utils/scrolling.js +39 -10
  68. package/optimize/es/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  69. package/optimize/es/components/flyout/_flyout_overlay.js +34 -4
  70. package/optimize/es/components/flyout/const.js +10 -0
  71. package/optimize/es/components/flyout/flyout.component.js +49 -57
  72. package/optimize/es/components/flyout/flyout.js +5 -2
  73. package/optimize/es/components/flyout/flyout.styles.js +2 -2
  74. package/optimize/es/components/flyout/flyout_menu.js +7 -3
  75. package/optimize/es/components/flyout/manager/actions.js +12 -5
  76. package/optimize/es/components/flyout/manager/flyout_managed.js +18 -12
  77. package/optimize/es/components/flyout/manager/reducer.js +251 -54
  78. package/optimize/es/components/flyout/manager/store.js +69 -12
  79. package/optimize/es/components/flyout/use_flyout_menu.js +69 -0
  80. package/optimize/es/components/form/file_picker/file_picker.js +35 -18
  81. package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  82. package/optimize/es/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +172 -0
  83. package/optimize/es/components/overlay_mask/overlay_mask.js +4 -2
  84. package/optimize/es/components/tree_view/tree_view_item.styles.js +1 -1
  85. package/optimize/es/services/hooks/index.js +8 -8
  86. package/optimize/es/services/hooks/useIsPointerDown.js +6 -10
  87. package/optimize/es/services/index.js +1 -1
  88. package/optimize/lib/components/basic_table/collapsed_item_actions.js +2 -0
  89. package/optimize/lib/components/color_picker/color_picker.js +30 -7
  90. package/optimize/lib/components/context_menu/context_menu_item.js +3 -2
  91. package/optimize/lib/components/context_menu/context_menu_item.styles.js +5 -1
  92. package/optimize/lib/components/datagrid/utils/scrolling.js +37 -8
  93. package/optimize/lib/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  94. package/optimize/lib/components/flyout/_flyout_overlay.js +33 -3
  95. package/optimize/lib/components/flyout/const.js +11 -1
  96. package/optimize/lib/components/flyout/flyout.component.js +48 -56
  97. package/optimize/lib/components/flyout/flyout.js +10 -1
  98. package/optimize/lib/components/flyout/flyout.styles.js +2 -2
  99. package/optimize/lib/components/flyout/flyout_menu.js +7 -3
  100. package/optimize/lib/components/flyout/manager/actions.js +12 -5
  101. package/optimize/lib/components/flyout/manager/flyout_managed.js +18 -12
  102. package/optimize/lib/components/flyout/manager/reducer.js +250 -53
  103. package/optimize/lib/components/flyout/manager/store.js +70 -12
  104. package/optimize/lib/components/flyout/use_flyout_menu.js +74 -0
  105. package/optimize/lib/components/form/file_picker/file_picker.js +35 -18
  106. package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  107. package/optimize/lib/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  108. package/optimize/lib/components/overlay_mask/overlay_mask.js +4 -2
  109. package/optimize/lib/components/tree_view/tree_view_item.styles.js +1 -1
  110. package/optimize/lib/services/hooks/index.js +60 -91
  111. package/optimize/lib/services/hooks/useIsPointerDown.js +5 -10
  112. package/optimize/lib/services/index.js +70 -11
  113. package/package.json +4 -4
  114. package/test-env/components/basic_table/collapsed_item_actions.js +2 -0
  115. package/test-env/components/button/split_button/split_button.js +13 -0
  116. package/test-env/components/button/split_button/split_button_actions.js +15 -0
  117. package/test-env/components/collapsible_nav/collapsible_nav.js +5 -0
  118. package/test-env/components/color_picker/color_picker.js +30 -7
  119. package/test-env/components/context_menu/context_menu_item.js +9 -3
  120. package/test-env/components/context_menu/context_menu_item.styles.js +5 -1
  121. package/test-env/components/datagrid/utils/scrolling.js +37 -8
  122. package/test-env/components/date_picker/super_date_picker/time_window_buttons.js +17 -3
  123. package/test-env/components/flyout/_flyout_overlay.js +33 -3
  124. package/test-env/components/flyout/const.js +11 -1
  125. package/test-env/components/flyout/flyout.component.js +48 -56
  126. package/test-env/components/flyout/flyout.styles.js +2 -2
  127. package/test-env/components/flyout/flyout_menu.js +19 -5
  128. package/test-env/components/flyout/flyout_resizable.js +5 -0
  129. package/test-env/components/flyout/manager/actions.js +12 -5
  130. package/test-env/components/flyout/manager/flyout_child.js +9 -2
  131. package/test-env/components/flyout/manager/flyout_managed.js +19 -12
  132. package/test-env/components/flyout/manager/reducer.js +250 -53
  133. package/test-env/components/flyout/manager/store.js +70 -12
  134. package/test-env/components/flyout/use_flyout_menu.js +74 -0
  135. package/test-env/components/form/file_picker/file_picker.js +46 -18
  136. package/test-env/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +2 -1
  137. package/test-env/components/markdown_editor/plugins/remark/remark_intraword_underscore.js +179 -0
  138. package/test-env/components/overlay_mask/overlay_mask.js +10 -3
  139. package/test-env/components/tree_view/tree_view_item.styles.js +1 -1
  140. package/test-env/services/hooks/index.js +60 -91
  141. package/test-env/services/hooks/useIsPointerDown.js +5 -10
  142. package/test-env/services/index.js +70 -11
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
19
19
  */
20
20
 
21
21
  import { ACTION_ADD, ACTION_CLOSE, ACTION_CLOSE_ALL, ACTION_SET_ACTIVE, ACTION_SET_LAYOUT_MODE, ACTION_SET_WIDTH, ACTION_SET_ACTIVITY_STAGE, ACTION_GO_BACK, ACTION_GO_TO_FLYOUT, ACTION_SET_PUSH_PADDING, ACTION_ADD_UNMANAGED_FLYOUT, ACTION_CLOSE_UNMANAGED_FLYOUT, ACTION_SET_CONTAINER_ELEMENT, ACTION_SET_REFERENCE_WIDTH } from './actions';
22
- import { LAYOUT_MODE_SIDE_BY_SIDE, LEVEL_MAIN, STAGE_OPENING } from './const';
22
+ import { LAYOUT_MODE_SIDE_BY_SIDE, LEVEL_MAIN, LEVEL_CHILD, STAGE_OPENING } from './const';
23
23
  /**
24
24
  * Default flyout manager state used to initialize the reducer.
25
25
  */
@@ -34,6 +34,28 @@ export var initialState = {
34
34
  currentZIndex: 0,
35
35
  unmanagedFlyouts: []
36
36
  };
37
+ var addSessionFlyoutsToRemove = function addSessionFlyoutsToRemove(session, flyoutsToRemove) {
38
+ var _session$childHistory;
39
+ flyoutsToRemove.add(session.mainFlyoutId);
40
+ if (session.childFlyoutId) {
41
+ flyoutsToRemove.add(session.childFlyoutId);
42
+ }
43
+ ((_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : []).forEach(function (e) {
44
+ return flyoutsToRemove.add(e.flyoutId);
45
+ });
46
+ };
47
+ var moveHistoryGroupToTop = function moveHistoryGroupToTop(sessions, historyKey) {
48
+ var groupSessions = [];
49
+ var otherSessions = [];
50
+ sessions.forEach(function (session) {
51
+ if (session.historyKey === historyKey) {
52
+ groupSessions.push(session);
53
+ } else {
54
+ otherSessions.push(session);
55
+ }
56
+ });
57
+ return [].concat(otherSessions, groupSessions);
58
+ };
37
59
 
38
60
  /**
39
61
  * Reducer handling all flyout manager actions and state transitions.
@@ -77,16 +99,21 @@ export function flyoutManagerReducer() {
77
99
  // session exists, do nothing (invalid child without a parent).
78
100
  case ACTION_ADD:
79
101
  {
102
+ var _currentSession$child;
80
103
  var flyoutId = action.flyoutId,
81
104
  title = action.title,
82
105
  level = action.level,
83
106
  size = action.size,
107
+ historyKey = action.historyKey,
108
+ iconType = action.iconType,
84
109
  minWidth = action.minWidth;
85
-
86
- // Ignore duplicate registrations
87
- if (state.flyouts.some(function (f) {
110
+ var isDuplicate = state.flyouts.some(function (f) {
88
111
  return f.flyoutId === flyoutId;
89
- })) {
112
+ });
113
+ var isIdempotentChild = level === LEVEL_CHILD && state.sessions.length > 0 && state.sessions[state.sessions.length - 1].childFlyoutId === flyoutId;
114
+
115
+ // Ignore duplicate registrations (except idempotent child re-registration after goBack)
116
+ if (isDuplicate && !isIdempotentChild) {
90
117
  return state;
91
118
  }
92
119
  var newFlyoutState = {
@@ -96,13 +123,16 @@ export function flyoutManagerReducer() {
96
123
  minWidth: minWidth,
97
124
  activityStage: STAGE_OPENING
98
125
  };
99
- var newFlyouts = [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
126
+ var newFlyouts = isIdempotentChild ? state.flyouts : [].concat(_toConsumableArray(state.flyouts), [newFlyoutState]);
100
127
  if (level === LEVEL_MAIN) {
101
128
  var newSession = {
102
129
  mainFlyoutId: flyoutId,
103
130
  title: title,
131
+ iconType: iconType,
104
132
  childFlyoutId: null,
105
- zIndex: state.currentZIndex
133
+ childHistory: [],
134
+ zIndex: state.currentZIndex,
135
+ historyKey: historyKey !== null && historyKey !== void 0 ? historyKey : Symbol()
106
136
  };
107
137
  return _objectSpread(_objectSpread({}, state), {}, {
108
138
  sessions: [].concat(_toConsumableArray(state.sessions), [newSession]),
@@ -118,8 +148,52 @@ export function flyoutManagerReducer() {
118
148
  }
119
149
  var updatedSessions = _toConsumableArray(state.sessions);
120
150
  var currentSessionIndex = updatedSessions.length - 1;
121
- updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, updatedSessions[currentSessionIndex]), {}, {
122
- childFlyoutId: flyoutId
151
+ var currentSession = updatedSessions[currentSessionIndex];
152
+ var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
153
+
154
+ // Idempotent re-registration (e.g. after goBack): flyout already in flyouts and session already points to it
155
+ if (state.flyouts.some(function (f) {
156
+ return f.flyoutId === flyoutId;
157
+ })) {
158
+ if (currentSession.childFlyoutId === flyoutId) {
159
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
160
+ childTitle: title,
161
+ childIconType: iconType,
162
+ childHistory: childHistory
163
+ });
164
+ return _objectSpread(_objectSpread({}, state), {}, {
165
+ sessions: updatedSessions
166
+ });
167
+ }
168
+ return state; // duplicate registration for a different child, ignore
169
+ }
170
+
171
+ // Session already has a child: push current child to history, then set new child (do not remove previous from flyouts)
172
+ if (currentSession.childFlyoutId) {
173
+ var _currentSession$child2;
174
+ var historyEntry = {
175
+ flyoutId: currentSession.childFlyoutId,
176
+ title: (_currentSession$child2 = currentSession.childTitle) !== null && _currentSession$child2 !== void 0 ? _currentSession$child2 : '',
177
+ iconType: currentSession.childIconType
178
+ };
179
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
180
+ childHistory: [].concat(_toConsumableArray(childHistory), [historyEntry]),
181
+ childFlyoutId: flyoutId,
182
+ childTitle: title,
183
+ childIconType: iconType
184
+ });
185
+ return _objectSpread(_objectSpread({}, state), {}, {
186
+ sessions: updatedSessions,
187
+ flyouts: newFlyouts
188
+ });
189
+ }
190
+
191
+ // First child in session
192
+ updatedSessions[currentSessionIndex] = _objectSpread(_objectSpread({}, currentSession), {}, {
193
+ childFlyoutId: flyoutId,
194
+ childTitle: title,
195
+ childIconType: iconType,
196
+ childHistory: childHistory
123
197
  });
124
198
  return _objectSpread(_objectSpread({}, state), {}, {
125
199
  sessions: updatedSessions,
@@ -129,10 +203,11 @@ export function flyoutManagerReducer() {
129
203
 
130
204
  // Unregister a flyout and update sessions accordingly.
131
205
  // - When closing a `main` flyout, drop its entire session and all associated flyouts.
132
- // - When closing a `child` flyout, clear the child pointer on the most
133
- // recent session if it matches.
206
+ // - When closing a `child` flyout, find the session that owns it (childFlyoutId or
207
+ // childHistory) and clear that session's child state so navigation back stays consistent.
134
208
  case ACTION_CLOSE:
135
209
  {
210
+ var _owningSession$childH;
136
211
  var removedFlyout = state.flyouts.find(function (f) {
137
212
  return f.flyoutId === action.flyoutId;
138
213
  });
@@ -145,11 +220,15 @@ export function flyoutManagerReducer() {
145
220
  return session.mainFlyoutId === action.flyoutId;
146
221
  });
147
222
  if (sessionToRemove) {
148
- // Remove all flyouts associated with this session (main + child)
223
+ var _sessionToRemove$chil;
224
+ // Remove all flyouts associated with this session (main + current child + child history)
149
225
  var flyoutsToRemove = new Set([action.flyoutId]);
150
226
  if (sessionToRemove.childFlyoutId) {
151
227
  flyoutsToRemove.add(sessionToRemove.childFlyoutId);
152
228
  }
229
+ ((_sessionToRemove$chil = sessionToRemove.childHistory) !== null && _sessionToRemove$chil !== void 0 ? _sessionToRemove$chil : []).forEach(function (entry) {
230
+ return flyoutsToRemove.add(entry.flyoutId);
231
+ });
153
232
  var _newFlyouts = state.flyouts.filter(function (f) {
154
233
  return !flyoutsToRemove.has(f.flyoutId);
155
234
  });
@@ -170,43 +249,80 @@ export function flyoutManagerReducer() {
170
249
  }
171
250
  }
172
251
 
173
- // Handle child flyout closing (existing logic)
174
- var _newFlyouts2 = state.flyouts.filter(function (f) {
175
- return f.flyoutId !== action.flyoutId;
176
- });
252
+ // Handle child flyout closing: find the session that owns this child and
253
+ // clear that session's child state (so we stay consistent when navigating back).
177
254
  if (state.sessions.length === 0) {
178
255
  return _objectSpread(_objectSpread({}, state), {}, {
179
- flyouts: _newFlyouts2
256
+ flyouts: state.flyouts.filter(function (f) {
257
+ return f.flyoutId !== action.flyoutId;
258
+ })
180
259
  });
181
260
  }
182
- var _updatedSessions = _toConsumableArray(state.sessions);
183
- var _currentSessionIndex = _updatedSessions.length - 1;
184
- if (_updatedSessions[_currentSessionIndex].childFlyoutId === action.flyoutId) {
185
- _updatedSessions[_currentSessionIndex] = _objectSpread(_objectSpread({}, _updatedSessions[_currentSessionIndex]), {}, {
186
- childFlyoutId: null
261
+ var owningSessionIndex = state.sessions.findIndex(function (session) {
262
+ var _session$childHistory2;
263
+ return session.childFlyoutId === action.flyoutId || ((_session$childHistory2 = session.childHistory) !== null && _session$childHistory2 !== void 0 ? _session$childHistory2 : []).some(function (entry) {
264
+ return entry.flyoutId === action.flyoutId;
265
+ });
266
+ });
267
+ if (owningSessionIndex === -1) {
268
+ // Closed flyout not in any session's child state; just remove the one flyout
269
+ return _objectSpread(_objectSpread({}, state), {}, {
270
+ flyouts: state.flyouts.filter(function (f) {
271
+ return f.flyoutId !== action.flyoutId;
272
+ })
187
273
  });
188
274
  }
275
+ var owningSession = state.sessions[owningSessionIndex];
276
+ var childIds = new Set([owningSession.childFlyoutId].concat(_toConsumableArray(((_owningSession$childH = owningSession.childHistory) !== null && _owningSession$childH !== void 0 ? _owningSession$childH : []).map(function (e) {
277
+ return e.flyoutId;
278
+ }))).filter(Boolean));
279
+ var _newFlyouts2 = state.flyouts.filter(function (f) {
280
+ return !childIds.has(f.flyoutId);
281
+ });
282
+ var _updatedSessions = _toConsumableArray(state.sessions);
283
+ _updatedSessions[owningSessionIndex] = _objectSpread(_objectSpread({}, owningSession), {}, {
284
+ childFlyoutId: null,
285
+ childTitle: undefined,
286
+ childIconType: undefined,
287
+ childHistory: []
288
+ });
189
289
  return _objectSpread(_objectSpread({}, state), {}, {
190
290
  sessions: _updatedSessions,
191
291
  flyouts: _newFlyouts2
192
292
  });
193
293
  }
194
294
 
195
- // Unregister all flyouts.
295
+ // Unregister all flyouts (within the current history group only).
196
296
  case ACTION_CLOSE_ALL:
197
297
  {
198
298
  if (state.sessions.length === 0) {
199
299
  return state;
200
300
  }
301
+ var _currentSessionIndex = state.sessions.length - 1;
302
+ var _currentSession = state.sessions[_currentSessionIndex];
303
+ var currentKey = _currentSession.historyKey;
201
304
 
202
- // Reset current z-index to 0 only if no unmanaged flyouts remain.
305
+ // Remove all sessions that have the current historyKey (entire group)
306
+ var _newSessions = state.sessions.filter(function (s) {
307
+ return s.historyKey !== currentKey;
308
+ });
309
+ var _flyoutsToRemove = new Set();
310
+ state.sessions.forEach(function (session) {
311
+ if (session.historyKey === currentKey) {
312
+ addSessionFlyoutsToRemove(session, _flyoutsToRemove);
313
+ }
314
+ });
315
+ var _newFlyouts3 = state.flyouts.filter(function (f) {
316
+ return !_flyoutsToRemove.has(f.flyoutId);
317
+ });
203
318
  var _newCurrentZIndex2 = state.currentZIndex;
204
- if (state.unmanagedFlyouts.length === 0) {
319
+ if (_newSessions.length === 0 && state.unmanagedFlyouts.length === 0) {
205
320
  _newCurrentZIndex2 = 0;
206
321
  }
207
- return _objectSpread(_objectSpread({}, initialState), {}, {
208
- currentZIndex: _newCurrentZIndex2,
209
- unmanagedFlyouts: state.unmanagedFlyouts
322
+ return _objectSpread(_objectSpread({}, state), {}, {
323
+ sessions: _newSessions,
324
+ flyouts: _newFlyouts3,
325
+ currentZIndex: _newCurrentZIndex2
210
326
  });
211
327
  }
212
328
 
@@ -265,59 +381,140 @@ export function flyoutManagerReducer() {
265
381
  });
266
382
  }
267
383
 
268
- // Go back one session (remove current session from stack)
384
+ // Go back: pop child history when any, else pop current session (only within same historyKey).
269
385
  case ACTION_GO_BACK:
270
386
  {
387
+ var _currentSession2$chil;
271
388
  if (state.sessions.length === 0) {
272
389
  return state;
273
390
  }
274
391
  var _currentSessionIndex3 = state.sessions.length - 1;
275
- var currentSession = state.sessions[_currentSessionIndex3];
276
-
277
- // Close all flyouts in the current session
278
- var _flyoutsToRemove = new Set([currentSession.mainFlyoutId]);
279
- if (currentSession.childFlyoutId) {
280
- _flyoutsToRemove.add(currentSession.childFlyoutId);
392
+ var _currentSession2 = state.sessions[_currentSessionIndex3];
393
+ var _childHistory = (_currentSession2$chil = _currentSession2.childHistory) !== null && _currentSession2$chil !== void 0 ? _currentSession2$chil : [];
394
+ if (_childHistory.length > 0) {
395
+ // Pop one child: set current child to the last entry in history, remove the current child flyout
396
+ var popped = _childHistory[_childHistory.length - 1];
397
+ var newChildHistory = _childHistory.slice(0, -1);
398
+ var _updatedSessions3 = _toConsumableArray(state.sessions);
399
+ _updatedSessions3[_currentSessionIndex3] = _objectSpread(_objectSpread({}, _currentSession2), {}, {
400
+ childHistory: newChildHistory,
401
+ childFlyoutId: popped.flyoutId,
402
+ childTitle: popped.title,
403
+ childIconType: popped.iconType
404
+ });
405
+ var _newFlyouts4 = state.flyouts.filter(function (f) {
406
+ return f.flyoutId !== _currentSession2.childFlyoutId;
407
+ });
408
+ return _objectSpread(_objectSpread({}, state), {}, {
409
+ sessions: _updatedSessions3,
410
+ flyouts: _newFlyouts4
411
+ });
281
412
  }
282
- var _newFlyouts3 = state.flyouts.filter(function (f) {
283
- return !_flyoutsToRemove.has(f.flyoutId);
413
+
414
+ // No child history: pop current session (main + all its children)
415
+ var _flyoutsToRemove2 = new Set();
416
+ addSessionFlyoutsToRemove(_currentSession2, _flyoutsToRemove2);
417
+ var sessionsWithoutCurrent = state.sessions.slice(0, _currentSessionIndex3);
418
+ var hasRemainingInCurrentGroup = sessionsWithoutCurrent.some(function (s) {
419
+ return s.historyKey === _currentSession2.historyKey;
420
+ });
421
+ var _newSessions2 = hasRemainingInCurrentGroup ? moveHistoryGroupToTop(sessionsWithoutCurrent, _currentSession2.historyKey) : sessionsWithoutCurrent;
422
+ var _newFlyouts5 = state.flyouts.filter(function (f) {
423
+ return !_flyoutsToRemove2.has(f.flyoutId);
284
424
  });
285
- var _newSessions = state.sessions.slice(0, _currentSessionIndex3);
286
425
  return _objectSpread(_objectSpread({}, state), {}, {
287
- sessions: _newSessions,
288
- flyouts: _newFlyouts3
426
+ sessions: _newSessions2,
427
+ flyouts: _newFlyouts5
289
428
  });
290
429
  }
291
430
 
292
- // Navigate to a specific flyout (remove all sessions after it)
431
+ // Navigate to a specific flyout (by main session or by child in current session's history)
293
432
  case ACTION_GO_TO_FLYOUT:
294
433
  {
295
- var _flyoutId3 = action.flyoutId;
434
+ var _flyoutId3 = action.flyoutId,
435
+ _level = action.level;
436
+ var _currentSessionIndex4 = state.sessions.length - 1;
437
+ if (_level === LEVEL_CHILD && state.sessions.length > 0) {
438
+ var _currentSession3$chil;
439
+ var _currentSession3 = state.sessions[_currentSessionIndex4];
440
+ var _childHistory2 = (_currentSession3$chil = _currentSession3.childHistory) !== null && _currentSession3$chil !== void 0 ? _currentSession3$chil : [];
441
+ var targetIndex = _childHistory2.findIndex(function (entry) {
442
+ return entry.flyoutId === _flyoutId3;
443
+ });
444
+ if (targetIndex === -1) {
445
+ return state; // Target child not in history
446
+ }
447
+ var targetEntry = _childHistory2[targetIndex];
448
+ var _newChildHistory = _childHistory2.slice(0, targetIndex);
449
+ var _flyoutsToRemove3 = new Set();
450
+ if (_currentSession3.childFlyoutId) {
451
+ _flyoutsToRemove3.add(_currentSession3.childFlyoutId);
452
+ }
453
+ _childHistory2.slice(targetIndex + 1).forEach(function (e) {
454
+ _flyoutsToRemove3.add(e.flyoutId);
455
+ });
456
+ var _newFlyouts6 = state.flyouts.filter(function (f) {
457
+ return !_flyoutsToRemove3.has(f.flyoutId);
458
+ });
459
+ var _updatedSessions4 = _toConsumableArray(state.sessions);
460
+ _updatedSessions4[_currentSessionIndex4] = _objectSpread(_objectSpread({}, _currentSession3), {}, {
461
+ childHistory: _newChildHistory,
462
+ childFlyoutId: targetEntry.flyoutId,
463
+ childTitle: targetEntry.title,
464
+ childIconType: targetEntry.iconType
465
+ });
466
+ return _objectSpread(_objectSpread({}, state), {}, {
467
+ sessions: _updatedSessions4,
468
+ flyouts: _newFlyouts6
469
+ });
470
+ }
296
471
 
297
- // Find the session containing the target flyout
472
+ // Navigate by main flyout: remove all sessions after the target
298
473
  var targetSessionIndex = state.sessions.findIndex(function (session) {
299
474
  return session.mainFlyoutId === _flyoutId3;
300
475
  });
301
476
  if (targetSessionIndex === -1) {
302
477
  return state; // Target flyout not found
303
478
  }
479
+ var _currentSession4 = state.sessions[_currentSessionIndex4];
480
+ var targetSession = state.sessions[targetSessionIndex];
304
481
 
305
- // Close all sessions after the target session
482
+ // Group-local navigation: keep other history groups, remove only newer sessions in target's group,
483
+ // then bring that group to the top.
484
+ if (targetSession.historyKey === _currentSession4.historyKey) {
485
+ var _flyoutsToRemove4 = new Set();
486
+ var sessionsAfterTargetInGroup = state.sessions.filter(function (session, index) {
487
+ return index > targetSessionIndex && session.historyKey === targetSession.historyKey;
488
+ });
489
+ sessionsAfterTargetInGroup.forEach(function (session) {
490
+ addSessionFlyoutsToRemove(session, _flyoutsToRemove4);
491
+ });
492
+ var sessionsWithoutRemoved = state.sessions.filter(function (session) {
493
+ return !sessionsAfterTargetInGroup.some(function (removed) {
494
+ return removed.mainFlyoutId === session.mainFlyoutId;
495
+ });
496
+ });
497
+ var reorderedSessions = moveHistoryGroupToTop(sessionsWithoutRemoved, targetSession.historyKey);
498
+ var _newFlyouts7 = state.flyouts.filter(function (f) {
499
+ return !_flyoutsToRemove4.has(f.flyoutId);
500
+ });
501
+ return _objectSpread(_objectSpread({}, state), {}, {
502
+ sessions: reorderedSessions,
503
+ flyouts: _newFlyouts7
504
+ });
505
+ }
306
506
  var sessionsToClose = state.sessions.slice(targetSessionIndex + 1);
307
- var _flyoutsToRemove2 = new Set();
507
+ var _flyoutsToRemove5 = new Set();
308
508
  sessionsToClose.forEach(function (session) {
309
- _flyoutsToRemove2.add(session.mainFlyoutId);
310
- if (session.childFlyoutId) {
311
- _flyoutsToRemove2.add(session.childFlyoutId);
312
- }
509
+ addSessionFlyoutsToRemove(session, _flyoutsToRemove5);
313
510
  });
314
- var _newFlyouts4 = state.flyouts.filter(function (f) {
315
- return !_flyoutsToRemove2.has(f.flyoutId);
511
+ var _newFlyouts8 = state.flyouts.filter(function (f) {
512
+ return !_flyoutsToRemove5.has(f.flyoutId);
316
513
  });
317
- var _newSessions2 = state.sessions.slice(0, targetSessionIndex + 1);
514
+ var _newSessions3 = state.sessions.slice(0, targetSessionIndex + 1);
318
515
  return _objectSpread(_objectSpread({}, state), {}, {
319
- sessions: _newSessions2,
320
- flyouts: _newFlyouts4
516
+ sessions: _newSessions3,
517
+ flyouts: _newFlyouts8
321
518
  });
322
519
  }
323
520
 
@@ -1,3 +1,9 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
7
  /*
2
8
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
9
  * or more contributor license agreements. Licensed under the Elastic License
@@ -42,19 +48,75 @@ function createStore() {
42
48
  // The onClick handlers won't execute until after store is fully assigned.
43
49
  // eslint-disable-next-line prefer-const -- Forward declaration requires 'let' not 'const'
44
50
  var store;
45
- var computeHistoryItems = function computeHistoryItems() {
51
+ var computeHistoryItems = function computeHistoryItems(dispatchFn) {
52
+ var _currentSession$child;
46
53
  var currentSessionIndex = currentState.sessions.length - 1;
54
+ var currentSession = currentSessionIndex >= 0 ? currentState.sessions[currentSessionIndex] : null;
55
+ if (!currentSession) {
56
+ return [];
57
+ }
47
58
  var previousSessions = currentState.sessions.slice(0, currentSessionIndex);
48
- return previousSessions.reverse().map(function (_ref) {
49
- var title = _ref.title,
50
- mainFlyoutId = _ref.mainFlyoutId;
59
+ // Only include sessions in the same history group (same historyKey reference)
60
+ var previousSessionsInGroup = previousSessions.filter(function (session) {
61
+ return session.historyKey === currentSession.historyKey;
62
+ });
63
+ var childHistory = (_currentSession$child = currentSession.childHistory) !== null && _currentSession$child !== void 0 ? _currentSession$child : [];
64
+ var childItems = _toConsumableArray(childHistory).reverse().map(function (entry) {
51
65
  return {
52
- title: title,
66
+ title: entry.title,
67
+ iconType: entry.iconType,
53
68
  onClick: function onClick() {
54
- store.dispatch(goToFlyoutAction(mainFlyoutId));
69
+ dispatchFn(goToFlyoutAction(entry.flyoutId, 'child'));
55
70
  }
56
71
  };
57
72
  });
73
+
74
+ // Previous sessions (same group): list each session's current child then its child history
75
+ var previousSessionItems = [];
76
+ var _loop = function _loop() {
77
+ var _session$childHistory;
78
+ var session = previousSessionsInGroup[i];
79
+ var mainTitle = session.title;
80
+ var mainFlyoutId = session.mainFlyoutId;
81
+ var history = (_session$childHistory = session.childHistory) !== null && _session$childHistory !== void 0 ? _session$childHistory : [];
82
+ var hasChildren = session.childFlyoutId != null && session.childTitle != null || history.length > 0;
83
+ if (session.childFlyoutId && session.childTitle) {
84
+ previousSessionItems.push({
85
+ title: session.childTitle,
86
+ iconType: session.childIconType,
87
+ onClick: function onClick() {
88
+ dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
89
+ }
90
+ });
91
+ }
92
+ var _loop2 = function _loop2() {
93
+ var entry = history[h];
94
+ previousSessionItems.push({
95
+ title: entry.title,
96
+ iconType: entry.iconType,
97
+ onClick: function onClick() {
98
+ dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
99
+ dispatchFn(goToFlyoutAction(entry.flyoutId, 'child'));
100
+ }
101
+ });
102
+ };
103
+ for (var h = history.length - 1; h >= 0; h--) {
104
+ _loop2();
105
+ }
106
+ if (!hasChildren) {
107
+ previousSessionItems.push({
108
+ title: mainTitle,
109
+ iconType: session.iconType,
110
+ onClick: function onClick() {
111
+ dispatchFn(goToFlyoutAction(mainFlyoutId, 'main'));
112
+ }
113
+ });
114
+ }
115
+ };
116
+ for (var i = previousSessionsInGroup.length - 1; i >= 0; i--) {
117
+ _loop();
118
+ }
119
+ return [].concat(_toConsumableArray(childItems), previousSessionItems);
58
120
  };
59
121
  var dispatch = function dispatch(action) {
60
122
  var nextState = flyoutManagerReducer(currentState, action);
@@ -65,7 +127,7 @@ function createStore() {
65
127
  // Recompute history items eagerly if sessions changed
66
128
  // This ensures stable references and avoids stale closures
67
129
  if (nextState.sessions !== previousSessions) {
68
- store.historyItems = computeHistoryItems();
130
+ store.historyItems = computeHistoryItems(dispatch);
69
131
 
70
132
  // Detect removed sessions and emit CLOSE_SESSION events
71
133
  var nextSessionIds = new Set(nextState.sessions.map(function (s) {
@@ -90,8 +152,8 @@ function createStore() {
90
152
  subscribe: subscribe,
91
153
  subscribeToEvents: subscribeToEvents,
92
154
  dispatch: dispatch,
93
- addFlyout: function addFlyout(flyoutId, title, level, size, minWidth) {
94
- return dispatch(addFlyoutAction(flyoutId, title, level, size, minWidth));
155
+ addFlyout: function addFlyout(flyoutId, title, level, size, historyKey, iconType, minWidth) {
156
+ return dispatch(addFlyoutAction(flyoutId, title, level, size, historyKey, iconType, minWidth));
95
157
  },
96
158
  closeFlyout: function closeFlyout(flyoutId) {
97
159
  return dispatch(closeFlyoutAction(flyoutId));
@@ -114,8 +176,8 @@ function createStore() {
114
176
  goBack: function goBack() {
115
177
  return dispatch(goBackAction());
116
178
  },
117
- goToFlyout: function goToFlyout(flyoutId) {
118
- return dispatch(goToFlyoutAction(flyoutId));
179
+ goToFlyout: function goToFlyout(flyoutId, level) {
180
+ return dispatch(goToFlyoutAction(flyoutId, level));
119
181
  },
120
182
  addUnmanagedFlyout: function addUnmanagedFlyout(flyoutId) {
121
183
  return dispatch(addUnmanagedFlyoutAction(flyoutId));
@@ -123,7 +185,7 @@ function createStore() {
123
185
  closeUnmanagedFlyout: function closeUnmanagedFlyout(flyoutId) {
124
186
  return dispatch(closeUnmanagedFlyoutAction(flyoutId));
125
187
  },
126
- historyItems: computeHistoryItems() // Initialize with current state
188
+ historyItems: computeHistoryItems(dispatch) // Initialize with current state
127
189
  };
128
190
  return store;
129
191
  }
@@ -0,0 +1,70 @@
1
+ var _excluded = ["titleId"];
2
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
4
+ /*
5
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
+ * or more contributor license agreements. Licensed under the Elastic License
7
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
8
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
9
+ * Side Public License, v 1.
10
+ */
11
+
12
+ import { useGeneratedHtmlId } from '../../services';
13
+ import { MENU_DISPLAY_ALWAYS, MENU_DISPLAY_AUTO } from './const';
14
+ import { useMemo } from 'react';
15
+ import classnames from 'classnames';
16
+
17
+ /**
18
+ * @internal
19
+ */
20
+
21
+ /**
22
+ * Hook to manage flyout menu state and rendering logic.
23
+ * Determines whether the menu should be rendered based on display mode
24
+ * and menu content, and computes the appropriate aria-labelledby value.
25
+ *
26
+ * @internal
27
+ */
28
+ export var useEuiFlyoutMenu = function useEuiFlyoutMenu(_ref) {
29
+ var _flyoutMenuProps$hist, _flyoutMenuProps$hist2, _flyoutMenuProps$cust, _flyoutMenuProps$cust2;
30
+ var _flyoutMenuProps = _ref.flyoutMenuProps,
31
+ flyoutMenuDisplayMode = _ref.flyoutMenuDisplayMode,
32
+ _ariaLabelledBy = _ref.ariaLabelledBy;
33
+ var generatedMenuId = useGeneratedHtmlId();
34
+ var _ref2 = _flyoutMenuProps || {},
35
+ _titleId = _ref2.titleId,
36
+ flyoutMenuProps = _objectWithoutProperties(_ref2, _excluded);
37
+ var hasMenu = !!_flyoutMenuProps;
38
+ var flyoutMenuId = useMemo(function () {
39
+ if (!hasMenu) return undefined;
40
+ return _titleId || generatedMenuId;
41
+ }, [hasMenu, _titleId, generatedMenuId]);
42
+
43
+ // Determine if the menu has any content
44
+ // hasBackButton or hasHistory or hasCustomActions or hasVisibleTitle
45
+ var menuHasContent = hasMenu && (!!flyoutMenuProps.showBackButton || ((_flyoutMenuProps$hist = (_flyoutMenuProps$hist2 = flyoutMenuProps.historyItems) === null || _flyoutMenuProps$hist2 === void 0 ? void 0 : _flyoutMenuProps$hist2.length) !== null && _flyoutMenuProps$hist !== void 0 ? _flyoutMenuProps$hist : 0) > 0 || ((_flyoutMenuProps$cust = (_flyoutMenuProps$cust2 = flyoutMenuProps.customActions) === null || _flyoutMenuProps$cust2 === void 0 ? void 0 : _flyoutMenuProps$cust2.length) !== null && _flyoutMenuProps$cust !== void 0 ? _flyoutMenuProps$cust : 0) > 0 ||
46
+ // Component defaults to hiding the title, so only explicit false means the title will be visible
47
+ !!(flyoutMenuProps.title && flyoutMenuProps.hideTitle === false));
48
+
49
+ // Determine if the menu should be rendered based on the display mode and menu content
50
+ var shouldRenderMenu = useMemo(function () {
51
+ if (!hasMenu) return false;
52
+ if (flyoutMenuDisplayMode === MENU_DISPLAY_ALWAYS) return true;
53
+ if (flyoutMenuDisplayMode === MENU_DISPLAY_AUTO) return menuHasContent;
54
+ return false;
55
+ }, [hasMenu, flyoutMenuDisplayMode, menuHasContent]);
56
+
57
+ // If the flyout menu is to be rendered, ensure the flyout has aria-labelledby referencing the menu's titleId
58
+ var ariaLabelledBy = useMemo(function () {
59
+ if (flyoutMenuId && shouldRenderMenu) {
60
+ return classnames(flyoutMenuId, _ariaLabelledBy);
61
+ }
62
+ return _ariaLabelledBy;
63
+ }, [flyoutMenuId, _ariaLabelledBy, shouldRenderMenu]);
64
+ return {
65
+ flyoutMenuId: flyoutMenuId,
66
+ flyoutMenuProps: flyoutMenuProps,
67
+ shouldRenderMenu: shouldRenderMenu,
68
+ ariaLabelledBy: ariaLabelledBy
69
+ };
70
+ };