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